@font-face {
  font-family: "Noto Serif Tibetan";
  src: url("./fonts/NotoSerifTibetan-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* ------------------------------------------------------------------ */
/* Tokens. Light theme: rice paper, burgundy, gold, deep blue.          */
/* ------------------------------------------------------------------ */
:root {
  color-scheme: light;
  --tib-font: "Noto Serif Tibetan", "Noto Sans Tibetan", "Kailasa", "Microsoft Himalaya", "Jomolhari", sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Charter, "Times New Roman", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --clouds: url("./img/bg-clouds.webp");
  --clouds-opacity: .62;
  --clouds-filter: none;

  --bg: #efe6d2; --bg-glow: #f8f1e1;
  --panel: #fcf8ee; --panel-border: #e2d4b6; --panel-shadow: #5a3a1a1a; --topbar: #f4ecda;
  --text: #2a2730; --muted: #6d6459; --fine: #978d7f; --heading: #1f3a5f; --label: #a9781c;
  --primary: #7a1f2e; --on-primary: #f5d98f; --brand: #6e1a28; --blue: #1f3a5f;
  --gold: #c99a2e; --goldsoft: #f5e5b6; --gold-text: #8a5f12; --gold-line: #d9b65c;
  --green: #2f7a5f; --rose: #a53d4a; --focus: #3b6fb6;
  --border: #d6c6a4; --sep: #ece3cd; --input-bg: #fffdf6;
  --badge-bg: #e3efe6; --badge-text: #22604a; --badge-grey-bg: #f0d4da; --badge-grey-text: #6e1a28; --badge-blue-bg: #dbe4f1; --badge-blue-text: #1f3a5f;
  --switch-bg: #1f3a5f; --switch-border: #1f3a5f; --switch-text: #c6d2e6; --switch-on-bg: #fcf8ee; --switch-on-text: #1f3a5f;
  --answer-bg: #f3ecda; --answer-border: #c99a2e; --answer-ok-bg: #e9f2e6;
  --rack-bg: #eee2c2; --rack-border: #dcc68f;
  --tile-1: #f9e3a0; --tile-2: #d8b24e; --tile-border: #7a1f2e; --tile-shadow: #8e6a1c; --tile-text: #3a2412; --tile-glow: #ffe7a3;
  --placed-1: #e2f0e2; --placed-2: #c6e0cb; --placed-border: #3f8a68; --placed-shadow: #2f6b50;
  --wrong-1: #fbe3e5; --wrong-2: #f3c9ce; --wrong-border: #b8505e; --wrong-shadow: #8e3a46;
  --feedback-bg: #f1e9d6; --feedback-border: #e0d2b1; --feedback-text: #4d453a;
  --good-bg: #e6f2e6; --good-border: #b3d6bb; --good-text: #1f5b44;
  --bad-bg: #fbe9ea; --bad-border: #ebc3c8; --bad-text: #8f2f3e;
  --chip-bg: #fdf8ea; --chip-border: #7a1f2e; --chip-known-bg: #edf5ee; --chip-known-border: #3f8a68; --chip-due-border: #3b6fb6; --chip-due-bg: #e9eff8; --dot: #c99a2e;
  --lesson-bg: #f6ead0; --lesson-border: #ddc58e; --lesson-strong: #8a5f12; --lesson-tib: #6e1a28;
  --note-bg: #e9eef5; --note-border: #c6d3e4; --note-text: #1f3a5f;
  --meter-bg: #e4d9bf; --stat-bg: #f6f0e0; --stat-border: #e6dabd;
  --option-bg: #fdf8ea; --option-border: #dcc68f;
  --toast-bg: #7a1f2e; --toast-text: #fbeecb;
  --banner-bg: #f2dc9c; --banner-border: #c99a2e; --banner-text: #4a3412;
}

/* Dark theme: night sky, burgundy and gold. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --clouds-opacity: .22;
    --clouds-filter: invert(1) hue-rotate(180deg);
    --bg: #131826; --bg-glow: #1d2236;
    --panel: #1a2032; --panel-border: #2c3450; --panel-shadow: #00000055; --topbar: #161c2c;
    --text: #ece5d6; --muted: #a59d8d; --fine: #837b6e; --heading: #cdd8ea; --label: #d8ad4a;
    --primary: #9b2f41; --on-primary: #f7dc98; --brand: #e8c06a; --blue: #9fb6d8;
    --gold: #d8ad4a; --goldsoft: #3a2f16; --gold-text: #f0d08a; --gold-line: #8a6a22;
    --green: #4fae8f; --rose: #e0808c; --focus: #7aa7e6;
    --border: #3a4260; --sep: #262e46; --input-bg: #11172a;
    --badge-bg: #1e3a32; --badge-text: #9fe0c4; --badge-grey-bg: #4a2230; --badge-grey-text: #f2c6cf; --badge-blue-bg: #223558; --badge-blue-text: #b7cdf0;
    --switch-bg: #0f1526; --switch-border: #2c3450; --switch-text: #9aa8bb; --switch-on-bg: #e8c06a; --switch-on-text: #1a2032;
    --answer-bg: #1d2438; --answer-border: #a9843a; --answer-ok-bg: #172e28;
    --rack-bg: #231d12; --rack-border: #4d3d18;
    --tile-1: #9a7628; --tile-2: #6b4f14; --tile-border: #d8ad4a; --tile-shadow: #2a1e08; --tile-text: #fff0c2; --tile-glow: #6b5527;
    --placed-1: #1f3a2f; --placed-2: #193027; --placed-border: #4f9a7f; --placed-shadow: #0f2019;
    --wrong-1: #3a2027; --wrong-2: #301a20; --wrong-border: #8a4a58; --wrong-shadow: #1f0f13;
    --feedback-bg: #1f2638; --feedback-border: #2c3450; --feedback-text: #c7cdd9;
    --good-bg: #16302a; --good-border: #2f6a55; --good-text: #8fd6b6;
    --bad-bg: #3a2027; --bad-border: #6b3440; --bad-text: #f0a0ad;
    --chip-bg: #1f2638; --chip-border: #c98a3a; --chip-known-bg: #1a2f2a; --chip-known-border: #2f6a55; --chip-due-border: #4b6fa8; --chip-due-bg: #1d2c48; --dot: #d8ad4a;
    --lesson-bg: #2a2416; --lesson-border: #5a4a2a; --lesson-strong: #e0bd75; --lesson-tib: #f3e2bf;
    --note-bg: #1b2a44; --note-border: #2f4670; --note-text: #b7cdf0;
    --meter-bg: #2c3450; --stat-bg: #161c2c; --stat-border: #2c3450;
    --option-bg: #1f2638; --option-border: #3a4260;
    --toast-bg: #e8c06a; --toast-text: #1a2032;
    --banner-bg: #3a2f16; --banner-border: #a9843a; --banner-text: #f0d08a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --clouds-opacity: .22;
  --clouds-filter: invert(1) hue-rotate(180deg);
  --bg: #131826; --bg-glow: #1d2236;
  --panel: #1a2032; --panel-border: #2c3450; --panel-shadow: #00000055; --topbar: #161c2c;
  --text: #ece5d6; --muted: #a59d8d; --fine: #837b6e; --heading: #cdd8ea; --label: #d8ad4a;
  --primary: #9b2f41; --on-primary: #f7dc98; --brand: #e8c06a; --blue: #9fb6d8;
  --gold: #d8ad4a; --goldsoft: #3a2f16; --gold-text: #f0d08a; --gold-line: #8a6a22;
  --green: #4fae8f; --rose: #e0808c; --focus: #7aa7e6;
  --border: #3a4260; --sep: #262e46; --input-bg: #11172a;
  --badge-bg: #1e3a32; --badge-text: #9fe0c4; --badge-grey-bg: #4a2230; --badge-grey-text: #f2c6cf; --badge-blue-bg: #223558; --badge-blue-text: #b7cdf0;
  --switch-bg: #0f1526; --switch-border: #2c3450; --switch-text: #9aa8bb; --switch-on-bg: #e8c06a; --switch-on-text: #1a2032;
  --answer-bg: #1d2438; --answer-border: #a9843a; --answer-ok-bg: #172e28;
  --rack-bg: #231d12; --rack-border: #4d3d18;
  --tile-1: #9a7628; --tile-2: #6b4f14; --tile-border: #d8ad4a; --tile-shadow: #2a1e08; --tile-text: #fff0c2; --tile-glow: #6b5527;
  --placed-1: #1f3a2f; --placed-2: #193027; --placed-border: #4f9a7f; --placed-shadow: #0f2019;
  --wrong-1: #3a2027; --wrong-2: #301a20; --wrong-border: #8a4a58; --wrong-shadow: #1f0f13;
  --feedback-bg: #1f2638; --feedback-border: #2c3450; --feedback-text: #c7cdd9;
  --good-bg: #16302a; --good-border: #2f6a55; --good-text: #8fd6b6;
  --bad-bg: #3a2027; --bad-border: #6b3440; --bad-text: #f0a0ad;
  --chip-bg: #1f2638; --chip-border: #c98a3a; --chip-known-bg: #1a2f2a; --chip-known-border: #2f6a55; --chip-due-border: #4b6fa8; --chip-due-bg: #1d2c48; --dot: #d8ad4a;
  --lesson-bg: #2a2416; --lesson-border: #5a4a2a; --lesson-strong: #e0bd75; --lesson-tib: #f3e2bf;
  --note-bg: #1b2a44; --note-border: #2f4670; --note-text: #b7cdf0;
  --meter-bg: #2c3450; --stat-bg: #161c2c; --stat-border: #2c3450;
  --option-bg: #1f2638; --option-border: #3a4260;
  --toast-bg: #e8c06a; --toast-text: #1a2032;
  --banner-bg: #3a2f16; --banner-border: #a9843a; --banner-text: #f0d08a;
}

/* ------------------------------------------------------------------ */
/* Base                                                                */
/* ------------------------------------------------------------------ */
* { box-sizing: border-box; }
html { min-height: 100%; -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: radial-gradient(ellipse at top left, var(--bg-glow) 0, transparent 55%), var(--bg); color: var(--text); font-family: var(--sans); line-height: 1.45; overflow-x: hidden; }
button { font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; color: inherit; }
a { color: var(--brand); }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tib { font-family: var(--tib-font); }
select, input[type="text"], input[type="search"], textarea { color: var(--text); background: var(--input-bg); }
h1, h2, h3, .prompt, .brand-title, .stat .num { font-family: var(--serif); }

/* faint cloud ornament behind the content */
.page { position: relative; }
.page::before { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; background: var(--clouds) center top / cover no-repeat; opacity: var(--clouds-opacity); filter: var(--clouds-filter); }

/* ------------------------------------------------------------------ */
/* Header                                                              */
/* ------------------------------------------------------------------ */
.header { background: var(--panel); border-bottom: 1px solid var(--panel-border); position: sticky; top: 0; z-index: 5; box-shadow: 0 2px 12px #3a24101a; }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: min(860px, calc(100% - 24px)); margin: 0 auto; padding: 10px 0 8px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--brand); min-width: 0; }
.seal { flex: 0 0 auto; display: block; width: 44px; height: 44px; border-radius: 11px; box-shadow: 0 2px 6px #0c162c40; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-title { font-weight: 700; font-size: 1.15rem; line-height: 1.1; letter-spacing: -.01em; }
.brand-sub { font-size: .72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-tools { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.lang-switch select { min-height: 44px; max-width: 120px; border: 1px solid var(--border); border-radius: 10px; padding: 0 10px; font: inherit; background: var(--input-bg); color: var(--text); }
.theme-toggle { width: 44px; height: 44px; padding: 0; border: 1px solid var(--border); border-radius: 10px; background: var(--input-bg); color: var(--gold-text); display: grid; place-items: center; }
.theme-toggle svg { grid-area: 1 / 1; }
.theme-toggle .icon-moon { display: none; }
.theme-toggle[aria-pressed="true"] .icon-sun { display: none; }
.theme-toggle[aria-pressed="true"] .icon-moon { display: block; }
.menu-toggle { width: 44px; height: 44px; padding: 0; border: 1.5px solid var(--primary); border-radius: 10px; background: var(--input-bg); color: var(--primary); display: grid; place-items: center; }
.menu-toggle svg { grid-area: 1 / 1; }
.menu-toggle .icon-close { display: none; }
.menu-toggle[aria-expanded="true"] { background: var(--primary); color: var(--on-primary); }
.menu-toggle[aria-expanded="true"] .icon-menu { display: none; }
.menu-toggle[aria-expanded="true"] .icon-close { display: block; }
.section-title { display: none; font-family: var(--serif); font-weight: 700; font-size: .98rem; line-height: 1.15; color: var(--brand); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu { position: absolute; right: max(12px, calc((100% - 860px) / 2)); top: calc(100% + 6px); min-width: 230px; display: flex; flex-direction: column; padding: 6px; background: var(--panel); border: 1px solid var(--panel-border); border-top: 3px solid var(--gold); border-radius: 14px; box-shadow: 0 18px 48px var(--panel-shadow); z-index: 6; animation: rise .18s ease-out; }
.menu a { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 8px 14px; border-radius: 10px; text-decoration: none; color: var(--heading); font-weight: 700; font-size: .95rem; transition: background .15s ease; }
.menu a svg { flex: 0 0 auto; color: var(--gold-text); }
.menu a:hover { background: var(--goldsoft); }
.menu a.active { background: var(--primary); color: var(--on-primary); }
.menu a.active svg { color: var(--on-primary); }
.menu .menu-report { border-top: 1px solid var(--sep); margin-top: 4px; padding-top: 10px; border-radius: 0 0 10px 10px; }
.report-form .cats { display: grid; gap: 6px; margin: 4px 0 12px; }
.report-form .cat { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--input-bg); cursor: pointer; }
.report-form .cat:has(input:checked) { border-color: var(--primary); background: var(--goldsoft); }
.report-form .cat input { accent-color: var(--primary); width: 18px; height: 18px; margin: 0; }

/* ------------------------------------------------------------------ */
/* Page & panels                                                       */
/* ------------------------------------------------------------------ */
.page { width: min(860px, calc(100% - 24px)); margin: 0 auto; padding: 16px 0 48px; }
.panel { background: var(--panel); border: 1px solid var(--panel-border); box-shadow: 0 18px 48px var(--panel-shadow); border-radius: 22px; overflow: hidden; margin-bottom: 16px; }
.panel-body { padding: 18px 16px; }
.topbar { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 14px 16px 14px; background: var(--topbar); border-bottom: 1px solid var(--sep); }
.lesson-meter { position: absolute; left: 0; right: 0; bottom: -1px; height: 4px; background: var(--meter-bg); }
.lesson-meter > div { height: 100%; width: 0; background: linear-gradient(90deg, #b8862a, #e6c266); transition: width .4s ease; }
.progressline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: .85rem; }
.badge { background: var(--badge-bg); color: var(--badge-text); border-radius: 999px; font-size: .74rem; padding: 6px 11px; font-weight: 750; }
.badge.gold { background: var(--goldsoft); color: var(--gold-text); }
.badge.reason { background: var(--badge-grey-bg); color: var(--badge-grey-text); }
.badge.blue { background: var(--badge-blue-bg); color: var(--badge-blue-text); }
.switch { display: flex; gap: 2px; border: 1px solid var(--switch-border); background: var(--switch-bg); border-radius: 12px; padding: 3px; }
.switch button { font-size: .8rem; color: var(--switch-text); background: transparent; border: 0; padding: 8px 12px; min-height: 40px; border-radius: 9px; font-weight: 750; transition: background .15s ease, color .15s ease; }
.switch button.selected { background: var(--switch-on-bg); color: var(--switch-on-text); box-shadow: 0 2px 8px #00000030; }
.label { font-size: .72rem; letter-spacing: .12em; color: var(--label); text-transform: uppercase; font-weight: 850; }
.prompt { font-weight: 700; font-size: clamp(1.3rem, 4.5vw, 1.9rem); line-height: 1.3; margin: 6px 0 4px; color: var(--brand); overflow-wrap: anywhere; }
.prompt.tib { font-family: var(--tib-font); font-weight: 400; font-size: clamp(1.7rem, 6vw, 2.4rem); line-height: 1.9; }
.helper { margin: 0; color: var(--muted); font-size: .88rem; }
.fine { font-size: .74rem; color: var(--fine); margin: 6px 0 0; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 18px 0 8px; }
.section-head h2 { margin: 0; font-family: var(--sans); font-size: .9rem; letter-spacing: .02em; color: var(--heading); }
.counter { color: var(--muted); font-size: .76rem; }

/* ------------------------------------------------------------------ */
/* Tiles                                                               */
/* ------------------------------------------------------------------ */
.answer, .rack { display: flex; align-content: center; align-items: center; flex-wrap: wrap; gap: 10px; border-radius: 16px; padding: 12px; min-height: 100px; }
.answer { background: var(--answer-bg); border: 2px solid var(--answer-border); box-shadow: inset 0 3px 10px #4a30102a, inset 0 0 0 3px #ffffff40; transition: border-color .2s ease, background .2s ease; }
.rack { background: var(--rack-bg); border: 2px solid var(--rack-border); box-shadow: inset 0 2px 6px #4a301014; }
.placeholder { font-size: .86rem; color: var(--muted); padding: 6px; }
.tile-wrap { position: relative; display: inline-flex; }
.tile { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; position: relative; user-select: none; -webkit-user-select: none; touch-action: manipulation; white-space: nowrap; line-height: 2.1; min-height: 64px; min-width: 56px; padding: 4px 14px 2px; border-radius: 14px; font-family: var(--tib-font); font-size: clamp(1.45rem, 5.5vw, 2rem); color: var(--tile-text); border: 2px solid var(--tile-border); background: linear-gradient(160deg, var(--tile-1), var(--tile-2)); box-shadow: inset 0 1px 0 #ffffff80, inset 0 -2px 0 #00000012, 0 5px 0 var(--tile-shadow), 0 8px 14px #3a24101f; transition: transform .12s ease, box-shadow .12s ease; animation: tile-in .22s ease-out; }
.tile:active { transform: translateY(3px); box-shadow: inset 0 1px 0 #ffffff80, 0 2px 0 var(--tile-shadow); }
.tile.new { box-shadow: inset 0 1px 0 #ffffff80, 0 5px 0 var(--tile-shadow), 0 0 0 3px var(--tile-glow); }
.tile.with-wylie { line-height: 1.7; padding-bottom: 4px; }
.tile-wylie { font-family: var(--sans); font-size: .72rem; line-height: 1.1; color: var(--muted); margin-top: -2px; }
.answer .tile { background: linear-gradient(160deg, var(--placed-1), var(--placed-2)); border-color: var(--placed-border); box-shadow: inset 0 1px 0 #ffffff60, 0 5px 0 var(--placed-shadow); color: var(--text); }
.answer .tile.wrong { background: linear-gradient(160deg, var(--wrong-1), var(--wrong-2)); border-color: var(--wrong-border); box-shadow: 0 5px 0 var(--wrong-shadow); animation: shake .3s ease; }
.tile.hinted { outline: 4px solid var(--gold); outline-offset: 2px; animation: pulse 1.2s ease-in-out infinite; }
.tile-help { position: absolute; top: -8px; right: -8px; width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid var(--gold-line); background: var(--primary); color: var(--on-primary); font: 700 .8rem var(--sans); display: grid; place-items: center; padding: 0; box-shadow: 0 2px 4px #0003; }
.tile-help::before { content: ""; position: absolute; inset: -8px; }
.answer.correct { border-color: var(--green); background: var(--answer-ok-bg); animation: glow 1.4s ease-out; }
.feedback { margin: 14px 0 0; min-height: 44px; border: 1px solid var(--feedback-border); border-radius: 12px; background: var(--feedback-bg); padding: 11px 13px; color: var(--feedback-text); font-size: .9rem; }
.feedback.good { background: var(--good-bg); border-color: var(--good-border); color: var(--good-text); }
.feedback.bad { background: var(--bad-bg); border-color: var(--bad-border); color: var(--bad-text); }
.buttons { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.action { border: 1.5px solid var(--primary); background: var(--input-bg); border-radius: 12px; padding: 11px 14px; min-height: 44px; color: var(--primary); font-size: .9rem; font-weight: 750; flex: 1 1 auto; text-decoration: none; text-align: center; display: inline-flex; align-items: center; justify-content: center; transition: background .15s ease, transform .12s ease; }
.action:hover { background: var(--goldsoft); }
.action:active { transform: translateY(1px); }
.action.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); box-shadow: 0 4px 12px #5e142040; }
.action.primary:hover { background: #8d2536; }
.action.next { background: var(--green); color: #fff; border-color: var(--green); }
.action.next:hover { background: #2a6b53; }
.action.danger { color: var(--rose); border-color: var(--rose); }
.action:disabled { opacity: .4; cursor: default; transform: none; }
.action.small { flex: 0 0 auto; padding: 8px 12px; font-size: .82rem; }
.linkish { background: none; border: 0; padding: 6px 0; color: var(--brand); font-size: .85rem; text-decoration: underline; min-height: 32px; }
.feedback .why { color: inherit; font-weight: 700; padding: 4px 6px; min-height: 0; }
.report-btn { font-size: inherit; padding: 0; min-height: 0; vertical-align: baseline; }
.report-form .field span { font-weight: 700; color: var(--brand); }
.report-text { width: 100%; border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; font: inherit; background: var(--input-bg); color: var(--text); resize: vertical; min-height: 96px; }
.report-status { min-height: 1.2em; margin: 0 0 4px; }
.toast a { text-decoration: underline; }
.support-line { text-align: center; font-size: .85rem; color: var(--muted); margin: 14px 0 0; }
.support-line a { color: var(--gold-text); }
.support-row { margin-top: 14px; }
.support-thanks { margin-top: 16px; font-size: .9rem; } .support-thanks .tib { font-size: 1.4em; line-height: 1; color: var(--brand); }
.support-value { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.support-value code { flex: 1 1 200px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--input-bg); font: .95rem/1.3 var(--mono); overflow-wrap: anywhere; }
.grammar-help .note-row { padding: 10px 0 12px; }
.grammar-help .note-row:first-of-type { border-top: 0; padding-top: 4px; }
.shortcuts { margin-top: 10px; }
.audio-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; border-radius: 50%; border: 1.5px solid var(--gold-line); background: var(--input-bg); color: var(--gold-text); vertical-align: middle; transition: background .15s ease, transform .12s ease; }
.audio-btn.small { width: 30px; height: 30px; }
.audio-btn:hover { background: var(--goldsoft); }
.audio-btn:active { transform: scale(.94); }
.audio-btn.playing { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.prompt-audio { display: block; margin: -2px 0 6px; }

/* multiple choice */
.options { display: grid; gap: 8px; margin-top: 10px; }
.option { display: flex; align-items: center; gap: 12px; text-align: left; min-height: 48px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--option-border); background: var(--option-bg); font-size: 1rem; transition: background .15s ease; }
.option:hover:not(:disabled) { background: var(--goldsoft); }
.option-num { flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--primary); color: var(--on-primary); font-size: .8rem; font-weight: 750; }
.option.right { border-color: var(--green); background: var(--good-bg); color: var(--good-text); }
.option.wrong { border-color: var(--bad-border); background: var(--bad-bg); color: var(--bad-text); opacity: .7; }
.option:disabled { cursor: default; }

/* Wylie typing */
.wylie-box { display: flex; gap: 8px; margin-top: 10px; align-items: center; flex-wrap: wrap; }
.wylie-input { flex: 1 1 200px; min-height: 48px; border: 1px solid var(--border); border-radius: 12px; padding: 0 12px; font: 500 1.1rem/1.2 var(--mono); }
.wylie-table { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.wylie-table .cell { display: inline-flex; flex-direction: column; align-items: center; min-width: 42px; padding: 4px 6px; border-radius: 8px; background: var(--stat-bg); border: 1px solid var(--stat-border); font-size: .78rem; color: var(--muted); }
.wylie-table .cell .tib { font-size: 1.3rem; line-height: 1.5; color: var(--text); }
.wylie-line { font-family: var(--mono); color: var(--muted); font-size: .88rem; margin-bottom: 6px; }

/* word chips & popover */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 4px 12px; border-radius: 12px; border: 1.5px solid var(--chip-border); background: var(--chip-bg); color: var(--text); font-size: .9rem; box-shadow: 0 2px 6px #3a24101a; transition: transform .12s ease; }
.chip:active { transform: translateY(1px); }
.chip .tib { font-size: 1.25rem; line-height: 1.6; color: var(--brand); }
.chip.new { border-color: var(--gold); background: var(--goldsoft); }
.chip.known { border-color: var(--chip-known-border); background: var(--chip-known-bg); }
.chip.due { border-color: var(--chip-due-border); background: var(--chip-due-bg); }
.chip .status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dot); }
.chip.known .status-dot { background: var(--green); }
.chip.learning .status-dot { background: var(--gold); }
.chip.due .status-dot { background: var(--badge-blue-text); }
.chip .tr { color: var(--muted); }
.popover-backdrop { position: fixed; inset: 0; background: #1a0a0e80; display: flex; align-items: flex-end; justify-content: center; z-index: 20; animation: fade-in .15s ease-out; }
.popover { background: var(--panel); border-radius: 20px 20px 0 0; border-top: 3px solid var(--gold); width: min(560px, 100%); max-height: 90vh; overflow: auto; padding: 18px 18px 26px; box-shadow: 0 -10px 40px #0004; animation: rise .22s ease-out; }
.popover h2, .popover h3 { margin: 0 0 8px; color: var(--brand); }
.popover .big-tib { font-family: var(--tib-font); font-size: 2.2rem; line-height: 1.8; color: var(--brand); margin: 0; }
.popover .wylie { color: var(--muted); font-size: .85rem; }
.popover .tr { font-size: 1.1rem; margin: 8px 0 14px; }
.onboarding p { margin: 0 0 10px; }
.onboarding .tips { margin: 0 0 14px; padding-left: 20px; color: var(--muted); font-size: .9rem; }
.onboarding .tips li { margin-bottom: 4px; }
.lesson { border-radius: 14px; margin-top: 16px; padding: 14px 16px; background: var(--lesson-bg); border: 1px solid var(--lesson-border); font-size: .9rem; line-height: 1.6; animation: fade-in .3s ease-out; }
.lesson strong { color: var(--lesson-strong); }
.lesson .sentence-display { display: block; margin: 6px 0; font-family: var(--tib-font); font-size: 1.8rem; line-height: 1.9; color: var(--lesson-tib); overflow-wrap: anywhere; }
.lesson .source { color: var(--fine); font-size: .78rem; margin-top: 8px; }
.cold-note { margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: var(--note-bg); border: 1px solid var(--note-border); color: var(--note-text); font-size: .86rem; }
.cold-note a { color: inherit; font-weight: 700; }

/* dictionary & grammar */
.search { width: 100%; min-height: 44px; border: 1px solid var(--border); border-radius: 12px; padding: 0 12px; font: inherit; margin-top: 8px; }
details.set { border-top: 1px solid var(--sep); }
details.set summary { cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 48px; padding: 8px 16px; font-weight: 700; color: var(--brand); list-style: none; }
details.set summary::-webkit-details-marker { display: none; }
details.set summary .counter { font-weight: 500; flex: 0 0 auto; }
details.set[open] summary { background: var(--topbar); }
.set-actions { padding: 0 16px 10px; }
.word-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; align-items: start; padding: 10px 16px; border-top: 1px solid var(--sep); }
.word-row .tib { font-size: 1.5rem; line-height: 1.7; color: var(--brand); }
.word-row .meta { color: var(--muted); font-size: .8rem; }
.word-row .tr { font-size: .95rem; }
.word-row .controls { display: flex; gap: 6px; }
.status-btn { min-height: 40px; min-width: 44px; border-radius: 10px; border: 1px solid var(--border); background: var(--input-bg); padding: 6px 10px; font-size: .8rem; color: var(--text); }
.status-btn.on.known { background: var(--good-bg); border-color: var(--good-border); color: var(--good-text); }
.status-btn.on.learning { background: var(--goldsoft); border-color: var(--gold); color: var(--gold-text); }
.meter { height: 6px; background: var(--meter-bg); border-radius: 3px; overflow: hidden; }
.meter > div { height: 100%; width: 0; background: linear-gradient(90deg, #b8862a, #e6c266); transition: width .25s; }
.examples { margin-top: 4px; }
.example { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; margin-top: 6px; border-radius: 10px; background: var(--stat-bg); border: 1px solid var(--stat-border); }
.example .tib { font-size: 1.3rem; line-height: 1.7; color: var(--brand); overflow-wrap: anywhere; }
.example .tr { color: var(--muted); font-size: .88rem; }
.note-row { padding: 10px 16px 14px; border-top: 1px solid var(--sep); }
.note-text { margin: 0 0 4px; font-size: .95rem; }
.note-text .tib, .lesson .tib, .feedback .tib { font-size: 1.2em; line-height: 1; }

/* stats */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.stat { background: var(--stat-bg); border: 1px solid var(--stat-border); border-radius: 14px; padding: 12px 14px; }
.stat .num { font-weight: 700; font-size: 1.8rem; line-height: 1.1; color: var(--brand); }
.stat .cap { font-size: .78rem; color: var(--muted); margin-top: 2px; }
.set-progress { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--sep); }
.set-progress .meter { grid-column: 1 / -1; }
.hard-list { margin-top: 8px; }
.hard-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 6px 0; border-top: 1px solid var(--sep); }
.hard-row .tib { font-size: 1.4rem; line-height: 1.6; color: var(--brand); }
.hard-row .tr { color: var(--muted); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.promo { margin-top: 16px; padding: 14px 16px; border-radius: 14px; background: var(--note-bg); border: 1px solid var(--note-border); color: var(--note-text); font-size: .9rem; }

/* settings */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-weight: 700; color: var(--brand); }
.field select { min-height: 44px; border: 1px solid var(--border); border-radius: 10px; padding: 0 10px; font: inherit; }
.field.check label { display: flex; align-items: center; gap: 8px; min-height: 44px; font-weight: 500; color: var(--text); }
.field.check input { width: 22px; height: 22px; accent-color: var(--gold); }
.notice { padding: 10px 12px; border-radius: 12px; background: var(--lesson-bg); border: 1px solid var(--lesson-border); color: var(--lesson-strong); font-size: .85rem; }
.move-banner { width: min(860px, calc(100% - 24px)); margin: 12px auto 0; background: var(--banner-bg); border: 2px solid var(--banner-border); color: var(--banner-text); box-shadow: inset 0 0 0 3px #ffffff55, inset 0 0 0 4px var(--banner-border); padding: 12px 16px; border-radius: 12px; }
.move-banner a { color: inherit; font-weight: 700; overflow-wrap: anywhere; }
.sync-status { font-size: .85rem; color: var(--muted); margin-top: 8px; }
.code-area { width: 100%; margin-top: 8px; border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; font: .8rem/1.3 var(--mono); resize: vertical; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--toast-bg); color: var(--toast-text); padding: 10px 16px; border-radius: 12px; font-size: .9rem; z-index: 30; box-shadow: 0 8px 24px #0004; max-width: calc(100% - 32px); animation: rise .2s ease-out; }
.loading { color: var(--muted); }
.no-script { padding: 12px; border: 1px solid #d6b270; border-radius: 12px; margin: 14px; color: #614c22; background: #fff3db; }

/* ------------------------------------------------------------------ */
/* Motion                                                              */
/* ------------------------------------------------------------------ */
@keyframes tile-in { from { opacity: 0; transform: translateY(-6px) scale(.94); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@keyframes pulse { 0%, 100% { outline-color: var(--gold); } 50% { outline-color: #f3d98a; } }
@keyframes glow { 0% { box-shadow: 0 0 0 0 #c99a2e00; } 30% { box-shadow: 0 0 28px 8px #e6c26680; } 100% { box-shadow: 0 0 0 0 #c99a2e00; } }
.toast { transform: translateX(-50%); }
@keyframes rise-toast { from { opacity: 0; transform: translate(-50%, 14px); } to { opacity: 1; transform: translate(-50%, 0); } }
.toast { animation-name: rise-toast; }

@media (max-width: 520px) {
  .page { padding: 12px 0 36px; }
  .panel-body { padding: 14px 12px; }
  .answer, .rack { min-height: 110px; padding: 10px; gap: 9px; }
  .tile { min-height: 66px; min-width: 52px; padding: 3px 10px 0; }
  .brand-sub { display: none; } .brand-title { display: none; } .section-title { display: block; }
  .lang-switch select { max-width: 88px; padding: 0 4px; }
  .header-tools { gap: 6px; }
  .header-inner { gap: 8px; }
  .menu { left: 12px; right: 12px; min-width: 0; }
  .topbar { padding: 12px 12px 12px; }
  .switch button { padding: 8px 9px; font-size: .76rem; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
