/* The chooser's own chrome. Deliberately not Bootstrap: the preview lives in an iframe so
   that token overrides never reach the tool's UI, and the tool never leaks into the preview. */

:root {
  color-scheme: light dark;

  --ink: light-dark(#16181c, #e7e9ee);
  --ink-muted: light-dark(#5c6370, #9aa2b1);
  --ink-faint: light-dark(#858d9b, #6d7684);
  /* Deliberately not white in light mode. The artboard beside it *is* white, and two
     adjacent white surfaces separated by a thin gutter read as one continuous panel. */
  --surface: light-dark(#f7f8fa, #16181d);
  --surface-sunken: light-dark(#eef0f4, #101216);
  --surface-raised: light-dark(#ffffff, #1c1f26);
  --line: light-dark(#e3e6eb, #2a2e37);
  --line-strong: light-dark(#cdd2da, #3a3f4a);
  --accent: light-dark(#5b3df5, #a894ff);
  --accent-ink: light-dark(#ffffff, #14121f);
  --shadow: light-dark(0 1px 2px rgb(16 18 22 / 8%), 0 1px 2px rgb(0 0 0 / 40%));
  /* Matches the ground inside the preview frame, so there is no seam at its edge. */
  --canvas: light-dark(#e6e8ec, #22252b);
  --radius: 8px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

/*
 * One focus treatment for everything.
 *
 * The stylesheet previously had exactly one :focus-visible rule, on text inputs, which meant
 * a keyboard user tabbing through the controls could not see where they were. Styling it
 * once here rather than per component is the only way it stays true as controls are added.
 */
:where(button, [href], input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* .dial-swatch carries its own radius, so its ring should follow it rather than square it
   off; .hue has no radius of its own, so inheriting one here is a no-op and the ring stays
   square, matching the swatch. */
.hue:focus-visible, .dial-swatch:focus-visible { outline-offset: 3px; border-radius: inherit; }
.segmented button:focus-visible, .panel-tabs button:focus-visible, .tabs button:focus-visible { outline-offset: -2px; }

body {
  margin: 0;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--surface-sunken);
  height: 100dvh;
  display: grid;
  /* Header, an optional notice, then the workspace. The notice row collapses to nothing
     when it is hidden, so the layout is the same when there is nothing to say. */
  grid-template-rows: auto auto minmax(0, 1fr);
}

/* --- top bar ------------------------------------------------------------ */

.topbar {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  padding: .5rem .875rem;
  background: var(--surface);
  border-block-end: 1px solid var(--line);
}

.brand { display: flex; gap: .625rem; align-items: center; min-width: 0; }

/* Bootstrap's own mark (web/vendor/bootstrap-logo.svg), not a CSS-drawn stand-in. */
.brand-mark {
  flex: none;
  width: 24px;
  height: 24px;
  display: block;
}

.brand-text { min-width: 0; }
.brand h1 { margin: 0; font-size: .875rem; font-weight: 650; letter-spacing: -.01em; white-space: nowrap; }
.brand-sub { margin: 0; font-size: .6875rem; color: var(--ink-faint); white-space: nowrap; }

/* The positioning root for .health-detail (below): the health button sits ahead of a few
   more buttons in this row, so anchoring the popover to its own wrapper — instead of to
   this full-width row — let it run off the left edge of the viewport once the row got
   narrow enough to wrap. */
.topbar-actions { position: relative; display: flex; gap: .5rem; align-items: center; }

.health {
  font-size: .6875rem;
  padding: .25rem .5rem;
  border-radius: 999px;
  white-space: nowrap;
  cursor: help;
}

.health.is-ok { background: color-mix(in oklab, #16a34a 16%, transparent); color: light-dark(#14532d, #86efac); }
.health.is-warn { background: color-mix(in oklab, #dc2626 18%, transparent); color: light-dark(#7f1d1d, #fca5a5); }
.health.is-muted { background: var(--surface-sunken); color: var(--ink-faint); }

.button {
  font: inherit;
  font-size: .8125rem;
  padding: .375rem .75rem;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}

.button:hover:not(:disabled) { background: var(--surface-sunken); }
.button:disabled { opacity: .4; cursor: default; }

.button-primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-ink);
  font-weight: 550;
}

.button-primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }

/*
 * The repository link, and the ask that goes with it.
 *
 * A quiet button rather than a colored call to action: it competes with Export otherwise,
 * and Export is what people came for.
 */
.repo-link {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  padding-inline: .5rem;
  color: var(--ink-muted);
  text-decoration: none;
}

.repo-link:hover { background: var(--surface-sunken); color: var(--ink); }
.repo-mark { flex: none; display: block; }

.icon-group { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 6px; overflow: hidden; }

.icon-button {
  display: grid;
  place-items: center;
  font: inherit;
  line-height: 1;
  padding: .375rem .5rem;
  border: 0;
  background: var(--surface);
  color: var(--ink-muted);
  cursor: pointer;
}

.icon-button + .icon-button { border-inline-start: 1px solid var(--line); }
.icon-button:hover:not(:disabled) { background: var(--surface-sunken); color: var(--ink); }
.icon-button:disabled { opacity: .35; cursor: default; }

.segmented { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 6px; overflow: hidden; }

.segmented button {
  font: inherit;
  font-size: .75rem;
  padding: .3125rem .625rem;
  border: 0;
  background: var(--surface);
  color: var(--ink-muted);
  cursor: pointer;
  white-space: nowrap;
}

.segmented button + button { border-inline-start: 1px solid var(--line); }
.segmented button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

/* --- layout ------------------------------------------------------------- */

.layout {
  display: grid;
  grid-template-columns: minmax(21rem, 27rem) minmax(20rem, 1fr);
  min-height: 0;
}

body[data-mode="advanced"] .layout { grid-template-columns: minmax(30rem, 54rem) minmax(20rem, 1fr); }

.panel, .preview { min-height: 0; display: flex; flex-direction: column; }
/* The panel is chrome and the preview is content, so the panel casts onto the canvas
   rather than merely sitting next to it behind a hairline. */
.panel {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border-inline-end: 1px solid var(--line-strong);
  box-shadow: 2px 0 12px light-dark(rgb(16 18 22 / 6%), rgb(0 0 0 / 40%));
}

/* The mode switch governs this panel, so it sits on it — not next to the preview's own
   scheme switch, where two identical segmented controls read as one setting. */
.panel-tabs { display: flex; gap: .25rem; padding: .5rem .75rem 0; border-block-end: 1px solid var(--line); }

.panel-tabs button {
  font: inherit;
  font-size: .8125rem;
  font-weight: 550;
  padding: .4375rem .75rem;
  border: 0;
  border-block-end: 2px solid transparent;
  background: none;
  color: var(--ink-faint);
  cursor: pointer;
}

.panel-tabs button[aria-selected="true"] { color: var(--ink); border-block-end-color: var(--accent); }
.panel-tabs button:hover { color: var(--ink); }

.panel-body { flex: 1; min-height: 0; overflow-y: auto; }
.advanced-split { display: grid; grid-template-columns: 12.5rem minmax(0, 1fr); align-items: start; }
.rail { border-inline-end: 1px solid var(--line); }
.rail-search { padding: .625rem .75rem; border-block-end: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 1; }

.rail-search input {
  width: 100%;
  font: inherit;
  font-size: .8125rem;
  padding: .375rem .5rem;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface-sunken);
  color: inherit;
}

.rail-list { padding: .5rem 0 1.5rem; }

.rail-group {
  margin-block-start: .5rem;
  padding: .75rem .75rem .1875rem;
  font-size: .625rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--ink);
}

/* A hairline, not just a color change, marks where one group ends and the next begins —
   contrast alone reads as one continuous list once a header scrolls away from its items. */
.rail-group:not(:first-child) { border-block-start: 1px solid var(--line); }

.rail-item {
  display: flex;
  justify-content: space-between;
  gap: .375rem;
  width: 100%;
  font: inherit;
  font-size: .75rem;
  text-align: start;
  padding: .25rem .75rem;
  border: 0;
  background: none;
  color: var(--ink-muted);
  cursor: pointer;
}

.rail-item:hover { background: var(--surface-sunken); color: var(--ink); }
.rail-item[aria-current="true"] { background: color-mix(in oklab, var(--accent) 12%, transparent); color: var(--ink); font-weight: 550; }
.rail-item .count { color: var(--ink-faint); font-size: .625rem; font-variant-numeric: tabular-nums; }
.rail-item .dot { color: var(--accent); }

/* --- editor ------------------------------------------------------------- */

.editor { min-width: 0; background: var(--surface-sunken); }

.editor-head {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: .75rem 1rem .5rem;
  border-block-end: 1px solid var(--line);
  background: var(--surface);
}

.editor-head h2 { margin: 0; font-size: .875rem; font-weight: 650; }
.editor-head p { margin: .1875rem 0 0; font-size: .75rem; color: var(--ink-faint); max-width: 60ch; }

.section-warning {
  margin-block-start: .375rem !important;
  padding: .3125rem .4375rem;
  border-radius: 5px;
  background: color-mix(in oklab, #d97706 16%, transparent);
  color: light-dark(#78350f, #fcd34d) !important;
}

.editor-body { padding: 0 0 3rem; }

.token {
  display: grid;
  grid-template-columns: minmax(8rem, 13rem) minmax(0, 1fr);
  gap: .5rem .875rem;
  align-items: start;
  padding: .5rem 1rem;
  border-block-end: 1px solid var(--line);
}

.token:hover { background: var(--surface); }
.token.is-changed { box-shadow: inset 3px 0 0 var(--accent); }

.token-name { min-width: 0; }
.token-name code { font: 500 .75rem/1.4 var(--mono); color: var(--ink); overflow-wrap: anywhere; }
.token-name .cssvar { display: block; font: .6875rem/1.5 var(--mono); color: var(--ink-faint); overflow-wrap: anywhere; }
.token-name .desc { display: block; font-size: .6875rem; color: var(--ink-faint); margin-block-start: .125rem; }

.token-controls { display: grid; gap: .375rem; min-width: 0; }

.field { display: flex; flex-wrap: wrap; gap: .375rem; align-items: center; min-width: 0; }
.field input[type="text"] { flex: 1 1 9rem; }
.field .mode { font: .625rem/1 var(--mono); color: var(--ink-faint); width: 2.25rem; flex: none; text-transform: uppercase; }

.field input[type="text"] {
  flex: 1;
  min-width: 0;
  font: .75rem/1.4 var(--mono);
  padding: .3125rem .4375rem;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink);
}

.field input[type="text"]:focus-visible { outline-offset: -1px; }
.field input[type="text"][aria-invalid="true"] { border-color: light-dark(#b91c1c, #fca5a5); }

.field-error { flex-basis: 100%; margin: 0; font-size: .6875rem; color: light-dark(#b91c1c, #fca5a5); }

.field input[type="color"] {
  inline-size: 1.875rem;
  block-size: 1.75rem;
  flex: none;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
  cursor: pointer;
}

.swatch {
  inline-size: 1.75rem;
  block-size: 1.75rem;
  flex: none;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background-image: linear-gradient(45deg, var(--line) 25%, transparent 25%, transparent 75%, var(--line) 75%),
    linear-gradient(45deg, var(--line) 25%, transparent 25%, transparent 75%, var(--line) 75%);
  background-size: 10px 10px;
  background-position: 0 0, 5px 5px;
}

.swatch > span { display: block; inline-size: 100%; block-size: 100%; border-radius: 4px; }

.token-reset {
  font: inherit;
  font-size: .6875rem;
  padding: 0 .3125rem;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--ink-faint);
  cursor: pointer;
}

.token-reset:hover { color: var(--accent); background: color-mix(in oklab, var(--accent) 10%, transparent); }

.readonly-note { font-size: .6875rem; color: var(--ink-faint); font-style: italic; }

.empty { padding: 2rem 1rem; color: var(--ink-faint); font-size: .8125rem; }
.empty .link-button { margin: 0; }

/* --- preview ------------------------------------------------------------ */

/* An inset edge along the leading side so the canvas reads as a well the tool looks into,
   rather than the next panel along. */
.preview {
  background: var(--canvas);
  box-shadow: inset 6px 0 10px -8px light-dark(rgb(16 18 22 / 35%), rgb(0 0 0 / 70%));
}

.preview-head {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
  justify-content: flex-start;
  padding: .5rem .875rem;
  background: var(--surface);
  border-block-end: 1px solid var(--line-strong);
}

.preview-head .chip { margin-inline-start: auto; }

/* Names the region outright. The framing does most of the work, but there is no reason to
   leave "which of these is the tool?" to inference. */
.preview-title {
  margin-inline-end: .25rem;
  font-size: .6875rem;
  font-weight: 650;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.chip {
  font: .6875rem/1 var(--mono);
  padding: .25rem .4375rem;
  border-radius: 999px;
  background: var(--surface-sunken);
  color: var(--ink-muted);
}

.chip.is-active { background: color-mix(in oklab, var(--accent) 15%, transparent); color: var(--ink); }

#preview { flex: 1; border: 0; inline-size: 100%; background: var(--canvas); }

/* --- export dialog ------------------------------------------------------ */

.export {
  inline-size: min(64rem, 92vw);
  block-size: min(44rem, 88vh);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 60px rgb(0 0 0 / 28%);
}

.export::backdrop { background: rgb(10 12 16 / 45%); }
.export[open] { display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto auto; }
.export-panel { display: grid; grid-template-rows: auto auto minmax(0, 1fr); min-block-size: 0; }

.export-head { display: flex; align-items: center; justify-content: space-between; padding: .875rem 1rem; border-block-end: 1px solid var(--line); }
.export-head h2 { margin: 0; font-size: .9375rem; }

.tabs { display: flex; gap: .25rem; padding: .625rem 1rem 0; }

.tabs button {
  font: inherit;
  font-size: .8125rem;
  padding: .375rem .625rem;
  border: 1px solid transparent;
  border-radius: 6px 6px 0 0;
  background: none;
  color: var(--ink-muted);
  cursor: pointer;
}

.tabs button[aria-selected="true"] { background: var(--surface-sunken); border-color: var(--line); color: var(--ink); font-weight: 550; }

.export-note { margin: .625rem 1rem 0; font-size: .75rem; color: var(--ink-muted); max-width: 78ch; }
.export-steps { margin: .5rem 1rem 0; padding-inline-start: 1.125rem; font-size: .75rem; color: var(--ink-faint); }
.export-steps li + li { margin-block-start: .1875rem; }
.export-steps code { font: .6875rem/1.5 var(--mono); background: var(--surface-sunken); padding: .0625rem .25rem; border-radius: 4px; }

.export-code {
  margin: .625rem 1rem;
  padding: .875rem;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-sunken);
}

.export-code code { font: .75rem/1.6 var(--mono); white-space: pre; }

.export-message {
  margin: 0 1rem;
  padding: .5rem .625rem;
  font-size: .75rem;
  border-radius: 6px;
  background: color-mix(in oklab, #dc2626 14%, transparent);
  color: light-dark(#7f1d1d, #fca5a5);
}

.export-actions { display: flex; flex-wrap: wrap; gap: .5rem; padding: .625rem 1rem .5rem; }

.export-aside { margin: 0 1rem 1rem; font-size: .6875rem; color: var(--ink-faint); max-width: 78ch; }
.export-aside code { font: .6875rem/1.5 var(--mono); background: var(--surface-sunken); padding: .0625rem .25rem; border-radius: 4px; }



/* A reading, not a label: no fill, no pill — that shape is `.badge` and `.alert`'s. The
   status is carried by a small dot and by color on numerals already set in a monospace
   face, the way an instrument's own readout would show it. */
.contrast {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: .3125rem;
  font: .6875rem/1 var(--mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--ink-muted);
}

.contrast::before {
  content: "";
  flex: none;
  inline-size: .375rem;
  block-size: .375rem;
  border-radius: 50%;
  background: currentcolor;
}

.contrast.is-pass { color: light-dark(#14532d, #86efac); }
.contrast.is-warn { color: light-dark(#78350f, #fcd34d); }
.contrast.is-fail { color: light-dark(#7f1d1d, #fca5a5); }

/* --- simple mode -------------------------------------------------------- */

#simple { padding: 0 0 3rem; }

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: .375rem;
  align-items: center;
  padding: .875rem 1rem;
  border-block-end: 1px solid var(--line);
}

.presets-label { font-size: .75rem; color: var(--ink-faint); margin-inline-end: .125rem; }

/* Flat and square rather than a pill: a rounded, bordered, filled control is what
   Bootstrap renders on the other side of the gutter, and the tool should not imitate it. */
.chip-button {
  font: inherit;
  font-size: .75rem;
  padding: .25rem .5rem;
  border: 1px solid transparent;
  border-radius: 4px;
  background: none;
  color: var(--ink-muted);
  cursor: pointer;
}

.chip-button:hover { background: var(--surface-sunken); color: var(--ink); border-color: var(--line); }

.dial-section {
  margin: 1.25rem 0 0;
  padding: 0 1rem .375rem;
  font-size: .6875rem;
  font-weight: 650;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.dial { padding: .75rem 1rem 1rem; border-block-end: 1px solid var(--line); }
.dial-head { display: flex; gap: .5rem; align-items: baseline; }
.dial-label { font-size: .8125rem; font-weight: 600; }

.dial-custom {
  font: .625rem/1 var(--mono);
  padding: .1875rem .375rem;
  border-radius: 4px;
  background: color-mix(in oklab, var(--accent) 16%, transparent);
  color: var(--ink);
}

.dial-help { margin: .1875rem 0 .625rem; font-size: .75rem; color: var(--ink-faint); max-width: 58ch; }
.dial-options { flex-wrap: wrap; }
.dial-options button { padding: .375rem .6875rem; font-size: .75rem; }

/* A butted-up matrix of hairline cells, not a wrapped row of rounded chips — the shape
   `.btn` and `.badge` also use. Square by design, so it reads as an instrument (a swatch
   strip) rather than as more of the preview it is theming. */
.hue-grid { display: flex; flex-wrap: wrap; gap: 1px; padding: 1px; border: 1px solid var(--line-strong); background: var(--line); }

.hue {
  inline-size: 1.75rem;
  block-size: 1.75rem;
  padding: 0;
  border: 0;
  position: relative;
  cursor: pointer;
}

.hue:hover { z-index: 1; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 30%); }

/* A bottom tick rather than an outlined ring — a ring here would read as the same focus/press
   affordance Bootstrap draws on its own buttons and badges. */
.hue[aria-pressed="true"] { z-index: 1; }
.hue[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  inset-block-end: 0;
  block-size: 3px;
  background: var(--ink);
}

.hue-custom { display: flex; gap: .5rem; align-items: center; margin-block-start: .625rem; }
.hue-note { font-size: .6875rem; color: var(--ink-faint); }

.simple-footer { padding: 1.25rem 1rem; display: grid; gap: .25rem; justify-items: start; }
.simple-footer p { margin: 0; font-size: .75rem; color: var(--ink-muted); }
.simple-notice { color: var(--ink-faint); }

.link-button {
  margin-block-start: .375rem;
  font: inherit;
  font-size: .75rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  cursor: pointer;
}

.link-button:hover { text-decoration: underline; }



.dial-contrast {
  display: flex;
  flex-wrap: wrap;
  gap: .375rem .75rem;
  align-items: center;
  margin-block-start: .625rem;
}

.dial-contrast-item { display: flex; gap: .375rem; align-items: center; font-size: .6875rem; color: var(--ink-faint); }
.dial-contrast-warning { flex-basis: 100%; font-size: .6875rem; color: light-dark(#b91c1c, #fca5a5); }

/* --- visual option swatches --------------------------------------------- */

.dial-swatches { display: flex; flex-wrap: wrap; gap: .5rem; }

.dial-swatch {
  display: grid;
  gap: .3125rem;
  justify-items: center;
  min-inline-size: 3.5rem;
  padding: .375rem .25rem .3125rem;
  font: inherit;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--ink-faint);
  cursor: pointer;
}

.dial-swatch:hover { background: var(--surface-sunken); color: var(--ink); }

/* Selection reads on the glyph, not on a card frame around it. */
.dial-swatch[aria-pressed="true"] { background: color-mix(in oklab, var(--accent) 12%, transparent); color: var(--ink); }
.dial-swatch[aria-pressed="true"] .swatch-preview { outline: 2px solid var(--accent); outline-offset: 2px; }

.dial-swatch-label { font-size: .6875rem; }

.swatch-preview {
  display: grid;
  place-content: center;
  inline-size: 2.25rem;
  block-size: 1.75rem;
  color: var(--ink);
}

.swatch-radius { background: var(--ink-muted); }
.swatch-border { border: 1px solid var(--ink-muted); border-radius: 4px; }
.swatch-density { grid-auto-rows: 3px; align-content: center; }
.swatch-density > span { display: block; inline-size: 1.75rem; block-size: 3px; border-radius: 2px; background: var(--ink-muted); }
.swatch-shadow { background: var(--surface); border: 1px solid var(--line); border-radius: 5px; }
.swatch-font { font-size: 1.0625rem; line-height: 1; }
.swatch-text-size { line-height: 1; }

/* 17px is the right size for the dot but fails WCAG 2.2 target size, so the hit area is
   grown past the visual with a pseudo-element instead of by making the dot bigger. */
.dial-info {
  position: relative;
  font: inherit;
  font-size: .625rem;
  inline-size: 1.0625rem;
  block-size: 1.0625rem;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: none;
  color: var(--ink-faint);
  cursor: pointer;
}

.dial-info::after {
  content: "";
  position: absolute;
  inset: -.25rem;
  min-inline-size: 24px;
  min-block-size: 24px;
}

.dial-info:hover, .dial-info[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }
.dial-help { margin: .375rem 0 .625rem; }

/* --- responsive --------------------------------------------------------- */

/* Below this width the two panes stack, and a preview you have to scroll to is a preview
   you never look at — so pin it to the bottom of the viewport and let the controls scroll
   underneath it. */
@media (width < 64rem) {
  body { height: auto; min-height: 100dvh; }
  .layout, body[data-mode="advanced"] .layout { grid-template-columns: 1fr; }
  .panel { border-inline-end: 0; padding-block-end: 44vh; }
  .panel-body { overflow: visible; }
  .advanced-split { grid-template-columns: 1fr; }
  .rail { border-inline-end: 0; border-block-end: 1px solid var(--line); }
  .rail-list { display: flex; flex-wrap: wrap; gap: .25rem; padding: .625rem .75rem; }
  .rail-group { flex-basis: 100%; padding: .375rem 0 0; }
  .rail-item { inline-size: auto; padding: .25rem .5rem; border: 1px solid var(--line); border-radius: 999px; }
  .editor-head, .rail-search { position: static; }

  .preview {
    position: fixed;
    inset-block-end: 0;
    inset-inline: 0;
    z-index: 5;
    block-size: 44vh;
    background: var(--surface);
    border-block-start: 1px solid var(--line-strong);
    box-shadow: 0 -6px 20px rgb(0 0 0 / 10%);
  }
}

@media (width < 34rem) {
  .topbar { flex-wrap: wrap; row-gap: .5rem; }
  .brand-sub { display: none; }
  /* Room runs out before the bar wraps a second time, and the mark alone still says where
     the link goes, so the word goes first. */
  .repo-label { display: none; }
  .topbar-actions { inline-size: 100%; justify-content: flex-end; }
  .token { grid-template-columns: 1fr; }
}

/* --- theme health disclosure -------------------------------------------- */

.health {
  font: inherit;
  font-size: .6875rem;
  padding: .25rem .5rem;
  border: 1px solid transparent;
  border-radius: 999px;
  white-space: nowrap;
  cursor: pointer;
}

.health:disabled { cursor: default; }
.health:not(:disabled):hover { border-color: currentcolor; }

.health-detail {
  position: absolute;
  inset-block-start: calc(100% + .375rem);
  inset-inline-end: 0;
  z-index: 20;
  inline-size: min(34rem, 84vw);
  max-block-size: 24rem;
  overflow-y: auto;
  padding: .625rem;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface-raised);
  box-shadow: 0 12px 32px light-dark(rgb(16 18 22 / 16%), rgb(0 0 0 / 55%));
}

.health-detail-head { margin: 0 0 .375rem; font-size: .6875rem; color: var(--ink-faint); }
.health-detail ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 1px; }
.health-groups { display: grid; gap: .5rem; }

.health-group-heading {
  margin: 0;
  padding: .25rem .375rem;
  font-size: .625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .02em;
  color: var(--ink-faint);
}

summary.health-group-heading { cursor: pointer; }
summary.health-group-heading::marker { font-size: .5625rem; }

.health-issue {
  display: flex;
  gap: .5rem;
  align-items: baseline;
  justify-content: space-between;
  inline-size: 100%;
  font: inherit;
  text-align: start;
  padding: .25rem .375rem;
  border: 0;
  border-radius: 5px;
  background: none;
  color: var(--ink);
  cursor: pointer;
}

.health-issue:hover { background: var(--surface-sunken); }
.health-issue code { font: .6875rem/1.4 var(--mono); overflow-wrap: anywhere; }
.health-issue-meta { flex: none; font: .625rem/1.4 var(--mono); color: var(--ink-faint); }

/* Where a jump lands, so the row you asked for is the row you see. */
.token.is-revealed { animation: reveal 1.6s ease-out; }

@keyframes reveal {
  0%, 45% { background: color-mix(in oklab, var(--accent) 16%, transparent); }
  100% { background: transparent; }
}

@media (prefers-reduced-motion: reduce) {
  .token.is-revealed { animation: none; outline: 2px solid var(--accent); outline-offset: -2px; }
}

/* --- build options ------------------------------------------------------- */

.options { border-block-start: 1px solid var(--line); margin-block-start: .5rem; }
.options-note { margin: 0 1rem .5rem; font-size: .75rem; color: var(--ink-faint); max-width: 58ch; }

.options-group {
  margin: .75rem 1rem .25rem;
  font-size: .625rem;
  font-weight: 650;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.option-row {
  display: flex;
  gap: .5rem;
  align-items: start;
  padding: .375rem 1rem;
  font-size: .75rem;
  cursor: pointer;
}

.option-row:hover { background: var(--surface-sunken); }
.option-row.is-changed { box-shadow: inset 3px 0 0 var(--accent); }
.option-row input[type="checkbox"] { margin-block-start: .1875rem; flex: none; }
.option-row code { font: .6875rem/1.5 var(--mono); color: var(--ink); }
.option-help { display: block; color: var(--ink-faint); max-width: 52ch; }
.option-row-value { align-items: center; justify-content: space-between; cursor: default; }

.option-row-value select,
.option-row-value input[type="text"] {
  flex: none;
  inline-size: 9rem;
  font: .6875rem/1.4 var(--mono);
  padding: .25rem .375rem;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink);
}

/* --- adding a color ----------------------------------------------------- */

.add-color { display: flex; flex-wrap: wrap; gap: .375rem; align-items: center; margin-block-start: .75rem; }

.added-chip {
  display: inline-flex;
  gap: .3125rem;
  align-items: center;
  padding: .1875rem .3125rem;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  font-size: .6875rem;
}

.added-chip-swatch { inline-size: .875rem; block-size: .875rem; border-radius: 3px; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 15%); }
.added-chip code { font: .625rem/1.4 var(--mono); }

.added-chip-remove {
  font: inherit;
  font-size: .8125rem;
  line-height: 1;
  padding: 0 .125rem;
  border: 0;
  background: none;
  color: var(--ink-faint);
  cursor: pointer;
}

.added-chip-remove:hover { color: light-dark(#b91c1c, #fca5a5); }

.add-color-form {
  flex-basis: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: .375rem;
  align-items: center;
  margin-block-start: .375rem;
  padding: .5rem;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface-sunken);
}

.add-color-form input[type="text"] {
  inline-size: 8rem;
  font: .75rem/1.4 var(--mono);
  padding: .3125rem .375rem;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink);
}

.add-color-form input[type="color"] {
  inline-size: 2rem;
  block-size: 1.875rem;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
  cursor: pointer;
}

.add-color-form .button { padding: .3125rem .5rem; font-size: .75rem; }
.add-color-role { display: flex; gap: .25rem; align-items: center; font-size: .6875rem; color: var(--ink-muted); }
.add-color-error { flex-basis: 100%; margin: 0; font-size: .6875rem; color: light-dark(#b91c1c, #fca5a5); }

/* An added scale is marked, so it is clear which colors are yours. A corner flag rather than
   an outer ring: cells now sit edge to edge, and a ring would bleed onto the neighbor. */
.hue.is-added::before {
  content: "";
  position: absolute;
  inset-block-start: 0;
  inset-inline-end: 0;
  border-block-start: 6px solid var(--accent);
  border-inline-start: 6px solid transparent;
}

/* --- theme picker -------------------------------------------------------- */

.theme-picker { position: relative; }

.theme-name {
  display: flex;
  gap: .3125rem;
  align-items: center;
  font: inherit;
  font-size: .875rem;
  font-weight: 650;
  letter-spacing: -.01em;
  padding: .0625rem .25rem;
  margin-inline-start: -.25rem;
  border: 0;
  border-radius: 5px;
  background: none;
  color: var(--ink);
  cursor: pointer;
}

.theme-name:hover { background: var(--surface-sunken); }
.theme-name svg { color: var(--ink-faint); }

.theme-menu {
  position: absolute;
  inset-block-start: calc(100% + .25rem);
  inset-inline-start: -.25rem;
  z-index: 20;
  inline-size: 15rem;
  padding: .3125rem;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface-raised);
  box-shadow: 0 12px 32px light-dark(rgb(16 18 22 / 16%), rgb(0 0 0 / 55%));
}

.theme-menu ul { margin: 0 0 .3125rem; padding: 0; list-style: none; max-block-size: 14rem; overflow-y: auto; }

.theme-menu li button {
  display: flex;
  gap: .375rem;
  align-items: baseline;
  justify-content: space-between;
  inline-size: 100%;
  font: inherit;
  font-size: .75rem;
  text-align: start;
  padding: .3125rem .375rem;
  border: 0;
  border-radius: 5px;
  background: none;
  color: var(--ink);
  cursor: pointer;
}

.theme-menu li button:hover { background: var(--surface-sunken); }
.theme-menu li button[aria-current="true"] { background: color-mix(in oklab, var(--accent) 14%, transparent); font-weight: 600; }
.theme-menu li .count { font: .625rem/1.4 var(--mono); color: var(--ink-faint); }
.theme-menu-actions { display: flex; flex-wrap: wrap; gap: .25rem; padding-block-start: .3125rem; border-block-start: 1px solid var(--line); }

/* --- change list --------------------------------------------------------- */

.changes-wrap { position: relative; margin-inline-start: auto; }
.chip[aria-expanded] { border: 1px solid transparent; cursor: pointer; font-family: var(--mono); }
.chip[aria-expanded]:not(:disabled):hover { border-color: var(--line-strong); }
.chip:disabled { cursor: default; }

.changes-detail {
  position: absolute;
  inset-block-start: calc(100% + .375rem);
  inset-inline-end: 0;
  z-index: 20;
  inline-size: min(32rem, 84vw);
  max-block-size: 24rem;
  overflow-y: auto;
  padding: .625rem;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface-raised);
  box-shadow: 0 12px 32px light-dark(rgb(16 18 22 / 16%), rgb(0 0 0 / 55%));
}

.changes-head { margin: 0 0 .5rem; font-size: .6875rem; color: var(--ink-faint); }
.changes-detail ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 1px; }

.change-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .125rem .5rem;
  align-items: baseline;
  padding: .3125rem .375rem;
  border-radius: 5px;
}

.change-row:hover { background: var(--surface-sunken); }
.change-key { font: .6875rem/1.4 var(--mono); color: var(--ink); overflow-wrap: anywhere; }
.change-values { grid-column: 1; font: .625rem/1.5 var(--mono); color: var(--ink-muted); overflow-wrap: anywhere; }
.change-values s { color: var(--ink-faint); }

.change-added {
  padding: .0625rem .25rem;
  border-radius: 3px;
  background: color-mix(in oklab, var(--accent) 18%, transparent);
  color: var(--ink);
}

.change-revert {
  grid-row: 1 / span 2;
  grid-column: 2;
  align-self: center;
  font: inherit;
  font-size: .625rem;
  padding: .1875rem .375rem;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink-muted);
  cursor: pointer;
}

.change-revert:hover { color: var(--ink); border-color: var(--accent); }

.change-invalid {
  grid-column: 1 / -1;
  margin: 0;
  font: .625rem/1.4 var(--mono);
  color: light-dark(#b91c1c, #fca5a5);
  overflow-wrap: anywhere;
}

/* --- contrast repair ----------------------------------------------------- */

.contrast-fix {
  font: inherit;
  font-size: .625rem;
  padding: .1875rem .375rem;
  margin-inline-end: .25rem;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}

.contrast-fix:hover { border-color: var(--accent); color: var(--accent); }
.dial-contrast-warning + .contrast-fix { margin-block-start: .25rem; }
.health-issue + .contrast-fix { align-self: center; }
.health-detail li { display: flex; gap: .375rem; align-items: center; }
.health-detail li .health-issue { flex: 1; min-width: 0; }

/* --- first run ----------------------------------------------------------- */

.intro {
  margin: .75rem .875rem .25rem;
  padding: .75rem .875rem;
  border: 1px solid color-mix(in oklab, var(--accent) 35%, var(--line));
  border-radius: 9px;
  background: color-mix(in oklab, var(--accent) 7%, transparent);
}

.intro h3 { margin: 0 0 .25rem; font-size: .8125rem; font-weight: 650; }
.intro p { margin: 0 0 .625rem; font-size: .75rem; color: var(--ink-muted); max-width: 52ch; }
.intro-actions { display: flex; gap: .375rem; }
.intro-actions .button { font-size: .75rem; padding: .3125rem .625rem; }

/* The markup editor. Tall enough that a real chunk of a page is legible without scrolling a
   five-line box, and set in the same sunken monospace surface as the export panes. */
.markup-input {
  display: block;
  inline-size: calc(100% - 2rem);
  min-block-size: 15rem;
  margin: .625rem 1rem;
  padding: .875rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-sunken);
  color: var(--ink);
  font: .75rem/1.6 var(--mono);
  resize: vertical;
}

/* The vision selector. A native select: five options, rarely changed, and a segmented
   control of five would crowd out the two that matter. */
.vision {
  display: flex;
  align-items: center;
  gap: .375rem;
  font-size: .75rem;
  color: var(--ink-muted);
}

.vision-label {
  font-weight: 650;
  letter-spacing: .04em;
  text-transform: uppercase;
  font-size: .625rem;
}

.vision select {
  padding: .25rem .375rem;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface-raised);
  color: var(--ink);
  font: inherit;
}

/* A page-level notice. Sits between the header and the workspace so it is impossible to
   miss and impossible to mistake for part of either. */
.notice {
  display: flex;
  gap: .75rem;
  align-items: center;
  justify-content: space-between;
  padding: .625rem .875rem;
  border-block-end: 1px solid var(--line-strong);
  background: light-dark(#fff7e0, #33290d);
  color: light-dark(#4a3600, #f4e3b4);
  font-size: .8125rem;
}

.notice p { margin: 0; }

/* `display: flex` outranks the user-agent's `[hidden] { display: none }`, so without this
   the row is always drawn — an empty colored band on every load. Any rule that sets
   `display` on something toggled with `hidden` needs this pair. */
.notice[hidden] { display: none; }

/* A token Bootstrap itself drops. Sits under the field rather than beside the name, because
   it explains why the field you just typed into did nothing. */
.token-finding {
  grid-column: 1 / -1;
  margin: .375rem 0 0;
  padding: .4rem .55rem;
  border-radius: 6px;
  background: light-dark(#fff3e0, #3a2a10);
  color: light-dark(#5b3a00, #f0d9ae);
  font-size: .75rem;
  line-height: 1.45;
}
