/* ---------- Overlay ---------- */
#sheet-root { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
#sheet-root.is-open { pointer-events: auto; }
.sheet-scrim { position: absolute; inset: 0; background: var(--scrim); opacity: 0; transition: opacity var(--t-med) var(--ease); }
.is-open .sheet-scrim { opacity: 1; }
.sheet {
  position: absolute; display: flex; flex-direction: column; background: var(--surface); color: var(--ink);
  transition: transform var(--t-med) var(--ease); touch-action: pan-y; outline: none;
}
.sheet__handle { display: none; padding: 10px 0 2px; justify-content: center; cursor: grab; touch-action: none; }
.sheet__handle span { width: 44px; height: 5px; border-radius: 3px; background: var(--line-strong); }
.sheet__body { overflow-y: auto; overscroll-behavior: contain; flex: 1; }

@media (min-width: 900px) {
  .sheet { top: 0; right: 0; bottom: 0; width: min(560px, 100vw); transform: translateX(100%); border-left: 1px solid var(--line); box-shadow: var(--shadow-pop); }
  .is-open .sheet { transform: none; }
}
@media (max-width: 899px) {
  .sheet { left: 0; right: 0; bottom: 0; max-height: 92dvh; height: 92dvh; border-radius: var(--radius-l) var(--radius-l) 0 0; transform: translateY(100%); box-shadow: var(--shadow-sheet); }
  .is-open .sheet { transform: none; }
  .sheet__handle { display: flex; }
}

.sheet__content { display: flex; flex-direction: column; min-height: 100%; }
.sheet__head {
  position: sticky; top: 0; z-index: 2; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; gap: var(--space-3); align-items: flex-start; justify-content: space-between; padding: var(--space-3) var(--space-4) var(--space-3) var(--space-5);
}
.sheet__headtext { display: grid; gap: 6px; min-width: 0; }
.sheet__chips { display: flex; gap: 6px; flex-wrap: wrap; }
.sheet__title { font-size: var(--step-3); line-height: 1.05; overflow-wrap: anywhere; }
.sheet__sub { color: var(--ink-2); font-size: var(--step--1); }
.sheet__tools { display: flex; align-items: center; flex: none; }
.sheet__scroll { padding: var(--space-2) var(--space-5) var(--space-7); display: grid; gap: var(--space-5); align-content: start; }
@media (max-width: 899px) { .sheet__head { padding-left: var(--space-4); } .sheet__scroll { padding-inline: var(--space-4); } }

.block { display: grid; gap: var(--space-3); padding-top: var(--space-4); border-top: 1px solid var(--line); }
.block:first-child { border-top: 0; padding-top: var(--space-3); }
.block__title { font: 700 var(--step-2)/1.1 var(--font-display); letter-spacing: 0.01em; }
.note { color: var(--ink-3); font-size: var(--step--1); max-width: 62ch; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.callout { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3) var(--space-4); border-radius: var(--radius-m); background: var(--surface-sunk); border: 1px solid var(--line); font-size: var(--step--1); color: var(--ink-2); }
.callout svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.callout--bad { background: var(--bad-bg); color: var(--bad-ink); border-color: var(--bad-line); }
.callout--ok { background: var(--turf-soft); color: var(--turf); border-color: var(--turf-mid); }

/* ---------- Scoreboard ---------- */
.board { display: grid; grid-template-columns: 1fr auto 1fr; gap: var(--space-3); align-items: start; padding: var(--space-3) 0 var(--space-1); }
.board__team { display: grid; gap: 2px; min-width: 0; }
.board__team--home { text-align: right; justify-items: end; }
.board__name { font-weight: 700; font-size: var(--step-1); line-height: 1.15; overflow-wrap: anywhere; }
.board__rec { color: var(--ink-3); font-size: 0.75rem; }
.board__pts { font-size: var(--step-5); color: var(--ink-3); margin-top: 6px; }
.board__team.is-lead .board__pts { color: var(--ink); }
.board__prob { color: var(--ink-2); font-size: var(--step--1); font-weight: 600; }
.board__team.is-lead .board__prob { color: var(--turf); }
.board__mid { display: grid; justify-items: center; align-content: center; gap: var(--space-2); padding-top: 22px; color: var(--ink-3); }
.board__at { font-weight: 600; }
.board__total { display: grid; justify-items: center; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-s); font-weight: 700; color: var(--ink); font-size: var(--step-1); }
.board__total small { font-size: 0.6875rem; font-weight: 600; color: var(--ink-3); }
.verdict { font-size: var(--step-1); line-height: 1.35; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-radius: var(--radius-m); background: var(--turf-soft); color: var(--ink); }
.verdict__spread { font: 700 var(--step-2)/1 var(--font-display); color: var(--turf); }
.verdict--small { font-size: var(--step-0); background: var(--surface-sunk); border: 1px solid var(--line); }

/* ---------- Margin ruler (the signature graphic) ---------- */
.ruler { margin: 0; display: grid; gap: 6px; }
.ruler__ends { display: flex; justify-content: space-between; font-size: 0.75rem; font-weight: 700; color: var(--ink-2); gap: var(--space-3); }
.ruler__field { position: relative; height: 56px; border-radius: var(--radius-s); background: var(--turf-soft); border: 1px solid var(--turf-mid); overflow: hidden; }
.ruler--sm .ruler__field { height: 14px; }
.ruler__zone { position: absolute; top: 0; bottom: 0; width: 8px; background: var(--turf-mid); opacity: 0.55; }
.ruler__zone--l { left: 0; } .ruler__zone--r { right: 0; }
.ruler__tick { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--turf-mid); translate: -0.5px 0; }
.ruler__tick--mid { width: 2px; background: var(--turf); translate: -1px 0; }
.ruler__band { position: absolute; top: 10px; bottom: 10px; background: color-mix(in srgb, var(--turf) 22%, transparent); border-radius: 4px; border-inline: 2px solid var(--turf-mid); }
.ruler__flag { position: absolute; top: 0; bottom: 0; width: 4px; translate: -2px 0; background: var(--ink); border-radius: 2px; box-shadow: 0 0 0 2px var(--surface); }
.ruler__flag::before { content: ''; position: absolute; top: 4px; left: 4px; width: 16px; height: 12px; background: var(--flag); clip-path: polygon(0 0, 100% 50%, 0 100%); }
.ruler__flag.is-clamped { background: var(--flag); }
.ruler__result { position: absolute; top: 50%; width: 16px; height: 16px; translate: -50% -50%; rotate: 45deg; border: 3px solid var(--ink); background: var(--surface); border-radius: 2px; }
.ruler__scale { position: relative; height: 16px; font-size: 0.6875rem; color: var(--ink-3); }
.ruler__scale span { position: absolute; translate: -50% 0; }
.legend-diamond { display: inline-block; width: 10px; height: 10px; border: 2px solid var(--ink); rotate: 45deg; border-radius: 1px; margin: 0 4px 0 2px; }

/* ---------- Drivers ---------- */
.drivers { display: grid; gap: 10px; }
.drivers li { display: grid; grid-template-columns: 112px 1fr 52px; align-items: center; gap: var(--space-3); font-size: var(--step--1); }
.drivers__val { text-align: right; font-weight: 700; }
.driver { position: relative; height: 10px; border-radius: 5px; background: var(--surface-2); }
.driver__mid { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 2px; background: var(--line-strong); translate: -1px 0; }
.driver__bar { position: absolute; top: 0; bottom: 0; background: var(--turf); border-radius: 5px; min-width: 3px; }
.driver__bar.is-neg { background: var(--ink-3); }

/* ---------- Record / history / market ---------- */
.hashline { display: flex; align-items: center; gap: var(--space-3); font-size: var(--step--1); color: var(--ink-3); flex-wrap: wrap; }
.hashline code { color: var(--ink); background: var(--surface-sunk); border: 1px solid var(--line); padding: 3px 8px; border-radius: 4px; font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 0.8125rem; }
.history { display: grid; gap: 0; border: 1px solid var(--line); border-radius: var(--radius-m); overflow: clip; }
.history li { display: grid; grid-template-columns: 36px 1fr auto; gap: var(--space-3); align-items: center; padding: 10px var(--space-3); border-bottom: 1px solid var(--line); font-size: var(--step--1); }
.history li:last-child { border-bottom: 0; }
.history li.is-current { background: var(--turf-soft); }
.history__v { font-weight: 800; color: var(--ink-2); }
.history__body { display: grid; gap: 1px; } .history__body small { color: var(--ink-3); }
.history__delta { color: var(--ink-2); font-weight: 600; text-align: right; }

.kv { display: grid; gap: 6px; font-size: var(--step--1); }
.kv > div { display: grid; grid-template-columns: 150px 1fr; gap: var(--space-3); align-items: baseline; }
.kv--wide > div { grid-template-columns: 1fr auto; border-bottom: 1px dashed var(--line); padding-bottom: 6px; }
.kv dt { color: var(--ink-3); } .kv dd { margin: 0; overflow-wrap: anywhere; font-weight: 600; }
.quotes { font-size: var(--step--1); }
.quotes th { text-align: left; color: var(--ink-3); font-weight: 600; padding: 4px 0; border-bottom: 1px solid var(--line); }
.quotes td { padding: 6px 0; border-bottom: 1px solid var(--line); }
.quotes .r { text-align: right; }
.notmodeled { display: grid; gap: 8px; font-size: var(--step--1); }
.notmodeled li { display: flex; gap: var(--space-3); align-items: center; }
.advanced { border: 1px solid var(--line); border-radius: var(--radius-m); padding: var(--space-3) var(--space-4); }
.advanced summary { cursor: pointer; font-weight: 600; font-size: var(--step--1); color: var(--ink-2); }
.advanced[open] summary { margin-bottom: var(--space-3); }

body.sheet-open #dev-root { display: none; }
.sheet__close { margin-left: 2px; }

/* Narrow sheets: the change note drops under the details so the date and cutoff get the full width. */
@media (max-width: 520px) {
  .history li { grid-template-columns: 30px 1fr; row-gap: 2px; }
  .history__delta { grid-column: 2; text-align: left; font-size: 0.8125rem; }
  .history__delta:empty { display: none; }
}
