/* Theme tokens — inspired by Tesla / Apple / Linear / Stripe / Spotify */

:root,
html[data-theme="tesla"] {
  --bg: #0a0a0a;
  --bg-elev: #111111;
  --fg: #f4f4f4;
  --muted: #8a8a8a;
  --line: rgba(255, 255, 255, 0.12);
  --accent: #ffffff;
  --btn-bg: #f4f4f4;
  --btn-fg: #0a0a0a;
  --top-bg: rgba(10, 10, 10, 0.82);
  --term-bg: #050505;
  --term-fg: #eaeaea;
  --term-muted: #9a9a9a;
  --term-line: rgba(255, 255, 255, 0.12);
  --term-control-bg: #141414;
  --online: #3ddc84;
  --degraded: #e6b84d;
  --offline: #ff5a5a;
  --info: #9ecbff;
  --hero-track: 0.14em;
  --radius: 0;
  --panel-radius: 0;
  --sans: "Space Grotesk", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --bg-image:
    radial-gradient(1200px 600px at 80% -10%, rgba(255, 255, 255, 0.06), transparent 55%),
    radial-gradient(900px 500px at 10% 110%, rgba(255, 255, 255, 0.04), transparent 50%);
}

/* Apple.com — light, airy, precise */
html[data-theme="apple"] {
  --bg: #f5f5f7;
  --bg-elev: #ffffff;
  --fg: #1d1d1f;
  --muted: #6e6e73;
  --line: rgba(0, 0, 0, 0.1);
  --accent: #0071e3;
  --btn-bg: #0071e3;
  --btn-fg: #ffffff;
  --top-bg: rgba(245, 245, 247, 0.82);
  --term-bg: #1d1d1f;
  --term-fg: #f5f5f7;
  --term-muted: #a1a1a6;
  --term-line: rgba(255, 255, 255, 0.14);
  --term-control-bg: #2c2c2e;
  --online: #30d158;
  --degraded: #ff9f0a;
  --offline: #ff453a;
  --info: #64d2ff;
  --hero-track: -0.02em;
  --radius: 14px;
  --panel-radius: 14px;
  --sans: "SF Pro Display", "Helvetica Neue", "Manrope", system-ui, sans-serif;
  --mono: "SF Mono", "IBM Plex Mono", ui-monospace, monospace;
  --bg-image: linear-gradient(180deg, #ffffff 0%, #f5f5f7 40%, #e8e8ed 100%);
}

/* Linear.app — charcoal product UI */
html[data-theme="linear"] {
  --bg: #0f0f11;
  --bg-elev: #16161a;
  --fg: #ebebef;
  --muted: #8a8f98;
  --line: rgba(255, 255, 255, 0.08);
  --accent: #5e6ad2;
  --btn-bg: #5e6ad2;
  --btn-fg: #ffffff;
  --top-bg: rgba(15, 15, 17, 0.88);
  --term-bg: #0b0b0d;
  --term-fg: #ebebef;
  --term-muted: #8a8f98;
  --term-line: rgba(255, 255, 255, 0.1);
  --term-control-bg: #16161a;
  --online: #4cb782;
  --degraded: #f2c94c;
  --offline: #eb5757;
  --info: #8b9cff;
  --hero-track: -0.03em;
  --radius: 10px;
  --panel-radius: 10px;
  --sans: "Inter Display", "Manrope", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --bg-image:
    radial-gradient(900px 500px at 0% 0%, rgba(94, 106, 210, 0.16), transparent 55%),
    radial-gradient(700px 400px at 100% 100%, rgba(255, 255, 255, 0.03), transparent 50%);
}

/* Stripe.com — crisp light + signature blue */
html[data-theme="stripe"] {
  --bg: #ffffff;
  --bg-elev: #f6f9fc;
  --fg: #0a2540;
  --muted: #425466;
  --line: rgba(10, 37, 64, 0.12);
  --accent: #635bff;
  --btn-bg: #635bff;
  --btn-fg: #ffffff;
  --top-bg: rgba(255, 255, 255, 0.9);
  --term-bg: #0a2540;
  --term-fg: #f6f9fc;
  --term-muted: #a3b3c6;
  --term-line: rgba(255, 255, 255, 0.14);
  --term-control-bg: #143556;
  --online: #00d924;
  --degraded: #f5be0b;
  --offline: #df1b41;
  --info: #80e9ff;
  --hero-track: -0.03em;
  --radius: 8px;
  --panel-radius: 8px;
  --sans: "Sohne", "Manrope", system-ui, sans-serif;
  --mono: "Source Code Pro", "IBM Plex Mono", ui-monospace, monospace;
  --bg-image:
    radial-gradient(1000px 500px at 90% -10%, rgba(99, 91, 255, 0.14), transparent 50%),
    linear-gradient(180deg, #ffffff 0%, #f6f9fc 100%);
}

/* Spotify — black canvas + green signal */
html[data-theme="spotify"] {
  --bg: #121212;
  --bg-elev: #181818;
  --fg: #ffffff;
  --muted: #b3b3b3;
  --line: rgba(255, 255, 255, 0.1);
  --accent: #1ed760;
  --btn-bg: #1ed760;
  --btn-fg: #000000;
  --top-bg: rgba(18, 18, 18, 0.9);
  --term-bg: #000000;
  --term-fg: #ffffff;
  --term-muted: #b3b3b3;
  --term-line: rgba(255, 255, 255, 0.12);
  --term-control-bg: #181818;
  --online: #1ed760;
  --degraded: #f59b23;
  --offline: #e91429;
  --info: #1ed760;
  --hero-track: -0.02em;
  /* Soft Spotify rounding — never 999px (that turns the log panel into a circle). */
  --radius: 24px;
  --pill-radius: 999px;
  --panel-radius: 12px;
  --sans: "Circular", "Manrope", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --bg-image:
    radial-gradient(800px 500px at 20% 0%, rgba(30, 215, 96, 0.14), transparent 55%),
    radial-gradient(900px 600px at 100% 80%, rgba(255, 255, 255, 0.04), transparent 50%);
}

html,
body {
  background: var(--bg-image), var(--bg);
  color: var(--fg);
  font-family: var(--sans);
}

.top {
  background: var(--top-bg);
  border-bottom-color: var(--line);
}

.top-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.user-chip {
  color: var(--muted);
  font-size: 0.85rem;
  letter-spacing: 0.04em;
}

.theme-select {
  background: var(--bg-elev);
  color: var(--fg);
  border: 1px solid var(--line);
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius);
  font-family: var(--sans);
  cursor: pointer;
}

.hero h1 {
  letter-spacing: var(--hero-track);
}

.btn {
  border-color: var(--btn-bg);
  background: var(--btn-bg);
  color: var(--btn-fg);
  border-radius: var(--radius);
}

html[data-theme="spotify"] .btn:not(.secondary) {
  border-radius: var(--pill-radius, 999px);
}

.btn.secondary {
  background: transparent;
  color: var(--fg);
  border-color: var(--line);
}

.ghost,
.ghost-sm {
  border-radius: var(--radius);
}

.terminal,
.events-panel.terminal,
section.terminal {
  background: var(--term-bg);
  /* Hard cap: log panel must stay rectangular on every theme */
  border-radius: var(--panel-radius, 12px) !important;
  color: var(--term-fg, #e8e8e8);
  border-color: var(--term-line, var(--line));
}

html[data-theme="spotify"] .terminal,
html[data-theme="spotify"] .events-panel {
  border-radius: 12px !important;
}

.terminal-bar {
  color: var(--term-muted, var(--muted));
  border-bottom-color: var(--term-line, var(--line));
}

.terminal-bar select,
.terminal-bar input[type="search"] {
  background: var(--term-control-bg, var(--bg-elev));
  color: var(--term-fg, var(--fg));
  border-color: var(--term-line, var(--line));
}

.terminal-controls .chk,
.terminal .ghost-sm {
  color: var(--term-fg, var(--fg));
  border-color: var(--term-line, var(--line));
}

.terminal .ghost-sm:hover {
  border-color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.06);
}

.terminal-body,
.events-panel .terminal-body,
.events-body {
  color: var(--term-fg, #e8e8e8);
}

.terminal .log-line,
.terminal .log-line.human {
  color: var(--term-fg, #e8e8e8);
}

.terminal .log-line.human.example,
.terminal .log-line .lvl {
  color: var(--term-muted, #9a9a9a);
}

.log-line.INFO .lvl {
  color: var(--info);
}

.auth button[type="submit"] {
  background: var(--btn-bg);
  color: var(--btn-fg);
  border-radius: var(--radius);
}

html[data-theme="apple"] .bot-row:hover,
html[data-theme="stripe"] .bot-row:hover {
  background: rgba(0, 0, 0, 0.03);
}

html[data-theme="spotify"] .brand-name {
  letter-spacing: 0.08em;
}

html[data-theme="apple"] .brand-name,
html[data-theme="stripe"] .brand-name,
html[data-theme="linear"] .brand-name {
  letter-spacing: 0.06em;
}

.theme-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.45rem;
  margin: 0 0 1rem;
}

.theme-grid legend {
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 0.35rem;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.9rem;
  color: var(--fg);
}

.theme-option input {
  accent-color: var(--accent);
}

.theme-swatch {
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  flex: 0 0 auto;
}

.theme-swatch.tesla { background: #111; }
.theme-swatch.apple { background: linear-gradient(135deg, #fff, #d2d2d7); }
.theme-swatch.linear { background: linear-gradient(135deg, #5e6ad2, #0f0f11); }
.theme-swatch.stripe { background: linear-gradient(135deg, #635bff, #0a2540); }
.theme-swatch.spotify { background: linear-gradient(135deg, #1ed760, #121212); }
