/* ── Apex Investment Analyzer — shared theme ────────────────────────────────
   Light is the default. Dark is opt-in via <html data-theme="dark">.
   theme.js sets the attribute from localStorage and renders a toggle. */

:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --border: #d8dee9;
  --text: #1a2233;
  --text-muted: #5b6678;
  --text-faint: #8a93a3;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --on-primary: #ffffff;
  --link: #2563eb;
  --danger: #dc2626;
  --success: #15803d;
  --chip-bg: #e7f6ee;
  --chip-text: #15803d;
  --chip-border: #b6e3c8;
  --user-msg-bg: #e8f0fe;
  --user-msg-border: #c5d9fb;
  --assistant-msg-bg: #ffffff;
  --tool-bg: #f1ecfd;
  --tool-text: #6d28d9;
  --warn-bg: #fff8e6;
  --warn-border: #f3e0a6;
  --warn-text: #8a6d1a;
  --shadow: 0 1px 3px rgba(20,30,55,.08), 0 4px 16px rgba(20,30,55,.06);
}

html[data-theme="dark"] {
  --bg: #0f1117;
  --surface: #131720;
  --surface-2: #1a2030;
  --border: #2d3748;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-faint: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --on-primary: #ffffff;
  --link: #60a5fa;
  --danger: #f87171;
  --success: #4ade80;
  --chip-bg: #14271d;
  --chip-text: #4ade80;
  --chip-border: #1f5135;
  --user-msg-bg: #1e3a5f;
  --user-msg-border: #2b517f;
  --assistant-msg-bg: #161c27;
  --tool-bg: #1a1f2e;
  --tool-text: #a78bfa;
  --warn-bg: #1c1606;
  --warn-border: #3f2d0a;
  --warn-text: #d6b86a;
  --shadow: none;
}

* { box-sizing: border-box; }
body { background: var(--bg); color: var(--text); margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
a { color: var(--link); }

/* Floating theme toggle (injected by theme.js) */
.theme-toggle {
  position: fixed; bottom: 16px; right: 16px; z-index: 200;
  width: 40px; height: 40px; border-radius: 999px; cursor: pointer;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  font-size: 1.05rem; line-height: 1; box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center;
}
.theme-toggle:hover { border-color: var(--primary); }

/* ── Auth/card pages ─────────────────────────────────────────────── */
.auth-body { min-height: 100dvh; display: flex; align-items: center; justify-content: center; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 36px; width: 380px; max-width: 92vw; box-shadow: var(--shadow); }
.card h1 { font-size: 1.25rem; margin: 0 0 6px; }
.card h2 { font-size: 1rem; margin: 0 0 12px; }
.sub { color: var(--text-muted); font-size: 0.85rem; margin: 0 0 24px; }
label { display: block; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input:not([type]) {
  width: 100%; background: var(--surface); border: 1px solid var(--border); color: var(--text);
  padding: 11px 14px; border-radius: 10px; font-size: 1rem; margin-bottom: 16px; }
input:focus { outline: none; border-color: var(--primary); }
button.primary, .card button[type=submit] {
  width: 100%; background: var(--primary); color: var(--on-primary); border: none;
  padding: 12px; border-radius: 10px; cursor: pointer; font-size: 0.95rem; font-weight: 500; }
button.primary:hover, .card button[type=submit]:hover { background: var(--primary-hover); }
.msg { font-size: 0.84rem; min-height: 18px; margin-bottom: 12px; }
.msg.err { color: var(--danger); }
.msg.ok { color: var(--success); }
.hint { color: var(--text-faint); font-size: 0.75rem; margin-top: 14px; }
.foot { text-align: center; margin-top: 16px; font-size: 0.83rem; color: var(--text-muted); }
.step { display: none; } .step.active { display: block; }
.secret-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px; margin: 6px 0 16px; font-family: monospace; font-size: 0.95rem;
  letter-spacing: 0.08em; color: var(--text); word-break: break-all; text-align: center; }
.check-row { display: flex; gap: 10px; align-items: flex-start; margin: 4px 0 18px;
  font-size: 0.78rem; color: var(--text-muted); line-height: 1.5; cursor: pointer; }
.check-row input { margin-top: 2px; width: auto; }

/* ── Document pages (privacy / terms) ───────────────────────────────── */
.doc { max-width: 800px; margin: 0 auto; padding: 48px 24px 96px; line-height: 1.7; color: var(--text); }
.doc h1 { font-size: 1.6rem; }
.doc h2 { font-size: 1.12rem; margin-top: 34px; }
.doc .updated { color: var(--text-faint); font-size: 0.85rem; }
.doc code { background: var(--surface-2); padding: 2px 6px; border-radius: 4px; font-size: 0.85em; }
.doc table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 0.9rem; }
.doc th, .doc td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; vertical-align: top; }
.doc th { background: var(--surface-2); color: var(--text); }
.doc .callout { background: var(--warn-bg); border: 1px solid var(--warn-border); color: var(--warn-text);
  padding: 14px 16px; border-radius: 10px; font-size: 0.9rem; margin: 18px 0; }
