/* ───────── Tokens ───────── */
:root {
  --bg: #F7F5F0;
  --surface: #FFFFFF;
  --surface-2: #F1EEE6;
  --ink: #191816;
  --ink-2: #3B3934;
  --muted: #6F6B61;
  --line: #E5E0D4;
  --new: #6A45F5;
  --easy: #0E9466;
  --safe: #2360E6;
  --big: #E0700A;
  --urg: #D93A3A;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(25, 22, 14, .05), 0 8px 24px rgba(25, 22, 14, .06);
  --serif: 'Fraunces', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131210; --surface: #1C1B18; --surface-2: #25231F; --ink: #F2EFE7; --ink-2: #D7D2C6;
    --muted: #9D978A; --line: #302D27; --new: #9D86FF; --easy: #3CC895; --safe: #6E9DFF; --big: #FFA04A; --urg: #FF6B6B;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #131210; --surface: #1C1B18; --surface-2: #25231F; --ink: #F2EFE7; --ink-2: #D7D2C6;
  --muted: #9D978A; --line: #302D27; --new: #9D86FF; --easy: #3CC895; --safe: #6E9DFF; --big: #FFA04A; --urg: #FF6B6B;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  color-scheme: dark;
}

/* Emotion colour mapping */
[data-e="new"], [data-e="only"] { --c: var(--new); }
[data-e="easy"], [data-e="anybody"] { --c: var(--easy); }
[data-e="safe"], [data-e="predictable"] { --c: var(--safe); }
[data-e="big"], [data-e="fast"] { --c: var(--big); }
[data-e="urg"], [data-e="urgency"] { --c: var(--urg); }

/* ───────── Base ───────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.65 var(--sans); -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -.01em; line-height: 1.2; margin: 0; }
p { margin: 0 0 1em; }
b, strong { font-weight: 600; }
button { font: inherit; color: inherit; }
input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--safe); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--muted); }

/* ───────── Layout ───────── */
.app { display: grid; grid-template-columns: 296px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--line);
  padding: 22px 14px 40px;
}
main { padding: 44px 48px 96px; min-width: 0; }
main:focus { outline: none; }
.page { max-width: 780px; margin: 0 auto; }
.page-wide { max-width: 1040px; margin: 0 auto; }
.topbar { display: none; }
.scrim { display: none; }

/* Brand */
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--serif); font-weight: 700; font-size: 19px; padding: 4px 8px 18px; }
.logo { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; width: 26px; height: 26px; flex: none; }
.logo i { border-radius: 4px; }
.logo i:nth-child(1) { background: var(--new); }
.logo i:nth-child(2) { background: var(--easy); }
.logo i:nth-child(3) { background: var(--safe); }
.logo i:nth-child(4) { background: var(--big); }

/* Sidebar nav */
.side-progress { margin: 0 8px 18px; padding: 12px 14px; background: var(--surface-2); border-radius: var(--radius-sm); }
.side-progress .row { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.side-progress .row b { color: var(--ink); }
.bar { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--new), var(--easy), var(--safe), var(--big)); transition: width .4s ease; }
.nav-group { margin-bottom: 14px; }
.nav-group h4 { margin: 0 0 4px; padding: 0 10px; font: 600 11px/1 var(--sans); text-transform: uppercase; letter-spacing: .09em; color: var(--muted); padding-top: 8px; }
.nav-link {
  display: flex; align-items: center; gap: 10px; text-decoration: none;
  padding: 7px 10px; border-radius: 9px; font-size: 14.5px; color: var(--ink-2);
}
.nav-link:hover { background: var(--surface-2); color: var(--ink); }
.nav-link.active { background: var(--surface-2); color: var(--ink); font-weight: 600; }
.nav-num {
  flex: none; width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center;
  font: 600 11.5px/1 var(--sans); background: var(--surface-2); color: var(--muted); border: 1px solid var(--line);
}
.nav-link[data-e] .nav-num { background: var(--c); color: #fff; border-color: transparent; }
.nav-link .nav-title { flex: 1; min-width: 0; }
.nav-check { flex: none; width: 16px; height: 16px; color: var(--easy); opacity: 0; }
.nav-link.done .nav-check { opacity: 1; }

/* ───────── Home ───────── */
.hero { padding: 8px 0 30px; }
.kicker { font: 600 12px/1 var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 14px; }
.hero h1 { font-size: clamp(36px, 6vw, 58px); line-height: 1.04; margin-bottom: 16px; }
.hero p.big { font-size: 19px; color: var(--ink-2); max-width: 620px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.nesb-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 30px 0 10px; }
.nesb-tile {
  text-decoration: none; border-radius: var(--radius); padding: 18px 16px 16px; color: #fff;
  background: var(--c); position: relative; overflow: hidden; min-height: 140px;
  display: flex; flex-direction: column; justify-content: space-between; box-shadow: var(--shadow);
  transition: transform .15s ease;
}
.nesb-tile:hover { transform: translateY(-2px); }
.nesb-tile .letter { font: 700 54px/1 var(--serif); opacity: .95; }
.nesb-tile .name { font-weight: 700; font-size: 17px; }
.nesb-tile .alt { font-size: 13px; opacity: .88; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 44px 0 14px; }
.section-head h2 { font-size: 26px; }
.section-head span { color: var(--muted); font-size: 14px; }
.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.map-card {
  display: flex; flex-direction: column; gap: 6px; text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; transition: border-color .15s, transform .15s, box-shadow .15s; position: relative;
}
.map-card:hover { border-color: color-mix(in srgb, var(--ink) 25%, var(--line)); transform: translateY(-1px); box-shadow: var(--shadow); }
.map-card .top { display: flex; align-items: center; justify-content: space-between; }
.map-card h3 { font-size: 17.5px; }
.map-card p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.map-card .meta { font-size: 12.5px; color: var(--muted); margin-top: auto; padding-top: 6px; }
.map-card.done::after {
  content: "✓ Done"; position: absolute; top: 14px; right: 14px; font-size: 12px; font-weight: 600; color: var(--easy);
}
.pill-num {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  font: 700 13px/1 var(--sans); background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line);
}
[data-e] > .top > .pill-num, .pill-num[data-e] { background: var(--c); color: #fff; border-color: transparent; }
.progress-card { display: flex; align-items: center; gap: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.progress-card .ring { --p: 0; width: 64px; height: 64px; border-radius: 50%; flex: none;
  background: conic-gradient(var(--easy) calc(var(--p) * 1%), var(--line) 0); display: grid; place-items: center; }
.progress-card .ring span { width: 50px; height: 50px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.progress-card h3 { font-size: 18px; margin-bottom: 2px; }
.progress-card p { margin: 0; color: var(--muted); font-size: 14px; }

/* ───────── Buttons ───────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none; cursor: pointer;
  padding: 11px 18px; border-radius: 11px; border: 1px solid var(--ink); background: var(--ink); color: var(--bg);
  font-weight: 600; font-size: 15px; transition: transform .1s, opacity .15s;
}
.btn:hover { opacity: .9; }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: var(--surface-2); opacity: 1; }
.btn.small { padding: 7px 12px; font-size: 13.5px; border-radius: 9px; }
.btn.done-state { background: var(--easy); border-color: var(--easy); color: #fff; }
.btn-link { background: none; border: 0; padding: 0; color: var(--safe); font-weight: 600; cursor: pointer; font-size: 14px; }
.icon-btn { background: none; border: 0; padding: 8px; border-radius: 10px; cursor: pointer; display: grid; place-items: center; color: var(--ink); }
.icon-btn:hover { background: var(--surface-2); }

/* ───────── Lesson page ───────── */
.crumb { font-size: 13px; color: var(--muted); margin-bottom: 18px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.crumb a { text-decoration: none; }
.crumb a:hover { color: var(--ink); }
.lesson-head { display: flex; gap: 18px; align-items: flex-start; margin-bottom: 26px; }
.lesson-badge {
  flex: none; width: 58px; height: 58px; border-radius: 16px; display: grid; place-items: center;
  font: 700 26px/1 var(--serif); background: var(--ink); color: var(--bg);
}
.lesson-badge[data-e] { background: var(--c); color: #fff; }
.lesson-head h1 { font-size: clamp(28px, 4.4vw, 40px); margin-bottom: 6px; }
.lesson-head .sub { color: var(--muted); font-size: 17px; margin: 0; }
.lesson-meta { display: flex; gap: 14px; align-items: center; font-size: 13px; color: var(--muted); margin-top: 10px; flex-wrap: wrap; }
.content > * + * { margin-top: 18px; }
.content h2 { font-size: 25px; margin-top: 40px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.content p { font-size: 16.5px; color: var(--ink-2); margin: 0; }
.content p.lead { font-size: 20px; line-height: 1.55; color: var(--ink); font-family: var(--serif); font-weight: 500; }
.caption { font-size: 13.5px !important; color: var(--muted) !important; text-align: center; }

/* Tags */
.tag {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px;
  font: 600 12.5px/1.5 var(--sans); white-space: nowrap;
  color: var(--c, var(--ink-2));
  background: color-mix(in srgb, var(--c, var(--muted)) 13%, transparent);
  border: 1px solid color-mix(in srgb, var(--c, var(--muted)) 32%, transparent);
}
.tag[data-e="only"], .tag[data-e="anybody"], .tag[data-e="predictable"], .tag[data-e="fast"] { border-style: dashed; }
.addon-badge {
  display: inline-flex; align-items: center; gap: 5px; font: 600 11px/1 var(--sans); letter-spacing: .04em; text-transform: uppercase;
  padding: 5px 8px; border-radius: 6px; color: var(--muted); background: var(--surface-2); border: 1px dashed var(--line);
  vertical-align: middle;
}

/* Callouts */
.callout { border-radius: var(--radius); padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); position: relative; }
.callout > div:last-child { color: var(--ink-2); font-size: 15.5px; }
.callout-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15.5px; margin-bottom: 6px; color: var(--ink); }
.callout-title svg { flex: none; }
.callout-rule { border-left: 4px solid var(--ink); }
.callout-tip { border-left: 4px solid var(--easy); }
.callout-tip .callout-title svg { color: var(--easy); }
.callout-warn { border-left: 4px solid var(--urg); }
.callout-warn .callout-title svg { color: var(--urg); }
.callout-note { border-left: 4px solid var(--safe); }
.callout-note .callout-title svg { color: var(--safe); }
.callout-addon { border: 1px dashed color-mix(in srgb, var(--ink) 30%, var(--line)); background: var(--surface-2); }
.callout-addon .addon-badge { margin-bottom: 10px; background: var(--surface); }

/* Lists */
.list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.list li { position: relative; padding-left: 30px; color: var(--ink-2); font-size: 16px; }
.list.check li::before {
  content: ""; position: absolute; left: 0; top: 4px; width: 18px; height: 18px; border-radius: 6px;
  background: color-mix(in srgb, var(--easy) 16%, transparent);
  -webkit-mask: none;
}
.list.check li::after {
  content: ""; position: absolute; left: 6px; top: 7px; width: 5px; height: 9px; border: solid var(--easy); border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.list.dot li::before { content: ""; position: absolute; left: 8px; top: 10px; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.olist { margin: 8px 0 0; padding-left: 22px; display: grid; gap: 6px; }

/* Cards */
.cards { display: grid; gap: 12px; }
.cards.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cards.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 16px 14px; position: relative; overflow: hidden; }
.card[data-e]::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--c); }
.card h3 { font-family: var(--sans); font-size: 15.5px; font-weight: 700; margin-bottom: 6px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card div, .card p { font-size: 14.5px; color: var(--ink-2); line-height: 1.55; }
.badge { font: 600 11px/1 var(--sans); text-transform: uppercase; letter-spacing: .05em; padding: 4px 7px; border-radius: 6px; background: var(--surface-2); color: var(--muted); }
.badge.strong { background: var(--ink); color: var(--bg); }

/* Steps */
.steps { list-style: none; margin: 0; padding: 0; counter-reset: s; display: grid; gap: 0; }
.steps li { counter-increment: s; position: relative; padding: 0 0 20px 50px; }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 0; width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 14px; background: var(--ink); color: var(--bg);
}
.steps li::after { content: ""; position: absolute; left: 15px; top: 36px; bottom: 4px; width: 2px; background: var(--line); }
.steps li:last-child { padding-bottom: 0; }
.steps li:last-child::after { display: none; }
.steps .st { font-weight: 700; font-size: 16px; line-height: 32px; }
.steps .sd { color: var(--ink-2); font-size: 15px; }

/* Flow */
.flow { display: flex; align-items: stretch; gap: 0; flex-wrap: nowrap; }
.flow-item { flex: 1; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 12px; text-align: center; }
.flow-item b { display: block; font-family: var(--serif); font-size: 18px; }
.flow-item span { font-size: 13px; color: var(--muted); }
.flow-arrow { flex: none; width: 26px; display: grid; place-items: center; color: var(--muted); }
.flow-repeat { flex: none; display: grid; place-items: center; padding-left: 8px; color: var(--muted); font-size: 13px; font-weight: 600; }
.flow-wrap .caption { margin-top: 10px !important; }

/* Chips */
.chips-wrap .chips-label { font: 600 12px/1 var(--sans); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip { padding: 6px 12px; border-radius: 99px; font-size: 14px; font-weight: 500; background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); }
.chips[data-e] .chip { color: var(--c); background: color-mix(in srgb, var(--c) 9%, var(--surface)); border-color: color-mix(in srgb, var(--c) 28%, transparent); }

/* Do / Don't */
.dodont { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dd { border-radius: var(--radius); padding: 14px 16px; border: 1px solid var(--line); background: var(--surface); }
.dd h3 { font-family: var(--sans); font-size: 13px; text-transform: uppercase; letter-spacing: .07em; margin-bottom: 10px; }
.dd.do h3 { color: var(--easy); }
.dd.dont h3 { color: var(--urg); }
.dd ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.dd li { padding-left: 24px; position: relative; font-size: 15px; color: var(--ink-2); }
.dd.do li::before { content: "✓"; position: absolute; left: 0; color: var(--easy); font-weight: 700; }
.dd.dont li::before { content: "✕"; position: absolute; left: 0; color: var(--urg); font-weight: 700; }
.dd-note { grid-column: 1 / -1; text-align: center; font-family: var(--serif); font-size: 18px; font-weight: 600; padding-top: 4px; }

/* Table */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; color: var(--ink-2); }
th { font: 600 12px/1.3 var(--sans); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }

/* Accordion */
details.acc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
details.acc + details.acc { margin-top: 8px; }
details.acc summary { cursor: pointer; padding: 14px 16px; font-weight: 600; list-style: none; display: flex; justify-content: space-between; align-items: center; }
details.acc summary::-webkit-details-marker { display: none; }
details.acc summary::after { content: "+"; font-size: 20px; color: var(--muted); }
details.acc[open] summary::after { content: "–"; }
details.acc .acc-body { padding: 0 16px 16px; color: var(--ink-2); font-size: 15px; }

/* Example (annotated line) */
.example { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.ex-label { font: 600 12px/1 var(--sans); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 12px; }
.ex-label .muted { text-transform: none; letter-spacing: 0; font-weight: 500; }
.ex-line { font-family: var(--serif); font-size: 21px !important; line-height: 1.7 !important; color: var(--ink) !important; font-weight: 500; }
mark.hl {
  background: color-mix(in srgb, var(--c) 15%, transparent); color: inherit; cursor: pointer;
  border-bottom: 2.5px solid var(--c); padding: 1px 3px; border-radius: 4px 4px 0 0; transition: background .15s;
  box-decoration-break: clone; -webkit-box-decoration-break: clone;
}
mark.hl:hover, mark.hl.active { background: color-mix(in srgb, var(--c) 30%, transparent); }
.ex-why { margin-top: 14px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 15px; color: var(--ink-2); display: flex; gap: 10px; align-items: flex-start; }
.ex-why[hidden] { display: none; }
.ex-foot { margin-top: 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.ex-all { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 8px; font-size: 14.5px; color: var(--ink-2); }
.ex-all[hidden] { display: none; }
.ex-all li, .tr-list li { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 10px; align-items: baseline; }
@media (max-width: 640px) { .ex-all li, .tr-list li { grid-template-columns: minmax(0, 1fr); gap: 4px; } }
.ex-all li .tag, .tr-list li .tag { justify-self: start; }

/* Flip cards */
.flip-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.flip { perspective: 900px; background: none; border: 0; padding: 0; cursor: pointer; height: 170px; text-align: left; }
.flip-inner { position: relative; width: 100%; height: 100%; transition: transform .5s cubic-bezier(.2,.7,.2,1); transform-style: preserve-3d; }
.flip.flipped .flip-inner { transform: rotateY(180deg); }
.face { position: absolute; inset: 0; border-radius: var(--radius); padding: 16px; backface-visibility: hidden; -webkit-backface-visibility: hidden; display: flex; flex-direction: column; justify-content: space-between; }
.face.front { background: var(--c); color: #fff; }
.face.back { background: var(--surface); border: 2px dashed var(--c); color: var(--ink); transform: rotateY(180deg); }
.face .fl-small { font: 600 11px/1 var(--sans); text-transform: uppercase; letter-spacing: .08em; opacity: .85; }
.face .fl-word { font: 700 30px/1 var(--serif); }
.face.back .fl-word { color: var(--c); }
.face .fl-sub { font-size: 13.5px; line-height: 1.4; }
.hint { font-size: 13px; color: var(--muted); text-align: center; margin-top: 8px !important; }

/* Gamble */
.gamble { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.g-q { font-family: var(--serif); font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.g-sub { font-size: 14px; color: var(--muted); margin-bottom: 14px; }
.g-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.g-opt { cursor: pointer; text-align: left; border-radius: var(--radius-sm); border: 1.5px solid var(--line); background: var(--surface-2); padding: 16px; transition: border-color .15s; }
.g-opt:hover { border-color: var(--safe); }
.g-opt.picked { border-color: var(--safe); background: color-mix(in srgb, var(--safe) 10%, var(--surface)); }
.g-opt .g-big { display: block; font: 700 22px/1.2 var(--serif); margin-bottom: 4px; }
.g-opt .g-small { font-size: 14px; color: var(--muted); }
.g-res { margin-top: 14px; padding: 14px; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--safe) 9%, var(--surface)); border: 1px solid color-mix(in srgb, var(--safe) 25%, transparent); font-size: 15px; color: var(--ink-2); }
.g-res[hidden] { display: none; }

/* Headline anatomy */
.anatomy { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.an-row { display: grid; grid-template-columns: 110px 1fr; border-bottom: 1px solid var(--line); }
.an-row:last-child { border-bottom: 0; }
.an-label { padding: 14px 12px; font: 600 11px/1.3 var(--sans); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); background: var(--surface-2); border-right: 1px solid var(--line); display: flex; align-items: center; }
.an-cell { padding: 14px 18px; text-align: center; }
.an-eyebrow { font: 600 12.5px/1.4 var(--sans); text-transform: uppercase; letter-spacing: .12em; color: var(--urg); }
.an-head { font: 700 clamp(24px, 4vw, 34px)/1.15 var(--serif); }
.an-deck { font-size: 15.5px; color: var(--ink-2); }
.an-quote { font-family: var(--serif); font-style: italic; font-size: 16px; color: var(--ink-2); }
.an-quote span { font-style: normal; font-family: var(--sans); font-size: 13px; color: var(--muted); }
.u-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.u-cell { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; background: var(--surface); font-size: 13.5px; color: var(--ink-2); }
.u-cell b { display: block; font-size: 13px; margin-bottom: 2px; color: var(--ink); }
.u-cell.miss b { color: var(--muted); text-decoration: line-through; }

/* Section cards (body sections) */
.sec-grid { display: grid; gap: 12px; }
.sec-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: grid; grid-template-columns: 44px 1fr; gap: 14px; }
.sec-num { width: 44px; height: 44px; border-radius: 12px; background: var(--ink); color: var(--bg); display: grid; place-items: center; font: 700 18px/1 var(--serif); }
.sec-card h3 { font-size: 20px; margin-bottom: 6px; }
.sec-ans { font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.sec-ans b { color: var(--ink); }
.sec-card .sec-body { font-size: 15px; color: var(--ink-2); }
.sec-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

/* Offer steps */
.osteps { display: grid; gap: 8px; counter-reset: o; }
details.ostep { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); counter-increment: o; }
details.ostep summary { list-style: none; cursor: pointer; padding: 12px 14px; display: flex; align-items: center; gap: 12px; font-weight: 600; }
details.ostep summary::-webkit-details-marker { display: none; }
details.ostep summary::before { content: counter(o); flex: none; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; }
details.ostep[open] summary::before { background: var(--ink); color: var(--bg); border-color: var(--ink); }
details.ostep summary::after { content: "+"; margin-left: auto; color: var(--muted); font-size: 18px; }
details.ostep[open] summary::after { content: "–"; }
details.ostep .os-body { padding: 0 16px 16px 54px; font-size: 15px; color: var(--ink-2); }

/* Lesson footer */
.lesson-foot { margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--line); display: grid; gap: 18px; }
.complete-row { display: flex; justify-content: center; }
.pn { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pn a { text-decoration: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 2px; }
.pn a:hover { border-color: color-mix(in srgb, var(--ink) 25%, var(--line)); }
.pn a span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; font-weight: 600; }
.pn a b { font-family: var(--serif); font-size: 17px; font-weight: 600; }
.pn a.next { text-align: right; }

/* ───────── Tools ───────── */
.tool-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.tool-label { display: inline-flex; align-items: center; gap: 6px; font: 600 11px/1 var(--sans); text-transform: uppercase; letter-spacing: .08em; padding: 5px 8px; border-radius: 6px; background: var(--ink); color: var(--bg); margin-bottom: 10px; }
.tool-box h3 { font-size: 21px; margin-bottom: 4px; }
.tool-box .tool-sub { color: var(--muted); font-size: 14.5px; margin-bottom: 16px !important; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 600; font-size: 14px; }
.field small { color: var(--muted); font-size: 13px; margin-top: -2px; }
.input, textarea.input, select.input {
  width: 100%; padding: 11px 13px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  font-size: 15.5px; transition: border-color .15s;
}
textarea.input { min-height: 74px; resize: vertical; line-height: 1.5; }
.input:focus { outline: none; border-color: var(--safe); box-shadow: 0 0 0 3px color-mix(in srgb, var(--safe) 18%, transparent); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.toggle-list { display: grid; gap: 8px; }
.toggle {
  display: grid; grid-template-columns: 22px 1fr; gap: 12px; align-items: start; cursor: pointer;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); transition: border-color .15s, background .15s;
}
.toggle:hover { border-color: color-mix(in srgb, var(--ink) 25%, var(--line)); }
.toggle input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--easy); cursor: pointer; }
.toggle .tt { font-weight: 600; font-size: 15px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toggle .td { font-size: 13.5px; color: var(--muted); margin-top: 2px; }
.toggle.on { border-color: color-mix(in srgb, var(--easy) 45%, transparent); background: color-mix(in srgb, var(--easy) 7%, var(--surface)); }
.toggle .ref { font-size: 12px; color: var(--muted); font-weight: 500; }
.verdict { margin-top: 16px; padding: 14px 16px; border-radius: var(--radius-sm); font-size: 15px; display: grid; gap: 4px; }
.verdict b { font-size: 16px; }
.verdict.good { background: color-mix(in srgb, var(--easy) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--easy) 35%, transparent); }
.verdict.ok { background: color-mix(in srgb, var(--big) 11%, var(--surface)); border: 1px solid color-mix(in srgb, var(--big) 35%, transparent); }
.verdict.bad { background: color-mix(in srgb, var(--urg) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--urg) 35%, transparent); }
.hintline { font-size: 13.5px; color: var(--muted); margin-top: 6px; }
.stat-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 16px; }
.stat { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px 14px; }
.stat span { display: block; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.stat b { font: 700 24px/1.2 var(--serif); }
.gauge { height: 10px; border-radius: 99px; background: linear-gradient(90deg, var(--easy) 0 50%, var(--big) 50% 75%, var(--urg) 75% 100%); position: relative; margin: 18px 0 6px; }
.gauge i { position: absolute; top: -5px; width: 4px; height: 20px; border-radius: 2px; background: var(--ink); transform: translateX(-50%); transition: left .3s; }
.gauge-scale { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.reframes { margin-top: 14px; display: grid; gap: 6px; }
.reframes div { background: var(--surface-2); border-radius: 9px; padding: 9px 12px; font-size: 14.5px; font-family: var(--serif); }
.sheet { white-space: pre-wrap; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; font-size: 14px; line-height: 1.6; max-height: 420px; overflow: auto; }
.drill-sec { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; position: relative; overflow: hidden; background: var(--surface); }
.drill-sec::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--c); }
.drill-sec h4 { margin: 0 0 12px; font: 700 18px/1.2 var(--serif); color: var(--c); display: flex; gap: 8px; align-items: center; }
.drill-sec .field:last-child { margin-bottom: 0; }
.daily-days { display: grid; grid-template-columns: repeat(14, 1fr); gap: 5px; margin-top: 8px; }
.daily-days i { aspect-ratio: 1; border-radius: 5px; background: var(--line); display: block; }
.daily-days i.part { background: color-mix(in srgb, var(--easy) 40%, var(--line)); }
.daily-days i.full { background: var(--easy); }
.daily-days i.today { outline: 2px solid var(--ink); outline-offset: 1px; }
.tool-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

/* Quiz */
.quiz-top { display: flex; justify-content: space-between; align-items: center; font-size: 13.5px; color: var(--muted); margin-bottom: 8px; }
.quiz-line { font: 500 clamp(21px, 3.2vw, 27px)/1.45 var(--serif); margin: 18px 0 20px; padding-left: 16px; border-left: 3px solid var(--ink); }
.opts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.opt { cursor: pointer; padding: 11px 10px; border-radius: 10px; border: 1.5px solid color-mix(in srgb, var(--c) 35%, var(--line)); background: color-mix(in srgb, var(--c) 7%, var(--surface)); color: var(--c); font-weight: 700; font-size: 14.5px; transition: transform .1s, background .15s; }
.opt:hover:not(:disabled) { background: color-mix(in srgb, var(--c) 16%, var(--surface)); }
.opt:disabled { cursor: default; opacity: .45; }
.opt.right { opacity: 1; background: var(--c); color: #fff; border-color: var(--c); }
.opt.wrong { opacity: 1; background: var(--surface); color: var(--urg); border-color: var(--urg); text-decoration: line-through; }
.opt.also { opacity: 1; border-style: dashed; }
.feedback { margin-top: 16px; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 15px; color: var(--ink-2); }
.feedback .fb-head { font-weight: 700; font-size: 16px; margin-bottom: 4px; color: var(--ink); }
.quiz-end { text-align: center; padding: 10px 0; }
.quiz-end .score { font: 700 64px/1 var(--serif); margin: 10px 0; }

/* Translate */
.tr-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.tr-card h4 { margin: 0 0 10px; font: 600 12px/1 var(--sans); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.tr-line { font: 500 20px/1.9 var(--serif); }
.tr-chunk { cursor: pointer; border: 0; background: none; padding: 0 2px; font: inherit; color: inherit; border-bottom: 2px dotted var(--muted); }
.tr-chunk.rev { background: color-mix(in srgb, var(--c) 15%, transparent); border-bottom: 2.5px solid var(--c); border-radius: 4px 4px 0 0; }
.tr-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.tr-list li { font-size: 14.5px; color: var(--ink-2); animation: pop .25s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Flashcards */
.fc-stage { perspective: 1200px; }
.fc { width: 100%; min-height: 240px; cursor: pointer; border: 0; background: none; padding: 0; }
.fc-inner { position: relative; width: 100%; min-height: 240px; transition: transform .5s cubic-bezier(.2,.7,.2,1); transform-style: preserve-3d; }
.fc.flipped .fc-inner { transform: rotateY(180deg); }
.fc-face { position: absolute; inset: 0; border-radius: var(--radius); display: grid; place-items: center; padding: 28px; text-align: center; backface-visibility: hidden; -webkit-backface-visibility: hidden; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); }
.fc-face.front { font: 700 clamp(26px, 4vw, 36px)/1.2 var(--serif); }
.fc-face.back { transform: rotateY(180deg); font-size: 18px; color: var(--ink-2); line-height: 1.55; background: var(--surface-2); }
.fc-controls { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; gap: 8px; flex-wrap: wrap; }

/* About */
.src-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.src-card h3 { font-size: 19px; margin-bottom: 8px; }
.excluded li { margin-bottom: 8px; }

/* ───────── Responsive ───────── */
@media (max-width: 1100px) {
  .flip-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    position: sticky; top: 0; z-index: 30; padding: 8px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
  }
  .brand-sm { padding: 0; font-size: 17px; }
  .sidebar {
    position: fixed; z-index: 60; left: 0; top: 0; bottom: 0; height: auto; width: 86%; max-width: 330px;
    transform: translateX(-102%); transition: transform .25s ease; box-shadow: var(--shadow);
  }
  .sidebar.open { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(0,0,0,.35); opacity: 0; pointer-events: none; transition: opacity .25s; }
  .scrim.open { opacity: 1; pointer-events: auto; }
  .sidebar .brand { display: none; }
  main { padding: 22px 16px 80px; }
  .nesb-tiles { grid-template-columns: repeat(2, 1fr); }
  .cards.cols-3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .cards.cols-2, .dodont, .g-opts, .row-2, .row-3, .pn { grid-template-columns: minmax(0, 1fr); }
  .flow { flex-direction: column; }
  .flow-arrow { width: auto; height: 22px; transform: rotate(90deg); }
  .flow-repeat { padding: 6px 0 0; }
  .opts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .u-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .an-row { grid-template-columns: minmax(0, 1fr); }
  .an-label { border-right: 0; border-bottom: 1px solid var(--line); padding: 8px 12px; }
  .lesson-head { gap: 14px; }
  .lesson-badge { width: 48px; height: 48px; font-size: 22px; border-radius: 13px; }
  .sec-card { grid-template-columns: minmax(0, 1fr); }
  .content p.lead { font-size: 18.5px; }
  .ex-line { font-size: 19px !important; }
  .daily-days { gap: 3px; }
  details.ostep .os-body { padding-left: 16px; }
  .stat-row { grid-template-columns: minmax(0, 1fr); }
  .pn a.next { text-align: left; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
