/**
 * AI Harness · shared light/dark theme tokens
 * Used by web-portal and web-manager (keep copies in sync).
 */
:root,
[data-theme="dark"] {
  color-scheme: dark;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "Cascadia Code", "SF Mono", Consolas, monospace;

  --bg-deep: #060d18;
  --bg-card: #0c1628;
  --bg-base: #0a1220;
  --bg-surface: #0f1a2e;
  --bg-elevated: #111f35;
  --bg-panel: #0c1628;
  --bg-hover: rgba(255, 200, 87, 0.06);

  --text: #e8edf5;
  --text-secondary: #b8c5d9;
  --text-muted: #8b9cb8;

  --gold: #f5a623;
  --gold-light: #ffc857;
  --gold-dim: rgba(245, 166, 35, 0.12);
  --gold-glow: rgba(245, 166, 35, 0.35);
  --gold-dark: #e8890b;
  --btn-primary-text: #1a1200;

  --border: rgba(255, 200, 87, 0.15);
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-accent: rgba(245, 166, 35, 0.28);

  --accent: #c9a227;
  --accent-blue: #3d8bfd;
  --blue: #5b9cf5;
  --blue-dim: rgba(91, 156, 245, 0.12);
  --success: #34d399;
  --ok: #34d399;
  --danger: #f87171;
  --warning: #fbbf24;
  --ok-bg: rgba(52, 211, 153, 0.12);
  --danger-bg: rgba(248, 113, 113, 0.12);
  --alert-ok-text: #a7f3d0;
  --alert-error-text: #fecaca;

  --overlay-backdrop: rgba(0, 0, 0, 0.6);
  --overlay-modal: rgba(5, 10, 18, 0.72);
  --overlay-surface: rgba(255, 255, 255, 0.03);
  --overlay-surface-hover: rgba(255, 255, 255, 0.045);
  --overlay-glass: rgba(8, 14, 26, 0.88);
  --overlay-header: rgba(12, 22, 40, 0.8);
  --overlay-footer: rgba(0, 0, 0, 0.12);

  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.35), 0 0 0 1px var(--border);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.5);

  --code-bg: #0a1220;
  --code-inline-bg: rgba(0, 0, 0, 0.35);

  --msg-user-bg: linear-gradient(135deg, rgba(37, 99, 235, 0.28), rgba(37, 99, 235, 0.12));
  --msg-user-border: rgba(59, 130, 246, 0.45);
  --msg-user-author: #93c5fd;
  --msg-assistant-bg: rgba(15, 23, 42, 0.92);
  --msg-assistant-border: rgba(52, 211, 153, 0.35);
  --msg-assistant-author: #6ee7b7;
  --msg-system-bg: #0a1220;
  --msg-system-border: rgba(61, 139, 253, 0.25);
  --msg-system-text: #94a3b8;
  --msg-repl-muted: #64748b;
  --msg-tool-start: #fbbf24;
  --msg-tool-end: #6ee7b7;
  --msg-progress: #7dd3fc;
  --stream-live-bg: rgba(61, 139, 253, 0.12);
  --stream-live-border: rgba(61, 139, 253, 0.35);
  --stream-live-text: #93c5fd;

  --tool-muted: #94a3b8;
  --tool-text: #cbd5e1;
  --tool-input: #e2e8f0;
  --tool-running: #fbbf24;
  --tool-worker: #7dd3fc;
  --tool-done: #6ee7b7;
  --tool-error: #f87171;
  --tool-progress: #7dd3fc;
  --tool-output: #94a3b8;

  --ambient-1: rgba(245, 166, 35, 0.07);
  --ambient-2: rgba(61, 139, 253, 0.04);
  --body-ambient-blue: rgba(91, 156, 245, 0.08);
  --body-ambient-gold: rgba(240, 160, 32, 0.06);

  --link-hover: #ffe08a;
  --progress-track: rgba(148, 163, 184, 0.15);
  --summary-bg: linear-gradient(180deg, rgba(14, 24, 42, 0.98) 0%, rgba(8, 14, 26, 0.99) 100%);
  --sidebar-shadow: 4px 0 32px rgba(0, 0, 0, 0.2);
  --hero-title-gradient: linear-gradient(135deg, #fff 0%, var(--gold-light) 100%);
  --story-pain: #fca5a5;
  --story-outcome: #6ee7b7;

  --landing-nav-bg: rgba(6, 13, 24, 0.75);
  --landing-nav-shadow: none;
  --landing-section-alt: rgba(12, 22, 40, 0.45);
  --landing-section-panel: rgba(12, 22, 40, 0.65);
  --landing-section-band: rgba(12, 22, 40, 0.6);
  --landing-section-deep: rgba(6, 13, 24, 0.5);
  --landing-section-muted: rgba(12, 22, 40, 0.5);
  --landing-section-gallery: rgba(12, 22, 40, 0.55);
  --landing-hero-bg:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(245, 166, 35, 0.18), transparent),
    radial-gradient(ellipse 60% 40% at 80% 60%, rgba(61, 139, 253, 0.08), transparent),
    var(--bg-deep);
  --landing-login-bg:
    radial-gradient(ellipse 60% 50% at 50% 0%, rgba(245, 166, 35, 0.12), transparent),
    var(--bg-deep);
  --landing-unify-bg: radial-gradient(ellipse 70% 50% at 50% 50%, rgba(245, 166, 35, 0.08), transparent);
  --landing-cta-bg: linear-gradient(145deg, var(--bg-card) 0%, rgba(245, 166, 35, 0.08) 100%);
  --landing-audience-alt-bg: linear-gradient(145deg, var(--bg-card) 0%, rgba(61, 139, 253, 0.06) 100%);
  --landing-audience-alt-border: rgba(61, 139, 253, 0.25);
  --landing-scenario-tint: rgba(245, 166, 35, 0.04);
  --landing-story-pain-tint: rgba(248, 113, 113, 0.05);
  --landing-story-outcome-tint: rgba(52, 211, 153, 0.06);
  --landing-tui-showcase-bg: radial-gradient(circle at 50% 0%, rgba(245, 166, 35, 0.05) 0%, transparent 70%);
  --landing-panel-shadow: none;
  --hero-grid-opacity: 0.06;
  --hero-grid-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='100' viewBox='0 0 56 100'%3E%3Cpath d='M28 0L56 16v32L28 64 0 48V16z' fill='none' stroke='%23ffc857' stroke-width='1'/%3E%3C/svg%3E");

  --mock-frame-bg: var(--bg-card);
  --mock-chrome-bg: linear-gradient(180deg, #1a2438 0%, #121a2a 100%);
  --mock-body-bg: var(--bg-deep);
  --mock-frame-border: rgba(255, 255, 255, 0.1);
  --mock-frame-shadow: 0 20px 50px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(245, 166, 35, 0.08);
  --mock-org-bar-bg: rgba(12, 22, 40, 0.8);
  --mock-tui-bg: #0c0c0c;
  --mock-tui-title-bg: rgba(8, 145, 178, 0.12);
  --mock-tui-title-border: #0891b2;
  --mock-tui-title-text: #67e8f9;
  --mock-tui-prompt: #e2e8f0;
  --mock-terminal-bg: #040810;
  --mock-terminal-header: #0a0e17;
  --mock-terminal-border: rgba(255, 255, 255, 0.1);
  --mock-terminal-shadow: 0 25px 60px rgba(0, 0, 0, 0.8), 0 0 30px rgba(61, 139, 253, 0.08);
  --mock-float-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);

  --sidebar-w: 260px;
  --transition: 0.18s ease;
}

[data-theme="light"] {
  color-scheme: light;

  --bg-deep: #eef1f6;
  --bg-card: #ffffff;
  --bg-base: #f8fafc;
  --bg-surface: #ffffff;
  --bg-elevated: #f1f5f9;
  --bg-panel: #ffffff;
  --bg-hover: rgba(15, 23, 42, 0.04);

  --text: #1e293b;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --gold: #d48806;
  --gold-light: #b45309;
  --gold-dim: rgba(212, 136, 6, 0.12);
  --gold-glow: rgba(212, 136, 6, 0.18);
  --gold-dark: #b45309;
  --btn-primary-text: #1a1200;

  --border: rgba(15, 23, 42, 0.12);
  --border-subtle: rgba(15, 23, 42, 0.08);
  --border-accent: rgba(180, 83, 9, 0.32);

  --accent: #b45309;
  --accent-blue: #2563eb;
  --blue: #2563eb;
  --blue-dim: rgba(37, 99, 235, 0.08);
  --success: #059669;
  --ok: #059669;
  --danger: #dc2626;
  --warning: #d97706;
  --ok-bg: rgba(5, 150, 105, 0.1);
  --danger-bg: rgba(220, 38, 38, 0.08);
  --alert-ok-text: #047857;
  --alert-error-text: #b91c1c;

  --overlay-backdrop: rgba(15, 23, 42, 0.35);
  --overlay-modal: rgba(15, 23, 42, 0.4);
  --overlay-surface: rgba(15, 23, 42, 0.03);
  --overlay-surface-hover: rgba(15, 23, 42, 0.05);
  --overlay-glass: rgba(255, 255, 255, 0.92);
  --overlay-header: rgba(255, 255, 255, 0.88);
  --overlay-footer: rgba(15, 23, 42, 0.03);

  --shadow: 0 12px 40px rgba(15, 23, 42, 0.08);
  --shadow-card: 0 2px 12px rgba(15, 23, 42, 0.06), 0 0 0 1px var(--border);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.1);

  --code-bg: #f1f5f9;
  --code-inline-bg: rgba(15, 23, 42, 0.06);

  --msg-user-bg: linear-gradient(135deg, rgba(37, 99, 235, 0.14), rgba(37, 99, 235, 0.06));
  --msg-user-border: rgba(37, 99, 235, 0.28);
  --msg-user-author: #1d4ed8;
  --msg-assistant-bg: #ffffff;
  --msg-assistant-border: rgba(5, 150, 105, 0.28);
  --msg-assistant-author: #047857;
  --msg-system-bg: #f8fafc;
  --msg-system-border: rgba(37, 99, 235, 0.18);
  --msg-system-text: #475569;
  --msg-repl-muted: #64748b;
  --msg-tool-start: #b45309;
  --msg-tool-end: #047857;
  --msg-progress: #0369a1;
  --stream-live-bg: rgba(37, 99, 235, 0.08);
  --stream-live-border: rgba(37, 99, 235, 0.22);
  --stream-live-text: #1d4ed8;

  --tool-muted: #64748b;
  --tool-text: #334155;
  --tool-input: #1e293b;
  --tool-running: #b45309;
  --tool-worker: #0369a1;
  --tool-done: #047857;
  --tool-error: #dc2626;
  --tool-progress: #0369a1;
  --tool-output: #64748b;

  --ambient-1: rgba(212, 136, 6, 0.06);
  --ambient-2: rgba(37, 99, 235, 0.04);
  --body-ambient-blue: rgba(37, 99, 235, 0.05);
  --body-ambient-gold: rgba(212, 136, 6, 0.04);

  --link-hover: #92400e;
  --progress-track: rgba(15, 23, 42, 0.1);
  --summary-bg: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  --sidebar-shadow: 2px 0 16px rgba(15, 23, 42, 0.06);
  --hero-title-gradient: linear-gradient(135deg, #1e293b 0%, var(--gold-light) 100%);
  --story-pain: #dc2626;
  --story-outcome: #059669;

  --landing-nav-bg: rgba(255, 255, 255, 0.88);
  --landing-nav-shadow: 0 1px 0 var(--border), 0 4px 24px rgba(15, 23, 42, 0.05);
  --landing-section-alt: #eef2f7;
  --landing-section-panel: #ffffff;
  --landing-section-band: #eef2f7;
  --landing-section-deep: #f8fafc;
  --landing-section-muted: #f1f5f9;
  --landing-section-gallery: #eef2f7;
  --landing-hero-bg:
    radial-gradient(ellipse 80% 50% at 50% -10%, var(--ambient-1), transparent),
    radial-gradient(ellipse 60% 40% at 80% 60%, var(--ambient-2), transparent),
    var(--bg-deep);
  --landing-login-bg:
    radial-gradient(ellipse 60% 50% at 50% 0%, var(--ambient-1), transparent),
    var(--bg-deep);
  --landing-unify-bg: radial-gradient(ellipse 70% 50% at 50% 50%, var(--ambient-1), transparent);
  --landing-cta-bg: linear-gradient(145deg, var(--bg-card) 0%, var(--gold-dim) 100%);
  --landing-audience-alt-bg: linear-gradient(145deg, var(--bg-card) 0%, var(--blue-dim) 100%);
  --landing-audience-alt-border: rgba(37, 99, 235, 0.18);
  --landing-scenario-tint: var(--gold-dim);
  --landing-story-pain-tint: rgba(220, 38, 38, 0.06);
  --landing-story-outcome-tint: rgba(5, 150, 105, 0.06);
  --landing-tui-showcase-bg: radial-gradient(circle at 50% 0%, var(--ambient-1) 0%, transparent 70%);
  --landing-panel-shadow: var(--shadow-card);
  --hero-grid-opacity: 0.035;
  --hero-grid-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='100' viewBox='0 0 56 100'%3E%3Cpath d='M28 0L56 16v32L28 64 0 48V16z' fill='none' stroke='%23b45309' stroke-width='1'/%3E%3C/svg%3E");

  --mock-frame-bg: #ffffff;
  --mock-chrome-bg: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
  --mock-body-bg: var(--bg-deep);
  --mock-frame-border: var(--border);
  --mock-frame-shadow: var(--shadow-lg);
  --mock-org-bar-bg: var(--bg-elevated);
  --mock-tui-bg: #f8fafc;
  --mock-tui-title-bg: rgba(8, 145, 178, 0.08);
  --mock-tui-title-border: #0891b2;
  --mock-tui-title-text: #0e7490;
  --mock-tui-prompt: var(--text);
  --mock-terminal-bg: #ffffff;
  --mock-terminal-header: #f1f5f9;
  --mock-terminal-border: var(--border);
  --mock-terminal-shadow: var(--shadow-lg);
  --mock-float-shadow: var(--shadow-lg);

  --sidebar-w: 260px;
  --transition: 0.18s ease;
}

/* Theme toggle control */
.theme-switcher {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--overlay-surface);
}

.theme-switcher-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  cursor: pointer;
  line-height: 1.2;
  transition: background 0.15s ease, color 0.15s ease;
}

.theme-switcher-btn:hover {
  color: var(--text);
  background: var(--overlay-surface-hover);
}

.theme-switcher-btn.active {
  color: var(--btn-primary-text);
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  box-shadow: 0 2px 8px var(--gold-glow);
}

.theme-switcher-compact .theme-switcher-btn {
  padding: 0.35rem 0.5rem;
  min-width: 2rem;
}

.theme-switcher-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  padding-left: 0.35rem;
  white-space: nowrap;
}
