:root {
  --bg: #f6f6fb;
  --bg-soft: #eeeef8;
  --card: #ffffff;
  --card-2: #fafaff;
  --text: #17162b;
  --muted: #5f6078;
  --faint: #9a9bb2;
  --line: #e4e4f0;
  --brand: #5b4cf0;
  --brand-2: #7c3aed;
  --brand-soft: #ecebff;
  --on-brand: #ffffff;
  --good: #16a34a;
  --good-soft: #dcfce7;
  --bad: #dc2626;
  --bad-soft: #fee2e2;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --visual: #0891b2;
  --visual-soft: #cffafe;
  --audio: #db2777;
  --audio-soft: #fce7f3;
  --inter: #ea580c;
  --inter-soft: #ffedd5;
  --shadow: 0 1px 2px rgba(23, 22, 43, .05), 0 4px 16px rgba(23, 22, 43, .06);
  --shadow-lg: 0 10px 40px rgba(23, 22, 43, .16);
  --radius: 16px;
  --radius-sm: 10px;
  --c1: #5b4cf0; --c2: #0891b2; --c3: #db2777; --c4: #ea580c; --c5: #16a34a; --c6: #ca8a04; --c7: #7c3aed; --c8: #0d9488;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0f1c; --bg-soft: #161729; --card: #171829; --card-2: #1c1d31; --text: #ececf7; --muted: #a8a9c4; --faint: #6d6e8a;
    --line: #2a2b44; --brand: #8b7fff; --brand-2: #a78bfa; --brand-soft: #25224a; --on-brand: #0e0f1c;
    --good: #4ade80; --good-soft: #14321f; --bad: #f87171; --bad-soft: #3a1818; --warn: #fbbf24; --warn-soft: #3a2c0c;
    --visual: #22d3ee; --visual-soft: #0c2e36; --audio: #f472b6; --audio-soft: #3a1328; --inter: #fb923c; --inter-soft: #3a200e;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25); --shadow-lg: 0 10px 40px rgba(0,0,0,.5);
    --c1: #8b7fff; --c2: #22d3ee; --c3: #f472b6; --c4: #fb923c; --c5: #4ade80; --c6: #facc15; --c7: #c4b5fd; --c8: #2dd4bf;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e0f1c; --bg-soft: #161729; --card: #171829; --card-2: #1c1d31; --text: #ececf7; --muted: #a8a9c4; --faint: #6d6e8a;
  --line: #2a2b44; --brand: #8b7fff; --brand-2: #a78bfa; --brand-soft: #25224a; --on-brand: #0e0f1c;
  --good: #4ade80; --good-soft: #14321f; --bad: #f87171; --bad-soft: #3a1818; --warn: #fbbf24; --warn-soft: #3a2c0c;
  --visual: #22d3ee; --visual-soft: #0c2e36; --audio: #f472b6; --audio-soft: #3a1328; --inter: #fb923c; --inter-soft: #3a200e;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25); --shadow-lg: 0 10px 40px rgba(0,0,0,.5);
  --c1: #8b7fff; --c2: #22d3ee; --c3: #f472b6; --c4: #fb923c; --c5: #4ade80; --c6: #facc15; --c7: #c4b5fd; --c8: #2dd4bf;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.55 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
p { margin: 0 0 .8em; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 18px;
  padding: 20px 14px; background: var(--card); border-right: 1px solid var(--line); overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-size: 20px; font-weight: 600; padding: 0 8px; }
.brand b { color: var(--brand); font-weight: 800; }
.brand-name { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name small { font-size: 11.5px; font-weight: 600; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); padding: 14px 10px 6px; }
.side-link {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; border: 0; background: none;
  color: var(--muted); cursor: pointer; text-align: left; font-weight: 500; width: 100%; text-decoration: none;
}
.side-link:hover { background: var(--bg-soft); color: var(--text); }
.side-link.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.side-link .t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.main { padding: 28px clamp(16px, 4vw, 44px) 80px; max-width: 1180px; width: 100%; min-width: 0; outline: none; }
.grid > *, .row > * { min-width: 0; }

/* ---------- primitives ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.card + .card { margin-top: 16px; }
.card h3 { font-size: 17px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.stack > * + * { margin-top: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--card); color: var(--text); font-weight: 600; cursor: pointer;
  transition: transform .08s, background .15s, border-color .15s; white-space: nowrap; text-decoration: none; min-height: 42px;
}
.btn:hover { border-color: var(--brand); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border-color: transparent; }
:root[data-theme="dark"] .btn.primary { color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--bg-soft); color: var(--text); }
.btn.sm { padding: 6px 11px; min-height: 34px; font-size: 13px; border-radius: 9px; }
.btn.lg { padding: 14px 22px; font-size: 16px; min-height: 52px; border-radius: 14px; }
.btn.icon { padding: 0; width: 42px; }
.btn.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.btn.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.btn.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: var(--bg-soft); color: var(--muted); }
.chip.brand { background: var(--brand-soft); color: var(--brand); }
.chip.visual { background: var(--visual-soft); color: var(--visual); }
.chip.audio { background: var(--audio-soft); color: var(--audio); }
.chip.inter { background: var(--inter-soft); color: var(--inter); }
.chip.good { background: var(--good-soft); color: var(--good); }
.chip svg.i { width: 14px; height: 14px; }

.input, .select, textarea.input {
  width: 100%; padding: 11px 13px; border-radius: 11px; border: 1px solid var(--line); background: var(--card-2); outline: none;
}
.input:focus, .select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea.input { resize: vertical; min-height: 220px; line-height: 1.5; }
label.field { display: block; font-weight: 600; font-size: 13px; margin-bottom: 12px; }
label.field > span { display: block; margin-bottom: 6px; }

.progress { height: 8px; border-radius: 99px; background: var(--bg-soft); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); transition: width .35s; }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty svg.i { width: 40px; height: 40px; color: var(--faint); margin-bottom: 10px; }

/* ---------- home ---------- */
.hero {
  position: relative; overflow: hidden; border-radius: 22px; padding: clamp(24px, 4vw, 40px);
  background: radial-gradient(1200px 400px at 100% 0%, rgba(124, 58, 237, .18), transparent 60%),
              radial-gradient(800px 300px at 0% 100%, rgba(8, 145, 178, .14), transparent 60%), var(--card);
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.hero h1 { font-size: clamp(26px, 4vw, 38px); font-weight: 800; letter-spacing: -0.025em; max-width: 720px; }
.hero h1 em { font-style: normal; background: linear-gradient(135deg, var(--brand), var(--visual)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p.lead { font-size: 16.5px; color: var(--muted); max-width: 640px; margin: 12px 0 22px; }
.dropzone {
  border: 2px dashed color-mix(in srgb, var(--brand) 45%, var(--line)); border-radius: 18px; padding: 26px; text-align: center;
  background: color-mix(in srgb, var(--brand-soft) 45%, transparent); transition: .15s;
}
.dropzone.drag { background: var(--brand-soft); border-color: var(--brand); transform: scale(1.01); }
.dropzone .big { font-weight: 700; font-size: 17px; margin: 6px 0 4px; }
.dropzone .row { justify-content: center; margin-top: 16px; }
.formats { font-size: 12.5px; color: var(--faint); margin-top: 12px; }
.style-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 22px; }
.style-tile { border-radius: 14px; padding: 14px; display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--line); background: var(--card); }
.style-tile .ico { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.style-tile b { display: block; font-size: 14px; }
.style-tile span { font-size: 12.5px; color: var(--muted); }
.ico.visual { background: var(--visual-soft); color: var(--visual); }
.ico.audio { background: var(--audio-soft); color: var(--audio); }
.ico.inter { background: var(--inter-soft); color: var(--inter); }
.ico.brand { background: var(--brand-soft); color: var(--brand); }

.section-head { display: flex; align-items: flex-end; gap: 12px; margin: 34px 0 14px; }
.section-head h2 { font-size: 20px; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.set-card { cursor: pointer; transition: transform .12s, box-shadow .12s; display: flex; flex-direction: column; gap: 10px; padding: 18px; }
.set-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.set-card h4 { font-size: 16px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.set-card .meta { font-size: 12.5px; color: var(--muted); }
.stat-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.stat span { font-size: 12.5px; color: var(--muted); }

/* ---------- set view ---------- */
.set-head { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 18px; flex-wrap: wrap; }
.set-head h1 { font-size: clamp(22px, 3vw, 30px); font-weight: 800; letter-spacing: -0.02em; }
.set-head .row { margin-top: 10px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 4px; margin: 0 -4px 20px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px; border-radius: 11px; border: 1px solid var(--line);
  background: var(--card); color: var(--muted); font-weight: 600; cursor: pointer; white-space: nowrap; position: relative;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.tab .dot { width: 7px; height: 7px; border-radius: 50%; }
.tab .dot.visual { background: var(--visual); } .tab .dot.audio { background: var(--audio); } .tab .dot.inter { background: var(--inter); }
.tab .foryou { position: absolute; top: -7px; right: -4px; font-size: 10px; background: var(--brand); color: #fff; padding: 1px 6px; border-radius: 99px; font-weight: 700; }

.summary p { font-size: 15.5px; }
.points { list-style: none; padding: 0; margin: 0; counter-reset: p; }
.points li { counter-increment: p; position: relative; padding: 10px 0 10px 40px; border-bottom: 1px solid var(--line); }
.points li:last-child { border-bottom: 0; }
.points li::before {
  content: counter(p); position: absolute; left: 0; top: 10px; width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: 13px;
}
.term-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.term { border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: 12px; padding: 12px 14px; background: var(--card-2); }
.term b { display: block; margin-bottom: 4px; }
.term span { font-size: 13.5px; color: var(--muted); }
mark.kt { background: color-mix(in srgb, var(--warn) 22%, transparent); color: inherit; border-radius: 4px; padding: 0 2px; cursor: help; border-bottom: 2px solid var(--warn); }

/* learn */
.lesson { max-width: 780px; margin: 0 auto; }
.lesson-top { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.lesson-top .progress { flex: 1; }
.lesson h2 { font-size: 24px; margin: 6px 0 16px; }
.bigidea { border-radius: 14px; padding: 16px 18px; background: linear-gradient(135deg, var(--brand-soft), transparent); border: 1px solid var(--line); margin-bottom: 18px; }
.bigidea small { font-weight: 700; color: var(--brand); text-transform: uppercase; letter-spacing: .06em; font-size: 11.5px; }
.bigidea p { font-size: 17px; font-weight: 600; margin: 4px 0 0; }
.explain p { font-size: 16px; line-height: 1.7; }
.takeaways { background: var(--card-2); border: 1px solid var(--line); border-radius: 14px; padding: 14px 18px; margin: 18px 0; }
.takeaways ul { margin: 6px 0 0; padding-left: 20px; }
.check { border: 2px solid var(--brand-soft); border-radius: 16px; padding: 18px; margin-top: 18px; }
.check .q { font-weight: 600; white-space: pre-line; margin-bottom: 12px; }

.opts { display: grid; gap: 10px; }
.opt {
  text-align: left; padding: 13px 15px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card); cursor: pointer;
  display: flex; gap: 12px; align-items: flex-start; font-weight: 500; transition: .12s;
}
.opt:hover:not(:disabled) { border-color: var(--brand); background: var(--brand-soft); }
.opt .k { flex: none; width: 26px; height: 26px; border-radius: 8px; background: var(--bg-soft); display: grid; place-items: center; font-size: 13px; font-weight: 700; }
.opt.correct { border-color: var(--good); background: var(--good-soft); }
.opt.correct .k { background: var(--good); color: #fff; }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong .k { background: var(--bad); color: #fff; }
.opt:disabled { cursor: default; }
.feedback { margin-top: 12px; padding: 12px 14px; border-radius: 12px; font-size: 14px; }
.feedback.good { background: var(--good-soft); color: var(--good); }
.feedback.bad { background: var(--bad-soft); color: var(--bad); }
.feedback .ex { color: var(--text); margin-top: 6px; opacity: .85; }

/* visual */
.mindmap-wrap { width: 100%; overflow: hidden; border-radius: 14px; background: var(--card-2); border: 1px solid var(--line); touch-action: none; cursor: grab; }
.mindmap-wrap:active { cursor: grabbing; }
.mindmap-wrap svg { display: block; width: 100%; height: auto; }
.mm-node { cursor: pointer; }
.mm-node text { font-family: Inter, system-ui, sans-serif; pointer-events: none; }
.bars .bar { display: grid; grid-template-columns: 170px 1fr 40px; align-items: center; gap: 10px; margin: 7px 0; font-size: 13.5px; }
.bars .bar span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.bars .track { height: 12px; border-radius: 99px; background: var(--bg-soft); overflow: hidden; }
.bars .track i { display: block; height: 100%; border-radius: 99px; }
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ''; position: absolute; left: 8px; top: 4px; bottom: 4px; width: 3px; border-radius: 3px; background: linear-gradient(var(--brand), var(--visual)); }
.tl-item { position: relative; padding: 0 0 16px; }
.tl-item::before { content: ''; position: absolute; left: -24px; top: 5px; width: 13px; height: 13px; border-radius: 50%; background: var(--card); border: 3px solid var(--brand); }
.tl-item b { color: var(--brand); display: block; }
.mnemo { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.mnemo div { flex: 1 1 110px; border-radius: 14px; padding: 12px; text-align: center; color: #fff; }
.mnemo b { display: block; font-size: 30px; font-weight: 800; line-height: 1; }
.mnemo span { font-size: 12.5px; opacity: .95; }
.concept-card { border-radius: 14px; padding: 14px; color: var(--text); border: 1px solid var(--line); background: var(--card-2); border-top: 5px solid; }
.concept-card h4 { font-size: 14.5px; margin-bottom: 6px; }
.concept-card ul { margin: 0; padding-left: 18px; font-size: 13px; color: var(--muted); }

/* listen */
.player { display: grid; grid-template-columns: 290px 1fr; gap: 16px; }
.playlist button { width: 100%; text-align: left; display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 12px; border: 1px solid transparent; background: none; cursor: pointer; }
.playlist button:hover { background: var(--bg-soft); }
.playlist button.active { background: var(--audio-soft); border-color: color-mix(in srgb, var(--audio) 30%, transparent); }
.playlist button b { display: block; font-size: 14px; }
.playlist button span { font-size: 12px; color: var(--muted); }
.transcript { max-height: 460px; overflow-y: auto; padding-right: 6px; }
.transcript .ln { padding: 7px 10px; border-radius: 9px; transition: background .2s; font-size: 15.5px; line-height: 1.6; }
.transcript .ln.h { font-weight: 700; margin-top: 8px; }
.transcript .ln.now { background: var(--audio-soft); color: var(--text); box-shadow: inset 3px 0 0 var(--audio); }
.controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px; border-radius: 14px; background: var(--card-2); border: 1px solid var(--line); margin-bottom: 14px; }
.playbtn { width: 52px; height: 52px; border-radius: 50%; border: 0; background: var(--audio); color: #fff; cursor: pointer; display: grid; place-items: center; }
.playbtn svg.i { width: 22px; height: 22px; }
.wave { display: flex; gap: 3px; align-items: center; height: 24px; }
.wave i { width: 3px; border-radius: 3px; background: var(--audio); height: 6px; }
.wave.on i { animation: wave 1s ease-in-out infinite; }
.wave i:nth-child(2) { animation-delay: .1s } .wave i:nth-child(3) { animation-delay: .2s } .wave i:nth-child(4) { animation-delay: .3s } .wave i:nth-child(5) { animation-delay: .4s }
@keyframes wave { 50% { height: 22px; } }

/* flashcards */
.fc-stage { max-width: 680px; margin: 0 auto; }
.flip { perspective: 1400px; cursor: pointer; }
.flip-inner { position: relative; min-height: 300px; transition: transform .5s cubic-bezier(.2,.8,.2,1); transform-style: preserve-3d; }
.flip.on .flip-inner { transform: rotateY(180deg); }
.face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 22px; padding: 30px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; box-shadow: var(--shadow-lg);
  border: 1px solid var(--line); background: var(--card); white-space: pre-line; overflow-y: auto;
}
.face.back { transform: rotateY(180deg); background: linear-gradient(160deg, var(--brand-soft), var(--card) 70%); }
.face .lbl { position: absolute; top: 14px; left: 18px; font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.face .content { font-size: clamp(17px, 2.4vw, 22px); font-weight: 600; line-height: 1.45; }
.face .hint { position: absolute; bottom: 14px; font-size: 12px; color: var(--faint); }
.rate { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 18px; }
.rate .btn { flex-direction: column; gap: 0; min-height: 58px; }
.rate .btn small { font-weight: 500; font-size: 11.5px; opacity: .8; }
.kbd { display: inline-block; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line); background: var(--card-2); font-size: 11.5px; font-family: ui-monospace, monospace; }
.card-list { display: grid; gap: 8px; }
.card-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; align-items: start; padding: 10px 12px; border-radius: 12px; background: var(--card-2); border: 1px solid var(--line); font-size: 14px; white-space: pre-line; }

/* quiz */
.quiz-q { font-size: 18.5px; font-weight: 600; white-space: pre-line; margin: 10px 0 18px; line-height: 1.45; }
.ring { width: 150px; height: 150px; margin: 0 auto; position: relative; }
.ring svg { transform: rotate(-90deg); }
.ring b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 34px; font-weight: 800; }
.review-item { border-left: 4px solid var(--line); padding: 8px 14px; margin: 10px 0; }
.review-item.ok { border-color: var(--good); } .review-item.no { border-color: var(--bad); }
.checks { display: flex; gap: 8px; flex-wrap: wrap; }
.checks label { display: inline-flex; gap: 8px; align-items: center; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; background: var(--card-2); font-weight: 500; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; }
.seg button { border: 0; background: var(--card); padding: 8px 14px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--brand); color: #fff; }
.spark { display: flex; align-items: flex-end; gap: 4px; height: 60px; }
.spark i { flex: 1; max-width: 22px; border-radius: 4px 4px 0 0; background: var(--brand); min-height: 3px; }

/* games */
.match-grid { display: grid; grid-template-columns: 1fr 1.6fr; gap: 12px; }
.match-col { display: grid; gap: 10px; align-content: start; }
.tile { padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card); cursor: pointer; font-size: 14px; text-align: left; transition: .15s; min-height: 50px; }
.tile:hover { border-color: var(--inter); }
.tile.sel { border-color: var(--inter); background: var(--inter-soft); }
.tile.done { opacity: 0; pointer-events: none; transform: scale(.95); }
.tile.shake { animation: shake .35s; border-color: var(--bad); background: var(--bad-soft); }
@keyframes shake { 25% { transform: translateX(-6px) } 75% { transform: translateX(6px) } }
.game-hud { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.hud { padding: 8px 14px; border-radius: 11px; background: var(--card-2); border: 1px solid var(--line); font-weight: 700; }
.sprint-card { font-size: 19px; font-weight: 600; padding: 26px; border-radius: 18px; background: var(--card-2); border: 1px solid var(--line); min-height: 140px; display: grid; place-items: center; text-align: center; }
.game-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.game-pick .card { cursor: pointer; transition: .12s; }
.game-pick .card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

/* tutor */
.chat { display: flex; flex-direction: column; gap: 12px; min-height: 320px; max-height: 60vh; overflow-y: auto; padding: 4px; }
.msg { max-width: 82%; padding: 11px 15px; border-radius: 16px; line-height: 1.55; font-size: 15px; }
.msg.me { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 5px; }
.msg.bot { align-self: flex-start; background: var(--card-2); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.msg.bot p:last-child { margin: 0; }
.msg.bot ul { margin: 4px 0; padding-left: 20px; }
.chat-input { display: flex; gap: 10px; margin-top: 14px; }
.suggest { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.suggest button { border: 1px solid var(--line); background: var(--card); border-radius: 99px; padding: 6px 12px; cursor: pointer; font-size: 13px; color: var(--muted); }
.suggest button:hover { color: var(--brand); border-color: var(--brand); }
.typing i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); margin: 0 2px; animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s } .typing i:nth-child(3) { animation-delay: .4s }
@keyframes blink { 50% { opacity: .2 } }

/* modal & toast */
.modal-root { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(10, 10, 25, .5); backdrop-filter: blur(4px); animation: fade .15s; }
.modal { background: var(--card); border-radius: 20px; box-shadow: var(--shadow-lg); width: min(620px, 100%); max-height: 90vh; overflow-y: auto; padding: 24px; border: 1px solid var(--line); }
.modal h2 { font-size: 20px; margin-bottom: 6px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
@keyframes fade { from { opacity: 0 } }
.toast-root { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 12px; box-shadow: var(--shadow-lg); font-weight: 500; animation: fade .2s; max-width: 90vw; }
.steps { list-style: none; padding: 0; margin: 16px 0 0; }
.steps li { display: flex; gap: 10px; align-items: center; padding: 6px 0; color: var(--faint); }
.steps li.on { color: var(--text); font-weight: 600; }
.steps li.done { color: var(--good); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--brand-soft); border-top-color: var(--brand); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg) } }
.style-q { margin: 16px 0; }
.style-q p { font-weight: 600; margin-bottom: 8px; }

/* markdown-ish */
.md p { margin: 0 0 .6em; }
.md strong { font-weight: 700; }

/* ---------- accounts & study groups ---------- */
.ellip { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar { display: inline-grid; place-items: center; border-radius: 50%; color: #fff; font-weight: 700; flex: none; line-height: 1; }
.badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--audio); color: #fff; font-size: 11.5px; font-weight: 700; display: grid; place-items: center; }
.account-chip { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border-radius: 12px; border: 1px solid var(--line); background: var(--card-2); cursor: pointer; text-align: left; }
.account-chip:hover { border-color: var(--brand); }
.account-chip span:last-child { min-width: 0; }
.account-chip b { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-chip small { display: block; color: var(--muted); font-size: 11.5px; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; }
.swatch.on { border-color: var(--text); }
.code-input { font-size: 26px; font-weight: 800; letter-spacing: .3em; text-align: center; text-transform: uppercase; }
.group-ico { width: 38px; height: 38px; border-radius: 12px; display: inline-grid; place-items: center; flex: none; font-weight: 800; color: #fff; background: linear-gradient(135deg, var(--brand), var(--visual)); }

.group-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; height: calc(100vh - 56px); min-height: 480px; }
.chat-card { display: flex; flex-direction: column; padding: 0; overflow: hidden; position: relative; min-height: 0; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.chat-head .btn.icon { width: 36px; min-height: 36px; }
.side-toggle { display: none; }
.gchat { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; min-height: 0; }
.gmsg { display: flex; gap: 10px; align-items: flex-end; margin-top: 10px; max-width: 78%; }
.gmsg.grouped { margin-top: 2px; }
.gmsg.own { align-self: flex-end; flex-direction: row-reverse; }
.gav { width: 32px; flex: none; }
.gbody { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.gmsg.own .gbody { align-items: flex-end; }
.gname { font-size: 12.5px; font-weight: 700; padding-left: 4px; }
.bubble { padding: 9px 13px; border-radius: 16px; background: var(--card-2); border: 1px solid var(--line); line-height: 1.5; overflow-wrap: anywhere; font-size: 14.5px; }
.gmsg.own .bubble { background: var(--brand); color: #fff; border-color: transparent; }
.gmsg.own .bubble a { color: #fff; }
.bubble.deleted { font-style: italic; color: var(--faint); background: transparent; }
.gmsg.own .bubble.deleted { background: transparent; color: var(--faint); border: 1px dashed var(--line); }
.gmeta { font-size: 11px; color: var(--faint); padding: 0 4px; opacity: 0; transition: opacity .15s; }
.gmsg:hover .gmeta, .gmsg:focus-within .gmeta { opacity: 1; }
.linkish { border: 0; background: none; padding: 0; color: var(--bad); cursor: pointer; font-size: 11px; }
.day-sep { text-align: center; margin: 14px 0 4px; font-size: 11.5px; color: var(--faint); font-weight: 600; }
.day-sep span { background: var(--bg-soft); padding: 3px 10px; border-radius: 99px; }
.sys-msg { text-align: center; font-size: 12.5px; color: var(--muted); margin: 8px 0; }
.share-card, .score-card { border: 1px solid var(--line); background: var(--card); border-radius: 14px; padding: 12px; width: 280px; max-width: 100%; box-shadow: var(--shadow); }
.score-card { display: flex; gap: 12px; align-items: center; }
.score-num { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.composer { display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px; border-top: 1px solid var(--line); background: var(--card); }
.composer textarea.input { min-height: 44px; max-height: 140px; resize: none; padding: 11px 13px; }
.composer .btn { min-height: 44px; }
.composer .btn.icon { width: 44px; }
.new-pill { position: absolute; bottom: 76px; left: 50%; transform: translateX(-50%); background: var(--brand); color: #fff; padding: 6px 14px; border-radius: 99px; font-size: 13px; font-weight: 600; cursor: pointer; box-shadow: var(--shadow-lg); }
.class-filter { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 16px; }
.class-filter button { display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); color: var(--muted); font-weight: 600; font-size: 13.5px; cursor: pointer; }
.class-filter button span { font-size: 11.5px; background: var(--bg-soft); border-radius: 99px; padding: 1px 7px; }
.class-filter button i { width: 9px; height: 9px; border-radius: 50%; }
.class-filter button.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.class-filter button.on span { background: rgba(127, 127, 127, .3); color: inherit; }
.class-label { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; margin-bottom: -4px; }
.sub-link { padding: 6px 10px 6px 20px; font-size: 13.5px; }
.class-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; font-style: normal; }
.unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--audio); flex: none; }
.gtabs { display: flex; gap: 4px; padding: 8px 12px 0; border-bottom: 1px solid var(--line); }
.gtabs button { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 8px 12px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2.5px solid transparent; margin-bottom: -1px; }
.gtabs button.on { color: var(--brand); border-bottom-color: var(--brand); }
.glib { flex: 1; overflow-y: auto; padding: 16px; min-height: 0; }
.lib-head { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.role-note { font-size: 13px; padding: 10px 12px; border-radius: 12px; background: var(--brand-soft); color: var(--text); margin-top: 12px; }
.mat-list { display: grid; gap: 10px; }
.mat { display: flex; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--card-2); flex-wrap: wrap; }
.mat-ico { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.mat-main { flex: 1; min-width: 200px; }
.mat-actions { display: flex; gap: 6px; align-items: center; }
.role-sel { width: auto; padding: 5px 8px; font-size: 12.5px; border-radius: 9px; }
.chip.role-owner { background: var(--brand-soft); color: var(--brand); }
.chip.role-editor { background: var(--good-soft); color: var(--good); }
.mode-opt { cursor: pointer; }
.mode-opt input { margin-top: 4px; accent-color: var(--brand); }
.mode-opt:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.opt.disabled { opacity: .5; cursor: not-allowed; }
.group-side { overflow-y: auto; min-height: 0; }
.group-side .stack { display: grid; gap: 8px; }
.group-side .stack > * + * { margin-top: 0; }
.side-close { display: none; }
.invite-box { text-align: center; padding: 14px; border-radius: 14px; background: var(--brand-soft); margin-top: 10px; }
.invite-box .code { font-size: 28px; font-weight: 800; letter-spacing: .25em; color: var(--brand); margin: 4px 0 10px; font-family: ui-monospace, monospace; }
.member-list { display: grid; gap: 4px; }
.member { display: flex; align-items: center; gap: 10px; padding: 6px 4px; border-radius: 10px; }
.member b { font-size: 14px; }
.av-wrap { position: relative; display: inline-flex; }
.av-wrap .online { position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%; background: var(--good); border: 2px solid var(--card); }

/* print */
@media print {
  .sidebar, .tabs, .btn, .toast-root { display: none !important; }
  .app { display: block; }
  .card { box-shadow: none; break-inside: avoid; }
}

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .player { grid-template-columns: 1fr; }
  .g3 { grid-template-columns: 1fr 1fr; }
  .stat-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; z-index: 40; flex-direction: row; padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--line); overflow: visible; gap: 4px;
  }
  .brand, .side-label, .side-foot, .side-link.lib-item { display: none; }
  .side-nav { flex-direction: row; flex: 1; justify-content: space-around; }
  .side-link { flex-direction: column; gap: 2px; font-size: 11px; padding: 6px 4px; width: auto; flex: 1; align-items: center; }
  .side-link .t { text-align: center; }
  .main { padding: 18px 16px 110px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .style-strip { grid-template-columns: 1fr; }
  .match-grid { grid-template-columns: 1fr 1.3fr; gap: 8px; }
  .tile { font-size: 13px; padding: 10px; }
  .rate .btn small { display: none; }
  .bars .bar { grid-template-columns: 110px 1fr 34px; }
  .card { padding: 16px; }
  .card-row { grid-template-columns: 1fr; }
  .msg { max-width: 92%; }
  .side-link .badge { position: absolute; top: 2px; margin-left: 22px; }
  .side-link { position: relative; }
  .group-layout { grid-template-columns: 1fr; height: calc(100vh - 150px); margin: -6px -8px 0; }
  .side-toggle { display: inline-flex; }
  .group-side { position: fixed; inset: 0 0 0 auto; width: min(340px, 90vw); z-index: 45; border-radius: 0; transform: translateX(105%); transition: transform .2s; }
  .group-side.open { transform: none; box-shadow: var(--shadow-lg); }
  .side-close { display: block; text-align: right; }
  .gmsg { max-width: 92%; }
  .gmeta { opacity: 1; }
  .chat-head .btn.sm:not(.icon) { padding: 6px 9px; }
  .chat-head .inv-label { display: none; }
  .chat-head #gSub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

/* ---------------------------------------------------------------- credits and plans */
.credit-chip { cursor: pointer; border: 1px solid var(--line); font: inherit; }
.credit-chip:hover { border-color: var(--brand); color: var(--brand); }
.credit-chip.low { background: var(--warn-soft); color: var(--warn); }
.model-sel { width: auto; min-height: 34px; padding: 4px 30px 4px 10px; font-size: 13px; font-weight: 600; }
.ai-line { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; font-size: 14px; }
.ai-line .i { color: var(--brand); }
.plans-modal { width: min(640px, 100%); }
.plans-modal h2 { display: flex; align-items: center; gap: 8px; }
.plans-h { font-size: 15px; margin: 22px 0 10px; }
.meter-card { background: var(--card-2); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.big-num { font-size: 30px; line-height: 1; }
.meter { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 10px 0 6px; }
.meter i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.notice { margin-top: 10px; padding: 8px 10px; background: var(--brand-soft); border-radius: 10px; }
.model-cards, .preset-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.model-card, .preset { display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--text); cursor: pointer; font: inherit; min-width: 0; }
.preset span { color: var(--muted); font-size: 13px; }
.model-card:hover, .preset:hover { border-color: var(--brand); }
.model-card.on, .preset.on { border: 2px solid var(--brand); padding: 9px 11px; background: var(--brand-soft); }
.price-box { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.price { font-size: 28px; font-weight: 800; }
.price small { font-size: 14px; font-weight: 500; color: var(--muted); }
.credit-log { margin-top: 8px; display: grid; gap: 6px; max-height: 220px; overflow: auto; }
.credit-log .plus { color: var(--good); }
.ai-line .linkish, .notice .linkish { color: var(--brand); font-size: 13px; font-weight: 600; }
.preset-row { grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); }
.group-limit { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 16px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--card-2); font-size: 14px; }
.group-limit span { flex: 1; min-width: 200px; }
.group-limit.full { background: var(--warn-soft); border-color: transparent; }
.setup-steps { padding-left: 20px; margin: 10px 0 14px; display: grid; gap: 8px; font-size: 14px; line-height: 1.5; }
.setup-steps code, .modal p code { overflow-wrap: anywhere; }

/* owner's AI cost report */
.cost-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.cost-stats > div { background: var(--card-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.cost-stats b { font-size: 20px; }
.cost-stats b.neg { color: var(--bad); }
.cost-stats b.pos { color: var(--good); }
.cost-stats span { font-size: 12px; color: var(--muted); }
.cost-table-wrap { overflow-x: auto; }
.cost-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.cost-table th, .cost-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.cost-table th { color: var(--muted); font-weight: 600; }
.cost-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.model-card[disabled] { opacity: .55; cursor: not-allowed; }

/* sign-up agreement */
.agree-row { align-items: flex-start; gap: 8px; margin: 2px 0 10px; line-height: 1.45; }
.agree-row input { margin-top: 3px; flex: none; }
.agree-row a { color: var(--brand); }
.legal-links { font-size: 12.5px; color: var(--muted); }
.legal-links a { color: inherit; }
