/* Self-hosted fonts (SIL Open Font License, see /fonts). Montserrat sets all text;
   Fraunces is kept for the wordmark and a few decorative numerals. */
@font-face { font-family: "Fraunces"; src: url("/fonts/fraunces-latin-wght-normal.woff2") format("woff2"); font-weight: 300 800; font-style: normal; font-display: swap; }
@font-face { font-family: "Fraunces"; src: url("/fonts/fraunces-latin-wght-italic.woff2") format("woff2"); font-weight: 300 800; font-style: italic; font-display: swap; }
@font-face { font-family: "Montserrat"; src: url("/fonts/montserrat-latin-wght-normal.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }

/* Ivory and forest: deep green for action, gold for achievement, ivory paper underneath. */
:root {
  color-scheme: light;
  --ink: #1c2a22;
  --muted: #56655b;
  --line: #e6dfcf;
  --line-strong: #cfc5ae;
  --surface: #fffdf8;
  --canvas: #f8f5ee;
  --sand: #f1ebdf;
  --brand: #14392b;
  --brand-dark: #0c2a1f;
  --brand-soft: #eaf1ec;
  --gold: #a07d2c;
  --gold-text: #7f6220;
  --gold-soft: #f6edd6;
  --header: #f4efe4;
  --header-active: #e2ebe4;
  --select: #1f5a43;
  --target: #fbf3dc;
  --ok: #1e6b45;
  --ok-bg: #e6f0e9;
  --bad: #a3392b;
  --bad-bg: #f8e9e5;
  --info-bg: #eef2ec;
  --field: #b9b09c;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(20, 57, 43, 0.05), 0 12px 32px rgba(20, 57, 43, 0.08);
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-family: var(--sans);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--canvas); color: var(--ink); line-height: 1.6; min-height: 100vh; display: flex; flex-direction: column; -webkit-font-smoothing: antialiased; }
::selection { background: var(--gold-soft); }

/* Typography */
h1, h2 { font-weight: 600; letter-spacing: -0.015em; }
h1 { font-size: clamp(1.75rem, 3.5vw, 2.25rem); line-height: 1.15; margin: 0 0 10px; }
h2 { font-size: clamp(1.35rem, 2.6vw, 1.75rem); line-height: 1.2; margin: 32px 0 10px; }
h3 { font-size: 1.05rem; font-weight: 600; margin: 0 0 6px; letter-spacing: -0.005em; }
h1 em, h2 em { color: var(--brand); }
a { color: var(--brand); text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
.muted { color: var(--muted); }
.eyebrow { color: var(--gold-text); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; margin: 16px 0 6px; }
.eyebrow:has(#position) { text-transform: none; letter-spacing: 0.01em; font-size: 0.875rem; }
.lead { font-size: 1.125rem; color: var(--muted); max-width: 52ch; }
.instructions { margin: 0 0 18px; max-width: 70ch; }
.message { text-align: center; padding: 64px 0; }

/* Layout */
.page { width: 100%; max-width: 960px; margin: 0 auto; padding: 32px 20px 56px; flex: 1; }
.page.narrow { max-width: 640px; }
.page.wide { max-width: 1120px; }

/* Header */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 20px; min-height: 64px; padding: 10px max(20px, calc((100% - 1120px) / 2)); background: rgba(248, 245, 238, 0.92); border-bottom: 1px solid var(--line); backdrop-filter: saturate(1.4) blur(8px); }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-family: var(--serif); font-size: 1.3rem; font-weight: 500; letter-spacing: -0.01em; text-decoration: none; }
.brand::before { content: ""; width: 28px; height: 28px; background: url("/favicon.svg") center / contain no-repeat; }
.site-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 22px; font-size: 0.9375rem; }
.site-nav a:not(.button), .link-button { color: var(--ink); text-decoration: none; font: inherit; background: none; border: 0; padding: 4px 0; cursor: pointer; }
.site-nav a:not(.button):hover, .site-nav .link-button:hover { color: var(--brand); text-decoration: underline; text-decoration-color: var(--gold); text-underline-offset: 6px; }
.site-nav .link-button { color: var(--ink); text-decoration: none; }
.link-button { color: var(--brand); text-decoration: underline; }
.link-button.danger-text { color: var(--bad); }

/* Footer */
.legal { margin-top: auto; padding: 40px 20px 32px; text-align: center; font-size: 0.8125rem; color: #b9c6bd; background: var(--brand-dark); }
.legal a { color: #efe9da; text-decoration: none; }
.legal a:hover { color: #fff; text-decoration: underline; }
.legal p { margin: 16px auto 0; max-width: 640px; }
.footer-nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 22px; font-size: 0.875rem; }

/* Buttons */
.button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; font-size: 0.9375rem; min-height: 42px; padding: 9px 20px; border-radius: 999px; border: 1px solid transparent; cursor: pointer; text-decoration: none; transition: background-color 0.15s, border-color 0.15s, transform 0.15s; }
.button:focus-visible, a:focus-visible, .tool:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.button.primary, a.button.primary { background: var(--brand); color: #f8f5ee; }
.button.primary:hover { background: var(--brand-dark); }
.button.quiet { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.button.quiet:hover { background: var(--surface); border-color: var(--brand); }
.button.gold { background: var(--gold); color: #fffdf8; }
.button.danger { background: var(--bad); color: #fff; }
.button.small { min-height: 36px; padding: 5px 16px; font-size: 0.875rem; }
.button.large { font-size: 1.0625rem; min-height: 52px; padding: 12px 28px; }
.button:disabled { opacity: 0.5; cursor: default; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; align-items: center; }
.spacer { flex: 1; }

/* Progress */
.progress { height: 6px; background: var(--sand); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--brand), var(--select)); border-radius: 999px; transition: width 0.3s; }

/* Spreadsheet */
.formula-row { display: flex; align-items: stretch; background: var(--surface); border: 1px solid var(--line); border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; overflow: hidden; }
#toolbar:not(:empty) + .formula-row, .toolbar + .formula-row, .filter-panel + .formula-row { border-radius: 0; }
.name-box { min-width: 76px; padding: 8px; border-right: 1px solid var(--line); font-size: 0.875rem; text-align: center; white-space: nowrap; font-family: var(--mono); color: var(--muted); }
.fx { padding: 8px 12px; color: var(--gold-text); font-family: var(--serif); font-style: italic; border-right: 1px solid var(--line); font-size: 0.9375rem; }
.formula-bar { flex: 1; min-width: 0; border: 0; padding: 8px 10px; font: 0.9375rem var(--mono); color: var(--ink); background: transparent; }
.formula-bar:focus { outline: 2px solid var(--select); outline-offset: -2px; }

.sheet-scroll { overflow: auto; border: 1px solid var(--line); background: var(--surface); border-radius: 0 0 var(--radius) var(--radius); box-shadow: var(--shadow); }
.grid-host { position: relative; width: max-content; outline: none; user-select: none; }
.sheet { border-collapse: collapse; table-layout: fixed; font-size: 0.875rem; }
.sheet th { background: var(--header); color: var(--muted); font-weight: 500; font-size: 0.8125rem; border: 1px solid var(--line); padding: 0; height: 28px; text-align: center; cursor: default; }
.sheet thead th { width: 104px; }
.sheet thead th.corner, .sheet tbody th { width: 42px; }
.sheet thead th { position: sticky; top: 0; z-index: 3; }
.sheet tbody th, .sheet thead th.corner { position: sticky; left: 0; z-index: 3; }
.sheet thead th.corner { z-index: 4; }
.sheet th.active { background: var(--header-active); color: var(--brand); font-weight: 600; }
.sheet td { border: 1px solid #efe9dc; height: 28px; width: 104px; max-width: 104px; padding: 0 7px; white-space: nowrap; overflow: hidden; cursor: cell; }
.sheet td.num { text-align: right; font-variant-numeric: tabular-nums; }
.sheet td.err { color: var(--bad); text-align: center; }
.sheet td.target { background: var(--target); }
.sheet td.ref-a { background: #dde9f5; }
.sheet td.ref-b { background: #f5dfd8; }
.sheet td.ref-c { background: #e6e0f2; }
.sheet td.ref-d { background: #dcebe0; }
.selection-box { position: absolute; border: 2px solid var(--select); background: rgba(31, 90, 67, 0.07); pointer-events: none; }
.fill-handle { position: absolute; width: 8px; height: 8px; background: var(--select); border: 1px solid #fff; cursor: crosshair; }
.cell-editor { position: absolute; z-index: 2; border: 2px solid var(--select); padding: 0 4px; font: 0.875rem var(--mono); outline: none; background: #fff; color: var(--ink); field-sizing: content; max-width: 420px; }

/* Feedback */
.feedback { margin-top: 18px; padding: 14px 18px; border-radius: var(--radius); border: 1px solid; }
.feedback p { margin: 4px 0 0; }
.feedback p:empty { display: none; }
.feedback.correct { background: var(--ok-bg); border-color: #bcd6c4; color: var(--ok); }
.feedback.correct p, .feedback.incorrect p { color: var(--ink); }
.feedback.incorrect { background: var(--bad-bg); border-color: #ebc7bf; color: var(--bad); }
.feedback.revealed { background: var(--info-bg); border-color: #cddbd0; }
.feedback.revealed strong { font-family: var(--mono); overflow-wrap: anywhere; }
.feedback.checking { background: var(--header); border-color: var(--line); color: var(--muted); }

/* Home */
.hero { max-width: 1120px; margin: 0 auto; padding: 72px 20px 64px; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 56px; align-items: center; }
.hero h1 { font-size: clamp(2.2rem, 5vw, 3.4rem); line-height: 1.08; letter-spacing: -0.03em; font-weight: 700; margin-bottom: 18px; }
.hero h1 em { font-style: normal; }
.hero .eyebrow { margin-top: 0; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 28px 0 12px; }
.hero-note { font-size: 0.875rem; color: var(--muted); margin: 0; }
.hero-sheet { position: relative; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px; box-shadow: 0 2px 4px rgba(20, 57, 43, 0.04), 0 30px 60px rgba(20, 57, 43, 0.14); }
.hero-sheet::after { content: ""; position: absolute; inset: 18px -18px -18px 18px; z-index: -1; border-radius: var(--radius-lg); background: var(--sand); border: 1px solid var(--line); }
.mini-bar { display: flex; gap: 12px; align-items: center; font-size: 0.8125rem; margin-bottom: 10px; color: var(--muted); padding: 6px 10px; background: var(--canvas); border-radius: 8px; }
.mini-bar span { font-family: var(--mono); }
.mini-bar code { color: var(--ink); overflow-wrap: anywhere; font-family: var(--mono); }
.sheet.mini { width: 100%; font-size: 0.8125rem; }
.sheet.mini th, .sheet.mini td { width: auto; max-width: none; position: static; }
.mini-feedback { display: flex; justify-content: space-between; gap: 8px; margin: 12px 0 0; padding: 8px 12px; background: var(--ok-bg); color: var(--ok); font-weight: 600; border-radius: 8px; font-size: 0.875rem; }
.mini-feedback span { color: var(--gold-text); }

.facts { max-width: 1120px; margin: 0 auto; padding: 0 20px 56px; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0; }
.facts div { padding: 4px 24px; border-left: 1px solid var(--line-strong); }
.facts strong { display: block; font-family: var(--serif); font-size: 2.25rem; font-weight: 400; line-height: 1.1; color: var(--brand); }
.facts span { font-size: 0.875rem; color: var(--muted); }

.band { background: var(--surface); border-block: 1px solid var(--line); }
.band.forest { background: var(--brand); color: #efe9da; border: 0; }
.band.forest h2, .band.forest h3 { color: #fffdf8; }
.band.forest .muted, .band.forest p { color: #c9d5cc; }
.section-head { max-width: 640px; margin-bottom: 8px; }
.section-head h2 { margin-top: 0; }
.page > .section-head:first-child, .band .page > .section-head:first-child { margin-top: 24px; }
.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 28px; margin-top: 28px; }
.columns p { margin: 0; }
.step-number { display: block; font-family: var(--serif); font-style: italic; font-size: 2rem; line-height: 1; color: var(--gold); margin-bottom: 12px; }
.topics { list-style: none; padding: 0; margin: 20px 0; display: flex; flex-wrap: wrap; gap: 10px; }
.topics li { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 7px 16px; font-size: 0.9375rem; }
.audience { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-top: 24px; }
.audience article { background: var(--canvas); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 22px; }
.audience p { margin: 0; color: var(--muted); }

.cert-feature { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 48px; align-items: center; }
.cert-preview { background: #fffdf8; color: var(--ink); border-radius: 6px; padding: 28px 24px; text-align: center; border: 1px solid var(--gold); outline: 6px solid rgba(160, 125, 44, 0.18); outline-offset: 6px; }
.cert-preview .eyebrow { margin: 0 0 8px; }
.cert-preview .cert-name { font-family: var(--serif); font-size: 1.6rem; font-style: italic; margin: 6px 0; color: var(--brand); }
.cert-preview p { color: var(--muted) !important; margin: 4px 0; font-size: 0.875rem; }
.cert-seal { display: inline-grid; place-items: center; width: 54px; height: 54px; margin-top: 12px; border-radius: 50%; background: var(--gold); color: #fffdf8; font-family: var(--serif); font-size: 1.4rem; }
.ticks { list-style: none; padding: 0; margin: 18px 0 24px; }
.ticks li { position: relative; padding-left: 28px; margin-bottom: 10px; }
.ticks li::before { content: ""; position: absolute; left: 0; top: 0.45em; width: 14px; height: 8px; border-left: 2px solid var(--gold); border-bottom: 2px solid var(--gold); transform: rotate(-45deg); }

.plans { display: grid; grid-template-columns: repeat(auto-fill, minmax(205px, 1fr)); gap: 18px; margin: 24px 0; align-items: stretch; }
.plan { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 26px 24px; }
.plan.featured { border: 1.5px solid var(--gold); box-shadow: var(--shadow); position: relative; }
.plan.featured::before { content: "Best value"; position: absolute; top: -12px; left: 24px; background: var(--gold); color: #fffdf8; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em; padding: 3px 10px; border-radius: 999px; }
.plan h3 { font-weight: 600; font-size: 1.2rem; }
.plan .price { font-size: 2.2rem; font-weight: 700; letter-spacing: -0.02em; margin: 4px 0 0; line-height: 1.1; }
.plan .muted { margin: 0 0 12px; font-size: 0.875rem; }
.plan .price-was { font-size: 1.25rem; font-weight: 500; color: var(--muted); }
.plan .plan-note { margin: -4px 0 12px; padding: 6px 10px; border-radius: 8px; background: var(--gold-soft); color: var(--gold-text); font-size: 0.8125rem; font-weight: 600; }
.plan ul { list-style: none; padding: 0; margin: 8px 0 20px; flex: 1; }
.plan li { position: relative; padding-left: 24px; margin-bottom: 8px; font-size: 0.9375rem; }
.plan li::before { content: ""; position: absolute; left: 2px; top: 0.5em; width: 11px; height: 6px; border-left: 2px solid var(--brand); border-bottom: 2px solid var(--brand); transform: rotate(-45deg); }
.plan .button { width: 100%; }
.quote { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 22px; }
.quote blockquote { margin: 0 0 10px; font-size: 1.05rem; }
.quote figcaption { color: var(--muted); font-size: 0.875rem; }
.faq details { border-bottom: 1px solid var(--line); padding: 16px 4px; }
.faq details:first-of-type { border-top: 1px solid var(--line); }
.faq summary { font-weight: 600; cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: 16px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-family: var(--serif); font-size: 1.4rem; line-height: 1; color: var(--gold); }
.faq details[open] summary::after { content: "–"; }
.faq details p { margin: 10px 0 2px; color: var(--muted); max-width: 70ch; }
.cta { text-align: center; padding: 72px 20px; }
.cta h2 { font-size: clamp(1.8rem, 4vw, 2.6rem); margin: 0 0 20px; }
.cta .button.primary { background: #fffdf8; color: var(--brand); }
.cta .button.primary:hover { background: var(--gold-soft); }

/* Lessons and catalogues */
.filter { display: inline-flex; gap: 10px; align-items: center; margin: 8px 0 12px; font-size: 0.9375rem; color: var(--muted); }
select { font: inherit; padding: 7px 12px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); color: var(--ink); }
.category h2 { font-size: 1.4rem; margin-top: 36px; }
.lesson-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.lesson-row { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; transition: border-color 0.15s, box-shadow 0.15s; }
.lesson-row:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.lesson-row a { font-weight: 600; color: var(--ink); text-decoration: none; }
.lesson-row a:hover { color: var(--brand); text-decoration: underline; }
.lesson-row p { width: 100%; margin: 0; font-size: 0.9375rem; }
.lesson-row .status { margin-left: auto; font-size: 0.875rem; }
.tag { font-size: 0.75rem; font-weight: 500; padding: 2px 10px; border-radius: 999px; background: var(--header); color: var(--muted); text-transform: capitalize; }
.tag.premium { background: var(--gold-soft); color: var(--gold-text); }
.tag.locked { background: var(--bad-bg); color: var(--bad); }

/* Forms */
.form { display: flex; flex-direction: column; gap: 16px; align-items: flex-start; margin: 20px 0; }
.form label { display: flex; flex-direction: column; gap: 6px; width: 100%; font-weight: 500; font-size: 0.9375rem; }
.form label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
.form input:not([type=checkbox]), .form select, .form textarea { font: inherit; font-weight: 400; width: 100%; padding: 11px 14px; border: 1px solid var(--field); border-radius: var(--radius); color: var(--ink); background: #fff; }
.form select { border-radius: var(--radius); }
.form input:focus, .form select:focus, .form textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.form .help { font-weight: 400; font-size: 0.8125rem; }
.form .feedback { width: 100%; margin-top: 0; }
.form .formula-bar { border: 0; border-radius: 0; }
.notice { background: var(--gold-soft); border: 1px solid #e8d7ab; border-radius: var(--radius); padding: 14px 18px; margin: 14px 0; }
.notice p { margin: 0 0 8px; }

/* Account pages sit on a card */
body[data-page=login] .page, body[data-page=register] .page, body[data-page=forgot] .page, body[data-page=action] .page { max-width: 480px; margin: 48px auto; padding: 36px 32px; flex: 0 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
body[data-page] .page .form .button.primary { width: 100%; min-height: 48px; }
body[data-page] .page > p { font-size: 0.9375rem; }

/* Dashboard */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin: 20px 0; }
.tile { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; font-size: 0.875rem; }
.tile-value { font-size: 1.8rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; color: var(--brand); }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr)); gap: 18px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 6px 20px 20px; min-width: 0; }
.card h2 { font-size: 1.2rem; margin: 16px 0 10px; }
.plain { list-style: none; margin: 0; padding: 0; }
.plain li { margin-bottom: 12px; }
.progress-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; }
.progress-row .progress { grid-column: 1 / -1; }
table.data { width: 100%; border-collapse: collapse; background: var(--surface); font-size: 0.9375rem; }
table.data th { font-size: 0.8125rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
table.data th, table.data td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tr.mine { background: var(--gold-soft); font-weight: 600; }
.badges { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.badge { display: flex; flex-direction: column; gap: 2px; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; font-size: 0.875rem; background: var(--surface); }
.badge.earned { border-color: #dcc68f; background: var(--gold-soft); }
.badge.locked { color: var(--muted); }
.badge-state { font-size: 0.75rem; margin-top: 4px; }

/* Admin */
.admin-layout { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 28px; align-items: start; }
.admin-tabs { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 80px; }
.admin-tabs a { padding: 8px 12px; border-radius: 8px; color: var(--ink); text-decoration: none; font-size: 0.9375rem; }
.admin-tabs a:hover { background: var(--header); }
.admin-tabs a[aria-current=page] { background: var(--header-active); color: var(--brand); font-weight: 600; }
.admin-content { min-width: 0; }
.table-scroll { overflow-x: auto; }
.row-actions { display: inline-flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.row-actions input, .row-actions select { font: inherit; font-size: 0.875rem; padding: 4px 8px; border: 1px solid var(--line-strong); border-radius: 6px; }
.search-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 16px; align-items: center; }
.search-row input { font: inherit; padding: 9px 14px; border: 1px solid var(--field); border-radius: 999px; flex: 1; min-width: 180px; background: #fff; }
.card.form { padding: 6px 20px 20px; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 10px; width: 100%; }
.label-text { font-weight: 500; margin: 0; }
.editor-grid { width: 100%; min-width: 0; }

/* Projects, assessments and certificates */
.task { list-style: none; margin-bottom: 12px; padding: 14px 18px; }
.task p { margin: 0 0 8px; }
.task .feedback { margin-top: 8px; }
.task-form { display: flex; flex-wrap: wrap; gap: 8px; }
.task-form input { font: inherit; flex: 1; min-width: 160px; padding: 9px 12px; border: 1px solid var(--field); border-radius: var(--radius); background: #fff; }
.assessment-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 4px 16px; }
.timer-box { margin: 0; font-variant-numeric: tabular-nums; }
#timer.urgent { color: var(--bad); }
.certificate { text-align: center; padding: 32px 24px; margin: 20px 0; border: 1px solid var(--gold); outline: 6px solid rgba(160, 125, 44, 0.15); outline-offset: 6px; }
.certificate h2 { font-size: 1.8rem; margin: 0 0 12px; }
.certificate h3 { font-family: var(--serif); font-style: italic; font-weight: 400; font-size: 1.5rem; color: var(--brand); }
.certificate p { margin: 4px 0; }

/* Formatting toolbar */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 6px 8px; background: var(--surface); border: 1px solid var(--line); border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; }
.tool { font: inherit; font-size: 0.8125rem; min-width: 32px; height: 32px; padding: 0 9px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; cursor: pointer; }
.tool:hover { background: var(--header); border-color: var(--line-strong); }
.tool-gap { width: 8px; }
.filter-panel { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-bottom: 0; }
.sheet td.s-b { font-weight: 700; }
.sheet td.s-i { font-style: italic; }
.sheet td.s-u { text-decoration: underline; }
.sheet td.s-fill { background: #ffe873; }

/* Simulators */
.simulator { background: var(--surface); border: 1px solid var(--line); border-top: 0; padding: 6px 16px 16px; border-radius: 0 0 var(--radius) var(--radius); }
.sim-title { font-size: 1.05rem; margin: 12px 0 8px; }
.sim-form { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
.sim-form label { display: flex; flex-direction: column; gap: 3px; font-size: 0.875rem; font-weight: 500; flex: 1 1 130px; min-width: 0; }
.sim-form input, .sim-form select { font: inherit; font-weight: 400; padding: 7px 10px; border: 1px solid var(--field); border-radius: 8px; width: 100%; min-width: 0; background: #fff; }
.sim-form .link-button { font-size: 0.8125rem; font-weight: 400; text-align: left; padding: 0; }
.sim-result { margin-top: 12px; min-width: 0; overflow-x: auto; }
.sim-result p { margin: 0 0 4px; }
.sim-tools { border: 0; padding: 4px 0; }
.sim-tools input, .sim-tools select { font: inherit; font-size: 0.875rem; padding: 4px 8px; border: 1px solid var(--field); border-radius: 6px; max-width: 100%; }
.sim-steps { margin: 4px 0 8px; padding-left: 22px; font-size: 0.9375rem; }
.total-row td { font-weight: 700; }
.chart { width: 100%; max-width: 560px; height: auto; display: block; }
.chart-title { font-size: 15px; font-weight: 600; fill: var(--ink); }
.chart-label { font-size: 12px; fill: var(--muted); }

@media (max-width: 860px) {
  .hero { grid-template-columns: minmax(0, 1fr); padding: 40px 20px 48px; gap: 40px; }
  .cert-feature { grid-template-columns: minmax(0, 1fr); gap: 36px; }
  .admin-layout { grid-template-columns: minmax(0, 1fr); }
  .admin-tabs { flex-direction: row; flex-wrap: wrap; position: static; }
}
@media (max-width: 560px) {
  .topbar { position: static; padding: 10px 16px; }
  .site-nav { gap: 2px 14px; font-size: 0.875rem; }
  .page { padding: 24px 16px 40px; }
  .facts div { padding: 8px 14px; }
  .hero-sheet::after { display: none; }
  .sheet.mini th:nth-child(4), .sheet.mini td:nth-child(4), .sheet.mini th:nth-child(5), .sheet.mini td:nth-child(5) { display: none; }
  body[data-page=login] .page, body[data-page=register] .page, body[data-page=forgot] .page, body[data-page=action] .page { margin: 20px 12px; padding: 26px 20px; width: auto; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* Practice page: lesson list, exercise, today's leaders */
.practice-page .page { max-width: 1440px; padding-top: 24px; }
.practice-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr) 280px; grid-template-areas: "nav main side"; gap: 28px; align-items: start; }
.lesson-nav { grid-area: nav; position: sticky; top: 88px; max-height: calc(100vh - 112px); overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 14px 8px; }
.lesson-nav-title { margin: 0 10px 8px; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold-text); }
.lesson-nav ol { list-style: none; margin: 0; padding: 0; }
.lesson-nav a { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 8px; padding: 9px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; font-size: 0.9375rem; line-height: 1.35; border-left: 3px solid transparent; }
.lesson-nav a:hover { background: var(--header); }
.lesson-nav a[aria-current] { background: var(--brand-soft); border-left-color: var(--brand); font-weight: 600; color: var(--brand); }
.lesson-nav .tag { font-size: 0.6875rem; }
.tag.current { background: var(--brand); color: #f8f5ee; }
.tag.done { background: var(--ok-bg); color: var(--ok); }

.practice-main { grid-area: main; min-width: 0; }
.crumbs { font-size: 0.875rem; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }
.practice-main h1 { margin-bottom: 12px; }
.lesson-progress { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.lesson-progress .progress { flex: 1; height: 10px; }
.progress-label { font-size: 1.2rem; font-weight: 600; min-width: 3ch; color: var(--brand); }
.exercise-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 8px 26px 26px; box-shadow: var(--shadow); }
.exercise-card .eyebrow { margin-top: 18px; }
.exercise-card .instructions { font-size: 1.2rem; line-height: 1.7; max-width: 74ch; margin-bottom: 24px; }
.instructions p { margin: 0 0 14px; }
.instructions p:last-child { margin-bottom: 0; }
.instructions strong { font-weight: 700; color: var(--ink); }
.formula-chip { display: inline-block; font-family: var(--mono); font-size: 0.95em; padding: 2px 9px; border-radius: 6px; background: var(--gold-soft); color: #7a3b1d; border: 1px solid #ecdcb2; }
.instructions p > .formula-chip:only-child { font-size: 1.15rem; padding: 6px 14px; }
.exercise-card .sheet-scroll { box-shadow: none; }
.practice-actions { margin-top: 20px; }

.practice-side { grid-area: side; display: grid; gap: 18px; position: sticky; top: 88px; }
.leader-card { background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--gold); border-radius: var(--radius-lg); padding: 18px 20px; }
.leader-card h2 { font-size: 1rem; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase; color: var(--brand); margin: 0 0 12px; }
.leader-list { list-style: none; counter-reset: rank; margin: 0; padding: 0; }
.leader-list li { counter-increment: rank; display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; font-size: 0.9375rem; }
.leader-list li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leader-list li span::before { content: counter(rank) ". "; color: var(--gold-text); font-family: var(--serif); }
.leader-list li strong { font-variant-numeric: tabular-nums; font-weight: 600; }
.leader-list li.empty { color: var(--muted); font-size: 0.875rem; }
.leader-list li.empty::before, .leader-list li.empty span::before { content: none; }
.leader-mine { display: flex; justify-content: space-between; margin: 10px 0 0; padding-top: 12px; border-top: 1px solid var(--line); font-weight: 600; }
.leader-mine strong { color: var(--brand); }
.leader-note { margin: 10px 0 0; padding-top: 12px; border-top: 1px solid var(--line); font-size: 0.875rem; color: var(--muted); }

@media (max-width: 1180px) {
  .practice-layout { grid-template-columns: 230px minmax(0, 1fr); grid-template-areas: "nav main" "nav side"; }
  .practice-side { position: static; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
}
@media (max-width: 820px) {
  .practice-layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "main" "side" "nav"; gap: 22px; }
  .lesson-nav { position: static; max-height: 360px; }
  .exercise-card { padding: 4px 16px 18px; }
  .exercise-card .instructions { font-size: 1.0625rem; }
}

/* Persistent question bar */
.practice-actions { position: sticky; bottom: 0; z-index: 5; margin: 20px -4px 0; padding: 14px 4px; background: linear-gradient(rgba(248, 245, 238, 0), var(--canvas) 30%); }
.practice-actions .button { min-width: 120px; }

/* Lesson drawer toggle (tablets and phones) */
.drawer-toggle { display: none; }
.drawer-backdrop { display: none; }

/* Motion: light and quick; switched off for people who prefer reduced motion */
@keyframes rise-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pop-in { 0% { opacity: 0; transform: scale(0.97); } 60% { opacity: 1; transform: scale(1.01); } 100% { transform: none; } }
@keyframes nudge { 0%, 100% { transform: none; } 20% { transform: translateX(-6px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }
.exercise-card.entering { animation: rise-in 0.35s ease-out; }
.feedback { animation: rise-in 0.25s ease-out; }
.feedback.correct { animation: pop-in 0.35s ease-out; }
.feedback.incorrect { animation: nudge 0.4s ease-in-out; }
.progress-bar { transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1); }
.button:not(:disabled):hover { transform: translateY(-1px); }
.button:not(:disabled):active { transform: translateY(0) scale(0.98); }
.lesson-nav a { transition: background-color 0.15s, color 0.15s, border-color 0.15s; }
.leader-list li { animation: rise-in 0.3s ease-out both; }
.leader-list li:nth-child(2) { animation-delay: 0.05s; }
.leader-list li:nth-child(3) { animation-delay: 0.1s; }

@media (max-width: 820px) {
  .drawer-toggle { display: inline-flex; margin-bottom: 12px; }
  .lesson-nav { position: fixed; top: 0; bottom: 0; left: 0; z-index: 40; width: min(320px, 86vw); max-height: none; border-radius: 0 var(--radius-lg) var(--radius-lg) 0; transform: translateX(-105%); transition: transform 0.25s ease-out; box-shadow: var(--shadow); }
  .practice-layout.drawer-open .lesson-nav { transform: none; }
  .practice-layout.drawer-open .drawer-backdrop { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(12, 42, 31, 0.35); }
  .practice-layout { grid-template-areas: "main" "side"; }
  .practice-actions .button { min-width: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; }
}
@media (max-width: 560px) {
  .practice-actions { gap: 6px; }
  .practice-actions .button { min-height: 38px; padding: 6px 12px; font-size: 0.875rem; }
  .practice-actions .spacer { display: none; }
}

/* Excel Functions library */
.fn-filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.fn-filter { font: inherit; font-size: 0.875rem; font-weight: 500; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer; transition: background-color 0.15s, border-color 0.15s; }
.fn-filter:hover { border-color: var(--brand); }
.fn-filter[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--canvas); }
.fn-grid { list-style: none; padding: 0; margin: 8px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.fn-grid a { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; height: 100%; padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); text-decoration: none; transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s; }
.fn-grid a:hover { border-color: var(--line-strong); box-shadow: var(--shadow); transform: translateY(-1px); }
.fn-grid strong { font-size: 1.05rem; color: var(--brand); }
.fn-grid a > span:last-child { font-size: 0.9rem; color: var(--muted); line-height: 1.5; }
.fn-grid .tag { text-transform: none; }
.fn-guide { max-width: 760px; }
.fn-guide h2 { font-size: 1.3rem; margin: 32px 0 10px; }
.fn-syntax { margin: 20px 0 8px; padding: 14px 18px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--gold); border-radius: var(--radius); }
.fn-syntax .eyebrow { display: block; margin: 0 0 6px; }
.fn-syntax code { display: block; font-family: var(--mono); font-size: 0.95rem; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink); }
table.data.fn-args th { width: 32%; text-align: left; vertical-align: top; font-weight: 500; text-transform: none; letter-spacing: normal; font-size: inherit; color: var(--ink); background: none; }
.fn-args code { font-family: var(--mono); font-size: 0.9rem; overflow-wrap: anywhere; }
.fn-args th, .fn-args td { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.fn-sheet { margin: 8px 18px 20px 0; }
.fn-sheet .sheet.mini td { white-space: nowrap; }
.fn-result { margin-top: 26px; }
.fn-cta { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; margin: 36px 0 8px; padding: 22px 24px; background: var(--brand); color: var(--canvas); border-radius: var(--radius-lg); }
.fn-cta h2 { margin: 0 0 4px; color: var(--canvas); }
.fn-cta p { margin: 0; color: #d7e2da; }
.fn-cta .button.primary { background: var(--canvas); color: var(--brand); }
.fn-cta .button.primary:hover { background: var(--gold-soft); }
.fn-related a { text-decoration: none; color: var(--brand); font-weight: 500; }
.fn-related li:hover { border-color: var(--line-strong); }
@media (max-width: 560px) {
  table.data.fn-args th { width: 40%; }
  .fn-sheet { margin-right: 0; }
  .fn-sheet::after { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .fn-grid a { transition: none; }
  .fn-grid a:hover { transform: none; }
}
