:root {
  --ink: #08090b;
  --panel: #131418;
  --panel-raised: #1a1b21;
  --hairline: #2a2b33;
  --hairline-soft: rgba(255,255,255,0.06);
  --paper: #eceef2;
  --ink-2: #7c7e8c;
  --gold: #cda149;
  --gold-dim: rgba(205, 161, 73, 0.14);
  --buy: #35c78a;
  --buy-dim: rgba(53, 199, 138, 0.14);
  --sell: #e5566a;
  --sell-dim: rgba(229, 86, 106, 0.14);
  --none: #6f8fae;
  --none-dim: rgba(111, 143, 174, 0.14);
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable", "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
}

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

html, body {
  background: var(--ink);
  color: var(--paper);
}

body {
  margin: 0;
  font-family: var(--font-display);
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  overflow-x: hidden;
}

.app-shell {
  width: 100%;
  max-width: 460px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  background:
    radial-gradient(120% 60% at 50% 0%, rgba(205,161,73,0.10) 0%, rgba(205,161,73,0) 60%),
    var(--ink);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 18px 24px 14px;
  flex-shrink: 0;
}

.brand { display: flex; align-items: center; gap: 10px; }

.mark { width: 26px; height: 26px; flex-shrink: 0; }

.wordmark { display: flex; flex-direction: column; line-height: 1.15; }

.wordmark .ticker {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0.02em;
  color: var(--paper);
}

.wordmark .sub {
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.version-toggle {
  display: flex;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: 100px;
  padding: 3px;
  gap: 2px;
  flex-shrink: 0;
}

.version-btn {
  border: none;
  background: transparent;
  color: var(--ink-2);
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 5px 12px;
  border-radius: 100px;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.version-btn.active { background: var(--gold-dim); color: var(--gold); }
.version-btn:disabled { cursor: default; opacity: 0.6; }

.screens {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 24px 32px;
  transition: transform 0.46s cubic-bezier(.22,.9,.32,1), opacity 0.4s ease;
}

.screen--idle { justify-content: center; transform: translateX(0); opacity: 1; }
.screen--idle.leaving { transform: translateX(-22%); opacity: 0; }

.screen--result {
  justify-content: flex-start;
  padding-top: 6vh;
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.screen--result.entered { transform: translateX(0); opacity: 1; pointer-events: auto; }

/* ---- Idle screen ---- */

.gauge-wrap {
  position: relative;
  width: 216px;
  height: 216px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gauge-ring { position: absolute; inset: 0; transform: rotate(-90deg); pointer-events: none; }
.gauge-ring circle { fill: none; stroke-width: 1.5; }
.gauge-ring .track { stroke: var(--hairline); }

.gauge-ring .sweep {
  stroke: var(--gold);
  stroke-linecap: round;
  stroke-dasharray: 40 616;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.gauge-wrap.pending .gauge-ring .sweep {
  opacity: 1;
  animation: sweep-rotate 1.35s linear infinite;
}

@keyframes sweep-rotate { to { transform: rotate(360deg); } }

.gauge-btn {
  width: 168px;
  height: 168px;
  border-radius: 50%;
  border: 1px solid var(--hairline);
  background: linear-gradient(160deg, var(--panel-raised), var(--panel) 70%);
  color: var(--paper);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.15s ease, border-color 0.3s ease;
}

.gauge-btn:active { transform: scale(0.96); }
.gauge-btn:not(:disabled):hover { border-color: rgba(205, 161, 73, 0.5); }
.gauge-btn:disabled { cursor: default; }

.gauge-icon { width: 30px; height: 30px; color: var(--gold); }
.gauge-label { font-size: 15px; font-weight: 650; letter-spacing: 0.02em; }

.gauge-sub {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.idle-hint {
  margin: 28px 0 0;
  font-size: 13.5px;
  color: var(--ink-2);
  text-align: center;
  max-width: 260px;
  line-height: 1.5;
}

.status-row {
  margin-top: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.status-row.error { color: var(--sell); }

.status-row .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  animation: pulse-dot 1.4s ease-in-out infinite;
}

.status-row.error .dot { background: var(--sell); animation: none; }

@keyframes pulse-dot { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }

/* ---- Result screen (trade ticket) ---- */

.ticket {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 24px 60px -24px rgba(0,0,0,0.6);
}

.ticket-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 22px 22px 20px;
}

.bias-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.bias-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.bias-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.bias-pill.buy { background: var(--buy-dim); color: var(--buy); }
.bias-pill.sell { background: var(--sell-dim); color: var(--sell); }
.bias-pill.none { background: var(--none-dim); color: var(--none); }

.confidence-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border: 1px solid transparent;
}
.confidence-chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.confidence-chip.low { background: var(--sell-dim); color: var(--sell); }
.confidence-chip.medium { background: var(--gold-dim); color: var(--gold); }
.confidence-chip.high { background: var(--buy-dim); color: var(--buy); }
.confidence-chip.neutral { background: transparent; border-color: var(--hairline); color: var(--ink-2); }
.confidence-chip.neutral::before { display: none; }
.confidence-chip[hidden] { display: none; }

.ticket-time {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.perforation {
  position: relative;
  height: 1px;
  background: repeating-linear-gradient(to right, var(--hairline) 0 6px, transparent 6px 12px);
  margin: 0;
}

.perforation::before, .perforation::after {
  content: "";
  position: absolute;
  top: -9px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--ink);
  border: 1px solid var(--hairline);
}

.perforation::before { left: -10px; }
.perforation::after { right: -10px; }

.ticket-stats { display: flex; flex-direction: column; }
.ticket-stats > * + * { border-top: 1px solid var(--hairline-soft); }
.ticket-stats[hidden] { display: none; }

.stat-row { display: flex; align-items: baseline; justify-content: space-between; padding: 13px 22px; gap: 12px; }
.stat-row[hidden] { display: none; }
.stat-label { font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
.stat-value { font-family: var(--font-mono); font-size: 14px; font-weight: 600; color: var(--paper); font-variant-numeric: tabular-nums; white-space: nowrap; }

.stat-value-group { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.stat-delta { font-family: var(--font-mono); font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat-delta.above { color: var(--buy); }
.stat-delta.below { color: var(--sell); }

.stat-block { padding: 13px 22px; }
.stat-block[hidden] { display: none; }
.stat-prose { margin: 6px 0 0; font-size: 13px; line-height: 1.55; color: var(--paper); }

.liquidity-grid { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.liq-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.liq-half { display: flex; align-items: baseline; gap: 6px; flex: 1; }
.liq-half.align-end { justify-content: flex-end; }
.liq-label { font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em; color: var(--ink-2); }
.liq-value { font-family: var(--font-mono); font-size: 13px; font-weight: 600; color: var(--paper); font-variant-numeric: tabular-nums; white-space: nowrap; }
.liq-value.near { color: var(--gold); font-weight: 700; }
.liq-value.near::after { content: ""; display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--gold); margin-left: 6px; vertical-align: middle; }

.ticket-keypoints { padding: 18px 22px 22px; border-top: 1px solid var(--hairline); }
.ticket-keypoints[hidden] { display: none; }
.section-label { display: block; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); margin-bottom: 10px; }
.key-summary { margin: 0 0 14px; font-size: 13.5px; line-height: 1.6; font-weight: 500; color: var(--paper); }
.key-summary[hidden] { display: none; }

.key-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.key-list li { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; line-height: 1.55; color: var(--paper); }
.key-index {
  flex-shrink: 0;
  width: 18px; height: 18px;
  border-radius: 5px;
  background: var(--gold-dim);
  color: var(--gold);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin-top: 1px;
}

.raw-fallback {
  margin: 0;
  padding: 22px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.75;
  color: var(--paper);
  white-space: pre-wrap;
}
.raw-fallback[hidden] { display: none; }

.session-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 18px 2px 0;
  padding: 15px 16px;
  border: 1px solid var(--hairline);
  border-radius: 14px;
  color: var(--paper);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 550;
  background: var(--panel);
  transition: transform 0.15s ease, border-color 0.2s ease;
}

.session-row[hidden] { display: none; }
.session-row:active { transform: scale(0.98); }
.session-row:hover { border-color: rgba(205,161,73,0.4); }
.session-row .chev { color: var(--gold); font-family: var(--font-mono); }

.again-btn {
  width: 100%;
  margin-top: 14px;
  padding: 15px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-2);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.2s ease, transform 0.15s ease;
}

.again-btn:active { transform: scale(0.98); }
.again-btn:hover { color: var(--paper); }

@media (prefers-reduced-motion: reduce) {
  .screen, .gauge-btn, .session-row, .again-btn { transition: none !important; }
  .gauge-ring .sweep, .status-row .dot { animation: none !important; }
}

/* ---- Screen switcher (Daily Bias / Scalping) ---- */

.screen-tabs {
  display: flex;
  gap: 4px;
  margin: 0 24px 14px;
  padding: 3px;
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  flex-shrink: 0;
}

.screen-tab {
  flex: 1;
  text-align: center;
  padding: 8px 10px;
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: 0.02em;
  color: var(--ink-2);
  text-decoration: none;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.screen-tab:hover { color: var(--paper); }
.screen-tab.active { background: var(--gold-dim); color: var(--gold); }

/* ---- Scalping screen ---- */

.last-read {
  margin-top: 22px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border: 1px solid var(--hairline);
  border-radius: 100px;
  background: var(--panel);
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}
.last-read:hover { color: var(--paper); border-color: rgba(205,161,73,0.4); }
.last-read .chev { color: var(--gold); }
.last-read[hidden] { display: none; }

.scalp-head { padding: 20px 22px 18px; display: flex; flex-direction: column; gap: 12px; }
.scalp-head[hidden] { display: none; }
.scalp-head-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.scalp-price { font-family: var(--font-mono); font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.scalp-bias-note { margin: 0; font-size: 13px; line-height: 1.5; color: var(--ink-2); }

.scalp-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.stale-chip {
  padding: 3px 8px;
  border-radius: 100px;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--sell-dim);
  color: var(--sell);
}
.stale-chip[hidden] { display: none; }

.scalp-section { padding: 18px 22px 20px; border-top: 1px solid var(--hairline); }
.scalp-section[hidden] { display: none; }

/* Level ladder */
.ladder { display: flex; flex-direction: column; }
.ladder-row {
  display: grid;
  grid-template-columns: 22px 104px 1fr;
  align-items: baseline;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--hairline-soft);
}
.ladder-row:first-child { border-top: none; }
.side-tag {
  width: 20px; height: 18px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  align-self: center;
}
.side-tag.r { background: var(--sell-dim); color: var(--sell); }
.side-tag.s { background: var(--buy-dim); color: var(--buy); }
.ladder-zone { font-family: var(--font-mono); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ladder-note { font-size: 12px; line-height: 1.45; color: var(--ink-2); }
.ladder-row.best .ladder-zone { color: var(--gold); }
.best-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--gold-dim);
  color: var(--gold);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  vertical-align: 1px;
}
.price-marker {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.price-marker::before, .price-marker::after { content: ""; flex: 1; height: 1px; background: rgba(205,161,73,0.45); }

/* Setup cards */
.setup-list { display: flex; flex-direction: column; gap: 10px; }
.setup-card {
  border: 1px solid var(--hairline);
  border-radius: 14px;
  background: var(--panel-raised);
  padding: 12px 14px;
}
.setup-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.setup-rank { font-family: var(--font-mono); font-size: 12px; font-weight: 700; color: var(--ink-2); }
.dir-pill {
  padding: 3px 9px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.dir-pill.long { background: var(--buy-dim); color: var(--buy); }
.dir-pill.short { background: var(--sell-dim); color: var(--sell); }
.setup-card .confidence-chip { margin-left: auto; padding: 3px 9px; font-size: 10px; }
.setup-trigger { margin: 8px 0 10px; font-size: 12.5px; line-height: 1.45; color: var(--paper); }
.setup-grid { display: grid; grid-template-columns: 1.3fr 0.8fr 1.2fr; gap: 8px; }
.setup-cell { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.setup-cell .k { font-size: 10px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); }
.setup-cell .v { font-family: var(--font-mono); font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.setup-cell .v.stop { color: var(--sell); }
.setup-cell .v.tgt { color: var(--buy); }

@media (prefers-reduced-motion: reduce) {
  .last-read { transition: none !important; }
}
