:root {
  color-scheme: dark;
  --ink: #eeede8; --ink-2: #b9bbc0; --ink-3: #8e9197; --dark: #0c0d0f;
  --bg: #0c0d0f; --bg2: #131417; --bg3: #1a1b1f; --card: #131417; --line: #25272c;
  --violet: #4b5cff; --violet-d: #a9b2ff; --violet-l: #1b2045; --accent-deep: #2b3fd1;
  --gold: #f5bd2e; --gold-d: #f5cf6a; --gold-l: #2e2610;
  --green: #4fe0a0; --green-l: #0f2e22; --red: #ff8fa2; --red-l: #3a1620; --blue-l: #16233a;
  --radius: 18px; --shadow: 0 14px 36px -22px rgba(0, 0, 0, .9);
  --head: "Unbounded", "Onest", system-ui, sans-serif;
  --body: "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.55 var(--body); }
h1, h2, h3 { font-family: var(--head); line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(24px, 4vw, 34px); font-weight: 700; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }
p { margin: 0 0 .8em; }
a { color: var(--violet-d); }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--violet); outline-offset: 2px; border-radius: 6px; }
.boot { display: grid; place-items: center; min-height: 100vh; font: 800 40px var(--head); color: var(--ink); }

.topbar { position: sticky; top: 0; z-index: 20; background: rgba(12, 13, 15, .9); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); color: var(--ink); }
.topbar-in { max-width: 1040px; margin: auto; display: flex; align-items: center; gap: 12px; padding: 10px 16px; }
.brand { font: 800 20px var(--head); color: var(--ink); text-decoration: none; display: flex; align-items: baseline; gap: 6px; }
.brand small { font: 500 11px var(--head); color: var(--ink-3); }
.spacer { flex: 1; }
.coin-pill { display: inline-flex; align-items: center; gap: 6px; background: var(--gold); color: var(--dark); font-weight: 700; padding: 5px 12px; border-radius: 99px; text-decoration: none; white-space: nowrap; }
.link-btn { background: none; border: 0; color: var(--ink-2); cursor: pointer; padding: 8px 4px; }
.link-btn:hover { color: #fff; }
.wrap { max-width: 1040px; margin: auto; padding: 20px 16px 96px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 20px; border: 0; border-radius: 12px; background: var(--violet); color: #fff; font-weight: 600; cursor: pointer; text-decoration: none; transition: transform .12s, background .12s; }
.btn:hover { background: var(--accent-deep); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: var(--violet-l); color: var(--violet-d); }
.btn.ghost:hover { background: #262d5e; }
.btn.gold { background: var(--gold); color: var(--dark); }
.btn.gold:hover { background: #ffd05a; }
.btn.danger:hover { background: #4d1c2a; }
.btn.danger { background: var(--red-l); color: var(--red); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.muted { color: var(--ink-3); }
.small { font-size: 14px; }
.tag { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 13px; font-weight: 600; background: var(--violet-l); color: var(--violet-d); }
.tag.done { background: var(--green-l); color: var(--green); }
.tag.review { background: var(--gold-l); color: var(--gold-d); }
.tag.returned, .tag.high { background: var(--red-l); color: var(--red); }
.tag.warn { background: var(--gold-l); color: var(--gold-d); }
.tag.info { background: var(--blue-l); color: #9cc2ff; }

/* login */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.5fr 1fr; background: var(--bg); color: var(--ink); }
.auth-hero { position: relative; padding: 32px; display: flex; flex-direction: column; justify-content: center; overflow: hidden; background: radial-gradient(80% 70% at 55% 40%, #1a2363 0%, transparent 72%); }
.logo3d { width: 100%; height: min(62vh, 520px); }
.logo-flat { display: grid; place-items: center; }
.logo-flat span { font: 800 clamp(64px, 12vw, 120px) var(--head); color: var(--ink); text-shadow: 3px 3px 0 var(--violet), 6px 6px 0 var(--accent-deep); }
.auth-hero h1 { font-size: clamp(26px, 4vw, 40px); }
.auth-hero p { color: var(--ink-2); max-width: 44ch; }
.auth-form { background: var(--bg2); color: var(--ink); border-left: 1px solid var(--line); display: grid; place-items: center; padding: 24px 16px; }
.auth-form form { width: min(360px, 100%); }
label.f { display: block; margin-bottom: 14px; font-weight: 600; font-size: 14px; }
label.f input, label.f textarea, label.f select { display: block; width: 100%; margin-top: 6px; min-height: 44px; padding: 10px 12px; font-weight: 400; font-size: 16px; background: var(--bg3); border: 1.5px solid var(--line); border-radius: 12px; }
.err { color: var(--red); font-size: 14px; min-height: 22px; }

/* dashboard */
.hero { background: linear-gradient(120deg, #101223, #1a2363); border: 1px solid var(--line); color: #fff; border-radius: 24px; padding: 24px; margin-bottom: 20px; display: grid; grid-template-columns: 1fr 340px; gap: 16px; align-items: center; overflow: hidden; }
.hero p { color: var(--ink-2); }
.hero .logo3d { height: 210px; }
.bar { height: 10px; background: rgba(120, 100, 220, .22); border-radius: 99px; overflow: hidden; margin: 10px 0; }
.bar > i { display: block; height: 100%; background: var(--gold); border-radius: 99px; transition: width .4s; }
.level-title { display: flex; align-items: center; gap: 10px; margin: 26px 0 12px; }
.level-badge { font: 800 14px var(--head); background: var(--accent-deep); color: #fff; padding: 5px 12px; border-radius: 10px; }
.mods { display: grid; gap: 12px; }
.mod { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.mod.locked { opacity: .62; }
.mod.active { border-color: var(--violet); box-shadow: 0 0 0 2px var(--violet-l); }
.mod-head { color: inherit; width: 100%; display: flex; gap: 14px; align-items: center; padding: 14px 16px; background: none; border: 0; text-align: left; cursor: pointer; }
.mod-n { flex: none; width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; background: var(--violet-l); color: var(--violet-d); font: 800 15px var(--head); }
.mod.passed .mod-n { background: var(--green-l); color: var(--green); }
.mod-t { flex: 1; min-width: 0; }
.mod-t strong { display: block; font-size: 16.5px; }
.mod-t span { font-size: 14px; color: var(--ink-3); }
.tasks { padding: 0 12px 12px; display: grid; gap: 6px; }
.task { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 8px 12px; border-radius: 12px; background: var(--bg3); color: var(--ink); text-decoration: none; }
a.task:hover { background: var(--violet-l); }
.task.off { color: var(--ink-3); }
.task .ico { width: 26px; text-align: center; }
.task .nm { flex: 1; min-width: 0; }
.task .rw { font-size: 13px; font-weight: 700; color: var(--gold-d); white-space: nowrap; }

/* task */
.crumb { display: inline-block; margin-bottom: 10px; text-decoration: none; font-size: 14px; }
.rule { border-left: 4px solid var(--violet); padding: 2px 0 2px 14px; margin-bottom: 18px; }
.ex { margin: 6px 0 0; padding: 0; list-style: none; }
.ex li { background: var(--bg3); border-radius: 10px; padding: 7px 12px; margin-bottom: 5px; font-weight: 500; }
.reading { font-size: 17px; line-height: 1.7; white-space: pre-line; }
.words { width: 100%; border-collapse: collapse; }
.words td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.words td:first-child { font-weight: 700; white-space: nowrap; }
.words .e { color: var(--ink-2); }
.q { padding: 14px 0; border-bottom: 1px solid var(--line); }
.q:last-of-type { border-bottom: 0; }
.q-t { font-weight: 600; margin-bottom: 8px; }
.opt { display: flex; gap: 10px; align-items: center; min-height: 44px; padding: 8px 12px; border: 1.5px solid var(--line); border-radius: 12px; margin-bottom: 6px; cursor: pointer; }
.opt:has(input:checked) { border-color: var(--violet); background: var(--violet-l); }
.q input[type=text], .q textarea { background: var(--bg3); width: 100%; min-height: 44px; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 12px; font-size: 16px; }
.q.good .q-t::after { content: ' ✓'; color: var(--green); }
.q.bad .q-t::after { content: ' ✗'; color: var(--red); }
.why { font-size: 14px; color: var(--green); margin-top: 6px; }
.video { position: relative; padding-top: 56.25%; border-radius: 14px; overflow: hidden; background: #000; margin-bottom: 12px; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.editor { background: var(--bg3); width: 100%; min-height: 260px; padding: 14px; border: 1.5px solid var(--line); border-radius: 14px; font-size: 16.5px; line-height: 1.6; resize: vertical; }
.editor-foot { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-top: 8px; }
.check { padding-left: 20px; margin: 0; }
.notice { background: var(--gold-l); color: #f5d37a; border-radius: 12px; padding: 10px 14px; font-size: 14.5px; margin-bottom: 12px; }
.notice.ok { background: var(--green-l); color: #7fe8bd; }
.notice.bad { background: var(--red-l); color: #ffb3bf; }
.steps { padding-left: 0; list-style: none; counter-reset: s; margin: 0; }
.steps li { counter-increment: s; display: flex; gap: 10px; margin-bottom: 8px; }
.steps li::before { content: counter(s); flex: none; width: 26px; height: 26px; border-radius: 8px; background: var(--violet); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--violet-l); color: var(--violet-d); padding: 5px 12px; border-radius: 99px; font-size: 14.5px; font-weight: 500; }

/* hint panel */
.hint-fab { position: fixed; right: 16px; bottom: 16px; z-index: 30; box-shadow: 0 10px 24px -8px rgba(60, 30, 160, .6); }
.hint-box { position: fixed; right: 16px; bottom: 74px; z-index: 30; width: min(360px, calc(100vw - 32px)); max-height: min(70vh, 520px); display: flex; flex-direction: column; background: var(--bg2); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 20px 50px -20px #000; }
.hint-box header { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.hint-log { flex: 1; overflow-y: auto; padding: 12px 14px; min-height: 120px; }
.msg { padding: 8px 12px; border-radius: 12px; margin-bottom: 8px; font-size: 15px; }
.msg.me { background: var(--violet-l); margin-left: 24px; }
.msg.ai { background: var(--bg3); margin-right: 24px; }
.hint-box form { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--line); }
.hint-box input { background: var(--bg3); flex: 1; min-width: 0; min-height: 44px; padding: 8px 12px; border: 1.5px solid var(--line); border-radius: 12px; font-size: 16px; }

/* admin */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; }
.stat b { display: block; font: 700 22px var(--head); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.matrix { width: 100%; border-collapse: collapse; font-size: 14px; }
.matrix th, .matrix td { padding: 6px; text-align: center; border-bottom: 1px solid var(--line); }
.matrix td:first-child, .matrix th:first-child { text-align: left; }
.dot { display: inline-block; width: 14px; height: 14px; border-radius: 5px; background: var(--line); }
.dot.done { background: var(--green); } .dot.review { background: var(--gold); } .dot.returned { background: var(--red); }
.scroll-x { overflow-x: auto; }
.work { white-space: pre-wrap; background: var(--bg3); border-radius: 12px; padding: 14px; overflow-wrap: anywhere; }
.flag { padding: 8px 12px; border-radius: 10px; margin-bottom: 6px; font-size: 14.5px; }
.flag.high { background: var(--red-l); } .flag.warn { background: var(--gold-l); } .flag.info { background: var(--blue-l); }
.meter { font: 700 20px var(--head); }

#toasts { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--bg3); border: 1px solid var(--line); color: var(--ink); padding: 10px 16px; border-radius: 12px; font-weight: 500; box-shadow: var(--shadow); }
.toast.gold { background: var(--gold); color: var(--dark); font-weight: 700; }
.celebrate { position: fixed; inset: 0; z-index: 70; background: rgba(12, 13, 15, .92); color: #fff; display: grid; place-items: center; text-align: center; padding: 16px; }
.celebrate .logo3d { width: min(420px, 90vw); height: 260px; margin: auto; }

@media (max-width: 800px) {
  .auth { grid-template-columns: 1fr; }
  .auth-hero { padding: 20px 16px; }
  .logo3d { height: 300px; }
  .hero { grid-template-columns: 1fr; }
  .hero .logo3d { display: none; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid2 { grid-template-columns: 1fr; }
  .words td:first-child { white-space: normal; }
  .brand small { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
