/* Shared colors respond to the preference resolved before the first paint. */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #edf4f9;
  --panel: #fff;
  --ink: #102238;
  --muted: #4f647a;
  --cyan: #0b5cc2;
  --lime: #147647;
  --line: #d4e0eb;
  --brand-hover: #084b9f;
  --theme-header: #fffffffa;
  --theme-shell: #e6f1f8;
  --theme-surface: #f4f8fc;
  --theme-soft: #e2edf8;
  --theme-control: #fff;
  --theme-button: #155acb;
  --theme-button-ink: #fff;
  --theme-button-hover: #104ba9;
  --theme-shadow: 0 12px 30px #183a6012;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #07131e;
  --panel: #102331;
  --ink: #edf6fc;
  --muted: #afc2d2;
  --cyan: #73ccff;
  --lime: #74dbac;
  --line: #294555;
  --brand-hover: #a1e1ff;
  --theme-header: #071824fa;
  --theme-shell: #061724;
  --theme-surface: #142c3c;
  --theme-soft: #17384c;
  --theme-control: #0b1c29;
  --theme-button: #31d8ce;
  --theme-button-ink: #03252b;
  --theme-button-hover: #83eee5;
  --theme-shadow: 0 14px 32px #0003;
}
:root[data-theme] body:not(.legal-doc) { background: var(--bg); color: var(--ink); }

/* These controls also work on legal pages, which keep their own document layout. */
.theme-toggle {
  display: inline-grid;
  place-items: center;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  min-width: 40px;
  padding: 0;
  border: 1px solid var(--line, #d4e0eb);
  border-radius: 50%;
  background: var(--panel, #fff);
  color: var(--ink, #102238);
  cursor: pointer;
  line-height: 1;
  box-shadow: none;
  transition: background .18s ease, border-color .18s ease;
}
.theme-toggle:hover { background: var(--theme-soft, #e2edf8); border-color: var(--cyan, #0b5cc2); }
.theme-toggle:focus-visible { outline: 2px solid var(--cyan, #0b5cc2); outline-offset: 3px; }
.theme-toggle svg { display: block; width: 20px; height: 20px; pointer-events: none; }
.theme-toggle .theme-icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .theme-icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .theme-icon-moon { display: none; }
.theme-toggle[hidden] { display: none; }
.header .theme-toggle { order: 2; }
.legal-doc .theme-toggle { font: inherit; align-self: center; }
.legal-doc .topbar-in { column-gap: 10px; }

/* Navigation and controls use the same palette on every product page. */
:root[data-theme] .header {
  color: var(--ink);
  background: var(--theme-header);
  border-bottom-color: var(--line);
}
:root[data-theme] .header .brand { color: var(--ink); }
:root[data-theme] .header .brand-dot { color: var(--cyan); }
:root[data-theme] .header :is(nav a, .link-button) { color: var(--muted); }
:root[data-theme] .header :is(nav a, .link-button):hover { color: var(--ink); }
:root[data-theme] .header #navigation > [aria-current="page"] { color: var(--cyan); }
:root[data-theme] .header #navigation > [aria-current="page"]::after { background: var(--cyan); }
:root[data-theme] .header .language-picker > summary {
  background: var(--panel);
  color: var(--ink);
  border-color: var(--line);
}
:root[data-theme] .language-options { background: var(--panel); border-color: var(--line); box-shadow: var(--theme-shadow); }
:root[data-theme] .language-options button { background: transparent; color: var(--ink); }
:root[data-theme] .language-options button:hover,
:root[data-theme] .language-options button[aria-pressed="true"] { background: var(--theme-soft); border-color: var(--cyan); }
:root[data-theme] .header .menu-toggle { color: var(--ink); }
:root[data-theme] .header .menu-toggle span { background: var(--ink); }
:root[data-theme] .landing .button,
:root[data-theme] .launch-actions .button,
:root[data-theme] .page-mod .mod-download-card .button {
  background: var(--theme-button);
  color: var(--theme-button-ink);
  border-color: var(--theme-button);
  box-shadow: none;
}
:root[data-theme] .landing .button:hover,
:root[data-theme] .launch-actions .button:hover,
:root[data-theme] .page-mod .mod-download-card .button:hover {
  background: var(--theme-button-hover);
  color: var(--theme-button-ink);
  border-color: var(--theme-button-hover);
}
:root[data-theme] :is(.landing, .download-launch-layout) .button.secondary {
  background: var(--theme-surface);
  color: var(--ink);
  border-color: var(--line);
}
:root[data-theme] :is(.landing, .download-launch-layout) .button.secondary:hover { background: var(--theme-soft); border-color: var(--cyan); }

/* Light mode changes the page surfaces while preserving the original artwork. */
:root[data-theme="light"] .home .hero-shell,
:root[data-theme="light"] .page-sub .page-head,
:root[data-theme="light"] .page-mod .mod-band {
  background: var(--theme-shell);
  color: var(--ink);
}
:root[data-theme="light"] .home #overview.hero h1,
:root[data-theme="light"] .page-sub .page-head h1,
:root[data-theme="light"] .mod-copy h1,
:root[data-theme="light"] .mod-copy .mod-version { color: var(--ink); }
:root[data-theme="light"] .home #overview .hero-description,
:root[data-theme="light"] .page-sub .page-lead,
:root[data-theme="light"] .mod-copy > p,
:root[data-theme="light"] .hero-brands { color: var(--muted); }
:root[data-theme="light"] .home #overview .pill { background: #d7eaf6; color: #075a72; border-color: #b8d7e9; }
:root[data-theme="light"] .home #overview .pill .times { color: #456a81; }
:root[data-theme="light"] .home #overview .hero-actions .button {
  background: var(--theme-button);
  border-color: var(--theme-button);
  color: var(--theme-button-ink);
  box-shadow: 0 7px 20px #155acb20;
}
:root[data-theme="light"] .home #overview .hero-actions .button:hover { background: var(--theme-button-hover); border-color: var(--theme-button-hover); }
:root[data-theme="light"] .home #overview .hero-actions .hero-mod-button { color: #134d86; background: #ffffffa6; border-color: #91b5d0; box-shadow: none; }
:root[data-theme="light"] .home #overview .hero-actions .hero-mod-button:hover { background: #fff; border-color: var(--cyan); }
:root[data-theme="light"] .home .hero-support { color: #315d7b; }
:root[data-theme="light"] .hero-compatibility { border-top-color: #bdd3e2; }
:root[data-theme="light"] .hero-compatibility .proof-line { color: var(--ink); }
:root[data-theme="light"] .hero-art-button { background: #061724; border: 1px solid #d0e0eb; box-shadow: 0 16px 34px #0b294526; overflow: hidden; }
:root[data-theme="light"] .hero-art-image { mask-image: none; border-radius: 21px; }
:root[data-theme="light"] .page-sub .page-head .eyebrow,
:root[data-theme="light"] :is(.mod-kicker, .mod-guide-link) { color: #0b5c9f; }
:root[data-theme="light"] .mod-download-card { background: var(--panel); border-color: var(--line); box-shadow: var(--theme-shadow); }

/* Dark mode covers the entire experience, including data and download panels. */
:root[data-theme="dark"] .home .hero-shell,
:root[data-theme="dark"] .page-sub .page-head,
:root[data-theme="dark"] .page-mod .mod-band { background: var(--theme-shell); }
:root[data-theme="dark"] :is(.tile, .model-card, .pain-card, .app-platforms article, .community-card, .community-links a, .signup-card, .telegram-card, .download-status, .mod-download-card, .launch-card) {
  background: var(--panel);
  color: var(--ink);
  border-color: var(--line);
  box-shadow: none;
}
:root[data-theme="dark"] .home :is(.tile-community, .tile-faq) { background: transparent; }
:root[data-theme="dark"] :is(.updates, .signup-section) { background: #0b1c29; border-color: var(--line); }
:root[data-theme="dark"] .trial-layout { background: var(--panel); border-color: var(--line); }
:root[data-theme="dark"] :is(.trial-main, .trial-side) { background: transparent; border-color: var(--line); }
:root[data-theme="dark"] .home .tile-launch { background: #122e47; border-color: #294d66; }
:root[data-theme="dark"] .feature-screen { background: #19364b; }
:root[data-theme="dark"] .feature-tile:nth-of-type(2) .feature-screen { background: #173e3d; }
:root[data-theme="dark"] .feature-tile:nth-of-type(3) .feature-screen { background: #302d4d; }
:root[data-theme="dark"] :is(.community-icon, .community-links .community-icon) { color: var(--cyan); background: var(--theme-soft); border-color: var(--line); }
:root[data-theme="dark"] :is(.feature-tabs, .feature-tabs button, .update-grid, .update-card, .install-steps li, .platform-guide, .faq-list, .faq-list details, .footer, .footer-bottom, .download-legal, .mod-checksum, .mod-help) { border-color: var(--line); }
:root[data-theme="dark"] :is(.caption, .feature-condition, .feature-detail > p, .pain-card p, .update-card > p, .update-note, .app-copy > p, .install-steps p, .trial-layout p, .signup-copy > p, .platform-guide > summary, .community-card p, .faq-list details > p, .model-card p, .model-brand, .model-features li, .mod-filename, .mod-checksum summary, .mod-checksum code, .mod-steps p, .mod-help, .download-heading > p) { color: var(--muted); }
:root[data-theme="dark"] :is(.feature-tabs button, .footer-top > div, .footer-top > p, .footer-bottom > span, .field label, .signup-field > label, .quick-name small, .quick-examples, .quick-count) { color: var(--muted); }
:root[data-theme="dark"] .feature-tabs [aria-selected="true"] { color: var(--cyan); }
:root[data-theme="dark"] :is(.link-button, .inline-link, .tile-link, .mod-help a, .mod-guide-link, .app-platforms small) { color: var(--cyan); }
:root[data-theme="dark"] :is(.feature-detail .eyebrow, .update-icon, .update-card:nth-child(3) .update-icon) { color: var(--cyan); }
:root[data-theme="dark"] .compat-note { color: var(--muted) !important; }
:root[data-theme="dark"] :is(.quick-field input, .field input, .field select, .signup-field input, .signup-field select, textarea) {
  background: var(--theme-control);
  color: var(--ink);
  border-color: #3d5b70;
}
:root[data-theme="dark"] :is(input, textarea)::placeholder { color: #95adbf; opacity: 1; }
:root[data-theme="dark"] .quick-field input:focus-visible { background: #102b3d; }
:root[data-theme="dark"] .search-icon { color: #9cb7cd; }
:root[data-theme="dark"] :is(.chip, .phone-switch button) { background: var(--theme-surface); color: var(--ink); border-color: var(--line); }
:root[data-theme="dark"] :is(.chip, .phone-switch button):hover,
:root[data-theme="dark"] .phone-switch button[aria-pressed="true"] { background: var(--theme-soft); border-color: var(--cyan); color: var(--cyan); }
:root[data-theme="dark"] .quick-item { background: var(--theme-control); border-color: var(--line); }
:root[data-theme="dark"] .model-type { background: #123a50; border-color: #2e5771; color: #a1dcff; }
:root[data-theme="dark"] .trial-label { background: #15392f; color: var(--lime); border-color: #2a5a48; }
:root[data-theme="dark"] :is(.quick-feats [data-state="ok"] .feature-icon, .model-features [data-state="ok"] .feature-icon, .mx-cell[data-state="ok"] .feature-icon, .compat-legend [data-state="ok"]) { background: #184234; color: #92e7b9; }
:root[data-theme="dark"] :is(.quick-feats [data-state="partial"] .feature-icon, .model-features [data-state="partial"] .feature-icon, .mx-cell[data-state="partial"] .feature-icon, .compat-legend [data-state="partial"]) { background: #193e59; color: #9cdbff; }
:root[data-theme="dark"] :is(.quick-feats [data-state="no"] .feature-icon, .model-features [data-state="no"] .feature-icon, .mx-cell[data-state="no"] .feature-icon, .compat-legend [data-state="no"]) { background: #4a2832; color: #ffb4b4; }
:root[data-theme="dark"] .matrix-scroll { background: var(--panel); border-color: var(--line); }
:root[data-theme="dark"] .matrix :is(th, td) { border-color: var(--line); }
:root[data-theme="dark"] .matrix thead th { background: var(--theme-surface); color: var(--ink); }
:root[data-theme="dark"] .matrix th small,
:root[data-theme="dark"] .matrix td::before { color: var(--muted); }
:root[data-theme="dark"] .mod-download-card h2 { color: var(--ink); }
:root[data-theme="dark"] :is(.mod-file-icon, .mod-file-meta span),
:root[data-theme="dark"] .mod-steps li::before { background: var(--theme-soft); color: var(--cyan); }
:root[data-theme="dark"] .mod-download-card { box-shadow: var(--theme-shadow); }
:root[data-theme="dark"] .launch-card :is(.countdown-unit, .launch-date) { border-color: var(--line); }
:root[data-theme="dark"] .launch-card .countdown-unit { background: var(--theme-control); }
:root[data-theme="dark"] .launch-card :is(.countdown-value, .launch-date time) { color: var(--ink); }
:root[data-theme="dark"] .launch-card :is(.countdown-label, .launch-status, .launch-noscript, .launch-date) { color: var(--muted); }
:root[data-theme="dark"] .launch-card-kicker { color: var(--cyan); }
:root[data-theme="dark"] :is(dialog, .photo-dialog) { color: var(--ink); background: var(--panel); border-color: var(--line); }
:root[data-theme="dark"] dialog::backdrop { background: #02090fbb; }
:root[data-theme="dark"] .photo-dialog .dialog-close { color: var(--ink); background: var(--panel); border-color: #526d80; }

/* Fit the extra control without shrinking the theme button or crowding the menu. */
@media (min-width: 851px) and (max-width: 1000px) {
  :root[data-theme] .landing .header .container { padding-inline: 24px; }
  :root[data-theme] .landing .header .nav-wrap { gap: 12px; }
  :root[data-theme] .landing .header .brand { font-size: 1.2rem; gap: 8px; }
  :root[data-theme] .landing .header .brand img { width: 32px; height: 32px; }
  :root[data-theme] .landing .header #navigation { gap: 12px; }
  :root[data-theme] .landing .header #navigation a { font-size: .8125rem; }
  :root[data-theme] .landing .header .language-picker { margin-left: auto; }
}
@media (max-width: 850px) {
  :root[data-theme] .header .nav-wrap { column-gap: 12px; }
  :root[data-theme] .header .language-picker { margin-left: auto; }
  :root[data-theme] .page-sub .header .mobile-signup-cta,
  :root[data-theme] .header .mobile-signup-cta { display: none; }
  :root[data-theme] .header #navigation,
  :root[data-theme] .header #navigation.open {
    background: var(--panel);
    color: var(--ink);
    border-color: var(--line);
    box-shadow: var(--theme-shadow);
  }
  :root[data-theme] .header #navigation a { color: var(--muted); }
  :root[data-theme] .header #navigation > [aria-current="page"] { color: var(--cyan); }
  :root[data-theme="dark"] .matrix tbody tr { background: var(--panel); border-color: var(--line); }
  :root[data-theme="dark"] .matrix tbody th { background: var(--theme-surface); }
}
@media (max-width: 380px) {
  :root[data-theme] .header .nav-wrap { column-gap: 7px; }
  :root[data-theme] .header .brand { font-size: 1.125rem; gap: 7px; }
  :root[data-theme] .header .brand img { width: 28px; height: 28px; }
  :root[data-theme] .header .language-picker > summary { min-width: 54px; padding: 8px 6px; }
  :root[data-theme] .header .menu-toggle { width: 36px; height: 40px; padding: 8px; }
  .legal-doc .topbar-in { column-gap: 8px; }
  .legal-doc .lang a { padding-inline: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .theme-toggle { transition: none; }
}

/* 30/11/2026: CH Play install buttons keep their emphasis in both palettes. */
:root[data-theme="light"] .home #overview .hero-actions .hero-check-button { color: #134d86; background: #ffffffa6; border-color: #91b5d0; box-shadow: none; }
:root[data-theme="light"] .home #overview .hero-actions .hero-check-button:hover { background: #fff; border-color: var(--cyan); }
:root[data-theme] .home .tile-install .play-button { background: #2bdcd0; color: #04252b; border-color: #2bdcd0; }
:root[data-theme] .home .tile-install .play-button:hover { background: #78efe5; color: #04252b; border-color: #78efe5; }
:root[data-theme="dark"] .install-card-steps li::before { background: var(--theme-soft); color: var(--cyan); }
