:root {
  --bg: #f7f8f9;
  --surface: #ffffff;
  --panel: #eceff0;
  --line: #dfe3e5;
  --text: #1e2427;
  --muted: #6a7378;
  --accent: #2f7d80;
  --accent-deep: #1f5c5f;
  --accent-tint: #e6f1f1;
  --warn: #a9762f;
  --warn-tint: #f7eee1;
  --bad: #a0453b;
  --bad-tint: #f7e6e3;
  --font-body: "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  --font-head: "Bricolage Grotesque", "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, Menlo, Consolas, monospace;
  --r-lg: 10px; --r-md: 7px; --r-sm: 4px;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font-body); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { font-family: var(--font-head); font-weight: 600; letter-spacing: -0.02em; line-height: 1.05; margin: 0; text-wrap: balance; }
h1 { font-size: 46px; } h2 { font-size: 32px; } h3 { font-size: 19px; } h4 { font-size: 16px; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-deep); text-decoration: underline; }
button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
*:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
code, pre, .mono { font-family: var(--font-mono); }
code { background: var(--panel); padding: 1px 5px; border-radius: 3px; font-size: 0.92em; }
pre { background: #1e2427; color: #f7f8f9; padding: 14px 16px; border-radius: var(--r-md); overflow-x: auto; font-size: 13px; line-height: 1.55; }
pre code { background: transparent; padding: 0; font-size: inherit; color: inherit; }
hr { border: 0; border-top: 1px solid var(--line); margin: 0; }
img, svg { max-width: 100%; }

/* ---- chrome ---- */
.nav { display: flex; align-items: center; gap: 32px; padding: 18px 40px; border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 5; }
.nav-brand { display: flex; align-items: center; gap: 10px; margin-right: auto; color: var(--text); font-family: var(--font-head); font-weight: 700; font-size: 16px; letter-spacing: -0.02em; }
.nav-brand:hover { text-decoration: none; }
.nav-mark { width: 22px; height: 22px; border-radius: 3px; background: var(--text); }
.nav-links { display: flex; gap: 4px; }
.nav-links a { font-size: 13px; color: var(--muted); padding: 7px 12px; border-radius: 6px; }
.nav-links a:hover, .nav-links a.active { background: var(--panel); color: var(--text); text-decoration: none; }
.nav-user { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }
.avatar { width: 28px; height: 28px; border-radius: 4px; background: var(--accent-tint); border: 1px solid var(--line); display: grid; place-items: center; font-family: var(--font-mono); font-size: 11px; color: var(--accent-deep); text-transform: uppercase; }

.page { padding: 56px 40px 72px; max-width: 1240px; display: flex; flex-direction: column; gap: 56px; }
.page.narrow { max-width: 820px; }
.page.tight { gap: 32px; padding-top: 40px; }

.kicker { font: 11px/1 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.kicker.teal { color: var(--accent-deep); }
.meta { font: 11px/1.4 var(--font-mono); color: var(--muted); }
.meta.upper { text-transform: uppercase; letter-spacing: 0.04em; }
.lede { font-size: 16px; line-height: 1.6; color: var(--muted); max-width: 50ch; text-wrap: pretty; }
.prose { font-size: 15px; line-height: 1.65; }
.prose p + p, .prose ul, .prose ol, .prose pre { margin-top: 12px; }
.prose ul, .prose ol { padding-left: 22px; }

.section-head { display: flex; align-items: baseline; gap: 12px; border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 24px; }
.section-head h3 { flex: 1; }

/* ---- layout helpers ---- */
.hero { display: flex; align-items: flex-end; gap: 40px; flex-wrap: wrap; }
.hero > div { flex: 1; min-width: 340px; }
.hero h1 { margin-top: 16px; }
.hero .lede { margin-top: 14px; }
.cols { display: flex; gap: 56px; align-items: flex-start; flex-wrap: wrap; }
.cols > .main { flex: 1; min-width: 560px; display: flex; flex-direction: column; gap: 48px; }
.cols > .side { width: 300px; display: flex; flex-direction: column; gap: 20px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.right { text-align: right; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; } .mt-32 { margin-top: 32px; }

/* ---- cards & lists ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.card .thumb { height: 88px; border-radius: 6px; background: repeating-linear-gradient(45deg, var(--panel) 0 7px, var(--bg) 7px 14px); display: flex; align-items: flex-end; padding: 8px; font: 10px/1 var(--font-mono); color: var(--muted); }
.card .thumb.teal { background: repeating-linear-gradient(45deg, var(--accent-tint) 0 7px, var(--bg) 7px 14px); }
.panel { background: var(--panel); border-radius: var(--r-lg); padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.panel.teal { background: var(--accent-tint); }
.panel.warn { background: var(--warn-tint); }
.panel .inner { background: var(--surface); border-radius: var(--r-md); padding: 14px; }

.list { display: flex; flex-direction: column; }
.list > .item { display: flex; align-items: center; gap: 20px; padding: 18px 4px; border-bottom: 1px solid var(--line); }
.list > .item .title { font-size: 15px; font-weight: 600; }
.list > .item .meta { margin-top: 4px; }
.num { width: 28px; height: 28px; border-radius: 6px; background: var(--panel); display: grid; place-items: center; font: 12px/1 var(--font-mono); color: var(--muted); flex-shrink: 0; }
.num.now { background: var(--accent); color: #fff; }
.num.done { background: var(--text); color: #fff; }

.progress { height: 4px; border-radius: 2px; background: var(--panel); overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); transition: width .3s; }
.progress.tall { height: 6px; }

.tag { display: inline-block; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; padding: 4px 9px; border-radius: var(--r-sm); background: var(--panel); color: var(--muted); white-space: nowrap; }
.tag.teal { background: var(--accent-tint); color: var(--accent-deep); }
.tag.warn { background: var(--warn-tint); color: var(--warn); }
.tag.bad { background: var(--bad-tint); color: var(--bad); }
.tag.dark { background: var(--text); color: var(--bg); }

.week { display: flex; gap: 6px; }
.week > div { flex: 1; height: 34px; border-radius: 4px; background: var(--panel); display: flex; align-items: flex-end; overflow: hidden; }
.week > div > i { display: block; width: 100%; background: var(--accent); }
.week-labels { display: flex; gap: 6px; }
.week-labels > span { flex: 1; text-align: center; font: 10px/1 var(--font-mono); color: var(--muted); }

/* ---- buttons & forms ---- */
.btn { border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 13px; font-weight: 600; padding: 9px 14px; border-radius: var(--r-md); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.btn.primary { border-color: var(--text); background: var(--text); color: var(--bg); }
.btn.primary:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.teal { border-color: var(--accent); background: var(--accent); color: #fff; }
.btn.teal:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); font-weight: 500; }
.btn.ghost:hover { background: var(--panel); color: var(--text); }
.btn.lg { font-size: 14px; padding: 13px 22px; border-radius: 8px; }
.btn.sm { font-size: 12px; padding: 7px 12px; font-weight: 500; }
.btn.block { width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: default; pointer-events: none; }
.btn.chip { font-weight: 500; font-size: 12px; padding: 6px 12px; border-radius: 999px; }
.btn.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 600; }
.input, .textarea, select.input { width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-md); padding: 10px 12px; font-size: 14px; }
.textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.textarea.big { font-size: 20px; font-family: var(--font-head); min-height: 120px; padding: 18px 20px; border-radius: var(--r-lg); line-height: 1.3; }
.input:focus, .textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.radio { display: flex; align-items: center; gap: 10px; font-size: 14px; padding: 6px 0; cursor: pointer; }
.radio input { accent-color: var(--accent); }
.radio.off { color: var(--muted); cursor: default; }
.seg { display: flex; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: var(--surface); }
.seg > label { flex: 1; text-align: center; padding: 8px; font-size: 12px; cursor: pointer; color: var(--muted); }
.seg > label:has(input:checked) { background: var(--text); color: var(--bg); }
.seg input { display: none; }
.alert { padding: 12px 14px; border-radius: var(--r-md); font-size: 13px; }
.alert.bad { background: var(--bad-tint); color: var(--bad); }
.alert.ok { background: var(--accent-tint); color: var(--accent-deep); }
.alert.warn { background: var(--warn-tint); color: var(--warn); }
.validation-summary-errors ul { margin: 0; padding-left: 18px; }
.field-validation-error { color: var(--bad); font-size: 12px; }

/* ---- lesson ---- */
.lesson-bar { display: flex; align-items: center; gap: 16px; padding: 14px 40px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 5; }
.lesson-bar .progress { flex: 1; }
.lesson { display: grid; grid-template-columns: minmax(340px, 5fr) minmax(400px, 7fr); gap: 48px; padding: 40px; max-width: 1280px; }
.lesson.single { grid-template-columns: minmax(340px, 760px); }
.lesson .read { display: flex; flex-direction: column; gap: 22px; }
.lesson .work { display: flex; flex-direction: column; gap: 14px; }
.task { border-left: 3px solid var(--accent); padding: 4px 0 4px 16px; }
.hint { background: var(--warn-tint); border-radius: var(--r-md); padding: 12px 14px; }
.editor-head { display: flex; justify-content: space-between; padding: 8px 14px; background: #2a3236; color: #aab3b8; border-radius: var(--r-md) var(--r-md) 0 0; font: 11px/1 var(--font-mono); }
.editor { width: 100%; min-height: 260px; background: #1e2427; color: #f7f8f9; border: 0; border-radius: 0 0 var(--r-md) var(--r-md); padding: 14px 16px; font: 13px/1.55 var(--font-mono); resize: vertical; tab-size: 2; }
.editor:focus { outline: 2px solid var(--accent); }
.output { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; }
.output pre { background: transparent; color: var(--text); padding: 0; margin: 6px 0 0; font-size: 12px; white-space: pre-wrap; }
.checks { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.checks > div { display: flex; gap: 10px; align-items: baseline; }
.checks .ok { color: var(--accent-deep); } .checks .no { color: var(--bad); } .checks .pending { color: var(--muted); }
.step { display: grid; grid-template-columns: 28px 1fr; gap: 14px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.step .figure { margin-top: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 8px; }
.step .figure svg { display: block; width: 100%; height: auto; }
.bubble { border-radius: var(--r-lg); padding: 14px 16px; max-width: 60ch; }
.bubble.you { background: var(--text); color: var(--bg); align-self: flex-end; }
.bubble.tutor { background: var(--surface); border: 1px solid var(--line); }
.bubble .who { font: 10px/1 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; opacity: .7; margin-bottom: 6px; }
.chat { display: flex; flex-direction: column; gap: 10px; }
.option { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); cursor: pointer; text-align: left; width: 100%; }
.option:hover { border-color: var(--text); }
.option.right { border-color: var(--accent); background: var(--accent-tint); }
.option.wrong { border-color: var(--bad); background: var(--bad-tint); }
.option .letter { font: 11px/1 var(--font-mono); color: var(--muted); padding-top: 3px; }
.game-wrap { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.game-wrap canvas { display: block; width: 100%; height: auto; }
.game-hud { display: flex; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--line); font: 12px/1 var(--font-mono); color: var(--muted); }
.buckets { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.buckets button { flex: 1; }
.spinner { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

.dropdown { position: relative; }
.dropdown > .menu { display: none; position: absolute; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); min-width: 180px; padding: 4px; z-index: 10; box-shadow: 0 8px 24px rgba(30,36,39,.08); }
.dropdown.open > .menu { display: block; }
.dropdown .menu button, .dropdown .menu a { display: block; width: 100%; text-align: left; background: transparent; border: 0; padding: 8px 10px; border-radius: 4px; font-size: 13px; cursor: pointer; color: var(--text); }
.dropdown .menu button:hover, .dropdown .menu a:hover { background: var(--panel); text-decoration: none; }
.dropdown .menu .danger { color: var(--bad); }

.auth { min-height: calc(100vh - 62px); display: grid; place-items: center; padding: 40px; }
.auth .card { width: 380px; padding: 28px; gap: 18px; }

/* ---- responsive ---- */
@media (max-width: 900px) {
  .nav { padding: 14px 20px; gap: 12px; }
  .nav-links { overflow-x: auto; }
  .page { padding: 32px 20px 56px; gap: 36px; }
  h1 { font-size: 34px; }
  .cols > .main { min-width: 0; }
  .cols > .side { width: 100%; }
  .grid3, .grid2 { grid-template-columns: 1fr; }
  .lesson { grid-template-columns: 1fr; padding: 20px; gap: 28px; }
  .lesson-bar { padding: 12px 20px; }
  .list > .item { flex-wrap: wrap; gap: 10px; }
}
