/* Shared website palette. Screenshots, demo interiors and games retain their
   own colors; no whole-page/image inversion. */
:root {
  color-scheme: light;
  --theme-bg: #ffffff;
  --theme-surface: #f7f7f6;
  --theme-raised: #ffffff;
  --theme-hover: #eef0ee;
  --theme-ink: #111311;
  --theme-text: #363a37;
  --theme-muted: #626863;
  --theme-line: #d9dcda;
  --theme-control: #a5aaa6;
  --theme-accent: #299447;
  --theme-heart: #df1f2d;
  --theme-logo: none;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --theme-bg: #151816;
  --theme-surface: #1e2320;
  --theme-raised: #1a1f1c;
  --theme-hover: #2c342e;
  --theme-ink: #eff3ee;
  --theme-text: #d0d8d1;
  --theme-muted: #a7b3aa;
  --theme-line: #3a443d;
  --theme-control: #77867b;
  --theme-accent: #85d49b;
  --theme-heart: #ff7e87;
  --theme-logo: invert(1);
}

:root[data-theme="colorful"] {
  color-scheme: light;
  --theme-bg: #fff8f1;
  --theme-surface: #f2edff;
  --theme-raised: #fffdf9;
  --theme-hover: #e8dff8;
  --theme-ink: #282239;
  --theme-text: #474052;
  --theme-muted: #686074;
  --theme-line: #d9cee4;
  --theme-control: #9785ad;
  --theme-accent: #7045a5;
  --theme-heart: #b8375b;
  --theme-logo: none;
}

/* A usable system theme also works when scripts/storage are unavailable. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --theme-bg: #151816;
    --theme-surface: #1e2320;
    --theme-raised: #1a1f1c;
    --theme-hover: #2c342e;
    --theme-ink: #eff3ee;
    --theme-text: #d0d8d1;
    --theme-muted: #a7b3aa;
    --theme-line: #3a443d;
    --theme-control: #77867b;
    --theme-accent: #85d49b;
    --theme-heart: #ff7e87;
    --theme-logo: invert(1);
  }
}

:root body {
  --ink: var(--theme-ink);
  --muted: var(--theme-muted);
  --line: var(--theme-line);
  --soft: var(--theme-surface);
  --black: var(--theme-ink);
  --white: var(--theme-bg);
  --card-border: var(--theme-line);
  --control-border: var(--theme-control);
  --inner-border: var(--theme-line);
  --help-bg: var(--theme-bg);
  --help-surface: var(--theme-surface);
  --help-surface-strong: var(--theme-hover);
  --help-ink: var(--theme-ink);
  --help-text: var(--theme-text);
  --help-muted: var(--theme-muted);
  --help-line: var(--theme-line);
  --help-line-strong: var(--theme-control);
  --help-heart: var(--theme-heart);
  color: var(--theme-ink);
  background: var(--theme-bg);
}

:root body .site-header,
:root body .help-header,
:root body .site-footer,
:root body .help-footer {
  color: var(--theme-muted);
  border-color: var(--theme-line);
  background: var(--theme-bg);
}
:root:root body .brand,
:root body :is(.brand-path [aria-current="page"]),
:root:root body .footer-brand { color: var(--theme-ink); }
:root body:is(body) .nav,
:root :where(body) a:is(.brand-path a),
:root body:is(body) .brand-separator { color: var(--theme-muted); }
:root body .language-switcher a { color: var(--theme-muted); }
:root body .language-switcher a[aria-current="page"] { color: var(--theme-ink); }
:root :where(body) a:is(.nav a):hover,
:root :where(body) a:is(.nav a):focus-visible,
:root :where(body) a:is(.nav a)[aria-current],
:root :where(body) a:is(.brand-path a):hover,
:root :where(body) a:is(.brand-path a):focus-visible,
:root :where(body) a:is(.brand-path a)[aria-current],
:root :where(body) a:is(.site-footer a):hover,
:root :where(body) a:is(.site-footer a):focus-visible,
:root :where(body) a:is(.site-footer a)[aria-current] { color: var(--theme-ink); }
:root body .site-header,
:root body .header-inner { column-gap: 16px; }

.theme-picker { position: relative; flex: 0 0 44px; width: 44px; height: 44px; }
.theme-picker[hidden] { display: none; }
.theme-toggle {
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--theme-line);
  border-radius: 12px;
  background: var(--theme-bg);
  color: var(--theme-ink);
  cursor: pointer;
}
.theme-toggle[hidden] { display: none; }
.theme-toggle:hover { border-color: var(--theme-control); background: var(--theme-hover); }
:root body :focus-visible { outline-color: var(--theme-accent); }
.theme-toggle:focus-visible { outline: 3px solid var(--theme-accent); outline-offset: 3px; }
.theme-toggle .theme-icon { display: none; }
[data-theme="light"] .theme-toggle .theme-icon-light,
[data-theme="dark"] .theme-toggle .theme-icon-dark,
[data-theme="colorful"] .theme-toggle .theme-icon-colorful { display: block; }
.theme-chevron { position: absolute; bottom: 3px; right: 3px; }
.theme-menu {
  position: fixed;
  inset: auto;
  margin: 0;
  width: 216px;
  max-width: calc(100vw - 16px);
  max-height: calc(100dvh - 16px);
  overflow: auto;
  box-sizing: border-box;
  padding: 8px;
  border: 1px solid var(--theme-control);
  border-radius: 16px;
  background: var(--theme-raised);
  color: var(--theme-ink);
  box-shadow: 0 12px 36px #15102124;
  font: 14px/1.4 system-ui, sans-serif;
}
.theme-menu-title { margin: 4px 8px 6px; color: var(--theme-muted); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
:root body .theme-option {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px;
  padding: 7px 9px; border: 1px solid transparent; border-radius: 9px;
  background: transparent; color: var(--theme-ink); font: inherit; text-align: left; cursor: pointer;
}
:root body .theme-option[aria-checked="true"] { background: var(--theme-surface); font-weight: 750; }
:root body .theme-option:hover,
:root body .theme-option:focus-visible { background: var(--theme-hover); border-color: var(--theme-control); color: var(--theme-ink); }
.theme-option:focus-visible { outline: 2px solid var(--theme-accent); outline-offset: -2px; }
.theme-swatch { display: grid; place-items: center; width: 28px; height: 28px; border: 1px solid #b7b0bd; border-radius: 9px; }
.theme-swatch-light { background: #fff; color: #37323f; }
.theme-swatch-dark { background: #202622; color: #f0f4eb; }
.theme-swatch-colorful { background: linear-gradient(135deg, #f3dcff, #d6efe5 55%, #ffe2c7); color: #583d7e; }
.theme-swatch .theme-icon { width: 18px; height: 18px; }
.theme-check { margin-left: auto; opacity: 0; color: var(--theme-accent); }
[aria-checked="true"] > .theme-check { opacity: 1; }
.theme-error-control { position: absolute; top: 16px; right: 22px; }
:root body.theme-error p { color: var(--theme-muted); }
:root body.theme-error nav a { color: var(--theme-ink); border-color: var(--theme-control); }
:root body.theme-error nav a:first-child { color: var(--theme-bg); background: var(--theme-ink); }
:root body.theme-lab { --bg: var(--theme-bg); --paper: var(--theme-raised); --red: var(--theme-heart); }
:root body.theme-lab .panel,
:root body.theme-lab .side,
:root body.theme-lab .library,
:root body.theme-lab .tag,
:root body.theme-lab .btn,
:root body.theme-lab .toggle,
:root body.theme-lab .chip,
:root body.theme-lab .loading-card {
  background: var(--theme-raised); color: var(--theme-ink); border-color: var(--theme-line);
}
:root body.theme-lab .arena-head,
:root body.theme-lab .quality-note,
:root body.theme-lab .metric,
:root body.theme-lab .now,
:root body.theme-lab .kbd { background: var(--theme-surface); color: var(--theme-ink); }
:root body:is(body).theme-lab .lead,
:root body:is(body).theme-lab .small,
:root body:is(body).theme-lab .audit,
:root body:is(body).theme-lab .footer,
:root :where(body).theme-lab p:is(.library-title p),
:root :where(body).theme-lab span:is(.metric span),
:root :where(body).theme-lab small:is(.now small),
:root :where(body).theme-lab em:is(.group-head em),
:root body:is(body).theme-lab .fps,
:root body:is(body).theme-lab .loading-sub,
:root body:is(body).theme-lab .brand-sub { color: var(--theme-muted); }
:root body.theme-lab .btn.primary,
:root body.theme-lab .btn.active,
:root body.theme-lab .toggle.on,
:root body.theme-lab .chip.selected { background: var(--theme-ink); color: var(--theme-bg); }
:root body.theme-lab .chip .num { color: var(--theme-muted); }
:root body.theme-lab .chip.seen .num { color: var(--theme-heart); }
:root body.theme-lab .chip.selected .num,
:root body.theme-lab .chip:hover .num,
:root body.theme-lab .chip:focus-visible .num { color: inherit; }
:root body.theme-lab .canvas-hint { color: #626863; }
:root body.theme-lab .btn:hover,
:root body.theme-lab .toggle:hover,
:root body.theme-lab .chip:hover { background: var(--theme-hover); color: var(--theme-ink); border-color: var(--theme-control); }

/* Shared marks are monochrome; product logos and captured UI stay native. */
:root body img[src*="first-step.svg"],
:root body .footer-brand::before { filter: var(--theme-logo); }

:root body .family-card,
:root body .product-panel,
:root body .product,
:root body .tools-preview,
:root body .tool-mark,
:root body .product-visual {
  border-color: var(--theme-line);
  background: var(--theme-raised);
}
:root body:is(body) .card-top,
:root body:is(body) .panel-top,
:root body:is(body) .principle,
:root :where(body) article:is(.features article),
:root :where(body) section:is(.trust-grid section),
:root body:is(body) .works-row,
:root body:is(body) .limit-card,
:root body:is(body) .note-preview,
:root body:is(body) .product-notes-group,
:root :where(body) article:is(.support-grid article),
:root :where(body) article:is(.page article),
:root body:is(body) .release-callout,
:root body:is(body) .help-callout,
:root body:is(body) .markdown-example {
  border-color: var(--theme-line);
  background: var(--theme-surface);
}
:root body:is(body) .section,
:root body:is(body) .products,
:root body:is(body) .faq-list,
:root :where(body) details:is(.faq-list details),
:root body:is(body) .contact,
:root :where(body) li:is(.family-list li),
:root body:is(body) .tool-family-item,
:root body:is(body) .tools-item,
:root body:is(body) .product-visual,
:root body:is(body) .notes-group,
:root body:is(body) .release-line,
:root body:is(body) .note-card,
:root body:is(body) .note-entry { border-color: var(--theme-line); }
:root :where(body) article:is(.features article):hover,
:root :where(body) article:is(.features article):focus-within,
:root :where(body) section:is(.trust-grid section):hover,
:root :where(body) section:is(.trust-grid section):focus-within,
:root body:is(body) .works-row:hover,
:root body:is(body) .works-row:focus-within,
:root body:is(body) .limit-card:hover,
:root body:is(body) .limit-card:focus-within,
:root body:is(body) .principle:hover,
:root body:is(body) .principle:focus-within {
  border-color: var(--theme-control);
}
:root:root :where(body) p.hero-copy,
:root:root body .lede,
:root:root body .eyebrow,
:root:root body .note-meta,
:root:root body .patch-title,
:root:root body .patch-date,
:root:root body .status,
:root:root body .tool-state,
:root:root body .tool-description,
:root:root :where(body) small:is(.tool-family-item :where(small)),
:root:root body .tool-family-state,
:root:root :where(body) span:is(.family-list :where(span)),
:root:root :where(body) p:is(.features :where(p)),
:root:root :where(body) p:is(.trust-grid :where(p)),
:root:root :where(body) p:is(.works-row :where(p)),
:root:root :where(body) p:is(.limit-card :where(p)),
:root:root body .workflow-choices,
:root:root body .overview-capture-provenance,
:root body :is(.help-contents .toc-title),
:root:root:root :where(body) figcaption:is(:where(figure) :where(figcaption)) { color: var(--theme-muted); }
:root:root body:is(body) .release-callout,
:root:root body:is(body) .workflow-note,
:root :where(body) p:is(.help-article .section-heading p),
:root :where(body) p:is(.help-article .help-section > p),
:root :where(body) p:is(.help-article .candidate-guide > p),
:root:root body:is(body) .markdown-example { color: var(--theme-text); }
:root body:is(body) .release-label,
:root :where(body) strong:is(.workflow-choices strong),
:root body:is(body) .patch-version,
:root body .task-matrix td::before { color: var(--theme-ink); }
:root body .aiblock-release-visual figcaption a,
:root body .aiblock-release-preview figcaption a { color: var(--theme-ink); }
:root body .first-run-steps li > span,
:root body .action-demo[data-state="before"] [data-phase="before"],
:root body .action-demo[data-state="acting"] [data-phase="acting"],
:root body .action-demo[data-state="after"] [data-phase="after"] { color: var(--theme-bg); background: var(--theme-ink); }
:root body .heart { color: var(--theme-heart); }

:root body .button,
:root body .note-link {
  border-color: var(--theme-control);
  color: var(--theme-ink);
  background: var(--theme-bg);
}
:root body .button:hover,
:root body .button:focus-visible,
:root body .note-link:hover,
:root body .note-link:focus-visible {
  color: var(--theme-ink);
  border-color: var(--theme-ink);
  background: var(--theme-hover);
}
:root body .button.primary,
:root:root body .header-action,
:root:root body .skip-link {
  color: var(--theme-bg);
  border-color: var(--theme-ink);
  background: var(--theme-ink);
}
:root body .button.primary:hover,
:root body .button.primary:focus-visible,
:root:root body .header-action:hover,
:root:root body .header-action:focus-visible {
  color: var(--theme-bg);
  background: var(--theme-text);
}
:root :where(body) span:is(.trust-row span),
:root :where(body) span:is(.trust-line span),
:root :where(body) span:is(.chips > span) {
  color: var(--theme-muted);
  border-color: var(--theme-line);
  background: var(--theme-bg);
}
:root :where(body) span:is(.trust-row span):hover,
:root :where(body) span:is(.trust-line span):hover,
:root :where(body) span:is(.chips > span):hover {
  color: var(--theme-ink);
  border-color: var(--theme-control);
  background: var(--theme-hover);
}
:root body .status::before,
:root body .tool-state::before { background: var(--theme-ink); }
:root body .help-contents,
:root body .help-toc-mobile { border-color: var(--theme-line); background: var(--theme-bg); }
:root body .help-contents a { color: var(--theme-muted); }
:root body .help-contents a:hover,
:root body .help-contents a:focus-visible,
:root body .help-contents a[aria-current] {
  color: var(--theme-ink);
  border-left-color: var(--theme-ink);
  background: var(--theme-surface);
}
:root body .task-matrix tbody tr { border-color: var(--theme-line); }
@media (max-width: 600px) {
  :root body .task-matrix tbody tr { background: var(--theme-surface); }
}

/* The narrow utility column must not cover the static FAQ title when footer
   clearance moves it upwards. Text can wrap without changing dock behavior. */
@media (max-width:600px) {
  :root body #faq .section-heading h2 { padding-inline-end:64px; }
}

/* Illustrated browser/extension examples remain readable light UI. */
:root body .demo-browser,
:root body .real-ui-stage,
:root body .context-workspace {
  color-scheme: light;
  --help-bg: #ffffff;
  --help-surface: #f7f7f6;
  --help-surface-strong: #eeeeec;
  --help-ink: #111311;
  --help-text: #363a37;
  --help-muted: #626863;
  --help-line: #d9dcda;
  --help-line-strong: #9da39e;
  --black: #111311;
  --white: #ffffff;
  color: #111311;
}
:root body .context-workspace { background: #ffffff; --inner-border: #d9dcda; }

/* Break Time uses the same palette and retains the underlying page view. */
:root body .ta-play { color: var(--theme-ink); background: var(--theme-surface); }
:root body .ta-play__header,
:root body .ta-play__status { background: var(--theme-bg); border-color: var(--theme-line); }
:root body .ta-play__header button,
:root body .ta-play__header select,
:root body .ta-play__status button {
  color: var(--theme-ink);
  background: var(--theme-surface);
  border-color: var(--theme-control);
}
:root body .ta-play__games button[aria-pressed="true"] {
  color: var(--theme-bg);
  background: var(--theme-ink);
}
:root body .ta-play__header button:not(:disabled):hover { color: var(--theme-ink); background: var(--theme-hover); }
:root body .ta-play[data-state="playing"][data-presentation="transparent"] { background: transparent; }
:root[data-theme][data-ta-play-open] body > header { background: var(--theme-bg); }
:root body .ta-play[data-multi-game] .ta-play__header { grid-template-columns: auto minmax(0, 1fr) 44px auto auto; }
:root body .ta-play[data-multi-game] .ta-play__theme { grid-column: 3; grid-row: 1; }
:root body .ta-play[data-multi-game] .ta-play__browse { grid-column: 4; grid-row: 1; }
:root body .ta-play[data-multi-game] .ta-play__close { grid-column: 5; grid-row: 1; }
:root body .ta-page-actions button,
:root body .ta-page-actions a,
:root body .ta-play-launch-status {
  background: var(--theme-raised);
  color: var(--theme-ink);
  border-color: var(--theme-control);
}
:root body .ta-page-actions button:hover,
:root body .ta-page-actions a:hover { background: var(--theme-hover); }
:root body .ta-page-actions .ta-play-launch { background: var(--theme-ink); color: var(--theme-bg); }
:root body .ta-play-launch[data-resume] { box-shadow: 0 0 0 2px var(--theme-bg), 0 0 0 4px var(--theme-accent); }
@media (max-width: 600px) {
  :root body .ta-play[data-multi-game] .ta-play__header { grid-template-columns: minmax(0, 1fr) 44px auto auto; }
  :root body .ta-play[data-multi-game] .ta-play__games { grid-column: 1 / -1; grid-row: 2; display: grid; grid-template-columns: 1fr 1fr; }
  :root body .ta-play[data-multi-game] .ta-play__theme { grid-column: 2; }
  :root body .ta-play[data-multi-game] .ta-play__browse { grid-column: 3; }
  :root body .ta-play[data-multi-game] .ta-play__close { grid-column: 4; }
  :root body .ta-play[data-multi-game] .ta-play__title { font-size: 15px; }
  :root body .ta-play[data-multi-game] .ta-play__header { gap: 6px; }
}

/* Give navigation its own row before the breadcrumb/action row gets crowded. */
@media (max-width: 1099px) {
  :root body .site-header,
:root body .header-inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto 44px;
    align-items: center;
    gap: 4px 14px;
    padding-block: 12px;
  }
  :root body .site-header > .brand,
:root body .site-header > .brand-trail,
:root body .header-inner > .brand,
:root body .header-inner > .brand-trail { grid-column: 1; grid-row: 1; min-width: 0; }
  :root body .site-header > .header-action,
:root body .header-inner > .header-action { grid-column: 2; grid-row: 1; }
  :root body .site-header > .theme-picker,
:root body .header-inner > .theme-picker { grid-column: 3; grid-row: 1; }
  :root body .site-header > .nav,
:root body .header-inner > .nav { grid-column: 1 / -1; grid-row: 2; width: 100%; }
}
@media (max-width: 760px) {
  :root body .site-header,
:root body .header-inner { grid-template-columns: minmax(0, 1fr) 44px; }
  :root body .site-header > .theme-picker,
:root body .header-inner > .theme-picker { grid-column: 2; }
  :root body .site-header > .header-action,
:root body .header-inner > .header-action { display: none; }
  :root body .site-header .brand-trail,
:root body .header-inner .brand-trail { width: auto; }
  :root body .site-header .brand-path,
:root body .header-inner .brand-path { flex-wrap: wrap; white-space: normal; }
}

/* Color stays in the page chrome; real product captures retain native pixels. */
:root[data-theme="colorful"] body .button.primary,
:root:root[data-theme="colorful"] body .header-action,
:root:root[data-theme="colorful"] body .skip-link,
:root:root[data-theme="colorful"] body .ta-play-launch,
:root[data-theme="colorful"] body.theme-lab .btn.primary,
:root[data-theme="colorful"] body.theme-lab .btn.active,
:root[data-theme="colorful"] body.theme-lab .toggle.on,
:root[data-theme="colorful"] body.theme-lab .chip.selected {
  background: #6842a4; border-color: #6842a4; color: #fffdf9;
}
:root[data-theme="colorful"] body .button.primary:hover,
:root[data-theme="colorful"] body .button.primary:focus-visible,
:root:root[data-theme="colorful"] body .header-action:hover,
:root:root[data-theme="colorful"] body .header-action:focus-visible,
:root:root[data-theme="colorful"] body .ta-play-launch:hover,
:root:root[data-theme="colorful"] body .ta-play-launch:focus-visible {
  background: #533285; border-color: #533285; color: #fffdf9;
}
:root[data-theme="colorful"] body .eyebrow,
:root[data-theme="colorful"] body .section-id,
:root[data-theme="colorful"] body .release-label,
:root[data-theme="colorful"] body .patch-version { color: #7045a5; }
:root[data-theme="colorful"] :where(body) article:is(.features article):nth-child(3n + 2),
:root[data-theme="colorful"] :where(body) section:is(.trust-grid section):nth-child(3n + 2),
:root[data-theme="colorful"] body:is(body) .principle:nth-child(3n + 2) { background: #eaf5ee; }
:root[data-theme="colorful"] :where(body) article:is(.features article):nth-child(3n),
:root[data-theme="colorful"] :where(body) section:is(.trust-grid section):nth-child(3n),
:root[data-theme="colorful"] body:is(body) .principle:nth-child(3n) { background: #fff0e5; }
:root[data-theme="colorful"] body .theme-toggle { background: #f2e9fb; border-color: #ac95c8; }
:root[data-theme="colorful"] body.theme-lab .btn:hover,
:root[data-theme="colorful"] body.theme-lab .toggle:hover,
:root[data-theme="colorful"] body.theme-lab .chip:hover { background: var(--theme-hover); color: var(--theme-ink); }

.theme-menu { width: 240px; }
.theme-detail-group { border-top: 1px solid var(--theme-line); margin-top: 6px; padding-top: 6px; }
.theme-detail-group[hidden] { display: none; }
.theme-swatch-system { background: var(--theme-surface); color: var(--theme-ink); }
:root[data-theme-preference="system"] .theme-toggle :is(.theme-icon-light, .theme-icon-dark) { display: none; }
:root[data-theme-preference="system"] .theme-toggle .theme-icon-system { display: block; }
.theme-detail-swatch { width: 18px; height: 18px; margin: 5px; border-radius: 50%; background: var(--theme-surface); }
.theme-detail-spring { background: #d0edaa; }
.theme-detail-summer, .theme-detail-forest { background: #598353; }
.theme-detail-autumn { background: #f6c57a; }
.theme-detail-winter { background: #cae6f5; }
.theme-detail-meadow { background: #9bb779; }
.theme-detail-leaves { background: #315d42; }
.theme-option:disabled { opacity: .65; cursor: default; }

/* A global 1ms duration creates implicit transition:all animations even on
   elements that had no transition. Reduced motion must disable them entirely. */
@media (prefers-reduced-motion: reduce) {
  :root,
:root::before,
:root::after,
:root body,
:root body *,
:root body::before,
:root body::after,
:root body *::before,
:root body *::after { transition: none !important; }
}
