/* BBSTATION alternate palette and style picker.
 * Load LAST, after page styles and bb-theme.css (also inside embedded documents).
 * JS owns html.dataset.bbStyle, .light/.dark and each button's aria-pressed.
 * All palette overrides are opt-in; blue keeps the existing site palette.
 */

/* Shared picker: use a labelled group containing two native type=button buttons.
 * Selection has a border, inset marker and weight as well as a color change.
 */
.bb-style-dock {
  display: flex;
  justify-content: flex-end;
  padding: 12px max(20px, 5vw);
  background: var(--background, #08162f);
  border-bottom: 1px solid var(--border, #365477);
}
.bb-style-switch {
  --bb-switch-bg: #0a1c38;
  --bb-switch-text: #d6e7ff;
  --bb-switch-border: #6384b0;
  --bb-switch-selected: #b8dcff;
  --bb-switch-ink: #081a38;
  --bb-switch-hover: #234875;
  --bb-switch-focus: #baff65;
  box-sizing: border-box;
  display: inline-flex;
  align-items: stretch;
  flex: 0 0 auto;
  gap: 3px;
  max-width: 100%;
  padding: 3px;
  border: 1px solid var(--bb-switch-border);
  border-radius: 999px;
  background: var(--bb-switch-bg);
  color: var(--bb-switch-text);
  font: 600 12px/1.2 system-ui, 'Microsoft YaHei', sans-serif;
  letter-spacing: 0;
  isolation: isolate;
  pointer-events: auto;
}
.bb-style-switch button[data-style-choice] {
  box-sizing: border-box;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  flex: 1 1 auto;
  gap: 5px;
  min-width: 62px;
  min-height: 38px;
  margin: 0;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--bb-switch-text);
  font: inherit;
  letter-spacing: inherit;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.bb-style-switch button[data-style-choice]:hover {
  background: var(--bb-switch-hover);
}
.bb-style-switch button[data-style-choice][aria-pressed="true"] {
  border-color: var(--bb-switch-selected);
  background: var(--bb-switch-selected);
  color: var(--bb-switch-ink);
  box-shadow: inset 0 -3px 0 currentColor;
  font-weight: 800;
}
.bb-style-switch button[data-style-choice]:focus-visible {
  position: relative;
  z-index: 1;
  outline: 3px solid var(--bb-switch-focus);
  outline-offset: 3px;
}
.bb-style-switch button[data-style-choice]:disabled {
  opacity: .55;
  cursor: not-allowed;
}
/* Only headers hosting the new control change layout. No absolute positioning. */
header:has(> .bb-style-switch) {
  z-index: 100 !important;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 12px;
  row-gap: 12px;
  height: auto;
  min-height: 64px;
}
header > .bb-style-switch {
  margin-inline-start: auto;
}
header:has(> .bb-style-switch) > nav {
  min-width: 0;
  flex-wrap: wrap;
}
/* Fixed app headers can contain a full-width navigation wrapper. Let it share
 * the row with the switch instead of forcing an extra desktop header row. */
header.fixed:has(> .bb-style-switch) > :first-child:not(.bb-style-switch) {
  flex: 1 1 30rem;
  align-items: center;
  min-width: 0;
  width: auto;
}
header.fixed > .bb-style-switch {
  margin-inline-end: max(12px, env(safe-area-inset-right));
}
@media (max-width: 1100px) {
  header.fixed:has(> .bb-style-switch) {
    align-content: center;
    min-height: 64px;
    height: auto !important;
    row-gap: 8px;
  }
  header.fixed:has(> .bb-style-switch) > :first-child:not(.bb-style-switch) {
    flex-basis: 100%;
    width: 100%;
  }
  header.fixed > .bb-style-switch {
    margin-inline-start: auto;
  }
}
@media (max-width: 760px) {
  header:has(> .bb-style-switch) {
    padding-block: 12px;
    column-gap: 10px;
    row-gap: 10px;
  }
  header:has(> .bb-style-switch) > nav {
    order: 2;
    flex: 1 0 100%;
    width: 100%;
    margin-inline-start: 0;
    gap: 10px 16px;
  }
  header > .bb-style-switch {
    margin-inline-start: auto;
  }
  /* A wrapped fixed-height header would cover app content. Keep it in flow
   * on compact screens; this also accommodates text zoom and long labels. */
  header.fixed:has(> .bb-style-switch) {
    position: sticky !important;
    top: 0;
    height: auto !important;
    min-height: 64px;
    max-height: none;
  }
  header.fixed:has(> .bb-style-switch) > :first-child:not(.bb-style-switch) {
    flex-basis: 100%;
    height: auto;
    min-height: 44px;
  }
  .bb-style-switch button[data-style-choice] {
    min-height: 44px;
    padding-inline: 10px;
  }
}
@media (prefers-reduced-motion: no-preference) {
  .bb-style-switch button[data-style-choice] {
    transition: background-color .16s ease, color .16s ease, border-color .16s ease;
  }
}

/* Cream paper, burnt orange and espresso. Attribute specificity beats both
 * :root.light and :root.dark; important tokens match the existing token layer.
 * --muted is a React surface token; static text is explicitly handled below.
 */
html:root[data-bb-style="warm"] {
  color-scheme: light;
  --background: #fbf4e8 !important;
  --foreground: #382418 !important;
  --card: #fffaf2 !important;
  --card-foreground: #382418 !important;
  --popover: #fffaf2 !important;
  --popover-foreground: #382418 !important;
  --primary: #a44218 !important;
  --primary-foreground: #ffffff !important;
  --secondary: #f0dfc7 !important;
  --secondary-foreground: #51321f !important;
  --muted: #f3e7d7 !important;
  --muted-foreground: #765943 !important;
  --accent: #f7d7b2 !important;
  --accent-foreground: #65321b !important;
  --border: #d9bfa0 !important;
  --input: #b39171 !important;
  --ring: #a44218 !important;
  --sidebar: #f3e5d1 !important;
  --sidebar-foreground: #382418 !important;
  --sidebar-primary: #a44218 !important;
  --sidebar-primary-foreground: #ffffff !important;
  --sidebar-accent: #f2d2ad !important;
  --sidebar-accent-foreground: #59331f !important;
  --sidebar-border: #d9bfa0 !important;
  --sidebar-ring: #a44218 !important;
  --chart-1: #b74e1c !important;
  --chart-2: #357366 !important;
  --chart-3: #97701b !important;
  --chart-4: #8c5272 !important;
  --chart-5: #7b533b !important;
  --bg: #fbf4e8;
  --panel: #fffaf2;
  --line: #d9bfa0;
  --text: #382418;
  --blue: #a44218;
  --green: #a44218;
  background: #fbf4e8;
  color: #382418;
}
html:root[data-bb-style="warm"] body {
  background: #fbf4e8;
  color: #382418;
}
html:root[data-bb-style="warm"] .bb-style-switch {
  --bb-switch-bg: #f4e5cf;
  --bb-switch-text: #65432b;
  --bb-switch-border: #b39171;
  --bb-switch-selected: #a44218;
  --bb-switch-ink: #ffffff;
  --bb-switch-hover: #ead3b6;
  --bb-switch-focus: #813312;
}
html:root[data-bb-style="warm"] :is(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 3px solid #a44218;
  outline-offset: 3px;
}
html:root[data-bb-style="warm"] ::selection {
  background: #efbd87;
  color: #382418;
}
/* Public page navigation and the app's explicit dark header rules. */
html:root[data-bb-style="warm"] header,
html:root[data-bb-style="warm"] header.fixed:has(nav) {
  background: #fff8ec !important;
  color: #382418;
  border-bottom-color: #d9bfa0 !important;
  box-shadow: 0 3px 18px #7042200a !important;
  --foreground: #382418;
  --muted-foreground: #765943;
}
html:root[data-bb-style="warm"] header strong { color: #a44218; }
html:root[data-bb-style="warm"] header nav,
html:root[data-bb-style="warm"] header nav a,
html:root[data-bb-style="warm"] header nav button {
  color: #65432b !important;
}
html:root[data-bb-style="warm"] header nav a[data-slot="button"].bg-primary {
  color: #fff !important;
}
html:root[data-bb-style="warm"] header nav a:hover,
html:root[data-bb-style="warm"] header nav button:hover {
  color: #813312 !important;
  background-color: #f4e3cc !important;
}
html:root[data-bb-style="warm"] header nav a[aria-current="page"],
html:root[data-bb-style="warm"] header nav a[data-status="active"] {
  color: #813312 !important;
  background-color: #f2d2ad !important;
}
html:root[data-bb-style="warm"] header nav a:focus-visible,
html:root[data-bb-style="warm"] header nav button:focus-visible {
  outline: 3px solid #a44218 !important;
}
/* Public layouts; avoid recoloring React status/error text globally. */
html:root[data-bb-style="warm"] :is(.intro, .layout, .card, .panel, .notice, footer) a,
html:root[data-bb-style="warm"] aside nav a { color: #a44218; }
html:root[data-bb-style="warm"] :is(.intro, .layout, .card, .panel, .notice) p,
html:root[data-bb-style="warm"] :is(.field, .results, footer, #copy-result),
html:root[data-bb-style="warm"] body > main > p { color: #765943; }
html:root[data-bb-style="warm"] :is(.eyebrow, .tag, aside small) { color: #945126; }
html:root[data-bb-style="warm"] :is(.card, section.panel, .layout main > section) {
  background: #fffaf2;
  border-color: #d9bfa0;
  box-shadow: 0 8px 26px #70422006;
}
html:root[data-bb-style="warm"] :is(.notice, .bb-launch-notice) {
  background: #f8ead5;
  border-color: #d9b387;
  border-left-color: #a44218;
  color: #51321f;
}
html:root[data-bb-style="warm"] .note { border-left-color: #b74e1c; }
html:root[data-bb-style="warm"] footer { border-top-color: #d9bfa0; }
html:root[data-bb-style="warm"] :is(.badge, .badge.pending) {
  background: #f7ebd9;
  border-color: #c9a37a;
  color: #79502b;
}
html:root[data-bb-style="warm"] :is(.filters input, .filters select, .field input, .field select) {
  background: #fffaf2;
  border-color: #b39171;
  color: #382418;
  color-scheme: light;
}
html:root[data-bb-style="warm"] :is(.filters input, .field input)::placeholder { color: #80664e; }
html:root[data-bb-style="warm"] :is(.card button, a.button) {
  background: #f4e5cf;
  border-color: #b39171;
  color: #65432b;
}
html:root[data-bb-style="warm"] :is(.card button, a.button):hover {
  background: #ead3b6;
  border-color: #a44218;
}
html:root[data-bb-style="warm"] :is(a.button.primary, .cta) {
  background: #a44218;
  border-color: #a44218;
  color: #fff;
}
html:root[data-bb-style="warm"] :is(a.button.primary, .cta):hover { background: #813312; }
html:root[data-bb-style="warm"] :is(.layout, .panel) :is(th, td) { border-color: #d9bfa0; }
html:root[data-bb-style="warm"] :is(.layout, .panel) th { color: #945126; }
html:root[data-bb-style="warm"] .layout pre {
  background: #f3e7d7;
  border-color: #d9bfa0;
  color: #51321f;
}
html:root[data-bb-style="warm"] .layout code { color: #8a3917; }
html:root[data-bb-style="warm"] .steps li::before {
  background: #f2d2ad;
  border-color: #c9a37a;
  color: #813312;
}
html:root[data-bb-style="warm"] form:has(input[type="password"]) input {
  background: #fffaf2 !important;
  color: #382418 !important;
}
html:root[data-bb-style="warm"] form:has(input[type="password"]) input:not([aria-invalid="true"]) {
  border-color: #b39171 !important;
}
html:root[data-bb-style="warm"] form:has(input[type="password"]) button[type="submit"] {
  background: #a44218 !important;
  color: #fff !important;
}
/* Hero poster. Preserve its shape, illustration and motion, recolor its ink. */
html:root[data-bb-style="warm"] .stage {
  background: radial-gradient(ellipse at 90% 30%, #f4d2a3 0, transparent 56%), #fbf4e8;
  color: #382418;
}
html:root[data-bb-style="warm"] .stage::before {
  background-image: radial-gradient(#9c6439 1px, transparent 1px);
}
html:root[data-bb-style="warm"] .stage :is(.topline, .bottom, .item) { border-color: #d9bfa0; }
html:root[data-bb-style="warm"] .stage :is(.topline, .eyebrow, .item small) { color: #805936; }
html:root[data-bb-style="warm"] .stage :is(h1, .sub, .item strong) { color: #382418 !important; }
html:root[data-bb-style="warm"] .stage h1 span {
  color: #bf5722 !important;
  -webkit-text-stroke: 1px #a44218;
  text-shadow: 4px 5px 0 #ead2b2;
}
html:root[data-bb-style="warm"] .stage .desc { color: #765943; }
html:root[data-bb-style="warm"] .stage .live { color: #945126 !important; }
html:root[data-bb-style="warm"] .stage .actions a {
  background: #fff8ec;
  border-color: #b39171;
  color: #65432b !important;
}
html:root[data-bb-style="warm"] .stage .actions .primary {
  background: #a44218;
  border-color: #a44218;
  color: #fff !important;
  box-shadow: 4px 4px 0 #d4ad80;
}
html:root[data-bb-style="warm"] .stage .actions a:hover { box-shadow: 5px 7px 0 #d4ad80; }
html:root[data-bb-style="warm"] .stage .disc {
  border-color: #ae6b38;
  background: repeating-radial-gradient(circle, #4d3020 0 4px, #65432c 5px 6px);
  box-shadow: 0 0 0 18px #e3bd8c, 0 0 0 20px #b58250, 18px 24px 0 #70422020;
}
html:root[data-bb-style="warm"] .stage .disc-label {
  background: #edab62;
  border-color: #9b4a23;
  color: #382418 !important;
}
html:root[data-bb-style="warm"] .stage .disc-label small { color: #59331f; }
html:root[data-bb-style="warm"] .stage .disc-label::after { background: #51321f; }
html:root[data-bb-style="warm"] .stage .sticker {
  background: #a44218;
  border-color: #813312;
  color: #fff8ec;
  box-shadow: 5px 6px 0 #70422026;
}
html:root[data-bb-style="warm"] .stage .tape {
  background: #f5deb8;
  border-color: #b39171;
  color: #59331f;
  box-shadow: 4px 5px 0 #7042201a;
}
html:root[data-bb-style="warm"] .stage .spark { color: #b74e1c; }
html:root[data-bb-style="warm"] .stage .item:hover { background-color: #e8c59b30; }
html:root[data-bb-style="warm"] .bb-prep { border-top-color: #d9bfa0; }
html:root[data-bb-style="warm"] .bb-prep .state {
  background: #f5e5cf;
  border-left-color: #a44218;
  color: #65432b;
}
html:root[data-bb-style="warm"] .bb-prep .state :is(strong, a) { color: #a44218; }
html:root[data-bb-style="warm"] .bb-prep article {
  background: #fffaf2;
  border-color: #d9bfa0;
}
html:root[data-bb-style="warm"] .bb-prep h2 { color: #382418 !important; }
html:root[data-bb-style="warm"] .bb-prep p { color: #765943; }
html:root[data-bb-style="warm"] .bb-prep article a { color: #a44218; }
/* About content can be served alone or embedded by the React shell. */
html:root[data-bb-style="warm"] .bb-about {
  background: radial-gradient(ellipse at 90% 10%, #f3d7b1, transparent 60%), #fbf4e8;
  color: #382418;
}
html:root[data-bb-style="warm"] .bb-about :is(small, a) { color: #a44218 !important; }
html:root[data-bb-style="warm"] .bb-about h1 { color: #382418 !important; }
html:root[data-bb-style="warm"] .bb-about h2 { color: #8a3917 !important; }
html:root[data-bb-style="warm"] .bb-about p { color: #765943 !important; }
html:root[data-bb-style="warm"] .bb-about article { background: #fffaf2; border-color: #d9bfa0; }
html:root[data-bb-style="warm"] .bb-about .line { border-top-color: #d9bfa0; }
/* Reference prices, readable React billing and notice text. */
html:root[data-bb-style="warm"] .reference-price { border-top-color: #d9bfa0; }
html:root[data-bb-style="warm"] .reference-price strong { color: #a44218; }
html:root[data-bb-style="warm"] .reference-price p { color: #765943; }
html:root[data-bb-style="warm"] .reference-price small { color: #945126; }
html:root[data-bb-style="warm"] .bb-launch-notice p { color: #765943; }
html:root[data-bb-style="warm"] .bb-launch-notice a { color: #a44218; }
html:root[data-bb-style="warm"] [data-slot="card"] { box-shadow: 0 6px 24px #70422008; }
@media (prefers-reduced-motion: no-preference) {
  html:root[data-bb-style="warm"] [data-slot="card"]:hover { box-shadow: 0 9px 28px #70422012; }
}
@media (forced-colors: active) {
  .bb-style-switch { border-color: ButtonText; background: Canvas; }
  .bb-style-switch button[data-style-choice] { color: ButtonText; }
  .bb-style-switch button[data-style-choice][aria-pressed="true"] {
    border-color: Highlight;
    background: Highlight;
    color: HighlightText;
    outline: 1px solid Highlight;
  }
  .bb-style-switch button[data-style-choice]:focus-visible { outline-color: Highlight; }
}
