/* Probable Cause components and screens. Built only on tokens.css. */

*,
*::before,
*::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-1);
  font-family: var(--font-ui);
  font-size: var(--text-md);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
}

h1, h2, h3, h4 { margin: 0; line-height: var(--leading-tight); font-weight: var(--weight-semibold); letter-spacing: -0.01em; }
h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
p { margin: 0; }
a { color: var(--accent); }
button { font: inherit; color: inherit; }
.icon { flex: none; display: block; }
.icon.inline { display: inline-block; vertical-align: -0.15em; margin-left: 2px; }
[hidden] { display: none !important; }
.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; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--radius-sm); }

.eyebrow { font-size: var(--text-xs); font-weight: var(--weight-semibold); letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); }
.muted { color: var(--text-2); }
.subtle { color: var(--text-3); font-size: var(--text-sm); }

/* ---------- app shell ---------- */
.app { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: var(--space-3);
  height: 60px; padding: 0 var(--gutter);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: var(--space-2); text-decoration: none; color: var(--text-1); min-height: var(--tap); }
.brand-mark { width: 30px; height: 30px; }
.brand-name { font-weight: var(--weight-bold); font-size: var(--text-md); letter-spacing: -0.01em; }
.brand-sub { font-size: var(--text-xs); color: var(--text-3); display: block; line-height: 1; margin-top: 2px; }
.nav { display: flex; gap: var(--space-1); margin-left: var(--space-4); }
.nav a {
  display: inline-flex; align-items: center; gap: var(--space-2);
  min-height: 36px; padding: 0 var(--space-3); border-radius: var(--radius-pill);
  color: var(--text-2); text-decoration: none; font-size: var(--text-sm); font-weight: var(--weight-medium);
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.nav a:hover { color: var(--text-1); background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--text-1); background: var(--surface-3); }
.topbar-spacer { flex: 1; }
.tabbar { display: none; }

main { flex: 1; width: 100%; max-width: var(--content-max); margin: 0 auto; padding: var(--space-4) var(--gutter) var(--space-7); }
main.full { max-width: none; padding: 0; }

.offline-banner {
  display: flex; align-items: center; gap: var(--space-2); justify-content: center;
  padding: var(--space-2) var(--gutter); font-size: var(--text-sm);
  background: var(--flag-soft); color: var(--flag); border-bottom: 1px solid var(--border);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--tap); padding: 0 var(--space-4);
  border-radius: var(--radius-md); border: 1px solid transparent;
  font-size: var(--text-sm); font-weight: var(--weight-semibold); letter-spacing: 0.005em;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow-1); }
.btn-primary:hover:not([disabled]) { background: var(--accent-strong); }
.btn-secondary { background: var(--surface-2); color: var(--text-1); border-color: var(--border); }
.btn-secondary:hover:not([disabled]) { background: var(--surface-3); border-color: var(--border-strong); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not([disabled]) { background: var(--surface-2); color: var(--text-1); }
.btn-icon { width: var(--tap); flex: none; padding: 0; }
.btn-sm { min-height: 36px; padding: 0 var(--space-3); font-size: var(--text-xs); }
.btn-block { width: 100%; }

/* ---------- chips and badges ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 28px; padding: 0 10px; border-radius: var(--radius-pill); max-width: 100%;
  font-size: var(--text-xs); font-weight: var(--weight-medium);
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
  white-space: nowrap;
}
.chip-accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip-asked { background: var(--asked-soft); color: var(--asked); border-color: transparent; }
.chip-missed { background: var(--missed-soft); color: var(--missed); border-color: transparent; }
.chip-flag { background: var(--flag-soft); color: var(--flag); border-color: transparent; }
button.chip { cursor: pointer; min-height: 36px; padding: 0 var(--space-3); font-size: var(--text-sm); }
button.chip:hover { border-color: var(--border-strong); color: var(--text-1); }

/* ---------- cards ---------- */
.card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
}
.card-pad { padding: var(--space-4); grid-template-columns: minmax(0, 1fr); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); margin: var(--space-6) 0 var(--space-3); }
.section-head:first-child { margin-top: 0; }

/* ---------- skeletons ---------- */
.skeleton {
  border-radius: var(--radius-md);
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.skel-line { height: 14px; margin: 10px 0; }
.skel-card { height: 220px; }

/* ---------- empty, error, offline states ---------- */
.state {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-3);
  padding: var(--space-7) var(--space-4); color: var(--text-2);
}
.state-icon {
  width: 56px; height: 56px; border-radius: var(--radius-lg); display: grid; place-items: center;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}
.state h2 { color: var(--text-1); font-size: var(--text-lg); }
.state p { max-width: 42ch; }

/* ---------- toast ---------- */
.toasts { position: fixed; left: 50%; bottom: var(--space-4); transform: translateX(-50%); z-index: 80; display: grid; gap: var(--space-2); width: min(92vw, 420px); pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-3); border-radius: var(--radius-md);
  background: var(--surface-3); color: var(--text-1); border: 1px solid var(--border-strong); box-shadow: var(--shadow-3);
  font-size: var(--text-sm); animation: toast-in var(--dur-base) var(--ease-out);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- sheets ---------- */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 60; animation: fade-in var(--dur-base) var(--ease-out); }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  position: fixed; z-index: 70; left: 50%; bottom: 0; transform: translateX(-50%);
  width: min(100%, 640px); max-height: 86vh; overflow: auto;
  background: var(--bg-elevated); border: 1px solid var(--border); border-bottom: 0;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0; box-shadow: var(--shadow-3);
  padding: var(--space-2) var(--space-4) var(--space-5);
  animation: sheet-up var(--dur-slow) var(--ease-spring);
}
.sheet.wide { width: min(100%, 920px); }
@keyframes sheet-up { from { transform: translate(-50%, 24px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
.sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--border-strong); margin: 4px auto var(--space-3); }
.sheet-head { display: flex; align-items: flex-start; gap: var(--space-3); margin-bottom: var(--space-3); }
.sheet-head h2 { flex: 1; font-size: var(--text-lg); padding-top: 10px; }

/* ---------- rings ---------- */
.ring { display: block; }
.ring-track { stroke: var(--surface-3); }
.ring-value { stroke: var(--accent); transition: stroke-dashoffset 900ms var(--ease-out); }
.ring-label { font-weight: var(--weight-bold); fill: var(--text-1); }
.ring-sub { fill: var(--text-3); }

/* ---------- segmented control ---------- */
.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--radius-md); background: var(--surface-2); border: 1px solid var(--border); }
.segmented button {
  min-height: 38px; padding: 0 var(--space-3); border: 0; border-radius: 8px; background: transparent;
  color: var(--text-2); font-size: var(--text-sm); font-weight: var(--weight-medium); cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.segmented button[aria-pressed="true"] { background: var(--surface-1); color: var(--text-1); box-shadow: var(--shadow-1); }

/* ========== HOME: STATE MAP ========== */
.hero { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--space-5); align-items: start; }
.hero-copy h1 { font-size: var(--text-3xl); letter-spacing: -0.02em; margin: var(--space-2) 0 var(--space-3); }
.hero-copy p { color: var(--text-2); max-width: 56ch; }
.map-wrap { position: relative; margin-top: var(--space-4); }
.usmap { width: 100%; height: auto; display: block; overflow: visible; }
.usmap .st {
  fill: var(--map-state); stroke: var(--map-stroke); stroke-width: 1; cursor: pointer;
  transition: fill var(--dur-fast) var(--ease-out), transform var(--dur-base) var(--ease-out), filter var(--dur-base) var(--ease-out);
  transform-box: fill-box; transform-origin: center;
}
.usmap .st:hover, .usmap .st:focus-visible { fill: var(--map-state-hover); transform: translateY(-3px); filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.35)); outline: none; }
.usmap .st.selected { fill: var(--surface-3); stroke: var(--text-3); stroke-width: 1.5; }
.usmap .st.live { fill: var(--accent); }
.usmap .st.live:hover, .usmap .st.live:focus-visible, .usmap .st.live.selected { fill: var(--accent-strong); stroke: var(--accent); stroke-width: 1; }
.usmap .pulse { fill: var(--accent); stroke: none; transform-box: fill-box; transform-origin: center; animation: pulse 2.4s var(--ease-out) infinite; pointer-events: none; }
.usmap .pin { fill: var(--on-accent); stroke: var(--accent-strong); stroke-width: 2; pointer-events: none; }
@keyframes pulse { 0% { opacity: 0.55; transform: scale(1); } 100% { opacity: 0; transform: scale(3.2); } }
.usmap .lbl { font-size: 11px; font-weight: var(--weight-semibold); fill: var(--text-3); pointer-events: none; }
.usmap .lbl.live { fill: var(--on-accent); }
.map-legend { display: flex; gap: var(--space-3); flex-wrap: wrap; margin-top: var(--space-3); font-size: var(--text-xs); color: var(--text-3); }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

.state-panel { position: sticky; top: 84px; }
.state-panel .card-pad { display: grid; gap: var(--space-3); }
.pack-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-2); }
.stat { background: var(--surface-2); border-radius: var(--radius-md); padding: var(--space-2) var(--space-3); }
.stat b { display: block; font-size: var(--text-lg); }
.stat span { font-size: var(--text-xs); color: var(--text-3); }
.download-row { display: flex; align-items: center; gap: var(--space-3); }
.state-list { display: none; }

/* ========== STATE HUB ========== */
.hub-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; }
.hub-head h1 { font-size: var(--text-3xl); letter-spacing: -0.02em; }
.hub-meta { display: flex; gap: var(--space-2); flex-wrap: wrap; margin-top: var(--space-2); }
.hub-tools { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--space-3); }
.scenario-card {
  display: flex; flex-direction: column; overflow: hidden; text-align: left; cursor: pointer; padding: 0;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-1);
  transition: transform var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out), border-color var(--dur-base) var(--ease-out);
}
.scenario-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: var(--border-strong); }
.scenario-card .art { aspect-ratio: 16 / 7; background: var(--illus-sky); border-bottom: 1px solid var(--border); }
.scenario-card .art svg { width: 100%; height: 100%; display: block; }
.scenario-card .body { padding: var(--space-3); display: grid; gap: var(--space-2); }
.scenario-card .title { font-weight: var(--weight-semibold); font-size: var(--text-md); }
.scenario-card .dispatch { color: var(--text-2); font-size: var(--text-sm); }
.scenario-card .foot { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }
.topic-badge { display: inline-flex; align-items: center; gap: var(--space-2); }
.topic-badge .tb { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-1); }
.soon-card { border-style: dashed; box-shadow: none; background: transparent; }
.soon-card .card-pad { display: grid; gap: var(--space-2); color: var(--text-3); }
.rollup { display: grid; gap: var(--space-2); }
.rollup-row { display: grid; grid-template-columns: 1fr 120px 48px; gap: var(--space-3); align-items: center; font-size: var(--text-sm); }
.bar { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }

/* ========== PLAY ========== */
.play { display: grid; grid-template-columns: minmax(0, 1fr) 360px; grid-template-rows: minmax(0, 1fr); height: calc(100dvh - 60px); }
.play-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-right: 1px solid var(--border); }
.play-bar { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--gutter); border-bottom: 1px solid var(--border); background: var(--bg-elevated); }
.play-bar .title { flex: 1; min-width: 0; }
.play-bar .title b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.counter { font-variant-numeric: tabular-nums; }
.chat > * { flex: none; }
.chat { flex: 1; min-height: 0; overflow-y: auto; padding: var(--space-4) var(--gutter); display: flex; flex-direction: column; gap: var(--space-2); scroll-behavior: smooth; }
.cad {
  display: grid; grid-template-columns: 1fr; overflow: hidden; margin-bottom: var(--space-3);
  border-radius: var(--radius-lg); border: 1px solid var(--border-strong); background: var(--surface-1); box-shadow: var(--shadow-2);
  animation: cad-in var(--dur-slow) var(--ease-out);
}
@keyframes cad-in { from { opacity: 0; transform: translateX(-16px); } to { opacity: 1; transform: none; } }
.cad-art { height: 140px; background: var(--illus-sky); }
.cad-art svg { width: 100%; height: 100%; display: block; }
.cad-body { padding: var(--space-3); display: grid; gap: var(--space-2); }
.cad-row { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-3); letter-spacing: 0.02em; }
.cad-row .sep { opacity: 0.5; }
.cad-type { font-family: var(--font-ui); font-size: var(--text-xs); font-weight: var(--weight-bold); letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.cad-text { font-size: var(--text-lg); font-weight: var(--weight-medium); line-height: 1.4; }
.msg { display: flex; gap: var(--space-2); max-width: 86%; animation: msg-in var(--dur-base) var(--ease-out); }
@keyframes msg-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg.me { align-self: flex-end; }
.msg.me .bubble { background: var(--accent); color: var(--on-accent); border-radius: 18px 18px 4px 18px; }
.msg.engine { align-self: flex-start; align-items: flex-end; }
.bubble { padding: 10px 14px; border-radius: 18px 18px 18px 4px; background: var(--surface-2); border: 1px solid var(--border); font-size: var(--text-md); }
.msg.me .bubble { border: 0; }
.answer-badge { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--surface-3); color: var(--text-2); }
.answer-badge.yes { background: var(--accent-soft); color: var(--accent); }
.answer-badge.no { background: var(--surface-3); color: var(--text-1); }
.answer-badge.flag { background: var(--flag-soft); color: var(--flag); }
.bubble .ans { font-weight: var(--weight-semibold); }
.bubble .qn { font-size: var(--text-xs); color: var(--text-3); margin-left: var(--space-2); font-variant-numeric: tabular-nums; }
.typing { display: inline-flex; gap: 4px; padding: 14px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); animation: blink 1s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }
.composer { border-top: 1px solid var(--border); padding: var(--space-2) var(--gutter) var(--space-3); background: var(--bg-elevated); display: grid; gap: var(--space-2); }
.suggest { display: flex; gap: var(--space-2); overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.composer form { display: flex; gap: var(--space-2); }
.input {
  flex: 1; min-height: var(--tap); padding: 0 var(--space-3); border-radius: var(--radius-md);
  border: 1px solid var(--border-strong); background: var(--surface-1); color: var(--text-1); font: inherit;
}
.input { min-width: 0; }
.show-xs { display: none; }
.play-bar .title > .subtle { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ref-main { min-width: 0; overflow-wrap: anywhere; grid-template-columns: minmax(0, 1fr); }
.composer { grid-template-columns: minmax(0, 1fr); }
.input::placeholder { color: var(--text-3); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.side { display: flex; flex-direction: column; min-height: 0; background: var(--bg-elevated); }
.side-tabs { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border); }
.side-body { flex: 1; overflow-y: auto; padding: var(--space-3); }
.notes { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.note {
  display: grid; grid-template-columns: 24px 1fr auto; gap: var(--space-2); align-items: start;
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); background: var(--surface-1); border: 1px solid var(--border);
  font-size: var(--text-sm); animation: note-in var(--dur-slow) var(--ease-spring);
}
@keyframes note-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
.note .n { font-size: var(--text-xs); color: var(--text-3); font-variant-numeric: tabular-nums; }
.note .ic { color: var(--text-3); padding-top: 1px; }
.note.yes .ic { color: var(--accent); }

/* ========== DECIDE ========== */
.decide { max-width: 880px; margin: 0 auto; display: grid; gap: var(--space-5); }
.step h2 { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-lg); margin-bottom: var(--space-3); }
.step-n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); font-size: var(--text-xs); font-weight: var(--weight-bold); }
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: var(--space-2); }
.choice {
  position: relative; display: grid; gap: 2px; text-align: left; cursor: pointer; min-height: 64px;
  padding: var(--space-3); border-radius: var(--radius-md); background: var(--surface-1); border: 1px solid var(--border);
  transition: border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.choice:hover { border-color: var(--border-strong); }
.choice[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.choice .t { font-weight: var(--weight-semibold); font-size: var(--text-sm); }
.choice .d { font-size: var(--text-xs); color: var(--text-3); }
.choice .tick { position: absolute; top: 10px; right: 10px; color: var(--accent); opacity: 0; transition: opacity var(--dur-fast); }
.choice[aria-pressed="true"] .tick { opacity: 1; }
.choices.chips { display: flex; flex-wrap: wrap; }
.choices.chips .choice { min-height: var(--tap); padding: 0 var(--space-3); display: inline-flex; align-items: center; font-family: var(--font-mono); font-size: var(--text-sm); }
.decide-bar { position: sticky; bottom: 0; padding: var(--space-3) 0; background: linear-gradient(transparent, var(--bg) 30%); display: flex; justify-content: flex-end; gap: var(--space-2); }

/* ========== DEBRIEF ========== */
.debrief { max-width: 960px; margin: 0 auto; display: grid; gap: var(--space-4); }
.score-hero { display: grid; grid-template-columns: auto 1fr; gap: var(--space-5); align-items: center; }
.score-lines { display: grid; gap: var(--space-2); }
.score-line { display: grid; grid-template-columns: 22px 1fr auto; gap: var(--space-2); align-items: center; font-size: var(--text-sm); }
.score-line .pts { font-variant-numeric: tabular-nums; font-weight: var(--weight-semibold); }
.score-line .ok { color: var(--asked); }
.score-line .bad { color: var(--missed); }
.score-line .part { color: var(--flag); }
.compare { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--space-2); }
.compare .cell { padding: var(--space-3); border-radius: var(--radius-md); background: var(--surface-2); display: grid; gap: 4px; font-size: var(--text-sm); }
.timeline { list-style: none; margin: 0; padding: 0; position: relative; display: grid; gap: var(--space-2); }
.timeline::before { content: ""; position: absolute; left: 13px; top: 8px; bottom: 8px; width: 2px; background: var(--border); }
.tl { position: relative; display: grid; grid-template-columns: 28px 1fr; gap: var(--space-3); align-items: start; animation: msg-in var(--dur-base) var(--ease-out) both; }
.tl .dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); border: 2px solid var(--bg); z-index: 1; }
.tl.asked .dot { background: var(--asked); color: var(--bg); }
.tl.missed .dot { background: var(--missed); color: var(--bg); }
.tl .what { font-weight: var(--weight-semibold); font-size: var(--text-sm); }
.tl .why { font-size: var(--text-sm); color: var(--text-2); }
.explain { font-size: var(--text-md); line-height: var(--leading-law); }
.cites { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.notice {
  display: flex; gap: var(--space-2); align-items: flex-start; padding: var(--space-3); border-radius: var(--radius-md);
  background: var(--surface-2); border: 1px solid var(--border); font-size: var(--text-sm); color: var(--text-2);
}
.notice.flag { background: var(--flag-soft); color: var(--flag); border-color: transparent; }

/* ========== STATUTE / ELEMENTS ========== */
.ref { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: var(--space-4); align-items: start; }
.ref-list { position: sticky; top: 84px; display: grid; gap: var(--space-2); max-height: calc(100dvh - 110px); overflow: auto; padding-right: 4px; }
.ref-item {
  display: grid; gap: 2px; text-align: left; cursor: pointer; padding: var(--space-2) var(--space-3); border-radius: var(--radius-md);
  background: transparent; border: 1px solid transparent; min-height: var(--tap); color: var(--text-1); text-decoration: none;
}
.ref-item:hover { background: var(--surface-2); }
.ref-item[aria-current="true"] { background: var(--surface-2); border-color: var(--border-strong); }
.ref-item .t { font-weight: var(--weight-semibold); font-size: var(--text-sm); }
.ref-item .c { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-3); }
.ref-group { margin-top: var(--space-3); }
.statute { font-family: var(--font-law); font-size: 1.0625rem; line-height: var(--leading-law); color: var(--text-1); }
.statute p { margin: 0 0 var(--space-2); }
.statute-cap { font-family: var(--font-law); font-size: var(--text-xl); font-weight: var(--weight-semibold); }
.seg.el { border-radius: 3px; transition: background var(--dur-slow) var(--ease-out), box-shadow var(--dur-slow) var(--ease-out); }
.lit .seg.el.on { background: var(--accent-soft); box-shadow: 0 1px 0 0 var(--accent); }
.seg.el.focus { background: color-mix(in srgb, var(--accent) 30%, transparent) !important; }
.seg.stip.on { background: var(--flag-soft); }
.marker {
  display: inline-grid; place-items: center; width: 20px; height: 20px; margin: 0 3px 0 1px; border-radius: 50%;
  font-family: var(--font-ui); font-size: 11px; font-weight: var(--weight-bold); vertical-align: 2px;
  background: var(--accent); color: var(--on-accent); transform: scale(0); transition: transform var(--dur-base) var(--ease-spring);
}
.marker.on { transform: scale(1); }
.term { text-decoration: underline; text-decoration-style: dotted; text-decoration-color: var(--accent); text-underline-offset: 4px; cursor: pointer; }
.term:hover { color: var(--accent); }
.el-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.el-list li { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: var(--space-2); align-items: start; font-size: var(--text-sm); }
.el-list .num { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); font-size: 11px; font-weight: var(--weight-bold); transition: background var(--dur-base), color var(--dur-base); }
.lit .el-list .num.on { background: var(--accent); color: var(--on-accent); }
.el-list button { all: unset; cursor: pointer; display: contents; }
.ref-search { position: relative; }
.ref-search .icon { position: absolute; left: 12px; top: 12px; color: var(--text-3); }
.ref-search .input { padding-left: 40px; width: 100%; }
.def-text { font-family: var(--font-law); font-size: var(--text-lg); line-height: var(--leading-law); }
.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--space-2); }
.meta-grid .stat b { font-size: var(--text-sm); }

/* ========== GALLERY ========== */
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--space-2); }
.swatch { border-radius: var(--radius-md); overflow: hidden; border: 1px solid var(--border); font-size: var(--text-xs); }
.swatch i { display: block; height: 56px; }
.swatch span { display: block; padding: 6px 8px; font-family: var(--font-mono); background: var(--surface-1); }
.gal-row { display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: center; }

/* ========== REPORT AN ISSUE ========== */
.report-form { display: grid; gap: var(--space-3); }
.report-form p { margin: 0; }
.report-about { display: flex; gap: var(--space-2); align-items: center; padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); background: var(--surface-2); font-weight: var(--weight-medium); font-size: var(--text-sm); }
.field { display: grid; gap: 6px; }
.field label { font-weight: var(--weight-semibold); font-size: var(--text-sm); }
.field-hint { font-size: var(--text-xs); color: var(--text-3); }
.field-hint:empty { display: none; }
.field-error { font-size: var(--text-xs); color: var(--missed); font-weight: var(--weight-medium); }
.field-row { display: flex; justify-content: space-between; gap: var(--space-2); align-items: baseline; }
.input.select { appearance: none; -webkit-appearance: none; padding-right: 40px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.input.textarea { padding: var(--space-3); min-height: 132px; resize: vertical; line-height: 1.5; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.report-sent { font-size: var(--text-sm); color: var(--text-2); }
.report-sent summary { cursor: pointer; min-height: var(--tap); display: flex; align-items: center; color: var(--text-2); }
.report-sent ul { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.report-actions { display: flex; gap: var(--space-2); justify-content: flex-end; flex-wrap: wrap; }
.link-btn { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; min-height: var(--tap); font-size: var(--text-xs); color: var(--text-3); }
.link-btn:hover, .link-btn:focus-visible { color: var(--text-1); text-decoration: underline; }
.link-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ========== LEGAL ========== */
.disclaimer { display: flex; gap: var(--space-2); align-items: flex-start; margin: 0; font-size: var(--text-xs); color: var(--text-3); line-height: 1.5; }
.disclaimer .icon { margin-top: 2px; }
.disclaimer a { color: var(--text-2); }
.legal-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px var(--space-2); padding: var(--space-3) var(--gutter) var(--space-4); font-size: var(--text-xs); color: var(--text-3); text-align: center; }
.legal-foot a { color: var(--text-2); min-height: var(--tap); display: inline-flex; align-items: center; }
.legal { max-width: 68ch; display: grid; gap: var(--space-4); }
.legal section { display: grid; gap: var(--space-2); }
.legal h2 { font-size: var(--text-lg); }
.legal p { margin: 0; color: var(--text-2); }
.legal .btn { justify-self: start; }

/* ========== RESPONSIVE ========== */
@media (max-width: 1023px) {
  .hero { grid-template-columns: 1fr; }
  .state-panel { position: static; }
  .play { grid-template-columns: minmax(0, 1fr) 300px; }
  .ref { grid-template-columns: 240px minmax(0, 1fr); }
}
@media (max-width: 767px) {
  .nav { display: none; }
  .tabbar {
    display: grid; grid-template-columns: repeat(3, 1fr); position: sticky; bottom: 0; z-index: 30;
    background: color-mix(in srgb, var(--bg-elevated) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a { display: grid; justify-items: center; gap: 2px; padding: 8px 0; min-height: 56px; color: var(--text-3); text-decoration: none; font-size: 11px; font-weight: var(--weight-medium); }
  .tabbar a[aria-current="page"] { color: var(--accent); }
  .hero-copy h1 { font-size: var(--text-2xl); }
  .hub-head h1 { font-size: var(--text-2xl); }
  .state-list { display: grid; gap: var(--space-2); margin-top: var(--space-3); }
  .play { grid-template-columns: 1fr; height: calc(100dvh - 60px); }
  .side { display: none; }
  .side.open { display: flex; position: fixed; inset: 60px 0 0 0; z-index: 40; }
  .ref { grid-template-columns: minmax(0, 1fr); }
  .hide-xs { display: none; }
  .show-xs { display: inline; }
  .play-bar { padding-left: var(--space-2); padding-right: var(--space-2); }
  .ref-list { position: static; max-height: none; }
  .ref.has-card .ref-list { display: none; }
  .score-hero { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .score-lines { width: 100%; text-align: left; }
  .msg { max-width: 92%; }
  .rollup-row { grid-template-columns: 1fr 80px 40px; }
  .brand-sub { display: none; }
  /* 44-point touch targets on phones. */
  .btn-sm, .segmented button { min-height: var(--tap); }
  .cites a.chip, a.tap-link { min-height: var(--tap); display: inline-flex; align-items: center; }
}
@media (min-width: 768px) {
  .only-mobile { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0ms !important; animation-iteration-count: 1 !important; transition-duration: 0ms !important; scroll-behavior: auto !important; }
  .usmap .pulse { display: none; }
}
#rep-count { white-space: nowrap; flex-shrink: 0; }

/* Report an issue: steps and review */
.report-steps { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); font-size: var(--text-xs); color: var(--text-3); font-weight: var(--weight-medium); }
.report-dots { display: flex; gap: 6px; }
.report-dots i { width: 22px; height: 4px; border-radius: 2px; background: var(--border-strong); }
.report-dots i.done { background: var(--accent); opacity: .5; }
.report-dots i.on { background: var(--accent); }
.report-q { margin: 0; font-size: var(--text-lg); outline: none; }
.report-choices { grid-template-columns: 1fr; }
.report-choices .choice { min-height: var(--tap); }
.review-block { display: grid; gap: var(--space-2); padding: var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-md); }
.review-block h3 { margin: 0; font-size: var(--text-sm); display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); }
.review-dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px var(--space-3); margin: 0; font-size: var(--text-sm); }
.review-dl dt { color: var(--text-3); }
.review-dl dd { margin: 0; overflow-wrap: anywhere; }
.review-why { white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--text-sm); }
.review-convo { margin: 0; padding-left: 22px; display: grid; gap: 6px; font-size: var(--text-sm); }
.review-convo li { display: flex; justify-content: space-between; gap: var(--space-2); }
.review-convo .q { min-width: 0; overflow-wrap: anywhere; }
.review-convo .a { flex-shrink: 0; font-weight: var(--weight-semibold); color: var(--text-2); }
