:root { color-scheme: light; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #151716;
  --ink: #f1f2ed;
  --muted: #bdc3bb;
  --line: #363d36;
  --surface: #222822;
  --accent: #c3ddc8;
}

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  flex: none;
  background: none;
  color: var(--ink);
  cursor: pointer;
}
.theme-toggle[hidden], .analytics-settings[hidden], .analytics-panel[hidden] { display: none; }
.theme-toggle span {
  width: 17px;
  height: 17px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  background: linear-gradient(90deg, currentColor 50%, transparent 50%);
}
.theme-toggle[aria-pressed="true"] span { background: linear-gradient(270deg, currentColor 50%, transparent 50%); }
.theme-toggle:hover { background: var(--surface); }
.theme-toggle:focus-visible { outline: 2px solid currentColor; outline-offset: -3px; }

.platform-credits { margin-top: 8px; color: var(--muted); font-size: .8125rem; }
.platform-credits summary {
  width: fit-content;
  padding-block: 11px;
  cursor: pointer;
}
.platform-credits p { max-width: 80ch; margin-bottom: .35em; }
.platform-credits a { text-decoration: underline; text-underline-offset: .18em; }
.platform-credits :is(summary, a):focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

[data-theme="dark"] :is(.header, .footer, .intro-stage) { background: var(--paper); }
[data-theme="dark"] .studio-opening .intro-stage { background: var(--paper); }
[data-theme="dark"] :is(.brand-mascot, .intro-portrait img) {
  box-sizing: border-box;
  background: #f7f6f2;
  border-radius: 50%;
  object-fit: contain;
}
[data-theme="dark"] .brand-mascot { padding: 2px; }
[data-theme="dark"] .intro-portrait img { padding: 6%; }
[data-theme="dark"] .studio-opening .intro-wordmark { color: var(--ink); }
[data-theme="dark"] .button.primary { background: var(--accent); color: #15251b; border-color: var(--accent); }
[data-theme="dark"] .button.primary:hover { background: #d4ead8; border-color: #d4ead8; }
[data-theme="dark"] .skip { background: var(--ink); color: var(--paper); }
[data-theme="dark"] .project-status { color: var(--muted); }
[data-theme="dark"] .tempi { color: var(--ink); }
[data-theme="dark"] :is(.tempi-app,.tempi-info) { border-color: var(--line); }
[data-theme="dark"] .tempi-story { background: var(--surface); }
[data-theme="dark"] :is(.tempi-identity p,.tempi-copy p,.tempi-facts p,.tempi-info small) { color: var(--muted); }
[data-theme="dark"] .tempi-info a { color: #98c9ff; }
[data-theme="dark"] :is(.protected-cover, .coming-art) { background: var(--surface); }
[data-theme="dark"] :is(.coming-message, .coming-message span) { color: var(--ink); }

.analytics-settings {
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: .2em;
  cursor: pointer;
}
.analytics-panel {
  position: fixed;
  z-index: 16;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  width: min(420px, calc(100% - 32px));
  padding: 18px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 10px 38px #0003;
}
.analytics-panel p { margin: 0; color: var(--ink); font-size: .925rem; }
.analytics-panel a { text-decoration: underline; }
.analytics-panel > div { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.analytics-panel button {
  flex: 1;
  min-height: 44px;
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.analytics-panel button:hover { border-color: var(--ink); }

@media (max-width: 420px) {
  .header .nav-links { gap: 6px; }
  .theme-toggle { margin-left: -3px; margin-right: -6px; }
}
