/* ===========================================================
   EN789 – Học tiếng Anh miễn phí
   =========================================================== */
:root {
  --bg: #f4f5fb;
  --surface: #ffffff;
  --surface-2: #f0f2fa;
  --surface-3: #e7eaf6;
  --text: #1c2040;
  --muted: #6a6f8f;
  --line: #e2e5f1;
  --primary: #5b5bf0;
  --primary-2: #8b5cf6;
  --primary-soft: #ecebff;
  --on-primary: #ffffff;
  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --bad: #e11d48;
  --bad-soft: #ffe4e6;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --info: #0284c7;
  --info-soft: #e0f2fe;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 4px 18px rgba(30, 35, 90, .07);
  --shadow-lg: 0 16px 44px rgba(30, 35, 90, .16);
  --nav-h: 64px;
  --side-w: 248px;
  --grad: linear-gradient(135deg, #5b5bf0 0%, #8b5cf6 55%, #d946ef 100%);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0e1121;
  --surface: #171b32;
  --surface-2: #1f2440;
  --surface-3: #282e4f;
  --text: #eef0ff;
  --muted: #a3a8c9;
  --line: #2a3052;
  --primary: #8486ff;
  --primary-2: #a78bfa;
  --primary-soft: #252a57;
  --ok: #4ade80;
  --ok-soft: #12321f;
  --bad: #fb7185;
  --bad-soft: #3b1421;
  --warn: #fbbf24;
  --warn-soft: #3a2d0c;
  --info: #38bdf8;
  --info-soft: #0c2a3d;
  --shadow: 0 4px 18px rgba(0, 0, 0, .35);
  --shadow-lg: 0 16px 44px rgba(0, 0, 0, .5);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1121;
    --surface: #171b32;
    --surface-2: #1f2440;
    --surface-3: #282e4f;
    --text: #eef0ff;
    --muted: #a3a8c9;
    --line: #2a3052;
    --primary: #8486ff;
    --primary-2: #a78bfa;
    --primary-soft: #252a57;
    --ok: #4ade80;
    --ok-soft: #12321f;
    --bad: #fb7185;
    --bad-soft: #3b1421;
    --warn: #fbbf24;
    --warn-soft: #3a2d0c;
    --info: #38bdf8;
    --info-soft: #0c2a3d;
    --shadow: 0 4px 18px rgba(0, 0, 0, .35);
    --shadow-lg: 0 16px 44px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
a { color: var(--primary); text-decoration: none; }
img, svg { display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.25; font-weight: 900; }
h1 { font-size: clamp(1.5rem, 4vw, 2.1rem); }
h2 { font-size: clamp(1.2rem, 3vw, 1.5rem); }
h3 { font-size: 1.1rem; }
p { margin: 0 0 .8em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.hidden { display: none !important; }
.ico { width: 1.25em; height: 1.25em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ico.fill { fill: currentColor; stroke: none; }

/* ---------------- Layout ---------------- */
.layout { display: flex; min-height: 100vh; }
.sidebar { display: none; }
.main {
  flex: 1; min-width: 0; width: 100%; max-width: 1180px; margin: 0 auto;
  padding: 16px 16px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom));
  outline: none;
}
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  display: flex;
}
.bottom-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); font-size: .72rem; font-weight: 800;
}
.bottom-nav a .ico { width: 24px; height: 24px; }
.bottom-nav a.active { color: var(--primary); }
.bottom-nav a.active .ico { transform: translateY(-1px); }
body.in-session .bottom-nav { display: none; }
body.in-session .main { padding-bottom: 24px; }

@media (min-width: 960px) {
  .sidebar {
    display: flex; flex-direction: column; gap: 8px;
    width: var(--side-w); flex: none; position: sticky; top: 0; height: 100vh;
    padding: 20px 14px; background: var(--surface); border-right: 1px solid var(--line); overflow-y: auto;
  }
  .bottom-nav { display: none; }
  .main { padding: 28px 32px 56px; }
  body.in-session .main { padding-bottom: 32px; }
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 14px; color: var(--text); }
.brand-logo {
  width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center;
  background: var(--grad); color: #fff; font-weight: 900; letter-spacing: .5px; box-shadow: 0 6px 16px rgba(91, 91, 240, .35);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-size: 1.15rem; }
.brand-text small { color: var(--muted); font-size: .75rem; font-weight: 700; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px;
  color: var(--muted); font-weight: 800; font-size: .95rem;
}
.side-nav a:hover { background: var(--surface-2); color: var(--text); }
.side-nav a.active { background: var(--primary-soft); color: var(--primary); }
.side-nav .sep { height: 1px; background: var(--line); margin: 8px 6px; }
.side-foot { margin-top: auto; }

/* ---------------- Footer: các trang học khác ---------------- */
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content .main { flex: 1; padding-bottom: 8px; }
.site-foot {
  width: 100%; max-width: 1180px; margin: 0 auto; text-align: center;
  padding: 20px 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom));
}
.site-foot h2 { font-size: 1.05rem; margin-bottom: 12px; border-top: 1px solid var(--line); padding-top: 22px; }
.sister { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.sister a {
  display: flex; align-items: center; gap: 12px; text-align: left; padding: 12px 14px; border-radius: 16px; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); transition: transform .15s, border-color .15s;
}
@media (hover: hover) { .sister a:hover { transform: translateY(-2px); border-color: var(--c); } }
.sister a:active { transform: scale(.98); border-color: var(--c); }
.sister .si {
  width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; font-size: 26px; flex: none;
  background: color-mix(in srgb, var(--c) 14%, var(--surface));
}
.sister b { display: block; color: var(--c); }
.sister small { color: var(--muted); font-weight: 700; font-size: .8rem; }
.site-foot p { color: var(--muted); font-size: .82rem; font-weight: 700; margin: 14px 0 0; }
body.in-session .site-foot { display: none; }
@media (min-width: 960px) { .site-foot { padding: 8px 32px 32px; } }
@media print { .site-foot { display: none !important; } }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 14px; padding: 11px 18px; font-weight: 800; font-size: .95rem;
  background: var(--primary); color: var(--on-primary);
  box-shadow: 0 3px 0 color-mix(in srgb, var(--primary) 60%, #000);
  transition: transform .08s, box-shadow .08s, background .2s, opacity .2s; user-select: none; white-space: nowrap;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 color-mix(in srgb, var(--primary) 60%, #000); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn-lg { padding: 14px 24px; font-size: 1.05rem; border-radius: 16px; }
.btn-sm { padding: 7px 12px; font-size: .85rem; border-radius: 11px; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; color: var(--text); box-shadow: none; border: 2px solid var(--line); }
.btn-ghost:active { box-shadow: none; }
.btn-soft { background: var(--primary-soft); color: var(--primary); box-shadow: none; }
.btn-soft:active { box-shadow: none; }
.btn-ok { background: var(--ok); box-shadow: 0 3px 0 color-mix(in srgb, var(--ok) 60%, #000); color: #fff; }
.btn-bad { background: var(--bad); box-shadow: 0 3px 0 color-mix(in srgb, var(--bad) 60%, #000); color: #fff; }
.btn-warn { background: var(--warn); box-shadow: 0 3px 0 color-mix(in srgb, var(--warn) 60%, #000); color: #fff; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 0; background: var(--surface-2); color: var(--text);
  display: inline-grid; place-items: center; flex: none;
}
.icon-btn:hover { background: var(--surface-3); }
.spk {
  width: 38px; height: 38px; border-radius: 50%; border: 0; flex: none;
  background: var(--primary-soft); color: var(--primary); display: inline-grid; place-items: center;
  transition: transform .1s;
}
.spk:active { transform: scale(.92); }
.spk.big { width: 64px; height: 64px; }
.spk.big .ico { width: 30px; height: 30px; }
.spk.huge { width: 110px; height: 110px; box-shadow: var(--shadow-lg); }
.spk.huge .ico { width: 50px; height: 50px; }
.spk.playing { animation: pulse 1s infinite; }
.spk.slow { background: var(--warn-soft); color: var(--warn); }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--primary) 45%, transparent); } 50% { box-shadow: 0 0 0 10px transparent; } }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.spacer { flex: 1; }
.mt { margin-top: 16px; }
.mt-lg { margin-top: 28px; }
.mb { margin-bottom: 16px; }

/* ---------------- Cards / grid ---------------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.card.pad-lg { padding: 24px; }
.card.flat { box-shadow: none; }
a.card, button.card { color: inherit; display: block; text-align: left; transition: transform .15s, box-shadow .15s, border-color .15s; width: 100%; }
a.card:hover, button.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--primary) 35%, var(--line)); }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.grid.sm { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.grid.xs { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.grid.lg { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); }
.section { margin-top: 28px; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-head h2 { margin: 0; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); font-weight: 700; margin: 2px 0 0; }
.back { margin-right: 2px; }
.crumb { display: flex; gap: 6px; flex-wrap: wrap; font-size: .85rem; color: var(--muted); font-weight: 700; margin-bottom: 6px; }
.crumb a { color: var(--muted); }
.crumb a:hover { color: var(--primary); }

.feature { display: flex; gap: 14px; align-items: flex-start; }
.feature .emo {
  width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; font-size: 28px; flex: none;
  background: var(--surface-2);
}
.feature h3 { margin: 2px 0 2px; }
.feature p { margin: 0; color: var(--muted); font-size: .9rem; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px;
  background: var(--surface-2); color: var(--text); font-weight: 800; font-size: .82rem; white-space: nowrap;
}
.chip.primary { background: var(--primary-soft); color: var(--primary); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.info { background: var(--info-soft); color: var(--info); }
.badge-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--bad); display: inline-block; }

/* ---------------- Hero ---------------- */
.hero {
  position: relative; overflow: hidden; border-radius: 26px; padding: 26px 22px; color: #fff;
  background: var(--grad); box-shadow: var(--shadow-lg);
}
.hero::after {
  content: ""; position: absolute; right: -60px; top: -60px; width: 240px; height: 240px; border-radius: 50%;
  background: rgba(255, 255, 255, .12);
}
.hero::before {
  content: ""; position: absolute; right: 60px; bottom: -90px; width: 200px; height: 200px; border-radius: 50%;
  background: rgba(255, 255, 255, .08);
}
.hero > * { position: relative; z-index: 1; }
.hero h1 { color: #fff; }
.hero p { color: rgba(255, 255, 255, .9); font-weight: 600; max-width: 640px; }
.hero .btn { background: #fff; color: #4338ca; box-shadow: 0 3px 0 rgba(0, 0, 0, .18); }
.hero .btn-ghost { background: rgba(255, 255, 255, .16); color: #fff; border-color: rgba(255, 255, 255, .4); box-shadow: none; }
.hero-stats { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0 18px; }
.hero-stats .chip { background: rgba(255, 255, 255, .18); color: #fff; }
@media (min-width: 720px) { .hero { padding: 34px 36px; } }

.goal-ring { --p: 0; width: 64px; height: 64px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: conic-gradient(var(--ok) calc(var(--p) * 1%), var(--surface-3) 0); }
.goal-ring span { width: 50px; height: 50px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-weight: 900; font-size: .8rem; }

/* ---------------- Grade tiles ---------------- */
.grade-tile {
  --c: var(--primary);
  position: relative; border-radius: 20px; padding: 16px; color: #fff; overflow: hidden; min-height: 128px;
  background: linear-gradient(140deg, var(--c), color-mix(in srgb, var(--c) 55%, #1e1b4b));
  box-shadow: 0 8px 22px color-mix(in srgb, var(--c) 30%, transparent);
  display: flex; flex-direction: column; justify-content: space-between; transition: transform .15s;
}
.grade-tile:hover { transform: translateY(-3px) rotate(-.4deg); }
.grade-tile .num { font-size: 2.6rem; font-weight: 900; line-height: 1; }
.grade-tile .lbl { font-weight: 800; opacity: .95; font-size: .95rem; }
.grade-tile .lvl { position: absolute; right: 12px; top: 12px; background: rgba(255, 255, 255, .22); padding: 3px 9px; border-radius: 999px; font-size: .75rem; font-weight: 900; }
.grade-tile .bar { height: 6px; border-radius: 6px; background: rgba(255, 255, 255, .25); overflow: hidden; margin-top: 10px; }
.grade-tile .bar i { display: block; height: 100%; background: #fff; border-radius: 6px; }
.grade-tile .emo { position: absolute; right: 10px; bottom: 6px; font-size: 44px; opacity: .3; }

/* ---------------- Unit list ---------------- */
.unit-card { display: flex; gap: 14px; align-items: center; }
.unit-card .uicon {
  width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; font-size: 30px; flex: none;
  background: color-mix(in srgb, var(--c, var(--primary)) 14%, var(--surface));
}
.unit-card .uno { font-size: .78rem; font-weight: 900; color: var(--c, var(--primary)); text-transform: uppercase; letter-spacing: .5px; }
.unit-card h3 { margin: 0; font-size: 1.02rem; }
.unit-card .uvi { color: var(--muted); font-size: .88rem; font-weight: 700; }
.unit-card .ustat { margin-left: auto; text-align: right; flex: none; }
.stars { display: inline-flex; gap: 1px; color: var(--surface-3); }
.stars .on { color: #f59e0b; }
.stars .ico { width: 18px; height: 18px; }
.mini-bar { width: 64px; height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; margin-top: 6px; margin-left: auto; }
.mini-bar i { display: block; height: 100%; background: var(--ok); }

/* ---------------- Tabs ---------------- */
.tabs {
  display: flex; gap: 6px; overflow-x: auto; padding: 4px; margin: 0 -2px 16px; background: var(--surface-2);
  border-radius: 16px; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  border: 0; background: transparent; padding: 9px 14px; border-radius: 12px; font-weight: 800; color: var(--muted);
  white-space: nowrap; flex: none;
}
.tabs button.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }

/* ---------------- Unit head ---------------- */
.unit-head {
  --c: var(--primary);
  border-radius: 24px; padding: 20px; color: #fff; margin-bottom: 16px; position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--c), color-mix(in srgb, var(--c) 50%, #1e1b4b));
}
.unit-head .big-emo { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font-size: 72px; opacity: .9; }
.unit-head h1 { color: #fff; margin: 4px 0 2px; padding-right: 86px; }
.unit-head p { margin: 0; opacity: .92; font-weight: 700; padding-right: 86px; }
.unit-head .crumb, .unit-head .crumb a { color: rgba(255, 255, 255, .85); }
.unit-head .row { margin-top: 12px; }
.unit-head .chip { background: rgba(255, 255, 255, .2); color: #fff; }
.unit-head .stars { color: rgba(255, 255, 255, .35); }
.unit-head .stars .on { color: #fde047; }

/* ---------------- Vocabulary ---------------- */
.vocab-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); }
.vcard {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 14px; text-align: center;
  position: relative; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer;
}
.vcard .emo { font-size: 44px; line-height: 1.1; min-height: 50px; display: grid; place-items: center; }
.vcard .emo.txt { font-size: 22px; font-weight: 900; width: 50px; height: 50px; border-radius: 14px; background: var(--primary-soft); color: var(--primary); }
.vcard .w { font-weight: 900; font-size: 1.12rem; word-break: break-word; }
.vcard .pos { font-size: .72rem; color: var(--primary); font-weight: 800; }
.vcard .vi { color: var(--muted); font-weight: 700; font-size: .9rem; }
.vcard .save { position: absolute; top: 8px; right: 8px; border: 0; background: none; color: var(--surface-3); padding: 2px; }
.vcard .save.on { color: #f59e0b; }
.vcard .save .ico { width: 20px; height: 20px; }
.vcard .spk { margin-top: 4px; }

.list { display: flex; flex-direction: column; gap: 10px; }
.line-item {
  display: flex; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; padding: 12px 14px;
}
.line-item .txt { flex: 1; min-width: 0; }
.line-item .en { font-weight: 800; font-size: 1.05rem; }
.line-item .vi { color: var(--muted); font-weight: 600; font-size: .92rem; }
.line-item .num { width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-weight: 900; font-size: .8rem; flex: none; color: var(--muted); }
.hl { background: var(--warn-soft); color: var(--warn); padding: 0 4px; border-radius: 6px; font-weight: 900; }

/* ---------------- Dialogue ---------------- */
.chat { display: flex; flex-direction: column; gap: 10px; }
.bubble-row { display: flex; gap: 10px; align-items: flex-end; }
.bubble-row.right { flex-direction: row-reverse; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; color: #fff; flex: none; font-size: .9rem; }
.bubble {
  max-width: min(78%, 560px); padding: 10px 14px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line);
  cursor: pointer; transition: transform .15s, box-shadow .15s;
}
.bubble-row.right .bubble { background: var(--primary-soft); border-color: transparent; }
.bubble .sp { font-size: .75rem; font-weight: 900; color: var(--muted); }
.bubble .en { font-weight: 800; }
.bubble .vi { color: var(--muted); font-size: .88rem; font-weight: 600; }
.bubble.active { box-shadow: 0 0 0 3px var(--primary); transform: scale(1.02); }
.bubble.me-turn { box-shadow: 0 0 0 3px var(--warn); }

/* ---------------- Notes / prose ---------------- */
.prose { font-size: 1rem; }
.prose h3 { margin-top: 1.1em; color: var(--primary); }
.prose h4 { margin: 1em 0 .4em; }
.prose ul, .prose ol { padding-left: 1.3em; margin: .4em 0 .9em; }
.prose li { margin: .25em 0; }
.prose table { width: 100%; border-collapse: collapse; margin: .6em 0 1em; font-size: .95rem; }
.prose th, .prose td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.prose th { background: var(--surface-2); font-weight: 900; }
.prose .ex, .ex-box { background: var(--surface-2); border-left: 4px solid var(--primary); padding: 10px 14px; border-radius: 10px; margin: .6em 0; }
.prose b, .prose strong { font-weight: 900; }
.prose code, .formula {
  font-family: inherit; background: var(--primary-soft); color: var(--primary); padding: 2px 8px; border-radius: 8px; font-weight: 800;
}
.formula { display: inline-block; margin: 3px 0; }
.tip { background: var(--warn-soft); border-radius: 14px; padding: 12px 14px; font-weight: 600; }
.tip b { color: var(--warn); }
.table-wrap { overflow-x: auto; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; }
.table th { background: var(--surface-2); font-weight: 900; position: sticky; top: 0; }
.table tr:last-child td { border-bottom: 0; }
.table td .spk { width: 32px; height: 32px; }
.table td .spk .ico { width: 16px; height: 16px; }

/* ---------------- Forms ---------------- */
.input, .select, textarea.input {
  width: 100%; border: 2px solid var(--line); background: var(--surface); border-radius: 14px; padding: 11px 14px; font-weight: 700;
  outline: none; transition: border-color .15s;
}
.input:focus, .select:focus { border-color: var(--primary); }
textarea.input { resize: vertical; min-height: 110px; line-height: 1.5; }
.label { font-weight: 800; font-size: .9rem; margin: 0 0 6px; display: block; }
.field { margin-bottom: 14px; }
.search-box { position: relative; }
.search-box .ico { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-box .input { padding-left: 44px; }
.check { display: flex; gap: 10px; align-items: center; font-weight: 700; cursor: pointer; padding: 6px 0; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); }
input[type=range] { width: 100%; accent-color: var(--primary); }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 3px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 7px 12px; border-radius: 10px; font-weight: 800; color: var(--muted); }
.seg button.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }

/* ---------------- Practice modes ---------------- */
.mode-card { display: flex; gap: 12px; align-items: center; position: relative; }
.mode-card .emo { font-size: 30px; width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; background: var(--surface-2); flex: none; }
.mode-card h3 { margin: 0; font-size: 1rem; }
.mode-card p { margin: 0; color: var(--muted); font-size: .84rem; }
.mode-card .done { position: absolute; top: 10px; right: 10px; color: var(--ok); }
.mode-card.test { background: linear-gradient(135deg, var(--warn-soft), var(--surface)); border-color: color-mix(in srgb, var(--warn) 30%, var(--line)); }

/* ---------------- Session ---------------- */
.session { max-width: 760px; margin: 0 auto; min-height: calc(100vh - 60px); display: flex; flex-direction: column; }
.session-top { display: flex; align-items: center; gap: 12px; padding: 4px 0 14px; position: sticky; top: 0; background: var(--bg); z-index: 5; }
.pbar { flex: 1; height: 14px; border-radius: 10px; background: var(--surface-3); overflow: hidden; }
.pbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #22c55e, #84cc16); border-radius: 10px; transition: width .35s; }
.pcount { font-weight: 900; color: var(--muted); font-size: .9rem; min-width: 46px; text-align: right; }
.session-body { flex: 1; padding: 6px 0 20px; animation: slideIn .3s ease; }
@keyframes slideIn { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
.q-title { font-weight: 900; font-size: 1.2rem; margin-bottom: 14px; }
.q-prompt { display: flex; align-items: center; justify-content: center; gap: 16px; flex-wrap: wrap; text-align: center; margin: 8px 0 22px; }
.q-word { font-size: clamp(1.9rem, 7vw, 2.8rem); font-weight: 900; line-height: 1.2; }
.q-emo { font-size: clamp(4rem, 16vw, 6rem); line-height: 1; }
.q-vi { font-size: 1.35rem; font-weight: 800; color: var(--muted); }
.q-sent { font-size: clamp(1.15rem, 4vw, 1.5rem); font-weight: 800; line-height: 1.5; }
.q-sent .blank { display: inline-block; min-width: 80px; border-bottom: 3px solid var(--primary); margin: 0 4px; color: var(--primary); }
.q-passage { text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; max-height: 38vh; overflow: auto; font-weight: 600; width: 100%; }
.q-passage summary { font-weight: 900; cursor: pointer; color: var(--primary); }
.opts { display: grid; gap: 10px; grid-template-columns: 1fr; }
.opts.grid2 { grid-template-columns: 1fr 1fr; }
@media (min-width: 560px) { .opts { grid-template-columns: 1fr 1fr; } }
.opt {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; border-radius: 16px; text-align: left;
  background: var(--surface); border: 2px solid var(--line); border-bottom-width: 4px; font-weight: 800; font-size: 1.05rem;
  transition: transform .08s, border-color .15s, background .15s; min-height: 62px;
}
.opt:hover { border-color: color-mix(in srgb, var(--primary) 40%, var(--line)); }
.opt:active { transform: translateY(2px); }
.opt .k { width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--line); display: grid; place-items: center; font-size: .78rem; color: var(--muted); flex: none; }
.opt .oe { font-size: 34px; line-height: 1; }
.opt.pic { flex-direction: column; text-align: center; justify-content: center; gap: 6px; min-height: 110px; position: relative; }
.opt.pic .k { position: absolute; top: 8px; left: 8px; }
.opt.right { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.opt.wrong { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); animation: shake .35s; }
.opt:disabled { cursor: default; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.session-foot { position: sticky; bottom: 0; padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); background: var(--bg); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; z-index: 5; }
.session-foot.show { margin: 0 -16px; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); border-radius: 22px 22px 0 0; animation: up .25s ease; }
@media (min-width: 960px) { .session-foot.show { margin: 0; border-radius: 22px; margin-bottom: 8px; } }
.session-foot.ok { background: var(--ok-soft); }
.session-foot.bad { background: var(--bad-soft); }
.session-foot .fb-msg { flex: 1; min-width: 200px; font-weight: 700; }
.session-foot .fb-msg b { font-size: 1.15rem; display: block; }
.session-foot.ok .fb-msg b { color: var(--ok); }
.session-foot.bad .fb-msg b { color: var(--bad); }
.session-foot.ok .btn { background: var(--ok); box-shadow: 0 3px 0 color-mix(in srgb, var(--ok) 60%, #000); color: #fff; }
.session-foot.bad .btn { background: var(--bad); box-shadow: 0 3px 0 color-mix(in srgb, var(--bad) 60%, #000); color: #fff; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* match */
.match { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.match .col { display: flex; flex-direction: column; gap: 10px; }
.mitem {
  padding: 12px 10px; min-height: 58px; border-radius: 14px; border: 2px solid var(--line); border-bottom-width: 4px; background: var(--surface);
  font-weight: 800; text-align: center; display: flex; align-items: center; justify-content: center; gap: 6px; transition: all .15s;
}
.mitem.sel { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.mitem.done { opacity: 0; transform: scale(.85); pointer-events: none; }
.mitem.err { border-color: var(--bad); background: var(--bad-soft); animation: shake .35s; }
.mitem .oe { font-size: 30px; }

/* spell & order */
.slots { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; margin: 12px 0 22px; }
.slot {
  width: 42px; height: 52px; border-radius: 12px; border: 2px dashed var(--line); display: grid; place-items: center;
  font-size: 1.5rem; font-weight: 900; text-transform: lowercase; background: var(--surface);
}
.slot.filled { border-style: solid; border-color: var(--primary); color: var(--primary); cursor: pointer; }
.slot.fixed { border: 0; background: none; width: 16px; }
.slot.ok { border-color: var(--ok); color: var(--ok); background: var(--ok-soft); }
.slot.no { border-color: var(--bad); color: var(--bad); background: var(--bad-soft); }
.tiles { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.tile {
  min-width: 46px; height: 50px; padding: 0 12px; border-radius: 12px; border: 2px solid var(--line); border-bottom-width: 4px;
  background: var(--surface); font-weight: 900; font-size: 1.25rem; display: grid; place-items: center; transition: transform .08s;
}
.tile:active { transform: translateY(2px); }
.tile.used { visibility: hidden; }
.tile.word { font-size: 1.05rem; height: 46px; }
.answer-area {
  min-height: 120px; border-bottom: 2px solid var(--line); border-top: 2px solid var(--line); padding: 12px 0;
  display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start; margin-bottom: 18px;
  background-image: repeating-linear-gradient(transparent 0 57px, var(--line) 57px 59px);
}
.answer-area.ok .tile { border-color: var(--ok); color: var(--ok); }
.answer-area.no .tile { border-color: var(--bad); color: var(--bad); }
.dict-input { font-size: 1.15rem; min-height: 100px; }
.diff-ok { color: var(--ok); font-weight: 900; }
.diff-bad { color: var(--bad); font-weight: 900; text-decoration: line-through; }
.diff-miss { color: var(--warn); font-weight: 900; }
.mic-btn {
  width: 96px; height: 96px; border-radius: 50%; border: 0; background: var(--grad); color: #fff; display: grid; place-items: center;
  box-shadow: 0 10px 28px rgba(91, 91, 240, .4); margin: 0 auto;
}
.mic-btn .ico { width: 40px; height: 40px; }
.mic-btn.rec { animation: rec 1.2s infinite; background: linear-gradient(135deg, #ef4444, #f97316); }
@keyframes rec { 0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, .5); } 50% { box-shadow: 0 0 0 18px rgba(239, 68, 68, 0); } }
.heard { margin-top: 14px; text-align: center; font-weight: 700; }
.word-ok { color: var(--ok); font-weight: 900; }
.word-no { color: var(--bad); font-weight: 900; text-decoration: underline wavy; }

/* summary */
.summary { text-align: center; padding: 20px 0; }
.summary .trophy { font-size: 86px; animation: pop .6s ease; }
@keyframes pop { 0% { transform: scale(.2); } 70% { transform: scale(1.15); } 100% { transform: scale(1); } }
.summary .big-stars { display: flex; justify-content: center; gap: 8px; margin: 10px 0; }
.summary .big-stars .ico { width: 54px; height: 54px; color: var(--surface-3); }
.summary .big-stars .on { color: #f59e0b; animation: pop .5s ease backwards; }
.summary .big-stars .on:nth-child(2) { animation-delay: .15s; }
.summary .big-stars .on:nth-child(3) { animation-delay: .3s; }
.stat-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin: 16px 0; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px 18px; min-width: 110px; }
.stat b { display: block; font-size: 1.6rem; font-weight: 900; }
.stat span { color: var(--muted); font-weight: 700; font-size: .85rem; }
.mistakes { text-align: left; margin: 18px auto; max-width: 560px; }

/* ---------------- Flashcards ---------------- */
.flash-wrap { max-width: 520px; margin: 0 auto; perspective: 1400px; }
.flash {
  position: relative; width: 100%; aspect-ratio: 4 / 4.4; max-height: 62vh; cursor: pointer;
  transform-style: preserve-3d; transition: transform .55s cubic-bezier(.3, .7, .3, 1);
}
.flash.flipped { transform: rotateY(180deg); }
.flash-face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 28px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 24px; text-align: center;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lg);
}
.flash-face.back { transform: rotateY(180deg); background: linear-gradient(160deg, var(--primary-soft), var(--surface)); }
.flash-face .emo { font-size: clamp(5rem, 22vw, 8rem); line-height: 1; }
.flash-face .w { font-size: clamp(2rem, 8vw, 3rem); font-weight: 900; line-height: 1.15; word-break: break-word; }
.flash-face .vi { font-size: clamp(1.4rem, 5vw, 2rem); font-weight: 900; color: var(--primary); }
.flash-face .hint { position: absolute; bottom: 14px; color: var(--muted); font-size: .8rem; font-weight: 700; }
.flash-face .ex { color: var(--muted); font-weight: 700; }
.flash-ctrl { display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

/* ---------------- Handbook ---------------- */
.ipa-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); }
.ipa {
  border-radius: 16px; padding: 12px 8px; text-align: center; background: var(--surface); border: 1px solid var(--line); cursor: pointer;
  border-bottom-width: 4px; transition: transform .1s;
}
.ipa:active { transform: translateY(2px); }
.ipa .sym { font-size: 1.8rem; font-weight: 900; font-family: 'Segoe UI', 'Noto Sans', Arial, sans-serif; color: var(--primary); }
.ipa .exw { font-weight: 800; font-size: .9rem; }
.ipa .exw u { text-decoration-color: var(--warn); text-decoration-thickness: 3px; }
.ipa.vowel .sym { color: #e11d48; }
.ipa.diph .sym { color: #d97706; }
.acc { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); margin-bottom: 10px; overflow: hidden; }
.acc > summary { padding: 14px 16px; font-weight: 900; cursor: pointer; list-style: none; display: flex; align-items: center; gap: 10px; }
.acc > summary::-webkit-details-marker { display: none; }
.acc > summary::after { content: "›"; margin-left: auto; font-size: 1.4rem; transition: transform .2s; color: var(--muted); }
.acc[open] > summary::after { transform: rotate(90deg); }
.acc > .acc-body { padding: 0 16px 16px; }
.letter-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(66px, 1fr)); }
.letter {
  aspect-ratio: 1; border-radius: 16px; display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-bottom-width: 4px; font-weight: 900; font-size: 1.5rem;
}
.letter small { font-size: .7rem; color: var(--muted); font-weight: 800; }
.letter.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.say-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 12px; background: var(--surface);
  border: 1px solid var(--line); font-weight: 800; cursor: pointer; margin: 4px; border-bottom-width: 3px;
}
.say-chip:hover { border-color: var(--primary); }
.say-chip small { color: var(--muted); font-weight: 700; }

/* ---------------- Tools ---------------- */
.clock-face { width: min(260px, 70vw); height: auto; margin: 0 auto; }
.big-out { font-size: clamp(1.3rem, 4.5vw, 1.9rem); font-weight: 900; text-align: center; margin: 12px 0; word-break: break-word; }
.timer-digits { font-size: clamp(4rem, 20vw, 9rem); font-weight: 900; text-align: center; font-variant-numeric: tabular-nums; letter-spacing: -2px; line-height: 1; margin: 16px 0; }
.timer-digits.end { color: var(--bad); animation: shake .4s 3; }
.picker-name { font-size: clamp(2rem, 9vw, 4rem); font-weight: 900; text-align: center; min-height: 1.3em; margin: 18px 0; color: var(--primary); }
.team { text-align: center; }
.team .score { font-size: 3rem; font-weight: 900; line-height: 1.1; }
.team input { text-align: center; font-weight: 900; border: 0; background: transparent; width: 100%; outline: none; font-size: 1.1rem; }

/* games */
.mem-grid { display: grid; gap: 10px; grid-template-columns: repeat(3, 1fr); max-width: 560px; margin: 0 auto; }
@media (min-width: 560px) { .mem-grid { grid-template-columns: repeat(4, 1fr); } }
.mem { aspect-ratio: 1; perspective: 800px; cursor: pointer; }
.mem-in { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .4s; }
.mem.open .mem-in, .mem.done .mem-in { transform: rotateY(180deg); }
.mem-f, .mem-b { position: absolute; inset: 0; border-radius: 16px; backface-visibility: hidden; -webkit-backface-visibility: hidden; display: grid; place-items: center; text-align: center; padding: 6px; font-weight: 900; }
.mem-f { background: var(--grad); color: #fff; font-size: 1.8rem; }
.mem-b { background: var(--surface); border: 2px solid var(--line); transform: rotateY(180deg); font-size: .95rem; word-break: break-word; }
.mem-b .oe { font-size: 2.4rem; }
.mem.done .mem-b { border-color: var(--ok); background: var(--ok-soft); }
.kb { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; max-width: 560px; margin: 0 auto; }
.kb button { width: 40px; height: 46px; border-radius: 10px; border: 2px solid var(--line); border-bottom-width: 4px; background: var(--surface); font-weight: 900; font-size: 1.05rem; }
.kb button.ok { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.kb button.no { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); opacity: .6; }
.balloons { font-size: 2.2rem; text-align: center; letter-spacing: 4px; min-height: 1.4em; }
.hang-word { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin: 16px 0; }
.hang-word span { width: 34px; border-bottom: 3px solid var(--text); text-align: center; font-size: 1.6rem; font-weight: 900; text-transform: lowercase; }
.hang-word span.sp { border: 0; }
.big-timer { font-size: 2.2rem; font-weight: 900; font-variant-numeric: tabular-nums; }

/* week chart */
.week { display: flex; gap: 8px; align-items: flex-end; height: 120px; padding-top: 8px; }
.week .d { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.week .b { width: 100%; max-width: 34px; background: var(--primary); border-radius: 8px 8px 4px 4px; min-height: 4px; }
.week .d.today .b { background: var(--ok); }
.week .d span { font-size: .72rem; font-weight: 800; color: var(--muted); }
.badge-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.badge { text-align: center; padding: 14px 8px; border-radius: 16px; background: var(--surface-2); filter: grayscale(1); opacity: .5; }
.badge.on { filter: none; opacity: 1; background: var(--warn-soft); }
.badge .e { font-size: 34px; }
.badge b { display: block; font-size: .85rem; }
.badge small { color: var(--muted); font-size: .72rem; font-weight: 700; }

/* level path */
.path { display: flex; flex-direction: column; gap: 14px; position: relative; }
.level-card { display: flex; gap: 16px; align-items: flex-start; }
.level-card .lv { width: 64px; height: 64px; border-radius: 20px; color: #fff; display: grid; place-items: center; font-weight: 900; flex: none; font-size: 1rem; text-align: center; line-height: 1.1; }

/* worksheet print */
.sheet { background: #fff; color: #111; border-radius: 8px; padding: 28px 32px; box-shadow: var(--shadow-lg); max-width: 820px; margin: 0 auto; font-size: 15px; }
.sheet h2 { text-align: center; color: #111; margin-bottom: 4px; }
.sheet h3 { color: #111; margin: 20px 0 8px; font-size: 1.02rem; }
.sheet .info { display: flex; gap: 20px; flex-wrap: wrap; justify-content: space-between; border-bottom: 2px solid #111; padding-bottom: 8px; margin: 12px 0; font-weight: 700; }
.sheet ol { margin: 6px 0; padding-left: 26px; }
.sheet li { margin: 6px 0; }
.sheet .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 24px; }
.sheet .box { border: 1.5px dashed #555; border-radius: 8px; padding: 8px 12px; margin: 6px 0 10px; font-weight: 700; }
.sheet .dots { display: inline-block; min-width: 140px; border-bottom: 1px dotted #333; }
.sheet .key { page-break-before: always; break-before: page; }
.sheet table { border-collapse: collapse; width: 100%; }
.sheet td, .sheet th { border: 1px solid #555; padding: 6px 8px; }
.print-only { display: none; }
@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff !important; }
  .sidebar, .bottom-nav, .no-print, .toast-wrap { display: none !important; }
  .main { padding: 0 !important; max-width: none; }
  .sheet { box-shadow: none; padding: 0; max-width: none; border-radius: 0; }
  .print-only { display: block; }
  .present-only { display: none; }
}

/* ---------------- Toast / modal ---------------- */
.toast-wrap { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom)); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
@media (min-width: 960px) { .toast-wrap { bottom: 26px; } }
.toast { background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 14px; font-weight: 800; box-shadow: var(--shadow-lg); animation: up .25s ease; text-align: center; }
.toast.ok { background: var(--ok); color: #fff; }
.toast.bad { background: var(--bad); color: #fff; }
.modal-back { position: fixed; inset: 0; background: rgba(10, 12, 30, .55); z-index: 150; display: grid; place-items: center; padding: 16px; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.modal-box { background: var(--surface); border-radius: 22px; padding: 22px; width: min(520px, 100%); max-height: 88vh; overflow: auto; box-shadow: var(--shadow-lg); animation: pop .25s ease; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 300; }

.loading { display: grid; place-items: center; min-height: 50vh; }
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 5px solid var(--surface-3); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); font-weight: 700; }
.empty .e { font-size: 56px; margin-bottom: 8px; }

/* presenter */
.present { position: fixed; inset: 0; z-index: 120; background: var(--bg); display: flex; flex-direction: column; padding: 16px; }
.present .stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; cursor: pointer; }
.present .stage .emo { font-size: min(30vh, 40vw); line-height: 1; }
.present .stage .w { font-size: min(14vh, 13vw); font-weight: 900; line-height: 1.1; }
.present .stage .vi { font-size: min(7vh, 7vw); font-weight: 900; color: var(--primary); }

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