:root {
  --bg: #0b0d10; --bg2: #11151a; --card: #151a20; --line: #232a33; --line2: #2f3843;
  --ink: #e8edf2; --ink2: #a7b1bc; --ink3: #6f7b88;
  --acc: #76e4b0; --acc-ink: #06150e; --warn: #f5c451; --bad: #ff7a6b; --info: #6cc4ff;
  --r1: 8px; --r2: 12px; --r3: 18px;
  --font: 'Inter Tight', system-ui, -apple-system, sans-serif; --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  --ease: cubic-bezier(.2,.7,.2,1);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--acc); text-decoration: none; background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat; transition: background-size .25s var(--ease); }
a:hover { background-size: 100% 1px; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 99; background: var(--acc); color: var(--acc-ink); padding: 8px 12px; border-radius: var(--r1); }
.skip:focus { left: 8px; }
h1, h2, h3 { line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 .5em; }
h1 { font-size: clamp(26px, 3.2vw, 38px); font-weight: 700; }
h2 { font-size: 21px; font-weight: 650; }
h3 { font-size: 16px; font-weight: 600; }
p { margin: 0 0 .8em; }
code, pre, .mono { font-family: var(--mono); font-size: 13px; }
pre { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r1); padding: 12px; overflow: auto; white-space: pre-wrap; }
.muted { color: var(--ink2); } .faint { color: var(--ink3); } .small { font-size: 13px; }

/* shell */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; border-right: 1px solid var(--line); padding: 22px 14px; display: flex; flex-direction: column; gap: 4px; background: var(--bg); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; padding: 0 10px 18px; letter-spacing: -0.01em; }
.brand .dot { width: 22px; height: 22px; border-radius: 6px; background: conic-gradient(from 210deg, var(--acc), #3fb6ff, var(--acc)); box-shadow: 0 0 18px rgba(118,228,176,.35); }
.nav { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border-radius: var(--r1); color: var(--ink2); background: none; transition: background .2s, color .2s, transform .2s var(--ease); }
.nav:hover { background: var(--bg2); color: var(--ink); transform: translateX(2px); }
.nav[aria-current="page"] { background: var(--card); color: var(--ink); box-shadow: inset 2px 0 0 var(--acc); }
.nav svg { width: 18px; height: 18px; flex: none; }
.side .spacer { flex: 1; }
main { padding: 32px clamp(18px, 4vw, 48px) 80px; max-width: 1240px; width: 100%; }
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.top p { margin: 0; }

/* parts */
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r2); padding: 18px; transition: transform .2s var(--ease), border-color .2s; }
a.card, .card.link { display: block; color: inherit; background-image: none; cursor: pointer; }
a.card:hover, .card.link:hover { transform: translateY(-2px); border-color: var(--line2); }
.stat .k { font-size: 12px; color: var(--ink3); text-transform: uppercase; letter-spacing: .08em; }
.stat .v { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; margin-top: 4px; }
.stat .v small { font-size: 14px; color: var(--ink2); font-weight: 500; }
.bar { height: 6px; background: var(--bg2); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.bar > i { display: block; height: 100%; background: var(--acc); border-radius: 99px; transition: width .6s var(--ease); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: var(--r1); border: 1px solid var(--line2); background: var(--bg2); color: var(--ink); font: 600 14px var(--font); cursor: pointer; transition: transform .15s var(--ease), background .2s, border-color .2s; }
.btn:hover { transform: translateY(-1px); border-color: var(--ink3); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn.primary { background: var(--acc); color: var(--acc-ink); border-color: var(--acc); }
.btn.primary:hover { background: #8cf0c0; }
.btn.ghost { background: none; }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: default; transform: none; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--bg2); border: 1px solid var(--line2); border-radius: var(--r1); padding: 10px 12px; min-height: 44px; width: 100%; }
textarea { min-height: 96px; resize: vertical; }
label { display: block; font-size: 13px; color: var(--ink2); margin: 0 0 6px; }
.field { margin-bottom: 14px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 99px; font-size: 12px; border: 1px solid var(--line2); color: var(--ink2); white-space: nowrap; }
.chip.acc { color: var(--acc); border-color: rgba(118,228,176,.4); } .chip.warn { color: var(--warn); border-color: rgba(245,196,81,.4); } .chip.bad { color: var(--bad); border-color: rgba(255,122,107,.4); } .chip.info { color: var(--info); border-color: rgba(108,196,255,.4); }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tab { min-height: 44px; padding: 0 14px; background: none; border: 0; color: var(--ink2); font: 600 14px var(--font); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab[aria-selected="true"] { color: var(--ink); border-color: var(--acc); }
.list { display: flex; flex-direction: column; }
.item { display: grid; grid-template-columns: 28px 1fr auto; gap: 12px; padding: 12px 4px; border-top: 1px solid var(--line); align-items: start; }
.item:first-child { border-top: 0; }
.item .t { white-space: pre-wrap; }
.item.done .t { color: var(--ink3); text-decoration: line-through; text-decoration-color: var(--line2); }
.check { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--acc); cursor: pointer; min-height: 0; }
.md p:last-child { margin-bottom: 0; } .md ul, .md ol { margin: 0 0 .8em; padding-left: 1.2em; } .md li { margin: .2em 0; }
.md pre { margin: .6em 0; } .md code { background: var(--bg2); padding: 1px 5px; border-radius: 4px; }
.md pre code { background: none; padding: 0; }
.md table { border-collapse: collapse; margin: .6em 0; } .md td, .md th { border: 1px solid var(--line2); padding: 4px 8px; }
.links a { display: block; margin: 2px 0; font-size: 13px; }
.empty { color: var(--ink3); padding: 28px; text-align: center; border: 1px dashed var(--line2); border-radius: var(--r2); }
.toast { position: fixed; right: 20px; bottom: 20px; background: var(--card); border: 1px solid var(--line2); border-radius: var(--r2); padding: 12px 16px; max-width: 420px; z-index: 50; box-shadow: 0 10px 30px rgba(0,0,0,.4); animation: up .3s var(--ease); }
@keyframes up { from { transform: translateY(8px); opacity: 0; } }
.spin { width: 16px; height: 16px; border: 2px solid var(--line2); border-top-color: var(--acc); border-radius: 50%; animation: rot .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes rot { to { transform: rotate(360deg); } }

/* coach */
.chat { display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 860px; }
.msg.me { align-self: flex-end; background: var(--bg2); border: 1px solid var(--line); padding: 10px 14px; border-radius: var(--r2) var(--r2) 4px var(--r2); white-space: pre-wrap; }
.msg.ai { padding: 2px 0; }
.msg .acts { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.composer { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding-top: 20px; margin-top: 16px; }
.composer textarea { min-height: 64px; }

/* practice */
.pad { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.editor { border: 1px solid var(--line2); border-radius: var(--r2); overflow: hidden; min-height: 420px; background: #282c34; }
.editor .cm-editor { height: 100%; min-height: 420px; font-size: 13.5px; }
.out { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r2); padding: 12px; font: 13px/1.5 var(--mono); white-space: pre-wrap; min-height: 120px; max-height: 360px; overflow: auto; }
.timer { font: 600 22px var(--mono); letter-spacing: .02em; }
.timer.low { color: var(--warn); } .timer.over { color: var(--bad); }

/* cards */
.flash { min-height: 260px; display: flex; align-items: center; justify-content: center; text-align: center; font-size: 19px; cursor: pointer; perspective: 1000px; }
.flash .face { max-width: 640px; }
.opts { display: grid; gap: 10px; }
.opt { text-align: left; min-height: 48px; padding: 10px 14px; border-radius: var(--r1); border: 1px solid var(--line2); background: var(--bg2); color: var(--ink); font: 500 15px var(--font); cursor: pointer; transition: transform .15s var(--ease), border-color .2s; }
.opt:hover { transform: translateY(-1px); border-color: var(--ink3); }
.opt.right { border-color: var(--acc); color: var(--acc); } .opt.wrong { border-color: var(--bad); color: var(--bad); }

/* library */
.reader { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; }
.pages { background: #fff; border-radius: var(--r2); overflow: auto; max-height: calc(100vh - 170px); display: flex; justify-content: center; }
.pages canvas { max-width: 100%; height: auto; }
.book { display: flex; flex-direction: column; gap: 8px; min-height: 150px; }
.book .title { font-weight: 600; line-height: 1.3; }

/* login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 70% -10%, rgba(118,228,176,.10), transparent 60%), radial-gradient(900px 500px at -10% 110%, rgba(108,196,255,.08), transparent 60%), var(--bg); }
.auth .box { width: min(440px, 100%); }
.auth .box .card { padding: 26px; }
.qr { background: #fff; padding: 10px; border-radius: var(--r1); display: inline-block; }

.score { font: 700 44px var(--font); letter-spacing: -0.04em; }
.grade { font-weight: 700; font-size: 22px; }

@media (max-width: 1000px) { .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); } .pad, .reader { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; bottom: 0; top: auto; height: auto; width: 100%; flex-direction: row; justify-content: space-around; border-right: 0; border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 20; overflow-x: auto; gap: 0; }
  .brand, .side .spacer, .nav span { display: none; }
  .nav { padding: 0 12px; }
  main { padding: 20px 16px 110px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .btn { width: 100%; } .row .btn { width: auto; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
