/* Sov Mobile — Monochrome Institutional Craft (Dark Obsidian + Paper Light)
   Single Token Sheet (I_hard: zero scattered hex) · CreedTaste D-01..D-28 Passthrough */

:root, [data-theme="dark"] {
  --stage-bg: #070709;
  --bezel-border: rgba(255, 255, 255, 0.11);
  --bezel-shadow: 0 34px 90px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(255, 255, 255, 0.04);
  --bg: #0f0f12;
  --chart-bg: #101013;
  --surface: #18181c;
  --surface-2: #222228;
  --surface-3: #2a2a31;
  --surface-glass: rgba(24, 24, 29, 0.86);
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --grid: rgba(255, 255, 255, 0.045);
  --text: #f3f2ee;
  --text-2: #9b9ca5;
  --text-3: #64656e;
  --ink-inv: #111114;
  --accent-pill-bg: #eceae3;
  --accent-pill-fg: #111114;
  --accent-pill-sub: #54534e;
  --sec-pill-bg: #25252b;
  --sec-pill-fg: #f3f2ee;
  --sec-pill-sub: #95969f;
  --pill-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  --sheet-bg: #151519;
  --scrim: rgba(0, 0, 0, 0.56);
  /* Chart monochrome palette */
  --c-bull-fill: #ecebe6;
  --c-bull-wick: #b4b4bc;
  --c-bear-fill: #5a5b64;
  --c-bear-wick: #5e5f68;
  --c-price-dot: rgba(243, 242, 238, 0.34);
  --c-target-line: rgba(236, 234, 227, 0.62);
  --c-entry-line: rgba(255, 255, 255, 0.28);
  --c-stop-line: rgba(255, 255, 255, 0.28);
  --c-crosshair: rgba(255, 255, 255, 0.26);
  --c-study-1: rgba(236, 234, 227, 0.55);
  --c-study-2: rgba(155, 156, 165, 0.45);
  --c-vp: rgba(255, 255, 255, 0.09);
  --c-draw: #eceae3;
  --c-alert: #d8c38d;
  --pos-tone: #b8e3c7;
  --neg-tone: #e5a3ac;
  --warn-bg: rgba(229, 163, 172, 0.14);
  --warn-fg: #f3b5bd;
}

[data-theme="paper"] {
  --stage-bg: #dcdce0;
  --bezel-border: rgba(0, 0, 0, 0.1);
  --bezel-shadow: 0 32px 84px rgba(0, 0, 0, 0.16), 0 0 0 1px rgba(0, 0, 0, 0.05);
  --bg: #f4f4f6;
  --chart-bg: #f1f1f3;
  --surface: #e9e9ed;
  --surface-2: #ffffff;
  --surface-3: #e3e3e8;
  --surface-glass: rgba(255, 255, 255, 0.92);
  --line: rgba(0, 0, 0, 0.08);
  --line-strong: rgba(0, 0, 0, 0.16);
  --grid: rgba(0, 0, 0, 0.055);
  --text: #141418;
  --text-2: #686a73;
  --text-3: #90929b;
  --ink-inv: #f7f7f9;
  --accent-pill-bg: #151519;
  --accent-pill-fg: #f7f7f9;
  --accent-pill-sub: #a0a1aa;
  --sec-pill-bg: #ffffff;
  --sec-pill-fg: #141418;
  --sec-pill-sub: #747680;
  --pill-shadow: 0 6px 18px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --sheet-bg: #f7f7f9;
  --scrim: rgba(15, 16, 22, 0.28);
  /* Paper monochrome chart palette */
  --c-bull-fill: #a3a4ad;
  --c-bull-wick: #868791;
  --c-bear-fill: #151519;
  --c-bear-wick: #2b2b32;
  --c-price-dot: rgba(20, 20, 24, 0.34);
  --c-target-line: rgba(20, 20, 24, 0.56);
  --c-entry-line: rgba(20, 20, 24, 0.25);
  --c-stop-line: rgba(20, 20, 24, 0.26);
  --c-crosshair: rgba(20, 20, 24, 0.28);
  --c-study-1: rgba(20, 20, 24, 0.55);
  --c-study-2: rgba(110, 112, 122, 0.48);
  --c-vp: rgba(0, 0, 0, 0.08);
  --c-draw: #151519;
  --c-alert: #7c6020;
  --pos-tone: #1d6b42;
  --neg-tone: #9f2d3f;
  --warn-bg: rgba(159, 45, 63, 0.1);
  --warn-fg: #8c2334;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%; width: 100%;
  background: var(--stage-bg); color: var(--text);
  font: 450 13px/1.4 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  user-select: none;
  transition: background 0.2s ease;
}

/* Desktop presentation stage (auto-flattens edge-to-edge on actual phones!) */
.stage {
  width: 100%; height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
}

.desk-bar {
  position: fixed; top: 16px; right: 18px; z-index: 50;
  display: flex; align-items: center; gap: 6px;
  padding: 4px; border-radius: 99px;
  background: var(--surface-glass); border: 1px solid var(--line-strong);
  backdrop-filter: blur(18px);
  box-shadow: var(--pill-shadow);
}
.desk-btn {
  height: 28px; padding: 0 11px; border-radius: 99px;
  border: 0; background: transparent; color: var(--text-2);
  font: 550 11.5px 'Inter', system-ui, sans-serif; cursor: pointer;
  transition: background 0.12s, color 0.12s; white-space: nowrap;
}
.desk-btn:hover { color: var(--text); }
.desk-btn.active { background: var(--accent-pill-bg); color: var(--accent-pill-fg); }

.device {
  width: 398px; height: min(844px, calc(100dvh - 36px));
  border-radius: 40px;
  background: var(--bg);
  border: 1px solid var(--bezel-border);
  box-shadow: var(--bezel-shadow);
  display: flex; flex-direction: column;
  overflow: hidden; position: relative;
  transition: width 0.2s ease, height 0.2s ease, border-radius 0.2s ease;
}
body.full-bleed .device {
  width: 100vw; height: 100dvh; border-radius: 0; border: 0; box-shadow: none;
}

@media (max-width: 540px) {
  .desk-bar { display: none; }
  .device {
    width: 100vw; height: 100dvh; border-radius: 0; border: 0; box-shadow: none;
  }
}

/* Top Header — Exact Match to Mockup */
.hdr {
  height: 54px; padding: 8px 14px 6px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  flex-shrink: 0; background: var(--bg); z-index: 12;
}
.sym-btn {
  display: inline-flex; align-items: baseline; gap: 7px;
  padding: 5px 7px 5px 4px; border-radius: 10px;
  border: 0; background: transparent; color: var(--text);
  cursor: pointer; min-width: 0; transition: background 0.12s;
}
.sym-btn:hover { background: var(--surface); }
.sym-code { font: 600 18px/1 'Inter', sans-serif; letter-spacing: -0.025em; }
.sym-chev { color: var(--text-3); display: inline-flex; align-items: center; transform: translateY(-1px); }
.sym-px { font: 550 13.5px/1 'Inter', sans-serif; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.sym-chg { font: 500 11.5px/1 'Inter', sans-serif; color: var(--text-2); font-variant-numeric: tabular-nums; }

.hdr-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.theme-mini {
  width: 30px; height: 30px; border-radius: 99px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--text-2); display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background 0.12s, color 0.12s;
}
.theme-mini:hover { color: var(--text); background: var(--surface-2); }
.acct-pill {
  height: 30px; padding: 0 9px 0 6px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--text); display: inline-flex; align-items: center; gap: 6px;
  font: 550 12px 'Inter', sans-serif; cursor: pointer;
  transition: background 0.12s, border-color 0.12s; white-space: nowrap;
}
.acct-pill:hover { background: var(--surface-2); border-color: var(--line-strong); }
.acct-badge {
  width: 18px; height: 18px; border-radius: 5px;
  background: var(--surface-3); color: var(--text-2);
  font: 600 10px 'Inter', sans-serif;
  display: inline-flex; align-items: center; justify-content: center;
}

/* Tab Content Screens */
.screens { flex: 1; min-height: 0; position: relative; overflow: hidden; display: flex; flex-direction: column; }
.screen { display: none; flex: 1; min-height: 0; flex-direction: column; position: relative; }
.screen.active { display: flex; }

/* CHART SCREEN */
.chart-stage {
  flex: 1; min-height: 0; position: relative;
  background: var(--chart-bg);
  touch-action: none; overflow: hidden;
}
.chart-canvas {
  position: absolute; inset: 0; width: 100%; height: 100%; display: block;
}
#c-overlay { pointer-events: none; }

/* Quiet HUD Top-Left inside Chart (OHLC crosshair readout + SIM tag when inspecting) */
.chart-hud-tl {
  position: absolute; top: 8px; left: 12px; z-index: 6;
  display: flex; align-items: center; gap: 6px; pointer-events: none;
}
.hud-chip {
  font: 500 10.5px 'JetBrains Mono', ui-monospace, monospace;
  color: var(--text-2); padding: 3px 7px; border-radius: 6px;
  background: var(--surface-glass); border: 1px solid var(--line);
  backdrop-filter: blur(10px); font-variant-numeric: tabular-nums;
}
.hud-chip.hidden { display: none; }

/* Auto-Fit Pill (appears only when user pans away from latest bars!) */
.auto-btn {
  position: absolute; bottom: 28px; right: 74px; z-index: 8;
  height: 24px; padding: 0 9px; border-radius: 7px;
  border: 1px solid var(--line-strong); background: var(--surface-glass);
  color: var(--text); font: 600 10.5px 'Inter', sans-serif;
  cursor: pointer; backdrop-filter: blur(12px);
  display: none;
}
.auto-btn.show { display: inline-flex; align-items: center; gap: 4px; }

/* ON-CHART DRAGGABLE BRACKET & POSITION PILLS (Zero-bounce D-06 Precision!) */
.onchart-layer {
  position: absolute; inset: 0; z-index: 9; pointer-events: none; overflow: hidden;
}
.bracket-row {
  position: absolute; left: 0; right: 0; height: 0;
  pointer-events: none;
}
.b-pill {
  position: absolute; left: 10px; transform: translateY(-50%);
  height: 28px; padding: 0 11px 0 8px; border-radius: 99px;
  display: inline-flex; align-items: center; gap: 6px;
  font: 600 11.5px 'Inter', sans-serif; font-variant-numeric: tabular-nums;
  pointer-events: auto; cursor: ns-resize; touch-action: none;
  box-shadow: var(--pill-shadow); white-space: nowrap;
}
.b-pill.target {
  background: var(--accent-pill-bg); color: var(--accent-pill-fg);
}
.b-pill.stop {
  background: var(--sec-pill-bg); color: var(--sec-pill-fg);
  border: 1px solid var(--line-strong);
}
.b-pill.entry {
  background: var(--sec-pill-bg); color: var(--sec-pill-fg);
  border: 1px solid var(--line); cursor: default; padding: 0 11px;
}
.b-pill.dragging {
  outline: 2px solid var(--text); outline-offset: 1px;
}
.grip {
  display: grid; grid-template-columns: repeat(2, 2.5px); gap: 2.5px; opacity: 0.65;
}
.grip i { width: 2.5px; height: 2.5px; border-radius: 50%; background: currentColor; display: block; }

.close-pill {
  position: absolute; transform: translateY(-50%);
  height: 26px; padding: 0 10px; border-radius: 99px;
  border: 1px solid var(--line-strong);
  background: var(--sec-pill-bg); color: var(--sec-pill-fg);
  font: 600 11px 'Inter', sans-serif; cursor: pointer;
  pointer-events: auto; box-shadow: var(--pill-shadow);
  transition: opacity 0.12s;
}
.close-pill:hover { opacity: 0.85; }

.axis-tag {
  position: absolute; right: 4px; transform: translateY(-50%);
  padding: 2.5px 6px; border-radius: 5px;
  font: 600 10px 'JetBrains Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums; white-space: nowrap;
  pointer-events: none;
}
.axis-tag.target { background: var(--accent-pill-bg); color: var(--accent-pill-fg); }
.axis-tag.stop, .axis-tag.entry {
  background: var(--sec-pill-bg); color: var(--text-2); border: 1px solid var(--line);
}
.axis-tag.live {
  background: var(--sec-pill-bg); color: var(--text); border: 1px solid var(--line-strong);
  text-align: center; line-height: 1.2; padding: 3px 6px;
}
.axis-tag.live small { display: block; font-size: 9px; color: var(--text-2); font-weight: 500; }

/* FLOATING RIGHT-SIDE BUY / QTY / SELL STACK (Exact Mockup Proportions) */
.trade-stack {
  position: absolute; right: 74px; top: 53%; transform: translateY(-50%);
  z-index: 10; display: flex; flex-direction: column; align-items: stretch;
  gap: 6px; width: 82px;
  transition: opacity 0.14s ease;
}
.trade-stack.dimmed { opacity: 0.22; pointer-events: none; }
.trade-stack.hidden { display: none; }

.t-btn {
  border: 0; border-radius: 13px; padding: 8px 6px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px; cursor: pointer; box-shadow: var(--pill-shadow);
  transition: opacity 0.1s;
}
.t-btn:active { opacity: 0.82; }
.t-btn strong { font: 600 14px/1.15 'Inter', sans-serif; letter-spacing: -0.015em; }
.t-btn span { font: 500 10px/1.1 'JetBrains Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.t-btn.buy { background: var(--accent-pill-bg); color: var(--accent-pill-fg); }
.t-btn.buy span { color: var(--accent-pill-sub); }
.t-btn.sell { background: var(--sec-pill-bg); color: var(--sec-pill-fg); border: 1px solid var(--line-strong); }
.t-btn.sell span { color: var(--sec-pill-sub); }

.qty-pill {
  height: 30px; border-radius: 99px;
  background: var(--sec-pill-bg); border: 1px solid var(--line);
  display: grid; grid-template-columns: 26px 1fr 26px; align-items: center;
  box-shadow: var(--pill-shadow);
}
.qty-pill button {
  border: 0; background: transparent; color: var(--text-2);
  font: 500 15px 'Inter', sans-serif; height: 100%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.qty-pill button:hover { color: var(--text); }
.qty-pill span {
  text-align: center; font: 600 13px 'Inter', sans-serif;
  color: var(--text); font-variant-numeric: tabular-nums;
}

/* Active Drawing Floating Banner (when a drawing tool is armed) */
.draw-banner {
  position: absolute; top: 10px; left: 12px; right: 12px; z-index: 15;
  display: none; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 10px; border-radius: 12px;
  background: var(--surface-glass); border: 1px solid var(--line-strong);
  backdrop-filter: blur(14px); box-shadow: var(--pill-shadow);
}
.draw-banner.show { display: flex; }
.draw-banner span { font: 550 11.5px 'Inter', sans-serif; color: var(--text); }
.db-actions { display: flex; gap: 5px; }
.mini-pill {
  height: 24px; padding: 0 8px; border-radius: 7px;
  border: 1px solid var(--line-strong); background: var(--surface-2);
  color: var(--text); font: 550 11px 'Inter', sans-serif; cursor: pointer;
}
.mini-pill.on { background: var(--accent-pill-bg); color: var(--accent-pill-fg); border-color: transparent; }

/* Bottom Timeframe + Draw Strip (Exact Mockup Match) */
.tf-bar {
  height: 48px; padding: 6px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--bg); border-top: 1px solid var(--line); flex-shrink: 0;
}
.tf-group { display: flex; align-items: center; gap: 2px; }
.tf-btn {
  height: 30px; min-width: 34px; padding: 0 8px; border-radius: 9px;
  border: 0; background: transparent; color: var(--text-2);
  font: 550 12.5px 'Inter', sans-serif; cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.tf-btn:hover { color: var(--text); }
.tf-btn.active {
  background: var(--sec-pill-bg); color: var(--text);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.14);
  border: 1px solid var(--line);
}
.draw-btn {
  height: 32px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--text); font: 550 12.5px 'Inter', sans-serif;
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.draw-btn:hover { background: var(--surface-2); border-color: var(--line-strong); }
.draw-btn.armed { background: var(--accent-pill-bg); color: var(--accent-pill-fg); border-color: transparent; }

/* Bottom Navigation Bar (Watchlist · Chart · Accounts) */
.bnav {
  height: 60px; padding: 6px 14px env(safe-area-inset-bottom, 8px);
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--bg); border-top: 1px solid var(--line); flex-shrink: 0;
}
.bnav-btn {
  border: 0; background: transparent; color: var(--text-3);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; cursor: pointer; font: 550 10.5px 'Inter', sans-serif;
  transition: color 0.12s;
}
.bnav-btn svg { width: 19px; height: 19px; }
.bnav-btn.active { color: var(--text); }

/* WATCHLIST & ACCOUNTS SCREENS */
.scroll-pane {
  flex: 1; overflow-y: auto; padding: 12px 14px 20px;
  display: flex; flex-direction: column; gap: 10px;
}
.search-box {
  height: 36px; width: 100%; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--text); padding: 0 12px;
  font: 450 13px 'Inter', sans-serif; outline: none;
}
.search-box:focus { border-color: var(--line-strong); }

.wl-row {
  display: grid; grid-template-columns: 1fr 78px auto; align-items: center; gap: 10px;
  padding: 11px 12px; border-radius: 13px;
  background: var(--surface); border: 1px solid var(--line);
  cursor: pointer; transition: background 0.12s, border-color 0.12s;
}
.wl-row:hover { background: var(--surface-2); border-color: var(--line-strong); }
.wl-row.active { border-color: var(--line-strong); }
.wl-sym { font: 600 14.5px 'Inter', sans-serif; display: flex; align-items: center; gap: 6px; }
.wl-nm { font: 450 11.5px 'Inter', sans-serif; color: var(--text-2); margin-top: 1px; }
.wl-px { font: 600 13.5px 'JetBrains Mono', ui-monospace, monospace; text-align: right; font-variant-numeric: tabular-nums; }
.wl-chg { font: 500 11px 'JetBrains Mono', ui-monospace, monospace; text-align: right; color: var(--text-2); margin-top: 1px; }
.wl-pos-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text); display: inline-block; }

.card {
  padding: 13px 14px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 10px;
}
.card-hd { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-k { font: 600 10.5px 'JetBrains Mono', monospace; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); }
.eq-big { font: 600 26px/1.1 'Inter', sans-serif; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.dd-bar { height: 5px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.dd-bar > i { display: block; height: 100%; border-radius: 99px; background: var(--text); transition: width 0.2s; }
.seg-row { display: flex; gap: 6px; flex-wrap: wrap; }
.seg-chip {
  height: 30px; padding: 0 11px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface-2);
  color: var(--text-2); font: 550 12px 'Inter', sans-serif; cursor: pointer;
}
.seg-chip.active { background: var(--accent-pill-bg); color: var(--accent-pill-fg); border-color: transparent; }

.row-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 0; border-top: 1px solid var(--line);
}
.row-item:first-child { border-top: 0; padding-top: 0; }

/* BOTTOM SHEETS (CreedTaste D-01/05: 140ms scale+fade on first open only!) */
.sheet-scrim {
  position: absolute; inset: 0; z-index: 30;
  background: var(--scrim); backdrop-filter: blur(4px);
  display: none; align-items: flex-end; justify-content: center;
}
.sheet-scrim.open { display: flex; }
.sheet {
  width: 100%; max-height: 76%;
  background: var(--sheet-bg); border-top: 1px solid var(--line-strong);
  border-radius: 22px 22px 0 0;
  padding: 10px 14px 18px;
  display: flex; flex-direction: column; gap: 10px;
  animation: sheetIn 0.15s cubic-bezier(0.22, 1, 0.36, 1);
  overflow: hidden;
}
@keyframes sheetIn {
  from { opacity: 0; transform: translateY(18px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.sheet-handle { width: 34px; height: 4px; border-radius: 99px; background: var(--line-strong); margin: 0 auto 2px; flex-shrink: 0; }
.sheet-hd { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sheet-hd h3 { margin: 0; font: 600 14.5px 'Inter', sans-serif; }
.sheet-tabs { display: flex; gap: 4px; padding: 3px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); }
.sheet-tab {
  flex: 1; height: 28px; border-radius: 7px; border: 0; background: transparent;
  color: var(--text-2); font: 550 12px 'Inter', sans-serif; cursor: pointer;
}
.sheet-tab.active { background: var(--sec-pill-bg); color: var(--text); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12); }
.sheet-body { overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }

.tool-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.tool-btn {
  padding: 11px 12px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--text); font: 550 12.5px 'Inter', sans-serif;
  display: flex; align-items: center; gap: 8px; cursor: pointer; text-align: left;
}
.tool-btn:hover { background: var(--surface-2); border-color: var(--line-strong); }
.tool-btn.active { background: var(--accent-pill-bg); color: var(--accent-pill-fg); border-color: transparent; }

/* Subtle Floating Toast */
.toast {
  position: absolute; top: 60px; left: 50%; transform: translateX(-50%);
  z-index: 40; padding: 7px 13px; border-radius: 99px;
  background: var(--accent-pill-bg); color: var(--accent-pill-fg);
  font: 600 11.5px 'Inter', sans-serif; white-space: nowrap;
  box-shadow: var(--pill-shadow);
  opacity: 0; pointer-events: none; transition: opacity 0.14s ease;
}
.toast.show { opacity: 1; }
.toast.warn { background: var(--warn-bg); color: var(--warn-fg); border: 1px solid var(--neg-tone); }
