:root[data-theme=light]{color-scheme:light}:root[data-theme=dark]{color-scheme:dark}
:root {
  color-scheme: light dark;
  --navy: #080D14; --navy-2: #111a27; --gold: #DFB967;
  --gold-deep: light-dark(#8F6F26, #DFB967); --gold-soft: light-dark(#f7efdc, #2a2416);
  --canvas: light-dark(#F5F5F1, #0d1219); --card: light-dark(#fff, #151c27); --ink: light-dark(#18202b, #e9ecf0);
  --muted: light-dark(#5d6673, #9aa4b1); --line: light-dark(#e4e2da, #263041); --field: light-dark(#fff, #0f151e);
  --ok: light-dark(#1f7a4d, #5cc48f); --ok-soft: light-dark(#e3f3ea, #12301f); --bad: light-dark(#b3372b, #f08a7e);
  --bad-soft: light-dark(#fbe7e4, #3a1a16); --info-soft: light-dark(#e8eef7, #1b2636); --soft: light-dark(#fbfaf6, #121923);
  --A: #3b6ea8; --B: #7a4fa0; --C: #1f7a6a; --D: #b0632a;
  --radius: 14px; --shadow: 0 1px 2px rgba(8,13,20,.06), 0 4px 16px rgba(8,13,20,.05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 17px/1.6 var(--font); color: var(--ink); background: var(--canvas); -webkit-text-size-adjust: 100%; }
a { color: var(--gold-deep); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.65rem; } h2 { font-size: 1.3rem; } h3 { font-size: 1.08rem; }
p { margin: 0 0 .9em; }
button, input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--navy); color: #fff; display: flex; align-items: center;
  gap: 20px; padding: 10px 24px; padding-top: max(10px, env(safe-area-inset-top)); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #fff; }
.brand img { height: 30px; }
.brand span { font-weight: 600; color: var(--gold); letter-spacing: .02em; border-left: 1px solid #334; padding-left: 10px; }
.mainnav { display: flex; gap: 4px; margin-left: auto; }
.mainnav a { color: #cfd5de; text-decoration: none; padding: 8px 14px; border-radius: 10px; font-size: .95rem; }
.mainnav a:hover { background: var(--navy-2); color: #fff; }
.mainnav a.on { color: var(--navy); background: var(--gold); font-weight: 600; }
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: var(--navy); display: flex;
  padding-bottom: env(safe-area-inset-bottom); }
.tabbar a { flex: 1; text-align: center; color: #aab3bf; text-decoration: none; font-size: .75rem; padding: 8px 0 9px; }
.tabbar a b { display: block; font-size: 1.25rem; line-height: 1.2; font-weight: 400; }
.tabbar a.on { color: var(--gold); }

.app { max-width: 1040px; margin: 0 auto; padding: 28px 24px 120px; }
.loading { color: var(--muted); padding: 40px 0; text-align: center; }

/* building blocks */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.stack > * + * { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid.g3 { grid-template-columns: repeat(3, 1fr); }
.grid.g2 { grid-template-columns: repeat(2, 1fr); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: .87rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .74rem; font-weight: 700; color: var(--gold-deep); margin-bottom: 6px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: var(--card);
  padding: 10px 18px; border-radius: 10px; cursor: pointer; text-decoration: none; color: var(--ink); font-weight: 600; font-size: .95rem; min-height: 44px; }
.btn:hover { border-color: var(--gold); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--navy); }
.btn.gold:hover { background: #d4ab55; }
.btn.navy { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--gold-deep); padding-left: 8px; padding-right: 8px; }
.btn.danger { color: var(--bad); }
.btn.rec { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { border: 0; background: transparent; font-size: 1.2rem; cursor: pointer; padding: 6px 10px; color: inherit; }
.pill { display: inline-block; font-size: .74rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--info-soft); color: var(--ink); white-space: nowrap; }
.pill.A { background: #e6eef8; color: var(--A); } .pill.B { background: #f0e9f6; color: var(--B); }
.pill.C { background: #e2f2ef; color: var(--C); } .pill.D { background: #f8ece2; color: var(--D); }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.gold { background: var(--gold-soft); color: var(--gold-deep); }
.bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--gold); border-radius: 99px; transition: width .4s; }
.back { display: inline-block; margin-bottom: 14px; text-decoration: none; font-weight: 600; font-size: .92rem; }
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
input[type=text], input[type=password], textarea, select { width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--field); }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--gold); outline-offset: 1px; border-color: var(--gold); }
.field + .field { margin-top: 14px; }
.error { color: var(--bad); font-weight: 600; font-size: .92rem; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--navy); }
.login { width: 100%; max-width: 400px; }
.login .logo { display: block; height: 46px; margin: 0 auto 18px; }
.login h1 { text-align: center; font-size: 1.35rem; }
.login p.lead { text-align: center; color: var(--muted); margin-bottom: 22px; }

/* home */
.hero { background: var(--navy); color: #fff; border-radius: var(--radius); padding: 28px; display: grid; grid-template-columns: 1.4fr 1fr; gap: 24px; align-items: center; }
.hero h1 { color: #fff; }
.hero .muted { color: #aab3bf; }
.hero .next { background: var(--navy-2); border: 1px solid #263244; border-radius: 12px; padding: 18px; }
.hero .next h3 { color: #fff; }
.stat { text-align: center; }
.stat b { display: block; font-size: 1.8rem; line-height: 1.1; }
.stat span { color: var(--muted); font-size: .85rem; }
.grade-card { display: block; text-decoration: none; color: inherit; transition: transform .15s; }
.grade-card:hover { transform: translateY(-2px); }
.grade-card .num { font-size: 2.6rem; font-weight: 800; color: var(--gold-deep); line-height: 1; }

/* unit list */
.unit-row { display: flex; gap: 16px; align-items: center; text-decoration: none; color: inherit; padding: 16px 18px; }
.unit-row + .unit-row { border-top: 1px solid var(--line); }
.unit-row:hover { background: var(--soft); }
.unit-row .n { width: 38px; height: 38px; border-radius: 50%; background: var(--gold-soft); color: var(--gold-deep); display: grid; place-items: center; font-weight: 800; flex: none; }
.unit-row .n.done { background: var(--ok); color: #fff; }
.unit-row .t { flex: 1; min-width: 0; }
.unit-row .t strong { display: block; }
.unit-row .t small { color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 8px; }

/* unit page */
.unit-head { margin-bottom: 18px; }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 22px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 10px 16px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--ink); border-color: var(--gold); }
.tabs a .tick { color: var(--ok); }
.lesson-sec h2 { display: flex; gap: 10px; align-items: center; }
.examples { background: var(--gold-soft); border-left: 4px solid var(--gold); border-radius: 8px; padding: 12px 16px; margin-top: 10px; }
.examples div + div { margin-top: 6px; }
.prose ul { margin: 0 0 .9em; padding-left: 1.3em; }
.prose li { margin: .2em 0; }
.passage { font-family: Georgia, "Times New Roman", serif; font-size: 1.12rem; line-height: 1.75; }
.goals li { margin: .25em 0; }

/* quiz */
.q-progress { display: flex; gap: 4px; margin-bottom: 18px; }
.q-progress i { flex: 1; height: 6px; border-radius: 4px; background: var(--line); }
.q-progress i.ok { background: var(--ok); } .q-progress i.bad { background: var(--bad); } .q-progress i.cur { background: var(--gold); }
.q-text { font-size: 1.15rem; font-weight: 600; margin-bottom: 16px; }
.opts { display: grid; gap: 10px; }
.opt { text-align: left; border: 2px solid var(--line); background: var(--card); padding: 13px 16px; border-radius: 12px; cursor: pointer; font-size: 1rem; display: flex; gap: 12px; align-items: flex-start; }
.opt:hover:not(:disabled) { border-color: var(--gold); }
.opt .k { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--gold-soft); display: grid; place-items: center; font-weight: 700; font-size: .85rem; }
.opt.right { border-color: var(--ok); background: var(--ok-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt:disabled { cursor: default; }
.feedback { margin-top: 16px; padding: 14px 16px; border-radius: 12px; }
.feedback.ok { background: var(--ok-soft); } .feedback.bad { background: var(--bad-soft); }
.score-big { font-size: 3.2rem; font-weight: 800; line-height: 1; }

/* writing / speaking */
.wordcount { font-size: .85rem; color: var(--muted); }
.ai-out { background: var(--soft); border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
.ai-out.streaming::after { content: "▍"; color: var(--gold-deep); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0; } }
.level { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; }
.level b { background: var(--navy); color: var(--gold); border-radius: 8px; padding: 2px 10px; }
.words span { padding: 1px 3px; border-radius: 4px; }
.words .hit { background: var(--ok-soft); color: var(--ok); }
.words .miss { background: var(--bad-soft); color: var(--bad); text-decoration: underline dotted; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #fff; animation: blink 1s infinite; }
.notice { background: var(--info-soft); border-radius: 12px; padding: 12px 16px; font-size: .93rem; }
.history details { border-top: 1px solid var(--line); padding: 10px 0; }
.history summary { cursor: pointer; font-weight: 600; }

/* tutor drawer */
.kora-fab { position: fixed; right: 22px; bottom: 26px; z-index: 25; background: var(--navy); color: #fff; border: 0; border-radius: 999px;
  padding: 13px 20px; font-weight: 700; box-shadow: 0 6px 20px rgba(8,13,20,.3); cursor: pointer; display: flex; gap: 8px; align-items: center; }
.kora-fab .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--gold); }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100vw); background: var(--card); z-index: 40; display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .25s; box-shadow: -8px 0 30px rgba(8,13,20,.15); }
.drawer.open { transform: none; }
.drawer-head { background: var(--navy); color: #fff; display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; padding-top: max(14px, env(safe-area-inset-top)); }
.drawer-head small { display: block; color: #aab3bf; font-size: .8rem; }
.chat { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 88%; padding: 10px 14px; border-radius: 14px; font-size: .97rem; }
.msg.user { align-self: flex-end; background: var(--navy); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--soft); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg p:last-child, .msg ul:last-child { margin-bottom: 0; }
.chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.chat-form textarea { resize: none; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 12px; font-size: .85rem; cursor: pointer; }
.scrim { position: fixed; inset: 0; background: rgba(8,13,20,.4); z-index: 35; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 90px; background: var(--navy); color: #fff; padding: 12px 20px; border-radius: 12px; z-index: 50; box-shadow: var(--shadow); }

/* tables */
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.tright { text-align: right; }

/* certificate */
.cert { background: #fff; color: #18202b; border: 10px solid var(--navy); outline: 2px solid var(--gold); outline-offset: -18px; padding: 56px 48px; text-align: center; max-width: 900px; margin: 0 auto; }
.cert img { height: 54px; }
.cert .title { font-family: Georgia, serif; font-size: 2.4rem; color: var(--navy); margin: 18px 0 6px; }
.cert .name { font-family: Georgia, serif; font-size: 2.1rem; color: var(--gold-deep); border-bottom: 1px solid var(--gold); display: inline-block; padding: 0 30px 6px; margin: 14px 0; }
.cert .meta { display: flex; justify-content: space-between; margin-top: 40px; font-size: .9rem; color: var(--muted); }
.cert .note { font-size: .75rem; color: var(--muted); margin-top: 26px; }

@media (max-width: 820px) {
  .unit-head .pill { white-space: normal; }
  h2.task { font-size: 1.05rem; }
  h1 { font-size: 1.4rem; }
  .mainnav { display: none; }
  .topbar { padding: 10px 16px; }
  .app { padding: 18px 14px 130px; }
  .grid.g3, .grid.g2, .hero { grid-template-columns: 1fr; }
  .hero { padding: 22px; }
  .kora-fab { bottom: calc(76px + env(safe-area-inset-bottom)); right: 14px; }
  .card { padding: 18px; }
  .cert { padding: 30px 18px; border-width: 6px; }
  .cert .title { font-size: 1.7rem; } .cert .name { font-size: 1.6rem; }
  .cert .meta { flex-direction: column; gap: 6px; }
}
@media (min-width: 821px) { .tabbar { display: none !important; } }
@media print {
  .topbar, .tabbar, .kora-fab, .no-print, .drawer, .scrim { display: none !important; }
  body { background: #fff; } .app { padding: 0; max-width: none; }
  @page { size: landscape; margin: 12mm; }
}

.btn.gold, .btn.gold:hover { color: #080D14; }
.pill.A, .pill.B, .pill.C, .pill.D { filter: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme=light]) .pill.A, :root:not([data-theme=light]) .pill.B, :root:not([data-theme=light]) .pill.C, :root:not([data-theme=light]) .pill.D { background: var(--info-soft); color: var(--ink); } }
:root[data-theme=dark] .pill.A, :root[data-theme=dark] .pill.B, :root[data-theme=dark] .pill.C, :root[data-theme=dark] .pill.D { background: var(--info-soft); color: var(--ink); }
.who { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin: 18px 0; }
.who button { border: 2px solid var(--line); background: var(--card); border-radius: 14px; padding: 18px 10px; cursor: pointer; font-weight: 700; font-size: 1rem; min-height: 44px; }
.who button:hover { border-color: var(--gold); }
.who .av { display: grid; place-items: center; width: 54px; height: 54px; margin: 0 auto 10px; border-radius: 50%; background: var(--navy); color: var(--gold); font-size: 1.4rem; }
.confirm { background: var(--bad-soft); border-radius: 10px; padding: 10px 12px; margin-top: 8px; }
.mic-on { box-shadow: 0 0 0 4px var(--bad-soft); }
.cert-wrap { overflow-x: auto; }
.unit-head .pill { white-space: normal; }
.scroll { overflow-x: auto; }
.lg-d { display: none; }
:root[data-theme=dark] .lg-l { display: none; } :root[data-theme=dark] .lg-d { display: inline; }
@media (prefers-color-scheme: dark) { :root:not([data-theme=light]) .lg-l { display: none; } :root:not([data-theme=light]) .lg-d { display: inline; } }
.voice-tg { border: 1px solid #334; background: transparent; color: var(--gold); border-radius: 999px; padding: 6px 12px; font-size: .82rem; font-weight: 700; cursor: pointer; margin-right: 6px; min-height: 36px; }
.voice-tg[aria-pressed=false] { color: #aab3bf; }
.drawer-head .spacer { flex: 1; }
.say-msg { display: inline-block; margin-top: 6px; border: 0; background: transparent; color: var(--gold-deep); font-weight: 700; font-size: .82rem; cursor: pointer; padding: 4px 0; }
.chat-form .mic { padding: 8px 12px; font-size: 1.2rem; }
.chat-form .mic.rec { background: var(--bad); border-color: var(--bad); color: #fff; font-size: .9rem; }
.opt.sel { border-color: var(--gold); background: var(--gold-soft); }
.rq + .rq { border-top: 1px solid var(--line); padding-top: 16px; }
.rq-in { max-width: 420px; }
.vocab { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.voc { border-left: 3px solid var(--gold); padding: 2px 0 2px 12px; }
