:root,
:root[data-theme="light"] {
  color-scheme: light;
  --bg-ink: #f7fafc;
  --bg-ink-2: #e9eff5;
  --bg-moss: #dbe9e0;
  --bg-slate: #e2e8f0;
  --panel: rgba(255, 255, 255, 0.84);
  --panel-border: rgba(148, 163, 184, 0.3);
  --text: #0f172a;
  --muted: #475569;
  --accent: #085785;
  --accent-2: #0f6da8;
  --accent-soft: rgba(8, 87, 133, 0.12);
  --accent-soft-strong: rgba(8, 87, 133, 0.2);
  --accent-contrast: #f8fafc;
  --danger: #dc2626;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --shadow: 0 26px 60px rgba(15, 23, 42, 0.12);
  --surface-1: rgba(255, 255, 255, 0.72);
  --surface-card: rgba(255, 255, 255, 0.94);
  --surface-2: rgba(248, 250, 252, 0.92);
  --surface-3: rgba(241, 245, 249, 0.96);
  --surface-4: rgba(226, 232, 240, 0.82);
  --line: rgba(148, 163, 184, 0.22);
  --line-strong: rgba(148, 163, 184, 0.35);
  --line-accent: rgba(8, 87, 133, 0.28);
  --link: #0f5f93;
  --link-hover: #0b4a72;
  --success-text: #166534;
  --warning-text: #92400e;
  --danger-text: #991b1b;
  --overlay: rgba(15, 23, 42, 0.34);
  --header-backdrop: linear-gradient(180deg, rgba(248, 250, 252, 0.96), rgba(248, 250, 252, 0.78));
  --orb-1: rgba(14, 116, 144, 0.24);
  --orb-2: rgba(148, 163, 184, 0.3);
  --glow-1: rgba(8, 87, 133, 0.12);
  --glow-2: rgba(56, 189, 248, 0.1);
  --status-thinking-base-color: rgba(15, 23, 42, 0.72);
  --menu-bg: #ffffff;
  --status-thinking-spotlight-color: rgba(15, 23, 42, 0.98);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg-ink: #0c1116;
  --bg-ink-2: #0a141b;
  --bg-moss: #0f2b1f;
  --bg-slate: #1b2430;
  --panel: rgba(12, 18, 24, 0.88);
  --panel-border: rgba(148, 163, 184, 0.18);
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #085785;
  --accent-2: #085785;
  --accent-soft: rgba(8, 87, 133, 0.18);
  --accent-soft-strong: rgba(8, 87, 133, 0.22);
  --accent-contrast: #eff6ff;
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.14);
  --shadow: 0 30px 60px rgba(2, 6, 23, 0.55);
  --surface-1: rgba(15, 23, 42, 0.72);
  --surface-card: rgba(15, 23, 42, 0.72);
  --surface-2: rgba(10, 16, 24, 0.98);
  --surface-3: rgba(30, 41, 59, 0.92);
  --surface-4: rgba(51, 65, 85, 0.45);
  --line: rgba(148, 163, 184, 0.2);
  --line-strong: rgba(148, 163, 184, 0.35);
  --line-accent: rgba(96, 165, 250, 0.35);
  --link: #93c5fd;
  --link-hover: #dbeafe;
  --success-text: #86efac;
  --warning-text: #fbbf24;
  --danger-text: #fecaca;
  --menu-bg: #1e293b;
  --overlay: rgba(5, 10, 18, 0.72);
  --header-backdrop: linear-gradient(180deg, rgba(7, 13, 24, 0.96), rgba(7, 13, 24, 0.72));
  --orb-1: #0a3651;
  --orb-2: #1e293b;
  --glow-1: rgba(8, 87, 133, 0.18);
  --glow-2: rgba(56, 189, 248, 0.12);
  --status-thinking-base-color: rgba(226, 232, 240, 0.75);
  --status-thinking-spotlight-color: rgba(255, 255, 255, 0.98);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg-ink: #0c1116;
    --bg-ink-2: #0a141b;
    --bg-moss: #0f2b1f;
    --bg-slate: #1b2430;
    --panel: rgba(12, 18, 24, 0.88);
    --panel-border: rgba(148, 163, 184, 0.18);
    --text: #e2e8f0;
    --muted: #94a3b8;
    --accent: #085785;
    --accent-2: #085785;
    --accent-soft: rgba(8, 87, 133, 0.18);
    --accent-soft-strong: rgba(8, 87, 133, 0.22);
    --accent-contrast: #eff6ff;
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, 0.14);
    --shadow: 0 30px 60px rgba(2, 6, 23, 0.55);
    --surface-1: rgba(15, 23, 42, 0.72);
    --surface-card: rgba(15, 23, 42, 0.72);
    --surface-2: rgba(10, 16, 24, 0.98);
    --surface-3: rgba(30, 41, 59, 0.92);
    --surface-4: rgba(51, 65, 85, 0.45);
    --line: rgba(148, 163, 184, 0.2);
    --line-strong: rgba(148, 163, 184, 0.35);
    --line-accent: rgba(96, 165, 250, 0.35);
    --link: #93c5fd;
    --link-hover: #dbeafe;
    --success-text: #86efac;
    --warning-text: #fbbf24;
    --danger-text: #fecaca;
    --menu-bg: #1e293b;
    --overlay: rgba(5, 10, 18, 0.72);
    --header-backdrop: linear-gradient(180deg, rgba(7, 13, 24, 0.96), rgba(7, 13, 24, 0.72));
    --orb-1: #0a3651;
    --orb-2: #1e293b;
    --glow-1: rgba(8, 87, 133, 0.18);
    --glow-2: rgba(56, 189, 248, 0.12);
    --status-thinking-base-color: rgba(226, 232, 240, 0.75);
    --status-thinking-spotlight-color: rgba(255, 255, 255, 0.98);
  }
}

html {
  background: var(--bg-ink);
}

body {
  color: var(--text);
  background:
    radial-gradient(circle at top left, var(--glow-1), transparent 45%),
    radial-gradient(circle at 30% 10%, var(--glow-2), transparent 40%),
    linear-gradient(180deg, var(--bg-ink) 0%, var(--bg-ink-2) 55%, var(--bg-ink-2) 100%);
  transition: background 180ms ease, color 180ms ease;
}

body::before {
  background: var(--orb-1);
}

body::after {
  background: var(--orb-2);
}

.brand-mark {
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  color: var(--accent-contrast);
}

.header-scrolled header {
  background: var(--header-backdrop);
}

.brand h1,
.brand h2,
.hero h2,
.intro h2,
.panel-title h2,
.auth-card h3,
.feedback-panel h3,
.settings-panel h3,
.action-card h3,
.table-card h3,
.section-title,
.source-title,
.source-item,
.prompt-card-title,
.prompt-suggestion-title {
  color: var(--text);
}

.brand span,
.brand p,
.muted,
.card-label,
.field label,
.control label,
.panel-title p,
.intro p,
.notice p,
.metric-line,
.window-user-meta,
.prompt-card-summary,
.prompt-suggestion-preview,
.prompt-suggestion-reason,
.updated-text,
.auth-status,
.feedback-hint,
.settings-panel p,
.settings-option-copy span,
.citation-source-excerpt,
.citation-source-meta,
.sources,
.status,
.status-line,
.status-pill,
.menu-item span {
  color: var(--muted);
}

.settings-option-copy strong {
  color: var(--text);
}

a,
.source-link,
.bubble.assistant blockquote a,
.sources-disclosure-summary {
  color: var(--link);
}

a:hover,
.source-link:hover,
.bubble.assistant blockquote a:hover,
.sources-disclosure-summary:hover {
  color: var(--link-hover);
}

.panel,
.hero,
.chat-panel,
.feedback-panel,
.settings-panel,
.auth-card,
.user-menu-panel {
  background: var(--panel);
  border-color: var(--panel-border);
  color: var(--text);
  box-shadow: var(--shadow);
}

.panel > .hero {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.summary-card,
.notice,
.memory-row,
.form-section,
.prompt-card,
.prompt-suggestion-button,
.window-user,
.source-item,
.composer-row,
.composer-prompt-suggestions,
.settings-option,
.raw,
.bubble.assistant {
  background: var(--surface-1);
  border-color: var(--line);
  color: var(--text);
}

.card,
.pack-card,
.action-card,
.table-card {
  background: var(--surface-card);
  border-color: var(--line);
  color: var(--text);
}

.table-wrap,
.window-user,
.table-card,
.summary-card,
.status-pill,
.pill,
.tag,
.memory-row,
.form-section,
.notice,
.raw,
.composer-row {
  border-color: var(--line);
}

th {
  background: var(--surface-4);
  color: var(--muted);
}

tbody tr:hover {
  background: var(--surface-2);
}

.ghost-button,
.outline-button,
.pill-button,
.button,
.bubble-action,
.feedback-button,
.settings-button,
.tab-button,
.user-trigger {
  background: var(--surface-2);
  border-color: var(--line-strong);
  color: var(--text);
}

.ghost-button:hover,
.outline-button:hover,
.pill-button:hover,
.button:hover,
.bubble-action:hover,
.feedback-button:hover,
.settings-button:hover,
.tab-button:hover,
.user-trigger:hover {
  background: var(--surface-3);
  border-color: var(--line-accent);
  color: var(--text);
}

.menu-item {
  color: var(--text);
}

.menu-item:hover {
  background: var(--surface-2);
  border-color: var(--line);
}

.menu-divider {
  background: var(--line);
}

.user-trigger span,
.user-trigger .chevron {
  color: var(--muted);
}

.tabs {
  background: var(--surface-4);
  border-color: var(--line);
}

.tab-button.active {
  background: var(--accent);
  color: var(--accent-contrast);
  box-shadow: 0 10px 24px rgba(8, 87, 133, 0.22);
}

.solid-button,
.pack-button,
.button.primary,
.feedback-button.primary,
.settings-button.primary,
.composer button,
.auth-button {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: var(--accent-contrast);
}

.danger-button {
  border-color: rgba(220, 38, 38, 0.35);
  background: rgba(248, 113, 113, 0.12);
  color: var(--danger-text);
}

.notice.success,
.status-pill.ok,
.pill.pass {
  border-color: rgba(34, 197, 94, 0.28);
  background: rgba(34, 197, 94, 0.1);
  color: var(--success-text);
}

.notice.error,
.status-pill.error,
.pill.fail,
.pill.disabled {
  border-color: rgba(220, 38, 38, 0.28);
  background: rgba(248, 113, 113, 0.12);
  color: var(--danger-text);
}

.status-pill.missing {
  border-color: rgba(245, 158, 11, 0.3);
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning-text);
}

.status-line.success,
.status.success,
.summary-card.pass p,
.summary-card.pass .card-value,
.summary-card.pass,
.summary-card.pass strong,
.summary-card.pass .status {
  color: var(--success-text);
}

.status-line.error,
.status.error,
.summary-card.fail p,
.summary-card.fail .card-value,
.summary-card.fail,
.summary-card.fail strong {
  color: var(--danger-text);
}

.summary-card h3,
.card-subvalue,
.prompt-text,
.query .muted,
.memory-row .meta,
.settings-option-copy span,
.pill.inactive,
.tag.inactive {
  color: var(--muted);
}

.pill,
.tag,
.bubble.assistant .inline-citation,
.source-citation-pill {
  background: var(--accent-soft);
  border-color: var(--line-accent);
  color: var(--link);
}

.pill.inactive {
  background: var(--surface-2);
  border-color: var(--line);
}

.bubble.assistant blockquote {
  border-left-color: var(--line-strong);
  color: var(--muted);
}

.bubble.assistant .inline-citation:hover,
.source-citation-pill:hover,
.citation-source.is-active {
  background: var(--surface-3);
  border-color: var(--line-accent);
  color: var(--link-hover);
}

.bubble.assistant .inline-citation[data-tooltip]::before {
  background: var(--surface-3);
  border-color: var(--line-strong);
  color: var(--text);
}

.bubble.assistant .inline-citation[data-tooltip]::after {
  background: var(--surface-3);
  border-right-color: var(--line-strong);
  border-bottom-color: var(--line-strong);
}

.composer-prompt-suggestions,
.response-prompt-suggestions {
  border-color: var(--line-accent);
}

.feedback-modal,
.settings-modal,
.auth-gate {
  background: var(--overlay);
}

.control input,
.control select,
.field input,
.field select,
.field textarea,
.feedback-input,
.composer textarea,
.settings-option,
.raw {
  background: var(--surface-2);
  color: var(--text);
}

.control input,
.control select,
.field input,
.field select,
.field textarea,
.feedback-input,
.settings-option,
.raw {
  border-color: var(--line-strong);
}

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  color: var(--text);
}

input:not([type="checkbox"]):not([type="radio"])::placeholder,
textarea::placeholder {
  color: var(--muted);
}

input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(8, 87, 133, 0.2);
  outline-offset: 2px;
  border-color: var(--line-accent);
}

.status.status-thinking {
  --status-thinking-base: var(--status-thinking-base-color);
  --status-thinking-spotlight: var(--status-thinking-spotlight-color);
}

.raw,
code {
  color: var(--text);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
}

.theme-toggle-buttons {
  display: inline-flex;
  gap: 4px;
}

.theme-toggle-button {
  position: relative;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  width: 36px;
  height: 36px;
  padding: 0;
  font: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.theme-toggle-button::before,
.theme-toggle-button::after {
  position: absolute;
  left: 50%;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease, transform 120ms ease;
}

.theme-toggle-button::before {
  content: attr(data-tooltip);
  bottom: calc(100% + 10px);
  transform: translateX(-50%) translateY(4px);
  padding: 6px 8px;
  border-radius: 8px;
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  color: var(--text);
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
  box-shadow: var(--shadow);
}

.theme-toggle-button::after {
  content: "";
  bottom: calc(100% + 4px);
  width: 8px;
  height: 8px;
  transform: translateX(-50%) translateY(4px) rotate(45deg);
  background: var(--surface-3);
  border-right: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
}

.theme-toggle-button:hover {
  color: var(--text);
  background: var(--surface-3);
}

.theme-toggle-button:hover::before,
.theme-toggle-button:hover::after,
.theme-toggle-button:focus-visible::before,
.theme-toggle-button:focus-visible::after {
  opacity: 1;
}

.theme-toggle-button:hover::before,
.theme-toggle-button:focus-visible::before {
  transform: translateX(-50%) translateY(0);
}

.theme-toggle-button:hover::after,
.theme-toggle-button:focus-visible::after {
  transform: translateX(-50%) translateY(0) rotate(45deg);
}

.theme-toggle-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-toggle-button.is-active {
  background: var(--accent-soft-strong);
  box-shadow: inset 0 0 0 1px var(--line-accent);
  color: var(--text);
}

.theme-toggle-button:focus-visible {
  outline: 2px solid rgba(8, 87, 133, 0.28);
  outline-offset: 2px;
}

@media (max-width: 720px) {
  .theme-toggle {
    align-self: flex-start;
  }
}
