:root {
  --page-bg: #0b1120;
  --card-bg: #1e293b;
  --card-soft: #0f172a;
  --surface-deep: #090d16;
  --header-bg: #0f172a;
  --ink-primary: #f8fafc;
  --ink-secondary: #cbd5e1;
  --ink-muted: #94a3b8;
  --border-subtle: #334155;
  --amber-bg: #29200c;
  --amber-border: #fbbf24;
  --amber-ink: #fde68a;
  --green: #34d399;
  --red: #f87171;
  --blue: #60a5fa;
  --banker: #dc2626;
  --player: #2563eb;
  --tie: #059669;
  --purple: #a855f7;
  --tab-track: #1e293b;
  --cell-border: #1e293b;
  --empty-dot: #334155;
  --curve-bg: #090f1c;
  --curve-grid: #1e293b;
}

body.theme-light {
  --page-bg: #f1f5f9;
  --card-bg: #ffffff;
  --card-soft: #f8fafc;
  --surface-deep: #e2e8f0;
  --header-bg: #0f172a;
  --ink-primary: #0f172a;
  --ink-secondary: #334155;
  --ink-muted: #64748b;
  --border-subtle: #cbd5e1;
  --amber-bg: #fffbeb;
  --amber-border: #f59e0b;
  --amber-ink: #b45309;
  --green: #059669;
  --red: #dc2626;
  --blue: #2563eb;
  --tab-track: #e2e8f0;
  --cell-border: #e2e8f0;
  --empty-dot: #cbd5e1;
  --curve-bg: #f8fafc;
  --curve-grid: #e2e8f0;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--page-bg);
  color: var(--ink-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  overscroll-behavior-y: none;
}

.app-shell {
  max-width: 560px;
  margin: 0 auto;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--page-bg);
  position: relative;
}

@media (min-width: 900px) {
  .app-shell {
    max-width: 780px;
    border-left: 1px solid var(--border-subtle);
    border-right: 1px solid var(--border-subtle);
  }
}

/* Top Bar & Navigation */
.top-fixed {
  flex: 0 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 6px) 8px 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--page-bg);
  z-index: 20;
}

.header-bar {
  background: #0f172a;
  color: #f8fafc;
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid #1e293b;
}

.header-left {
  min-width: 0;
  flex: 1;
}

.header-title {
  font-size: 13px;
  font-weight: 900;
  color: #38bdf8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-sub {
  font-size: 10px;
  font-weight: 700;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.icon-pill {
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  line-height: 1.1;
}

.icon-pill.gold {
  border-color: #fbbf24;
  color: #fde68a;
}

.icon-pill.pro {
  background: #065f46;
  border-color: #10b981;
  color: #a7f3d0;
}

.icon-pill.upgrade {
  background: #b45309;
  border-color: #fbbf24;
  color: #ffffff;
}

.icon-pill:active {
  transform: scale(0.96);
}

/* 3-Tab Switcher */
.tab-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  background: var(--tab-track);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 4px;
}

.tab-btn {
  border: none;
  background: transparent;
  color: var(--ink-primary);
  font-size: 11px;
  font-weight: 900;
  padding: 8px 4px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tab-btn.locked-hint {
  color: var(--amber-ink);
}

.tab-btn.active-auto {
  background: #1d4ed8;
  color: #ffffff;
}

.tab-btn.active-deep {
  background: #0f766e;
  color: #ffffff;
}

.tab-btn.active-dynamic {
  background: #0f172a;
  color: #ffffff;
}

/* Status / Sandbox / Trial Strips */
.status-strip {
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 10.5px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.strip-sandbox {
  background: #0f766e;
  border: 1.5px solid #5eead4;
  color: #ffffff;
}

.strip-trial {
  background: #1e293b;
  border: 1px solid #475569;
  color: #f8fafc;
  cursor: pointer;
}

.strip-trial.locked {
  background: #dc2626;
  border-color: #fca5a5;
}

.strip-btn {
  background: #0f172a;
  color: #fbbf24;
  border: 1px solid #fbbf24;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 9.5px;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
}

/* Scrollable Cockpit Content */
.cockpit-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 2px 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

/* Generic Card */
.card {
  background: var(--card-bg);
  border: 1.2px solid var(--border-subtle);
  border-radius: 10px;
  padding: 9px 10px;
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 6px;
}

.card-title {
  font-size: 11px;
  font-weight: 900;
  color: var(--ink-primary);
}

/* Hero Cards (Auto Telemetry v4.5) */
.hero-v45 {
  border-radius: 14px;
  padding: 12px;
  color: #ffffff;
  border: 2px solid #64748b;
  background: linear-gradient(180deg, #0f172a 0%, #0b1120 100%);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hero-v45.sev-STRONG_B, .hero-v45.sev-BET_B {
  border-color: #ef4444;
  background: linear-gradient(180deg, #2a0d14 0%, #0b1120 100%);
}
.hero-v45.sev-STRONG_P, .hero-v45.sev-BET_P {
  border-color: #3b82f6;
  background: linear-gradient(180deg, #0d1e3a 0%, #0b1120 100%);
}
.hero-v45.sev-LOCK_WIN {
  border-color: #10b981;
  background: linear-gradient(180deg, #0a2a20 0%, #0b1120 100%);
}
.hero-v45.sev-LOCK_LOSS {
  border-color: #f97316;
  background: linear-gradient(180deg, #2d160b 0%, #0b1120 100%);
}
.hero-v45.sev-NEUTRAL {
  border-color: #a855f7;
  background: linear-gradient(180deg, #211238 0%, #0b1120 100%);
}
.hero-v45.sev-CAUTION {
  border-color: #f59e0b;
}

.hero-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.hero-kicker {
  font-size: 10px;
  font-weight: 900;
  color: #38bdf8;
}

.hero-badge {
  font-size: 10px;
  font-weight: 900;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #ffffff;
}

.hero-headline {
  font-size: 16.5px;
  font-weight: 900;
  line-height: 1.2;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hero-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  flex-shrink: 0;
  background: #64748b;
}

.hero-reason {
  font-size: 11.5px;
  color: #e2e8f0;
  line-height: 1.4;
}

.hero-divider {
  height: 1px;
  background: #1e293b;
  margin: 2px 0;
}

.hero-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  font-weight: 800;
}

.hero-src {
  color: #fde68a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hero-sync {
  font-size: 10px;
  font-weight: 700;
  color: #93c5fd;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hero-l6 {
  font-size: 9.5px;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Shield Strip */
.shield-strip {
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 10.5px;
  font-weight: 900;
  border: 1px solid #d97706;
  background: #1e293b;
  color: #fde68a;
}

body.theme-light .shield-strip.st-ACTIVE {
  background: #fef3c7;
  color: #92400e;
}

.shield-strip.st-PROFIT_LOCK {
  background: #064e3b;
  border-color: #10b981;
  color: #a7f3d0;
}

.shield-strip.st-STOP_LOSS {
  background: #451a03;
  border-color: #f97316;
  color: #fed7aa;
}

.shield-strip.st-TRAIL_ARMED {
  background: #422006;
  border-color: #f59e0b;
  color: #fde68a;
}

/* Control Rows (Pace / Shield / Scale) */
.ctrl-row {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 6px;
}
.ctrl-row:last-child { margin-bottom: 0; }

.ctrl-label {
  width: 48px;
  flex-shrink: 0;
  font-size: 9.5px;
  font-weight: 900;
  color: var(--ink-secondary);
}

.ctrl-group {
  flex: 1;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 5px;
}

.ctrl-btn {
  border: 1px solid var(--border-subtle);
  background: var(--card-soft);
  color: var(--ink-primary);
  border-radius: 6px;
  padding: 6px 4px;
  font-size: 9.5px;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ctrl-btn.on-blue { background: #1d4ed8; border-color: #60a5fa; color: #ffffff; }
.ctrl-btn.on-teal { background: #0f766e; border-color: #2dd4bf; color: #ffffff; }
.ctrl-btn.on-purple { background: #7c3aed; border-color: #c4b5fd; color: #ffffff; }
.ctrl-btn.on-sky { background: #0369a1; border-color: #38bdf8; color: #ffffff; }

/* Canvas Charts */
.curve-canvas {
  width: 100%;
  height: 130px;
  display: block;
  border-radius: 8px;
  background: var(--curve-bg);
  border: 1px solid var(--curve-grid);
}

.curve-canvas.tall {
  height: 200px;
}

.kpi-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 800;
  margin-top: 5px;
  color: var(--ink-secondary);
}

/* Bead Road (6x12) */
.bead-grid-wrap {
  background: var(--card-soft);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 6px;
  margin-top: 6px;
}

.bead-row {
  display: grid;
  grid-template-columns: 16px repeat(12, 1fr);
  align-items: center;
}

.bead-row-num {
  font-size: 9px;
  font-weight: 800;
  color: var(--ink-muted);
  text-align: center;
}

.bead-cell {
  height: 24px;
  border: 0.5px solid var(--cell-border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.bead-ball {
  width: 19px;
  height: 19px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 900;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bead-ball.B { background: var(--banker); }
.bead-ball.P { background: var(--player); }
.bead-ball.T { background: var(--tie); }

.bead-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--empty-dot);
}

.bead-col-nums {
  display: grid;
  grid-template-columns: 16px repeat(12, 1fr);
  margin-top: 3px;
}

.bead-col-num {
  font-size: 8.5px;
  font-weight: 700;
  color: var(--ink-muted);
  text-align: center;
}

/* CSV Export Banner */
.csv-banner {
  background: linear-gradient(90deg, #0f172a, #1e3a5f);
  border: 1px solid #f59e0b;
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  color: #ffffff;
}

/* Ledger Rows */
.ledger-row {
  background: var(--card-bg);
  border: 1px solid var(--border-subtle);
  border-radius: 9px;
  padding: 7px 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ledger-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.ledger-ball {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 900;
  color: #ffffff;
  flex-shrink: 0;
}

.ledger-ball.B { background: var(--banker); }
.ledger-ball.P { background: var(--player); }

.ledger-text {
  min-width: 0;
  flex: 1;
}

.ledger-head {
  font-size: 10.5px;
  font-weight: 900;
  color: var(--ink-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ledger-sub {
  font-size: 9px;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ledger-tag {
  font-size: 9.5px;
  font-weight: 900;
  padding: 4px 7px;
  border-radius: 6px;
  border: 1px solid currentColor;
  white-space: nowrap;
}

/* Dynamic / Deep Hero Action Banner */
.hero-action-card {
  background: var(--card-bg);
  border: 2px solid var(--amber-border);
  border-radius: 12px;
  padding: 10px 11px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.hero-action-pill {
  border-radius: 9px;
  padding: 10px;
  text-align: center;
  font-size: 15.5px;
  font-weight: 900;
  letter-spacing: 0.3px;
}

.hero-action-pill.B { background: var(--banker); color: #ffffff; }
.hero-action-pill.P { background: var(--player); color: #ffffff; }
.hero-action-pill.LOCKED { background: #b45309; color: #ffffff; cursor: pointer; }
.hero-action-pill.WAIT { background: var(--surface-deep); color: var(--ink-primary); }

.auto-lock-badge {
  font-size: 9.5px;
  font-weight: 900;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  background: var(--surface-deep);
  color: var(--ink-secondary);
  cursor: pointer;
  white-space: nowrap;
}

.auto-lock-badge.on {
  background: #d1fae5;
  border-color: #10b981;
  color: #065f46;
}

/* Deep Telemetry Sortable 73-Model Matrix */
.matrix-head {
  display: grid;
  grid-template-columns: 36px 1fr 48px 46px 34px 56px;
  align-items: center;
  gap: 4px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 7px 6px;
  font-size: 10px;
  font-weight: 900;
  color: #cbd5e1;
  position: sticky;
  top: 0;
  z-index: 5;
}

.matrix-head button {
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  padding: 0;
  text-align: center;
}

.matrix-head button.sorted {
  color: #fbbf24;
}

.matrix-row {
  display: grid;
  grid-template-columns: 36px 1fr 48px 46px 34px 56px;
  align-items: center;
  gap: 4px;
  background: var(--card-bg);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 7px 6px;
  cursor: pointer;
}

.matrix-row.rank1 {
  background: var(--amber-bg);
  border: 1.8px solid var(--amber-border);
}

.matrix-row.pinned {
  border: 1.8px solid var(--blue);
}

.matrix-name {
  font-size: 11px;
  font-weight: 900;
  color: var(--ink-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.matrix-sub {
  font-size: 9px;
  font-weight: 700;
  color: var(--ink-muted);
}

.matrix-num {
  text-align: center;
  font-size: 10.5px;
  font-weight: 900;
}

.call-pill {
  text-align: center;
  font-size: 9.5px;
  font-weight: 900;
  padding: 4px 3px;
  border-radius: 6px;
  background: var(--surface-deep);
  color: var(--ink-muted);
}
.call-pill.B { background: var(--banker); color: #ffffff; }
.call-pill.P { background: var(--player); color: #ffffff; }
.call-pill.LOCKED { background: #b45309; color: #ffffff; }

/* Dynamic Grids (Base Tiers / Matrix Aggs / Pool) */
.grid-4 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}
@media (min-width: 520px) {
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
}

.grid-5 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 5px;
}
@media (min-width: 520px) {
  .grid-5 { grid-template-columns: repeat(5, 1fr); }
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}
@media (min-width: 500px) {
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.mini-card {
  background: var(--card-bg);
  border: 1.2px solid var(--border-subtle);
  border-radius: 8px;
  padding: 7px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mini-card.selected {
  border: 2px solid var(--blue);
}

.mini-card.leader {
  background: var(--amber-bg);
  border: 2px solid var(--amber-border);
}

.mini-title {
  font-size: 9.5px;
  font-weight: 900;
  color: var(--ink-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-stats {
  display: flex;
  justify-content: space-between;
  font-size: 9.5px;
  font-weight: 800;
  color: var(--ink-secondary);
}

.mini-pred {
  text-align: center;
  font-size: 11px;
  font-weight: 900;
  padding: 3px;
  border-radius: 5px;
  background: var(--surface-deep);
}
.mini-pred.B { color: var(--red); }
.mini-pred.P { color: var(--blue); }
.mini-pred.LOCKED { color: var(--amber-ink); }

/* Horizontal Radar Chips & Hand-by-Hand Strip */
.chip-scroll {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.radar-chip {
  flex: 0 0 auto;
  font-size: 9.5px;
  font-weight: 900;
  padding: 4px 7px;
  border-radius: 5px;
  cursor: pointer;
  white-space: nowrap;
}

.radar-chip.hot {
  background: rgba(16, 185, 129, 0.16);
  border: 1px solid #10b981;
  color: var(--green);
}

.radar-chip.cold {
  background: rgba(239, 68, 68, 0.16);
  border: 1px solid #ef4444;
  color: var(--red);
}

.hbh-cell {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 3px 4px;
  border-radius: 6px;
}

.hbh-cell.win6 {
  background: var(--amber-bg);
  border: 1px solid var(--amber-border);
}

/* Fixed Bottom Thumb Input Deck */
.bottom-deck {
  flex: 0 0 auto;
  padding: 6px 8px calc(env(safe-area-inset-bottom, 0px) + 8px);
  background: var(--page-bg);
  border-top: 1px solid var(--border-subtle);
  z-index: 25;
}

.deck-card {
  background: var(--card-bg);
  border: 1.5px solid var(--border-subtle);
  border-radius: 10px;
  padding: 7px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.deck-tally {
  background: #0f172a;
  color: #ffffff;
  border-radius: 6px;
  padding: 4px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  font-weight: 900;
}

.deck-main-btns {
  display: grid;
  grid-template-columns: 1.25fr 1.25fr 0.8fr;
  gap: 6px;
}

.btn-p, .btn-b, .btn-t {
  border: none;
  border-radius: 8px;
  height: 46px;
  color: #ffffff;
  font-size: 13.5px;
  font-weight: 900;
  cursor: pointer;
}
.btn-p { background: var(--player); }
.btn-b { background: var(--banker); }
.btn-t { background: var(--tie); font-size: 12px; }
.btn-p:active, .btn-b:active, .btn-t:active { transform: scale(0.97); }

.deck-util-btns {
  display: grid;
  grid-template-columns: 1fr 0.9fr 1fr 1.1fr;
  gap: 6px;
}

.util-btn {
  border: none;
  border-radius: 6px;
  height: 32px;
  color: #ffffff;
  font-size: 10px;
  font-weight: 900;
  cursor: pointer;
}
.util-mode-a { background: #334155; }
.util-mode-b { background: #0f766e; }
.util-undo { background: #64748b; }
.util-clear { background: #ef4444; }
.util-csv { background: #0d9488; }

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.78);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 14px;
}

.modal-backdrop.open {
  display: flex;
}

.modal-box {
  width: 100%;
  max-width: 440px;
  max-height: 85dvh;
  overflow-y: auto;
  background: #0f172a;
  color: #f8fafc;
  border: 2px solid #fbbf24;
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 13.5px;
  font-weight: 900;
  color: #fbbf24;
}

.modal-close {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 18px;
  font-weight: 900;
  cursor: pointer;
}

.modal-item {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 9px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.modal-item.active {
  border: 2px solid #fbbf24;
}

.txt-green { color: var(--green); }
.txt-red { color: var(--red); }
.txt-blue { color: var(--blue); }
.txt-amber { color: var(--amber-ink); }
.txt-muted { color: var(--ink-muted); }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 112px;
  transform: translateX(-50%);
  background: #0f172a;
  color: #fde68a;
  border: 1px solid #fbbf24;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 11.5px;
  font-weight: 800;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  max-width: 90vw;
  text-align: center;
}
.toast.show { opacity: 1; }

.loading-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #38bdf8;
  margin-left: 5px;
  opacity: 0;
  transition: opacity 0.15s;
}
.loading-dot.busy { opacity: 1; }

/* === SELECTABLE COCKPIT BACKGROUND THEMES (HD ENVIRONMENTS + FROSTED GLASS) === */
.theme-picker-box {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.theme-picker-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.theme-chip-btn {
  border: 1px solid #475569;
  background: #0f172a;
  color: #f8fafc;
  border-radius: 7px;
  padding: 8px 6px;
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.theme-chip-btn:active { transform: scale(0.97); }
.theme-chip-btn.active {
  border: 2px solid #fbbf24;
  background: #1e3a5f;
  color: #fde68a;
}

/* iPhone-safe full-viewport fixed HD environment backdrop */
body.theme-beach,
body.theme-park,
body.theme-casino {
  background: transparent;
}

body.theme-beach::before,
body.theme-park::before,
body.theme-casino::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  pointer-events: none;
}

body.theme-beach::before  { background-image: url("/themes/beach.png"); }
body.theme-park::before   { background-image: url("/themes/park.png"); }
body.theme-casino::before { background-image: url("/themes/casino.png"); }

/* Subtle ambient veil so environment stays vivid while UI stays legible */
body.theme-beach::after,
body.theme-park::after,
body.theme-casino::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  background: rgba(5, 10, 20, 0.24);
  pointer-events: none;
}

body.theme-beach.theme-light::after,
body.theme-park.theme-light::after,
body.theme-casino.theme-light::after {
  background: rgba(255, 255, 255, 0.10);
}

body.theme-beach .app-shell,
body.theme-park .app-shell,
body.theme-casino .app-shell {
  position: relative;
  z-index: 1;
  background: transparent;
  border-left: 1px solid rgba(255, 255, 255, 0.14);
  border-right: 1px solid rgba(255, 255, 255, 0.14);
}

/* Frosted glass cards & bars */
body.theme-beach .card,
body.theme-park .card,
body.theme-casino .card,
body.theme-beach .mini-card,
body.theme-park .mini-card,
body.theme-casino .mini-card,
body.theme-beach .matrix-row,
body.theme-park .matrix-row,
body.theme-casino .matrix-row,
body.theme-beach .ledger-row,
body.theme-park .ledger-row,
body.theme-casino .ledger-row,
body.theme-beach .hero-action-card,
body.theme-park .hero-action-card,
body.theme-casino .hero-action-card,
body.theme-beach .deck-card,
body.theme-park .deck-card,
body.theme-casino .deck-card {
  backdrop-filter: blur(11px);
  -webkit-backdrop-filter: blur(11px);
}

body.theme-beach .top-fixed,
body.theme-beach .bottom-deck,
body.theme-park .top-fixed,
body.theme-park .bottom-deck,
body.theme-casino .top-fixed,
body.theme-casino .bottom-deck {
  background: rgba(8, 15, 28, 0.56);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

body.theme-beach.theme-light .top-fixed,
body.theme-beach.theme-light .bottom-deck,
body.theme-park.theme-light .top-fixed,
body.theme-park.theme-light .bottom-deck,
body.theme-casino.theme-light .top-fixed,
body.theme-casino.theme-light .bottom-deck {
  background: rgba(255, 255, 255, 0.54);
}

/* Dark-mode glass tokens per environment */
body.theme-beach {
  --card-bg: rgba(9, 24, 38, 0.66);
  --card-soft: rgba(7, 19, 32, 0.62);
  --surface-deep: rgba(6, 16, 28, 0.74);
  --border-subtle: rgba(125, 211, 252, 0.30);
  --tab-track: rgba(9, 24, 38, 0.68);
  --curve-bg: rgba(6, 18, 30, 0.78);
}

body.theme-park {
  --card-bg: rgba(8, 26, 18, 0.66);
  --card-soft: rgba(6, 20, 14, 0.62);
  --surface-deep: rgba(5, 16, 11, 0.74);
  --border-subtle: rgba(134, 239, 172, 0.30);
  --tab-track: rgba(8, 26, 18, 0.68);
  --curve-bg: rgba(6, 18, 13, 0.78);
}

body.theme-casino {
  --card-bg: rgba(6, 28, 20, 0.70);
  --card-soft: rgba(4, 21, 15, 0.66);
  --surface-deep: rgba(3, 16, 12, 0.78);
  --border-subtle: rgba(251, 191, 36, 0.36);
  --tab-track: rgba(6, 26, 19, 0.72);
  --curve-bg: rgba(3, 18, 13, 0.80);
}

/* Light-mode glass tokens per environment */
body.theme-beach.theme-light,
body.theme-park.theme-light,
body.theme-casino.theme-light {
  --card-bg: rgba(255, 255, 255, 0.74);
  --card-soft: rgba(248, 250, 252, 0.72);
  --surface-deep: rgba(226, 232, 240, 0.82);
  --tab-track: rgba(255, 255, 255, 0.70);
  --curve-bg: rgba(248, 250, 252, 0.86);
}