/* ==========================================================================
   Titan Mobile v2 — design tokens
   Source of truth for colour, type, space, radius, motion and density.
   Colours follow the live webapp (testnet.titanx.cc, read 2026-11-28):
   neutral graphite surfaces, silver/graphite "chrome" CTAs, green #36b85a /
   red #ee4a5c in dark. Dark is the primary theme; light is a full peer.
   Frames pick a theme with ?theme=light|dark (kit.js sets data-theme).
   ========================================================================== */

:root {
  /* type */
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", Inter, system-ui, sans-serif;
  --font-num: ui-monospace, "SF Mono", SFMono-Regular, "JetBrains Mono", Menlo, monospace;

  --fs-11: 11px;  /* caption, table head, badges */
  --fs-12: 12px;  /* secondary meta */
  --fs-13: 13px;  /* dense body, list sub-lines */
  --fs-14: 14px;  /* body, controls */
  --fs-15: 15px;  /* list titles */
  --fs-17: 17px;  /* screen titles (inline), sheet titles */
  --fs-20: 20px;  /* section hero numbers */
  --fs-24: 24px;  /* trade price */
  --fs-28: 28px;  /* large screen title */
  --fs-34: 34px;  /* balance hero */
  --fs-44: 44px;  /* amount entry */

  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;

  --tracking-tight: -0.02em;
  --tracking-num: -0.01em;
  --tracking-caps: 0.06em;

  /* space (4pt grid) */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px;
  --gutter: 16px;

  /* radius */
  --r-xs: 6px;  --r-sm: 8px;  --r-md: 12px; --r-lg: 16px;
  --r-xl: 22px; --r-sheet: 28px; --r-pill: 999px;

  /* control heights — exchange-grade (Binance/Bybit/OKX/Hyperliquid/Lighter);
     hit areas stay ≥44pt through .hit padding, never by inflating the drawn control */
  --h-chip: 28px;   /* timeframe row, filter chips */
  --h-tab: 32px;    /* tabs, segmented controls */
  --h-btn-sm: 32px;
  --h-btn: 40px;    /* Long / Short, standard buttons */
  --h-input: 40px;
  --h-btn-lg: 48px; /* single primary CTA at the foot of a flow */
  --h-row: 52px;    /* list row */
  --h-row-dense: 40px;
  --h-tabbar: 56px;

  /* motion */
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --ease-spring: cubic-bezier(.3, 1.35, .5, 1);
  --dur-1: 120ms; --dur-2: 220ms; --dur-3: 380ms;

  /* device */
  --device-w: 390px;
  --device-h: 844px;
  --safe-top: 54px;
  --safe-bottom: 34px;

  /* brand constants (not theme-dependent) */
  --coin-btc: #f7931a;
  --coin-eth: #627eea;
  --coin-sol: linear-gradient(135deg, #9945ff 0%, #14f195 100%);
  --coin-cc: #f3ff6b;
  --coin-usdc: #2775ca;
}

/* --- dark (primary) ----------------------------------------------------- */
:root,
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0a0b;
  --bg-raised: #0f0f11;
  --surface: #131316;
  --surface-2: #1a1a1d;
  --surface-3: #222226;
  --surface-4: #2b2b30;
  --overlay: rgba(0, 0, 0, 0.62);
  --line: rgba(255, 255, 255, 0.08);
  --line-soft: rgba(255, 255, 255, 0.05);
  --line-strong: rgba(255, 255, 255, 0.16);

  --t1: rgba(255, 255, 255, 0.95);
  --t2: rgba(255, 255, 255, 0.66);
  --t3: rgba(255, 255, 255, 0.55); /* ≥4.5:1 on --bg and --surface */
  --t4: rgba(255, 255, 255, 0.22); /* decorative only */

  --up: #36b85a;
  --down: #ee4a5c;
  --up-soft: rgba(54, 184, 90, 0.15);
  --down-soft: rgba(238, 74, 92, 0.15);
  --up-ink: #04150a;   /* text on solid --up (7.3:1) */
  --down-ink: #1a0407; /* text on solid --down; white is only 3.6:1 on #ee4a5c */
  --warn: #f4a130;
  --warn-soft: rgba(244, 161, 48, 0.15);
  --info: #0a84ff;
  --info-soft: rgba(10, 132, 255, 0.16);
  --focus: #0a84ff;

  /* chrome = Titan's metallic CTA. Silver in dark, graphite in light. */
  --chrome: linear-gradient(135deg, rgba(255,255,255,.8) 0%, transparent 25%, rgba(255,255,255,.3) 50%, transparent 75%, rgba(255,255,255,.6) 100%),
            linear-gradient(45deg, #e8f0f8 0%, #b8cce4 25%, #f0f8ff 50%, #a8c0dc 75%, #d8e4f0 100%);
  --chrome-ink: #141418;
  --chrome-edge: inset 0 1px 0 rgba(255,255,255,.7), inset 0 -1px 0 rgba(0,0,0,.18), 0 6px 18px rgba(170, 196, 228, 0.16);

  --glass: rgba(22, 22, 25, 0.78);
  --glass-line: rgba(255, 255, 255, 0.12);
  --glass-shadow: 0 0 0 .5px rgba(0,0,0,.6), 0 18px 40px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.12);

  --shadow-1: 0 1px 2px rgba(0,0,0,.4);
  --shadow-2: 0 8px 24px rgba(0,0,0,.45);
  --shadow-sheet: 0 -12px 40px rgba(0,0,0,.6);

  --grid-line: rgba(255, 255, 255, 0.05);
  --chart-line: #e8ecf2;
}

/* --- light ---------------------------------------------------------------- */
[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f5f7;
  --bg-raised: #fafafc;
  --surface: #ffffff;
  --surface-2: #fafafc;
  --surface-3: #f0f0f2;
  --surface-4: #e6e6ea;
  --overlay: rgba(10, 10, 12, 0.36);
  --line: #e5e5ea;
  --line-soft: #f0f0f2;
  --line-strong: rgba(0, 0, 0, 0.14);

  --t1: #1d1d1f;
  --t2: rgba(29, 29, 31, 0.70);
  --t3: rgba(29, 29, 31, 0.62);
  --t4: rgba(29, 29, 31, 0.20);

  --up: #15803d;      /* darker than webapp #2ba84a so text passes 4.5:1 on white (5.0:1) */
  --down: #d92f40;
  --up-soft: rgba(43, 168, 74, 0.12);
  --down-soft: rgba(229, 57, 74, 0.11);
  --up-ink: #ffffff;
  --down-ink: #ffffff;
  --warn: #a35500;
  --warn-soft: rgba(240, 142, 26, 0.14);
  --info: #0064d1;
  --info-soft: rgba(0, 113, 227, 0.10);
  --focus: #0071e3;

  --chrome: linear-gradient(135deg, rgba(255,255,255,.1) 0%, transparent 25%, rgba(180,200,255,.06) 50%, transparent 75%, rgba(255,255,255,.08) 100%),
            linear-gradient(45deg, #1a1a1f 0%, #2a2a30 25%, #0e0e12 50%, #1f1f25 75%, #0a0a0c 100%);
  --chrome-ink: #ffffff;
  --chrome-edge: inset 0 1px 0 rgba(255,255,255,.22), 0 6px 16px rgba(0,0,0,.18);

  --glass: rgba(255, 255, 255, 0.82);
  --glass-line: rgba(0, 0, 0, 0.08);
  --glass-shadow: 0 0 0 .5px rgba(0,0,0,.06), 0 14px 34px rgba(0,0,0,.14), inset 0 1px 0 rgba(255,255,255,.9);

  --shadow-1: 0 1px 2px rgba(0,0,0,.06);
  --shadow-2: 0 8px 24px rgba(0,0,0,.08);
  --shadow-sheet: 0 -10px 36px rgba(0,0,0,.12);

  --grid-line: rgba(0, 0, 0, 0.05);
  --chart-line: #1d1d1f;
}

/* --- density (mirrors the webapp's Settings → Density) -------------------
   compact is the default for trading screens. Set data-density on .device. */
[data-density="comfortable"] {
  --h-chip: 32px; --h-tab: 36px; --h-btn: 44px; --h-input: 44px;
  --h-btn-lg: 52px; --h-row: 60px; --h-row-dense: 46px; --gutter: 18px;
}
[data-density="spacious"] {
  --h-chip: 36px; --h-tab: 42px; --h-btn: 48px; --h-input: 48px;
  --h-btn-lg: 56px; --h-row: 68px; --h-row-dense: 52px; --gutter: 20px;
}
[data-density="compact"] { /* defaults above */ }
