/* ============================================================
   phone-RTA — editorial light theme
   ============================================================
   Design tokens follow the foodfix system: warm off-white page,
   near-black ink, single orange accent, two fonts (Inter + Instrument
   Serif italic), tracking-heavy editorial eyebrows instead of
   chip-style labels. Tints are intentionally limited so the "real"
   information (POT odds, decision, EV gap, cost) reads as the bold
   element on a calm background — not as one more colored chip in a
   wall of chips.
   ============================================================ */
:root {
  /* Brand — single accent */
  --orange:        #ff7a1a;
  --orange-hover:  #ff9040;
  --orange-deep:   #cc5200;
  --orange-soft:   #ffe7d6;
  --orange-ink:    #5c2800;

  /* Warm neutrals (NOT the cold #fff/#e5e5e5) */
  --bg:            #FAFAF7;
  --bg-alt:        #F2F0EB;
  --surface:       #FFFFFF;
  --surface-2:     #F6F5F1;
  --ink:           #0E0E0C;
  --ink-2:         #3A3A38;
  --ink-muted:     #8A8A84;
  --hairline:        rgba(14, 14, 12, 0.08);
  --hairline-strong: rgba(14, 14, 12, 0.16);

  /* Radii — wide spread, no "medium" */
  --r-xs: 6px; --r-sm: 10px; --r-md: 16px;
  --r-lg: 24px; --r-xl: 32px; --r-full: 999px;

  /* Soft, ink-tinted shadows (NOT pure black drop shadows) */
  --sh-1: 0 1px 2px  rgba(14,14,12,.06);
  --sh-2: 0 8px 24px rgba(14,14,12,.08);
  --sh-3: 0 24px 60px rgba(14,14,12,.12);

  /* Motion */
  --ease-out:    cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --d-fast: 180ms; --d-base: 280ms; --d-slow: 520ms;

  /* Typography duet */
  --font-sans:  "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-serif: "Instrument Serif", Georgia, "Times New Roman", serif;

  /* ----------- Compatibility shims for legacy JS ---------------
     The frontend JS sets inline ``style.color = 'var(--xxx)'`` for
     dynamic actions / states. We map the legacy names onto the new
     palette so the renderer keeps working without touching JS. */
  --fg:        var(--ink);
  --fg-dim:    var(--ink-muted);    /* used by JS for FOLD action — softly muted */
  --fg-mute:   var(--ink-muted);
  --accent:    var(--orange);       /* used by JS for RAISE / BET / ALL_IN — emotional accent */
  --accent-2:  var(--orange-deep);
  --warn:      var(--ink);          /* used by JS for CHECK / CALL — neutral, decisive */
  --danger:    #d23a2a;             /* used for hallucination / network errors */
  --info:      #2563d6;             /* used very rarely; kept for completeness */
  --border:        var(--hairline);
  --border-strong: var(--hairline-strong);
  --bg-card:   var(--surface);
  --bg-tab:    var(--surface-2);
  --felt:      #245138;             /* SVG felt fill — slightly desaturated */
  --felt-edge: #143222;
  --row-gap:   8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font-sans);
  font-feature-settings: "ss01", "cv01", "cv11";
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

body { font-size: 14px; }

main#app {
  display: grid;
  grid-template-rows: auto auto auto auto auto auto 1fr;
  gap: var(--row-gap);
  padding: 10px max(10px, env(safe-area-inset-right))
            max(10px, env(safe-area-inset-bottom))
            max(10px, env(safe-area-inset-left));
  padding-top: max(10px, env(safe-area-inset-top));
  height: 100%;
  max-width: 980px;
  margin: 0 auto;
}

/* ===========================================================
   TYPOGRAPHY · editorial duo
   =========================================================== */
h1, h2, h3, h4 {
  margin: 0;
  font-family: var(--font-sans);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
}

/* The single italic-serif accent — applied as `<em class="title-accent">`
   inside any heading. One word, sometimes two. The whole reason this
   project doesn't look like a vibe-coded template is this rule. */
.title-accent,
em.title-accent {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  color: var(--orange);
  letter-spacing: -0.01em;
}

/* Editorial eyebrow — replaces the old SANDBOX pill / .badge.
   No fill, no border, no shadow, just a 28×1 px orange rule and
   tracking 0.22em. The label *is* the signal — that's the point. */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  font-family: var(--font-sans);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-2);
  white-space: nowrap;
}
.eyebrow::before {
  content: "";
  width: 24px; height: 1px; flex: none;
  background: var(--orange);
  opacity: 0.95;
}
.eyebrow.on-dark    { color: rgba(255,255,255,0.78); }

/* ===========================================================
   HEADER
   =========================================================== */
header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0 6px;
}
.title { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
header h1 {
  font-size: clamp(20px, 4.6vw, 28px);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.025em;
  color: var(--ink);
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  white-space: nowrap;
}
header h1 .muted-dot { color: var(--ink-muted); font-weight: 400; }
header h1 .title-accent { font-size: 1.05em; }

/* legacy ``.badge`` left as zero-styled fallback — we don't render it
   anymore but keep it null so any future use doesn't pollute layout */
.badge { display: none !important; }

.right-ctrls {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.lang-switch {
  display: inline-flex;
  height: 32px;
  background: var(--surface);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-full);
  overflow: hidden;
  flex: none;
}
.lang-switch button {
  background: transparent;
  color: var(--ink-muted);
  border: 0;
  font-size: 11px;
  font-weight: 600;
  padding: 0 14px;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: color var(--d-fast) var(--ease-out),
              background var(--d-fast) var(--ease-out);
}
.lang-switch button.active {
  background: var(--ink);
  color: var(--surface);
}
.status-pill {
  display: inline-flex; align-items: center;
  height: 32px;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--ink-2);
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-full);
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===========================================================
   GENERIC CARD + SECTION HEADER ("eyebrow inside cards")
   =========================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: 14px 16px;
  box-shadow: var(--sh-1);
}
.hdr {
  /* In-card section heading. Same editorial-eyebrow rule but with a
     mini variant of the orange overline — one in every section so
     the eye groups fields at a glance. */
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-family: var(--font-sans);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 10px;
}
.hdr::before {
  content: "";
  width: 18px; height: 1px; flex: none;
  background: var(--orange);
  opacity: 0.95;
}
.hdr > span:first-child { min-width: 0; }
.mini {
  font-size: 10.5px;
  color: var(--ink-muted);
  letter-spacing: 0.02em;
  text-transform: none;
  font-weight: 400;
  margin-left: auto;
}

/* ===========================================================
   CAMERA STRIP
   =========================================================== */
#cam-strip {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 10px;
  height: 72px;
}
#cam-thumb {
  position: relative;
  background: var(--ink);
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--hairline-strong);
}
#video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.cam-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(14,14,12,0.62);
  color: rgba(255,255,255,0.75);
  font-size: 10px;
  text-align: center;
  padding: 4px;
  text-transform: uppercase;
  letter-spacing: 0.22em;
}
#cam-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
#cam-buttons button {
  height: 100%;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  padding: 0 10px;
  transition: transform var(--d-fast) var(--ease-out),
              border-color var(--d-fast) var(--ease-out),
              background var(--d-fast) var(--ease-out),
              box-shadow var(--d-fast) var(--ease-out);
}
#cam-buttons button:hover {
  transform: translateY(-1px);
  border-color: var(--ink);
}
#cam-buttons button#btn-snap {
  background: var(--orange);
  color: var(--surface);
  border-color: transparent;
  box-shadow: 0 10px 24px rgba(255, 122, 26, 0.32);
}
#cam-buttons button#btn-snap:hover {
  background: var(--orange-hover);
  box-shadow: 0 14px 32px rgba(255, 122, 26, 0.40);
}
#cam-buttons button:disabled {
  opacity: 0.35;
  transform: none;
  box-shadow: none;
  cursor: not-allowed;
}

/* ===========================================================
   DECISION PANEL
   =========================================================== */
#decision-panel {
  padding: 16px 18px 14px;
  position: relative;
  border-top: 2px solid var(--orange);
  border-radius: var(--r-md);
}
.dec-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: flex-start;
}
.dec-left { min-width: 0; }
.dec-right {
  text-align: right;
  min-width: 0;
  max-width: 55%;
  display: flex; flex-direction: column; gap: 4px;
}
.dec-left .hdr { margin-bottom: 6px; }

#action-big {
  font-family: var(--font-sans);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 0.98;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  color: var(--ink);
}
#action-big .act-name {
  font-size: clamp(34px, 9vw, 56px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: lowercase;     /* "raise" reads warmer than "RAISE" */
}
#action-big .act-name.long {
  font-size: clamp(26px, 7vw, 44px);
}
#action-big .act-size {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  letter-spacing: -0.01em;
  font-size: clamp(18px, 4.5vw, 26px);
  color: var(--orange);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#action-big .act-size:empty { display: none; }

.action-sub {
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1.4;
  letter-spacing: -0.005em;
}
.action-meta {
  font-size: 10.5px;
  line-height: 1.45;
  color: var(--ink-muted);
  white-space: normal;
  word-break: break-word;
  letter-spacing: 0.01em;
}
.action-cost {
  font-size: 10.5px;
  line-height: 1.4;
  margin-top: 4px;
  color: var(--ink-muted);
  letter-spacing: 0.01em;
}
.action-cost b { color: var(--ink); font-weight: 600; }
.action-cost.warn b { color: var(--danger); }
.action-cost.high b { color: var(--orange); }

/* ===========================================================
   COST BREAKDOWN TABLE
   =========================================================== */
.cost-table {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 0 12px;
  font-size: 12px;
  line-height: 1.5;
  align-items: center;
}
.cost-table .row { display: contents; }
.cost-table .row > * {
  padding: 6px 4px;
  border-bottom: 1px solid var(--hairline);
}
.cost-table .row.head > * {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
  border-bottom: 1px solid var(--hairline-strong);
}
.cost-table .num { font-variant-numeric: tabular-nums; text-align: right; }
.cost-table .pct { color: var(--ink-muted); font-variant-numeric: tabular-nums; text-align: right; }
.cost-table .role-tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-2);
  margin-left: 6px;
}
.cost-table .role-primary     { background: var(--orange-soft); color: var(--orange-ink); border-color: rgba(255,122,26,.2); }
.cost-table .role-shadow      { background: rgba(38,99,214,.10); color: #1d4faa;   border-color: rgba(38,99,214,.18); }
.cost-table .role-fallback    { background: rgba(184,95,0,.10);  color: #8b4500;   border-color: rgba(184,95,0,.18); }
.cost-table .role-high_stakes { background: rgba(210,58,42,.10); color: #a32616;   border-color: rgba(210,58,42,.20); }
.cost-table .role-hud         { background: rgba(120,75,180,.10); color: #533a82;  border-color: rgba(120,75,180,.20); }
.cost-table .role-other       { background: var(--surface-2); }

/* ===========================================================
   TABLE CLONE (SVG)
   =========================================================== */
#table-clone { padding: 14px 16px; }
#table-svg-wrap { position: relative; margin-top: 6px; }
#table-svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 240px;
  border-radius: var(--r-md);
  background: var(--surface-2);
}
#table-empty {
  text-align: center;
  font-size: 12px;
  padding: 36px 12px;
  color: var(--ink-muted);
  letter-spacing: 0.02em;
}
.hidden { display: none !important; }

.seat-bg {
  fill: var(--surface);
  stroke: var(--hairline-strong);
  stroke-width: 1;
}
.seat-bg.in-hand { stroke: var(--ink-2); stroke-width: 1.2; }
.seat-bg.folded  { fill: var(--bg-alt); opacity: 0.55; }
.seat-bg.hero    { stroke: var(--orange); stroke-width: 2; fill: var(--orange-soft); }
.seat-name  { fill: var(--ink); font-size: 8px; font-weight: 600; }
.seat-stack { fill: var(--ink-muted); font-size: 7px; }
.seat-pos   { fill: var(--orange-deep); font-size: 7px; font-weight: 700; letter-spacing: 0.06em; }
.seat-bet   { fill: var(--orange-ink); font-size: 8px; font-weight: 700; }
.seat-decision {
  fill: var(--orange);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.seat-hud {
  fill: var(--ink); font-size: 6.5px; font-weight: 600; letter-spacing: -0.02em;
}
.seat-hud-label {
  fill: var(--ink-muted); font-size: 5.2px; font-weight: 700; letter-spacing: 0.06em;
}
.seat-hud-row.applied .seat-hud { fill: var(--orange); }
.seat-applied-dot {
  fill: var(--orange);
  stroke: var(--surface);
  stroke-width: 0.6;
}
.seat-bg.clickable { cursor: pointer; transition: stroke var(--d-fast); }
.seat-bg.clickable:hover { stroke: var(--orange); stroke-width: 1.6; }
.seat-bg.has-override {
  stroke: var(--orange); stroke-width: 1.4;
  filter: drop-shadow(0 0 3px rgba(255,122,26,.35));
}
.seat-decision.tight { font-size: 7px; }
.seat-decision.fold-color { fill: var(--ink-muted); }
.seat-decision.warn-color { fill: var(--warn); }
.pot-label {
  fill: #FFFFFF; font-size: 10px; font-weight: 600; letter-spacing: 0.06em;
}
.card-rect { stroke: var(--hairline-strong); stroke-width: 0.6; rx: 2; }
.card-text {
  font-size: 9px; font-weight: 700;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.card-back { fill: #1f2a52; }

/* ===========================================================
   SEAT MODAL (HUD upload)
   =========================================================== */
.seat-modal {
  position: fixed;
  inset: 0;
  background: rgba(14,14,12,0.55);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  padding: 16px;
}
.seat-modal.hidden { display: none; }
.seat-modal-box {
  background: var(--surface);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-lg);
  width: min(380px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  padding: 18px 18px 16px;
  box-shadow: var(--sh-3);
}
.seat-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 14px; font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 12px;
}
.seat-modal-head .mini-btn {
  background: transparent;
  border: 1px solid var(--hairline-strong);
  color: var(--ink);
  font-size: 18px; line-height: 1;
  padding: 0; width: 28px; height: 28px;
  border-radius: var(--r-full);
}
.seat-modal-meta {
  display: flex; flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  margin-bottom: 12px;
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: var(--r-sm);
}
.seat-modal-meta input {
  background: var(--surface);
  border: 1px solid var(--hairline-strong);
  color: var(--ink);
  border-radius: var(--r-xs);
  padding: 4px 8px;
  font-size: 12px;
  width: 130px;
  font-family: inherit;
}
.seat-modal-meta .known-badge {
  background: var(--orange);
  color: var(--surface);
  font-weight: 600;
  font-size: 10.5px;
  padding: 2px 10px;
  border-radius: var(--r-full);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.seat-modal-meta .known-badge.hidden { display: none; }
.seat-modal-section { margin-top: 14px; }

/* ===========================================================
   CONTROLS (mode / realism / persona / period)
   =========================================================== */
#controls {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 80px;
  gap: 8px;
}
.mode {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 9.5px;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-weight: 600;
}
.mode > span:first-child {
  padding-left: 2px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.mode .hint {
  font-size: 9.5px;
  color: var(--orange);
  letter-spacing: 0;
  text-transform: none;
  font-weight: 400;
  cursor: help;
}
input[type="number"]:disabled,
select:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
select, input[type="number"], input[type="text"], input[type="file"] {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--hairline-strong);
  padding: 8px 10px;
  border-radius: var(--r-sm);
  font-size: 12px;
  font-family: inherit;
  width: 100%;
  min-width: 0;
  height: 36px;
  letter-spacing: -0.005em;
  transition: border-color var(--d-fast) var(--ease-out);
}
select:focus, input[type="number"]:focus,
input[type="text"]:focus, input[type="file"]:focus {
  outline: none;
  border-color: var(--ink);
}
input[type="file"] {
  padding: 6px 8px;
  cursor: pointer;
}
input[type="file"]::-webkit-file-upload-button {
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--hairline);
  padding: 4px 10px;
  border-radius: var(--r-xs);
  font-size: 11px;
  margin-right: 8px;
  cursor: pointer;
}

/* ===========================================================
   TABS
   =========================================================== */
#tabs {
  display: flex;
  gap: 2px;
  padding-bottom: 0;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--hairline);
}
#tabs::-webkit-scrollbar { display: none; }
.tab {
  background: transparent;
  color: var(--ink-muted);
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  letter-spacing: -0.005em;
  transition: color var(--d-fast) var(--ease-out),
              border-color var(--d-fast) var(--ease-out);
}
.tab:hover { color: var(--ink-2); }
.tab.active {
  color: var(--ink);
  font-weight: 600;
  border-bottom-color: var(--orange);
}

/* ===========================================================
   TAB BODY
   =========================================================== */
#tab-body {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  min-height: 100px;
  box-shadow: var(--sh-1);
}
.tab-pane {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding: 16px 18px 20px;
  display: none;
}
.tab-pane.active { display: block; }
.tab-pane > .hdr:first-child { margin-top: 0; }

/* ===========================================================
   KEY-VALUE PAIRS
   =========================================================== */
.kv {
  font-size: 12px;
  color: var(--ink-2);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 16px;
  letter-spacing: -0.005em;
}
.kv b {
  color: var(--ink-muted);
  font-weight: 600;
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding-top: 2px;
}
.kv > span { color: var(--ink); font-variant-numeric: tabular-nums; }
.kv > span b { color: var(--ink); font-weight: 600; }

/* ===========================================================
   WHY LIST · explanation bullets
   =========================================================== */
.why-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-2);
}
.why-list li {
  padding: 8px 0 8px 18px;
  border-bottom: 1px solid var(--hairline);
  position: relative;
}
.why-list li::before {
  content: "";
  position: absolute;
  left: 0; top: 16px;
  width: 8px; height: 1px;
  background: var(--orange);
}
.why-list li:last-child { border-bottom: none; }

/* ===========================================================
   CANDIDATES TABLE
   =========================================================== */
.cand-table {
  display: grid;
  grid-template-columns: 64px 56px 1fr 64px 64px;
  gap: 6px 10px;
  font-size: 12px;
  align-items: center;
}
.cand-table .th {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-muted);
  font-weight: 600;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--hairline-strong);
}
.cand-table .chosen {
  color: var(--orange);
  font-weight: 600;
}
.cand-table > *:not(.th) {
  padding: 6px 0;
  border-bottom: 1px solid var(--hairline);
}
.cand-bar {
  height: 6px;
  background: var(--surface-2);
  border-radius: var(--r-full);
  position: relative;
  overflow: hidden;
}
.cand-bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--orange), var(--orange-deep));
  border-radius: var(--r-full);
}

/* ===========================================================
   LATENCY TABLE
   =========================================================== */
.latency-table {
  display: grid;
  grid-template-columns: 1fr auto 80px;
  gap: 4px 12px;
  font-size: 12px;
  align-items: center;
}
.latency-table .th {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-muted);
  font-weight: 600;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--hairline-strong);
}
.latency-table .lab { color: var(--ink-2); }
.latency-table .val { color: var(--ink); font-variant-numeric: tabular-nums; text-align: right; font-weight: 500; }
.latency-bar {
  height: 6px;
  background: var(--surface-2);
  border-radius: var(--r-full);
  overflow: hidden;
}
.latency-bar > span { display: block; height: 100%; }
.latency-bar > .b-phone   { background: #2563d6; }
.latency-bar > .b-upload  { background: #b85f00; }
.latency-bar > .b-vlm     { background: var(--orange); }
.latency-bar > .b-decide  { background: #2c8c4a; }
.latency-bar > .b-render  { background: #6b3aa3; }

/* ===========================================================
   VLM BENCHMARK
   =========================================================== */
.bench-table { font-size: 12px; }
.bench-grid {
  display: grid;
  grid-template-columns:
    minmax(140px, 1.6fr) 60px 76px 76px
    minmax(64px, 1fr) minmax(96px, 1.4fr) 64px 46px 64px;
  gap: 4px 8px;
  align-items: center;
}
.bench-grid .th {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-muted);
  font-weight: 600;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--hairline-strong);
}
.bench-grid > *:not(.th) {
  padding: 4px 0;
  border-bottom: 1px solid var(--hairline);
}
.bench-grid .primary { color: var(--orange); font-weight: 600; }
.bench-grid .shadow  { color: var(--ink); font-weight: 500; }
.bench-grid em {
  font-style: normal;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-muted);
  margin-left: 6px;
  padding: 1px 6px;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-full);
}
.bench-grid .mono {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-variant-numeric: tabular-nums;
}
.bench-grid .err  { color: var(--danger); }
.bench-grid .ok   { color: var(--orange); font-weight: 600; }
.bench-grid .diff { color: var(--warn);   font-weight: 600; }

@media (max-width: 520px) {
  .bench-grid {
    grid-template-columns: 1.6fr 56px 60px minmax(70px,1fr) minmax(96px,1.2fr) 56px;
  }
  .bench-grid > .th:nth-child(3),
  .bench-grid > .th:nth-child(4),
  .bench-grid > .th:nth-child(8),
  .bench-grid > .th:nth-child(9) { display: none; }
  .bench-grid > :nth-child(9n + 3),
  .bench-grid > :nth-child(9n + 4),
  .bench-grid > :nth-child(9n + 8),
  .bench-grid > :nth-child(9n + 9) { display: none; }
}

/* ===========================================================
   HISTORY TAB
   =========================================================== */
.history-list {
  font-size: 12px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
}
.history-list .hand-row {
  display: grid;
  grid-template-columns: 48px 64px 1fr 64px 80px;
  gap: 6px 10px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--hairline);
  border-left: 3px solid transparent;
  border-radius: var(--r-sm);
  background: var(--surface);
  transition: border-color var(--d-fast) var(--ease-out),
              transform var(--d-fast) var(--ease-out);
}
.history-list .hand-row:hover { transform: translateX(2px); }
.history-list .hand-row.win  { border-left-color: var(--orange); }
.history-list .hand-row.loss { border-left-color: var(--danger); }
.history-list .hand-row.neutral { border-left-color: var(--hairline-strong); }
.history-list .hand-row.collision {
  background: var(--orange-soft);
  border-left-color: var(--orange-deep);
}
.history-list .hand-id    { color: var(--ink-muted); font-family: ui-monospace, monospace; }
.history-list .hand-cards { font-family: ui-monospace, monospace; letter-spacing: 0.5px; color: var(--ink); }
.history-list .hand-meta  { color: var(--ink-2); font-size: 11px; }
.history-list .hand-pnl   { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.history-list .hand-pnl.win  { color: var(--orange); }
.history-list .hand-pnl.loss { color: var(--danger); }
.history-list .hand-info  { color: var(--ink-muted); font-size: 10.5px; text-align: right; }

/* ===========================================================
   BUTTONS
   =========================================================== */
.mini-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: -0.005em;
  height: 32px;
  padding: 0 14px;
  border-radius: var(--r-full);
  border: 1px solid var(--hairline-strong);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  margin-left: 4px;
  transition: border-color var(--d-fast) var(--ease-out),
              transform var(--d-fast) var(--ease-out),
              background var(--d-fast) var(--ease-out);
}
.mini-btn:hover {
  border-color: var(--ink);
  transform: translateY(-1px);
}
.mini-btn.warn {
  color: var(--danger);
  border-color: rgba(210,58,42,.30);
}
.mini-btn.warn:hover { border-color: var(--danger); background: rgba(210,58,42,.05); }

/* Primary CTA — single elevated button (orange-tinted shadow). */
.btn-primary, button.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.005em;
  height: 44px;
  padding: 0 22px;
  background: var(--orange);
  color: var(--surface);
  border: 0;
  border-radius: var(--r-full);
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(255,122,26,.30);
  transition: transform var(--d-fast) var(--ease-out),
              box-shadow var(--d-fast) var(--ease-out),
              background var(--d-fast) var(--ease-out);
}
.btn-primary:hover, button.primary:hover {
  transform: translateY(-2px);
  background: var(--orange-hover);
  box-shadow: 0 16px 36px rgba(255,122,26,.36);
}

/* ===========================================================
   MODELS TOGGLE ROWS
   =========================================================== */
.models-toggles {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 8px 14px;
  font-size: 12px;
  align-items: center;
}
.models-toggles .model-role {
  color: var(--ink-muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-weight: 600;
}
.models-toggles .model-cost {
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
}
.models-toggles .model-tog {
  appearance: none;
  width: 38px;
  height: 22px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  border: 1px solid var(--hairline-strong);
  position: relative;
  cursor: pointer;
  transition: background var(--d-fast) var(--ease-out),
              border-color var(--d-fast) var(--ease-out);
}
.models-toggles .model-tog::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--ink-muted);
  transition: transform var(--d-fast) var(--ease-out),
              background var(--d-fast) var(--ease-out);
}
.models-toggles .model-tog:checked {
  background: var(--orange);
  border-color: var(--orange);
}
.models-toggles .model-tog:checked::after {
  transform: translateX(16px);
  background: var(--surface);
}
.models-toggles .model-tog:disabled { opacity: 0.45; cursor: not-allowed; }

/* ===========================================================
   OPPONENTS TAB
   =========================================================== */
.opp-uploader {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.opp-uploader label.mode { gap: 4px; }
.opp-manual {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  font-size: 12px;
}
.opp-manual label {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.opp-manual label.full { grid-column: 1 / -1; }
.opp-manual label > span {
  color: var(--ink-muted);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 600;
}
.opp-manual button { grid-column: 1 / -1; }

.opps-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
}
.opp-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 14px;
  align-items: start;
  transition: border-color var(--d-fast) var(--ease-out);
}
.opp-card.applied {
  border-color: var(--orange);
  box-shadow: 0 0 0 1px rgba(255,122,26,.15);
}
.opp-card .seat-tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  border: 1px solid var(--hairline-strong);
  color: var(--ink);
  font-weight: 600;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  margin-right: 6px;
}
.opp-card .opp-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-top: 4px;
  color: var(--ink-2);
}
.opp-card .opp-stat { font-variant-numeric: tabular-nums; }
.opp-card .opp-stat b { color: var(--ink); font-weight: 600; }
.opp-card .opp-stat.muted { color: var(--ink-muted); }
.opp-card .opp-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}
.opp-card .opp-meta {
  grid-column: 1 / -1;
  color: var(--ink-muted);
  font-size: 10.5px;
}
.opp-card .applied-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--r-full);
  background: var(--orange);
  color: var(--surface);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-left: 6px;
}

/* ===========================================================
   RAW JSON
   =========================================================== */
pre#extracted {
  background: var(--surface-2);
  color: var(--ink-2);
  padding: 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--hairline);
  overflow: auto;
  font-size: 11.5px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  margin: 0;
  max-height: 100%;
  line-height: 1.5;
}

/* ===========================================================
   UTILITIES
   =========================================================== */
.dim { color: var(--ink-muted); }

/* ===========================================================
   WIDE VIEWPORTS — desktop layout
   =========================================================== */
@media (min-width: 780px) {
  main#app {
    grid-template-columns: 380px 1fr;
    grid-template-rows: auto auto auto auto auto 1fr;
    grid-template-areas:
      "header  header"
      "cam     decision"
      "table   tabs"
      "table   body"
      "ctrls   body"
      "ctrls   body";
    gap: 12px;
  }
  header           { grid-area: header; }
  #cam-strip       { grid-area: cam; height: 110px; grid-template-columns: 150px 1fr; }
  #decision-panel  { grid-area: decision; }
  #table-clone     { grid-area: table; }
  #table-svg       { max-height: 360px; }
  #controls        { grid-area: ctrls; }
  #tabs            { grid-area: tabs; }
  #tab-body        { grid-area: body; }
}
