/* 行云 Xíngyún — rice paper, ink and cinnabar */
:root {
  --paper: #f5eee0;
  --paper-2: #efe5d0;
  --card: #fffaf0;
  --line: #e2d5bb;
  --line-2: #d4c29f;
  --ink: #1f1b16;
  --ink-2: #4d4438;
  --ink-3: #85786a;
  --kai: #b3372a;        /* cinnabar seal */
  --kai-soft: #f3ddd5;
  --xing: #24606a;       /* indigo-teal ink */
  --xing-soft: #d7e8e7;
  --gold: #b08638;
  --good: #3c7d4a;
  --warn: #c07a1c;
  --bad: #b8322a;
  --accent: var(--kai);
  --accent-soft: var(--kai-soft);
  --grid: rgba(179, 55, 42, .38);
  --shadow: 0 1px 2px rgba(60, 40, 10, .06), 0 6px 20px rgba(60, 40, 10, .07);
  --radius: 16px;
  --kai-font: 'XY Kai', 'Kaiti SC', 'STKaiti', 'KaiTi', serif;
  --ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  --tabbar-h: 64px;
  color-scheme: light;
}
body[data-side="xing"] { --accent: var(--xing); --accent-soft: var(--xing-soft); --grid: rgba(36, 96, 106, .36); }
body[data-theme="night"] {
  --paper: #16140f; --paper-2: #1e1b15; --card: #23201a; --line: #3a342a; --line-2: #4d4536;
  --ink: #f1e8d6; --ink-2: #cfc3ad; --ink-3: #988c78;
  --kai: #e0634f; --kai-soft: #3c231d; --xing: #5bb2b5; --xing-soft: #18333a; --gold: #d0a85a;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .36 0 0 0 0 .2 0 0 0 .05 0'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)'/%3E%3C/svg%3E");
  color: var(--ink);
  font: 16px/1.5 var(--ui);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
.zh, .kai { font-family: var(--kai-font); }
.f-lk { font-family: 'XY XingKai', var(--kai-font); }
.f-xs { font-family: 'XY Xing', var(--kai-font); }
.f-cs { font-family: 'XY Cao', var(--kai-font); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: .01em; margin: 0 0 .4em; line-height: 1.2; }
h1 { font-size: 1.8rem; } h2 { font-size: 1.35rem; } h3 { font-size: 1.1rem; }
p { margin: 0 0 .8em; }
.muted { color: var(--ink-3); }
.small { font-size: .86rem; }
.hidden { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; margin-right: auto; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; }
.brand-zh { font-family: 'XY Xing', var(--kai-font); font-size: 1.7rem; line-height: 1; color: var(--ink); }
.brand-en { font-family: var(--serif); font-size: 1.05rem; color: var(--ink-2); letter-spacing: .04em; }
.sideswitch { display: flex; background: var(--paper-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.sideswitch a {
  display: flex; align-items: center; gap: 6px; padding: 5px 14px; border-radius: 999px;
  text-decoration: none; color: var(--ink-2); font-size: .88rem; transition: background .2s, color .2s;
}
.sideswitch a b { font-family: var(--kai-font); font-size: 1.15rem; font-weight: 400; }
.sideswitch a[data-side="xing"] b { font-family: 'XY Xing', var(--kai-font); }
.sideswitch a.on[data-side="kai"] { background: var(--kai); color: #fff; }
.sideswitch a.on[data-side="xing"] { background: var(--xing); color: #fff; }
.topicon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--line); background: var(--card); }
.topicon svg { width: 20px; height: 20px; fill: none; stroke: var(--ink-2); stroke-width: 1.8; stroke-linecap: round; }

main#view { max-width: 1080px; margin: 0 auto; padding: 18px 16px calc(var(--tabbar-h) + 30px + env(safe-area-inset-bottom)); outline: none; }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: center; gap: 4px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 5px 2px; border-radius: 12px; text-decoration: none; color: var(--ink-3); font-size: .7rem; letter-spacing: .02em;
}
.tabbar a .ti { font-family: var(--kai-font); font-size: 1.35rem; line-height: 1.15; }
.tabbar a.on { color: var(--accent); background: var(--accent-soft); }
.tabbar .badge { position: absolute; transform: translate(14px, -2px); background: var(--bad); color: #fff; border-radius: 999px; font-size: .62rem; padding: 0 5px; line-height: 15px; }

/* ---------- cards & layout ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 14px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }
.section-title { display: flex; align-items: baseline; gap: 10px; margin: 26px 2px 10px; }
.section-title h2 { margin: 0; }
.section-title .zh { color: var(--accent); font-size: 1.25rem; }
.section-title a { margin-left: auto; font-size: .9rem; color: var(--accent); text-decoration: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 12px; border: 1px solid var(--line-2);
  background: var(--card); color: var(--ink); cursor: pointer; text-decoration: none; font-weight: 550; font-size: .95rem;
  transition: transform .08s, background .2s, box-shadow .2s; user-select: none;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 3px 10px color-mix(in srgb, var(--accent) 30%, transparent); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--accent); }
.btn.sm { padding: 6px 12px; font-size: .85rem; border-radius: 10px; }
.btn.icon { padding: 8px; width: 42px; height: 42px; border-radius: 50%; }
.btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line-2); background: var(--card); border-radius: 999px; padding: 5px 12px;
  font-size: .84rem; cursor: pointer; color: var(--ink-2); white-space: nowrap;
}
.chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 12px; overflow: hidden; background: var(--card); }
.seg button { border: 0; background: none; padding: 7px 12px; cursor: pointer; font-size: .86rem; color: var(--ink-2); border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent); color: #fff; }
.seg button .zh { font-size: 1.05rem; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .74rem; font-weight: 600; letter-spacing: .03em; background: var(--accent-soft); color: var(--accent); }
.pill.gold { background: color-mix(in srgb, var(--gold) 18%, transparent); color: var(--gold); }
.pill.gray { background: var(--paper-2); color: var(--ink-3); }

input[type=text], input[type=search], select, textarea {
  font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line-2); border-radius: 12px; padding: 10px 14px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; }
label.field { display: block; margin-bottom: 12px; font-size: .88rem; color: var(--ink-2); }
label.field > span { display: block; margin-bottom: 4px; font-weight: 600; }

/* tones */
.t1 { color: #c0392b; } .t2 { color: #d07a12; } .t3 { color: #2a8a4a; } .t4 { color: #2b62b5; } .t5 { color: var(--ink-3); }
body[data-theme="night"] .t1 { color: #ff7b6b; } body[data-theme="night"] .t2 { color: #f2a74b; } body[data-theme="night"] .t3 { color: #6fcf8a; } body[data-theme="night"] .t4 { color: #7aa8ff; }

/* ---------- home ---------- */
.hero {
  position: relative; overflow: hidden; border-radius: 22px; padding: 28px 24px; margin-bottom: 16px;
  background: linear-gradient(135deg, #2b241b, #3d3023 60%, #5a2c22);
  color: #f7efe0; box-shadow: var(--shadow);
}
.hero.has-banner { background-size: cover; background-position: center; }
.hero::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(20,15,10,.82), rgba(20,15,10,.35) 70%, rgba(20,15,10,.1)); }
.hero > * { position: relative; z-index: 1; }
.hero h1 { font-size: 2rem; margin-bottom: 4px; }
.hero .hz { font-family: 'XY Xing', var(--kai-font); font-size: 3.4rem; line-height: 1; margin-bottom: 6px; }
.hero p { max-width: 520px; color: #e9dcc5; }
.hero .stats { display: flex; gap: 22px; margin-top: 12px; flex-wrap: wrap; }
.hero .stats div { font-size: .8rem; color: #d8c8ad; }
.hero .stats b { display: block; font-size: 1.5rem; color: #fff; font-family: var(--serif); }

.door {
  position: relative; display: block; text-decoration: none; overflow: hidden;
  border-radius: 20px; padding: 22px 22px 18px; min-height: 210px; border: 1px solid var(--line); box-shadow: var(--shadow);
  background: var(--card); transition: transform .15s, box-shadow .15s;
}
.door:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(60,40,10,.12); }
.door .big { position: absolute; right: 8px; bottom: -28px; font-size: 11rem; line-height: 1; opacity: .13; pointer-events: none; }
.door.d-kai .big { font-family: var(--kai-font); color: var(--kai); }
.door.d-xing .big { font-family: 'XY Xing', var(--kai-font); color: var(--xing); }
.door h2 { font-size: 1.5rem; margin-bottom: 2px; }
.door .zh-t { font-size: 1.05rem; margin-bottom: 8px; }
.door.d-kai .zh-t { color: var(--kai); font-family: var(--kai-font); }
.door.d-xing .zh-t { color: var(--xing); font-family: 'XY XingKai', var(--kai-font); font-size: 1.3rem; }
.door p { color: var(--ink-2); max-width: 340px; font-size: .95rem; }
.door .go { display: inline-flex; gap: 6px; align-items: center; font-weight: 650; }
.door.d-kai .go { color: var(--kai); } .door.d-xing .go { color: var(--xing); }
.progressbar { height: 7px; border-radius: 99px; background: var(--paper-2); overflow: hidden; margin: 10px 0 6px; max-width: 320px; }
.progressbar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s; }
.door.d-kai .progressbar > i { background: var(--kai); } .door.d-xing .progressbar > i { background: var(--xing); }

.todo { display: flex; align-items: center; gap: 14px; padding: 14px 16px; text-decoration: none; }
.todo .ic { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font-size: 1.7rem; flex: none; background: var(--accent-soft); color: var(--accent); font-family: var(--kai-font); }
.todo .ic.x { background: var(--xing-soft); color: var(--xing); font-family: 'XY Xing', var(--kai-font); }
.todo .ic.k { background: var(--kai-soft); color: var(--kai); }
.todo h3 { margin: 0; font-size: 1.02rem; font-family: var(--ui); font-weight: 650; }
.todo p { margin: 2px 0 0; font-size: .86rem; color: var(--ink-3); }
.todo .arrow { margin-left: auto; color: var(--ink-3); font-size: 1.3rem; }

.cotd { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; }
.cotd div { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 8px 4px 6px; }
.cotd svg { overflow: visible; }
.cotd .g { font-size: 3.2rem; line-height: 1.15; display: block; }
.cotd small { color: var(--ink-3); font-size: .72rem; }

/* ---------- library ---------- */
.libbar { display: grid; gap: 10px; margin-bottom: 14px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.tile {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 8px 4px 6px; text-decoration: none;
  aspect-ratio: 1 / 1.12; transition: transform .1s, border-color .15s;
}
.tile:hover { border-color: var(--accent); transform: translateY(-1px); }
.tile .g { font-size: 2.5rem; line-height: 1.1; font-family: var(--kai-font); }
.tile.xing .g { font-family: 'XY XingKai', var(--kai-font); font-size: 2.6rem; }
.tile .py { font-size: .74rem; color: var(--ink-3); margin-top: 2px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .dot { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; }
.tile .dot.l1 { background: var(--warn); } .tile .dot.l2 { background: var(--good); } .tile .dot.l3 { background: var(--gold); box-shadow: 0 0 0 2px color-mix(in srgb, var(--gold) 30%, transparent); }
.tile .star { position: absolute; top: 3px; left: 6px; font-size: .7rem; color: var(--gold); }
.loadmore { display: block; margin: 16px auto; }

/* ---------- character page ---------- */
.charhead { display: grid; grid-template-columns: minmax(0, 360px) 1fr; gap: 20px; align-items: start; }
@media (max-width: 760px) { .charhead { grid-template-columns: 1fr; } }
.stage { position: relative; width: 100%; aspect-ratio: 1; background: var(--card); border: 1px solid var(--line-2); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; touch-action: none; }
.stage > svg.gridbg, .stage > canvas, .stage > .hw, .stage > svg.layer { position: absolute; inset: 0; width: 100%; height: 100%; }
.stage > .hw svg { width: 100%; height: 100%; display: block; }
.stage .corner { position: absolute; top: 8px; left: 10px; font-size: .75rem; color: var(--ink-3); z-index: 3; pointer-events: none; }
.stagectl { display: flex; justify-content: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.charinfo .bigpy { font-size: 1.9rem; font-family: var(--serif); font-weight: 600; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.charinfo .meaning { font-size: 1.1rem; color: var(--ink-2); margin: 4px 0 12px; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; margin: 10px 0 14px; }
.fact { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
.fact small { display: block; font-size: .7rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }
.fact b { font-weight: 600; font-size: 1rem; }
.fact b.zh { font-size: 1.3rem; font-weight: 400; }
.fact a { text-decoration: none; }
.speak { border: 1px solid var(--line-2); background: var(--card); border-radius: 50%; width: 38px; height: 38px; display: inline-grid; place-items: center; cursor: pointer; }
.speak svg { width: 18px; height: 18px; fill: var(--accent); }

.strip { display: flex; gap: 6px; overflow-x: auto; padding: 4px 2px 10px; scroll-snap-type: x proximity; }
.strip .st { flex: none; width: 74px; text-align: center; cursor: pointer; scroll-snap-align: start; }
.strip .st svg { width: 74px; height: 74px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; display: block; }
.strip .st.on svg { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.strip .st span { display: block; font-size: .72rem; color: var(--ink-2); margin-top: 3px; line-height: 1.2; }
.strip .st span b { font-family: var(--kai-font); font-weight: 400; font-size: .9rem; color: var(--ink); }

.words { display: grid; gap: 6px; }
.word { display: flex; align-items: baseline; gap: 10px; padding: 8px 12px; border-radius: 12px; background: var(--paper); border: 1px solid var(--line); text-decoration: none; }
.word .w { font-family: var(--kai-font); font-size: 1.45rem; }
.word .w.f-lk { font-family: 'XY XingKai', var(--kai-font); font-size: 1.7rem; }
.word .py { color: var(--ink-2); font-size: .92rem; }
.word .gl { color: var(--ink-3); font-size: .86rem; margin-left: auto; text-align: right; max-width: 50%; }
.comp a { font-family: var(--kai-font); font-size: 1.4rem; text-decoration: none; color: var(--accent); padding: 0 3px; }

/* ---------- practice ---------- */
.practice { max-width: 560px; margin: 0 auto; }
.prompt { text-align: center; margin-bottom: 10px; }
.prompt .py { font-size: 1.6rem; font-family: var(--serif); font-weight: 600; }
.prompt .mn { color: var(--ink-2); }
.prompt .ex { color: var(--ink-3); font-size: .92rem; margin-top: 2px; }
.prompt .ex b { font-family: var(--kai-font); font-weight: 400; font-size: 1.15rem; color: var(--ink); }
.modebar { display: flex; justify-content: center; gap: 4px; margin: 0 0 12px; flex-wrap: wrap; }
.modebar button { border: 1px solid var(--line-2); background: var(--card); border-radius: 999px; padding: 6px 12px; font-size: .82rem; cursor: pointer; color: var(--ink-2); }
.modebar button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.modebar button.done::before { content: '✓ '; }
.practice .stage { max-width: min(520px, calc(100vh - 330px)); min-width: 260px; margin: 0 auto; }
.feedback { text-align: center; min-height: 1.6em; margin-top: 8px; font-weight: 600; transition: color .2s; }
.feedback.good { color: var(--good); } .feedback.bad { color: var(--bad); } .feedback.info { color: var(--ink-2); }
.queuebar { display: flex; justify-content: center; gap: 5px; margin-bottom: 10px; flex-wrap: wrap; }
.queuebar i { width: 26px; height: 5px; border-radius: 9px; background: var(--line); }
.queuebar i.done { background: var(--good); } .queuebar i.cur { background: var(--accent); }

.result { text-align: center; animation: pop .35s cubic-bezier(.2,1.4,.4,1); }
@keyframes pop { from { transform: scale(.92); opacity: 0; } to { transform: none; opacity: 1; } }
.result .grade { font-family: var(--serif); font-size: 1.6rem; font-weight: 600; margin: 6px 0 2px; }
.stars { font-size: 1.7rem; letter-spacing: 4px; color: var(--gold); }
.stars .off { color: var(--line-2); }
.result .compare { display: flex; justify-content: center; gap: 12px; margin: 12px 0; }
.result .compare figure { margin: 0; }
.result .compare figcaption { font-size: .75rem; color: var(--ink-3); }
.result .compare canvas, .result .compare img, .result .compare svg { width: min(170px, 40vw); height: min(170px, 40vw); border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.issues { text-align: left; margin: 10px auto; max-width: 460px; display: grid; gap: 6px; }
.issue { display: flex; gap: 10px; align-items: flex-start; padding: 9px 12px; border-radius: 12px; background: var(--paper); border: 1px solid var(--line); font-size: .92rem; }
.issue .k { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: .75rem; font-weight: 700; color: #fff; background: var(--warn); }
.issue.bad .k { background: var(--bad); } .issue.good .k { background: var(--good); } .issue.tip .k { background: var(--xing); }
.legend { display: flex; justify-content: center; gap: 14px; font-size: .78rem; color: var(--ink-3); margin-top: 6px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }

/* ---------- lessons ---------- */
.course { display: grid; gap: 10px; }
.lesson-card { display: flex; gap: 14px; align-items: center; padding: 14px 16px; text-decoration: none; }
.lesson-card .num { flex: none; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--line-2); font-family: var(--serif); font-weight: 700; color: var(--ink-3); background: var(--paper); }
.lesson-card.done .num { background: var(--accent); border-color: var(--accent); color: #fff; }
.lesson-card.next .num { border-color: var(--accent); color: var(--accent); }
.lesson-card h3 { margin: 0; font-family: var(--ui); font-weight: 650; font-size: 1rem; }
.lesson-card h3 .zh { color: var(--accent); font-weight: 400; margin-left: 6px; font-size: 1.1rem; }
.lesson-card p { margin: 2px 0 0; font-size: .86rem; color: var(--ink-3); }
.lesson-card .peek { margin-left: auto; font-size: 1.9rem; color: var(--ink-2); flex: none; }
.lesson h1 .zh { color: var(--accent); margin-left: 8px; }
.lesson .body { font-size: 1.02rem; line-height: 1.65; }
.lesson .body b.zh, .lesson .body .zh { font-size: 1.2em; }
.lesson .tipbox { border-left: 4px solid var(--accent); background: var(--accent-soft); padding: 12px 14px; border-radius: 0 12px 12px 0; margin: 12px 0; }
.examples { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 12px 0; }
.example { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 8px; text-align: center; cursor: pointer; }
.example .mini { width: 100%; aspect-ratio: 1; position: relative; }
.example .mini > * { position: absolute; inset: 0; width: 100%; height: 100%; }
.example .cap { font-size: .8rem; color: var(--ink-2); margin-top: 4px; }
.example .cap b { font-family: var(--kai-font); font-weight: 400; font-size: 1rem; }
.pairs { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin: 12px 0; }
.pair { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 8px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; text-align: center; cursor: pointer; }
.pair .mini { aspect-ratio: 1; position: relative; background: var(--card); border-radius: 10px; border: 1px solid var(--line); }
.pair .mini > * { position: absolute; inset: 0; width: 100%; height: 100%; }
.pair small { grid-column: span 2; font-size: .78rem; color: var(--ink-2); }
.pair small b { font-family: var(--kai-font); font-weight: 400; font-size: 1rem; }

/* ---------- cursive page ---------- */
.stylebar { display: flex; justify-content: center; margin-bottom: 10px; }
.morph { display: flex; align-items: center; gap: 10px; margin: 12px auto 0; max-width: 360px; }
.morph input { flex: 1; accent-color: var(--accent); }
.morph span { font-size: .9rem; color: var(--ink-3); }
.flowfacts { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 12px; }
.tipcard { border-left: 4px solid var(--xing); padding: 10px 14px; background: var(--xing-soft); border-radius: 0 12px 12px 0; margin-bottom: 8px; font-size: .94rem; }
.tipcard b.zh { font-size: 1.15rem; font-weight: 400; }

.phrase-stage { position: relative; width: 100%; background: var(--card); border: 1px solid var(--line-2); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; touch-action: none; }
.phrase-stage > canvas, .phrase-stage > svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.phrases { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.phrase { padding: 10px 14px; text-decoration: none; display: block; }
.phrase .p { font-family: 'XY XingKai', var(--kai-font); font-size: 1.8rem; line-height: 1.2; }
.phrase small { color: var(--ink-3); display: block; }

/* ---------- me ---------- */
.statgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.stat b { display: block; font-family: var(--serif); font-size: 1.7rem; }
.stat small { color: var(--ink-3); font-size: .8rem; }
.heat { display: grid; grid-template-columns: repeat(14, 1fr); gap: 4px; max-width: 420px; }
.heat i { aspect-ratio: 1; border-radius: 4px; background: var(--paper-2); border: 1px solid var(--line); }
.heat i.h1 { background: color-mix(in srgb, var(--accent) 30%, var(--paper)); }
.heat i.h2 { background: color-mix(in srgb, var(--accent) 60%, var(--paper)); }
.heat i.h3 { background: var(--accent); }
.journal { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.jitem { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 6px; text-align: center; font-size: .74rem; color: var(--ink-3); }
.jitem img { width: 100%; aspect-ratio: 1; border-radius: 8px; background: var(--paper); display: block; }
.jitem b { color: var(--ink); font-family: var(--kai-font); font-weight: 400; font-size: 1rem; }

/* ---------- toast ---------- */
#toast { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none; background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 999px; font-size: .9rem; transition: all .25s; z-index: 50; box-shadow: var(--shadow); max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%); }

.empty { text-align: center; padding: 40px 10px; color: var(--ink-3); }
.empty .zh { font-size: 3rem; display: block; color: var(--line-2); }
.back { display: inline-flex; align-items: center; gap: 4px; text-decoration: none; color: var(--ink-3); font-size: .9rem; margin-bottom: 10px; }
.loading { text-align: center; padding: 50px; color: var(--ink-3); }
.loading::before { content: '墨'; display: block; font-family: var(--kai-font); font-size: 2.6rem; color: var(--accent); animation: breathe 1.4s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .3; transform: scale(.92); } }

/* ---------- worksheets ---------- */
#print-root { display: none; }
.sheet-preview { background: #fff; color: #111; border-radius: 6px; box-shadow: var(--shadow); padding: 0; overflow: hidden; margin: 12px auto; max-width: 820px; }
.sheet-preview svg { display: block; width: 100%; height: auto; }
@media print {
  @page { size: A4; margin: 0; }
  body { background: #fff !important; }
  #app, #toast { display: none !important; }
  #print-root { display: block; }
  #print-root .page { width: 210mm; height: 297mm; page-break-after: always; break-after: page; overflow: hidden; }
  #print-root .page svg { width: 210mm; height: 297mm; display: block; }
}

@media (max-width: 560px) {
  .brand-en { display: none; }
  .sideswitch a span { display: none; }
  .sideswitch a { padding: 5px 16px; }
  .hero { padding: 22px 18px; }
  .hero h1 { font-size: 1.5rem; }
  .hero::after { background: linear-gradient(180deg, rgba(20,15,10,.8), rgba(20,15,10,.62)); }
  .hero .stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; }
  .hero .hz { font-size: 2.8rem; }
  h1 { font-size: 1.5rem; }
  .tile .g { font-size: 2.2rem; }
  .card { padding: 14px; }
}
@media (min-width: 1000px) {
  .tabbar { top: auto; }
}
