/* Socials: "Counsel" (light) + "Midnight" (dark), house-design §14, chosen 2026-11-23.
   Layout: header (brand, tabs, L/D/A) fixed at top; only #main scrolls, inside its own box.
   On a phone the tabs become a bottom bar. The page itself never scrolls (CLAUDE.global §3).
   Contrast (WCAG, measured by scripts/contrast.mjs in npm run check): see that file's table. */
:root {
  --bg: #f3f3ee; --surface: #ffffff; --surface-2: #f4f5f1; --line: #e3e4dd;
  --ink: #16203a; --muted: #5a6478;
  --accent: #0e7a5c; --accent-dark: #0b5e47; --btn-ink: #ffffff;
  --soft: #e7f1ec; --soft-ink: #0c5c46;
  --good: #12916e; --danger: #c0452f; --gold: #b0832a;
  --flag-bg: #fbf1dd; --flag-ink: #6e4f12; --block-bg: #f9e3de; --block-ink: #8f2f1f;
  --shadow: 0 6px 20px rgba(20, 27, 46, .07);
  --glass: rgba(243, 243, 238, .86);
  --r: 15px; --r-btn: 10px;
  --serif: "Iowan Old Style", "Source Serif 4", Georgia, serif;
  --sans: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, Menlo, Consolas, monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #12141c; --surface: #1b1e29; --surface-2: #232733; --line: #2a2e3d;
  --ink: #e9ebf4; --muted: #969bb0;
  --accent: #8f7ff2; --accent-dark: #b3a6ff; --btn-ink: #14161f;
  --soft: #262247; --soft-ink: #c9c0ff;
  --good: #37e0c8; --danger: #ff6b78; --gold: #e0b24d;
  --flag-bg: #3a2f14; --flag-ink: #f0cf7a; --block-bg: #3d1d22; --block-ink: #ffb0b8;
  --shadow: 0 10px 26px rgba(0, 0, 0, .42);
  --glass: rgba(18, 20, 28, .86);
  color-scheme: dark;
}
[hidden] { display: none !important; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.45 var(--sans); overflow: hidden; -webkit-text-size-adjust: 100%; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; margin: 0; text-wrap: balance; }
a { color: var(--accent); }
:root[data-theme="dark"] a { color: var(--accent-dark); }
.muted { color: var(--muted); }
button { font: inherit; }

/* Version badge: tiny, fixed, top-left inside the safe area. muted on bg = 5.6 light / 6.4 dark. */
.appver { position: fixed; z-index: 50; top: calc(env(safe-area-inset-top, 0px) + 1px); left: calc(env(safe-area-inset-left, 0px) + 6px);
  font: 500 9.5px/1.2 var(--mono); color: var(--muted); pointer-events: none; }
.appver.bad { color: var(--danger); }

/* ---------- PIN gate (team-manager/docs/pin-keypad-standard.md) ---------- */
.gate { height: 100%; display: grid; place-items: center; padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.gate-card { display: flex; flex-direction: column; align-items: center; gap: clamp(6px, 1.6vh, 12px); text-align: center; }
.gate-card h1 { font-size: clamp(24px, 4vh, 30px); }
.gate-sub { margin: 0; color: var(--muted); font-size: 15px; max-width: 30ch; }
.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; margin-top: clamp(4px, 1.5vh, 14px); }
.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, 2vh, 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: 600; 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); color: var(--btn-ink); }
.pin-pad button:disabled { opacity: .5; }
.pin-pad .pin-del { border: none; background: transparent; font-size: 24px; }

/* ---------- app shell ---------- */
.app { height: 100%; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 16px; padding: calc(env(safe-area-inset-top, 0px) + 12px) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 9px; font: 600 20px var(--serif); }
.tabs { display: flex; gap: 4px; margin-left: auto; }
.tabs button { position: relative; display: flex; align-items: center; gap: 7px; border: 0; background: transparent; color: var(--muted); font-weight: 600; font-size: 14px;
  padding: 8px 12px; border-radius: var(--r-btn); cursor: pointer; }
.tabs button svg { width: 19px; height: 19px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs button.on { background: var(--soft); color: var(--soft-ink); }
.tabs .badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: var(--btn-ink); font-size: 11px; line-height: 18px; text-align: center; }
.lda { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; }
.lda button { border: 0; background: transparent; color: var(--muted); font: 600 12px var(--sans); width: 28px; height: 26px; border-radius: 999px; cursor: pointer; }
.lda button.on { background: var(--ink); color: var(--bg); }

#main { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 18px max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left)); }
.view { display: none; max-width: 1400px; margin: 0 auto; }
.view.on { display: block; }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.view-head h2 { font-size: 24px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); gap: 14px; }

.btn { border-radius: var(--r-btn); padding: 9px 14px; font-weight: 600; font-size: 14px; border: 1px solid transparent; cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--btn-ink); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.small { padding: 6px 11px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn:focus-visible, .tabs button:focus-visible, .lda button:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px; min-width: 0; }

/* Empty state: a picture and one plain sentence about what will show up here. */
.empty { grid-column: 1 / -1; display: flex; gap: 22px; align-items: center; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--r); padding: 26px; }
.empty svg { flex: none; width: 112px; height: 112px; }
.empty h3 { font-size: 19px; margin-bottom: 6px; }
.empty p { margin: 0 0 6px; color: var(--muted); max-width: 62ch; }
.empty .steps { margin: 8px 0 0; padding-left: 20px; color: var(--ink); }
.empty .steps li { margin: 3px 0; }
.illo-a { fill: var(--soft); } .illo-b { fill: var(--accent); } .illo-c { fill: var(--surface-2); stroke: var(--line); } .illo-l { stroke: var(--muted); stroke-width: 3; stroke-linecap: round; fill: none; }

/* ---------- settings ---------- */
.settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 12px; align-items: start; }
.settings details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 4px 16px; min-width: 0; }
.settings details[open] { padding-bottom: 14px; }
.settings summary { font: 600 16px var(--serif); padding: 12px 0; cursor: pointer; list-style: none; display: flex; justify-content: space-between; }
.settings summary::-webkit-details-marker { display: none; }
.settings summary::after { content: "+"; color: var(--muted); font-family: var(--sans); }
.settings details[open] summary::after { content: "\2212"; }
.settings p { margin: 0 0 10px; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat { background: var(--surface-2); border-radius: 11px; padding: 10px 12px; }
.stat b { display: block; font: 600 22px var(--serif); font-variant-numeric: tabular-nums; }
.stat span { font-size: 12.5px; color: var(--muted); }
.log { max-height: 320px; overflow-y: auto; display: flex; flex-direction: column; }
.log .row { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.log .row time { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.log .row .n { grid-column: 2; color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.log .row.bad b { color: var(--danger); }
.apis { display: flex; flex-direction: column; gap: 10px; }
.apis .api { border-bottom: 1px solid var(--line); padding-bottom: 9px; font-size: 13.5px; }
.apis .api b { display: block; }
.apis .api span { color: var(--muted); }
.copyrow { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-weight: 600; overflow-wrap: anywhere; }
.guard-form { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.guard-form input, .guard-form select, .appearance input, .appearance select { font: 16px var(--sans); color: var(--ink); background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; min-width: 0; }
.guard-form input { flex: 1 1 180px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--soft); color: var(--soft-ink); border-radius: 999px; padding: 4px 6px 4px 11px; font-size: 13px; font-weight: 600; }
.chip small { font-weight: 500; opacity: .85; }
.chip button { border: 0; background: transparent; color: inherit; cursor: pointer; font-size: 15px; line-height: 1; padding: 2px 5px; }
.appearance { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.appearance label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }

.toast { position: fixed; z-index: 60; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom, 0px) + 84px); background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 14px; box-shadow: var(--shadow); max-width: min(92vw, 520px); }

/* ---------- phone: tabs become a bottom bar; chrome stays put, only #main moves ---------- */
@media (max-width: 760px) {
  .topbar { padding-bottom: 9px; }
  .tabs { position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; margin: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 0;
    background: var(--glass); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); border-top: 1px solid var(--line);
    padding: 4px max(6px, env(safe-area-inset-right)) calc(env(safe-area-inset-bottom, 0px) + 4px) max(6px, env(safe-area-inset-left)); }
  .tabs button { flex-direction: column; gap: 2px; font-size: 11px; padding: 6px 2px; border-radius: 10px; }
  .tabs button.on { background: transparent; color: var(--accent); }
  :root[data-theme="dark"] .tabs button.on { color: var(--accent-dark); }
  .tabs .badge { position: absolute; top: 2px; left: calc(50% + 6px); }
  .lda { margin-left: auto; }
  #main { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 82px); }
  .empty { flex-direction: column; text-align: left; align-items: flex-start; padding: 20px; }
  .empty svg { width: 84px; height: 84px; }
  .view-head h2 { font-size: 21px; }
}
@media (prefers-reduced-motion: reduce) { .pin-gate.busy .pin-dots span.on, .pin-gate.bad .pin-dots { animation: none; } }
