/* C1 palettes belong to the workbench root. Preview iframes keep story styles. */
:is(.histoire-app, .histoire-workbench, .histoire-root) {
  --histoire-canvas-rgb: 241 241 243;
  --histoire-home-rgb: 247 247 248;
  --histoire-surface-rgb: 255 255 255;
  --histoire-border-rgb: 228 228 231;
  --histoire-chip-rgb: 244 244 245;
  --histoire-input-rgb: 250 250 250;
  --histoire-text-rgb: 24 24 27;
  --histoire-body-rgb: 63 63 70;
  --histoire-muted-rgb: 95 99 112;
  --histoire-accent-rgb: 5 150 105;
  --histoire-accent-alpha: 1;
  --histoire-accent-soft-rgb: 236 253 245;
  --histoire-accent-soft-alpha: 1;
  --histoire-accent-text-rgb: 6 95 70;
  --histoire-accent-link-rgb: 4 120 87;
  --histoire-danger-rgb: 220 38 38;
  --histoire-danger-text-rgb: 185 28 28;
  --histoire-danger-soft-rgb: 254 242 242;
  --histoire-warn-rgb: 180 83 9;
  --histoire-agent-rgb: 124 58 237;
  --histoire-agent-text-rgb: 109 40 217;
  --histoire-agent-soft-rgb: 245 243 255;
  --histoire-measure-rgb: 225 29 72;
  --histoire-measure-gap-rgb: 147 51 234;
  --histoire-measure-padding-rgb: 132 204 22;
  --histoire-measure-margin-rgb: 249 115 22;
  --histoire-code-rgb: 24 24 27;
  --histoire-canvas: rgb(var(--histoire-canvas-rgb) / var(--histoire-canvas-alpha, 1));
  --histoire-home: rgb(var(--histoire-home-rgb) / var(--histoire-home-alpha, 1));
  --histoire-surface: rgb(var(--histoire-surface-rgb) / var(--histoire-surface-alpha, 1));
  --histoire-border: rgb(var(--histoire-border-rgb) / var(--histoire-border-alpha, 1));
  --histoire-chip: rgb(var(--histoire-chip-rgb) / var(--histoire-chip-alpha, 1));
  --histoire-input: rgb(var(--histoire-input-rgb) / var(--histoire-input-alpha, 1));
  --histoire-text: rgb(var(--histoire-text-rgb) / var(--histoire-text-alpha, 1));
  --histoire-body: rgb(var(--histoire-body-rgb) / var(--histoire-body-alpha, 1));
  --histoire-muted: rgb(var(--histoire-muted-rgb) / var(--histoire-muted-alpha, 1));
  --histoire-accent: rgb(var(--histoire-accent-rgb) / var(--histoire-accent-alpha));
  --histoire-accent-soft: rgb(var(--histoire-accent-soft-rgb) / var(--histoire-accent-soft-alpha));
  --histoire-accent-text: rgb(var(--histoire-accent-text-rgb) / var(--histoire-accent-text-alpha, 1));
  --histoire-accent-link: rgb(var(--histoire-accent-link-rgb) / var(--histoire-accent-link-alpha, 1));
  --histoire-danger: rgb(var(--histoire-danger-rgb) / var(--histoire-danger-alpha, 1));
  --histoire-danger-text: rgb(var(--histoire-danger-text-rgb) / var(--histoire-danger-text-alpha, 1));
  --histoire-danger-soft: rgb(var(--histoire-danger-soft-rgb) / var(--histoire-danger-soft-alpha, 1));
  --histoire-warn: rgb(var(--histoire-warn-rgb) / var(--histoire-warn-alpha, 1));
  --histoire-agent: rgb(var(--histoire-agent-rgb) / var(--histoire-agent-alpha, 1));
  --histoire-agent-text: rgb(var(--histoire-agent-text-rgb) / var(--histoire-agent-text-alpha, 1));
  --histoire-agent-soft: rgb(var(--histoire-agent-soft-rgb) / var(--histoire-agent-soft-alpha, 1));
  --histoire-measure: rgb(var(--histoire-measure-rgb) / var(--histoire-measure-alpha, 1));
  --histoire-measure-gap: rgb(var(--histoire-measure-gap-rgb) / var(--histoire-measure-gap-alpha, 1));
  --histoire-code: rgb(var(--histoire-code-rgb) / var(--histoire-code-alpha, 1));
  --histoire-shadow-toolbar: 0 1px 3px rgb(24 24 27 / 8%);
  /* Floating canvas bars (top toolbar, bottom tool hints). */
  --histoire-shadow-canvas-toolbar: 0 2px 5px rgb(0 0 0 / .07);
  --histoire-shadow-popover: 0 8px 24px rgb(24 24 27 / 10%);
  --histoire-shadow-panel: 0 16px 48px rgb(24 24 27 / 12%);
  --histoire-shadow: var(--histoire-shadow-panel);
  --histoire-radius-control: 7px;
  --histoire-radius-button: 9px;
  --histoire-radius-panel: 16px;
  --histoire-ease: cubic-bezier(.16, 1, .3, 1);
  color: var(--histoire-text);
  caret-color: var(--histoire-accent);
  font-family: var(--histoire-font-sans, "Manrope", system-ui, sans-serif);
  font-size: 13px;
  color-scheme: light;
}

:is(.htw-dark, [data-histoire-appearance="dark"]) :is(.histoire-app, .histoire-workbench, .histoire-root),
:is(.histoire-app, .histoire-workbench, .histoire-root):is(.htw-dark, [data-histoire-appearance="dark"]) {
  --histoire-canvas-rgb: 13 14 17;
  --histoire-home-rgb: 13 14 17;
  --histoire-surface-rgb: 22 23 27;
  --histoire-border-rgb: 38 40 45;
  --histoire-chip-rgb: 32 34 39;
  --histoire-input-rgb: 15 16 19;
  --histoire-text-rgb: 230 231 234;
  --histoire-body-rgb: 180 184 192;
  --histoire-muted-rgb: 138 142 151;
  --histoire-accent-rgb: 52 211 153;
  --histoire-accent-soft-rgb: 52 211 153;
  --histoire-accent-soft-alpha: .12;
  --histoire-accent-text-rgb: 243 244 246;
  --histoire-accent-link-rgb: 52 211 153;
  --histoire-danger-rgb: 248 113 113;
  --histoire-danger-text-rgb: 248 113 113;
  --histoire-danger-soft-rgb: 42 29 31;
  --histoire-warn-rgb: 251 191 36;
  --histoire-agent-text-rgb: 196 181 253;
  --histoire-agent-soft-rgb: 34 27 54;
  --histoire-shadow-toolbar: 0 1px 3px rgb(0 0 0 / 20%);
  --histoire-shadow-popover: 0 8px 24px rgb(0 0 0 / 24%);
  --histoire-shadow-panel: 0 16px 48px rgb(0 0 0 / 32%);
  color-scheme: dark;
}

:where(.histoire-app, .histoire-workbench, .histoire-root) {
  :is(code, pre, kbd) {
    font-family: var(--histoire-font-mono, "JetBrains Mono", ui-monospace, monospace);
  }

  :is(button, input, textarea, select) {
    font-family: inherit;
  }

  :focus-visible {
    outline: 2px solid var(--histoire-accent);
    outline-offset: 3px;
  }

  ::selection {
    color: var(--histoire-accent-text);
    background: var(--histoire-accent-soft);
  }

  ::placeholder {
    color: var(--histoire-muted);
    opacity: 1;
  }

  * {
    scrollbar-width: thin;
    scrollbar-color: var(--histoire-border) transparent;
  }
}

@media (prefers-reduced-motion: reduce) {
  :is(.histoire-app, .histoire-workbench, .histoire-root) *,
  :is(.histoire-app, .histoire-workbench, .histoire-root) *::before,
  :is(.histoire-app, .histoire-workbench, .histoire-root) *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
