:root {
  --bg: #f5f6f9; --surface: #ffffff; --surface-2: #f1f3f7; --ink: #1e2230; --muted: #667085; --line: #e3e6ed;
  --primary: #4a5bd4; --primary-ink: #ffffff; --primary-soft: #eef0fc; --primary-strong: #3b4bbd; --primary-2: #6b7be6;
  --rec: #dc4c4c; --rec-soft: #fcefee;
  --ok: #2e9e6e; --ok-soft: #e8f5ee; --mid: #c98a1b; --mid-soft: #fbf3e2; --bad: #cf4b4b; --bad-soft: #fbecec; --new: #d3d8e3;
  --user: #4a5bd4; --user-ink: #ffffff;
  --shadow: 0 1px 2px rgba(22, 28, 45, .05), 0 4px 14px rgba(22, 28, 45, .05);
  --radius: 14px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --pad: 16px;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12141c; --surface: #1a1d28; --surface-2: #222634; --ink: #e6e8ef; --muted: #9ba2b4; --line: #2d3242;
    --primary: #8391f0; --primary-ink: #12141c; --primary-soft: #262c47; --primary-strong: #a2adf5; --primary-2: #9aa6f3;
    --rec: #ef6b6b; --rec-soft: #3a2226; --ok: #52bf8c; --ok-soft: #1a3329; --mid: #e3ac4f; --mid-soft: #3a3020; --bad: #ec7272; --bad-soft: #3b2226; --new: #363c50;
    --user: #4f5fd6; --user-ink: #ffffff; --shadow: 0 1px 2px rgba(0,0,0,.25), 0 4px 16px rgba(0,0,0,.2);
  }
}
:root[data-theme="dark"] {
  --bg: #12141c; --surface: #1a1d28; --surface-2: #222634; --ink: #e6e8ef; --muted: #9ba2b4; --line: #2d3242;
  --primary: #8391f0; --primary-ink: #12141c; --primary-soft: #262c47; --primary-strong: #a2adf5; --primary-2: #9aa6f3;
  --rec: #ef6b6b; --rec-soft: #3a2226; --ok: #52bf8c; --ok-soft: #1a3329; --mid: #e3ac4f; --mid-soft: #3a3020; --bad: #ec7272; --bad-soft: #3b2226; --new: #363c50;
  --user: #4f5fd6; --user-ink: #ffffff; --shadow: 0 1px 2px rgba(0,0,0,.25), 0 4px 16px rgba(0,0,0,.2);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { display: grid; grid-template-columns: 300px 1fr; background: var(--bg); color: var(--ink); font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
button, select, textarea, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--primary); }
svg.ic { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.grow { flex: 1; }
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
[hidden] { display: none !important; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 8px 14px; font-weight: 600; font-size: 14px; transition: background .15s, border-color .15s, transform .05s; }
.btn:hover { border-color: var(--primary); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { background: var(--primary-strong); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; border: none; background: transparent; color: var(--muted); }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn.on { color: var(--primary); background: var(--primary-soft); }
.round { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; border: none; flex: none; }
.round svg.ic { width: 20px; height: 20px; }
.round.send { background: var(--primary); color: var(--primary-ink); }
.round.send:disabled { opacity: .45; }
.round.mic { background: var(--primary-soft); color: var(--primary); }
.round.mic:hover { background: var(--primary); color: var(--primary-ink); }
.round.ghost { background: var(--surface-2); color: var(--muted); }
.logo { width: 38px; height: 38px; border-radius: 11px; background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; display: grid; place-items: center; font-weight: 800; letter-spacing: .02em; flex: none; }
.logo.lg { width: 56px; height: 56px; border-radius: 16px; font-size: 20px; }
.pill { font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 99px; background: var(--primary-soft); color: var(--primary); }

/* sidebar */
.side { background: var(--surface); border-right: 1px solid var(--line); padding: var(--s4); overflow-y: auto; display: flex; flex-direction: column; gap: var(--s1); }
.brand { display: flex; gap: var(--s3); align-items: center; margin-bottom: var(--s2); }
.brand-txt { min-width: 0; flex: 1; }
.brand-txt strong { display: block; font-size: 15px; }
#who { margin-top: 2px; border: 1px solid var(--line); border-radius: 8px; padding: 3px 6px; background: var(--surface-2); font-size: 13px; font-weight: 600; max-width: 100%; }
.side h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: var(--s4) var(--s3) var(--s2); }
.actions { display: grid; gap: var(--s1); }
.action { display: flex; align-items: center; gap: var(--s3); text-align: left; border: none; background: transparent; padding: var(--s2) var(--s3); border-radius: 10px; font-weight: 600; font-size: 14px; color: var(--ink); }
.action:hover { background: var(--primary-soft); color: var(--primary); }
.action svg.ic { color: var(--primary); }
.side-foot { margin-top: auto; padding-top: 14px; font-size: 12px; color: var(--muted); }

.level { border: 1px solid var(--line); border-radius: 12px; padding: var(--s3); margin-bottom: var(--s2); cursor: pointer; background: var(--surface); transition: border-color .15s; }
.level:hover { border-color: var(--primary); }
.level.current { border-color: var(--primary); background: var(--primary-soft); }
.level .top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.level .name { font-weight: 700; }
.level .tag { font-size: 12px; color: var(--muted); white-space: nowrap; }
.level.passed .tag { color: var(--ok); font-weight: 600; }
.level.current .tag { color: var(--primary); font-weight: 700; }
.bar { display: flex; height: 6px; border-radius: 99px; overflow: hidden; background: var(--new); margin: 7px 0 5px; }
.bar i { display: block; height: 100%; }
.bar .m { background: var(--ok); } .bar .l { background: var(--mid); } .bar .g { background: var(--bad); }
.level .nums { font-size: 12px; color: var(--muted); }
.level .nums b { color: var(--bad); }

#plan .label { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--primary); margin: 2px 0 6px; }
#plan .focus { border: 1px solid var(--rec); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; background: var(--rec-soft); }
#plan .focus .label { color: var(--rec); }
#plan .ft { font-weight: 700; margin: 2px 0; }
#plan .fs { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
#plan .focus .btn { margin-top: 6px; width: 100%; justify-content: center; }
#plan .queue { margin: 0; padding-left: 20px; font-size: 13px; display: grid; gap: 4px; }
#plan .queue small { color: var(--muted); }
.lv { font-size: 11px; font-weight: 700; border: 1px solid var(--line); border-radius: 6px; padding: 0 5px; color: var(--muted); background: var(--surface); }
.badge { font-size: 10px; font-weight: 700; text-transform: uppercase; background: var(--primary); color: var(--primary-ink); border-radius: 6px; padding: 1px 5px; vertical-align: middle; }

/* main + topbar */
main { display: flex; flex-direction: column; min-width: 0; height: 100vh; height: 100dvh; }
.topbar { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s5); border-bottom: 1px solid var(--line); background: var(--surface); }
.topbar .menu { display: none; }
.top-title { display: none; align-items: center; gap: 8px; min-width: 0; }
.top-title strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tabs { display: flex; gap: 2px; flex: 1; }
.tabs button { display: inline-flex; align-items: center; gap: 7px; border: none; background: transparent; padding: 8px 12px; border-radius: 10px; color: var(--muted); font-size: 14px; }
.tabs button b { font-weight: 600; }
.tabs button:hover { color: var(--ink); background: var(--surface-2); }
.tabs button.on { color: var(--primary); background: var(--primary-soft); }
.top-actions { display: flex; gap: 2px; }
.tab { display: none; flex: 1; min-height: 0; overflow-y: auto; }
.tab.on { display: block; }
#tab-chat.on { display: flex; flex-direction: column; }
.page { padding: 22px 26px 40px; max-width: 1100px; margin: 0 auto; }

/* chat */
#messages { flex: 1; overflow-y: auto; padding: var(--s5) var(--s5) var(--s4); display: flex; flex-direction: column; gap: var(--s4); scroll-behavior: smooth; }
#messages > * { width: 100%; max-width: 820px; margin-left: auto; margin-right: auto; }
.row-msg { display: flex; gap: var(--s3); align-items: flex-start; }
.row-msg.user { justify-content: flex-end; padding-left: 42px; }
.avatar { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; font-size: 11px; font-weight: 800; display: grid; place-items: center; flex: none; margin-top: 2px; }
.msg { min-width: 0; }
.msg.assistant { flex: 1; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); padding: var(--s4) var(--s5); border-radius: 4px 16px 16px 16px; }
.msg.user { max-width: 85%; background: var(--user); color: var(--user-ink); padding: var(--s3) var(--s4); border-radius: 16px 4px 16px 16px; box-shadow: var(--shadow); }
.msg > :first-child { margin-top: 0; }
.msg .meta { font-size: 12px; opacity: .75; margin-top: var(--s3); display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }
.msg .meta .btn { padding: 2px 8px; font-size: 12px; background: transparent; color: inherit; border-color: currentColor; opacity: .9; }
.msg.user .meta .btn { border-color: rgba(255,255,255,.5); }
.msg p { margin: 0 0 9px; } .msg p:last-child { margin-bottom: 0; }
.msg ul, .msg ol { margin: 4px 0 10px; padding-left: 22px; }
.msg li { margin: 2px 0; }
.msg h1, .msg h2, .msg h3, .msg h4, .msg h5 { margin: 14px 0 6px; font-size: 16px; line-height: 1.3; }
.msg h2 { font-size: 18px; }
.msg code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: 13.5px; }
.msg table { border-collapse: collapse; margin: 8px 0 12px; font-size: 14px; display: block; overflow-x: auto; }
.msg th, .msg td { border: 1px solid var(--line); padding: 5px 9px; text-align: left; }
.msg th { background: var(--surface-2); }
.msg blockquote { margin: 8px 0; padding: 6px 12px; border-left: 3px solid var(--primary); background: var(--primary-soft); border-radius: 0 8px 8px 0; }
.msg del { color: var(--bad); }
.voice-note { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.heard { font-size: 12px; opacity: .9; margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px; }
.heard span { background: rgba(255,255,255,.18); border-radius: 6px; padding: 0 6px; }
.answers summary { cursor: pointer; display: flex; align-items: center; gap: 8px; font-weight: 600; list-style: none; }
.answers summary::-webkit-details-marker { display: none; }
.answers summary small { font-weight: 400; opacity: .8; }
.answers pre { white-space: pre-wrap; font: inherit; font-size: 13px; margin: 8px 0 0; opacity: .92; }
.typing { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.typing .bubble { background: var(--surface); border: 1px solid var(--line); border-radius: 4px 16px 16px 16px; padding: 12px 16px; display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow); }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); opacity: .35; animation: dot 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; } .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes dot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.empty h2 { color: var(--ink); margin: 0 0 6px; }
.starters { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin: 22px auto 0; max-width: 640px; text-align: left; }
.starter { border: 1px solid var(--line); background: var(--surface); border-radius: 14px; padding: 14px; box-shadow: var(--shadow); display: grid; gap: 4px; }
.starter:hover { border-color: var(--primary); }
.starter b { display: flex; align-items: center; gap: 8px; color: var(--ink); }
.starter b svg { color: var(--primary); }
.starter small { color: var(--muted); }

.card { border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px; padding: var(--s4); margin: var(--s4) 0; display: grid; gap: var(--s3); }
.card .label, .q-label { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--primary); font-weight: 800; }
.card .phrase, .q-phrase { font-size: 18px; font-weight: 650; line-height: 1.4; }
.card .phrase.hidden { filter: blur(7px); user-select: none; }
.btnrow { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* recorder button */
.recbtn { display: inline-flex; align-items: center; justify-self: start; gap: var(--s2); border: 1px solid transparent; border-radius: 99px; padding: 9px 18px 9px 14px; font-weight: 700; font-size: 14px; background: var(--primary-soft); color: var(--primary); transition: background .15s, color .15s; }
.recbtn:hover { background: var(--primary); color: var(--primary-ink); }
.recbtn.redo { background: var(--surface); color: var(--primary); border-color: var(--line); }
.recbtn.redo:hover { border-color: var(--primary); background: var(--surface); }
.recbtn.live { background: var(--rec); color: #fff; animation: pulse 1.4s infinite; }
.recbtn.live .t { font-variant-numeric: tabular-nums; }
.recbtn.busy { background: var(--surface-2); color: var(--muted); box-shadow: none; }
.recbtn:disabled { opacity: .6; cursor: default; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(220,76,76,.4); } 70% { box-shadow: 0 0 0 10px rgba(220,76,76,0); } 100% { box-shadow: 0 0 0 0 rgba(220,76,76,0); } }
.said { display: flex; align-items: flex-start; gap: 8px; background: var(--ok-soft); color: var(--ink); border-radius: 10px; padding: 8px 10px; font-size: 14px; }
.said > svg { color: var(--ok); margin-top: 2px; }
.said em { font-style: normal; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--primary); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* quiz */
.quiz { border: 1px solid var(--line); border-radius: 16px; margin: var(--s4) 0; background: var(--bg); overflow: hidden; }
.quiz.sent { opacity: .8; }
.q-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s3) calc(var(--s3) + var(--s4)); background: var(--primary-soft); }
.q-title { display: flex; align-items: center; gap: var(--s2); font-weight: 800; color: var(--primary); min-width: 0; }
.q-progress { font-size: 12px; font-weight: 700; color: var(--primary); white-space: nowrap; }
.quiz ol { list-style: none; margin: 0; padding: var(--s3); display: grid; gap: var(--s3); }
.q-item { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: var(--s4); display: grid; gap: var(--s3); transition: border-color .15s; }
.q-top { display: flex; align-items: center; gap: var(--s2); }
.q-num { width: 24px; height: 24px; border-radius: 50%; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 800; display: grid; place-items: center; flex: none; }
.q-item.done { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }
.q-item.done .q-num { background: var(--ok); color: #fff; }
.q-top .q-label { margin: 0; }
.q-prompt { line-height: 1.55; }
.q-prompt:has(.q-gap) { line-height: 2.1; }
.q-gap { border: none; border-bottom: 2px solid var(--primary); background: var(--primary-soft); border-radius: 6px 6px 0 0; padding: 0 6px; min-width: 5ch; width: 7ch; margin: 0 3px; outline: none; font-weight: 600; text-align: center; }
.q-gap.wide { width: 100%; max-width: 420px; text-align: left; }
.q-gap:focus { background: var(--surface-2); box-shadow: 0 2px 0 var(--primary); }
.q-opts { display: flex; gap: 8px; flex-wrap: wrap; }
.q-opts label { position: relative; }
.q-opts input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.q-opts span { display: inline-block; border: 1.5px solid var(--line); border-radius: 99px; padding: 6px 14px; font-weight: 600; font-size: 14px; background: var(--surface); transition: all .12s; }
.q-opts input:checked + span { border-color: var(--primary); background: var(--primary); color: var(--primary-ink); }
.q-opts input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.quiz textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; background: var(--surface-2); resize: vertical; min-height: 44px; }
.quiz textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; background: var(--surface); }
.q-foot { padding: 0 var(--s3) var(--s3); display: grid; gap: var(--s2); }
.q-foot .btn { justify-content: center; padding: 11px; font-size: 15px; }
.q-foot .note { text-align: center; font-weight: 700; color: var(--ok); padding: 8px; }
.q-foot .note.closed { color: var(--muted); font-weight: 600; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.chip { font-size: 12px; border-radius: 99px; padding: 3px 10px; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); }
.chip a { font-weight: 700; }
.chip.up { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.chip.down { color: var(--bad); background: var(--bad-soft); border-color: transparent; }

/* composer */
.composer-wrap { border-top: 1px solid var(--line); background: var(--surface); padding: var(--s3) var(--s5) calc(var(--s3) + env(safe-area-inset-bottom)); }
.composer-wrap > * { max-width: 820px; margin-left: auto; margin-right: auto; }
#composer { display: flex; gap: 8px; align-items: flex-end; background: var(--surface-2); border: 1px solid var(--line); border-radius: 24px; padding: 5px 5px 5px 16px; }
#composer:focus-within { border-color: var(--primary); }
#composer textarea { flex: 1; resize: none; border: none; background: transparent; padding: 11px 0; max-height: 180px; outline: none; line-height: 1.4; }
.recbar { display: flex; align-items: center; gap: 12px; background: var(--rec-soft); border: 1px solid var(--rec); border-radius: 24px; padding: 5px; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--rec); animation: blink 1s infinite; flex: none; }
@keyframes blink { 50% { opacity: .3; } }
.rec-time { font-weight: 800; color: var(--rec); font-variant-numeric: tabular-nums; min-width: 3.2em; }
#recLevel { flex: 1; min-width: 0; height: 32px; }
.busybar { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 12px; color: var(--muted); font-weight: 600; }

/* pages */
.page h2 { margin: 0 0 4px; font-size: 20px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.lvl-block { margin-bottom: 26px; }
.lvl-block .goal { color: var(--muted); margin: 0 0 12px; font-size: 14px; }
.area { margin: 12px 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; }
.skills { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 8px; }
.skill { border: 1px solid var(--line); border-left: 4px solid var(--new); border-radius: 10px; padding: 9px 11px; background: var(--surface); cursor: pointer; }
.skill.gap { border-left-color: var(--bad); } .skill.learning { border-left-color: var(--mid); } .skill.mastered { border-left-color: var(--ok); }
.skill .t { font-weight: 650; font-size: 14px; }
.skill .s { font-size: 12px; color: var(--muted); }
.skill .detail { display: none; font-size: 13px; margin-top: 8px; color: var(--muted); }
.skill.open .detail { display: grid; gap: 8px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-bottom: 18px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }
.covgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px; margin-bottom: 22px; }
.level.cov { cursor: default; }
.level.cov .nums { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.sect { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; margin: 8px 0 10px; }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
table.list { border-collapse: collapse; width: 100%; }
table.list th, table.list td { border-bottom: 1px solid var(--line); padding: 9px 12px; text-align: left; vertical-align: top; font-size: 14px; }
table.list tr:last-child td { border-bottom: none; }
table.list th { color: var(--muted); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; background: var(--surface-2); }
.wrong { color: var(--bad); text-decoration: line-through; } .right { color: var(--ok); font-weight: 650; }

/* login + dialog */
.login { position: fixed; inset: 0; background: var(--bg); display: grid; place-items: center; z-index: 60; padding: 16px; }
.login form { background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 20px; padding: 30px 26px; width: min(380px, 100%); display: grid; gap: 12px; text-align: center; justify-items: center; }
.login h2 { margin: 4px 0 0; }
.login p { margin: 0; color: var(--muted); }
.login input { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--surface-2); }
.login .err { color: var(--bad); min-height: 1em; }
dialog { border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--ink); width: min(460px, calc(100% - 32px)); box-shadow: var(--shadow); padding: 20px 22px; }
dialog::backdrop { background: rgba(10, 12, 30, .45); }
dialog h3 { margin: 0 0 8px; }
dialog label { display: grid; gap: 5px; margin: 12px 0; font-size: 14px; font-weight: 600; }
dialog label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
dialog select { padding: 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); }
dialog .range { display: flex; align-items: center; gap: 10px; }
dialog .range input { flex: 1; }
dialog .row { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.scrim { display: none; }

/* mobile */
@media (max-width: 860px) {
  body { grid-template-columns: 1fr; font-size: 15.5px; }
  .side { position: fixed; inset: 0 auto 0 0; width: min(320px, 88vw); z-index: 40; transform: translateX(-105%); transition: transform .22s ease; box-shadow: var(--shadow); padding-top: calc(16px + env(safe-area-inset-top)); }
  body.menu-open .side { transform: none; }
  body.menu-open .scrim { display: block; position: fixed; inset: 0; background: rgba(10, 12, 30, .4); z-index: 35; }
  .topbar { padding: calc(6px + env(safe-area-inset-top)) 8px 6px; gap: 4px; }
  .topbar .menu { display: inline-grid; }
  .top-title { display: flex; flex: 1; }
  .tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--line); justify-content: space-around; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); gap: 0; }
  .tabs button { flex-direction: column; gap: 2px; padding: 6px 4px; font-size: 11px; flex: 1; border-radius: 10px; }
  .tabs button b { font-weight: 600; }
  .tabs button svg.ic { width: 21px; height: 21px; }
  main { padding-bottom: calc(58px + env(safe-area-inset-bottom)); }
  .composer-wrap { padding: var(--s2) var(--s3) var(--s3); }
  #messages { padding: var(--s4) var(--s3) var(--s3); gap: var(--s3); }
  .avatar { display: none; }
  .row-msg.user { padding-left: var(--s6); }
  .msg.assistant { padding: var(--s4); }
  .msg.user { max-width: 100%; }
  .page { padding: var(--s4) var(--s3) var(--s6); }
  .quiz { margin: var(--s3) 0; }
  .quiz ol { padding: var(--s2); gap: var(--s2); }
  .q-head { padding: var(--s3) calc(var(--s2) + var(--s3)); }
  .q-item { padding: var(--s3); }
  .q-foot { padding: 0 var(--s2) var(--s2); }
  .card .phrase, .q-phrase { font-size: 17px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
