/* FRONTEND ONLY: never load in the Site Editor. Light tokens live in blocks.css. */
html { color-scheme: light; background: var(--bw-background); }
body { background: var(--bw-background); color: var(--bw-ink); }

/* Manual choices win over the OS, including explicit Light on a dark device. */
html[data-bw-appearance="dark"] {
  color-scheme: dark;
  --bw-background: #101827;
  --bw-surface: #182438;
  --bw-ink: #edf2ff;
  --bw-muted: #b7c4da;
  --bw-blue: #9aafff;
  --bw-line: #435572;
  --bw-soft: #131e30;
  --bw-focus: #9aafff;
  --bw-hero-surface: #192943;
  --bw-hero-line: #354a6d;
  --bw-icon-surface: #263659;
  --bw-chat-line: #435572;
  --bw-message-surface: #263659;
  --bw-chat-bottom: #152033;
  --bw-closing-surface: #1a2b45;
  --bw-success: #95d7af;
  --bw-cta-shadow: #101e75;
  --bw-mascot-shadow: #00000055;
  --bw-hello-shadow: #00000033;
  --bw-note-shadow: #00000044;
  --bw-chat-shadow: #00000044;
  /* Adapt core text/links/headings on ordinary pages, not just the landing page. */
  --wp--preset--color--base: var(--bw-background);
  --wp--preset--color--contrast: var(--bw-ink);
  --wp--preset--color--blue: var(--bw-blue);
  --wp--preset--color--muted: var(--bw-muted);
  --wp--preset--color--soft: var(--bw-soft);
}
/* System works even when JavaScript is disabled/blocked or optimized to run late. */
@media (prefers-color-scheme: dark) {
  html:not([data-bw-appearance="light"]):not([data-bw-appearance="dark"]) {
    color-scheme: dark;
    --bw-background: #101827;
    --bw-surface: #182438;
    --bw-ink: #edf2ff;
    --bw-muted: #b7c4da;
    --bw-blue: #9aafff;
    --bw-line: #435572;
    --bw-soft: #131e30;
    --bw-focus: #9aafff;
    --bw-hero-surface: #192943;
    --bw-hero-line: #354a6d;
    --bw-icon-surface: #263659;
    --bw-chat-line: #435572;
    --bw-message-surface: #263659;
    --bw-chat-bottom: #152033;
    --bw-closing-surface: #1a2b45;
    --bw-success: #95d7af;
    --bw-cta-shadow: #101e75;
    --bw-mascot-shadow: #00000055;
    --bw-hello-shadow: #00000033;
    --bw-note-shadow: #00000044;
    --bw-chat-shadow: #00000044;
    --wp--preset--color--base: var(--bw-background);
    --wp--preset--color--contrast: var(--bw-ink);
    --wp--preset--color--blue: var(--bw-blue);
    --wp--preset--color--muted: var(--bw-muted);
    --wp--preset--color--soft: var(--bw-soft);
  }
}

/* Native editable buttons; only hide the inactive FRONTEND selector, not blocks in editors. */
.bw-appearance { display: none; }
.bw-appearance.is-enhanced { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.bw-header > * { min-width: 0; max-width: 100%; }
.bw-header .bw-appearance-options { gap: 4px; flex-wrap: wrap; justify-content: center; margin: 0; }
.bw-appearance .wp-block-button { margin: 0; }
.bw-appearance .wp-block-button__link,
.bw-appearance .wp-block-button__link:is(:hover, :focus, :active) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--bw-muted);
  border-radius: 10px;
  background: var(--bw-surface);
  color: var(--bw-ink);
  font: 600 13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-decoration: none;
  box-shadow: none;
  cursor: pointer;
}
.bw-appearance-caption { display: none; }
.bw-appearance-icon { width: 20px; height: 20px; flex: 0 0 20px; }
.bw-appearance .wp-block-button__link:hover { text-decoration: underline; }
.bw-appearance .wp-block-button__link:focus-visible { outline: 3px solid var(--bw-focus); outline-offset: 3px; }
.bw-appearance-status { max-width: 230px; color: var(--bw-muted); font-size: 12px; line-height: 1.5; text-align: center; }
.bw-appearance-status:empty { display: none; }

/* Core's base preset becomes dark. CTA text must remain white in every state. */
.bw-page .wp-block-button__link,
.bw-page .wp-element-button,
.bw-page .wp-element-button:is(:hover, :focus, :active) { background: var(--bw-cta); color: var(--bw-cta-text); }
.bw-page :is(a, button, summary, input, select, textarea):focus-visible { outline: 3px solid var(--bw-focus); outline-offset: 5px; }
@media (max-width: 781px) {
  /* Two-row grid overrides the core flex layout: brand + appearance on top, centered nav below. */
  /* Beat core's body .is-layout-flex (0,1,1) without !important. */
  .bw-header.bw-wrap {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    min-height: auto;
  }
  .bw-header > .bw-brand-lockup {
    grid-row: 1;
    grid-column: 1;
  }
  .bw-header > .wp-block-navigation {
    grid-row: 2;
    grid-column: 1 / -1;
    justify-content: center;
  }
  .bw-header > .bw-appearance {
    grid-row: 1;
    grid-column: 2;
    justify-self: end;
  }
  .bw-header .wp-block-navigation__container { flex-wrap: wrap; }
}
