/* ─────────────────────────────────────────────────────────────────────────
   dta.css — URGA shared design system (SINGLE SOURCE OF TRUTH).
   Served at /system/dta.css. Every surface links this; page-specific CSS
   lives in each page's own <style> block. Edit tokens/chrome HERE, once.
   ───────────────────────────────────────────────────────────────────────── */

/* ─── design tokens ─── */
:root {
  --bg: #FBFAF7; --paper: #FFFFFF; --ink: #0E1116; --soft: #2A2F37;
  --mute: #5A636E; --faint: #8B92A1; --hair: rgba(14,17,22,0.07);
  --rule: rgba(14,17,22,0.22); --grid: rgba(14,17,22,0.12);
  --accent: #B2201A; --up: #0E8A4A; --blue: #2E5C8A;
  --stale: #8A6E1A;   /* amber — overdue primary series ("as of" cue, contract B) */
  /* multi-series (compare) */
  --s0:#B2201A; --s1:#2E5C8A; --s2:#0E8A4A; --s3:#8A6E1A; --s4:#6B4FA0; --s5:#0E1116;
  /* map */
  --land: #ECE7DC; --landstroke: rgba(14,17,22,0.30); --nodata: #D7DBE0;
  --serif: 'STIX Two Text', Georgia, serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
}
:root[data-theme="dark"] {
  --bg: #0E1116; --paper: #161B22; --ink: #ECEAE3; --soft: #C7C3B6;
  --mute: #8B92A1; --faint: #5A636E; --hair: rgba(236,234,227,0.09);
  --rule: rgba(236,234,227,0.20); --grid: rgba(236,234,227,0.12);
  --accent: #F2675C; --up: #5FE08D; --blue: #5B9BD5;
  --stale: #D6B656;   /* amber — overdue primary series ("as of" cue, contract B) */
  --s0:#F2675C; --s1:#5B9BD5; --s2:#5FE08D; --s3:#D6B656; --s4:#B79CE0; --s5:#ECEAE3;
  --land: #1C222B; --landstroke: rgba(236,234,227,0.28); --nodata: #2A313B;
}

/* ─── base ─── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
/* the `hidden` attribute must always win: an author display:flex/grid/block rule
   otherwise silently beats the UA [hidden]{display:none} (ANALYST 2026-06-03 — a
   hidden-but-display:flex camera button rendered DEAD on iOS/FF). Guard the whole
   class, not one element. */
[hidden] { display: none !important; }
body { background: var(--bg); color: var(--ink); font-family: var(--mono); font-size: 12.5px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }

/* ─── language reveal (EN/MN dual-span; html[data-lang] flips it) ─── */
[data-lang="en"] .mn-only { display: none !important; }
[data-lang="mn"] .en-only { display: none !important; }

/* ─── chrome / topbar (identical on every surface) ─── */
.chrome { position: sticky; top: 0; z-index: 50; min-height: 36px; display: flex; align-items: center; gap: 10px; padding: 0 14px; border-bottom: 0.5px solid var(--rule); background: var(--bg); font-family: var(--mono); font-size: 11px; }
/* mobile: wrap the bar instead of forcing whole-page horizontal scroll, and
   enlarge nav tap targets (ANALYST: 327px bar overflowed to 582px, nav 14px tall). */
@media (max-width: 720px) {
  .chrome { flex-wrap: wrap; padding-top: 3px; padding-bottom: 3px; row-gap: 0; }
  .chrome .ws a, .chrome .ws.now { display: inline-block; padding: 9px 3px; }
}
.chrome .brand { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; letter-spacing: 0.06em; color: var(--ink); flex-shrink: 0; }
.chrome .brand svg { transition: transform 0.4s cubic-bezier(0.2,0.7,0.3,1); }
.chrome .brand:hover svg { transform: rotate(45deg); }
/* full name beside the DTA wordmark (BOB) — muted tagline, hidden on the tight
   mobile bar (the acronym + logo carry the brand there). */
.chrome .brand .full { font-size: 0.82em; font-weight: 400; letter-spacing: 0.01em; color: var(--mute); white-space: nowrap; }
@media (max-width: 720px) { .chrome .brand .full { display: none; } }
/* brand mark: theme-aware red dot that eases toward the cursor when near
   (compass-needle feel, wired in dta.js) + a slow radar PULSE ping from centre.
   dot was hardcoded #B2201A — invisible on the dark bg; var(--accent) brightens it. */
.chrome .brand .brand-dot { fill: var(--accent); transition: transform 0.18s cubic-bezier(0.2,0.7,0.3,1); }
.chrome .brand .brand-ping { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; transform-box: fill-box; transform-origin: center; opacity: 0; }
@media (prefers-reduced-motion: no-preference) {
  .chrome .brand .brand-ping { animation: brand-ping 3.4s ease-out infinite; }
}
@keyframes brand-ping { 0% { transform: scale(1); opacity: 0.5; } 70% { transform: scale(4.6); opacity: 0; } 100% { transform: scale(4.6); opacity: 0; } }
.chrome .sep { color: var(--faint); flex-shrink: 0; }
.chrome .ws { color: var(--mute); white-space: nowrap; }
.chrome .ws a { color: var(--mute); }
.chrome .ws a:hover { color: var(--accent); }
.chrome .ws.now { color: var(--ink); }
.chrome .prompt { color: var(--accent); font-weight: 700; font-size: 13px; flex-shrink: 0; }
.chrome .cmd-input { flex: 1; min-width: 90px; font-family: var(--mono); font-size: 12px; color: var(--ink); background: transparent; border: 0; outline: none; padding: 0; caret-color: var(--accent); }
.chrome .cmd-input::placeholder { color: var(--faint); }
.chrome .crumb { color: var(--mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.chrome .crumb b { color: var(--ink); }
.chrome .right { margin-left: auto; display: flex; gap: 12px; align-items: center; color: var(--mute); flex-shrink: 0; }
.chrome .clock { color: var(--soft); font-variant-numeric: tabular-nums; }

/* ─── theme + language toggles (inline, in the chrome .right cluster) ─── */
.lang-toggle, .dt-toggle { font-family: var(--mono); color: var(--mute); background: transparent; border: 0; cursor: pointer; line-height: 1; white-space: nowrap; flex-shrink: 0; }
.lang-toggle { font-size: 10px; letter-spacing: 0.08em; padding: 4px 4px; }
.dt-toggle { font-size: 14px; padding: 2px 2px; }
.lang-toggle:hover, .lang-toggle:focus, .dt-toggle:hover, .dt-toggle:focus { color: var(--accent); }
.lang-toggle .seg { color: var(--faint); }
.lang-toggle .seg-sep { color: var(--faint); margin: 0 1px; }
[data-lang="en"] .lang-toggle .seg-en, [data-lang="mn"] .lang-toggle .seg-mn { color: var(--ink); font-weight: 600; }
@media (max-width: 800px) { .lang-toggle, .dt-toggle { padding: 6px 5px; } }
/* ─── mobile bottom tab bar (TIER-1: consistent thumb-nav; SCAN = QR verb) ─── */
.botbar { display: none; }
@media (max-width: 720px) {
  .botbar {
    display: flex; justify-content: space-around; align-items: stretch;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    background: var(--bg); border-top: 0.5px solid var(--rule);
    padding-bottom: env(safe-area-inset-bottom); font-family: var(--mono);
  }
  body { padding-bottom: calc(58px + env(safe-area-inset-bottom)); }
}
.botbar .bb-item { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 3px; flex: 1; min-width: 0; background: transparent; border: 0; cursor: pointer; color: var(--mute); padding: 7px 2px 5px; text-decoration: none; }
.botbar .bb-item.now { color: var(--accent); }
.botbar .bb-item:active { color: var(--ink); }
.botbar .bb-ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.botbar .bb-lbl { font-size: 9px; letter-spacing: 0.04em; }

/* scan / verify bottom sheet */
.scansheet[hidden] { display: none; }
.scansheet { position: fixed; inset: 0; z-index: 70; display: flex; align-items: flex-end; }
.scansheet .ss-back { position: absolute; inset: 0; background: rgba(14,17,22,0.45); }
.scansheet .ss-panel { position: relative; width: 100%; background: var(--paper); border-radius: 14px 14px 0 0; padding: 16px 16px calc(20px + env(safe-area-inset-bottom)); box-shadow: 0 -4px 24px rgba(14,17,22,0.22); animation: ss-up 0.22s ease-out; }
@keyframes ss-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.scansheet .ss-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-family: var(--serif); font-size: 16px; color: var(--ink); }
.scansheet .ss-x { background: transparent; border: 0; color: var(--mute); font-size: 16px; cursor: pointer; padding: 4px 6px; }
.scansheet .ss-note { font-size: 11.5px; color: var(--mute); line-height: 1.55; margin: 0 0 14px; }
.scansheet .ss-paste { display: flex; gap: 8px; }
.scansheet .ss-paste input { flex: 1; min-width: 0; font-family: var(--mono); font-size: 13px; color: var(--ink); background: var(--bg); border: 1px solid var(--rule); border-radius: 8px; padding: 10px 12px; outline: none; }
.scansheet .ss-paste input:focus { border-color: var(--accent); }
.scansheet .ss-paste button { font-family: var(--mono); font-size: 13px; color: #fff; background: var(--accent); border: 0; border-radius: 8px; padding: 10px 14px; cursor: pointer; white-space: nowrap; }
.scansheet .ss-err { color: var(--accent); font-size: 11px; margin-top: 8px; }
.scansheet .ss-cam-btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; font-family: var(--mono); font-size: 13px; color: #fff; background: var(--accent); border: 0; border-radius: 8px; padding: 12px; cursor: pointer; margin-bottom: 12px; }
.scansheet .ss-cam-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.scansheet .ss-cam { position: relative; width: 100%; aspect-ratio: 4 / 3; background: #000; border-radius: 10px; overflow: hidden; margin-bottom: 12px; }
.scansheet .ss-cam video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scansheet .ss-ret { position: absolute; inset: 16% 20%; border: 2px solid rgba(255,255,255,0.9); border-radius: 12px; box-shadow: 0 0 0 100vmax rgba(0,0,0,0.28); }
.scansheet .ss-or { text-align: center; font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); margin-bottom: 10px; }
@media (min-width: 560px) { .scansheet { align-items: center; justify-content: center; } .scansheet .ss-panel { max-width: 420px; border-radius: 14px; } }
@media (prefers-reduced-motion: reduce) { .scansheet .ss-panel { animation: none; } }

/* ─── backtick console — live signed-obs feed (HLDS-style, always-dark) ─── */
.console[hidden] { display: none; }
.console { position: fixed; left: 0; right: 0; bottom: 0; z-index: 80; height: 46vh; max-height: 460px; display: flex; flex-direction: column; background: #0E1116; color: #ECEAE3; border-top: 2px solid var(--accent); box-shadow: 0 -8px 28px rgba(0,0,0,0.4); font-family: var(--mono); animation: con-up 0.18s ease-out; }
@keyframes con-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.console .con-head { display: flex; align-items: center; gap: 12px; padding: 7px 14px; border-bottom: 1px solid rgba(255,255,255,0.14); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; flex-shrink: 0; }
.console .con-title { color: #ECEAE3; font-weight: 600; }
.console .con-health { color: #5FE08D; letter-spacing: 0.03em; text-transform: none; }
.console .con-health .dn { color: #F2675C; }
.console .con-hint { color: rgba(255,255,255,0.4); font-size: 9px; letter-spacing: 0.03em; text-transform: none; }
.console .con-x { background: transparent; border: 0; color: rgba(255,255,255,0.55); cursor: pointer; font-size: 13px; padding: 2px 4px; }
.console .con-x:hover { color: #ECEAE3; }
.console .con-log { flex: 1; overflow-y: auto; padding: 8px 14px 14px; font-size: 11px; line-height: 1.7; }
.console .con-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: rgba(236,234,227,0.82); }
.console .con-line .t { color: rgba(255,255,255,0.38); }
.console .con-line .op { color: #5B9BD5; }
.console .con-line .val { color: #5FE08D; font-weight: 600; }
.console .con-line a { color: #F2675C; border: 0; }
.console .con-line a:hover { text-decoration: underline; }
.console .con-empty { color: rgba(255,255,255,0.4); font-size: 11px; padding: 6px 0; }

/* ─── popup-window system (the "popwindow") — reskinned from CSCLEAR.
   Desktop: floating draggable window. Mobile (≤700px): full-screen bottom
   sheet, swipe-down to dismiss. See web/INTERACTION.md §L2.2. ─── */
#win-layer { position: fixed; inset: 0; z-index: 200; pointer-events: none; }
#win-layer .win { pointer-events: auto; }
.win {
  position: fixed; display: flex; flex-direction: column; overflow: hidden;
  min-width: 280px; min-height: 160px; max-width: 96vw; resize: both;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--rule); border-left: 2px solid var(--accent);
  box-shadow: 0 10px 40px rgba(14,17,22,0.18);
}
:root[data-theme="dark"] .win { box-shadow: 0 12px 48px rgba(0,0,0,0.55); }
.win-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  height: 30px; flex-shrink: 0; padding: 0 5px 0 11px; cursor: move; user-select: none;
  background: var(--bg); border-bottom: 1px solid var(--rule);
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
}
.win-title { color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.win-close { color: var(--mute); cursor: pointer; font-size: 14px; line-height: 1; padding: 4px 7px; border-radius: 2px; }
.win-close:hover, .win-close:focus-visible { color: var(--accent); background: var(--hair); outline: none; }
.win-body { flex: 1; overflow-y: auto; padding: 13px 15px; min-height: 0; font-family: var(--mono); font-size: 12px; }
.win-body::-webkit-scrollbar { width: 6px; }
.win-body::-webkit-scrollbar-thumb { background: var(--hair); border-radius: 3px; }
@media (max-width: 700px) {
  .win {
    left: 0 !important; right: 0; top: auto !important; bottom: 0;
    width: 100vw !important; max-width: 100vw; height: 86vh !important;
    border-left: 0; border-right: 0; border-bottom: 0; border-radius: 11px 11px 0 0;
    resize: none; transition: transform 0.18s ease;
  }
  .win-bar { height: 42px; padding-top: 9px; position: relative; font-size: 11px; }
  .win-bar::before { content: ''; position: absolute; top: 5px; left: 50%; transform: translateX(-50%); width: 38px; height: 4px; border-radius: 2px; background: var(--rule); }
  .win-close { font-size: 20px; padding: 6px 11px; }
  .win-body { padding: 12px 14px; font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) { .win { transition: none; } }

/* ─── support / buy-a-coffee popwindow body ─── */
.coffee { text-align: center; font-family: var(--mono); }
.coffee-qr { width: 232px; height: 232px; max-width: 100%; display: block; margin: 2px auto 0; background: #fff; padding: 9px; border: 0.5px solid var(--hair); border-radius: 4px; image-rendering: pixelated; }
.coffee-amt { font-family: var(--serif); font-weight: 600; font-size: 26px; color: var(--ink); margin: 13px 0 2px; font-variant-numeric: tabular-nums; }
.coffee-lead { font-size: 12px; color: var(--ink); margin: 6px 4px 0; line-height: 1.5; }
.coffee-note { font-size: 10.5px; color: var(--mute); margin: 10px 4px 0; line-height: 1.55; }

/* ─── nav menu — the expandable menu (replaces the inline "listed buttons");
   right-side drawer on desktop, bottom sheet on mobile. Opened from the chrome
   ☰ and the botbar Menu. ─── */
.menu-btn { background: none; border: 0; color: var(--mute); cursor: pointer; padding: 4px 6px; line-height: 0; flex-shrink: 0; }
.menu-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.menu-btn:hover { color: var(--accent); }
.navmenu { position: fixed; inset: 0; z-index: 90; display: flex; justify-content: flex-end; }
.navmenu[hidden] { display: none; }
.nm-back { position: absolute; inset: 0; background: rgba(14,17,22,0.42); animation: nm-fade 0.18s ease; }
:root[data-theme="dark"] .nm-back { background: rgba(0,0,0,0.55); }
@keyframes nm-fade { from { opacity: 0; } to { opacity: 1; } }
.nm-panel { position: relative; width: min(300px, 86vw); height: 100%; display: flex; flex-direction: column; background: var(--bg); border-left: 1px solid var(--rule); box-shadow: -10px 0 40px rgba(14,17,22,0.18); padding: 12px 0 14px; animation: nm-in 0.2s cubic-bezier(0.2,0.7,0.3,1); }
@keyframes nm-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.nm-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 16px 12px; border-bottom: 0.5px solid var(--hair); }
.nm-head .wm { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.06em; color: var(--mute); }
.nm-x { background: none; border: 0; color: var(--mute); font-size: 17px; cursor: pointer; padding: 2px 8px; line-height: 1; }
.nm-x:hover { color: var(--accent); }
.nm-links { display: flex; flex-direction: column; padding: 8px 0; }
.nm-links a { padding: 11px 16px; color: var(--ink); font-family: var(--mono); font-size: 13px; letter-spacing: 0.04em; text-transform: capitalize; border-left: 2px solid transparent; }
.nm-links a:hover { background: var(--hair); color: var(--accent); border-left-color: var(--accent); }
.nm-links a.now { color: var(--accent); border-left-color: var(--accent); }
.nm-actions { margin-top: auto; padding: 12px 16px 2px; border-top: 0.5px solid var(--hair); }
.nm-act { display: flex; align-items: center; gap: 9px; width: 100%; background: none; border: 0; color: var(--mute); font-family: var(--mono); font-size: 12px; letter-spacing: 0.04em; cursor: pointer; padding: 8px 0; text-align: left; }
.nm-act:hover { color: var(--accent); }
.nm-act svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; flex-shrink: 0; }
@media (max-width: 720px) {
  .navmenu { justify-content: stretch; align-items: flex-end; }
  .nm-panel { width: 100%; height: auto; max-height: 82vh; border-left: 0; border-radius: 14px 14px 0 0; padding-top: 16px; padding-bottom: calc(14px + env(safe-area-inset-bottom)); animation: nm-up 0.2s cubic-bezier(0.2,0.7,0.3,1); }
  .nm-head { position: relative; }
  .nm-head::before { content: ''; position: absolute; top: -8px; left: 50%; transform: translateX(-50%); width: 38px; height: 4px; border-radius: 2px; background: var(--rule); }
  .nm-links a { padding: 13px 18px; font-size: 14px; }
}
@keyframes nm-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

@media print { .chrome, .dt-toggle, .lang-toggle, .botbar, .scansheet, .console, #win-layer, .navmenu, .menu-btn { display: none; } }
