/* Layout: one reading column (68ch) under a slim ledger-style header; tool pages put the calculator card first, teaching content below.
   Palette: gradebook green ink on cool paper, pencil-yellow highlighter for results. */
:root {
  --paper: #F5F7F4;
  --surface: #FFFFFF;
  --ink: #16231F;
  --muted: #55635D;
  --line: #D8DED9;
  --brand: #0F5C4E;
  --brand-ink: #FFFFFF;
  --tint: #E6EFEA;
  --mark: rgba(245, 197, 24, .42);
  --good: #1E7A45;
  --warn: #9A5B00;
  --bad: #B42318;
  --font-display: "Literata", Georgia, "Times New Roman", serif;
  --font-body: "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-num: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #101715; --surface: #17201D; --ink: #E6EDE9; --muted: #9DAEA6; --line: #2B3833;
    --brand: #5FC4A8; --brand-ink: #0B1412; --tint: #1C2A25; --mark: rgba(245, 197, 24, .30);
    --good: #5FCB8B; --warn: #F0A640; --bad: #F97066; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #101715; --surface: #17201D; --ink: #E6EDE9; --muted: #9DAEA6; --line: #2B3833;
  --brand: #5FC4A8; --brand-ink: #0B1412; --tint: #1C2A25; --mark: rgba(245, 197, 24, .30);
  --good: #5FCB8B; --warn: #F0A640; --bad: #F97066; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.65;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
a { color: var(--brand); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.2; text-wrap: balance; margin: 0; }
h1 { font-size: clamp(1.9rem, 4.5vw, 2.75rem); font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 1.55rem; font-weight: 600; }
h3 { font-size: 1.15rem; font-weight: 600; }
p { margin: 0; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }

.wrap { max-width: 1040px; margin: 0 auto; }
.col { max-width: 46rem; }

/* Header */
.site-head { border-bottom: 1px solid var(--line); }
.site-head .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-block: 14px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; }
.brand svg { flex: none; }
.nav { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: .95rem; }
.nav a { color: var(--muted); text-decoration: none; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--ink); text-decoration: underline; }

main { padding-block: 32px 64px; }
.crumbs { font-size: .875rem; color: var(--muted); margin-bottom: 12px; }
.crumbs a { color: var(--muted); }
.lede { color: var(--muted); font-size: 1.15rem; margin-top: 10px; max-width: 40rem; }

/* Tool card */
.tool {
  margin-top: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}
.tool form { padding: 22px; display: grid; gap: 14px; align-content: start; }
.tool .out { padding: 22px; background: var(--tint); border-left: 1px solid var(--line); border-radius: 0 14px 14px 0; display: grid; gap: 16px; align-content: start; min-width: 0; }
@media (max-width: 720px) {
  .tool { grid-template-columns: 1fr; }
  .tool .out { border-left: 0; border-top: 1px solid var(--line); border-radius: 0 0 14px 14px; }
}
.field { display: grid; gap: 6px; }
.field label { font-weight: 700; font-size: .95rem; }
.field .hint { font-size: .85rem; color: var(--muted); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
input[type="number"], input[type="text"], textarea {
  font: inherit; font-family: var(--font-num); font-size: 1.05rem;
  width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
}
textarea { font-family: var(--font-body); font-size: 1rem; line-height: 1.6; min-height: 220px; resize: vertical; }
input:focus, textarea:focus { border-color: var(--brand); outline: 2px solid var(--brand); outline-offset: 0; }
.btns { display: flex; flex-wrap: wrap; gap: 10px; }
button {
  font: inherit; font-weight: 700; font-size: .95rem; cursor: pointer;
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--brand);
  background: var(--brand); color: var(--brand-ink);
}
button.ghost { background: transparent; color: var(--brand); }
button:hover { filter: brightness(1.06); }

.big { display: grid; gap: 2px; }
.big .label { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.big .value { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: clamp(2.4rem, 7vw, 3.25rem); font-weight: 600; line-height: 1.1; }
.big .value span { background: linear-gradient(transparent 58%, var(--mark) 58%, var(--mark) 92%, transparent 92%); padding: 0 .1em; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.stat .k { font-size: .8rem; color: var(--muted); }
.stat .v { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: 1.3rem; font-weight: 600; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: .9rem; padding: 4px 10px; border-radius: 999px; border: 1.5px solid currentColor; justify-self: start; }
.pill.good { color: var(--good); } .pill.warn { color: var(--warn); } .pill.bad { color: var(--bad); }
.note { font-size: .9rem; color: var(--muted); }

/* Class log */
.log { margin-top: 4px; }
.log table { font-size: .9rem; }
.example-tag { font-size: .8rem; color: var(--muted); }

/* Content */
.content { margin-top: 48px; display: grid; gap: 40px; }
.content section { display: grid; gap: 14px; }
.content ul, .content ol { margin: 0; padding-left: 1.3em; display: grid; gap: 6px; }
.answer { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 16px 18px; display: grid; gap: 8px; }
.answer .formula { font-family: var(--font-num); font-size: .98rem; background: var(--tint); padding: 10px 12px; border-radius: 8px; overflow-x: auto; white-space: nowrap; }
.tablebox { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
details { border-bottom: 1px solid var(--line); padding-block: 12px; }
details summary { cursor: pointer; font-weight: 700; }
details p { margin-top: 8px; color: var(--ink); }
.author { display: flex; gap: 14px; align-items: center; border-top: 1px solid var(--line); padding-top: 18px; font-size: .92rem; color: var(--muted); }
.author .av { width: 44px; height: 44px; border-radius: 50%; background: var(--tint); color: var(--brand); display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; flex: none; }

/* Related + home tiles */
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 820px) { .tiles { grid-template-columns: 1fr; } }
.tile { display: grid; gap: 8px; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); text-decoration: none; min-width: 0; }
.tile:hover { border-color: var(--brand); }
.tile .eg { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: 1.9rem; font-weight: 600; }
.tile .eg span { background: linear-gradient(transparent 58%, var(--mark) 58%, var(--mark) 92%, transparent 92%); }
.tile .k { font-size: .85rem; color: var(--muted); }
.tile .go { color: var(--brand); font-weight: 700; font-size: .95rem; }

.hero { display: grid; gap: 14px; padding-block: 16px 8px; }
.kicker { font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; color: var(--brand); font-weight: 700; }
.split { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
@media (max-width: 820px) { .split { grid-template-columns: 1fr; } }

.site-foot { border-top: 1px solid var(--line); color: var(--muted); font-size: .9rem; }
.site-foot .wrap { padding-block: 28px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px; }
.site-foot nav { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.site-foot a { color: var(--muted); }

.prose { display: grid; gap: 16px; }
.prose ul { margin: 0; padding-left: 1.3em; display: grid; gap: 6px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
