/* Monty's swing vault — Atlas (light) + Evidence Bench (dark). Tokens from Fourwood. */
@font-face { font-family: Barlow; src: url('/monty/assets/fonts/Barlow-Regular.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: Barlow; src: url('/monty/assets/fonts/Barlow-Medium.woff2') format('woff2'); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: Barlow; src: url('/monty/assets/fonts/Barlow-SemiBold.woff2') format('woff2'); font-weight: 600; font-style: normal; font-display: swap; }

:root {
  --forest: #0b241a; --green: #123824; --accent: #6ec176; --cream: #f4f0e7; --ink: #102118; --line: #b8b1a4;
  --paper: #fbfaf6; --muted: #4d5a51; --ochre: #8a5a12; --flag: #e3b04b; --error: #9a281e;
  --bench-line: rgba(244, 240, 231, .16); --bench-muted: #b9c6bd;
  --focus: var(--forest); --pad: clamp(16px, 3vw, 32px);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--cream); color: var(--ink); font: 16px/1.45 Barlow, system-ui, sans-serif; font-variant-numeric: tabular-nums; }
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3 { font-weight: 600; line-height: 1.15; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
[hidden] { display: none !important; }

.skip { position: absolute; left: 12px; top: -80px; z-index: 50; background: var(--forest); color: var(--cream); padding: 10px 14px; }
.skip:focus { top: 12px; }

/* Header */
.masthead { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px 32px; align-items: end; padding: 18px var(--pad) 16px; background: var(--paper); border-bottom: 1px solid var(--line); }
.crumb { font-size: 13px; color: var(--muted); }
.masthead h1 { font-size: clamp(28px, 3.2vw, 38px); font-weight: 600; letter-spacing: -.01em; color: var(--forest); }
.intro { max-width: 52ch; color: var(--muted); font-size: 15px; }
.counts { font-size: 14px; color: var(--muted); white-space: nowrap; text-align: right; margin-bottom: 8px; }
.view-tabs { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.view-tabs [role="tab"] { min-height: 44px; padding: 8px 18px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--forest); font-weight: 600; font-size: 15px; }
.view-tabs [role="tab"]:hover { border-color: var(--forest); }
.view-tabs [role="tab"][aria-selected="true"] { background: var(--forest); border-color: var(--forest); color: var(--cream); }

/* Layout: Atlas canvas left, Evidence Bench right */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 420px); gap: 24px; padding: 20px var(--pad) 40px; align-items: start; }
.atlas { min-width: 0; }
.atlas:focus { outline: none; }
.atlas-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.atlas-head h2 { font-size: 22px; color: var(--forest); }
.cohort-count { font-size: 14px; color: var(--muted); }

/* Controls */
button { cursor: pointer; min-height: 44px; border-radius: 3px; padding: 8px 16px; font-weight: 600; font-size: 15px; border: 1px solid transparent; }
button:disabled { cursor: default; opacity: .5; }
.primary { background: var(--forest); color: var(--cream); }
.primary:hover:not(:disabled) { background: var(--green); }
.quiet { background: transparent; color: var(--forest); border-color: var(--line); }
.quiet:hover:not(:disabled) { border-color: var(--forest); }
.bench .primary { background: var(--accent); color: var(--forest); }
.bench .quiet { color: var(--cream); border-color: var(--bench-line); }
.bench .quiet:hover:not(:disabled) { border-color: var(--cream); }

.filters { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: end; margin-bottom: 16px; }
.field { display: grid; gap: 4px; min-width: 0; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); }
select, input[type="text"], input[type="number"], textarea { min-height: 44px; border: 1px solid var(--line); border-radius: 3px; background: var(--paper); padding: 8px 10px; color: var(--ink); max-width: 100%; }
.filters select { min-width: 190px; }

.plot { position: relative; background: var(--paper); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.empty-state { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; padding: 24px; text-align: center; background: rgba(251, 250, 246, .88); }
.empty-state p { max-width: 36ch; font-size: 17px; }
.shot-map { display: block; max-width: 100%; height: auto; touch-action: manipulation; }
.shot-map .grid line { stroke: #e3ded3; stroke-width: 1; }
.shot-map .grid line.target-line { stroke: var(--green); stroke-width: 1.4; }
.shot-map .tick { font-size: 11px; fill: var(--muted); }
.shot-map .axis-label, .shot-map .side-label { font-size: 12px; fill: var(--muted); font-weight: 500; }
.dot-base { fill: var(--line); opacity: .55; }
.dot-cohort { stroke: var(--paper); stroke-width: .8; }
.dot-cohort.group-woods { fill: var(--green); }
.dot-cohort.group-irons { fill: var(--ochre); }
.dot-cohort.group-wedges { fill: #3f7d5a; }

.selected-ring { fill: none; stroke: var(--ink); stroke-width: 2; }
.selected-label { font-size: 12px; font-weight: 600; fill: var(--ink); paint-order: stroke; stroke: var(--paper); stroke-width: 4px; stroke-linejoin: round; }
.shot-map:focus-visible { outline: 3px solid var(--forest); outline-offset: -3px; }
.map-help { font-size: 13px; color: var(--muted); margin: 8px 0 12px; }
.primary-heading { margin: 12px 0; }
.primary-heading h3 { font-size: 23px; }
.primary-heading p { font-size: 14px; color: var(--muted); margin-top: 5px; }
.distribution-range { stroke: var(--green); stroke-width: 2; }
.distribution-drill { cursor: pointer; }
.distribution-box { fill: var(--accent); fill-opacity: .45; stroke: var(--green); }
.distribution-median { stroke: var(--forest); stroke-width: 3; }
.distribution-mean { fill: var(--ochre); }
.trend-line { fill: none; stroke: var(--ochre); stroke-width: 2.5; }
.trend-point { fill: var(--green); stroke: var(--paper); stroke-width: 2; cursor: pointer; }
.rack-hit { cursor: pointer; }
.rack-count { fill: var(--forest); font-size: 13px; font-weight: 600; }
.chart-modes { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.chart-modes button { font-size: 14px; padding: 8px 12px; }
.chart-modes [aria-pressed="true"] { color: var(--cream); background: var(--green); border-color: var(--green); }
.relationship-point { cursor: pointer; }
.relationship-selected { stroke: var(--ink); stroke-width: 3px; }
.target-window { fill: var(--accent); fill-opacity: .18; stroke: var(--green); stroke-width: 1.5; stroke-dasharray: 5 3; }
#primary-table-host { margin: 10px 0; }
#primary-table-host summary { cursor: pointer; padding: 10px 0; min-height: 44px; font-weight: 600; }

.mark-a { fill: var(--accent); stroke: var(--green); stroke-width: 1.6; }
.mark-b { fill: var(--flag); stroke: #5c3b08; stroke-width: 1.4; }
.map-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 8px 0 0; padding: 0; font-size: 14px; color: var(--ink); }
.map-legend li { display: inline-flex; align-items: center; gap: 6px; }
.map-legend strong { font-weight: 600; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.swatch.group-woods { background: var(--green); }
.swatch.group-irons { background: var(--ochre); }
.swatch.group-wedges { background: #3f7d5a; }
.swatch-base { background: var(--line); opacity: .7; }
.compare-legend { margin-top: 8px; font-size: 14px; font-weight: 600; white-space: pre-wrap; color: var(--forest); }

.pin-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 12px 14px; background: var(--paper); border: 1px solid var(--line); border-radius: 4px; margin-bottom: 12px; }
.pin-intro { font-size: 14px; color: var(--muted); flex: 1 1 220px; }
.pin-actions { display: flex; gap: 8px; }
.pin-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; flex-basis: 100%; }
.pin-chips:empty { display: none; }
.pin-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border: 1px solid var(--line); border-radius: 999px; font-size: 14px; }
.pin-key { display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 6px; font-weight: 600; }
.pin-chip.pin-a .pin-key { background: var(--accent); color: var(--forest); border-radius: 50%; }
.pin-chip.pin-b .pin-key { background: var(--flag); color: var(--forest); clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }

.table-wrap { margin-top: 4px; }
.shot-table { margin-top: 10px; max-height: 420px; overflow: auto; border: 1px solid var(--line); background: var(--paper); }
.shot-table table { width: 100%; border-collapse: collapse; font-size: 14px; }
.shot-table caption { text-align: left; padding: 10px 12px; font-weight: 600; }
.shot-table th, .shot-table td { padding: 4px 12px; border-top: 1px solid #e3ded3; text-align: left; white-space: nowrap; }
.shot-table thead th { position: sticky; top: 0; background: var(--paper); font-size: 13px; color: var(--muted); }
.shot-table .num { text-align: right; }
.row-select { min-height: 36px; padding: 4px 10px; background: transparent; border-color: var(--line); color: var(--forest); font-weight: 500; }
.row-select[aria-pressed="true"] { background: var(--forest); color: var(--cream); border-color: var(--forest); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Evidence Bench */
.bench { background: var(--forest); color: var(--cream); border-radius: 4px; padding: 20px 22px 24px; min-width: 0; --focus: var(--accent); position: sticky; top: 16px; max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain; }
.bench-title { font-size: 14px; font-weight: 500; color: var(--bench-muted); }
.bench-empty { color: var(--bench-muted); margin-top: 12px; }
.shot-title { font-size: 22px; margin-top: 10px; }
.shot-sub { color: var(--bench-muted); font-size: 14px; margin: 2px 0 8px; }
.shot-group h4 { font-size: 13px; font-weight: 600; color: var(--accent); margin: 14px 0 2px; }
.metric-list { margin: 0; }
.metric-row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--bench-line); }
.metric-row dt { color: var(--bench-muted); }
.metric-row dd { margin: 0; text-align: right; }
.metric-value { font-weight: 600; }
.metric-note { display: block; font-size: 12px; color: var(--bench-muted); }
.view-title { font-size: 24px; margin-top: 8px; }
.view-sub { color: var(--bench-muted); font-size: 14px; margin: 2px 0 10px; }
.list-title { font-size: 13px; font-weight: 600; color: var(--accent); margin: 12px 0 2px; }
.explain { font-size: 13px; color: var(--bench-muted); margin-top: 12px; }
.target-block { margin-top: 16px; padding: 12px 14px; border: 1px solid var(--bench-line); border-radius: 3px; }
.target-block h4 { font-size: 15px; margin-bottom: 6px; }
.target-block ul { margin: 6px 0 0; padding-left: 18px; font-size: 14px; }
.target-block.recorded { border-style: dashed; }
.target-block > .quiet { margin-top: 10px; }
.target-form { margin-top: 12px; }
.target-form h5 { font-size: 14px; font-weight: 600; margin: 0 0 8px; }
.target-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.bench .field label { color: var(--bench-muted); }
.bench input, .bench textarea, .bench select { background: var(--paper); color: var(--ink); border-color: var(--line); width: 100%; }
.bench input[aria-invalid="true"], .bench textarea[aria-invalid="true"] { border: 2px solid #f0a49a; }
.field-error { color: #ffc2b8; font-size: 13px; font-weight: 600; }
.device-note { font-size: 13px; color: var(--cream); margin-top: 10px; padding-left: 10px; border-left: 3px solid var(--accent); }
.target-status { font-size: 13px; color: var(--accent); margin-top: 8px; min-height: 1em; }
.target-status:empty { display: none; }
.notes { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--bench-line); }
.notes-title { font-size: 19px; margin-bottom: 8px; }
.notes .device-note { margin: 0 0 10px; }
.storage-notice { background: rgba(227, 176, 75, .14); border-left: 3px solid var(--flag); padding: 8px 10px; font-size: 14px; margin: 8px 0; }
.notes-saved p { margin: 6px 0; }
.notes-text { white-space: pre-wrap; overflow-wrap: anywhere; background: rgba(244, 240, 231, .06); padding: 10px 12px; border-radius: 3px; }
.tag-list { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 6px 0; }
.tag-list li { border: 1px solid var(--bench-line); border-radius: 999px; padding: 2px 10px; font-size: 13px; overflow-wrap: anywhere; }
.notes-form { display: grid; gap: 12px; }
.intentions { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.intentions legend { font-size: 13px; font-weight: 600; color: var(--bench-muted); margin-bottom: 6px; padding: 0; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.choice label { display: inline-flex; align-items: center; min-height: 40px; padding: 6px 14px; border: 1px solid var(--bench-line); border-radius: 999px; cursor: pointer; font-size: 14px; }
.choice input:checked + label { background: var(--accent); color: var(--forest); border-color: var(--accent); font-weight: 600; }
.choice input:focus-visible + label { outline: 3px solid var(--accent); outline-offset: 2px; }
.bench textarea { min-height: 96px; resize: vertical; }
.confirm { margin-top: 10px; padding: 10px 12px; border: 1px solid var(--flag); border-radius: 3px; }
.bench-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.compare-scroll { overflow-x: auto; margin-top: 8px; }
.compare-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.compare-table th, .compare-table td { padding: 7px 6px; border-bottom: 1px solid var(--bench-line); text-align: right; vertical-align: top; }
.compare-table th:first-child { text-align: left; color: var(--bench-muted); font-weight: 500; }
.compare-table thead th { font-size: 13px; font-weight: 600; }
.compare-table thead .pin-key { display: inline; padding: 0; }
.compare-table .col-a .pin-key, .compare-table td[data-col="a"] .metric-value { color: var(--accent); }
.compare-table .col-b .pin-key, .compare-table td[data-col="b"] .metric-value { color: var(--flag); }
.compare-table .group-row th { text-align: left; color: var(--accent); font-weight: 600; font-size: 13px; padding-top: 14px; }
.medians-note { font-size: 13px; color: var(--cream); margin-top: 6px; padding-left: 10px; border-left: 3px solid var(--accent); }
.selected-block { margin-top: 14px; padding-top: 4px; }
.selected-block h4 { font-size: 13px; color: var(--accent); margin: 10px 0 2px; }

.link { background: transparent; border: 0; padding: 4px 6px; min-height: 44px; color: var(--forest); text-decoration: underline; text-underline-offset: 3px; font-weight: 600; font-size: 14px; }
.link:hover { color: var(--green); }

/* Dialogs */
dialog { width: min(760px, calc(100% - 24px)); max-height: calc(100dvh - 24px); padding: 0 28px 28px; border: 0; border-radius: 4px; background: var(--paper); color: var(--ink); overflow: auto; }
dialog::backdrop { background: rgba(4, 22, 14, .78); }
.dialog-bar { position: sticky; top: 0; display: flex; justify-content: flex-end; padding: 12px 0; background: var(--paper); z-index: 1; }
.dialog-body h2 { font-size: 28px; color: var(--forest); margin-bottom: 12px; }
.dialog-body h3 { font-size: 17px; margin: 18px 0 6px; }
.dialog-body p, .dialog-body li { max-width: 68ch; margin: 0 0 8px; }
.dialog-body ul { padding-left: 20px; margin: 0 0 8px; }
.digest { font-size: 12px; overflow-wrap: anywhere; background: var(--cream); padding: 1px 4px; }
dialog.sheet { margin: auto 0 0; width: 100%; max-width: 100%; max-height: 86dvh; border-radius: 12px 12px 0 0; background: var(--forest); color: var(--cream); padding: 0 18px 24px; --focus: var(--accent); }
.sheet .dialog-bar { background: var(--forest); justify-content: space-between; align-items: center; }
.sheet .dialog-bar::before { content: ""; width: 44px; height: 4px; border-radius: 2px; background: var(--bench-line); }
.sheet .quiet { color: var(--cream); border-color: var(--bench-line); }
.film-intro { color: var(--muted); }
.film-shell { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 16px; margin-top: 12px; }
.film-rack { display: grid; gap: 8px; align-content: start; }
.film-clip { display: grid; text-align: left; gap: 2px; background: transparent; border-color: var(--line); color: var(--ink); font-weight: 500; }
.film-clip span { font-size: 13px; color: var(--muted); font-weight: 400; }
.film-clip[aria-pressed="true"] { background: var(--forest); color: var(--cream); border-color: var(--forest); }
.film-clip[aria-pressed="true"] span { color: var(--bench-muted); }
.film-frame { background: var(--forest); border-radius: 3px; display: grid; place-items: center; }
.film-frame video { display: block; max-width: 100%; height: auto; max-height: 56dvh; }
.phase-marks { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.phase-mark { min-height: 40px; padding: 6px 10px; background: transparent; border-color: var(--line); color: var(--ink); font-weight: 500; font-size: 13px; }
.phase-mark[aria-pressed="true"] { background: var(--forest); border-color: var(--forest); color: var(--cream); }
.phase-code { font-weight: 600; }
.phase-time { color: inherit; opacity: .75; }

.load-error { grid-column: 1 / -1; background: var(--paper); border: 1px solid var(--line); padding: 24px; }
.load-error h2 { font-size: 22px; margin-bottom: 8px; }

@media (max-width: 1023px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .bench { position: static; max-height: none; overflow: visible; }
  .masthead { grid-template-columns: minmax(0, 1fr) auto; }
  .intro { grid-column: 1 / -1; grid-row: 2; }
}
@media (max-width: 600px) {
  .masthead { grid-template-columns: minmax(0, 1fr); gap: 6px; padding-top: 14px; }
  .counts { white-space: normal; text-align: left; }
  .view-tabs { justify-content: flex-start; gap: 6px; }
  .view-tabs [role="tab"] { padding: 8px 13px; font-size: 14px; }
  .counts { display: flex; flex-wrap: wrap; align-items: center; column-gap: 4px; }
  .layout { padding: 14px 12px 32px; gap: 18px; }
  .bench { padding: 16px 14px 20px; border-radius: 0; margin: 0 -12px; }
  .filters select { min-width: 0; width: 100%; }
  .filters .field { flex: 1 1 140px; }
  .filters [data-testid="reset-filters"] { flex: 1 1 100%; }
  .pin-actions { flex: 1 1 100%; }
  .pin-actions button { flex: 1; }
  .target-fields { grid-template-columns: minmax(0, 1fr); }
  .compare-table { font-size: 13px; }
  .compare-table th, .compare-table td { padding: 6px 3px; overflow-wrap: anywhere; }
  .compare-table th:first-child { width: 34%; }
  dialog:not(.sheet) { padding: 0 16px 20px; }
  .film-shell { grid-template-columns: minmax(0, 1fr); }
  .film-rack { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
