/* Opportunity: Law — redesign stylesheet.
   Ledger typography (Source Serif 4 display) × Shortlist guided structure,
   with a dense Docket mode for power-user surfaces. */

:root {
  --paper: #fbf9f4;
  --surface: #fffdf8;
  --ink: #1c1917;
  --soft: #635c4f;   /* WCAG AA on cream backgrounds (was #7d7567, 4.3:1) */
  --faint: #6b6456;  /* WCAG AA (was #a39a89, 2.7:1) */
  --line: #e8e2d5;
  --line2: #d3cab7;

  --accent: #8a6515;       /* AA as text + as button bg w/ light text (was #a3791a) */
  --accent-deep: #7d5c12;
  --accent-soft: #f3ead0;
  --amber: #8a6515;
  --amber-soft: #f3ead0;
  --amber-border: #e5d6a9;
  --accent-contrast: #f5f1e6;

  --safety: #3d6b50;  --safety-dot: #4e8a66;  --safety-bg: #e6efe7;
  --target: #14532d;  --target-dot: #1f6b3d;  --target-bg: #dbe9dc;
  --reach: #92400e;   --reach-dot: #b45309;   --reach-bg: #f6e8d4;
  --hard: #8c3120;    --hard-dot: #9a3324;    --hard-bg: #f5e2dc;

  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --display: var(--serif);

  /* density scale — compact is the production default */
  --row-pad: 9px;
  --card-pad: 14px;
  --gap: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  font-size: 14.5px;
  line-height: 1.5;
}
a { color: var(--accent-deep); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.12; font-family: var(--display); font-weight: 700; letter-spacing: -0.015em; }
h1 { font-size: 38px; }
h2 { font-size: 24px; }
h3 { font-size: 19px; }
.mono { font-family: var(--mono); font-size: 12px; color: var(--soft); }
.muted { color: var(--soft); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- shell ---------- */
.shell { max-width: 1180px; margin: 0 auto; padding: 0 32px 90px; }

.masthead {
  display: flex; align-items: baseline; gap: 28px;
  padding: 22px 0 14px; margin-bottom: 0;
  border-bottom: 1px solid var(--line);
}
.brand {
  border: none; background: none; padding: 0; cursor: pointer;
  font-family: var(--serif); font-size: 21px; font-weight: 700; color: var(--ink);
  letter-spacing: -0.01em;
}
.colon { color: var(--amber); }
.brand .colon { color: var(--amber); }
.masthead .tagline { font-size: 12px; color: var(--faint); }
.masthead nav { margin-left: auto; display: flex; gap: 24px; align-items: baseline; }
.nav-link {
  border: none; background: none; padding: 0 0 3px; cursor: pointer;
  font: inherit; font-size: 13.5px; color: var(--soft);
  border-bottom: 2px solid transparent;
}
.nav-link:hover { color: var(--ink); }
.nav-link.active { color: var(--ink); font-weight: 600; border-bottom-color: var(--amber); }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--line2); background: var(--surface); color: var(--ink);
  font: inherit; font-size: 14px; font-weight: 500;
  padding: 8px 16px; border-radius: 8px; cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.06s ease;
}
.btn:hover { background: #f6f2e9; }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); font-weight: 600;
}
.btn.primary:hover { background: var(--accent-deep); color: #f5f1e6; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--soft); }
.btn.ghost:hover { background: #f1ecdf; color: var(--ink); }
.btn.sm { padding: 5px 11px; font-size: 13px; }
.btn.xs { padding: 2px 8px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: 0.45; cursor: default; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label {
  font-size: 11px; font-weight: 600; color: var(--soft);
  text-transform: uppercase; letter-spacing: 0.08em;
}
input[type="text"], input[type="number"], select, textarea {
  font: inherit; font-size: 15px; color: var(--ink);
  padding: 9px 12px; border: 1px solid var(--line2); border-radius: 8px;
  background: var(--surface);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent-soft); border-color: var(--accent);
}
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 20px; margin: 0; background: transparent; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px;
  background: linear-gradient(to right, var(--accent) var(--p, 50%), var(--line2) var(--p, 50%));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%; margin-top: -6px;
  background: var(--accent); border: 2.5px solid var(--surface);
  box-shadow: 0 0 0 1.5px var(--accent);
}
input[type="range"]:active::-webkit-slider-thumb,
input[type="range"]:focus::-webkit-slider-thumb {
  background: var(--accent); box-shadow: 0 0 0 1.5px var(--accent);
}
input[type="range"]:focus { outline: none; }
input[type="range"]::-moz-range-track {
  height: 4px; border-radius: 2px; background: var(--line2);
}
input[type="range"]::-moz-range-progress {
  height: 4px; border-radius: 2px; background: var(--accent);
}
input[type="range"]::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); border: 2.5px solid var(--surface);
  box-shadow: 0 0 0 1.5px var(--accent);
}
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.checkbox-row input { width: 15px; height: 15px; accent-color: var(--accent); }

.chip-group { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  border: 1px solid var(--line2); background: var(--surface); color: var(--ink);
  border-radius: 999px; padding: 5px 14px; font-size: 13px; font-weight: 500; cursor: pointer;
}
.chip:hover { border-color: var(--accent); }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }

.seg { display: inline-flex; background: #efeadd; border-radius: 9px; padding: 3px; gap: 2px; }
.seg button {
  border: none; background: transparent; font: inherit; font-size: 13px; font-weight: 600;
  color: var(--soft); padding: 5px 14px; border-radius: 7px; cursor: pointer; white-space: nowrap;
}
.seg button.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(28,25,23,0.12); }

/* ---------- tier badges ---------- */
.tier-tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  white-space: nowrap;
}
.tier-tag .dot { width: 8px; height: 8px; border-radius: 99px; flex: none; }
.tier-pill {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 6px; padding: 3px 9px; font-size: 11px; font-weight: 700;
  letter-spacing: 0.05em; text-transform: uppercase; white-space: nowrap;
}
.t-safety { color: var(--safety); } .t-safety.tier-pill { background: var(--safety-bg); }
.t-safety .dot { background: var(--safety-dot); }
.t-target { color: var(--target); } .t-target.tier-pill { background: var(--target-bg); }
.t-target .dot { background: var(--target-dot); }
.t-reach { color: var(--reach); } .t-reach.tier-pill { background: var(--reach-bg); }
.t-reach .dot { background: var(--reach-dot); }
.t-hard { color: var(--hard); } .t-hard.tier-pill { background: var(--hard-bg); }
.t-hard .dot { background: var(--hard-dot); }

/* ---------- profile screen ---------- */
.intake-head { padding: 44px 0 8px; max-width: 660px; }
.intake-head p { margin: 10px 0 0; font-size: 15.5px; color: var(--soft); line-height: 1.55; }
.intake-grid {
  display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 1px 3px rgba(28,25,23,0.05); margin-top: 26px; overflow: hidden;
}
.intake-grid > section { padding: calc(var(--card-pad) + 6px); }
.intake-grid > section + section { border-left: 1px solid var(--line); background: #faf7ee; }
.intake-grid h2 { font-size: 19px; margin-bottom: 4px; }
.intake-grid .sec-sub { font-size: 13px; color: var(--soft); margin: 0 0 18px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.weights { display: flex; flex-direction: column; gap: 20px; }
.slider-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 13.5px; font-weight: 600; }
.slider-head .val { font-family: var(--mono); font-size: 12px; color: var(--accent); }
.slider-hint { font-size: 12px; color: var(--faint); margin-top: 2px; }
.weighted-row { display: flex; align-items: center; gap: 8px; }
.weighted-row select { flex: 1; }
.weighted-row input[type="number"] { width: 68px; }
.intake-actions { margin-top: 26px; display: flex; align-items: center; gap: 14px; }
.intake-actions .btn.primary { padding: 11px 26px; font-size: 15px; }
.fin-toggle {
  border: none; background: none; padding: 0; cursor: pointer; text-align: left;
  font: inherit; font-size: 14px; font-weight: 600; color: var(--ink);
  display: flex; align-items: baseline; gap: 8px;
}
.fin-toggle:hover { color: var(--accent-deep); }
.optional-badge {
  font-size: 10px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--soft); background: #efeadd; border-radius: 999px; padding: 3px 9px;
}
.fin-body { margin-top: 14px; padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }

/* ---------- scenarios panel ---------- */
.sc-panel {
  margin-top: 20px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); overflow: hidden;
}
.sc-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; gap: 10px;
}
.sc-label {
  font-size: 11px; font-weight: 600; color: var(--soft);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.sc-toggle {
  font-size: 12px; font-weight: 600; color: var(--soft);
  display: flex; align-items: center; gap: 5px;
  text-transform: uppercase; letter-spacing: 0.07em;
}
.sc-toggle-arrow { font-size: 10px; }
.sc-count {
  background: #efeadd; color: var(--soft); border-radius: 999px;
  font-size: 10px; font-weight: 700; padding: 1px 7px;
}
.sc-save-area { display: flex; align-items: center; gap: 7px; }
.sc-name-row { display: flex; align-items: center; gap: 6px; }
.sc-name-input {
  font: inherit; font-size: 13px; padding: 4px 9px;
  border: 1px solid var(--accent); border-radius: 6px;
  background: var(--surface); color: var(--ink);
  width: 180px;
}
.sc-name-input:focus { outline: 2px solid var(--accent-soft); }
.sc-save-btn { font-size: 12px; color: var(--soft); }
.sc-list {
  list-style: none; margin: 0; padding: 0 12px 8px;
  border-top: 1px solid var(--line);
}
.sc-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 0; border-bottom: 1px solid var(--line);
}
.sc-item:last-child { border-bottom: none; }
.sc-load-btn {
  border: none; background: none; padding: 0 4px; cursor: pointer;
  font: inherit; font-size: 13px; font-weight: 500; color: var(--ink);
  text-align: left; flex: 1;
}
.sc-load-btn:hover { color: var(--accent-deep); text-decoration: underline; }
.sc-del { font-size: 11px; color: var(--faint); flex: none; }
.sc-del:hover { color: var(--hard); }

/* ---------- results: shared header ---------- */
.results-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 28px; padding: 34px 0 0; }
.results-head p { margin: 8px 0 0; font-size: 14.5px; color: var(--soft); max-width: 540px; }
.profile-card {
  flex: none; display: flex; align-items: stretch;
  border: 1px solid var(--line2); background: var(--surface); border-radius: 10px; overflow: hidden;
}
.profile-card .pc-cell { padding: 10px 18px; border-right: 1px solid var(--line); }
.profile-card .pc-cell .k { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--soft); }
.profile-card .pc-cell .v { font-family: var(--display); font-size: 17px; font-weight: 600; }
.profile-card .pc-edit {
  border: none; background: transparent; font: inherit; font-size: 13px; font-weight: 600;
  color: var(--accent-deep); padding: 0 18px; cursor: pointer;
}
.profile-card .pc-edit:hover { background: var(--accent-soft); }

.results-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 22px 0 0; padding-bottom: 16px; border-bottom: 1px solid var(--line);
}
.results-toolbar .spacer { flex: 1; }

/* compact what-if spinner: value + vertical +/− */
.spin {
  display: inline-flex; align-items: stretch; height: 30px;
  background: var(--surface); border: 1px solid var(--line2); border-radius: 7px; overflow: hidden;
}
.spin .spin-val {
  display: flex; align-items: center; padding: 0 10px;
  font-family: var(--mono); font-size: 13px; font-weight: 700; color: var(--accent-deep);
}
.spin .spin-btns { display: flex; flex-direction: column; border-left: 1px solid var(--line); }
.spin .spin-btns button {
  flex: 1; border: none; background: none; cursor: pointer; padding: 0 7px;
  font-size: 12px; font-weight: 700; line-height: 1; color: var(--soft);
  display: flex; align-items: center; justify-content: center;
}
.spin .spin-btns button:first-child { border-bottom: 1px solid var(--line); }
.spin .spin-btns button:hover { background: var(--accent-soft); color: var(--accent-deep); }
.spin .spin-btns button:disabled { opacity: 0.35; cursor: default; background: none; }
.spin .spin-x {
  border: none; border-left: 1px solid var(--line); background: none; cursor: pointer;
  padding: 0 8px; font-size: 13px; line-height: 1; color: var(--faint);
  display: flex; align-items: center;
}
.spin .spin-x:hover { background: #f1ecdf; color: var(--ink); }

/* match score (detail head) — treatment C */
.ms-block { width: 210px; }
.ms-top { display: flex; align-items: baseline; justify-content: space-between; }
.ms-num { font-family: var(--display); font-size: 32px; font-weight: 700; line-height: 1; color: var(--ink); }
.ms-denom { font-size: 14px; color: var(--faint); font-weight: 600; }
.ms-scale { position: relative; height: 6px; background: var(--line); border-radius: 3px; margin-top: 9px; overflow: hidden; }
.ms-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; }
.ms-labels { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 9.5px; color: var(--faint); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.06em; }

/* ---------- results: guided (shortlist) view ---------- */
.tier-section { margin-top: 34px; }
.tier-section .ts-head { display: flex; align-items: center; gap: 11px; }
.tier-section .ts-head h2 { font-size: 21px; }
.tier-section .ts-head .count { font-size: 13px; color: var(--soft); }
.tier-section .ts-sub { margin: 2px 0 14px 21px; font-size: 13.5px; color: var(--soft); }

/* ---- Apply plan controls + sections ---- */
.apply-controls {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; margin-bottom: 8px;
}
.apply-controls .ac-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.apply-controls .ac-label { font-size: 13px; font-weight: 600; color: var(--ink); }
.apply-controls .ts-sub { margin-left: 0; }

.apply-notes { margin: 12px 0 4px; display: flex; flex-direction: column; gap: 8px; }
.apply-note {
  margin: 0; padding: 10px 13px; font-size: 13px; line-height: 1.45;
  background: var(--bg2, #f3f0ea); border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0; color: var(--ink);
}

.apply-timeline { margin: 8px 0 0 4px; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; }
.apply-timeline li { font-size: 13.5px; line-height: 1.5; color: var(--ink); padding-left: 4px; }
.apply-tips { margin: 10px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 9px; }
.apply-tips li { font-size: 13.5px; line-height: 1.5; color: var(--ink); }

.school-card {
  display: flex; align-items: center; gap: 22px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: var(--row-pad) var(--card-pad);
  box-shadow: 0 1px 2px rgba(28,25,23,0.04);
  cursor: pointer; transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.school-card:hover { border-color: var(--line2); box-shadow: 0 2px 8px rgba(28,25,23,0.08); }
.school-card + .school-card { margin-top: var(--gap); }
.school-card .sc-name { font-family: var(--display); font-size: 17.5px; font-weight: 700; letter-spacing: -0.01em; }
.school-card:hover .sc-name { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.school-card .sc-meta { font-size: 12px; color: var(--soft); }
.school-card .sc-why { font-size: 13.5px; color: var(--soft); margin-top: 3px; }
.school-card .sc-why .lead { font-weight: 600; }
.sc-stats { display: flex; gap: 26px; flex: none; }
.sc-stat { min-width: 78px; text-align: right; }
.sc-stat .v { font-size: 16.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.sc-stat .v.hero { color: var(--accent); font-weight: 700; }
.sc-stat .k { font-size: 10px; letter-spacing: 0.07em; text-transform: uppercase; color: var(--faint); margin-top: 1px; }
.sc-ring { position: relative; flex: none; }
.sc-ring .ring-num { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; font-size: 15px; }
.sc-add {
  flex: none; border-radius: 999px; border: 1.5px solid var(--line2);
  background: none; color: var(--soft); font: inherit; font-size: 12.5px; font-weight: 600;
  padding: 5px 13px; cursor: pointer; white-space: nowrap;
}
.sc-add:hover { border-color: var(--accent-deep); color: var(--accent-deep); }
.sc-add.added { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }

.collapsed-tier {
  margin-top: 26px; padding: 15px var(--card-pad);
  border: 1px dashed var(--line2); border-radius: 12px;
  display: flex; align-items: center; gap: 12px; color: var(--soft); font-size: 14px;
}
.collapsed-tier .show { margin-left: auto; color: var(--accent); font-weight: 700; cursor: pointer; white-space: nowrap; }
.show-more-row { margin-top: 12px; text-align: center; }

/* compare tray */
.compare-tray {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 18px; z-index: 60;
  display: flex; align-items: center; gap: 14px;
  background: var(--ink); color: #f0ece1; border-radius: 12px;
  padding: 10px 12px 10px 20px; box-shadow: 0 8px 28px rgba(28,25,23,0.35);
  font-size: 13.5px;
}
.compare-tray .names { font-weight: 600; max-width: 420px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.compare-tray .btn.primary { background: var(--amber); border-color: var(--amber); }
.compare-tray .clear { border: none; background: none; color: #b3aa97; cursor: pointer; font: inherit; font-size: 13px; }
.compare-tray .clear:hover { color: #fff; }

/* ---------- dense table (results table view + rankings) ---------- */
.dense-wrap { margin-top: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow-x: auto; }
.dense { width: 100%; border-collapse: collapse; }
.dense th {
  text-align: right; font-size: 10.5px; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--soft); padding: 9px 12px; background: #f3f0e6;
  border-bottom: 1px solid var(--line2); white-space: nowrap; cursor: pointer; user-select: none;
}
.dense th.l { text-align: left; }
.dense th:hover { color: var(--ink); }
.dense th .arrow { color: var(--amber); }
.dense td {
  padding: calc(var(--row-pad) - 8px) 12px; border-bottom: 1px solid var(--line);
  font-family: var(--mono); font-size: 12.5px; text-align: right;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.dense td.l { text-align: left; font-family: var(--sans); }
.dense tbody tr { cursor: pointer; }
.dense tbody tr:nth-child(even) { background: #fbf9f2; }
.dense tbody tr:hover { background: var(--accent-soft); }
.dense tbody tr.selected { background: var(--accent-soft); }
.dense .school-cell .nm { font-weight: 600; font-size: 13.5px; }
.dense .school-cell .lc { color: var(--soft); font-size: 12px; margin-left: 8px; }
.dense .delta-pos { color: var(--accent); font-weight: 700; }
.dense .delta-neg { color: var(--amber); font-weight: 700; }
.score-chip {
  display: inline-block; min-width: 38px; text-align: center; padding: 2px 8px;
  border-radius: 5px; font-weight: 700; font-family: var(--mono); font-size: 12.5px;
  background: var(--accent-soft); color: var(--accent);
}
.score-chip.top { background: var(--accent); color: #f5f1e6; }
.cellbar { display: inline-flex; align-items: center; gap: 8px; }
.cellbar .track { width: 50px; height: 5px; background: var(--line); border-radius: 3px; overflow: hidden; }
.cellbar .fill { height: 100%; border-radius: 3px; background: var(--accent); }
.cellbar .pv { min-width: 34px; text-align: right; }
.table-foot { display: flex; gap: 18px; padding: 10px 14px; font-family: var(--mono); font-size: 11px; color: var(--soft); }
.table-foot .right { margin-left: auto; }
.dense .cmp-box { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }

.raw-detail-row td { background: #f6f3e9 !important; cursor: default; }
.raw-detail { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 36px; padding: 8px 6px; font-family: var(--sans); }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 5px 18px; font-size: 13.5px; }
.kv .k { color: var(--soft); }
.kv .v { font-family: var(--mono); font-size: 13px; text-align: right; }

/* ---------- detail screen ---------- */
.crumb { margin: 22px 0 0; }
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; padding: 16px 0 22px; border-bottom: 1px solid var(--line); }
.detail-head h1 { font-size: 34px; }
.detail-head .sub { margin-top: 6px; font-size: 13.5px; color: var(--soft); }
.detail-head .head-right { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; flex: none; }

.detail-hero { display: grid; grid-template-columns: 330px 1fr; gap: 34px; align-items: center; padding: 26px 0; border-bottom: 1px solid var(--line); }
.stat-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.stat { text-align: center; padding: 12px 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.stat .stat-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--soft); }
.stat .stat-value { font-family: var(--display); font-size: 23px; font-weight: 700; margin-top: 2px; }
.stat .stat-sub { font-family: var(--mono); font-size: 10.5px; color: var(--faint); margin-top: 2px; }
.score-bars { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 18px; margin-top: 18px; }
.bar-wrap { display: flex; flex-direction: column; gap: 4px; }
.bar-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--soft); }
.bar-head .v { font-family: var(--mono); color: var(--ink); }
.bar-track { height: 6px; background: #efe9da; border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; background: var(--accent); }

.story-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-top: 26px; }
.story-col { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: var(--card-pad); display: flex; flex-direction: column; gap: 12px; }
.story-col h2 { font-size: 18px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.big-num { font-family: var(--display); font-size: 27px; font-weight: 700; }

/* detail: range lines, verdict, ledgers */
.range-line { display: flex; align-items: flex-start; gap: 12px; margin-top: 4px; }
.range-line .rl-label { width: 38px; flex: none; font-size: 11px; font-weight: 600; color: var(--soft); text-transform: uppercase; letter-spacing: 0.07em; padding-top: 12px; }
.rl-wrap { position: relative; flex: 1; height: 46px; }
.rl-track { position: absolute; left: 0; right: 0; top: 18px; height: 2px; background: var(--line2); }
.rl-tick { position: absolute; top: 14px; width: 1.5px; height: 10px; background: var(--line2); transform: translateX(-50%); }
.rl-tick-label { position: absolute; top: 28px; transform: translateX(-50%); font-family: var(--mono); font-size: 10.5px; color: var(--faint); }
.rl-you { position: absolute; top: 19px; transform: translate(-50%, -50%); width: 11px; height: 11px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); box-shadow: 0 0 0 1.5px var(--accent); }
.rl-you-val { position: absolute; bottom: 13px; left: 50%; transform: translateX(-50%); font-family: var(--mono); font-size: 10.5px; font-weight: 700; color: var(--accent-deep); white-space: nowrap; }
.verdict { display: flex; align-items: center; gap: 10px; font-size: 13.5px; font-weight: 600; }
.story-col .kv { font-size: 13px; }
.story-col .kv .goal { color: var(--accent-deep); font-weight: 700; }
.ledger { display: flex; flex-direction: column; gap: 5px; font-size: 13.5px; }
.ledger .lr { display: flex; justify-content: space-between; align-items: baseline; gap: 18px; }
.ledger .lr .amt { font-family: var(--mono); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.ledger .lr.subtotal { border-top: 1px solid var(--line2); padding-top: 6px; font-weight: 600; }
.ledger .lr.total { border-top: 2px solid var(--ink); padding-top: 7px; font-weight: 700; }
.ledger .lr.total .amt { font-weight: 700; }

.detail-section { margin-top: 30px; }
.detail-section > h2 { margin-bottom: 14px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tab {
  border: none; background: none; font: inherit; font-size: 14px; padding: 8px 15px;
  cursor: pointer; color: var(--soft); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab.active { color: var(--ink); font-weight: 600; border-bottom-color: var(--amber); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; }
.note {
  background: #f6f3e9; border: 1px solid var(--line); border-radius: 10px;
  padding: 13px 16px; font-size: 13.5px; color: var(--soft); line-height: 1.55;
}
.note strong { color: var(--ink); }
.schedule { width: 100%; border-collapse: collapse; }
.schedule th, .schedule td { text-align: right; padding: 6px 8px; font-family: var(--mono); font-size: 12px; border-bottom: 1px solid var(--line); }
.schedule th { color: var(--soft); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; }
.schedule th:first-child, .schedule td:first-child { text-align: left; }

.people-list { display: flex; flex-wrap: wrap; gap: 7px; }
.person {
  font-size: 13px; padding: 4px 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); color: var(--accent);
}

/* ---------- compare ---------- */
.compare-legend { display: flex; gap: 30px; align-items: center; flex-wrap: wrap; padding: 22px 0; border-bottom: 1px solid var(--line); }
.legend-list { flex: 1; min-width: 280px; display: flex; flex-direction: column; gap: 10px; }
.legend-row { display: flex; align-items: center; gap: 12px; }
.legend-row .swatch { width: 13px; height: 13px; border-radius: 4px; flex: none; }
.legend-row .nm { font-family: var(--display); font-size: 15.5px; font-weight: 700; }
.legend-row .meta { font-size: 12px; color: var(--soft); }
.legend-row .btn { margin-left: auto; }
.compare-table { width: 100%; border-collapse: collapse; }
.compare-table th, .compare-table td { padding: 9px 14px; border-bottom: 1px solid var(--line); text-align: right; }
.compare-table thead th { border-bottom: 1px solid var(--line2); white-space: nowrap; vertical-align: bottom; }
.compare-table thead .nm { font-family: var(--display); font-size: 15px; font-weight: 700; }
.compare-table .metric-col { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--soft); font-weight: 600; white-space: nowrap; }
.compare-table td { font-family: var(--mono); font-size: 13px; font-variant-numeric: tabular-nums; }
.compare-table td.best { background: var(--safety-bg); color: var(--safety); font-weight: 700; }

/* ---------- states, modal, footer ---------- */
.center-msg { text-align: center; padding: 60px 20px; color: var(--soft); }
.error-banner {
  margin-top: 18px; padding: 12px 16px; border-radius: 10px;
  background: var(--hard-bg); border: 1px solid #e3c2b8; color: var(--hard); font-size: 13.5px;
}
.spinner {
  width: 22px; height: 22px; margin: 0 auto 12px;
  border: 2.5px solid var(--line2); border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(28,25,23,0.5); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; padding: 60px 20px; overflow-y: auto;
}
.modal {
  background: var(--surface); border-radius: 14px; max-width: 620px; width: 100%;
  padding: 26px 28px; box-shadow: 0 16px 48px rgba(28,25,23,0.3);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.prose { font-size: 14px; line-height: 1.6; }
.prose ul { padding-left: 20px; }
.prose li { margin-bottom: 7px; }
.footer-note {
  margin-top: 44px; padding-top: 16px; border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.report-text {
  width: 100%; resize: vertical; font-family: var(--sans); font-size: 14px;
}
.linklike {
  border: none; background: none; padding: 0; cursor: pointer;
  font: inherit; color: var(--accent-deep);
}
.linklike:hover { text-decoration: underline; }

.infotip { position: relative; display: inline-flex; margin-left: 4px; vertical-align: middle; }
.infotip-btn {
  width: 16px; height: 16px; padding: 0; border-radius: 50%;
  border: 1px solid var(--line2); background: var(--surface); color: var(--soft);
  font-size: 10px; line-height: 1; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.infotip-btn:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.infotip-pop {
  position: absolute; top: 22px; left: 50%; transform: translateX(-50%); z-index: 30;
  width: 250px; padding: 10px 13px; background: var(--ink); color: #f0ece1;
  border-radius: 8px; font-size: 12px; line-height: 1.45; font-weight: 400;
  text-transform: none; letter-spacing: 0;
  box-shadow: 0 6px 18px rgba(28,25,23,0.3);
}

/* ---------- responsive ---------- */

/* Tablet / small laptop: collapse the multi-column layouts to single column. */
@media (max-width: 900px) {
  .shell { padding: 0 22px 72px; }
  .intake-grid, .detail-hero, .story-cols { grid-template-columns: 1fr; }
  /* When the intake panels stack, the divider moves from the side to the top. */
  .intake-grid > section + section { border-left: none; border-top: 1px solid var(--line); }
  .results-head { flex-direction: column; align-items: flex-start; }
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
  .score-bars { grid-template-columns: repeat(2, 1fr); }
  h1 { font-size: 32px; }
  .detail-head h1 { font-size: 30px; }
  .detail-hero { gap: 22px; }
}

/* Phone: the heavy restructuring pass. */
@media (max-width: 600px) {
  .shell { padding: 0 16px 64px; }

  body { font-size: 14px; }
  h1 { font-size: 26px; }
  h2 { font-size: 21px; }
  .intake-head { padding: 28px 0 8px; }
  .intake-head p { font-size: 14.5px; }

  /* 16px inputs stop iOS from auto-zooming on focus. */
  input[type="text"], input[type="number"], select, textarea { font-size: 16px; }

  /* Masthead wraps; the nav drops to its own full-width row. */
  .masthead { flex-wrap: wrap; gap: 6px 16px; padding: 16px 0 12px; }
  .masthead nav { margin-left: 0; width: 100%; gap: 20px; }
  .masthead .tagline { display: none; }

  /* Single-column form fields. */
  .intake-grid > section { padding: 16px; }
  .field-grid { grid-template-columns: 1fr; gap: 14px; }

  /* Profile recap scrolls sideways instead of overflowing the viewport. */
  .results-head { gap: 16px; }
  .profile-card { width: 100%; overflow-x: auto; }

  /* School cards: the name keeps row 1 next to the ring (the content div's
     inline flex:1 fills it); forcing .sc-stats to a full-width basis wraps the
     stats — and the compare button after them — onto their own rows below. */
  .school-card { flex-wrap: wrap; gap: 12px 16px; }
  .school-card .sc-stats { flex: 1 0 100%; gap: 22px; justify-content: flex-start; }
  .sc-stat { min-width: 0; text-align: left; }

  /* Detail screen: stats 2-up, bars single column, header stacks. */
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .score-bars { grid-template-columns: 1fr; }
  .ms-block { width: 100%; }
  .detail-head { flex-direction: column; }
  .detail-head .head-right { align-items: flex-start; }
  .detail-head h1 { font-size: 26px; }

  /* Tab strips scroll horizontally rather than wrapping awkwardly. */
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tabs::-webkit-scrollbar { display: none; }

  /* Compare tray spans the viewport and wraps its contents. */
  .compare-tray {
    left: 12px; right: 12px; transform: none; max-width: none;
    flex-wrap: wrap; gap: 10px; padding: 12px 14px;
  }
  .compare-tray .names { max-width: 100%; white-space: normal; }

  /* Larger tap targets for touch. */
  .btn { padding: 9px 16px; }
  .btn.sm { padding: 7px 12px; }
  .nav-link { padding-bottom: 4px; }
  .seg button { padding: 7px 14px; }

  /* Modals and dense detail use more of the small screen. */
  .modal-backdrop { padding: 24px 12px; }
  .modal { padding: 20px 18px; }
  .raw-detail { grid-template-columns: 1fr; }
  .footer-note { flex-direction: column; gap: 8px; }
}

/* Very small phones. */
@media (max-width: 380px) {
  h1 { font-size: 23px; }
  .school-card .sc-stats { gap: 12px; }
  .masthead nav { gap: 16px; }
}
