/* hallmark v2.0.0 | theme: oled-terminal (custom) | scope: app | floor: clean */
/* critique: pure OLED black chrome with single blue accent, tabular figures, zero glow slop, fluid 2-snap sheets */

:root {
  /* Neutral OLED Graphite Ramp */
  --bg-oled: #000000;
  --bg-surface-1: #0D0E12;
  --bg-surface-2: #141720;
  --bg-surface-3: #1C202B;
  --bg-elevated: #202432;
  --bg-glass: rgba(16, 18, 24, 0.82);
  --bg-scrim: rgba(0, 0, 0, 0.68);

  /* Hairline Borders */
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --border-accent: rgba(41, 98, 255, 0.55);

  /* Text Roles (3 strict roles) */
  --text-primary: #F0F3FA;
  --text-secondary: #9CA3B5;
  --text-muted: #666E80;
  --text-inverse: #0B0D12;

  /* Single Accent + Semantic Market Tones */
  --accent: #2962FF;
  --accent-hover: #3B73FF;
  --accent-soft: rgba(41, 98, 255, 0.16);
  --bull: #089981;
  --bull-soft: rgba(8, 153, 129, 0.16);
  --bear: #F23645;
  --bear-soft: rgba(242, 54, 69, 0.16);
  --warn: #F59E0B;
  --warn-soft: rgba(245, 158, 11, 0.16);

  /* Spacing Scale (4px grid) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;

  /* Nested Radii */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-pill: 999px;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  /* Motion Curves (Apple + Animate UI tokens) */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-press: cubic-bezier(0.2, 0, 0, 1);
  --dur-fast: 140ms;
  --dur-sheet: 280ms;

  /* Layout Heights */
  --topbar-h: 52px;
  --bottomnav-h: 58px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

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

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow-x: clip;
  background-color: var(--bg-oled);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

input, textarea, select, pre, code, .selectable {
  user-select: text;
  font-family: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.hidden {
  display: none !important;
}

/* App Shell */
#app-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100dvh;
  background: var(--bg-oled);
  padding-top: var(--safe-top);
  position: relative;
}

/* Announcement Banner */
#global-announcement {
  background: var(--bg-surface-2);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 8px 16px;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* Top Bar (Responsive clamp + locked flex-shrink: 0) */
#top-bar {
  height: var(--topbar-h);
  min-height: var(--topbar-h);
  padding: 0 clamp(8px, 2.5vw, 16px);
  background: var(--bg-oled);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  position: relative;
  z-index: 30;
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  min-width: 0;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: clamp(14px, 3.6vw, 16px);
  letter-spacing: -0.01em;
  color: var(--text-primary);
  white-space: nowrap;
}

.brand-mark img {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  flex-shrink: 0;
}

/* Buttons & Controls */
.btn, .icon-btn, .chip-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-2);
  color: var(--text-primary);
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), transform 100ms var(--ease-press), opacity var(--dur-fast);
}

.btn {
  min-height: 36px;
  padding: 0 12px;
}

.btn-sm {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: var(--r-sm);
}

.icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-primary);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-bull {
  background: var(--bull);
  border-color: var(--bull);
  color: var(--text-primary);
}

.btn-bear {
  background: var(--bear);
  border-color: var(--bear);
  color: var(--text-primary);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-surface-2);
  color: var(--text-primary);
}

.btn:active, .icon-btn:active, .chip-btn:active {
  transform: scale(0.97);
}

.chip-btn {
  min-height: 30px;
  padding: 0 10px;
  border-radius: var(--r-pill);
  font-size: 12px;
  color: var(--text-secondary);
}

.chip-btn.active {
  background: var(--text-primary);
  color: var(--text-inverse);
  border-color: var(--text-primary);
}

.chip-btn.sentinel-on {
  background: var(--bull-soft);
  border-color: var(--bull);
  color: var(--bull);
}

.svg-icon {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 1.65;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.svg-icon-sm {
  width: 15px;
  height: 15px;
}

/* Main Content Views */
#main-views {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

.view-pane {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: none;
  background: var(--bg-oled);
  padding-bottom: 24px;
}

.view-pane.active {
  display: block;
}

#view-chart.active {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 0;
}

#view-ai.active {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 0;
}

/* ============================================================================
   VIEW 1: WATCHLIST (OLED, Grouped, Pip Superscript, Tick Flash)
   ============================================================================ */
.watchlist-toolbar {
  padding: 12px 16px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-input-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  padding: 0 12px;
  height: 38px;
}

.search-input-wrap input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
}

.wl-group {
  margin-top: 8px;
}

.wl-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.wl-row {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 0.9fr) minmax(0, 0.85fr);
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out);
}

.wl-row:hover {
  background: var(--bg-surface-1);
}

.wl-row:active {
  background: var(--bg-surface-2);
}

.wl-sym-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.wl-sym-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wl-price-col {
  text-align: right;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.pip-sup {
  font-size: 0.72em;
  vertical-align: super;
  opacity: 0.82;
  margin-left: 1px;
}

.wl-chg-col {
  text-align: right;
}

.chg-pill {
  display: inline-block;
  min-width: 66px;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.chg-up {
  background: var(--bull-soft);
  color: var(--bull);
}

.chg-down {
  background: var(--bear-soft);
  color: var(--bear);
}

.tick-flash-up {
  animation: flashUp 420ms var(--ease-out);
}

.tick-flash-down {
  animation: flashDown 420ms var(--ease-out);
}

@keyframes flashUp {
  0% { background-color: rgba(8, 153, 129, 0.24); }
  100% { background-color: transparent; }
}

@keyframes flashDown {
  0% { background-color: rgba(242, 54, 69, 0.24); }
  100% { background-color: transparent; }
}

/* ============================================================================
   SYMBOL OVERVIEW SCREEN (Sticky Header + Mini Area Chart + 3 Technical Gauges)
   ============================================================================ */
#symbol-overview-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--bg-oled);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  visibility: hidden;
  pointer-events: none;
  transition: transform var(--dur-sheet) var(--ease-out), opacity var(--dur-sheet) var(--ease-out);
}

#symbol-overview-overlay.open {
  transform: translateX(0);
  visibility: visible;
  pointer-events: auto;
}

.overview-sticky-bar {
  height: 52px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-glass);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.overview-sticky-mini {
  opacity: 0;
  transform: translateY(4px);
  transition: opacity var(--dur-fast), transform var(--dur-fast);
  text-align: center;
}

.overview-sticky-mini.visible {
  opacity: 1;
  transform: translateY(0);
}

.overview-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.overview-hero-price {
  font-size: clamp(28px, 7vw, 38px);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.mini-chart-box {
  position: relative;
  height: 170px;
  margin: 14px 0;
  background: var(--bg-surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.mini-chart-expand {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 4;
}

.sub-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border-subtle);
  margin: 12px 0 16px;
  overflow-x: auto;
}

.sub-tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.sub-tab-btn.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent);
}

.gauges-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0 16px;
}

@media (max-width: 520px) {
  .gauges-grid {
    grid-template-columns: 1fr;
  }
}

.gauge-card {
  background: var(--bg-surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  padding: 14px 12px;
  text-align: center;
}

.gauge-title {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.gauge-verdict {
  font-size: 15px;
  font-weight: 600;
  margin-top: 2px;
}

.gauge-counts {
  display: flex;
  justify-content: center;
  gap: 12px;
  font-size: 11px;
  margin-top: 8px;
  color: var(--text-secondary);
}

/* ============================================================================
   VIEW 2: FULL CHART ENGINE (OLED + Canvas Overlay + Favorites Pill + Replay)
   ============================================================================ */
.chart-header-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--bg-oled);
  border-bottom: 1px solid var(--border-subtle);
  gap: 6px;
  flex-shrink: 0;
}

.chart-ohlc-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-secondary);
  overflow-x: auto;
  white-space: nowrap;
  min-width: 0;
}

.chart-stage-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
  background: var(--bg-oled);
  overflow: hidden;
}

#chart-container {
  position: absolute;
  inset: 0;
}

#drawing-canvas {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
}

#drawing-canvas.drawing-active {
  pointer-events: auto;
  cursor: crosshair;
}

/* Active Indicators Legend (Collapsible, Eye Lazy-Compute Toggle) */
.ind-legend-stack {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 12;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: min(300px, 72vw);
  pointer-events: none;
}

.ind-pill {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(13, 14, 18, 0.78);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-sm);
  padding: 3px 8px;
  font-size: 11px;
  color: var(--text-primary);
}

.ind-pill.is-hidden {
  opacity: 0.48;
}

.ind-pill button {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 2px;
  display: inline-flex;
}

.ind-pill button:hover {
  color: var(--text-primary);
}

/* Candle Countdown Badge */
.countdown-badge {
  position: absolute;
  right: 8px;
  top: 8px;
  z-index: 12;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-sm);
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  pointer-events: none;
}

/* Floating Draggable Favorites Pill (:: handle) */
#fav-draw-pill {
  position: absolute;
  left: 12px;
  bottom: 54px;
  z-index: 18;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  background: var(--bg-glass);
  backdrop-filter: blur(18px);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-pill);
  touch-action: none;
}

.drag-grip {
  width: 22px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: grab;
}

.fav-tool-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.fav-tool-btn.active {
  background: var(--accent);
  color: var(--text-primary);
}

/* Replay & Paper Trading Dock */
#replay-dock {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-surface-1);
  border-top: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

#replay-dock.open {
  display: flex;
}

#paper-dock {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-surface-1);
  border-top: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

#paper-dock.open {
  display: flex;
}

/* Chart Bottom Action Bar (Symbol Wheel, TF Wheel, Draw, Indicators, More) */
.chart-bottom-bar {
  height: 46px;
  padding: 0 8px;
  background: var(--bg-oled);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-shrink: 0;
}

.wheel-trigger {
  height: 34px;
  padding: 0 10px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  flex-shrink: 0;
}

/* ============================================================================
   3D WHEEL PICKER OVERLAY (Center Floating + Scale Magnification + Haptics)
   ============================================================================ */
#wheel-picker-overlay {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 180ms var(--ease-out);
}

#wheel-picker-overlay.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.wheel-box {
  width: min(260px, 78vw);
  height: 230px;
  background: var(--bg-glass);
  backdrop-filter: blur(22px) saturate(160%);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.wheel-center-band {
  position: absolute;
  left: 10px;
  right: 10px;
  top: 50%;
  height: 44px;
  transform: translateY(-50%);
  border-radius: var(--r-md);
  background: rgba(41, 98, 255, 0.16);
  border: 1px solid rgba(41, 98, 255, 0.4);
  pointer-events: none;
}

.wheel-scroller {
  flex: 1;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  padding: 93px 0;
  scrollbar-width: none;
}

.wheel-scroller::-webkit-scrollbar {
  display: none;
}

.wheel-item {
  height: 44px;
  scroll-snap-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: transform 140ms var(--ease-out), color 140ms var(--ease-out), opacity 140ms var(--ease-out);
}

.wheel-item.selected {
  color: var(--text-primary);
  font-weight: 600;
  transform: scale(1.16);
}

/* ============================================================================
   2-SNAP BOTTOM SHEET (Apple Fluid Drag + Safe Reduced Motion)
   ============================================================================ */
#sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: var(--bg-scrim);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--dur-sheet) var(--ease-out);
}

#sheet-backdrop.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

#bottom-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 85;
  max-width: 720px;
  margin: 0 auto;
  height: 86dvh;
  background: var(--bg-surface-1);
  border-top: 1px solid var(--border-strong);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  visibility: hidden;
  pointer-events: none;
  transition: transform var(--dur-sheet) var(--ease-out), opacity var(--dur-sheet) var(--ease-out);
}

#bottom-sheet.open {
  visibility: visible;
  pointer-events: auto;
  transform: translateY(34dvh);
}

#bottom-sheet.open.snap-full {
  transform: translateY(0);
}

.sheet-handle-zone {
  padding: 10px 16px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: grab;
  touch-action: none;
}

.sheet-handle-bar {
  width: 38px;
  height: 4px;
  border-radius: var(--r-pill);
  background: var(--border-strong);
}

.sheet-header {
  padding: 6px 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}

.sheet-title {
  font-size: 15px;
  font-weight: 600;
}

.sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px calc(24px + var(--safe-bottom));
}

/* Drawings 3-Col Grid & Search Highlight */
.draw-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

@media (max-width: 360px) {
  .draw-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.draw-tile {
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
  cursor: pointer;
  text-align: center;
}

.draw-tile.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.draw-tile-label {
  font-size: 11px;
  color: var(--text-primary);
  line-height: 1.25;
}

.draw-star-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
}

.draw-star-btn.starred {
  color: var(--warn);
}

mark.hl {
  background: var(--accent-soft);
  color: var(--text-primary);
  border-radius: 3px;
  padding: 0 2px;
}

/* ============================================================================
   VIEW 3: QUANT AI COPILOT + SENTINEL + TRAINING PROFILES
   ============================================================================ */
.ai-header-bar {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.ai-controls-strip {
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface-1);
}

.ai-messages-list {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-msg {
  max-width: 92%;
  padding: 12px 14px;
  border-radius: var(--r-lg);
  font-size: 13.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.ai-msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: var(--text-primary);
}

.ai-msg.assistant {
  align-self: flex-start;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

.ai-composer {
  padding: 10px 12px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface-1);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-quick-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
}

.ai-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.ai-input-row textarea {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  max-height: 120px;
  resize: none;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  color: var(--text-primary);
  padding: 9px 12px;
  font-size: 14px;
  outline: none;
}

/* Voice Waveform indicator */
.voice-wave {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 16px;
}

.voice-wave span {
  width: 3px;
  height: 6px;
  border-radius: 2px;
  background: var(--bear);
  animation: vBar 600ms ease-in-out infinite alternate;
}

.voice-wave span:nth-child(2) { animation-delay: 150ms; }
.voice-wave span:nth-child(3) { animation-delay: 300ms; }

@keyframes vBar {
  from { height: 4px; }
  to { height: 15px; }
}

/* ============================================================================
   CARDS, FORMS, GRIDS, PLANS & ADMIN PANEL
   ============================================================================ */
.section-pad {
  padding: 16px;
  max-width: 1120px;
  margin: 0 auto;
}

.card {
  background: var(--bg-surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  padding: 16px;
  margin-bottom: 12px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

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

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 640px) {
  .grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 390px) {
  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
  min-width: 0;
}

.field label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.input, .select, .textarea {
  width: 100%;
  min-width: 0;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  color: var(--text-primary);
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
}

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
}

.textarea {
  min-height: 88px;
  resize: vertical;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.switch-row:last-child {
  border-bottom: none;
}

/* Dynamic Plan Card (supports Admin uploaded WebP / URL background + auto contrast) */
.plan-card {
  position: relative;
  border-radius: var(--r-lg);
  border: 1px solid var(--border-strong);
  overflow: hidden;
  padding: 18px;
  background: var(--bg-surface-2);
  background-size: cover;
  background-position: center;
}

.plan-card-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.42) 0%, rgba(0,0,0,0.82) 100%);
  pointer-events: none;
}

.plan-card-inner {
  position: relative;
  z-index: 2;
}

/* Fullscreen Modals (Auth, Reset Password, Admin Panel) */
.fullscreen-modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: var(--bg-oled);
  display: flex;
  flex-direction: column;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms var(--ease-out);
}

.fullscreen-modal.open {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

#reset-password-modal {
  z-index: 200;
}

.admin-tabs-bar {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-oled);
}

.admin-tab-pill {
  padding: 8px 14px;
  border-radius: var(--r-pill);
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
}

.admin-tab-pill.active {
  background: var(--text-primary);
  color: var(--text-inverse);
  border-color: var(--text-primary);
}

/* Bottom Navigation Bar (5 Tabs) */
#bottom-nav {
  height: calc(var(--bottomnav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--bg-oled);
  border-top: 1px solid var(--border-subtle);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  z-index: 40;
  flex-shrink: 0;
}

.nav-item {
  background: transparent;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 2px;
}

.nav-item.active {
  color: var(--text-primary);
}

/* Toast Notification */
#toast-stack {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bottomnav-h) + 16px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 250;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(360px, 92vw);
  pointer-events: none;
}

.toast-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  padding: 10px 14px;
  border-radius: var(--r-md);
  font-size: 13px;
  text-align: center;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out);
}

.toast-item.show {
  opacity: 1;
  transform: translateY(0);
}

/* Data Table */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.data-table th, .data-table td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
}

.data-table th {
  color: var(--text-secondary);
  font-weight: 500;
}

/* SAFE Reduced Motion: NEVER transform: none !important on sheets/overlays */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
  #bottom-sheet, #symbol-overview-overlay, #wheel-picker-overlay, .fullscreen-modal {
    transition: opacity 140ms ease !important;
  }
}
