/* Design tokens — v1.16. iPhone-like: neutral grays, one accent, semantic colours only for state.
   Loaded AFTER style.css: the legacy names (--page, --text-*, --accent, …) are redefined here
   with the same selectors, so old pages adopt the system without edits.

   Data-viz series = the dataviz skill's validated reference palette, re-validated on these
   surfaces (2026-11-06): light on #ffffff passes all hard gates, slots 3/4/5 < 3:1 contrast
   → charts using them need visible labels or a table view; dark on #1c1c1e passes everything. */

:root {
  color-scheme: light;

  /* ---- surfaces ---- */
  --bg: #f2f2f7;                       /* grouped page background */
  --surface-1: #ffffff;                /* cards, list rows */
  --surface-2: #f7f7fa;                /* nested blocks */
  --fill: rgba(118, 118, 128, 0.12);   /* inputs, segmented track, chips */
  --fill-strong: rgba(120, 120, 128, 0.20);
  --separator: rgba(60, 60, 67, 0.18);
  --overlay: rgba(0, 0, 0, 0.32);
  --material: rgba(249, 249, 251, 0.78);    /* translucent bars (with blur) */

  /* ---- ink ---- */
  --label: #0b0b0c;
  --label-2: #6b6b70;                  /* secondary text, 5.3:1 on white */
  --label-3: #8a8a8e;                  /* muted/meta, large or non-essential only */
  --label-4: #c4c4c8;                  /* placeholders, disabled */

  /* ---- one accent ---- */
  --accent: #0071e3;
  --accent-soft: rgba(0, 113, 227, 0.12);
  --on-accent: #ffffff;

  /* ---- status (fixed; always with an icon or label, never colour alone) ---- */
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --good-text: #006300;
  --critical-text: #c02a2a;

  /* ---- price moves: A-share convention, rise red / fall green (not good/bad) ---- */
  --rise: #d03b3b;
  --fall: #006300;

  /* ---- data-viz: categorical in fixed order, never cycled ---- */
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #6250d6; --series-8: #e34948;
  --seq-100: #cde2fb; --seq-250: #86b6ef; --seq-450: #2a78d6; --seq-600: #184f95;
  --viz-grid: #e5e5ea;
  --viz-axis: #c7c7cc;

  /* ---- type (system SF / PingFang) ---- */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue",
          "Microsoft YaHei", system-ui, sans-serif;
  --fs-largetitle: 34px; --lh-largetitle: 41px;
  --fs-title: 22px;      --lh-title: 28px;
  --fs-headline: 17px;   --lh-headline: 22px;   /* semibold body */
  --fs-body: 17px;       --lh-body: 22px;
  --fs-subhead: 15px;    --lh-subhead: 20px;
  --fs-footnote: 13px;   --lh-footnote: 18px;
  --fs-caption: 11px;    --lh-caption: 13px;

  /* ---- space (4-pt grid), shape, depth, motion ---- */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px; --sp-8: 32px;
  --margin: 16px;                      /* page side margin */
  --r-xs: 6px; --r-sm: 10px; --r-md: 14px; --r-lg: 20px; --r-pill: 999px;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 14px rgba(0, 0, 0, 0.05);
  --shadow-2: 0 10px 40px rgba(0, 0, 0, 0.16);
  --dur-1: 150ms; --dur-2: 260ms; --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --tabbar-h: 50px;

  /* ---- legacy names (pre-v1.16 pages) ---- */
  --page: var(--bg);
  --text-primary: var(--label);
  --text-secondary: var(--label-2);
  --text-muted: var(--label-3);
  --border: var(--separator);
  --accent-2: var(--series-2);
  --accent-3: var(--good);
  --accent-4: var(--series-7);
  --accent-5: var(--critical);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #000000;
    --surface-1: #1c1c1e;
    --surface-2: #2c2c2e;
    --fill: rgba(118, 118, 128, 0.24);
    --fill-strong: rgba(120, 120, 128, 0.36);
    --separator: rgba(84, 84, 88, 0.6);
    --overlay: rgba(0, 0, 0, 0.5);
    --material: rgba(28, 28, 30, 0.72);
    --label: #f2f2f7;
    --label-2: #aeaeb2;
    --label-3: #8e8e93;
    --label-4: #48484a;
    --accent: #0a84ff;
    --accent-soft: rgba(10, 132, 255, 0.18);
    --good-text: #30c04a;
    --critical-text: #ff6961;
    --rise: #ff6961;
    --fall: #30c04a;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
    --seq-100: #104281; --seq-250: #1c5cab; --seq-450: #3987e5; --seq-600: #86b6ef;
    --viz-grid: #2c2c2e;
    --viz-axis: #48484a;
    --shadow-1: none;
    --shadow-2: 0 10px 40px rgba(0, 0, 0, 0.6);
    --page: var(--bg);
    --text-primary: var(--label);
    --text-secondary: var(--label-2);
    --text-muted: var(--label-3);
    --border: var(--separator);
    --accent-2: var(--series-2);
    --accent-4: var(--series-7);
  }
}

@media (prefers-reduced-motion: reduce) {
  :root { --dur-1: 0ms; --dur-2: 0ms; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important;
                           transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

*, *::before, *::after { box-sizing: border-box; }
html, body { font-family: var(--font); background: var(--bg); color: var(--label); }
