/* Theme tokens — dark default; light + system via data-theme on <html> */
:root,
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1220;
  --bg-glow-a: #1a3a4a;
  --bg-glow-b: #1a2440;
  --card: #131b2d;
  --border: #2a3650;
  --text: #eef3fb;
  --muted: #93a0b8;
  --accent: #3dd6c6;
  --accent-dim: #1b8f85;
  --danger: #ef6b6b;
  --ok: #5dca7a;
  --warn: #e6b84d;
  --pass: #6b8cff;
  --chip: #1c2740;
  --header-bg: rgba(11, 18, 32, 0.92);
  --banner-bg: rgba(19, 27, 45, 0.97);
  --tabs-bg: rgba(11, 18, 32, 0.92);
  --story-bg: rgba(61, 214, 198, 0.08);
  --story-border: rgba(61, 214, 198, 0.22);
  --story-text: #d7f7f2;
  --input-bg: #0a101c;
  --output-bg: #0a101c;
  --output-text: #c9d4e8;
  --btn-secondary: #243049;
  --btn-text-on-accent: #06221f;
  --shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
  --sans: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Code", Consolas, monospace;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f7fb;
  --bg-glow-a: #d4eef0;
  --bg-glow-b: #e2e8f5;
  --card: #ffffff;
  --border: #d0d8e6;
  --text: #152033;
  --muted: #5b6b84;
  --accent: #0d9f92;
  --accent-dim: #0a7a70;
  --danger: #d64545;
  --ok: #1f9d55;
  --warn: #c4880a;
  --pass: #3b6de0;
  --chip: #eef2f8;
  --header-bg: rgba(255, 255, 255, 0.92);
  --banner-bg: rgba(255, 255, 255, 0.97);
  --tabs-bg: rgba(244, 247, 251, 0.95);
  --story-bg: rgba(13, 159, 146, 0.08);
  --story-border: rgba(13, 159, 146, 0.22);
  --story-text: #0b4f49;
  --input-bg: #f7f9fc;
  --output-bg: #f0f3f8;
  --output-text: #243047;
  --btn-secondary: #e4eaf3;
  --btn-text-on-accent: #ffffff;
  --shadow: 0 10px 24px rgba(21, 32, 51, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  color: var(--text);
  background:
    radial-gradient(900px 420px at 0% -10%, var(--bg-glow-a) 0%, transparent 55%),
    radial-gradient(700px 380px at 100% 0%, var(--bg-glow-b) 0%, transparent 50%),
    var(--bg);
  transition: background 0.2s ease, color 0.15s ease;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.95rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 0.2rem;
  min-width: 0;
  flex: 0 1 auto;
}
.brand-link {
  display: block;
  line-height: 0;
  text-decoration: none;
}
.brand-wordmark {
  display: block;
  height: 40px;
  width: auto;
  max-width: min(320px, 52vw);
  object-fit: contain;
  object-position: left center;
}
.logo { color: var(--accent); font-size: 1.5rem; }
.brand h1 { margin: 0; font-size: 1.2rem; }
.tag { margin: 0; color: var(--muted); font-size: 0.82rem; padding-left: 0.15rem; }

@media (max-width: 640px) {
  .brand-wordmark { height: 32px; max-width: 58vw; }
  .tag { display: none; }
}

.header-right { display: flex; align-items: center; gap: 0.65rem; }
.header-text { text-align: right; }
.header-status { font-size: 0.88rem; color: var(--muted); }
.refresh-hint { font-size: 0.72rem; color: var(--muted); opacity: 0.85; }

.live-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 0 rgba(93, 202, 122, 0.6);
  animation: pulse 2s infinite;
}
.live-dot.off { background: var(--muted); animation: none; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(93, 202, 122, 0.55); }
  70% { box-shadow: 0 0 0 10px rgba(93, 202, 122, 0); }
  100% { box-shadow: 0 0 0 0 rgba(93, 202, 122, 0); }
}

/* Practice / learning autonomy banner — sticky, aligned with main width */
.autonomy-banner {
  border-bottom: 1px solid var(--border);
  background: var(--banner-bg);
  position: sticky;
  top: var(--header-h, 64px);
  z-index: 15;
  transition: transform 0.22s ease, opacity 0.22s ease, max-height 0.25s ease;
  max-height: 40rem;
  overflow: hidden;
}
.autonomy-banner.autohide-hidden {
  transform: translateY(-110%);
  opacity: 0;
  pointer-events: none;
  max-height: 0;
  border-bottom-width: 0;
}
.banner-toggle {
  display: none;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 650;
  font-size: 0.88rem;
  padding: 0.65rem 1rem;
  text-align: left;
  cursor: pointer;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}
.banner-chevron {
  color: var(--muted);
  transition: transform 0.15s ease;
}
.autonomy-banner.collapsed .banner-chevron {
  transform: rotate(-90deg);
}
.autonomy-inner {
  max-width: 1200px; /* match main content width */
  margin: 0 auto;
  padding: 0.65rem 1.25rem;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.65rem;
  align-items: stretch;
  width: 100%;
  box-sizing: border-box;
}
.autonomy-tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.65rem 0.8rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}
.autonomy-tile[data-state="active"],
.autonomy-tile[data-state="running"] {
  border-color: rgba(93, 202, 122, 0.45);
  box-shadow: 0 0 0 1px rgba(93, 202, 122, 0.12);
}
.autonomy-tile[data-state="paused"],
.autonomy-tile[data-state="idle"] {
  border-color: rgba(230, 184, 77, 0.4);
}
.autonomy-tile[data-state="off"],
.autonomy-tile[data-state="blocked"] {
  border-color: rgba(147, 160, 184, 0.35);
  opacity: 0.92;
}

/* Demo Kalshi — calm blue cue (demo funds, not pretend, not real cash) */
.autonomy-tile.tile-demo {
  border-color: rgba(96, 165, 250, 0.45);
  background: linear-gradient(165deg, rgba(59, 130, 246, 0.08), transparent 55%), var(--card);
}
.autonomy-tile.tile-demo[data-state="active"] {
  border-color: rgba(59, 130, 246, 0.65);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.2);
}
.autonomy-tile.tile-demo[data-state="active"] .autonomy-dot {
  background: #60a5fa;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.25);
}
.autonomy-tile.tile-demo[data-state="active"] .autonomy-label {
  color: #93c5fd;
  border-color: rgba(96, 165, 250, 0.4);
  background: rgba(59, 130, 246, 0.15);
}
html[data-theme="light"] .autonomy-tile.tile-demo[data-state="active"] .autonomy-label {
  color: #1d4ed8;
}

/* REAL DEAL — emergency / high-attention tile */
.autonomy-tile.tile-real {
  border: 2px solid rgba(239, 68, 68, 0.75);
  background: linear-gradient(160deg, rgba(239, 68, 68, 0.22), rgba(127, 29, 29, 0.12) 45%, var(--card) 100%);
  box-shadow:
    0 0 0 1px rgba(239, 68, 68, 0.25),
    0 0 18px rgba(239, 68, 68, 0.18);
}
.autonomy-tile.tile-real .autonomy-name {
  color: #fecaca;
  letter-spacing: 0.02em;
  font-size: 0.88rem;
}
html[data-theme="light"] .autonomy-tile.tile-real .autonomy-name {
  color: #991b1b;
}
.autonomy-tile.tile-real[data-state="off"] {
  opacity: 0.95;
  border-color: rgba(239, 68, 68, 0.45);
  box-shadow: none;
}
.autonomy-tile.tile-real[data-state="paused"] {
  border-color: rgba(251, 146, 60, 0.85);
  background: linear-gradient(160deg, rgba(251, 146, 60, 0.18), var(--card) 70%);
}
.autonomy-tile.tile-real[data-state="active"],
.autonomy-tile.tile-real[data-state="blocked"] {
  border-color: #ef4444;
  background: linear-gradient(160deg, rgba(239, 68, 68, 0.38), rgba(185, 28, 28, 0.2) 50%, var(--card));
  box-shadow:
    0 0 0 2px rgba(239, 68, 68, 0.35),
    0 0 28px rgba(239, 68, 68, 0.35);
  animation: realAlertPulse 1.8s ease-in-out infinite;
}
.autonomy-tile.tile-real[data-state="active"] .autonomy-dot,
.autonomy-tile.tile-real[data-state="blocked"] .autonomy-dot {
  background: #f87171;
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.35);
}
.autonomy-tile.tile-real[data-state="active"] .autonomy-label,
.autonomy-tile.tile-real[data-state="blocked"] .autonomy-label {
  color: #fff;
  border-color: rgba(254, 202, 202, 0.5);
  background: rgba(185, 28, 28, 0.75);
  font-weight: 800;
}
.autonomy-tile.tile-real .mode-btn-danger.active-mode,
.autonomy-controls[data-loop="real"] .mode-btn[data-mode="on"].active-mode {
  border-color: #ef4444 !important;
  color: #fff !important;
  background: #dc2626 !important;
  font-weight: 800;
}
@keyframes realAlertPulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.35), 0 0 18px rgba(239, 68, 68, 0.28); }
  50% { box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.55), 0 0 32px rgba(239, 68, 68, 0.45); }
}
html[data-theme="light"] .autonomy-tile.tile-real {
  background: linear-gradient(160deg, rgba(254, 226, 226, 0.95), rgba(254, 202, 202, 0.4) 40%, var(--card));
}
html[data-theme="light"] .autonomy-tile.tile-real[data-state="active"],
html[data-theme="light"] .autonomy-tile.tile-real[data-state="blocked"] {
  background: linear-gradient(160deg, #fecaca, #fee2e2 55%, #fff);
}
.autonomy-tile-top {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}
.autonomy-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}
.autonomy-tile[data-state="active"] .autonomy-dot,
.autonomy-tile[data-state="running"] .autonomy-dot {
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(93, 202, 122, 0.2);
}
.autonomy-tile[data-state="running"] .autonomy-dot {
  animation: pulse 1.4s infinite;
}
.autonomy-tile[data-state="paused"] .autonomy-dot,
.autonomy-tile[data-state="idle"] .autonomy-dot {
  background: var(--warn);
}
.autonomy-tile[data-state="off"] .autonomy-dot,
.autonomy-tile[data-state="blocked"] .autonomy-dot {
  background: var(--muted);
}
.autonomy-name {
  font-weight: 700;
  font-size: 0.92rem;
}
.autonomy-label {
  margin-left: auto;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  background: var(--chip);
  color: var(--muted);
  border: 1px solid var(--border);
}
.autonomy-tile[data-state="active"] .autonomy-label,
.autonomy-tile[data-state="running"] .autonomy-label {
  color: var(--ok);
  border-color: rgba(93, 202, 122, 0.35);
  background: rgba(93, 202, 122, 0.12);
}
.autonomy-tile[data-state="paused"] .autonomy-label,
.autonomy-tile[data-state="idle"] .autonomy-label {
  color: var(--warn);
  border-color: rgba(230, 184, 77, 0.35);
  background: rgba(230, 184, 77, 0.1);
}
.autonomy-detail {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.35;
  min-height: 2.2em;
}
.autonomy-summary {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0.15rem 0.25rem 0.25rem;
}
.autonomy-summary-title {
  font-weight: 650;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}
.autonomy-summary-title.summary-danger {
  color: #fca5a5;
  font-weight: 800;
}
html[data-theme="light"] .autonomy-summary-title.summary-danger {
  color: #b91c1c;
}
.autonomy-summary-title.summary-warn {
  color: var(--warn);
}
.autonomy-summary-hint {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
}
.btn.tiny {
  align-self: flex-start;
  padding: 0.28rem 0.65rem;
  font-size: 0.78rem;
  border-radius: 8px;
}
.autonomy-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.15rem;
}
.autonomy-controls .mode-btn.active-mode {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(61, 214, 198, 0.12);
  font-weight: 700;
}

.check-list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.check-list li {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.15);
  font-size: 0.88rem;
  line-height: 1.35;
}
.check-list li.ok { border-color: rgba(93, 202, 122, 0.35); }
.check-list li.bad { border-color: rgba(230, 184, 77, 0.4); }
.check-list .ck {
  flex-shrink: 0;
  width: 1.15rem;
  text-align: center;
  font-weight: 700;
}
.check-list li.ok .ck { color: var(--ok); }
.check-list li.bad .ck { color: var(--warn); }
.check-list .ck-body { min-width: 0; }
.check-list .ck-label { font-weight: 650; }
.check-list .ck-detail { color: var(--muted); font-size: 0.8rem; margin-top: 0.15rem; }
.check-list .ck-fix { color: var(--accent); font-size: 0.78rem; margin-top: 0.2rem; }

/* Cycle history timeline */
.timeline {
  list-style: none;
  margin: 0.65rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  border-left: 2px solid var(--border);
  margin-left: 0.55rem;
}
.timeline li {
  position: relative;
  padding: 0.55rem 0 0.55rem 1.1rem;
  font-size: 0.88rem;
  line-height: 1.35;
}
.timeline li::before {
  content: "";
  position: absolute;
  left: -0.42rem;
  top: 0.85rem;
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  background: var(--muted);
  border: 2px solid var(--card, var(--bg));
  box-shadow: 0 0 0 1px var(--border);
}
.timeline li.ok::before { background: var(--ok); }
.timeline li.bad::before { background: var(--danger, #e85d5d); }
.timeline li.dry::before { background: var(--warn); }
.timeline .tl-when {
  font-weight: 650;
  font-size: 0.82rem;
}
.timeline .tl-sum {
  color: var(--text);
  margin-top: 0.12rem;
}
.timeline .tl-plain {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 0.15rem;
}
.timeline .tl-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.3rem;
}
.timeline .tl-badge {
  font-size: 0.7rem;
  font-weight: 650;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: rgba(0, 0, 0, 0.12);
}
html[data-theme="light"] .timeline .tl-badge {
  background: rgba(0, 0, 0, 0.04);
}
.timeline .tl-badge.ok { color: var(--ok); border-color: rgba(93, 202, 122, 0.35); }
.timeline .tl-badge.bad { color: var(--danger, #e85d5d); border-color: rgba(232, 93, 93, 0.35); }
.timeline .tl-badge.dry { color: var(--warn); border-color: rgba(230, 184, 77, 0.4); }
.timeline .tl-badge.skip { opacity: 0.85; }

.tabs {
  display: flex;
  gap: 0.35rem;
  padding: 0.75rem 1.25rem 0.35rem;
  flex-wrap: wrap;
  max-width: 1200px;
  margin: 0 auto;
  -webkit-overflow-scrolling: touch;
}
.tab-short { display: none; }
.tab-full { display: inline; }

.tab {
  border: 1px solid var(--border);
  background: var(--chip);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.45rem 0.95rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex: 0 0 auto;
  -webkit-tap-highlight-color: transparent;
}
.tab:hover { color: var(--text); }
.tab.active {
  background: rgba(61, 214, 198, 0.15);
  color: var(--accent);
  border-color: var(--accent-dim);
}

main { max-width: 1200px; margin: 0 auto; padding: 1rem 1.25rem 2rem; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.story {
  background: var(--story-bg);
  border: 1px solid var(--story-border);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  margin: 0 0 0.9rem;
  color: var(--story-text);
  line-height: 1.45;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem 1rem;
}
.stat-card.accent { border-color: rgba(61, 214, 198, 0.35); }
.stat-card.danger { border-color: rgba(239, 107, 107, 0.35); }
.stat-label { color: var(--muted); font-size: 0.8rem; margin-bottom: 0.25rem; }
.stat-value { font-size: 1.45rem; font-weight: 700; }
.stat-value.sm { font-size: 1.05rem; line-height: 1.25; }
.stat-sub { color: var(--muted); font-size: 0.78rem; margin-top: 0.25rem; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
  margin-bottom: 0.9rem;
}

.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent 35%), var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.1rem 1.15rem;
  margin-bottom: 0.9rem;
  box-shadow: var(--shadow);
}

.card h2 {
  margin: 0 0 0.65rem;
  font-size: 1rem;
  font-weight: 650;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.card-head h2 { margin: 0; }

.badge {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  background: rgba(61, 214, 198, 0.12);
  border: 1px solid rgba(61, 214, 198, 0.25);
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
}

.hint { color: var(--muted); font-size: 0.88rem; line-height: 1.45; margin: 0.35rem 0 0.75rem; }
.page-intro { margin: 0 0 0.85rem; max-width: 52rem; }
.intro-card .steps-list {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.5;
}
.intro-card .steps-list li { margin: 0.35rem 0; }
.intro-card .steps-list strong { color: var(--accent); }

/* Start here — primary onboarding card */
.start-here-card {
  border-color: rgba(61, 214, 198, 0.35);
  box-shadow: 0 0 0 1px rgba(61, 214, 198, 0.08), var(--shadow);
}
.start-here-card h2 { margin-bottom: 0.15rem; }
.start-checklist {
  list-style: none;
  margin: 0.85rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.start-item {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.12);
}
html[data-theme="light"] .start-item {
  background: rgba(13, 159, 146, 0.04);
}
.start-item[data-state="ok"] {
  border-color: rgba(93, 202, 122, 0.4);
}
.start-item[data-state="warn"] {
  border-color: rgba(230, 184, 77, 0.45);
}
.start-mark {
  flex-shrink: 0;
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--chip);
  color: var(--muted);
  border: 1px solid var(--border);
}
.start-item[data-state="ok"] .start-mark {
  background: rgba(93, 202, 122, 0.18);
  color: var(--ok);
  border-color: rgba(93, 202, 122, 0.35);
}
.start-item[data-state="warn"] .start-mark {
  background: rgba(230, 184, 77, 0.15);
  color: var(--warn);
  border-color: rgba(230, 184, 77, 0.4);
}
.start-title {
  font-weight: 650;
  font-size: 0.92rem;
}
.start-detail {
  margin: 0.2rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
}
.start-actions .btn { min-height: 2.5rem; }
.money-legend-wrap,
.start-extra-actions {
  margin-top: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.35rem 0.7rem 0.5rem;
  background: rgba(0, 0, 0, 0.08);
}
html[data-theme="light"] .money-legend-wrap,
html[data-theme="light"] .start-extra-actions {
  background: rgba(0, 0, 0, 0.03);
}
.money-legend-wrap summary,
.start-extra-actions summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 650;
  padding: 0.3rem 0;
  user-select: none;
}
.money-legend {
  list-style: none;
  margin: 0.45rem 0 0;
  padding: 0;
}
.money-legend li {
  margin: 0.25rem 0;
  font-size: 0.84rem;
  line-height: 1.4;
}
.money-legend strong { color: var(--accent); }

/* Account chip in header */
.account-chip {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  max-width: 12rem;
}
.account-email {
  font-size: 0.72rem;
  color: var(--muted);
  max-width: 7rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}
.account-main { width: min(28rem, 100%); }
.account-card {
  padding-top: 1.15rem;
}
.account-card h1 { margin: 0.65rem 0 0.35rem; font-size: 1.35rem; }
.account-brand {
  display: block;
  width: 100%;
  margin: 0 0 0.35rem;
  line-height: 0;
}
.account-brand .brand-wordmark {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  max-height: none;
  object-fit: contain;
  object-position: center;
}
.account-form {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 0.85rem;
}
.account-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  font-weight: 650;
}
.account-form input {
  font: inherit;
  font-weight: 400;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
}
.pw-field {
  display: flex;
  gap: 0.4rem;
  align-items: stretch;
}
.pw-field input {
  flex: 1 1 auto;
  min-width: 0;
}
.pw-field .pw-toggle {
  flex: 0 0 auto;
  align-self: center;
}
.account-tabs { margin-top: 0.75rem; }
.account-tab.active {
  border-color: var(--accent);
  color: var(--accent);
}
.account-switch {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: flex-start;
}
.account-switch .hint { margin: 0; }
.account-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin: 0.15rem 0 0.85rem;
  font-size: 0.9rem;
}
.account-links a {
  color: var(--accent);
  font-weight: 650;
  text-decoration: none;
}
.account-links a:hover { text-decoration: underline; }
.reset-link-box {
  margin-top: 0.85rem;
  padding: 0.75rem 0.85rem;
  border-radius: 10px;
  border: 1px solid rgba(61, 214, 198, 0.35);
  background: rgba(61, 214, 198, 0.08);
}
.reset-link-text {
  font-family: ui-monospace, monospace;
  font-size: 0.82rem;
  word-break: break-all;
  margin: 0.35rem 0 0.65rem;
  color: var(--text);
}
.ai-insight-card {
  border-color: rgba(167, 139, 250, 0.4);
  background: linear-gradient(165deg, rgba(139, 92, 246, 0.1), transparent 50%), var(--card);
}
.ai-insight-meta {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0.25rem 0 0.5rem;
}
.ai-insight-body {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.45;
  white-space: pre-wrap;
}
.faculty-roster {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11.5rem, 1fr));
  gap: 0.5rem;
  margin: 0.5rem 0 0.85rem;
}
.faculty-chip-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.5rem 0.6rem 0.55rem;
  background: var(--chip);
  min-width: 0;
}
.faculty-chip-card.on {
  border-color: rgba(93, 202, 122, 0.4);
  background: rgba(93, 202, 122, 0.1);
}
.faculty-chip-card.off {
  opacity: 0.72;
}
.faculty-chip-name {
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.25;
}
.faculty-chip-role {
  margin-top: 0.2rem;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.3;
}
.faculty-chip-model {
  margin-top: 0.3rem;
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--muted);
  opacity: 0.9;
  letter-spacing: 0.01em;
  word-break: break-word;
}
.faculty-panel {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-bottom: 0.65rem;
}
.faculty-opinion {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  background: rgba(0, 0, 0, 0.12);
}
html[data-theme="light"] .faculty-opinion {
  background: rgba(0, 0, 0, 0.03);
}
.faculty-opinion h4 {
  margin: 0 0 0.15rem;
  font-size: 0.92rem;
}
.faculty-role-line {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 0.15rem;
  line-height: 1.35;
}
.faculty-model-line {
  font-size: 0.68rem;
  color: var(--muted);
  opacity: 0.9;
  margin: 0 0 0.4rem;
  word-break: break-word;
}
.faculty-opinion p {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.4;
  color: var(--text);
}
.faculty-opinion .focus-line {
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 650;
}
#aiScheduleHint {
  margin: 0.35rem 0 0;
}
.plan-row {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  margin: 0.45rem 0;
}
.plan-row strong { display: block; margin-bottom: 0.15rem; }
.admin-panel-card {
  border-color: rgba(239, 68, 68, 0.45);
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.12);
}
.admin-panel-card .badge.danger {
  color: #fecaca;
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(185, 28, 28, 0.35);
}
.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}
.admin-role-select {
  font: inherit;
  font-size: 0.8rem;
  padding: 0.25rem 0.35rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--input-bg, var(--card));
  color: var(--text);
}
.autonomy-banner.compact-pref .autonomy-detail {
  display: none;
}
#maintenanceBanner {
  background: rgba(239, 68, 68, 0.15);
  border-bottom: 1px solid rgba(239, 68, 68, 0.4);
  color: var(--text);
  padding: 0.55rem 1rem;
  text-align: center;
  font-weight: 650;
  font-size: 0.9rem;
}
#maintenanceBanner[hidden] { display: none !important; }

footer a,
footer .linkish {
  color: var(--accent);
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
footer .linkish:hover,
footer a:hover { opacity: 0.9; }

/* First-visit welcome */
.welcome-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(5, 10, 20, 0.72);
  backdrop-filter: blur(6px);
}
.welcome-modal[hidden] { display: none !important; }
.welcome-card {
  width: min(28rem, 100%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.25rem 1.35rem 1.35rem;
  box-shadow: var(--shadow);
}
.welcome-card h2 { margin: 0 0 0.5rem; }
.welcome-steps {
  margin: 0.75rem 0 0;
  padding-left: 1.2rem;
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.5;
}
.welcome-steps li { margin: 0.3rem 0; }
.welcome-never {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.9rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.welcome-never input {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--accent);
}

/* Journey milestone pills */
.journey-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.65rem 0 0.15rem;
}
.journey-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: rgba(0, 0, 0, 0.12);
}
html[data-theme="light"] .journey-pill {
  background: rgba(0, 0, 0, 0.04);
}
.journey-pill.done {
  color: var(--ok);
  border-color: rgba(93, 202, 122, 0.4);
  background: rgba(93, 202, 122, 0.12);
}
.journey-pill.current {
  color: var(--accent);
  border-color: rgba(61, 214, 198, 0.45);
  background: rgba(61, 214, 198, 0.12);
}

/* Coach — one recommended next step */
.coach-panel {
  margin: 0.75rem 0 0.35rem;
  padding: 0.85rem 0.95rem;
  border-radius: 14px;
  border: 1px solid rgba(61, 214, 198, 0.35);
  background: linear-gradient(
    135deg,
    rgba(61, 214, 198, 0.1) 0%,
    rgba(0, 0, 0, 0.12) 100%
  );
}
html[data-theme="light"] .coach-panel {
  background: linear-gradient(
    135deg,
    rgba(13, 159, 146, 0.1) 0%,
    rgba(255, 255, 255, 0.6) 100%
  );
}
.coach-stage {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.4rem;
}
.coach-progress {
  height: 0.35rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.2);
  overflow: hidden;
  margin-bottom: 0.65rem;
}
html[data-theme="light"] .coach-progress {
  background: rgba(0, 0, 0, 0.08);
}
.coach-progress-fill {
  height: 100%;
  width: 10%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.35s ease;
}
.coach-headline {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.3;
}
.coach-detail {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}
.coach-primary {
  font-size: 1rem;
  padding: 0.65rem 1.15rem;
  min-height: 2.75rem;
}

/* Simple nav: hide advanced tabs until "More tools" */
body.nav-simple .tab[data-nav="more"] {
  display: none !important;
}
body:not(.nav-simple) .tab-more-toggle .tab-full::before {
  content: none;
}
.tab-more-toggle.active,
body:not(.nav-simple) .tab-more-toggle {
  border-color: var(--accent);
  color: var(--accent);
}
.badge.ok {
  color: var(--ok);
  border-color: rgba(93, 202, 122, 0.35);
  background: rgba(93, 202, 122, 0.12);
}
.home-advanced {
  margin: 0.85rem 0 1rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.35rem 0.85rem 0.65rem;
  background: var(--card);
}
.home-advanced > summary {
  cursor: pointer;
  font-weight: 650;
  color: var(--muted);
  padding: 0.55rem 0.15rem;
  user-select: none;
  list-style: none;
}
.home-advanced > summary::-webkit-details-marker { display: none; }
.home-advanced > summary::before {
  content: "▸ ";
  color: var(--accent);
}
.home-advanced[open] > summary::before { content: "▾ "; }
.home-advanced-body {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding-bottom: 0.35rem;
}
.home-advanced-body > .card {
  margin: 0;
}
.tech-details {
  margin-top: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.35rem 0.65rem 0.5rem;
  background: rgba(0, 0, 0, 0.12);
}
html[data-theme="light"] .tech-details {
  background: rgba(0, 0, 0, 0.03);
}
.tech-details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
  user-select: none;
  padding: 0.25rem 0;
}
.tech-details[open] summary { margin-bottom: 0.35rem; }
.tech-details .output { margin-top: 0.25rem; }
.msg { min-height: 1.2rem; font-size: 0.88rem; color: var(--accent); margin: 0.5rem 0 0; }
.msg.err { color: var(--danger); }
.mt { margin-top: 0.85rem; }

.card h3 {
  margin: 1rem 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 650;
  letter-spacing: 0.01em;
}
.card h3:first-of-type {
  margin-top: 0.75rem;
}

.check-label {
  flex-direction: row !important;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.9rem;
  color: var(--muted);
  padding-bottom: 0.35rem;
}
.check-label input {
  width: auto;
  margin: 0;
}

.card code {
  font-size: 0.85em;
  color: var(--accent);
}

.row { display: flex; align-items: end; }
.gap { gap: 0.55rem; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 200px; }

label {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  font-size: 0.8rem;
  color: var(--muted);
}

input, select {
  background: var(--input-bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  font: inherit;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 0.55rem 0.9rem;
  font-weight: 650;
  cursor: pointer;
  background: var(--accent);
  color: var(--btn-text-on-accent);
}
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.secondary { background: var(--btn-secondary); color: var(--text); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.tiny { padding: 0.28rem 0.55rem; font-size: 0.8rem; }

.theme-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  background: var(--chip);
  flex-shrink: 0;
}
.theme-switch button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 650;
  padding: 0.35rem 0.65rem;
  cursor: pointer;
  min-height: 2rem;
}
.theme-switch button.active {
  background: rgba(61, 214, 198, 0.18);
  color: var(--accent);
}
html[data-theme="light"] .theme-switch button.active {
  background: rgba(13, 159, 146, 0.16);
}

.table-wrap { overflow: auto; max-height: 360px; margin-top: 0.5rem; }
.table-wrap.short { max-height: 240px; }
.table-wrap.feed { max-height: 420px; }

table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
th, td { text-align: left; padding: 0.48rem 0.4rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--card); z-index: 1; }
td.market { font-family: var(--mono); font-size: 0.74rem; max-width: 220px; word-break: break-all; color: var(--muted); }
tr.flash { animation: flashrow 1.2s ease; }
@keyframes flashrow {
  from { background: rgba(61, 214, 198, 0.18); }
  to { background: transparent; }
}

.output {
  margin-top: 0.85rem;
  background: var(--output-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 320px;
  overflow: auto;
  color: var(--output-text);
}
.output:empty { display: none; }

.gauge-bar,
.chip {
  background: var(--input-bg);
}

.plain-list { list-style: none; padding: 0; margin: 0; }
.plain-list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.plain-list li span:first-child { color: var(--muted); }
.plain-list li span:last-child { font-weight: 650; text-align: right; }

.milestone-list { list-style: none; padding: 0; margin: 0; }
.milestone-list li {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
}
.milestone-list .check {
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex: 0 0 auto;
  margin-top: 0.1rem;
}
.milestone-list li.done .check {
  background: var(--ok);
  border-color: var(--ok);
}
.milestone-list .mtitle { font-weight: 650; }
.milestone-list .mdetail { color: var(--muted); font-size: 0.82rem; margin-top: 0.15rem; }

.gauge-wrap { margin-top: 0.35rem; }
.gauge-bar {
  height: 12px;
  background: #0a101c;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.gauge-bar.tall { height: 16px; }
.gauge-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  transition: width 0.6s ease;
}
.gauge-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 0.45rem;
  font-size: 0.9rem;
}

.mini-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.75rem;
}
.chip {
  background: #0a101c;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
  font-size: 0.78rem;
  color: var(--muted);
}
.chip strong { color: var(--text); }

.bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 120px;
  padding: 0.35rem 0 0.15rem;
}
.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  min-width: 0;
  height: 100%;
}
.bar-stack {
  width: 100%;
  max-width: 18px;
  display: flex;
  flex-direction: column-reverse;
  gap: 1px;
  height: 100%;
  justify-content: flex-start;
}
.bar-seg { width: 100%; border-radius: 2px 2px 0 0; min-height: 0; }
.bar-seg.trade { background: var(--accent); }
.bar-seg.pass { background: var(--pass); }
.bar-seg.other { background: #4a5670; }
.bar-label {
  font-size: 0.58rem;
  color: var(--muted);
  margin-top: 0.2rem;
  transform: rotate(-45deg);
  white-space: nowrap;
  height: 0.9rem;
}

.legend {
  display: flex;
  gap: 0.9rem;
  margin-top: 0.55rem;
  font-size: 0.78rem;
  color: var(--muted);
}
.legend span { display: inline-flex; align-items: center; gap: 0.3rem; }
.swatch {
  display: inline-block;
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 2px;
}
.swatch.trade { background: var(--accent); }
.swatch.pass { background: var(--pass); }
.swatch.other { background: #4a5670; }

.reliability { display: flex; flex-direction: column; gap: 0.55rem; }
.rel-row {
  display: grid;
  grid-template-columns: 72px 1fr 90px;
  gap: 0.55rem;
  align-items: center;
  font-size: 0.82rem;
}
.rel-label { color: var(--muted); }
.rel-track {
  position: relative;
  height: 12px;
  background: #0a101c;
  border: 1px solid var(--border);
  border-radius: 999px;
}
.rel-guess {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  background: rgba(61, 214, 198, 0.35);
  border-radius: 999px;
}
.rel-actual {
  position: absolute;
  top: -3px; bottom: -3px;
  width: 3px;
  background: var(--ok);
  border-radius: 2px;
}
.rel-count { color: var(--muted); text-align: right; }
.rel-empty { color: var(--muted); font-size: 0.88rem; }

.pill {
  display: inline-block;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}
.pill.ok { background: rgba(93, 202, 122, 0.15); color: var(--ok); }
.pill.bad { background: rgba(239, 107, 107, 0.15); color: var(--danger); }
.pill.warn { background: rgba(230, 184, 77, 0.15); color: var(--warn); }

.grade-good { color: var(--ok); font-weight: 700; }
.grade-miss { color: var(--danger); font-weight: 700; }
.grade-neutral { color: var(--muted); }

footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 0.5rem 1rem 1.5rem;
}

@media (max-width: 960px) {
  .stat-row { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .rel-row { grid-template-columns: 64px 1fr 70px; }
}
@media (max-width: 560px) {
  .stat-row { grid-template-columns: 1fr; }
}

/* ========== Mobile / narrow screens ========== */
@media (max-width: 900px) {
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .autonomy-inner { grid-template-columns: 1fr 1fr; }
  .autonomy-summary { grid-column: 1 / -1; }
}

@media (max-width: 720px) {
  :root { --header-h: auto; }

  .top {
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.7rem 0.85rem;
    align-items: flex-start;
  }
  .brand-wordmark {
    height: 30px;
    max-width: min(240px, 70vw);
  }
  .header-right {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.45rem;
  }
  .theme-switch {
    order: 3;
    width: 100%;
    justify-content: stretch;
  }
  .theme-switch button { flex: 1; }
  .header-text { text-align: left; flex: 1; min-width: 0; }
  .header-status {
    font-size: 0.78rem;
    line-height: 1.35;
    word-break: break-word;
  }
  .header-status .pill { display: inline-block; margin: 0.1rem 0.15rem 0.1rem 0; }
  .refresh-hint { display: none; }

  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    max-width: none;
    margin: 0;
    padding: 0.55rem 0.75rem;
    gap: 0.4rem;
    scrollbar-width: none;
    border-bottom: 1px solid var(--border);
    background: var(--tabs-bg);
    position: sticky;
    top: 0;
    z-index: 18;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab {
    padding: 0.42rem 0.75rem;
    font-size: 0.84rem;
  }
  .tab-full { display: none; }
  .tab-short { display: inline; }

  /* Keep logo bar above tabs in document flow; tabs sticky under it is complex —
     use simpler stacking: header not sticky on mobile, tabs sticky */
  .top { position: relative; z-index: 19; }

  .banner-toggle {
    display: flex;
  }
  .autonomy-banner {
    position: relative;
    top: auto;
  }
  .autonomy-banner.collapsed .autonomy-inner {
    display: none;
  }
  .autonomy-inner {
    grid-template-columns: 1fr 1fr;
    padding: 0.55rem 0.75rem 0.75rem;
    gap: 0.55rem;
  }
  .autonomy-summary {
    grid-column: 1 / -1;
    padding: 0.15rem 0.1rem 0.35rem;
  }
  .autonomy-tile.tile-real {
    grid-column: auto;
  }
  .autonomy-detail { min-height: 0; }
  .autonomy-controls .mode-btn {
    flex: 1 1 auto;
    text-align: center;
    min-height: 2.25rem;
  }

  main {
    padding: 0.75rem 0.75rem 5rem;
  }
  .stat-row {
    grid-template-columns: 1fr 1fr;
    gap: 0.55rem;
  }
  .stat-card { padding: 0.7rem 0.75rem; }
  .stat-value { font-size: 1.2rem; }
  .stat-value.sm { font-size: 0.95rem; }

  .card {
    padding: 0.85rem 0.85rem 1rem;
    border-radius: 10px;
  }
  .row.gap.wrap {
    gap: 0.45rem;
  }
  .btn {
    padding: 0.6rem 0.85rem;
    min-height: 2.5rem;
  }
  label { min-width: min(100%, 10rem); flex: 1 1 10rem; }
  input, select {
    width: 100%;
    min-height: 2.5rem;
    font-size: 16px; /* prevent iOS zoom */
  }

  .table-wrap {
    max-height: none;
    margin-left: -0.15rem;
    margin-right: -0.15rem;
  }
  table { font-size: 0.8rem; }
  th, td { padding: 0.45rem 0.35rem; }
  td.market { max-width: 140px; }

  .output {
    max-height: 240px;
    font-size: 0.75rem;
  }
  .story {
    font-size: 0.9rem;
    padding: 0.75rem 0.85rem;
  }
  footer {
    padding: 0.85rem;
    font-size: 0.75rem;
    line-height: 1.4;
  }
}

@media (max-width: 420px) {
  .stat-row { grid-template-columns: 1fr; }
  .brand-wordmark { height: 26px; max-width: 78vw; }
  .tab { padding: 0.4rem 0.65rem; font-size: 0.8rem; }
}
