/* Theme roles. Load after page and shared component styles. */
:root {
  --page-bg: #080611;
  --surface: #141020;
  --surface-soft: #1c172a;
  --ink: #f6f6ff;
  --muted-ink: #bcb0cd;
  --accent: #85f5ea;
  --accent-soft: #183331;
  --accent-ink: #092626;
  --border: #443a54;
  --success: #94e2bc;
  --success-soft: #15372b;
  --warning: #edc582;
  --warning-soft: #342a1a;
  --danger: #f1a4aa;
}
:root[data-theme="light"] {
  color-scheme: light;
  --page-bg: #ffffff;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-soft: #f3f5f9;
  --ink: #172135;
  --text: #172135;
  --muted-ink: #5d687b;
  --muted: #5d687b;
  --accent: #285bcc;
  --accent-soft: #eaf0ff;
  --accent-ink: #ffffff;
  --cyan: #285bcc;
  --violet: #6952ab;
  --line: #e0e5ee;
  --border: #d7deea;
  --control-bg: #ffffff;
  --control-border: #b8c2d3;
  --readable-muted: #5d687b;
  --success: #117653;
  --success-soft: #edf8f2;
  --warning: #936000;
  --warning-soft: #fff6e2;
  --danger: #b43943;
  color: var(--ink);
  background: var(--page-bg);
}
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  gap: 7px;
  min-width: 44px;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--ink);
  background: var(--surface);
  font: inherit;
  font-size: 12px;
  line-height: 1.4;
  cursor: pointer;
}
.theme-toggle svg {
  display: block;
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.theme-toggle:hover { background: var(--surface-soft); border-color: var(--accent); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
:root[data-theme="light"] body { background: var(--page-bg); color: var(--ink); }
:root[data-theme="light"] * { scrollbar-color: #a1afc3 #f4f6fa; }
:root[data-theme="light"] ::selection { color: #123269; background: #dce8ff; }
:root[data-theme="light"] :is(input, select, textarea) { color: var(--ink); caret-color: var(--accent); }
:root[data-theme="light"] :is(input, textarea)::placeholder { color: #657184; }
:root[data-theme="light"] select option { background: white; color: var(--ink); }
:root[data-theme="light"] :is(.skip, .skip-link) { background: var(--accent); color: #fff; }
:root[data-theme="light"] :is(.mono, .white-logo, .dock-featured .dock-icon img) { filter: brightness(0); }

/* A clear daylight canvas retains the orbit and floating brand composition. */
:root[data-theme="light"] .site-nav { background: linear-gradient(#ffffffed, #ffffff00); }
:root[data-theme="light"] :is(.site-nav.is-scrolled, .tutorial-header, .support-header) {
  background: #ffffffed;
  border-bottom-color: var(--line);
}
:root[data-theme="light"] :is(nav > a, .motion-toggle) { color: #566277; }
:root[data-theme="light"] :is(nav > a:hover, nav > a.active) { color: var(--ink); }
:root[data-theme="light"] nav > a.active:after { background: var(--accent); box-shadow: none; }
:root[data-theme="light"] .nav-start { border-color: #b8c2d3; background: #fff9; color: var(--ink); }
:root[data-theme="light"] .nav-start:hover { border-color: var(--accent); background: #edf3ff; }
:root[data-theme="light"] .icon-button:hover { background: #eaf0f9; color: var(--accent); }
:root[data-theme="light"] .space {
  background: radial-gradient(ellipse at 50% 47%, #eef3ff 0, #f8faff 43%, #ffffff 75%);
}
:root[data-theme="light"] .space:after { background: linear-gradient(0deg, #fff, transparent 20%, transparent 86%, #ffffff60); }
:root[data-theme="light"] .nebula { opacity: .18; }
:root[data-theme="light"] .nebula-violet { background: radial-gradient(ellipse, #a68ce9, transparent 66%); }
:root[data-theme="light"] .nebula-cyan { background: radial-gradient(ellipse, #7fced9, transparent 65%); opacity: .17; }
:root[data-theme="light"] .orbit-one { border-color: #b7c9ed; background: none; box-shadow: none; }
:root[data-theme="light"] .orbit-two { border-color: #d7dff2; }
:root[data-theme="light"] .orbit-three { border-color: #d6e7ed; }
:root[data-theme="light"] .horizon { background: radial-gradient(ellipse, #b5c3e82b, transparent 68%); }
:root[data-theme="light"] #stardust { opacity: .23; mix-blend-mode: multiply; }
:root[data-theme="light"] .logo-face,
:root[data-theme="light"] :is(.float-gpt, .float-claude) .logo-face {
  background: #ffffffce;
  border-color: transparent;
  box-shadow: 0 14px 35px #38508412;
}
:root[data-theme="light"] .logo-face:before { background: none; }
:root[data-theme="light"] .logo-face span { color: #4e5e77; }
:root[data-theme="light"] :is(.float-muse, .float-ollama) { opacity: .8; }
:root[data-theme="light"] .hero-panel {
  background: #ffffffdf;
  border-color: transparent;
  box-shadow: 0 26px 75px -26px #586f9c36;
}
:root[data-theme="light"] .hero-panel:before { background: none; }
:root[data-theme="light"] .panel-edge { background: linear-gradient(90deg, transparent, #aabce0, transparent); opacity: .5; }
:root[data-theme="light"] h1 { text-shadow: none; }
:root[data-theme="light"] .title-ai { color: #2454ba; }
:root[data-theme="light"] .title-dot { background: #26958d; box-shadow: none; }
:root[data-theme="light"] .hero-subtitle { color: #344561; }
:root[data-theme="light"] :is(.hero-copy, .hero-evidence-link, .price-note, .hero-foot, .hero-foot > a) { color: #606e83; }
:root[data-theme="light"] :is(.primary-action, .button.primary) { color: #fff; background: #285bcc; }
:root[data-theme="light"] :is(.primary-action:hover, .button.primary:hover) { color: #fff; background: #1d4caf; box-shadow: 0 8px 22px #285bcc1f; }
:root[data-theme="light"] .button.primary .external-note { color: #e3ecff; }
:root[data-theme="light"] .tutorial-dock { border-top-color: var(--line); }
:root[data-theme="light"] .dock-link + .dock-link:before { background: var(--line); }
:root[data-theme="light"] .dock-link:hover { background: #f0f4fb; }
:root[data-theme="light"] .dock-text small { color: #627089; }

/* Records and all search/control states share one light surface vocabulary. */
:root[data-theme="light"] :is(.section-intro h2 > span, .support-teaser h2 span) { color: #53647e; }
:root[data-theme="light"] :is(.evidence-caption, .evidence-caption > span:last-child, .record-count, .record-amount, .record-meta, .record-meta > span:last-child, .evidence-bottom p) { color: var(--muted-ink); }
:root[data-theme="light"] .filters button { color: #5c677c; }
:root[data-theme="light"] .filters button:hover { color: var(--ink); }
:root[data-theme="light"] .filters button.selected { color: var(--accent); }
:root[data-theme="light"] .filters button.selected:after { box-shadow: none; }
:root[data-theme="light"] :is(.record-search, .select-field select, .search-box, .faq-search) { background: white; border-color: #b9c4d6; }
:root[data-theme="light"] :is(.record-search > .icon, .select-field, .select-field select) { color: #47566e; }
:root[data-theme="light"] .record-visual { background: #f0f3f8; }
:root[data-theme="light"] .record-card:hover .record-visual { background: #e9eef7; }
:root[data-theme="light"] .record-visual img { box-shadow: 0 9px 20px #273c6212; }
:root[data-theme="light"] .zoom-indicator { background: #ffffffed; border-color: #d7deea; color: #355179; }
:root[data-theme="light"] .plan-label { color: #52617a; background: #fffffff2; border-color: #d7deea; }
:root[data-theme="light"] .record-spotlight .plan-label { color: #214eaf; background: #eaf0ff; border-color: #c8d6f7; }
:root[data-theme="light"] .record-type { color: #1e7768; }
:root[data-theme="light"] .record-type.verification { color: #886027; }
:root[data-theme="light"] .record-type.status { color: #7359a0; }
:root[data-theme="light"] .record-spotlight .record-amount { color: #435873; }
:root[data-theme="light"] .record-visual .image-error { color: var(--muted-ink); }
:root[data-theme="light"] .empty-records { border-color: #a7b5cd; }
:root[data-theme="light"] :is(.text-button, .text-link, .download-link, .issue-shortcuts a) { color: #285bcc; }
:root[data-theme="light"] :is(.text-button:hover, .text-link:hover, .download-link:hover, .issue-shortcuts a:hover, .copy-number:hover) { color: #153e94; }
:root[data-theme="light"] :is(.outline-button, .button.secondary, .chat-controls button, .story-toolbar button) {
  color: #354661; background: #fff; border-color: #bdc8d9;
}
:root[data-theme="light"] :is(.outline-button:hover, .button.secondary:hover, .chat-controls button:hover:not(:disabled), .story-toolbar button:hover:not(:disabled)) {
  color: #214eaf; background: #edf3ff; border-color: #7598df;
}
:root[data-theme="light"] :is(.outline-button[aria-pressed="true"], .chat-controls button[aria-pressed="true"], .story-toolbar button[aria-pressed="true"]) {
  color: #214eaf; background: #eaf0ff; border-color: #86a6e6;
}

/* The records remain the focus: restrained color frames genuine chat content. */
:root[data-theme="light"] .stories-section { border-top-color: var(--line); background: #f9fbfe; }
:root[data-theme="light"] .stories-glow { background: radial-gradient(ellipse at 50% 50%, #e9effc99, transparent 68%); }
:root[data-theme="light"] .stories-heading h2 { color: var(--ink); }
:root[data-theme="light"] :is(.stories-heading > p, .stories-heading > span, .story-hint, .next-chapter > span) { color: var(--muted-ink); }
:root[data-theme="light"] .chat-bubble { background: #fff; border-color: #dce6ec; box-shadow: 0 8px 23px #3850840a; }
:root[data-theme="light"] .chat-float:nth-child(3n + 2) .chat-bubble { background: #f7f5fe; border-color: #e4ddf3; }
:root[data-theme="light"] .chat-float:nth-child(3n) .chat-bubble { background: #f0f8f6; border-color: #d5e9e2; }
:root[data-theme="light"] :is(.chat-meta, .chat-float:nth-child(3n + 2) .chat-meta, .chat-float:nth-child(3n) .chat-meta, .chat-static-card .chat-meta) { color: #616e82; }
:root[data-theme="light"] .chat-text { color: #23324b; }
:root[data-theme="light"] .chat-avatar { background: #e1e8f3; }
:root[data-theme="light"] .chat-avatar.avatar-unavailable { background: #d1dceb; }
:root[data-theme="light"] .chat-static-card { background: #fff; border-color: #dae2ee; }
:root[data-theme="light"] .chat-source { border-top-color: var(--line); }
:root[data-theme="light"] :is(.chat-source summary, .chat-source summary span, .chat-source p, .chat-source > small, .chat-empty) { color: var(--muted-ink); }
:root[data-theme="light"] .chat-source blockquote { color: #263750; }
:root[data-theme="light"] .chat-source summary:hover,
:root[data-theme="light"] .chat-source[open] summary { color: var(--accent); }
:root[data-theme="light"] :is(.support-intro h1 span, .support-conversations h2 span) { color: #526681; }
:root[data-theme="light"] :is(.support-conversations .conversation-intro > p, .support-conversations .conversation-intro > .conversation-source-note, .support-thread-heading .chat-meta, .support-chat-copy > small, #support-chat-hint) { color: var(--muted-ink); }
:root[data-theme="light"] .support-thread-heading { border-bottom-color: var(--line); }
:root[data-theme="light"] .support-thread-heading h3 { color: var(--ink); }
:root[data-theme="light"] .support-chat-copy > p { background: #edf1f8; color: #273750; }
:root[data-theme="light"] .support-chat-line[data-role="support"] .support-chat-copy > p { background: #e8f4ee; color: #235b45; }
:root[data-theme="light"] .support-chat-line[data-role="support"] .support-chat-copy > small { color: #306d58; }
:root[data-theme="light"] .support-thread-dots button > span { background: #b8c4d7; }
:root[data-theme="light"] .support-thread-dots button:hover > span { background: #6e8bc0; }
:root[data-theme="light"] .support-thread-dots button:is([aria-current="true"], [aria-selected="true"], [aria-pressed="true"]) > span { background: var(--accent); }

/* Support, QR images, ordinary text and system feedback. */
:root[data-theme="light"] .support-teaser { border-top-color: var(--line); background: none; }
:root[data-theme="light"] .support-teaser-copy > p { color: var(--muted-ink); }
:root[data-theme="light"] :is(.support-teaser-copy strong, .support-path > p, .service-note p, .scan-help strong) { color: #344762; }
:root[data-theme="light"] .support-path { border-top-color: #bdc8d9; }
:root[data-theme="light"] .support-path li { border-bottom-color: var(--line); }
:root[data-theme="light"] .support-path small { color: var(--muted-ink); }
:root[data-theme="light"] .group-card { background: #f7f9fc; border-color: #e0e6ef; }
:root[data-theme="light"] .qr-open > span { background: #eef3fcee; color: #304563; }
:root[data-theme="light"] .group-tabs button { color: #52617a; background: #f6f8fb; border-color: #d4ddeb; }
:root[data-theme="light"] .group-tabs button[aria-selected="true"] { color: #214eaf; background: #eaf0ff; border-color: #96b0e5; }
:root[data-theme="light"] :is(.search-count, .template-panel > label, .template-panel > p) { color: var(--muted-ink); }
:root[data-theme="light"] .template-panel { background: #f5f7fb; border-color: #dbe3ef; }
:root[data-theme="light"] .copy-fallback { background: #f0f4fb; }
:root[data-theme="light"] :is(.copy-fallback textarea, #copy-text, #record-link-fallback) { background: #fff; border-color: #b9c6da; color: var(--ink); }
:root[data-theme="light"] :is(.toast, .site-toast) { background: #193358; color: #fff; border-color: transparent; box-shadow: 0 8px 24px #13294a2b; }
:root[data-theme="light"] .footer > p,
:root[data-theme="light"] .footer > div,
:root[data-theme="light"] .footer > small { color: var(--muted-ink); border-color: var(--line); }
:root[data-theme="light"] dialog { background: #fff; border-color: transparent; color: var(--ink); box-shadow: 0 28px 90px #25375435; }
:root[data-theme="light"] dialog::backdrop { background: #24324765; backdrop-filter: blur(8px); }
:root[data-theme="light"] .dialog-image-wrap { background: #f1f4f8; }
:root[data-theme="light"] .dialog-facts { background: #edf3ff; color: #4d607d; }
:root[data-theme="light"] :is(.dialog-category, .dialog-bottom > p, .dialog-paging > span) { color: var(--muted-ink); }
:root[data-theme="light"] .dialog-source { color: var(--muted-ink) !important; }
:root[data-theme="light"] .dialog-feedback { color: #285bcc !important; }

/* Existing tutorial route remains readable when shared as a deep link. */
:root[data-theme="light"] :is(.intro-note > span:last-child, .save-label, .step-counter, .reset-link, .step-note) { color: var(--muted-ink); }
:root[data-theme="light"] .route-choice { background: #fff; border-color: #d7deea; }
:root[data-theme="light"] .route-choice:hover { background: #f5f8fd; }
:root[data-theme="light"] .route-choice.selected { background: #edf3ff; border-color: #8ca9e3; }
:root[data-theme="light"] .route-choice.selected:after { background: var(--accent); }
:root[data-theme="light"] progress,
:root[data-theme="light"] progress::-webkit-progress-bar { background: #e5ebf5; }
:root[data-theme="light"] .step-nav-button:hover { background: #f2f5fa; }
:root[data-theme="light"] .step-nav-button.active { color: #214eaf; background: #eaf0ff; }
:root[data-theme="light"] .step-nav-num { color: #64738a; border-color: #bac7da; }
:root[data-theme="light"] .step-nav-button.active .step-nav-num { color: #285bcc; border-color: #7096df; }
:root[data-theme="light"] .step-content { background: #fff; border-color: #dee5ef; }
:root[data-theme="light"] .mobile-step-location { background: #f2f5fb; border-color: #d7e0ee; }
:root[data-theme="light"] .completion-symbol { border-color: #a0bded; }

@media (max-width: 1150px) {
  .theme-toggle { padding: 9px; }
  .theme-toggle > span { display: none; }
  .site-nav .nav-actions { gap: 10px; }
}
@media (max-width: 800px) {
  :root[data-theme="light"] .site-nav nav { background: #fffffff7; border-color: var(--line); box-shadow: 0 16px 26px #223b6412; }
}
@media (max-width: 760px) {
  .header-inner { gap: 10px; }
  .header-inner > .theme-toggle { margin-left: auto; }
  .header-inner > .menu-toggle { flex-shrink: 0; }
  :root[data-theme="light"] #top-nav { background: #fffffff7; border-color: var(--line); }
}
@media (max-width: 540px) {
  .site-nav .nav-actions { gap: 4px; }
  .site-nav { gap: 9px; }
  .theme-toggle { min-width: 40px; padding: 9px; }
  :root[data-theme="light"] .hero-panel { background: #ffffffeb; box-shadow: 0 18px 46px -18px #586f9c36; }
}
@media print { .theme-toggle { display: none !important; } }
