@charset "UTF-8";

:root {
  --red-900: #6f1218;
  --red-800: #87171d;
  --red-700: #9f1d24;
  --red-600: #b92c32;
  --red-100: #f8e9e7;
  --red-50: #fff7f5;
  --gold-700: #9b6d14;
  --gold-500: #d2a43b;
  --gold-300: #ead082;
  --gold-100: #fbf3d8;
  --ink-950: #201c19;
  --ink-800: #39322d;
  --ink-650: #5d534c;
  --ink-500: #786d65;
  --ink-300: #ada39b;
  --paper: #fffdf9;
  --paper-warm: #f7f2ea;
  --white: #fff;
  --green: #287a5b;
  --green-soft: #e4f4ed;
  --blue: #356b84;
  --danger: #b4232b;
  --line: #e7ded4;
  --shadow-sm: 0 2px 8px rgba(61, 38, 22, .07);
  --shadow-md: 0 12px 32px rgba(68, 40, 20, .1);
  --shadow-lg: 0 22px 60px rgba(55, 28, 17, .15);
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --max-width: 1180px;
  --header-height: 72px;
  --font-sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, "Noto Sans", sans-serif;
  --font-cjk: "Noto Sans CJK TC", "PingFang TC", "Microsoft JhengHei", "Heiti TC", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink-950);
  background:
    radial-gradient(circle at 10% 0%, rgba(210, 164, 59, .08), transparent 28rem),
    linear-gradient(180deg, #fffdf9 0%, #faf6ef 100%);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; }
svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.svg-sprite { position: absolute; overflow: hidden; }
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
.skip-link {
  position: fixed;
  z-index: 1000;
  top: .75rem;
  left: .75rem;
  padding: .7rem 1rem;
  color: #fff;
  background: var(--red-800);
  border-radius: 8px;
  transform: translateY(-150%);
  transition: transform .2s;
}
.skip-link:focus { transform: translateY(0); }
:focus-visible { outline: 3px solid rgba(53, 107, 132, .45); outline-offset: 3px; }

/* App chrome */
.topbar {
  position: sticky;
  z-index: 100;
  top: 0;
  min-height: var(--header-height);
  background: rgba(255, 253, 249, .92);
  border-bottom: 1px solid rgba(231, 222, 212, .85);
  box-shadow: 0 3px 16px rgba(61, 38, 22, .035);
  backdrop-filter: blur(18px);
}
.topbar-inner {
  width: min(calc(100% - 2rem), var(--max-width));
  height: var(--header-height);
  margin: auto;
  display: flex;
  align-items: center;
  gap: 2rem;
}
.brand {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: .7rem;
  color: var(--ink-950);
  text-decoration: none;
}
.brand-seal {
  position: relative;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: #fff8e8;
  background: var(--red-700);
  border: 2px solid var(--red-900);
  border-radius: 11px 8px 12px 9px;
  font: 700 1.35rem/1 var(--font-cjk);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.16);
  transform: rotate(-1.5deg);
}
.brand-seal::after { content: ""; position: absolute; inset: 4px; border: 1px solid rgba(255,255,255,.45); border-radius: 6px; }
.brand-copy { display: flex; flex-direction: column; line-height: 1.1; }
.brand-copy strong { font-size: 1rem; letter-spacing: .01em; }
.brand-copy small { margin-top: .22rem; color: var(--ink-500); font-size: .68rem; font-weight: 600; }
.desktop-nav { align-self: stretch; margin: 0 auto; display: flex; align-items: center; gap: .25rem; }
.desktop-nav a {
  position: relative;
  height: 100%;
  padding: 0 .85rem;
  display: flex;
  align-items: center;
  gap: .42rem;
  color: var(--ink-650);
  text-decoration: none;
  font-size: .88rem;
  font-weight: 650;
}
.desktop-nav a svg { width: 1.05rem; height: 1.05rem; }
.desktop-nav a::after { content: ""; position: absolute; right: .8rem; bottom: -1px; left: .8rem; height: 3px; background: var(--red-700); border-radius: 3px 3px 0 0; transform: scaleX(0); transition: transform .2s ease; }
.desktop-nav a:hover, .desktop-nav a.active { color: var(--red-700); }
.desktop-nav a.active::after { transform: scaleX(1); }
.top-actions { display: flex; align-items: center; gap: .3rem; }
.icon-button {
  position: relative;
  width: 42px;
  height: 42px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  color: var(--ink-650);
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  text-decoration: none;
  transition: color .18s, background .18s, transform .18s;
}
.icon-button:hover { color: var(--red-700); background: var(--red-100); }
.icon-button:active { transform: scale(.94); }
.action-count { position: absolute; top: 1px; right: -1px; min-width: 17px; height: 17px; padding: 0 4px; display: grid; place-items: center; color: #fff; background: var(--red-700); border: 2px solid var(--paper); border-radius: 10px; font-size: .6rem; font-weight: 800; }
.connection-bar { padding: .4rem 1rem; color: #fff; background: var(--ink-800); text-align: center; font-size: .78rem; font-weight: 650; }
.mobile-nav { display: none; }

main { min-height: calc(100vh - var(--header-height)); }
.page-shell { width: min(calc(100% - 2rem), var(--max-width)); margin: 0 auto; padding: 2.2rem 0 4.5rem; }
.page-shell.narrow { width: min(calc(100% - 2rem), 850px); }
.route-loading { min-height: 70vh; display: flex; align-items: center; justify-content: center; gap: .35rem; }
.route-loading span { width: 8px; height: 8px; background: var(--red-700); border-radius: 50%; animation: loading 1s infinite alternate; }
.route-loading span:nth-child(2) { animation-delay: .2s; }
.route-loading span:nth-child(3) { animation-delay: .4s; }
@keyframes loading { to { opacity: .25; transform: translateY(-7px); } }

/* Type and common components */
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { letter-spacing: -.025em; }
.eyebrow { display: inline-flex; align-items: center; gap: .4rem; margin-bottom: .55rem; color: var(--red-700); font-size: .73rem; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.eyebrow::before { content: ""; width: 18px; height: 2px; background: var(--gold-500); }
.section-heading { margin: 3.2rem 0 1.25rem; display: flex; align-items: end; justify-content: space-between; gap: 1rem; }
.section-heading h2 { margin: 0 0 .3rem; font-size: clamp(1.5rem, 3vw, 2rem); }
.section-heading p { margin: 0; color: var(--ink-500); font-size: .92rem; }
.inline-link, .section-heading a { display: inline-flex; align-items: center; gap: .35rem; color: var(--red-700); font-size: .84rem; font-weight: 750; text-decoration: none; white-space: nowrap; }
.inline-link:hover, .section-heading a:hover { text-decoration: underline; }
.inline-link svg, .section-heading a svg { width: 1rem; height: 1rem; }
.button {
  min-height: 48px;
  padding: .72rem 1.15rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  text-decoration: none;
  font-weight: 750;
  transition: transform .18s, box-shadow .18s, background .18s;
}
.button:hover { transform: translateY(-2px); }
.button:active { transform: translateY(0); }
.button.primary { color: #fff; background: var(--red-700); box-shadow: 0 8px 20px rgba(159,29,36,.2); }
.button.primary:hover { background: var(--red-800); box-shadow: 0 10px 24px rgba(159,29,36,.28); }
.button.secondary { color: var(--red-700); background: #fff; border-color: var(--line); box-shadow: var(--shadow-sm); }
.button.secondary:hover { border-color: var(--gold-300); }
.button.gold { color: var(--ink-950); background: var(--gold-300); }
.button.compact { min-height: 40px; padding: .5rem .8rem; font-size: .8rem; }
.button svg { width: 1.1rem; height: 1.1rem; }
.button[disabled] { opacity: .48; cursor: not-allowed; transform: none; box-shadow: none; }
.text-button { padding: .35rem; color: var(--red-700); background: transparent; border: 0; cursor: pointer; font-weight: 700; }
.text-button:hover { text-decoration: underline; }
.text-button.danger { color: var(--danger); }
.badge { padding: .26rem .54rem; display: inline-flex; align-items: center; gap: .28rem; color: var(--ink-650); background: var(--paper-warm); border: 1px solid var(--line); border-radius: 999px; font-size: .67rem; font-weight: 750; }
.badge svg { width: .78rem; height: .78rem; }
.progress-track { height: 7px; overflow: hidden; background: #eee7df; border-radius: 99px; }
.progress-track > span { display: block; width: var(--progress, 0%); height: 100%; background: linear-gradient(90deg, var(--red-700), var(--gold-500)); border-radius: inherit; transition: width .5s ease; }

/* Home */
.home-shell { padding-top: 1.4rem; }
.home-hero {
  position: relative;
  min-height: 410px;
  padding: clamp(2rem, 5vw, 4.2rem);
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, .7fr);
  align-items: center;
  gap: 3rem;
  color: #fff;
  background:
    linear-gradient(118deg, rgba(111,18,24,.98), rgba(159,29,36,.95) 58%, rgba(126,20,28,.96)),
    var(--red-800);
  border-radius: 28px;
  box-shadow: var(--shadow-lg);
}
.home-hero::before { content: "粵"; position: absolute; right: 25%; bottom: -6rem; color: rgba(255,255,255,.045); font: 700 25rem/1 var(--font-cjk); transform: rotate(-8deg); }
.home-hero::after { content: ""; position: absolute; top: -120px; right: -80px; width: 380px; height: 380px; border: 1px solid rgba(234,208,130,.28); border-radius: 50%; box-shadow: 0 0 0 35px rgba(234,208,130,.045), 0 0 0 70px rgba(234,208,130,.035); }
.hero-copy, .hero-panel { position: relative; z-index: 1; }
.hero-kicker { margin-bottom: 1rem; display: flex; align-items: center; gap: .65rem; color: var(--gold-300); font-size: .75rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.hero-kicker span { width: 24px; height: 1px; background: currentColor; }
.home-hero h1 { max-width: 680px; margin: 0 0 1rem; font-size: clamp(2.25rem, 5vw, 4.25rem); line-height: 1.02; letter-spacing: -.045em; }
.home-hero h1 em { display: block; margin-top: .35rem; color: var(--gold-300); font: 600 .63em/1.2 var(--font-cjk); letter-spacing: .04em; }
.home-hero .hero-lead { max-width: 610px; margin-bottom: 1.8rem; color: rgba(255,255,255,.8); font-size: clamp(.98rem, 2vw, 1.12rem); line-height: 1.7; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .75rem; }
.home-hero .button.primary { color: var(--red-900); background: var(--gold-300); box-shadow: 0 9px 24px rgba(54,20,0,.22); }
.home-hero .button.secondary { color: #fff; background: rgba(255,255,255,.09); border-color: rgba(255,255,255,.22); box-shadow: none; backdrop-filter: blur(5px); }
.hero-panel { padding: 1.15rem; background: rgba(255,255,255,.09); border: 1px solid rgba(255,255,255,.18); border-radius: 20px; backdrop-filter: blur(10px); }
.hero-panel-label { margin-bottom: .8rem; display: flex; justify-content: space-between; color: rgba(255,255,255,.65); font-size: .7rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.hero-phrase { padding: 1rem; color: var(--ink-950); background: #fffaf1; border-radius: 14px; }
.hero-phrase .cantonese { margin-bottom: .25rem; font: 700 clamp(1.55rem, 4vw, 2.15rem)/1.3 var(--font-cjk); }
.hero-phrase .jyutping { color: var(--red-700); font-size: .82rem; font-weight: 700; }
.hero-phrase .translation { margin: .55rem 0 0; color: var(--ink-650); font-size: .84rem; }
.hero-phrase-actions { margin-top: .8rem; display: flex; justify-content: space-between; align-items: center; }
.hero-phrase-actions button { color: #fff; }
.streak-pill { padding: .45rem .65rem; display: inline-flex; align-items: center; gap: .35rem; color: var(--gold-300); background: rgba(0,0,0,.14); border-radius: 9px; font-size: .73rem; font-weight: 750; }
.streak-pill svg { width: .9rem; height: .9rem; }

.stats-strip { margin: 1.15rem 1rem 0; padding: 1.1rem 1.5rem; display: grid; grid-template-columns: repeat(4, 1fr); background: #fff; border: 1px solid var(--line); border-radius: 0 0 18px 18px; box-shadow: var(--shadow-sm); }
.mini-stat { padding: .35rem 1rem; display: flex; align-items: center; gap: .7rem; border-right: 1px solid var(--line); }
.mini-stat:last-child { border: 0; }
.mini-stat-icon { width: 38px; height: 38px; display: grid; place-items: center; color: var(--red-700); background: var(--red-100); border-radius: 10px; }
.mini-stat-icon svg { width: 1.05rem; height: 1.05rem; }
.mini-stat strong { display: block; font-size: 1.15rem; }
.mini-stat span { color: var(--ink-500); font-size: .69rem; font-weight: 600; }
.module-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.module-card {
  --module: var(--red-700);
  position: relative;
  min-height: 235px;
  padding: 1.4rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  color: inherit;
  background: rgba(255,255,255,.9);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s;
}
.module-card::after { content: attr(data-watermark); position: absolute; right: -8px; bottom: -34px; color: color-mix(in srgb, var(--module) 7%, transparent); font: 700 8rem/1 var(--font-cjk); transform: rotate(-5deg); }
.module-card:hover { z-index: 1; transform: translateY(-5px); border-color: color-mix(in srgb, var(--module) 35%, var(--line)); box-shadow: var(--shadow-md); }
.module-top { position: relative; z-index: 1; margin-bottom: 1rem; display: flex; align-items: start; justify-content: space-between; }
.module-icon { width: 48px; height: 48px; display: grid; place-items: center; color: #fff; background: var(--module); border-radius: 14px 11px 15px 10px; font: 700 1.25rem/1 var(--font-cjk); box-shadow: 0 6px 15px color-mix(in srgb, var(--module) 25%, transparent); }
.module-arrow { width: 34px; height: 34px; display: grid; place-items: center; color: var(--ink-500); background: var(--paper-warm); border-radius: 50%; transition: transform .2s; }
.module-arrow svg { width: 1rem; height: 1rem; }
.module-card:hover .module-arrow { color: #fff; background: var(--module); transform: translateX(3px); }
.module-card h3 { position: relative; z-index: 1; margin: 0 0 .18rem; font-size: 1.12rem; }
.module-card .chinese-title { position: relative; z-index: 1; color: var(--module); font: 650 .88rem/1.3 var(--font-cjk); }
.module-card p { position: relative; z-index: 1; margin: .65rem 0 1rem; color: var(--ink-500); font-size: .8rem; line-height: 1.55; }
.module-card-progress { position: relative; z-index: 1; margin-top: auto; }
.module-card-progress div:first-child { margin-bottom: .45rem; display: flex; justify-content: space-between; color: var(--ink-500); font-size: .67rem; font-weight: 700; }
.module-card .progress-track > span { background: var(--module); }
.resume-card { padding: 1.25rem 1.4rem; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 1rem; background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--gold-500); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.resume-icon { width: 48px; height: 48px; display: grid; place-items: center; color: var(--red-700); background: var(--gold-100); border-radius: 50%; font: 700 1.2rem var(--font-cjk); }
.resume-card h3 { margin: 0 0 .25rem; font-size: 1rem; }
.resume-card p { margin: 0; color: var(--ink-500); font-size: .78rem; }
.culture-note { margin-top: 3.2rem; padding: 1.6rem; display: grid; grid-template-columns: auto 1fr; gap: 1.1rem; background: var(--gold-100); border: 1px solid #efdda7; border-radius: var(--radius); }
.culture-note-icon { width: 44px; height: 44px; display: grid; place-items: center; color: var(--gold-700); background: #fffaf0; border-radius: 50%; }
.culture-note h3 { margin: 0 0 .35rem; font-size: .95rem; }
.culture-note p { margin: 0; color: var(--ink-650); font-size: .82rem; line-height: 1.6; }
.app-footer { margin-top: 4rem; padding-top: 1.5rem; display: flex; justify-content: space-between; gap: 1rem; color: var(--ink-500); border-top: 1px solid var(--line); font-size: .73rem; }
.app-footer a { color: var(--red-700); font-weight: 700; }

/* Learn hub and module */
.page-header { margin-bottom: 2rem; display: flex; align-items: end; justify-content: space-between; gap: 1rem; }
.page-header h1 { margin: 0 0 .35rem; font-size: clamp(2rem, 5vw, 3.15rem); }
.page-header p { max-width: 640px; margin: 0; color: var(--ink-500); line-height: 1.6; }
.learn-grid .module-card { min-height: 260px; }
.back-link { margin-bottom: 1.2rem; display: inline-flex; align-items: center; gap: .35rem; color: var(--ink-500); text-decoration: none; font-size: .8rem; font-weight: 700; }
.back-link:hover { color: var(--red-700); }
.back-link svg { width: 1rem; height: 1rem; }
.module-hero {
  --module: var(--red-700);
  position: relative;
  padding: clamp(1.5rem, 4vw, 2.5rem);
  overflow: hidden;
  display: grid;
  grid-template-columns: auto 1fr minmax(180px, .35fr);
  align-items: center;
  gap: 1.4rem;
  background: linear-gradient(120deg, color-mix(in srgb, var(--module) 11%, white), #fff 65%);
  border: 1px solid color-mix(in srgb, var(--module) 22%, var(--line));
  border-radius: var(--radius-lg);
}
.module-hero::after { content: attr(data-watermark); position: absolute; right: 24%; bottom: -65px; color: color-mix(in srgb, var(--module) 6%, transparent); font: 700 11rem/1 var(--font-cjk); }
.module-hero > * { position: relative; z-index: 1; }
.module-hero .module-icon { width: 64px; height: 64px; font-size: 1.7rem; }
.module-hero h1 { margin: 0 0 .22rem; font-size: clamp(1.65rem, 4vw, 2.6rem); }
.module-hero .module-cn { color: var(--module); font: 650 1rem var(--font-cjk); }
.module-hero p { max-width: 630px; margin: .5rem 0 0; color: var(--ink-500); font-size: .86rem; line-height: 1.55; }
.module-progress { padding: 1rem; background: rgba(255,255,255,.75); border: 1px solid color-mix(in srgb, var(--module) 17%, var(--line)); border-radius: 14px; }
.module-progress div:first-child { margin-bottom: .55rem; display: flex; justify-content: space-between; font-size: .72rem; font-weight: 750; }
.module-progress strong { color: var(--module); }
.module-progress .progress-track > span { background: var(--module); }
.module-toolbar { position: sticky; z-index: 30; top: calc(var(--header-height) + .65rem); margin: 1.3rem 0; padding: .8rem; display: flex; align-items: center; gap: .75rem; background: rgba(255,253,249,.94); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-sm); backdrop-filter: blur(14px); }
.lesson-search { min-width: 230px; flex: 1; position: relative; }
.lesson-search svg { position: absolute; top: 50%; left: .8rem; width: 1rem; height: 1rem; color: var(--ink-500); transform: translateY(-50%); }
.lesson-search input { width: 100%; height: 42px; padding: 0 .8rem 0 2.4rem; color: var(--ink-950); background: var(--paper-warm); border: 1px solid transparent; border-radius: 10px; outline: 0; }
.lesson-search input:focus { background: #fff; border-color: var(--gold-500); box-shadow: 0 0 0 3px var(--gold-100); }
.filter-scroller { display: flex; gap: .4rem; overflow-x: auto; scrollbar-width: none; }
.filter-scroller::-webkit-scrollbar { display: none; }
.filter-chip { height: 38px; padding: 0 .8rem; color: var(--ink-650); background: #fff; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; font-size: .72rem; font-weight: 720; white-space: nowrap; }
.filter-chip:hover, .filter-chip.active { color: #fff; background: var(--red-700); border-color: var(--red-700); }
.toolbar-settings { flex: 0 0 auto; display: flex; align-items: center; gap: .35rem; padding-left: .75rem; border-left: 1px solid var(--line); }
.speed-pill { height: 38px; padding: 0 .7rem; display: flex; align-items: center; gap: .35rem; color: var(--ink-650); background: var(--gold-100); border: 1px solid #eddca8; border-radius: 9px; cursor: pointer; font-size: .68rem; font-weight: 750; }
.speed-pill svg { width: .9rem; height: .9rem; }
.speed-pill[data-slow="true"] { color: var(--red-700); }

.number-lab { margin: 1.4rem 0; padding: 1.4rem; display: grid; grid-template-columns: minmax(250px, .8fr) 1.4fr; gap: 1.4rem; background: linear-gradient(130deg, #fff8ec, #fff); border: 1px solid #ead8aa; border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.number-lab-copy h2 { margin: 0 0 .35rem; font-size: 1.15rem; }
.number-lab-copy p { margin: 0 0 .9rem; color: var(--ink-500); font-size: .78rem; line-height: 1.55; }
.context-tabs { display: flex; flex-wrap: wrap; gap: .35rem; }
.context-tabs button { padding: .45rem .7rem; color: var(--ink-650); background: #fff; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-size: .68rem; font-weight: 700; }
.context-tabs button.active { color: #fff; background: var(--red-700); border-color: var(--red-700); }
.number-stage { min-height: 170px; padding: 1.1rem; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 1rem; color: #fff; background: var(--red-800); border-radius: 14px; }
.number-step { width: 38px; height: 38px; display: grid; place-items: center; color: #fff; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.22); border-radius: 50%; cursor: pointer; font-size: 1.2rem; }
.number-step:hover { background: rgba(255,255,255,.2); }
.number-display { text-align: center; }
.number-arabic { color: var(--gold-300); font-size: .7rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.number-cantonese { margin: .2rem 0; font: 700 clamp(2rem, 6vw, 3.4rem)/1.15 var(--font-cjk); }
.number-jyutping { color: rgba(255,255,255,.75); font-size: .85rem; font-weight: 650; }
.number-english { margin-top: .35rem; color: rgba(255,255,255,.84); font-size: .7rem; }
.number-actions { margin-top: .7rem; display: flex; justify-content: center; gap: .4rem; }
.number-actions button { width: 34px; height: 34px; display: grid; place-items: center; color: var(--red-800); background: var(--gold-300); border: 0; border-radius: 50%; cursor: pointer; }
.number-actions button:last-child { color: #fff; background: rgba(255,255,255,.12); }
.number-actions svg { width: .95rem; height: .95rem; }
.number-range { grid-column: 1 / -1; width: 100%; margin-top: .75rem; accent-color: var(--gold-500); }
.phrase-summary { margin: 1.6rem 0 .8rem; display: flex; align-items: center; justify-content: space-between; color: var(--ink-500); font-size: .75rem; }
.phrase-summary strong { color: var(--ink-800); }
.phrase-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .85rem; }
.phrase-card {
  position: relative;
  min-height: 270px;
  padding: 1.05rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 2px 5px rgba(61,38,22,.035);
  transition: transform .2s, box-shadow .2s, border-color .2s;
}
.phrase-card:hover { transform: translateY(-3px); border-color: #d6c8bb; box-shadow: var(--shadow-md); }
.phrase-card.learned { background: linear-gradient(145deg, #fff, #f8fcfa); border-color: #badbcd; }
.phrase-card.learned::before { content: ""; position: absolute; top: 0; right: 0; left: 0; height: 3px; background: var(--green); }
.phrase-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.category-label { max-width: calc(100% - 42px); overflow: hidden; color: var(--ink-500); font-size: .63rem; font-weight: 800; letter-spacing: .07em; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }
.favorite-button { width: 34px; height: 34px; }
.favorite-button svg { width: 1.05rem; height: 1.05rem; }
.favorite-button.active { color: var(--red-700); background: var(--red-100); }
.favorite-button.active svg { fill: currentColor; }
.phrase-main { margin: .8rem 0 1rem; }
.phrase-cantonese { margin-bottom: .35rem; font: 700 clamp(1.35rem, 3vw, 1.8rem)/1.35 var(--font-cjk); letter-spacing: .01em; }
.phrase-jyutping { color: var(--red-700); font-size: .78rem; font-weight: 720; line-height: 1.5; }
.phrase-english { margin-top: .62rem; color: var(--ink-650); font-size: .82rem; line-height: 1.45; }
.phrase-note { margin: 0 0 .9rem; padding: .6rem .7rem; color: var(--ink-650); background: var(--gold-100); border-radius: 8px; font-size: .68rem; line-height: 1.45; }
.phrase-actions { margin-top: auto; padding-top: .8rem; display: flex; align-items: center; justify-content: space-between; gap: .55rem; border-top: 1px solid #eee7df; }
.audio-button { min-width: 92px; height: 40px; padding: 0 .8rem; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; color: #fff; background: var(--red-700); border: 0; border-radius: 10px; cursor: pointer; font-size: .72rem; font-weight: 750; transition: background .18s, transform .18s; }
.audio-button:hover { background: var(--red-800); }
.audio-button:active { transform: scale(.97); }
.audio-button svg { width: 1rem; height: 1rem; }
.audio-button .stop-icon { display: none; }
[data-audio-id].playing:not(.audio-button):not(.listen-orb) { color: #fff; background: var(--green); }
[data-audio-id].playing:not(.audio-button) svg { animation: soundPulse .75s ease infinite alternate; }
.audio-button.playing { background: var(--green); }
.audio-button.playing .play-label { display: none; }
.audio-button.playing .playing-label { display: inline; }
.audio-button:not(.playing) .playing-label { display: none; }
.audio-button.playing svg { animation: soundPulse .75s ease infinite alternate; }
@keyframes soundPulse { to { transform: scale(1.22); opacity: .65; } }
.learned-button { height: 38px; padding: 0 .55rem; display: inline-flex; align-items: center; gap: .3rem; color: var(--ink-500); background: transparent; border: 0; border-radius: 8px; cursor: pointer; font-size: .68rem; font-weight: 730; }
.learned-button:hover { color: var(--green); background: var(--green-soft); }
.learned-button svg { width: .95rem; height: .95rem; }
.learned .learned-button { color: var(--green); }
.learned .learned-button svg { fill: var(--green-soft); }
.empty-state { padding: 3.5rem 1.5rem; text-align: center; background: #fff; border: 1px dashed #d7cabd; border-radius: var(--radius); }
.empty-state-icon { width: 58px; height: 58px; margin: 0 auto 1rem; display: grid; place-items: center; color: var(--ink-500); background: var(--paper-warm); border-radius: 50%; }
.empty-state h2, .empty-state h3 { margin-bottom: .5rem; }
.empty-state p { max-width: 460px; margin: 0 auto 1.2rem; color: var(--ink-500); font-size: .84rem; line-height: 1.55; }
.emergency-note { margin: 1.2rem 0; padding: .9rem 1rem; display: flex; gap: .7rem; color: #732126; background: #fff0ef; border: 1px solid #efcac7; border-radius: 12px; font-size: .78rem; line-height: 1.5; }
.emergency-note svg { flex: 0 0 auto; width: 1.1rem; height: 1.1rem; margin-top: .05rem; }
.training-note { margin: 1.2rem 0; padding: .9rem 1rem; display: flex; gap: .7rem; color: #574315; background: var(--gold-100); border: 1px solid #e6d08c; border-radius: 12px; font-size: .78rem; line-height: 1.5; }
.training-note svg { flex: 0 0 auto; width: 1.1rem; height: 1.1rem; margin-top: .05rem; }

/* Quiz */
.quiz-intro { max-width: 700px; margin-bottom: 2rem; }
.quiz-intro h1 { margin-bottom: .6rem; font-size: clamp(2.1rem, 5vw, 3.3rem); }
.quiz-intro p { color: var(--ink-500); line-height: 1.65; }
.quiz-config { display: grid; grid-template-columns: 1fr .85fr; gap: 1.2rem; }
.config-card { padding: 1.4rem; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.config-card h2 { margin: 0 0 1rem; font-size: 1rem; }
.mode-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .65rem; }
.mode-option { position: relative; padding: 1rem .75rem; text-align: left; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.mode-option:hover { border-color: var(--gold-500); }
.mode-option.active { background: var(--red-50); border-color: var(--red-700); box-shadow: 0 0 0 2px var(--red-100); }
.mode-option .mode-icon { width: 38px; height: 38px; margin-bottom: .6rem; display: grid; place-items: center; color: var(--red-700); background: var(--red-100); border-radius: 10px; }
.mode-option strong { display: block; font-size: .8rem; }
.mode-option small { display: block; margin-top: .3rem; color: var(--ink-500); font-size: .65rem; line-height: 1.35; }
.config-select { width: 100%; height: 46px; padding: 0 .8rem; color: var(--ink-800); background: var(--paper-warm); border: 1px solid var(--line); border-radius: 10px; }
.config-meta { margin: 1rem 0; padding: .75rem; display: flex; justify-content: space-between; color: var(--ink-500); background: var(--paper-warm); border-radius: 9px; font-size: .72rem; }
.quiz-tip { margin-top: .8rem; color: var(--ink-500); font-size: .68rem; line-height: 1.45; }
.quiz-tip svg { width: .85rem; height: .85rem; margin-right: .25rem; vertical-align: -.15rem; }
.quiz-session { max-width: 760px; margin: 0 auto; }
.quiz-top { margin-bottom: 1.1rem; display: flex; align-items: center; gap: 1rem; }
.quiz-top .progress-track { flex: 1; height: 9px; }
.quiz-counter { color: var(--ink-500); font-size: .75rem; font-weight: 750; white-space: nowrap; }
.quiz-card { min-height: 510px; padding: clamp(1.4rem, 5vw, 2.5rem); display: flex; flex-direction: column; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); }
.quiz-card-head { display: flex; justify-content: space-between; align-items: center; }
.quiz-mode-label { color: var(--red-700); font-size: .7rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.quiz-score-mini { color: var(--ink-500); font-size: .72rem; font-weight: 700; }
.quiz-prompt { margin: 2rem 0 1.5rem; text-align: center; }
.quiz-prompt-label { margin-bottom: .7rem; color: var(--ink-500); font-size: .74rem; }
.quiz-prompt .phrase-cantonese { font-size: clamp(2rem, 7vw, 3.5rem); }
.quiz-prompt .phrase-jyutping { font-size: .92rem; }
.listen-orb { width: 102px; height: 102px; margin: 0 auto 1.1rem; display: grid; place-items: center; color: #fff; background: var(--red-700); border: 8px solid var(--red-100); border-radius: 50%; cursor: pointer; box-shadow: 0 0 0 1px #eac3c0, 0 12px 30px rgba(159,29,36,.2); }
.listen-orb:hover { background: var(--red-800); }
.listen-orb svg { width: 2.1rem; height: 2.1rem; }
.listen-orb.playing { animation: orbPulse 1s infinite; }
@keyframes orbPulse { 50% { box-shadow: 0 0 0 15px rgba(159,29,36,.08), 0 12px 30px rgba(159,29,36,.2); } }
.answer-grid { margin-top: auto; display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; }
.answer-button { min-height: 58px; padding: .8rem 1rem; color: var(--ink-800); background: var(--paper); border: 1px solid var(--line); border-radius: 11px; cursor: pointer; text-align: left; font-size: .8rem; font-weight: 650; line-height: 1.35; transition: border .18s, background .18s, transform .18s; }
.answer-button:hover:not([disabled]) { transform: translateY(-2px); border-color: var(--gold-500); background: #fffaf0; }
.answer-button.correct { color: #176044; background: var(--green-soft); border-color: #7dbba1; }
.answer-button.wrong { color: #8e252c; background: #fce8e7; border-color: #db9995; }
.answer-button[disabled] { cursor: default; }
.quiz-feedback { min-height: 46px; margin-top: .8rem; padding: .7rem .8rem; display: flex; align-items: center; justify-content: space-between; gap: .8rem; border-radius: 9px; font-size: .75rem; }
.quiz-feedback.correct { color: #176044; background: var(--green-soft); }
.quiz-feedback.wrong { color: #8e252c; background: #fce8e7; }
.quiz-feedback[hidden] { visibility: hidden; display: flex; }
.quiz-feedback button { padding: .4rem .65rem; color: #fff; background: var(--ink-800); border: 0; border-radius: 7px; cursor: pointer; font-weight: 700; }
.speech-stage { margin-top: auto; text-align: center; }
.mic-button { width: 92px; height: 92px; margin: 0 auto .9rem; display: grid; place-items: center; color: #fff; background: var(--red-700); border: 7px solid var(--red-100); border-radius: 50%; cursor: pointer; }
.mic-button svg { width: 2rem; height: 2rem; }
.mic-button.listening { background: var(--green); animation: micPulse 1.2s infinite; }
@keyframes micPulse { 50% { box-shadow: 0 0 0 18px rgba(40,122,91,.08); } }
.speech-status { min-height: 45px; color: var(--ink-500); font-size: .78rem; line-height: 1.5; }
.transcript { color: var(--ink-950); font: 650 1.25rem var(--font-cjk); }
.speech-actions { margin-top: .8rem; display: flex; justify-content: center; gap: .6rem; }
.unsupported-note { margin: 1rem auto; padding: .8rem; max-width: 480px; color: var(--ink-650); background: var(--gold-100); border-radius: 9px; font-size: .72rem; line-height: 1.5; }
.quiz-results { max-width: 700px; margin: 0 auto; text-align: center; }
.result-medallion { width: 120px; height: 120px; margin: 1rem auto 1.5rem; display: grid; place-items: center; color: var(--red-800); background: var(--gold-100); border: 2px solid var(--gold-300); border-radius: 50%; box-shadow: 0 0 0 10px #fff8e8; }
.result-medallion strong { display: block; font-size: 2rem; }
.result-medallion span { display: block; font-size: .62rem; font-weight: 700; }
.quiz-results h1 { margin-bottom: .4rem; font-size: 2.3rem; }
.quiz-results > p { color: var(--ink-500); }
.result-stats { margin: 1.5rem 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; }
.result-stat { padding: 1rem; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.result-stat strong { display: block; font-size: 1.25rem; }
.result-stat span { color: var(--ink-500); font-size: .67rem; }
.result-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: .7rem; }

/* Progress and favorites */
.progress-overview { display: grid; grid-template-columns: 1.15fr .85fr; gap: 1rem; }
.progress-card { padding: 1.4rem; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.progress-card h2 { margin: 0 0 1rem; font-size: 1rem; }
.mastery-hero { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 1.2rem; }
.mastery-ring { --value: 0; width: 120px; height: 120px; display: grid; place-items: center; background: conic-gradient(var(--red-700) calc(var(--value) * 1%), #eee6dd 0); border-radius: 50%; }
.mastery-ring::before { content: ""; grid-area: 1/1; width: 92px; height: 92px; background: #fff; border-radius: 50%; }
.mastery-ring div { z-index: 1; grid-area: 1/1; text-align: center; }
.mastery-ring strong { display: block; font-size: 1.55rem; }
.mastery-ring span { color: var(--ink-500); font-size: .62rem; }
.mastery-copy h3 { margin: 0 0 .4rem; }
.mastery-copy p { margin: 0; color: var(--ink-500); font-size: .75rem; line-height: 1.5; }
.progress-numbers { display: grid; grid-template-columns: repeat(2, 1fr); gap: .65rem; }
.big-stat { padding: 1rem; background: var(--paper-warm); border-radius: 11px; }
.big-stat strong { display: block; color: var(--red-700); font-size: 1.55rem; }
.big-stat span { color: var(--ink-500); font-size: .67rem; }
.module-progress-list { margin-top: 1rem; display: grid; gap: .65rem; }
.module-progress-row { --module: var(--red-700); padding: .85rem 1rem; display: grid; grid-template-columns: 34px minmax(100px, .55fr) 1fr auto; align-items: center; gap: .8rem; color: inherit; background: #fff; border: 1px solid var(--line); border-radius: 11px; text-decoration: none; }
.module-progress-row:hover { border-color: color-mix(in srgb, var(--module) 40%, var(--line)); box-shadow: var(--shadow-sm); }
.module-progress-row .mini-module-icon { width: 34px; height: 34px; display: grid; place-items: center; color: #fff; background: var(--module); border-radius: 9px; font: 700 .85rem var(--font-cjk); }
.module-progress-row h3 { margin: 0; font-size: .78rem; }
.module-progress-row h3 span { display: block; margin-top: .15rem; color: var(--ink-500); font: 600 .64rem var(--font-cjk); }
.module-progress-row .progress-track > span { background: var(--module); }
.module-progress-row > strong { color: var(--ink-650); font-size: .7rem; }
.activity-empty { padding: 1.2rem; color: var(--ink-500); background: var(--paper-warm); border-radius: 10px; text-align: center; font-size: .75rem; }
.activity-list { display: grid; gap: .45rem; }
.activity-item { padding: .65rem 0; display: flex; align-items: center; gap: .7rem; border-bottom: 1px solid var(--line); }
.activity-item:last-child { border: 0; }
.activity-dot { width: 31px; height: 31px; display: grid; place-items: center; color: var(--green); background: var(--green-soft); border-radius: 50%; }
.activity-dot svg { width: .85rem; height: .85rem; }
.activity-item p { margin: 0; font-size: .74rem; }
.activity-item small { color: var(--ink-500); font-size: .62rem; }
.favorites-header { margin-bottom: 1.4rem; }
.favorites-header h1 { margin-bottom: .4rem; font-size: clamp(2rem, 5vw, 3rem); }
.favorites-header p { color: var(--ink-500); }

/* About */
.about-hero { padding: 2rem; color: #fff; background: var(--red-800); border-radius: var(--radius-lg); }
.about-hero h1 { margin-bottom: .6rem; }
.about-hero p { max-width: 650px; margin: 0; color: rgba(255,255,255,.75); line-height: 1.65; }
.about-grid { margin-top: 1rem; display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.about-card { padding: 1.4rem; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.about-card h2 { font-size: 1rem; }
.about-card p, .about-card li { color: var(--ink-650); font-size: .78rem; line-height: 1.65; }
.about-card ul { padding-left: 1.1rem; }
.source-list { display: grid; gap: .55rem; }
.source-link { padding: .75rem; display: block; color: inherit; background: var(--paper-warm); border-radius: 9px; text-decoration: none; }
.source-link strong { display: block; color: var(--red-700); font-size: .76rem; }
.source-link small { color: var(--ink-500); font-size: .65rem; }
.source-link:hover strong { text-decoration: underline; }

/* Dialogs */
.app-dialog { width: min(calc(100% - 2rem), 680px); max-height: min(780px, calc(100vh - 2rem)); padding: 0; color: var(--ink-950); background: var(--paper); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-lg); }
.app-dialog::backdrop { background: rgba(32,28,25,.5); backdrop-filter: blur(4px); }
.app-dialog[open] { animation: dialogIn .2s ease; }
@keyframes dialogIn { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.dialog-head { padding: 1.25rem 1.35rem .9rem; display: flex; justify-content: space-between; align-items: start; }
.dialog-head .eyebrow { margin-bottom: .25rem; font-size: .62rem; }
.dialog-head h2 { margin: 0; font-size: 1.25rem; }
.search-field { position: relative; margin: .4rem 1.35rem 1rem; display: block; }
.search-field > svg { position: absolute; top: 50%; left: .9rem; width: 1.05rem; height: 1.05rem; color: var(--ink-500); transform: translateY(-50%); }
.search-field input { width: 100%; height: 52px; padding: 0 3rem 0 2.7rem; background: #fff; border: 1px solid #d9cdc1; border-radius: 12px; outline: 0; }
.search-field input:focus { border-color: var(--gold-500); box-shadow: 0 0 0 3px var(--gold-100); }
.search-field kbd { position: absolute; top: 50%; right: .8rem; padding: .15rem .4rem; color: var(--ink-500); background: var(--paper-warm); border: 1px solid var(--line); border-radius: 5px; font: 600 .7rem var(--font-sans); transform: translateY(-50%); }
.search-results { min-height: 200px; max-height: 440px; padding: 0 1.35rem 1.35rem; overflow-y: auto; }
.search-hint { padding: 2.5rem 1rem; color: var(--ink-500); text-align: center; font-size: .78rem; }
.search-result { padding: .8rem 0; display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: .7rem; border-bottom: 1px solid var(--line); }
.search-result:last-child { border: 0; }
.search-result-module { width: 38px; height: 38px; display: grid; place-items: center; color: #fff; background: var(--module, var(--red-700)); border-radius: 10px; font: 700 .9rem var(--font-cjk); }
.search-result a { min-width: 0; text-decoration: none; }
.search-result a:hover .search-canto { color: var(--red-700); }
.search-canto { overflow: hidden; font: 700 .98rem var(--font-cjk); text-overflow: ellipsis; white-space: nowrap; }
.search-meta { margin-top: .18rem; overflow: hidden; color: var(--ink-500); font-size: .65rem; text-overflow: ellipsis; white-space: nowrap; }
.search-play { width: 36px; height: 36px; }
.settings-stack { padding: .2rem 1.35rem 1.35rem; }
.setting-row, .setting-column { padding: 1rem 0; border-top: 1px solid var(--line); }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.setting-column { display: grid; gap: .7rem; }
.setting-row strong, .setting-column strong { display: block; font-size: .8rem; }
.setting-row small, .setting-column small { display: block; margin-top: .2rem; color: var(--ink-500); font-size: .65rem; line-height: 1.4; }
.segmented { padding: 3px; display: flex; background: var(--paper-warm); border: 1px solid var(--line); border-radius: 9px; }
.segmented button { height: 32px; padding: 0 .65rem; color: var(--ink-500); background: transparent; border: 0; border-radius: 6px; cursor: pointer; font-size: .68rem; font-weight: 700; }
.segmented button.active { color: #fff; background: var(--red-700); box-shadow: var(--shadow-sm); }
.switch { position: relative; display: inline-flex; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch span { width: 45px; height: 25px; padding: 3px; background: #c8beb5; border-radius: 99px; transition: background .2s; }
.switch span::after { content: ""; display: block; width: 19px; height: 19px; background: #fff; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s; }
.switch input:checked + span { background: var(--red-700); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 3px solid rgba(53,107,132,.4); outline-offset: 2px; }
.switch em { position: absolute; width: 1px; height: 1px; overflow: hidden; }
.setting-column select { width: 100%; height: 42px; padding: 0 .7rem; color: var(--ink-800); background: #fff; border: 1px solid var(--line); border-radius: 9px; }
.danger-setting { align-items: start; }

.toast-region { position: fixed; z-index: 500; right: 1rem; bottom: 1rem; display: grid; gap: .5rem; pointer-events: none; }
.toast { min-width: 240px; max-width: 360px; padding: .8rem 1rem; display: flex; align-items: center; gap: .6rem; color: #fff; background: var(--ink-800); border-radius: 10px; box-shadow: var(--shadow-lg); font-size: .75rem; font-weight: 650; animation: toastIn .25s ease; }
.toast.success { background: #246b50; }
.toast.error { background: #8e252c; }
.toast svg { flex: 0 0 auto; width: 1rem; height: 1rem; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

/* Tablet */
@media (max-width: 980px) {
  .desktop-nav a { padding: 0 .55rem; }
  .desktop-nav a svg { display: none; }
  .home-hero { grid-template-columns: 1fr .7fr; gap: 1.5rem; }
  .module-grid, .phrase-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-strip { grid-template-columns: repeat(2, 1fr); gap: .5rem 0; }
  .mini-stat:nth-child(2) { border-right: 0; }
  .quiz-config { grid-template-columns: 1fr; }
}

/* Mobile */
@media (max-width: 720px) {
  :root { --header-height: 62px; }
  body { padding-bottom: calc(67px + env(safe-area-inset-bottom)); }
  .topbar-inner { width: calc(100% - 1rem); gap: .5rem; }
  .brand-seal { width: 38px; height: 38px; }
  .brand-copy small { display: none; }
  .desktop-nav { display: none; }
  .top-actions { margin-left: auto; }
  .favorite-link { display: none; }
  .icon-button { width: 39px; height: 39px; }
  .mobile-nav {
    position: fixed;
    z-index: 100;
    right: 0;
    bottom: 0;
    left: 0;
    height: calc(64px + env(safe-area-inset-bottom));
    padding: 4px 5px env(safe-area-inset-bottom);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    background: rgba(255,253,249,.96);
    border-top: 1px solid var(--line);
    box-shadow: 0 -5px 22px rgba(61,38,22,.06);
    backdrop-filter: blur(16px);
  }
  .mobile-nav a { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--ink-500); border-radius: 9px; text-decoration: none; font-size: .58rem; font-weight: 700; }
  .mobile-nav a svg { width: 1.18rem; height: 1.18rem; }
  .mobile-nav a.active { color: var(--red-700); background: var(--red-50); }
  .page-shell, .page-shell.narrow { width: calc(100% - 1.2rem); padding-top: 1.1rem; padding-bottom: 2.5rem; }
  .home-shell { width: 100%; padding-top: 0; }
  .home-shell > :not(.home-hero) { margin-right: .6rem; margin-left: .6rem; }
  .home-hero { min-height: auto; padding: 2rem 1.15rem 1.2rem; grid-template-columns: 1fr; gap: 1.4rem; border-radius: 0 0 24px 24px; }
  .home-hero::before { right: -3rem; bottom: 3rem; font-size: 15rem; }
  .home-hero h1 { font-size: clamp(2.25rem, 12vw, 3.2rem); }
  .home-hero h1 em { font-size: .56em; }
  .home-hero .hero-lead { margin-bottom: 1.3rem; font-size: .9rem; line-height: 1.6; }
  .hero-actions .button { flex: 1; min-width: 130px; }
  .hero-panel { padding: .8rem; }
  .stats-strip { margin-top: .8rem !important; padding: .7rem; border-radius: 14px; }
  .mini-stat { padding: .5rem; gap: .5rem; }
  .mini-stat-icon { width: 32px; height: 32px; }
  .mini-stat strong { font-size: .95rem; }
  .section-heading { margin-top: 2.4rem; align-items: center; }
  .section-heading p { font-size: .78rem; }
  .module-grid, .phrase-grid { grid-template-columns: 1fr; }
  .module-card { min-height: 205px; }
  .resume-card { grid-template-columns: auto 1fr; }
  .resume-card .button { grid-column: 1 / -1; }
  .app-footer { flex-direction: column; padding-bottom: 1rem; }
  .page-header { margin-top: .5rem; align-items: start; flex-direction: column; }
  .module-hero { padding: 1.2rem; grid-template-columns: auto 1fr; gap: .9rem; }
  .module-hero .module-icon { width: 52px; height: 52px; font-size: 1.35rem; }
  .module-hero p { font-size: .74rem; }
  .module-progress { grid-column: 1 / -1; }
  .module-toolbar { top: calc(var(--header-height) + .35rem); padding: .55rem; flex-wrap: wrap; }
  .lesson-search { min-width: calc(100% - 52px); }
  .filter-scroller { width: 100%; order: 3; }
  .toolbar-settings { padding-left: .35rem; }
  .toolbar-settings .icon-button { display: none; }
  .number-lab { padding: 1rem; grid-template-columns: 1fr; }
  .number-stage { min-height: 180px; }
  .phrase-card { min-height: 245px; }
  .phrase-cantonese { font-size: 1.55rem; }
  .quiz-intro { margin-top: 1rem; }
  .mode-grid { grid-template-columns: 1fr; }
  .mode-option { padding: .8rem; display: grid; grid-template-columns: 38px 1fr; column-gap: .7rem; }
  .mode-option .mode-icon { grid-row: 1 / 3; margin: 0; }
  .quiz-card { min-height: calc(100vh - 170px); padding: 1.1rem; border-radius: var(--radius); }
  .answer-grid { grid-template-columns: 1fr; }
  .quiz-feedback { align-items: start; }
  .progress-overview, .about-grid { grid-template-columns: 1fr; }
  .mastery-hero { grid-template-columns: 100px 1fr; }
  .mastery-ring { width: 100px; height: 100px; }
  .mastery-ring::before { width: 76px; height: 76px; }
  .module-progress-row { grid-template-columns: 34px 1fr auto; }
  .module-progress-row .progress-track { grid-column: 2 / -1; grid-row: 2; }
  .app-dialog { width: 100%; max-width: none; max-height: calc(100vh - 1rem); margin: auto 0 0; border-radius: 20px 20px 0 0; }
  .search-results { max-height: 52vh; }
  .setting-row { align-items: start; }
  .toast-region { right: .6rem; bottom: calc(72px + env(safe-area-inset-bottom)); left: .6rem; }
  .toast { min-width: 0; max-width: none; width: 100%; }
}

@media (max-width: 420px) {
  .brand-copy strong { font-size: .88rem; }
  .home-hero h1 { font-size: 2.25rem; }
  .hero-actions { flex-direction: column; }
  .stats-strip { grid-template-columns: 1fr 1fr; }
  .mini-stat-icon { display: none; }
  .culture-note { grid-template-columns: 1fr; }
  .module-hero { grid-template-columns: 1fr; }
  .module-hero .module-icon { width: 46px; height: 46px; }
  .number-stage { grid-template-columns: 32px 1fr 32px; gap: .35rem; padding: .75rem; }
  .number-step { width: 32px; height: 32px; }
  .result-stats { gap: .35rem; }
  .result-stat { padding: .75rem .3rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media print {
  .topbar, .mobile-nav, .module-toolbar, .phrase-actions, .top-actions { display: none !important; }
  body { padding: 0; background: #fff; }
  .page-shell { width: 100%; }
  .phrase-grid { grid-template-columns: repeat(2, 1fr); }
  .phrase-card { min-height: auto; break-inside: avoid; box-shadow: none; }
}
