/* GammaWork — design tokens
   v0.8 IM-workbench skin. Light palette only; dark/terminal themes removed.
   Token names match the dark-era schema (--bg-0..4, --fg-0..3, --line-1..3,
   --accent, --pos/neg) so existing component CSS picks up the new look
   without per-file rewrites. New prototype-specific tokens are added below.
*/

:root {
  /* === Prototype palette (primary set) === */
  --primary: #2563EB;
  --primary-mid: #3B82F6;
  --primary-soft: #EFF6FF;
  --bg-page: #EEF2F7;
  --bg-panel: #FFFFFF;
  --bg-subtle: #F4F7FB;
  --border-soft: #F1F5F9;
  --border: #E2E8F0;
  --border-strong: #CBD5E1;
  --text-strong: #1E3A5F;
  --text-body: #334155;
  --text-muted: #64748B;
  --text-faint: #94A3B8;

  /* Layout dimensions */
  --sidebar-w: 72px;
  --list-w: 300px;
  --maintop-h: 52px;
  --shadow-card: 0 1px 2px rgba(37, 99, 235, 0.06), 0 8px 24px rgba(15, 23, 42, 0.06);
  --shadow-soft: 0 2px 6px rgba(15, 23, 42, 0.05);

  /* === Legacy alias layer — maps old token names to the new light palette.
     Every component in app.css / shell.css uses these. */
  --bg-0: var(--bg-page);
  --bg-1: var(--bg-panel);
  --bg-2: var(--bg-subtle);
  --bg-3: var(--primary-soft);
  --bg-4: #DBEAFE;

  --line-1: var(--border);
  --line-2: var(--border-strong);
  --line-3: #94A3B8;

  --fg-0: var(--text-strong);
  --fg-1: var(--text-body);
  --fg-2: var(--text-muted);
  --fg-3: var(--text-faint);

  /* Accent is now the prototype blue (was amber). */
  --accent: var(--primary);
  --accent-fg: #FFFFFF;
  --accent-soft: var(--primary-soft);

  /* === Financial semantic (A-share convention: red = up, green = down) === */
  --pos: #EF4444;
  --pos-bg: #FEE2E2;
  --neg: #16A34A;
  --neg-bg: #DCFCE7;
  --error: #EF4444;
  --error-bg: #FEE2E2;
  --success: #16A34A;
  --success-bg: #DCFCE7;
  --warn: #F59E0B;
  --info: #0EA5E9;

  /* === Type === */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", "Roboto Mono", ui-monospace, Menlo, monospace;
  --font-serif: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --font-display: var(--font-sans);
  --font-body: var(--font-sans);
  --font-data: var(--font-mono);

  /* === Density === */
  --row-h: 32px;
  --row-h-sm: 26px;
  --pad-1: 4px;
  --pad-2: 8px;
  --pad-3: 12px;
  --pad-4: 16px;
  --pad-5: 24px;

  /* Type scale — flat px to match the prototype's tight 13px base.
     --font-scale is preserved for the Settings UI font-size control;
     default is 1.0 (was 1.5 in the dark-era v0.7 readability bump). */
  --font-scale: 1.0;
  --t-xs:  calc(11px * var(--font-scale));
  --t-sm:  calc(12px * var(--font-scale));
  --t-md:  calc(13px * var(--font-scale));
  --t-lg:  calc(14px * var(--font-scale));
  --t-xl:  calc(15px * var(--font-scale));
  --t-2xl: calc(18px * var(--font-scale));
  --t-3xl: calc(22px * var(--font-scale));
  --t-4xl: calc(28px * var(--font-scale));
  --t-5xl: calc(40px * var(--font-scale));

  --ctl-h:    calc(32px * var(--font-scale));
  --ctl-h-sm: calc(26px * var(--font-scale));

  /* === Radii (softer, matching the prototype's rounded chips/cards) === */
  --r-1: 4px;
  --r-2: 6px;
  --r-3: 8px;
  --r-card: 10px;
}

/* Density variants — kept for the Settings UI. */
[data-density="comfortable"] {
  --row-h: 36px;
  --row-h-sm: 30px;
  --pad-2: 12px;
  --pad-3: 16px;
  --pad-4: 20px;
  --pad-5: 32px;
}

[data-density="spacious"] {
  --row-h: 44px;
  --row-h-sm: 36px;
  --pad-2: 16px;
  --pad-3: 20px;
  --pad-4: 28px;
  --pad-5: 40px;
}

/* Base reset */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg-page);
  color: var(--text-body);
  font-family: var(--font-body);
  font-size: var(--t-md);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
button { font-family: inherit; color: inherit; background: none; border: none; cursor: pointer; padding: 0; }
input, textarea, select { font-family: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

.mono { font-family: var(--font-data); font-feature-settings: "tnum"; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.fg-1 { color: var(--fg-1); }
.fg-2 { color: var(--fg-2); }
.fg-3 { color: var(--fg-3); }
.tabular { font-variant-numeric: tabular-nums; }
.uppercase { text-transform: uppercase; letter-spacing: 0.05em; }

/* Scrollbar — light variant */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border: 2px solid transparent; background-clip: padding-box; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #94A3B8; background-clip: padding-box; border: 2px solid transparent; }

::selection { background: var(--primary-soft); color: var(--text-strong); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

/* === Common building blocks === */

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--pad-3) var(--pad-4);
  border-bottom: 1px solid var(--border);
  font-size: var(--t-md);
  font-weight: 600;
  color: var(--text-strong);
}
.panel-header strong { color: var(--text-strong); font-weight: 700; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  font-size: var(--t-xs);
  font-weight: 600;
  border-radius: var(--r-1);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-body);
}
.chip-pos { background: var(--pos-bg); color: var(--pos); border-color: transparent; }
.chip-neg { background: var(--neg-bg); color: var(--neg); border-color: transparent; }
.chip-accent { background: var(--primary-soft); color: var(--primary); border-color: #BFDBFE; }
.chip-warn { background: #FEF3C7; color: var(--warn); border-color: transparent; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--ctl-h);
  padding: 0 14px;
  font-size: var(--t-md);
  font-weight: 500;
  border: 1px solid var(--border-strong);
  background: var(--bg-panel);
  color: var(--text-body);
  border-radius: var(--r-2);
  transition: background 120ms, border-color 120ms, box-shadow 120ms;
}
.btn:hover { background: var(--bg-subtle); border-color: #94A3B8; }
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #FFFFFF;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.16);
}
.btn-primary:hover { background: #1D4ED8; border-color: #1D4ED8; }
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover { background: var(--primary-soft); color: var(--primary); }
.btn-sm { height: var(--ctl-h-sm); padding: 0 10px; font-size: var(--t-sm); }

.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 18px;
  min-width: 18px;
  padding: 0 5px;
  font-family: var(--font-data);
  font-size: 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: var(--r-1);
  color: var(--text-muted);
}

.tag {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  font-size: 10px;
  font-weight: 600;
  background: var(--bg-subtle);
  color: var(--text-muted);
  border-radius: var(--r-1);
  border: 1px solid var(--border);
}

.divider { height: 1px; background: var(--border); }
.vdivider { width: 1px; background: var(--border); align-self: stretch; }

.sparkline {
  display: inline-block;
  width: 60px;
  height: 16px;
  vertical-align: middle;
}
