:root {
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --space-1: .25rem; --space-2: .5rem; --space-3: .75rem; --space-4: 1rem; --space-5: 1.25rem;
  --space-6: 1.5rem; --space-8: 2rem; --space-10: 2.5rem; --space-12: 3rem; --space-16: 4rem;

  --bg: #f4f1ea;
  --surface: #fbfaf6;
  --surface-2: #efebe2;
  --border: #d9d3c6;
  --divider: #e5e0d5;
  --ink: #1d2024;
  --ink-2: #474b51;
  --ink-3: #6a6d70;
  --accent: #0d6468;
  --accent-ink: #0a4b4e;
  --accent-soft: #d7e7e4;
  --warn: #8a3b12;
  --warn-soft: #f4e2d6;
  --c0: #f1ede4; --c1: #e3e7df; --c2: #c6dcd6; --c3: #93c2bb; --c4: #4c9893; --c5: #0d6468;
  --radius: .5rem;
  --font-display: 'Newsreader', 'Iowan Old Style', Georgia, serif;
  --font-body: 'Public Sans', 'Segoe UI', system-ui, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: var(--text-base); line-height: 1.55; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; line-height: 1.15; margin: 0; text-wrap: balance; }
p { margin: 0; }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: #fff; padding: var(--space-2) var(--space-4); z-index: 10; }
.skip:focus { left: var(--space-4); }
.wrap { max-width: 1320px; margin: 0 auto; padding-inline: clamp(var(--space-4), 3vw, var(--space-10)); }

/* Masthead */
.masthead { border-bottom: 1px solid var(--border); background: var(--surface); }
.masthead-inner { display: flex; gap: var(--space-4); align-items: flex-start; padding-block: var(--space-6); }
.mark { width: 36px; height: 36px; color: var(--accent); flex: none; margin-top: 4px; }
.masthead h1 { font-size: var(--text-xl); letter-spacing: -0.01em; }
.lede { color: var(--ink-2); margin-top: var(--space-2); max-width: 70ch; font-size: var(--text-sm); }

/* Layout */
.layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: var(--space-8); padding-block: var(--space-8) var(--space-16); align-items: start; }
.controls { position: sticky; top: var(--space-4); max-height: calc(100vh - 2rem); overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-5); scrollbar-width: thin; }
.group { border: 0; padding: 0; margin: 0 0 var(--space-5); }
.group legend { font-weight: 700; font-size: var(--text-sm); display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-2); padding: 0; }
.num { display: inline-grid; place-items: center; width: 1.4rem; height: 1.4rem; border-radius: 50%; background: var(--ink); color: #fff; font-size: .75rem; font-weight: 700; }
.opts { display: grid; gap: var(--space-1); }
.opt { position: relative; display: block; }
.opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.opt span { display: block; padding: var(--space-2) var(--space-3); border: 1px solid var(--border); border-radius: 6px; background: var(--surface); cursor: pointer; transition: border-color .15s, background .15s; }
.opt b { display: block; font-size: var(--text-sm); font-weight: 600; }
.opt small { display: block; font-size: var(--text-xs); color: var(--ink-3); line-height: 1.35; }
.opt:hover span { border-color: var(--ink-3); }
.opt input:checked + span { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.opt input:checked + span small { color: var(--accent-ink); }
.opt input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.opts.row { grid-template-columns: repeat(3, 1fr); }
.opts.grid2 { grid-template-columns: 1fr 1fr; }
.opts.row .opt span { text-align: center; padding-inline: var(--space-1); }
.opts.row .opt small { display: none; }
.subnote { font-size: var(--text-xs); color: var(--ink-3); margin-top: var(--space-2); }
.field { display: grid; grid-template-columns: 1fr 9.5rem; align-items: center; gap: var(--space-2); margin-bottom: var(--space-2); font-size: var(--text-sm); }
select { width: 100%; padding: var(--space-2) var(--space-3); border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.weights { border-top: 1px solid var(--divider); padding-top: var(--space-4); }
.weights summary { cursor: pointer; font-weight: 600; font-size: var(--text-sm); color: var(--accent-ink); }
.hint { font-size: var(--text-xs); color: var(--ink-3); margin-top: var(--space-1); }
.wrow { display: grid; grid-template-columns: 5.5rem 1fr 2.6rem; gap: var(--space-2); align-items: center; margin-top: var(--space-3); font-size: var(--text-sm); }
.wrow input { accent-color: var(--accent); width: 100%; }
.wrow output { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.link-btn { background: none; border: 0; padding: 0; margin-top: var(--space-3); color: var(--accent-ink); text-decoration: underline; cursor: pointer; font-size: var(--text-sm); }

/* Recommendation */
.results { min-width: 0; }
.rec { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: clamp(var(--space-5), 3vw, var(--space-8)); display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: var(--space-8); }
.eyebrow { font-size: var(--text-xs); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-ink); }
.rec h2 { font-size: var(--text-xl); margin-top: var(--space-2); }
.tagline { font-family: var(--font-display); font-size: var(--text-lg); color: var(--ink-2); margin-top: var(--space-2); line-height: 1.3; }
.rec .summary { margin-top: var(--space-4); color: var(--ink); max-width: 65ch; }
.rec .why { margin-top: var(--space-3); color: var(--ink-2); font-size: var(--text-sm); max-width: 65ch; }
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-4); }
.chip { font-size: var(--text-xs); font-weight: 600; padding: 2px var(--space-3); border-radius: 999px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--border); }
.chip.fit-strong { background: var(--accent); color: #fff; border-color: var(--accent); }
.chip.fit-good { background: var(--accent-soft); color: var(--accent-ink); border-color: #a9cbc6; }
.chip.fit-work { background: #f3ead3; color: #6b4a07; border-color: #e0cf9f; }
.chip.fit-poor { background: var(--warn-soft); color: var(--warn); border-color: #e6c0a8; }
.example { margin-top: var(--space-5); padding: var(--space-4); background: var(--surface-2); border-radius: 6px; font-size: var(--text-sm); }
.example b { display: block; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin-bottom: var(--space-1); }
.example + .example { margin-top: var(--space-2); }
.pair { margin-top: var(--space-5); font-size: var(--text-sm); border-left: 3px solid var(--accent); padding-left: var(--space-3); }
.pair button { background: none; border: 0; padding: 0; color: var(--accent-ink); font-weight: 700; text-decoration: underline; cursor: pointer; }
.actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-5); }
.btn { display: inline-flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-4); border-radius: 6px; border: 1px solid var(--accent); background: var(--accent); color: #fff; font-weight: 600; font-size: var(--text-sm); cursor: pointer; }
.btn:hover { background: var(--accent-ink); }
.btn.ghost { background: transparent; color: var(--accent-ink); }
.btn.ghost:hover { background: var(--accent-soft); }

.scorebox { display: flex; flex-direction: column; gap: var(--space-4); }
.ring { position: relative; width: 148px; height: 148px; margin: 0 auto; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .val { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring .val strong { font-family: var(--font-display); font-size: 2.75rem; line-height: 1; font-variant-numeric: tabular-nums; }
.ring .val span { font-size: var(--text-xs); color: var(--ink-3); }
.breakdown { display: grid; gap: var(--space-3); }
.brow { font-size: var(--text-xs); }
.brow .top { display: flex; justify-content: space-between; gap: var(--space-2); }
.brow .top span:first-child { color: var(--ink-2); }
.brow .top b { font-variant-numeric: tabular-nums; }
.bar { height: 8px; background: var(--surface-2); border-radius: 4px; margin-top: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width .35s ease; }
.bar i.low { background: #c0763f; }

/* Tabs */
.tabs { display: flex; gap: var(--space-1); margin-top: var(--space-8); border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs button { background: none; border: 0; border-bottom: 3px solid transparent; padding: var(--space-3) var(--space-4); font-weight: 600; font-size: var(--text-sm); color: var(--ink-3); cursor: pointer; white-space: nowrap; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.tabs button:hover { color: var(--ink); }
.panel { background: var(--surface); border: 1px solid var(--border); border-top: 0; border-radius: 0 0 var(--radius) var(--radius); padding: clamp(var(--space-5), 3vw, var(--space-8)); }
.panel h3 { font-size: var(--text-lg); }
.panel h4 { font-family: var(--font-body); font-size: var(--text-sm); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin: var(--space-6) 0 var(--space-3); }
.panel-intro { color: var(--ink-2); font-size: var(--text-sm); margin-top: var(--space-2); max-width: 70ch; }
.steps { list-style: none; padding: 0; margin: var(--space-5) 0 0; counter-reset: s; display: grid; gap: var(--space-3); }
.steps li { counter-increment: s; display: grid; grid-template-columns: 2.25rem 1fr; gap: var(--space-3); align-items: start; padding: var(--space-3) 0; border-bottom: 1px solid var(--divider); }
.steps li:last-child { border-bottom: 0; }
.steps li::before { content: counter(s); font-family: var(--font-display); font-size: 1.5rem; font-weight: 600; color: var(--accent); line-height: 1.1; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-6); }
.plain { margin: 0; padding-left: 1.1rem; display: grid; gap: var(--space-2); font-size: var(--text-sm); }
.basis { margin-top: var(--space-6); font-size: var(--text-xs); color: var(--ink-3); border-top: 1px solid var(--divider); padding-top: var(--space-3); }

/* Pacing */
.timeline { display: flex; height: 56px; border-radius: 6px; overflow: hidden; margin-top: var(--space-4); border: 1px solid var(--border); }
.timeline div { display: flex; flex-direction: column; justify-content: center; padding: 0 var(--space-2); font-size: var(--text-xs); line-height: 1.2; color: #fff; min-width: 0; overflow: hidden; border-right: 2px solid var(--surface); }
.timeline div:last-child { border-right: 0; }
.timeline div b { font-variant-numeric: tabular-nums; }
.timeline div span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.px { overflow-x: auto; }
.wk { display: block; font-weight: 400; color: var(--ink-3); font-size: var(--text-xs); }
.ptable { width: 100%; border-collapse: collapse; margin-top: var(--space-4); font-size: var(--text-sm); }
.ptable th, .ptable td { text-align: left; padding: var(--space-3) var(--space-3); border-bottom: 1px solid var(--divider); vertical-align: top; }
.ptable th { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 700; }
.ptable td.n { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: var(--space-2); vertical-align: middle; }
.flag { display: inline-block; margin-top: var(--space-1); font-size: var(--text-xs); color: var(--warn); background: var(--warn-soft); padding: 1px var(--space-2); border-radius: 4px; }
.callout { margin-top: var(--space-4); padding: var(--space-3) var(--space-4); background: var(--accent-soft); color: var(--accent-ink); border-radius: 6px; font-size: var(--text-sm); }
.callout.warn { background: var(--warn-soft); color: var(--warn); }

/* Rubric */
.rubric-top { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--space-4); flex-wrap: wrap; }
.toggle { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); cursor: pointer; }
.toggle input { accent-color: var(--accent); width: 1.1rem; height: 1.1rem; }
.rubric-scroll { overflow-x: auto; margin-top: var(--space-4); }
.rubric { width: 100%; min-width: 760px; border-collapse: collapse; font-size: var(--text-sm); table-layout: fixed; }
.rubric th, .rubric td { border: 1px solid var(--border); padding: var(--space-3); vertical-align: top; text-align: left; }
.rubric thead th { background: var(--ink); color: #fff; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .05em; }
.rubric thead th small { display: block; text-transform: none; letter-spacing: 0; font-weight: 400; opacity: .85; }
.rubric tbody th { background: var(--surface-2); width: 17%; }
.rubric tbody th small { display: block; font-weight: 400; color: var(--ink-3); margin-top: var(--space-1); font-size: var(--text-xs); }
.rubric td:nth-child(2) { background: #eaf2f0; }
.rubric .outcome-row th { box-shadow: inset 3px 0 0 var(--accent); }
.ican { list-style: none; padding: 0; margin: var(--space-4) 0 0; display: grid; gap: var(--space-3); }
.ican li { display: grid; grid-template-columns: 1fr auto; gap: var(--space-4); align-items: center; padding: var(--space-4); border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.ican li b { display: block; font-size: var(--text-xs); color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; }
.ican li p { font-size: var(--text-base); margin-top: 2px; }
.faces { display: flex; gap: var(--space-2); }
.faces span { width: 2.25rem; height: 2.25rem; border-radius: 50%; border: 2px solid var(--border); display: grid; place-items: center; font-weight: 700; font-size: var(--text-sm); color: var(--ink-2); }
.scale { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-2); margin-top: var(--space-4); font-size: var(--text-xs); }
.scale div { padding: var(--space-2) var(--space-3); background: var(--surface-2); border-radius: 4px; }
.scale b { display: block; font-size: var(--text-sm); }

/* Matrix */
.matrix-wrap { margin-top: var(--space-10); }
.matrix-head { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-4); }
.matrix-head h2 { font-size: var(--text-lg); }
.legend { display: flex; align-items: center; gap: 3px; font-size: var(--text-xs); color: var(--ink-3); }
.legend i { width: 18px; height: 12px; border-radius: 2px; display: inline-block; }
.legend span { margin: 0 var(--space-1); }
.c0 { background: var(--c0); } .c1 { background: var(--c1); } .c2 { background: var(--c2); } .c3 { background: var(--c3); } .c4 { background: var(--c4); } .c5 { background: var(--c5); }
.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.matrix { width: 100%; border-collapse: collapse; font-size: var(--text-sm); min-width: 720px; }
.matrix th, .matrix td { padding: var(--space-2) var(--space-3); text-align: left; border-bottom: 1px solid var(--divider); }
.matrix thead th { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); background: var(--surface-2); font-weight: 700; position: sticky; top: 0; }
.matrix thead th small { display: block; text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--ink-2); }
.matrix tbody tr { cursor: pointer; transition: background .12s; }
.matrix tbody tr:hover { background: #f3f0e8; }
.matrix tbody tr.sel { background: var(--accent-soft); }
.matrix tbody tr.sel td:first-child { box-shadow: inset 4px 0 0 var(--accent); }
.matrix td.rank { width: 2.5rem; color: var(--ink-3); font-variant-numeric: tabular-nums; text-align: center; }
.matrix td.name b { display: block; font-weight: 600; }
.matrix td.name small { color: var(--ink-3); font-size: var(--text-xs); }
.matrix td.cell { width: 4.75rem; text-align: center; padding: var(--space-1); }
.matrix td.cell span { display: grid; place-items: center; height: 2rem; border-radius: 4px; font-weight: 700; font-variant-numeric: tabular-nums; }
.matrix td.cell .c4 span, .matrix td.cell span.c4, .matrix td.cell span.c5 { color: #fff; }
.matrix td.cell span.c0, .matrix td.cell span.c1, .matrix td.cell span.c2, .matrix td.cell span.c3 { color: var(--ink); }
.matrix td.total { width: 11rem; }
.tot { display: flex; align-items: center; gap: var(--space-2); }
.tot b { width: 2rem; text-align: right; font-variant-numeric: tabular-nums; }
.tot .bar { flex: 1; margin-top: 0; }
.foot { margin-top: var(--space-8); font-size: var(--text-xs); color: var(--ink-3); max-width: 80ch; }

.press { margin-top: var(--space-4); font-size: var(--text-sm); color: var(--ink-2); font-weight: 600; }
.press a { color: var(--accent-ink); }
.toast { position: fixed; bottom: var(--space-6); left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: var(--space-3) var(--space-5); border-radius: 6px; font-size: var(--text-sm); z-index: 20; }

@media (max-width: 1080px) {
  .rec { grid-template-columns: 1fr; }
  .scorebox { flex-direction: row; align-items: center; gap: var(--space-6); }
  .scorebox .breakdown { flex: 1; }
  .ring { margin: 0; flex: none; }
}
@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; }
  .controls { position: static; max-height: none; }
  .two { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .scorebox { flex-direction: column; align-items: stretch; }
  .ring { margin: 0 auto; width: 128px; height: 128px; }
  .field { grid-template-columns: 1fr 8.5rem; }
  .ican li { grid-template-columns: 1fr; }
  .scale { grid-template-columns: 1fr 1fr; }
  .timeline { height: auto; flex-direction: column; }
  .ptable th, .ptable td { padding: var(--space-2); }
  .ptable.sess th:nth-child(3), .ptable.sess td:nth-child(3) { display: none; }
  .matrix { min-width: 0; font-size: var(--text-xs); }
  .matrix th, .matrix td { padding: var(--space-2) var(--space-1); }
  .matrix td.name { padding-left: var(--space-3); }
  .matrix .rank, .matrix th:first-child, .matrix thead th small, .tot .bar { display: none; }
  .matrix td.cell { width: 2.6rem; }
  .matrix td.total { width: 2.6rem; }
  .matrix thead th { font-size: .6875rem; letter-spacing: 0; text-align: center; }
  .matrix thead th:nth-child(2) { text-align: left; padding-left: var(--space-3); }
  .tabs { flex-wrap: wrap; }
  .tabs button { flex: 1 1 45%; padding-inline: var(--space-2); }
  .timeline div { flex: none !important; padding: var(--space-2); border-right: 0; border-bottom: 2px solid var(--surface); flex-direction: row; justify-content: space-between; gap: var(--space-2); }
  .timeline div span { white-space: normal; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print {
  .controls, .tabs, .actions, .matrix-wrap, .masthead .mark, .skip { display: none !important; }
  .layout { display: block; }
  body { background: #fff; }
}
