/* FOUR Score — components and patterns from design-system/design-system.md. Colours only via tokens.css. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--background); color: var(--ink);
  font-family: var(--font-sans); font-size: 16px; line-height: 1.45;
  font-variant-numeric: tabular-nums;
}
a { color: var(--link); }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--ink-secondary); }

/* ---------- screen anatomy ---------- */
.screen { min-height: 100dvh; display: flex; flex-direction: column; }
.screen main { flex: 1 1 auto; display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-2) 0 var(--space-6); }
.bar-bottom { position: sticky; bottom: 0; z-index: 5; background: var(--layer-01); border-top: 1px solid var(--hairline-strong); padding: 12px 16px 16px; }
@media (min-width: 600px) {
  .screen { max-width: var(--content-max); margin: 0 auto; width: 100%; }
}

/* ---------- chrome (dark header, always dark) ---------- */
.chrome { position: sticky; top: 0; z-index: 6; background: var(--chrome); color: var(--on-chrome); }
.chrome a, .chrome button { color: var(--on-chrome); }
.chrome-row { min-height: 56px; display: flex; align-items: center; gap: 8px; padding: 0 16px 0 4px; }
.chrome-title { margin: 0; flex-grow: 1; font-size: 20px; font-weight: 400; }
.chrome-big { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 4px; }
.chrome-big h1 { margin: 0; font-size: 28px; font-weight: 300; line-height: 1.1; }
.chrome .lbl, .lbl-chrome { font-size: 12px; letter-spacing: 0.32px; color: var(--on-chrome-muted); }
.chrome .sub { font-size: 13px; color: var(--on-chrome-muted); }
.icon-btn { width: var(--tap-min); height: var(--tap-min); border: 0; background: transparent; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; text-decoration: none; flex: none; }
.chip-btn { height: 40px; padding: 0 8px 0 12px; border: 0; background: var(--chrome-field); color: var(--on-chrome); display: inline-flex; align-items: center; gap: 4px; font-size: 14px; text-decoration: none; cursor: pointer; }

/* patient header */
.ph-ids { padding: 0 16px 14px; display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.ph-col { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ph-col.end { align-items: flex-end; flex: none; }
.display-id { font-size: 36px; font-weight: 300; line-height: 1; letter-spacing: -0.2px; }
.id-mono { font-family: var(--font-mono); font-size: 24px; line-height: 1.1; overflow-wrap: anywhere; }
.ph-cells { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--chrome-divider); border-top: 1px solid var(--chrome-divider); }
.ph-cell { min-height: var(--button-h); border: 0; background: var(--chrome-field); color: var(--on-chrome); padding: 8px 8px 8px 16px; display: flex; align-items: center; gap: 4px; text-align: left; text-decoration: none; cursor: pointer; }
.ph-cell .v { font-size: 15px; }
.ph-cell .k { font-size: 12px; color: var(--on-chrome-muted); }
.ph-compact { height: 56px; display: flex; align-items: center; gap: 8px; padding: 0 16px 0 4px; }
.ph-compact .id { flex-grow: 1; font-family: var(--font-mono); font-size: 17px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- sections & lists ---------- */
.section { background: var(--layer-01); flex: none; }
.section-pad { padding: 16px; }
.kicker { margin: 0; font-family: var(--font-mono); font-size: 12px; font-weight: 400; letter-spacing: 0.32px; color: var(--ink-secondary); }
.kicker.on { color: var(--link); }
.section-head { padding: 14px 16px 10px; border-bottom: 1px solid var(--hairline); }
.list-row { min-height: var(--option-row); display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--hairline); text-decoration: none; color: var(--ink); background: var(--layer-01); }
.list-row .main { flex-grow: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.list-row .id { font-family: var(--font-mono); font-size: 16px; font-weight: 500; overflow-wrap: anywhere; }
.list-row .meta { font-size: 13px; color: var(--ink-secondary); }
.chev { flex: none; color: var(--border-strong); }
.row-action { min-height: 56px; display: flex; align-items: center; gap: 12px; padding: 0 16px; color: var(--link); text-decoration: none; background: var(--layer-01); border: 0; width: 100%; text-align: left; font-size: 16px; cursor: pointer; }
.row-plain { color: var(--ink); }
.row-danger { color: var(--danger); }

/* ---------- buttons ---------- */
.btn { height: var(--button-h); border: 0; border-radius: var(--radius-0); padding: 0 16px; font-size: 16px; font-weight: 500; display: flex; align-items: center; justify-content: space-between; gap: 8px; cursor: pointer; text-decoration: none; width: 100%; text-align: left; }
.btn-primary { background: var(--interactive); color: var(--on-interactive); }
.btn-primary:hover { background: var(--interactive-hover); }
.btn-next { background: var(--inverse); color: var(--on-inverse); }
.btn-secondary { background: var(--secondary); color: var(--on-interactive); }
.btn-danger { background: var(--danger); color: var(--on-interactive); }
.btn[disabled], .btn[aria-disabled="true"] { background: var(--hairline); color: var(--ink-secondary); cursor: not-allowed; pointer-events: none; }
.btn-outline { height: 44px; padding: 0 14px; border: 1px solid var(--ink); background: var(--layer-01); color: var(--ink); font-size: 14px; font-weight: 500; cursor: pointer; flex: none; }
.link-action { min-height: var(--tap-min); padding: 0 4px; border: 0; background: transparent; color: var(--link); font-size: 14px; display: inline-flex; align-items: center; text-decoration: none; cursor: pointer; }
.btn-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; }

/* ---------- tags, chips ---------- */
.tag { height: 22px; padding: 0 6px; border-radius: var(--radius-2); font-size: 12px; font-weight: 500; display: inline-flex; align-items: center; flex: none; background: var(--layer-02); color: var(--ink); white-space: nowrap; }
.tag-warning { background: var(--warning); color: var(--on-warning); }
.tag-info { background: var(--layer-selected); color: var(--ink); }
.chip { height: var(--badge); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; background: var(--layer-02); color: var(--ink-secondary); }
.chip.on { background: var(--interactive); color: var(--on-interactive); }
.chip .k { font-size: 12px; line-height: 1; }
.chip .v { font-family: var(--font-mono); font-size: 16px; font-weight: 500; line-height: 1; }
.badge { min-width: var(--badge); height: var(--badge); display: inline-flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-size: 20px; background: var(--layer-02); color: var(--ink-secondary); flex: none; }
.badge.on { background: var(--interactive); color: var(--on-interactive); font-weight: 500; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label { font-size: 12px; letter-spacing: 0.32px; color: var(--ink-secondary); }
.input { height: 52px; border: 0; border-bottom: 1px solid var(--border-strong); border-radius: 0; background: var(--layer-02); padding: 0 12px; font-size: 16px; color: var(--ink); width: 100%; }
.input.mono { font-family: var(--font-mono); font-size: 18px; }
textarea.input { min-height: 72px; height: auto; padding: 12px; resize: vertical; }
.chrome .input { background: var(--chrome-field); color: var(--on-chrome); border-bottom-color: var(--on-chrome); }
.helper { font-size: 13px; line-height: 1.4; color: var(--ink-secondary); }
.radio-row { width: 100%; min-height: 60px; border: 0; border-bottom: 1px solid var(--hairline); background: var(--layer-01); color: var(--ink); text-align: left; padding: 8px 16px; display: flex; align-items: center; gap: 14px; cursor: pointer; }
.radio-row input { position: absolute; opacity: 0; pointer-events: none; }
.radio-row .ring { width: 20px; height: 20px; border-radius: 999px; border: 2px solid var(--border-strong); flex: none; }
.radio-row:has(input:checked) { background: var(--layer-selected); }
.radio-row:has(input:checked) .ring { border: 6px solid var(--interactive); }
.radio-row:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: -2px; }
.radio-row .main { display: flex; flex-direction: column; gap: 2px; flex-grow: 1; }
.radio-row .sub { font-size: 13px; color: var(--ink-secondary); }

/* filter tabs on chrome */
.filter-tabs { display: grid; grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr)); gap: 1px; background: var(--chrome-divider); border-top: 1px solid var(--chrome-divider); }
.filter-tabs a { min-height: 48px; padding: 0 12px; display: flex; align-items: center; justify-content: space-between; gap: 6px; text-decoration: none; background: var(--chrome-field); color: var(--on-chrome); font-size: 14px; }
.filter-tabs a[aria-current="true"] { background: var(--layer-01); color: var(--ink); font-weight: 600; }

/* segmented (language) */
.segmented { display: flex; gap: 1px; background: var(--hairline-strong); border: 1px solid var(--hairline-strong); }
.segmented button { height: 40px; padding: 0 12px; border: 0; background: var(--layer-01); color: var(--ink); font-size: 14px; cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--inverse); color: var(--on-inverse); font-weight: 600; }

/* ---------- score sheet ---------- */
.item-section { background: var(--layer-01); flex: none; scroll-margin-top: 64px; }
.item-head { display: flex; align-items: center; gap: 12px; padding: 16px 4px 12px 16px; }
.item-head .col { flex-grow: 1; display: flex; flex-direction: column; gap: 2px; }
.item-head h2 { margin: 0; font-size: 22px; font-weight: 400; line-height: 1.25; }
.item-row { width: 100%; min-height: var(--option-row); border: 0; background: var(--layer-01); color: var(--ink); text-align: left; padding: 12px 16px; display: flex; align-items: center; gap: 12px; cursor: pointer; }
.item-row .col { flex-grow: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.item-row .chosen { font-size: 15px; font-weight: 500; line-height: 1.35; }
.item-row .title { font-size: 17px; }
.hint { margin: 0 16px 12px; padding: 12px 14px; background: var(--layer-selected); display: flex; flex-direction: column; gap: 6px; font-size: 14px; line-height: 1.5; }
.hint .draft { font-size: 12px; color: var(--ink-secondary); }
.options { border-top: 1px solid var(--hairline); }
.opt-row { position: relative; width: 100%; min-height: var(--option-row); display: grid; grid-template-columns: var(--score-cell) minmax(0, 1fr) 40px; border: 0; border-bottom: 1px solid var(--hairline); padding: 0; background: transparent; color: var(--ink); text-align: left; cursor: pointer; }
.opt-row input { position: absolute; opacity: 0; pointer-events: none; }
.opt-row .num { display: flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-size: 20px; background: var(--layer-02); color: var(--ink-secondary); transition: background-color 150ms ease; }
.opt-row .lab { padding: 12px 8px 12px 16px; font-size: 16px; line-height: 1.45; display: flex; align-items: center; background: var(--layer-01); transition: background-color 150ms ease; }
.opt-row .tick { display: flex; align-items: center; justify-content: center; background: var(--layer-01); color: transparent; }
.opt-row:has(input:checked) .num { background: var(--interactive); color: var(--on-interactive); font-weight: 500; }
.opt-row:has(input:checked) .lab { background: var(--layer-selected); font-weight: 500; }
.opt-row:has(input:checked) .tick { background: var(--layer-selected); color: var(--link); }
.opt-row.is-flash .lab, .opt-row.is-flash .tick { background: var(--layer-flash); }
.opt-row:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: -2px; }

.score-bar { position: sticky; bottom: 0; z-index: 5; background: var(--layer-01); border-top: 1px solid var(--hairline-strong); display: grid; grid-template-columns: minmax(0, 1fr) 172px; }
.score-bar .left { padding: 10px 12px 14px 16px; display: flex; align-items: flex-end; gap: 12px; }
.score-bar .chips { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; flex-grow: 1; }
.score-bar .btn { height: auto; min-height: 64px; }
.total { font-size: 40px; font-weight: 300; line-height: 1; }
.of16 { font-size: 15px; color: var(--ink-secondary); }

/* ---------- feedback ---------- */
.notice-error { margin: 0 8px 8px; background: var(--error-surface); border: 1px solid var(--support-error); padding: 8px 8px 8px 14px; display: flex; align-items: center; gap: 10px; font-size: 14px; line-height: 1.35; }
.notice-error svg { color: var(--support-error); flex: none; }
.banner-warning { margin: 0 8px; background: var(--warning-surface); border: 1px solid var(--warning); padding: 12px 12px 12px 14px; display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-size: 14px; }
.scrim { position: fixed; inset: 0; z-index: 20; background: var(--overlay); display: flex; flex-direction: column; justify-content: flex-end; }
.dialog { background: var(--layer-01); color: var(--ink); padding: 20px 16px 16px; display: flex; flex-direction: column; gap: 16px; width: 100%; max-width: var(--content-max); margin: 0 auto; }
.dialog h2 { margin: 0; font-size: 22px; font-weight: 400; line-height: 1.3; }
.dialog p { margin: 0; font-size: 15px; line-height: 1.5; }

/* ---------- today ---------- */
.segments { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; }
.segments span { height: 8px; background: var(--chrome-divider); }
.segments span.on { background: var(--interactive); }
.status { min-width: 64px; height: 40px; padding: 0 8px; display: flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-size: 14px; background: var(--layer-02); color: var(--ink-secondary); flex: none; }
.status.on { background: var(--interactive); color: var(--on-interactive); font-weight: 500; }

/* ---------- compare table ---------- */
.compare-table { display: grid; border-top: 1px solid var(--hairline-strong); }
.compare-table .cell, .compare-table .rowhead, .compare-table .colhead { min-height: 48px; border-bottom: 1px solid var(--hairline); display: flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-size: 16px; }
.compare-table .cell, .compare-table .colhead { border-left: 1px solid var(--hairline); }
.compare-table .colhead { flex-direction: column; gap: 1px; min-height: 52px; border-bottom-color: var(--hairline-strong); font-family: var(--font-sans); font-size: 13px; font-weight: 500; text-align: center; padding: 0 2px; }
.compare-table .colhead .time { font-family: var(--font-mono); font-size: 12px; font-weight: 400; color: var(--ink-secondary); }
.compare-table .rowhead { justify-content: flex-start; padding-left: 16px; font-size: 14px; }
.compare-table .mine { background: var(--layer-selected); font-weight: 500; }
.compare-table .cell.diff { box-shadow: inset 0 0 0 2px var(--interactive); font-weight: 600; }
.compare-table .ne { font-size: 12px; margin-left: 4px; color: var(--link); }
.compare-table .tot { font-size: 18px; font-weight: 500; }
.compare-table .rowhead.tot { font-family: var(--font-sans); font-weight: 600; background: var(--layer-02); }

/* ---------- patient page ---------- */
.strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.strip .c { height: 40px; display: flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-size: 16px; font-weight: 500; background: var(--layer-02); }
.strip .c.val { background: var(--layer-selected); }
.strip .c.lock { background: var(--layer-01); border: 1px dashed var(--border-strong); color: var(--ink-secondary); }
.strip .d { text-align: center; font-family: var(--font-mono); font-size: 12px; color: var(--ink-secondary); }
.ledger-head, .ledger-row { display: grid; grid-template-columns: 44px 52px minmax(0, 1fr) 44px; gap: 8px; align-items: center; padding: 6px 16px; }
.ledger-head { padding-top: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--hairline-strong); font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.32px; color: var(--ink-secondary); }
.ledger-row { min-height: 52px; border-bottom: 1px solid var(--hairline); text-decoration: none; color: var(--ink); }
.detail-row { padding: 10px 16px; border-bottom: 1px solid var(--hairline); display: flex; align-items: center; gap: 12px; min-height: 48px; }
.detail-row .k { font-size: 12px; color: var(--ink-secondary); }

/* ---------- tab bar ---------- */
.tabbar { position: sticky; bottom: 0; z-index: 5; background: var(--layer-01); border-top: 1px solid var(--hairline-strong); display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tabbar a { position: relative; height: 60px; display: flex; align-items: center; justify-content: center; color: var(--ink-secondary); text-decoration: none; font-size: 13px; }
.tabbar a[aria-current="page"] { color: var(--ink); font-weight: 600; }
.tabbar a[aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 24%; right: 24%; height: 3px; background: var(--interactive); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
[x-cloak] { display: none !important; }
