/* Web Master: "Slate + Citrine" (David picked it from the 4-look pitch, 2026-11-22).
   All color comes from these tokens; component rules never use a literal color.
   Measured contrast pairs are checked by scripts/check.mjs (it reads this block). */
:root {
  --bg: #f4f5f2; --surface: #ffffff; --surface2: #e7e9e3; --line: #dfe2da;
  --ink: #22282b; --muted: #5b6468; --link: #285a70;
  --accent-fill: #2f3b40; --accent-ink: #f4e27a; --citrine: #d9c234;
  --hi: #f5efc4; --hi-ink: #4d4300;
  --good-bg: #dff0e6; --good-ink: #1d5a3a; --warn-bg: #fbe3d4; --warn-ink: #7a3412; --bad-bg: #f8dede; --bad-ink: #8a1f24;
  --glass: rgba(244, 245, 242, .86); --shadow: 0 8px 22px rgba(34, 40, 43, .08);
  --r: 18px; --r-sm: 12px;
  --font: "Manrope", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --head: "Source Serif 4", Georgia, "Iowan Old Style", serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #171b1d; --surface: #20262a; --surface2: #2a3136; --line: #343c42;
  --ink: #eef0ec; --muted: #a1aaad; --link: #9cc9dc;
  --accent-fill: #e6d35c; --accent-ink: #1f1c00; --citrine: #e6d35c;
  --hi: #3a3614; --hi-ink: #f4e98f;
  --good-bg: #1d3328; --good-ink: #9fe3bf; --warn-bg: #3d2a1d; --warn-ink: #ffc39c; --bad-bg: #3d1f22; --bad-ink: #ffb3b8;
  --glass: rgba(23, 27, 29, .86); --shadow: 0 10px 26px rgba(0, 0, 0, .4);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--font); -webkit-text-size-adjust: 100%; overflow: hidden; }
a { color: var(--link); }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { font-size: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 9px 11px; width: 100%; color: var(--ink); }
textarea { resize: vertical; min-height: 90px; }
:focus-visible { outline: 3px solid var(--citrine); outline-offset: 2px; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--head); font-weight: 600; margin: 0; text-wrap: balance; }

/* version badge: tiny, fixed, inside the safe area, top-right (no header control there on phones' first row) */
/* muted on bg: light #5b6468 on #f4f5f2 = 5.6; dark #a1aaad on #171b1d = 7.6 */
.ver { position: fixed; top: calc(env(safe-area-inset-top, 0px) + 2px); right: calc(env(safe-area-inset-right, 0px) + 6px); font: 10px/1 var(--mono); color: var(--muted); pointer-events: none; z-index: 100; }

/* ---------- PIN gate ---------- */
.gate { height: 100%; display: grid; place-items: center; padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.gate-card { display: flex; flex-direction: column; align-items: center; gap: clamp(8px, 1.8vh, 16px); text-align: center; }
.gate-card h1 { font-size: clamp(24px, 4vh, 32px); }
.gate-card p { margin: 0; font-size: 15px; }
.pin-gate { display: flex; flex-direction: column; align-items: center; gap: clamp(10px, 2.2vh, 20px); touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.pin-dots { display: flex; gap: 10px; }
.pin-dots span { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ink); }
.pin-dots span.on { background: var(--ink); }
.pin-gate.busy .pin-dots span.on { animation: pinpulse .9s ease-in-out infinite; }
@keyframes pinpulse { 50% { opacity: .35; } }
.pin-gate.bad .pin-dots { animation: pinshake .35s; }
@keyframes pinshake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.pin-msg { min-height: 1.3em; font-size: 16px; color: var(--muted); }
.pin-pad { display: grid; grid-template-columns: repeat(3, clamp(64px, 22vw, 84px)); gap: clamp(10px, 1.8vh, 16px); }
.pin-pad button { height: clamp(64px, 10vh, 84px); border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 700; font-size: clamp(26px, 4vh, 32px); line-height: 1; touch-action: manipulation; -webkit-tap-highlight-color: transparent; cursor: pointer; }
.pin-pad button:active { background: var(--accent-fill); color: var(--accent-ink); }
.pin-pad button:disabled { opacity: .5; }
.pin-pad .pin-del { border: none; background: transparent; font-size: 24px; }

/* ---------- app shell: fixed chrome, only the middle scrolls (rule 3, fallback 3) ---------- */
.app { height: 100%; display: grid; grid-template-rows: auto auto 1fr; }
.top { display: flex; align-items: center; gap: 12px; padding: calc(env(safe-area-inset-top, 0px) + 14px) max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left)); }
.brand { display: flex; align-items: center; gap: 9px; font: 600 20px var(--head); white-space: nowrap; }
.searchbox { flex: 1; min-width: 0; }
.searchbox input { border-radius: 999px; padding: 8px 14px; }
.lda { display: flex; background: var(--surface2); border-radius: 999px; padding: 3px; gap: 2px; flex: none; }
.lda button { border: 0; background: transparent; border-radius: 999px; width: 30px; height: 28px; font-weight: 700; font-size: 13px; color: var(--muted); cursor: pointer; }
.lda button.on { background: var(--accent-fill); color: var(--accent-ink); }
.tabs { display: flex; gap: 4px; padding: 0 max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left)); overflow-x: auto; scrollbar-width: none; }
.tabs button { display: flex; gap: 6px; align-items: center; border: 0; background: transparent; padding: 8px 13px; border-radius: var(--r-sm); color: var(--muted); font-weight: 700; cursor: pointer; white-space: nowrap; }
.tabs button .ic { font-size: 14px; }
.tabs button.on { background: var(--accent-fill); color: var(--accent-ink); }
.main { overflow-y: auto; overflow-x: hidden; padding: 4px max(16px, env(safe-area-inset-right)) calc(env(safe-area-inset-bottom, 0px) + 20px) max(16px, env(safe-area-inset-left)); -webkit-overflow-scrolling: touch; min-height: 0; }
.view { display: flex; flex-direction: column; gap: 14px; max-width: 1500px; margin: 0 auto; }

/* phone: tab bar moves to the bottom, chrome stays put */
@media (max-width: 720px) {
  .app { grid-template-rows: auto 1fr auto; }
  .tabs { order: 3; justify-content: space-around; padding: 6px max(6px, env(safe-area-inset-right)) calc(env(safe-area-inset-bottom, 0px) + 6px) max(6px, env(safe-area-inset-left)); background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-top: 1px solid var(--line); gap: 0; overflow: hidden; }
  .tabs button { flex-direction: column; gap: 1px; padding: 6px 4px; font-size: 10.5px; flex: 1; min-width: 0; }
  .tabs button .ic { font-size: 17px; }
  .main { order: 2; padding-bottom: 14px; }
  .brand span { display: none; }
  .top { gap: 8px; }
}

/* ---------- shared pieces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.card h2 { font-size: 20px; }
.card h3 { font-size: 17px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr)); }
.grid.sites { grid-template-columns: 1fr; }
@media (min-width: 721px) { .grid.sites { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1280px) { .grid.sites { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; display: inline-block; }
.pill { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--hi); color: var(--hi-ink); white-space: nowrap; }
.pill.good { background: var(--good-bg); color: var(--good-ink); }
.pill.warn { background: var(--warn-bg); color: var(--warn-ink); }
.pill.bad { background: var(--bad-bg); color: var(--bad-ink); }
.pill.plain { background: var(--surface2); color: var(--ink); }
.btn { border: 0; background: var(--accent-fill); color: var(--accent-ink); padding: 9px 15px; border-radius: var(--r-sm); font-weight: 700; cursor: pointer; touch-action: manipulation; }
.btn.ghost { background: var(--surface2); color: var(--ink); }
a.btn { text-decoration: none; display: inline-block; }
.btn.small { padding: 6px 11px; font-size: 13.5px; }
.btn:disabled { opacity: .6; cursor: progress; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.list { display: flex; flex-direction: column; }
.list > div, .list > details { border-top: 1px solid var(--line); padding: 8px 0; }
.list > div:first-child, .list > details:first-child { border-top: 0; }
.li-title { font-weight: 700; }
.li-meta { font-size: 13px; color: var(--muted); }
.mono { font-family: var(--mono); font-size: 13px; }
.copy { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 8px; font-size: 12px; padding: 2px 7px; cursor: pointer; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 5px 12px; font-weight: 700; font-size: 13px; cursor: pointer; display: flex; gap: 6px; align-items: center; }
.chip.on { background: var(--accent-fill); color: var(--accent-ink); border-color: transparent; }
.scroll-panel { max-height: min(60vh, 640px); overflow: auto; }
.out { background: var(--hi); color: var(--hi-ink); border-radius: var(--r-sm); padding: 12px 14px; white-space: pre-wrap; font-size: 14.5px; }
.empty { color: var(--muted); font-size: 14px; padding: 8px 0; }
details > summary { cursor: pointer; font-weight: 700; list-style-position: inside; }
form.stack { display: flex; flex-direction: column; gap: 8px; }
.formrow { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); gap: 8px; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 700; }
label.f > input, label.f > select, label.f > textarea { color: var(--ink); font-weight: 400; }

/* site card */
.site-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.site-head h2 { display: flex; gap: 9px; align-items: center; }
.counts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.counts button { border: 1px solid var(--line); background: var(--surface2); color: var(--ink); border-radius: var(--r-sm); padding: 8px 6px; cursor: pointer; text-align: left; min-width: 0; }
.counts b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.counts span { font-size: 12px; color: var(--muted); }
.due-strip { display: flex; gap: 8px; flex-wrap: wrap; }
.due-strip .pill { white-space: normal; display: inline-flex; gap: 6px; align-items: center; max-width: 100%; }

/* practices matrix */
.matrix-wrap { overflow-x: auto; }
table.matrix { border-collapse: collapse; width: 100%; min-width: 640px; font-size: 14px; }
table.matrix th, table.matrix td { border-top: 1px solid var(--line); padding: 8px 6px; text-align: left; vertical-align: top; }
table.matrix th { font-size: 12px; color: var(--muted); font-weight: 700; position: sticky; top: 0; background: var(--surface); }
table.matrix td.st { width: 108px; }
table.matrix select { padding: 4px 6px; font-size: 16px; border-radius: 8px; }
@media (max-width: 720px) {
  table.matrix { min-width: 0; }
  table.matrix thead { display: none; }
  table.matrix tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; border-top: 1px solid var(--line); padding: 10px 0; }
  table.matrix td { border: 0; padding: 0; }
  table.matrix td:first-child, table.matrix td:last-child { grid-column: 1 / -1; }
  table.matrix td.st { width: auto; }
  table.matrix td.st::before { content: attr(data-label); display: block; font-size: 12px; color: var(--muted); font-weight: 700; }
  table.matrix select { width: 100%; }
}
.st-adopted { background: var(--good-bg); color: var(--good-ink); }
.st-todo { background: var(--warn-bg); color: var(--warn-ink); }
.st-sent { background: var(--hi); color: var(--hi-ink); }
.st-na, .st-declined { background: var(--surface2); color: var(--muted); }

/* findings */
.finding { border-left: 4px solid var(--line); padding: 6px 0 6px 12px; display: flex; flex-direction: column; gap: 4px; }
.finding.error { border-color: var(--bad-ink); }
.finding.imprecise, .finding.unverified { border-color: var(--warn-ink); }
.finding.confirmed { border-color: var(--good-ink); }
.finding blockquote { margin: 0; font-style: italic; }
.finding .fix { background: var(--hi); color: var(--hi-ink); border-radius: 8px; padding: 6px 9px; }
.auth { font-size: 13px; }

/* drawer, search results, toast, drop zone */
.drawer { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: flex; flex-direction: column; }
@media (min-width: 900px) { .drawer { left: auto; width: min(760px, 70vw); border-left: 1px solid var(--line); box-shadow: var(--shadow); } }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: calc(env(safe-area-inset-top, 0px) + 14px) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left)); border-bottom: 1px solid var(--line); }
.drawer-head h2 { flex: 1; font-size: 20px; display: flex; gap: 9px; align-items: center; min-width: 0; }
.drawer-body { overflow-y: auto; padding: 14px max(16px, env(safe-area-inset-right)) calc(env(safe-area-inset-bottom, 0px) + 20px) max(16px, env(safe-area-inset-left)); display: flex; flex-direction: column; gap: 14px; flex: 1; min-height: 0; }
.x { border: 0; background: var(--surface2); color: var(--ink); width: 40px; height: 40px; border-radius: 50%; font-size: 20px; cursor: pointer; flex: none; }
.results { position: fixed; z-index: 40; top: calc(env(safe-area-inset-top, 0px) + 60px); left: max(12px, env(safe-area-inset-left)); right: max(12px, env(safe-area-inset-right)); max-width: 760px; margin: 0 auto; max-height: 70vh; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 12px 16px; }
.results .hit { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 8px 0; border-top: 1px solid var(--line); cursor: pointer; color: var(--ink); }
.results .divider { margin-top: 10px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.toast { position: fixed; z-index: 60; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom, 0px) + 84px); background: var(--accent-fill); color: var(--accent-ink); padding: 10px 16px; border-radius: var(--r-sm); font-weight: 700; max-width: min(92vw, 520px); box-shadow: var(--shadow); }
.toast.bad { background: var(--bad-bg); color: var(--bad-ink); }
.drop { position: fixed; inset: 0; z-index: 70; background: var(--glass); display: grid; place-items: center; }
.drop div { border: 3px dashed var(--ink); border-radius: var(--r); padding: 40px; font: 600 20px var(--head); }
.dropzone { border: 2px dashed var(--line); border-radius: var(--r-sm); padding: 12px; text-align: center; color: var(--muted); font-size: 14px; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
