:root {
  --bg: #fbfaf8;
  --surface: #ffffff;
  --sunk: #f4f2ee;
  --line: #e5e1da;
  --line-soft: #efece6;
  --ink: #23201d;
  --ink-2: #4a443d;
  --ink-3: #766e64;
  --muted: #8b8378;
  --brand: #1f6f5c;
  --brand-dark: #185447;
  --brand-wash: #e8f2ef;
  --accent: #b4573a;
  --accent-wash: #fbeee9;
  --amber: #a97c1e;
  --amber-wash: #fdf5e4;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(35, 32, 29, .05), 0 4px 14px rgba(35, 32, 29, .04);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: ui-serif, Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-dark); }

/* ============================================================ site chrome */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(251, 250, 248, .92);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 68rem;
  margin: 0 auto;
  padding: .7rem 1.15rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: .55rem;
  text-decoration: none;
  color: var(--ink);
  flex: 0 0 auto;
}

.brand svg { display: block; color: var(--brand); }

.brand b {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.12rem;
  letter-spacing: -.01em;
}

.brand span {
  display: block;
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: -2px;
}

.nav {
  margin-left: auto;
  display: flex;
  gap: .2rem;
  align-items: center;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }

.nav a {
  font-size: .875rem;
  font-weight: 500;
  color: var(--ink-2);
  text-decoration: none;
  padding: .4rem .6rem;
  border-radius: 8px;
  white-space: nowrap;
}
.nav a:hover { background: var(--sunk); color: var(--ink); }
.nav a[aria-current="page"] { color: var(--brand-dark); background: var(--brand-wash); }

/* ================================================================= layout */

.wrap {
  max-width: 68rem;
  margin: 0 auto;
  padding: 1.6rem 1.15rem 4rem;
}

.narrow { max-width: 46rem; }

section + section { margin-top: 2.6rem; }

/* =================================================================== hero */

.hero {
  display: grid;
  gap: 1.6rem;
  padding: 1.4rem 0 .6rem;
}

.eyebrow {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--brand);
  margin: 0 0 .55rem;
}

h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.75rem, 4.4vw, 2.5rem);
  line-height: 1.14;
  letter-spacing: -.02em;
  margin: 0 0 .7rem;
  text-wrap: balance;
}

.lede {
  margin: 0;
  font-size: 1.06rem;
  color: var(--ink-2);
  max-width: 40em;
}

/* ============================================================== exam card */

.exam {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.6rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.05rem 1.2rem;
}

.exam-count {
  display: flex;
  align-items: baseline;
  gap: .4rem;
}

.exam-count b {
  font-family: var(--serif);
  font-size: 2.1rem;
  line-height: 1;
  font-weight: 500;
  color: var(--brand);
}

.exam-count span { font-size: .8rem; color: var(--ink-3); }

.exam-meta { font-size: .875rem; color: var(--ink-2); }
.exam-meta b { color: var(--ink); font-weight: 600; }

.bar {
  flex: 1 1 12rem;
  min-width: 10rem;
}

.bar-track {
  height: 7px;
  border-radius: 99px;
  background: var(--sunk);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: var(--brand);
}

/* Widths live here rather than in a style attribute: the CSP has no
   'unsafe-inline', so an inline style would simply not apply. */
.bar-fill[data-pct="42"] { width: 42%; }
.bar-fill[data-pct="55"] { width: 55%; }
.bar-fill[data-pct="69"] { width: 69%; }
.bar-fill[data-pct="78"] { width: 78%; }
.bar-fill[data-pct="90"] { width: 90%; }

.bar-label {
  display: flex;
  justify-content: space-between;
  font-size: .72rem;
  color: var(--ink-3);
  margin-bottom: .35rem;
}

/* ================================================================= blocks */

h2 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.32rem;
  letter-spacing: -.01em;
  margin: 0 0 .25rem;
}

h3 {
  font-size: .98rem;
  font-weight: 600;
  margin: 0 0 .3rem;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.1rem;
}

.section-head p { margin: 0; font-size: .9rem; color: var(--ink-3); }

.seeall {
  font-size: .85rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.seeall:hover { text-decoration: underline; }

/* ================================================================== cards */

.grid {
  display: grid;
  gap: .9rem;
  grid-template-columns: repeat(auto-fill, minmax(15.5rem, 1fr));
}

.card {
  display: flex;
  flex-direction: column;
  gap: .55rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.05rem 1.1rem;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: transform .12s ease, border-color .12s ease;
}

a.card:hover { transform: translateY(-1px); border-color: #d8d2c8; }

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
}

.chip {
  font-size: .66rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  padding: .2rem .5rem;
  border-radius: 99px;
  background: var(--sunk);
  color: var(--ink-3);
}

.chip.brand { background: var(--brand-wash); color: var(--brand-dark); }
.chip.warm  { background: var(--accent-wash); color: var(--accent); }
.chip.amber { background: var(--amber-wash); color: var(--amber); }

.card p { margin: 0; font-size: .875rem; color: var(--ink-3); }

.card-foot {
  margin-top: auto;
  padding-top: .35rem;
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .76rem;
  color: var(--muted);
}

.dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .55; }

/* ================================================================== lists */

.rows {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.row {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: .8rem 1.05rem;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid var(--line-soft);
}
.row:last-child { border-bottom: 0; }
a.row:hover { background: var(--sunk); }

.row-num {
  font-family: var(--mono);
  font-size: .72rem;
  color: var(--muted);
  width: 1.9rem;
  flex: 0 0 auto;
}

.row-body { flex: 1 1 auto; min-width: 0; }
.row-body b { display: block; font-size: .92rem; font-weight: 600; }
.row-body span { font-size: .8rem; color: var(--ink-3); }

.row-meta { font-size: .74rem; color: var(--muted); white-space: nowrap; flex: 0 0 auto; }

/* ================================================================== prose */

.prose p { color: var(--ink-2); margin: 0 0 1rem; }
.prose h2 { margin-top: 2.1rem; }
.prose h3 { margin-top: 1.5rem; font-size: 1.02rem; }
.prose ul, .prose ol { margin: 0 0 1.15rem; padding-left: 1.3rem; color: var(--ink-2); }
.prose li { margin-bottom: .4rem; }
.prose li::marker { color: var(--muted); }

.note {
  background: var(--brand-wash);
  border-left: 3px solid var(--brand);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: .85rem 1rem;
  margin: 0 0 1.5rem;
  font-size: .9rem;
  color: var(--ink-2);
}

.warn {
  background: var(--amber-wash);
  border-left: 3px solid var(--amber);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: .85rem 1rem;
  margin: 0 0 1.5rem;
  font-size: .9rem;
  color: var(--ink-2);
}

.formula {
  font-family: var(--mono);
  font-size: .95rem;
  background: var(--sunk);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .85rem 1rem;
  margin: 0 0 1.2rem;
  overflow-x: auto;
  color: var(--ink);
}

.worked {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.15rem;
  margin: 0 0 1.3rem;
}
.worked h3 { margin-top: 0; }
.worked ol { margin-bottom: 0; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
  margin: 0 0 1.4rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

th {
  text-align: left;
  font-size: .7rem;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--ink-3);
  background: var(--sunk);
  padding: .6rem .8rem;
  border-bottom: 1px solid var(--line);
}

td { padding: .6rem .8rem; border-bottom: 1px solid var(--line-soft); color: var(--ink-2); }
tr:last-child td { border-bottom: 0; }
td b { color: var(--ink); }

dl.terms { margin: 0; }
dl.terms > div {
  padding: .85rem 0;
  border-bottom: 1px solid var(--line-soft);
}
dl.terms dt { font-weight: 600; font-size: .95rem; margin-bottom: .2rem; }
dl.terms dd { margin: 0; font-size: .9rem; color: var(--ink-3); }

/* =================================================================== form */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.2rem 1.35rem;
}

.panel h2 { font-size: 1.15rem; }
.panel .hint { margin: 0 0 1.15rem; font-size: .875rem; color: var(--ink-3); }

label {
  display: block;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: .35rem;
}

input[type="text"], textarea {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .62rem .75rem;
  margin-bottom: 1rem;
}

textarea { resize: vertical; min-height: 5.5rem; }

input[type="text"]:focus, textarea:focus {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
  border-color: var(--brand);
}

button[type="submit"] {
  font: inherit;
  font-weight: 600;
  font-size: .93rem;
  color: #fff;
  background: var(--brand);
  border: 0;
  border-radius: 10px;
  padding: .66rem 1.4rem;
  cursor: pointer;
  min-height: 44px;
}
button[type="submit"]:hover { background: var(--brand-dark); }
button[type="submit"]:disabled { opacity: .55; cursor: default; }

.linkish {
  font: inherit;
  font-size: .88rem;
  font-weight: 600;
  color: var(--brand-dark);
  background: none;
  border: 0;
  padding: .4rem 0;
  cursor: pointer;
  text-decoration: underline;
}

.is-off { display: none; }

/* ================================================================= footer */

footer {
  border-top: 1px solid var(--line);
  margin-top: 3rem;
  background: var(--surface);
}

.foot-inner {
  max-width: 68rem;
  margin: 0 auto;
  padding: 1.6rem 1.15rem 2.2rem;
  padding-bottom: max(2.2rem, env(safe-area-inset-bottom));
  display: flex;
  flex-wrap: wrap;
  gap: 1.2rem 2.4rem;
  align-items: flex-start;
}

.foot-col { min-width: 9rem; }
.foot-col h4 {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 .55rem;
}
.foot-col a {
  display: block;
  font-size: .86rem;
  color: var(--ink-2);
  text-decoration: none;
  padding: .16rem 0;
}
.foot-col a:hover { color: var(--brand-dark); text-decoration: underline; }

.fine {
  width: 100%;
  border-top: 1px solid var(--line-soft);
  padding-top: 1rem;
  margin: 0;
  font-size: .78rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1rem;
  align-items: center;
}

.badge {
  font-family: var(--mono);
  font-size: .68rem;
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: .1rem .5rem;
  color: var(--ink-3);
}

/* =================================================================== dark */

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1816;
    --surface: #221f1c;
    --sunk: #2a2622;
    --line: #35302b;
    --line-soft: #2e2a26;
    --ink: #f1ece6;
    --ink-2: #d6cfc6;
    --ink-3: #a79f95;
    --muted: #8b8378;
    --brand: #57b39a;
    --brand-dark: #74c6ae;
    --brand-wash: #1e3630;
    --accent: #d0765a;
    --accent-wash: #3a2620;
    --amber: #d0a44a;
    --amber-wash: #362c17;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
  .topbar { background: rgba(26, 24, 22, .92); }
  button[type="submit"] { color: #14201d; }
}
