:root {
  --bg: #0b0c0a;
  --bg-elev: #121310;
  --surface: #17181410;
  --surface-1: #1a1b17;
  --surface-2: #22231e;
  --surface-3: #2c2d26;
  --border: #2a2b25;
  --border-bright: #3a3b34;
  --text: #ece9df;
  --text-muted: #9a9687;
  --text-dim: #63605a;
  --accent: #e08a3c;          /* warm amber */
  --accent-bright: #f4a054;
  --accent-soft: rgba(224, 138, 60, 0.15);
  --success: #a3c968;
  --success-soft: rgba(163, 201, 104, 0.12);
  --error: #e56b5a;
  --error-soft: rgba(229, 107, 90, 0.12);
  --info: #7fb2d4;
  --serif: 'Instrument Serif', 'Cormorant Garamond', 'Georgia', serif;
  --sans: 'Figtree', system-ui, sans-serif;
  --mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
.hidden { display: none !important; }
html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 14px; -webkit-font-smoothing: antialiased; }

/* Subtle grain + vignette */
body::before {
  content: "";
  position: fixed; inset: 0;
  background-image:
    radial-gradient(1200px 600px at 70% -10%, rgba(224, 138, 60, 0.06), transparent 60%),
    radial-gradient(800px 500px at 10% 110%, rgba(127, 178, 212, 0.04), transparent 60%);
  pointer-events: none;
  z-index: 0;
}
body::after {
  content: "";
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.9  0 0 0 0 0.85  0 0 0 0 0.78  0 0 0 0.05 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  opacity: 0.45;
  pointer-events: none;
  mix-blend-mode: overlay;
  z-index: 0;
}

/* Layout shell */
.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

/* Scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* Loading splash */
.splash {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 300;
  transition: opacity 0.5s;
}
.splash.hide { opacity: 0; pointer-events: none; }
.splash .logo {
  font-family: var(--serif);
  font-style: italic;
  font-size: 56px;
  color: var(--text);
  letter-spacing: -0.02em;
}
.splash .logo::before { content: "·"; color: var(--accent); margin-right: 10px; font-style: normal; }
.splash .sub {
  font-size: 11px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-top: 8px;
}
.splash .bar {
  width: 200px; height: 1px;
  background: var(--border);
  margin-top: 28px;
  position: relative;
  overflow: hidden;
}
.splash .bar::after {
  content: "";
  position: absolute; inset: 0;
  background: var(--accent);
  animation: load 1.8s ease-in-out infinite;
}
@keyframes load {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* small screens */
@media (max-width: 1050px) {
  .main { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr auto; }
  .left, .right { border: none; border-bottom: 1px solid var(--border); }
  .results { max-height: none; }
}

/* ─── Dark Theme (explicit — controlled by data-theme attribute) ── */
html[data-theme="dark"],
[data-theme="dark"] {
  --bg: #0b0c0a;
  --bg-elev: #121310;
  --surface: #17181410;
  --surface-1: #1a1b17;
  --surface-2: #22231e;
  --surface-3: #2c2d26;
  --border: #2a2b25;
  --border-bright: #3a3b34;
  --text: #ece9df;
  --text-muted: #9a9687;
  --text-dim: #63605a;
  --accent: #e08a3c;
  --accent-bright: #f4a054;
  --accent-soft: rgba(224, 138, 60, 0.15);
  --success: #a3c968;
  --success-soft: rgba(163, 201, 104, 0.12);
  --error: #e56b5a;
  --error-soft: rgba(229, 107, 90, 0.12);
  --info: #7fb2d4;
}

/* ─── Light Theme ── */
html[data-theme="light"],
[data-theme="light"] {
  --bg: #f5f3ef;
  --bg-elev: #ffffff;
  --surface: rgba(0,0,0,0.04);
  --surface-1: #f8f7f4;
  --surface-2: #eeece8;
  --surface-3: #e2e0da;
  --border: #d8d5ce;
  --border-bright: #c4c1b8;
  --text: #1a1918;
  --text-muted: #6b6860;
  --text-dim: #9a9689;
  --accent: #c96a20;
  --accent-bright: #b85e18;
  --accent-soft: rgba(201, 106, 32, 0.12);
  --success: #5a8a38;
  --success-soft: rgba(90, 138, 56, 0.12);
  --error: #c0392b;
  --error-soft: rgba(192, 57, 43, 0.12);
  --info: #2980b9;
}

/* ─── Auto Theme (follows system preference) ── */
html[data-theme="auto"],
[data-theme="auto"] {
  --bg: #0b0c0a;
  --bg-elev: #121310;
  --surface: #17181410;
  --surface-1: #1a1b17;
  --surface-2: #22231e;
  --surface-3: #2c2d26;
  --border: #2a2b25;
  --border-bright: #3a3b34;
  --text: #ece9df;
  --text-muted: #9a9687;
  --text-dim: #63605a;
  --accent: #e08a3c;
  --accent-bright: #f4a054;
  --accent-soft: rgba(224, 138, 60, 0.15);
  --success: #a3c968;
  --success-soft: rgba(163, 201, 104, 0.12);
  --error: #e56b5a;
  --error-soft: rgba(229, 107, 90, 0.12);
  --info: #7fb2d4;
}

/* When system prefers light and data-theme is auto, apply light values */
@media (prefers-color-scheme: light) {
  html[data-theme="auto"],
  [data-theme="auto"] {
    --bg: #f5f3ef;
    --bg-elev: #ffffff;
    --surface: rgba(0,0,0,0.04);
    --surface-1: #f8f7f4;
    --surface-2: #eeece8;
    --surface-3: #e2e0da;
    --border: #d8d5ce;
    --border-bright: #c4c1b8;
    --text: #1a1918;
    --text-muted: #6b6860;
    --text-dim: #9a9689;
    --accent: #c96a20;
    --accent-bright: #b85e18;
    --accent-soft: rgba(201, 106, 32, 0.12);
    --success: #5a8a38;
    --success-soft: rgba(90, 138, 56, 0.12);
    --error: #c0392b;
    --error-soft: rgba(192, 57, 43, 0.12);
    --info: #2980b9;
  }
}

/* ─── WCAG AA Focus Indicators ── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Remove default focus ring (replaced by custom) */
:focus:not(:focus-visible) {
  outline: none;
}

/* Interactive elements focus */
button:focus-visible, .btn:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible,
[role="button"]:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Links focus */
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
