/* DIVINITY menu demo.
   Sizes are in rem so "UI scale" (the root font size) scales the whole menu.
   Depth comes in four tones: the stage, the glass window, raised modules, recessed control wells.
   The accent (lavender #be9eca by default, any solid color from Settings) marks selection lines, switch tracks,
   slider fills, active icons and focus. The window is blurred glass; modules are near-solid surfaces on it. */

@font-face {
  font-family: "Archivo";
  src: url("fonts/archivo-latin-wdth-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --scale: 1;
  --accent: #be9eca;
  --glow: .6;
  --panel-alpha: .85;
  --module-alpha: .92;
  --glow-mix: calc(var(--glow) * 75%);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;

  /* Graphite, the only theme: neutral greys */
  --stage: #09090a;
  --ground: 22 22 24;
  --line: #262629;
  --surface: 30 30 33;
  --module: rgb(var(--surface) / var(--module-alpha));
  --module-hover: rgb(255 255 255 / .06);
  --module-line: #2e2e32;
  --well: rgb(0 0 0 / .32);
  --lift: rgb(255 255 255 / .075);
  --raised: #242427;
  --control-hover: #5c5c61;
  --knob: #9b9ba2;
  --text: #f4f4f5;
  --label: #e1e1e4;
  --muted: #b2b2b8;
  --faint: #919197;

  /* Corner style: soft */
  --r-window: 18px;
  --r-module: 12px;
  --r-card: 8px;
  --r-field: 7px;
  --r-control: 999px;
  --r-chip: 6px;

  /* Density: comfortable */
  --row-min: 2.75rem;
  --bar-h: 4rem;
  --module-gap: .875rem;
  --stack-gap: 1.25rem;
  --pad-x: 1rem;
  --row-line: rgb(255 255 255 / .055);

  font-size: calc(16px * var(--scale));
}

:root[data-density="compact"] {
  --row-min: 2.375rem;
  --module-gap: .625rem;
  --stack-gap: 1rem;
  --pad-x: .875rem;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: var(--stage);
  color: var(--text);
  font: 400 .8125rem/1.5 "Archivo", system-ui, sans-serif;
  font-stretch: 100%;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  caret-color: var(--accent);
  scrollbar-color: #3b3542 transparent;
  transition: background-color 150ms;
}

::selection { background: color-mix(in srgb, var(--accent) 38%, transparent); color: var(--text); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 calc(.75rem * var(--glow)) color-mix(in srgb, var(--accent) var(--glow-mix), transparent);
}

button, input { font: inherit; color: inherit; }
h2, h3 { margin: 0; }
[hidden] { display: none !important; }

.sr-only, .skip:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip {
  position: fixed;
  z-index: 20;
  top: 1rem;
  left: 1rem;
  padding: .625rem 1rem;
  border-radius: var(--r-chip);
  background: var(--raised);
  color: var(--text);
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon {
  width: 1rem;
  height: 1rem;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-sm { width: .875rem; height: .875rem; }

/* The winged figure stands behind the glass; the window blurs it into a lavender haze. */
.stage-mark {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: color-mix(in srgb, var(--accent) 24%, transparent);
  -webkit-mask: var(--mark) center 42% / auto min(118vh, 125vw) no-repeat;
          mask: var(--mark) center 42% / auto min(118vh, 125vw) no-repeat;
}

/* Window: tinted glass. Panel opacity sets the tint; at 100% it is solid. */

.window {
  position: relative;
  width: min(82.5rem, 100%);
  height: min(50rem, calc(100dvh - 3rem));
  display: grid;
  grid-template-columns: 13.5rem minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  grid-template-areas: "side main";
  background: rgb(var(--ground) / var(--panel-alpha));
  -webkit-backdrop-filter: blur(24px) saturate(1.15);
          backdrop-filter: blur(24px) saturate(1.15);
  border: 1px solid var(--module-line);
  border-radius: var(--r-window);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .07), 0 1.5rem 4rem rgb(0 0 0 / .55);
  overflow: clip;
  transition: background-color 150ms, border-radius 150ms;
}
.intro .window { opacity: 0; }

:root[data-window="max"] body { padding: 0; }
:root[data-window="max"] .window { width: 100%; height: 100dvh; border-color: transparent; border-radius: 0; box-shadow: none; }

/* Brand block at the top of the sidebar: it shares the toolbar's height, so one divider runs across the window. */

.brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  min-width: 0;
  height: var(--bar-h);
  margin: 0 -.75rem .25rem;
  padding: 0 .75rem;
  border-bottom: 1px solid var(--line);
  user-select: none;
}
.brand-tile {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  flex: none;
  border: 1px solid var(--module-line);
  border-radius: var(--r-card);
  background: var(--well);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .06);
}
.brand-logo { width: 1.5rem; height: 1.5rem; flex: none; }
.brand-text { display: grid; gap: .125rem; min-width: 0; }
.wordmark {
  display: block;
  font-size: .8125rem;
  font-weight: 640;
  font-stretch: 125%;
  letter-spacing: .2em;
  line-height: 1.25;
}
.brand-sub { color: var(--faint); font-size: .75rem; line-height: 1.2; white-space: nowrap; }

/* Window controls close the toolbar row, full height, flush with the window edge. */
.window-controls { display: flex; align-self: stretch; margin: -.5rem calc(var(--pad-x) * -1) -.5rem 0; }
.wc {
  position: relative;
  display: grid;
  place-items: center;
  width: 2.75rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 150ms, color 150ms;
}
.wc::before { content: ""; position: absolute; inset: -.125rem 0; }
.wc:hover { background: rgb(255 255 255 / .07); color: var(--text); }
.wc-close:hover { background: rgb(255 255 255 / .12); }
.wc:focus-visible { outline-offset: -2px; }

/* Sidebar: the same glass as the window, split off by one line; brand, categories in two groups, profile */

.sidebar {
  grid-area: side;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0 .75rem;
  border-right: 1px solid var(--line);
}

.nav-wrap { position: relative; }
.nav { display: grid; gap: .1875rem; margin: 0; padding: 0; list-style: none; }
.nav-group {
  padding: 1rem .75rem .375rem;
  color: var(--faint);
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.nav-group:first-child { padding-top: .375rem; }

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: .75rem;
  min-height: 2.75rem;
  padding: 0 .75rem;
  border-radius: var(--r-card);
  color: var(--muted);
  font-size: .875rem;
  font-weight: 500;
  text-decoration: none;
  transition: color 150ms, background-color 150ms, box-shadow 150ms;
}
.nav-item .icon { color: var(--faint); transition: color 150ms; }
.nav-item:hover { color: var(--text); background: rgb(255 255 255 / .035); }
.nav-item[aria-current="page"] {
  color: var(--text);
  background: var(--lift);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .06), 0 1px 2px rgb(0 0 0 / .3);
}
.nav-item[aria-current="page"] .icon { color: var(--accent); }
.nav-short { display: none; }

/* The halo: one 1px accent line that travels to the active section (placed by app.js). */
.halo {
  position: absolute;
  top: 0;
  left: 0;
  width: 100px;
  height: 1px;
  background: var(--accent);
  box-shadow: 0 0 calc(.5rem * var(--glow)) color-mix(in srgb, var(--accent) var(--glow-mix), transparent);
  transform-origin: 0 50%;
  pointer-events: none;
  opacity: 0;
}
.halo.is-placed { opacity: 1; }

/* Profile row: the sidebar's foot, behind one divider. It opens Settings. */
.profile-chip {
  display: flex;
  align-items: center;
  gap: .75rem;
  width: calc(100% + 1.5rem);
  margin: auto -.75rem 0;
  min-height: 4.25rem;
  padding: .75rem 1.25rem .75rem 1rem;
  text-align: left;
  cursor: pointer;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0 0 0 calc(var(--r-window) - 1px);
  background: none;
  color: var(--text);
  text-decoration: none;
  transition: background-color 150ms;
}
.profile-chip:hover { background: rgb(255 255 255 / .035); }
.profile-chip:focus-visible { outline-offset: -2px; }
.profile-chip[aria-expanded="true"] { background: var(--lift); }
.profile-chip[aria-expanded="true"] .icon { color: var(--accent); }
.profile-chip .icon { margin-left: auto; color: var(--faint); }
.avatar {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  flex: none;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 24%, rgb(var(--ground)));
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .12);
  font-size: .75rem;
  font-weight: 600;
}
.chip-text { display: grid; min-width: 0; line-height: 1.3; }
.chip-name { font-weight: 500; }
.chip-sub { color: var(--faint); font-size: .75rem; }

/* Icon rail */

:root[data-sidebar="icons"] .window { grid-template-columns: 4.5rem minmax(0, 1fr); }
:root[data-sidebar="icons"] .sidebar { padding-inline: .625rem; }
:root[data-sidebar="icons"] .nav-item,
:root[data-sidebar="icons"] .profile-chip { justify-content: center; padding-inline: 0; }
:root[data-sidebar="icons"] .brand { justify-content: center; padding: 0; }
:root[data-sidebar="icons"] .nav-label,
:root[data-sidebar="icons"] .brand-text,
:root[data-sidebar="icons"] .chip-text,
:root[data-sidebar="icons"] .profile-chip .icon {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
:root[data-sidebar="icons"] .nav-group { height: 1px; margin: .625rem .375rem; padding: 0; overflow: hidden; background: var(--line); color: transparent; }
:root[data-sidebar="icons"] .nav-group:first-child { display: none; }
:root[data-sidebar="icons"] .profile-chip { position: relative; }

/* Tooltips for icon-only controls */

:root[data-tooltips="on"] .wc:is(:hover, :focus-visible)::after,
:root[data-tooltips="on"] #save-config:not(.is-saved):is(:hover, :focus-visible)::after,
:root[data-tooltips="on"] .more-btn:not([aria-expanded="true"]):is(:hover, :focus-visible)::after {
  content: attr(data-tip);
  position: absolute;
  z-index: 10;
  padding: .3125rem .5625rem;
  border: 1px solid var(--module-line);
  border-radius: var(--r-chip);
  background: rgb(36 32 42 / .9);
  -webkit-backdrop-filter: blur(12px);
          backdrop-filter: blur(12px);
  box-shadow: 0 .5rem 1.25rem rgb(0 0 0 / .45);
  color: var(--text);
  font-size: .75rem;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
}
:root[data-tooltips="on"] .wc:is(:hover, :focus-visible)::after { top: calc(100% + .375rem); right: .25rem; }
:root[data-tooltips="on"] #save-config:not(.is-saved):is(:hover, :focus-visible)::after { top: calc(100% + .5rem); left: -1px; }
:root[data-tooltips="on"] .more-btn:not([aria-expanded="true"]):is(:hover, :focus-visible)::after { right: 0; bottom: calc(100% + .375rem); }

@media (min-width: 768px) {
  :root[data-tooltips="on"][data-sidebar="icons"] :is(.nav-item, .profile-chip):is(:hover, :focus-visible)::after {
    content: attr(data-tip);
    position: absolute;
    z-index: 10;
    top: 50%;
    left: calc(100% + .625rem);
    padding: .3125rem .5625rem;
    border: 1px solid var(--module-line);
    border-radius: var(--r-chip);
    background: rgb(36 32 42 / .9);
    -webkit-backdrop-filter: blur(12px);
            backdrop-filter: blur(12px);
    box-shadow: 0 .5rem 1.25rem rgb(0 0 0 / .45);
    color: var(--text);
    font-size: .75rem;
    font-weight: 500;
    white-space: nowrap;
    transform: translateY(-50%);
    pointer-events: none;
  }
}

/* Main column: the toolbar over the active category. The active nav item names the category, so the h1 is for screen readers. */

.main {
  grid-area: main;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.main:focus { outline: none; }

.toolbar {
  position: relative;
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem .75rem;
  min-height: var(--bar-h);
  padding: .5rem var(--pad-x);
  border-bottom: 1px solid var(--line);
}

.tools { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; min-width: 0; }
.tool { display: flex; align-items: center; gap: .5rem; }
.toolbar .select-btn { min-width: 7.75rem; height: 2.25rem; }
.toolbar .popover { right: auto; left: 0; transform-origin: 0 0; }

/* Save and the config list share one field, split by a hairline. */
.tool-config {
  gap: 0;
  border: 1px solid var(--module-line);
  border-radius: var(--r-field);
  background: var(--well);
  box-shadow: inset 0 1px 2px rgb(0 0 0 / .35);
  transition: border-color 150ms;
}
.tool-config:has(:is(.btn-icon, .select-btn):hover) { border-color: var(--control-hover); }
.tool-config:has(.select.is-open),
.tool-config:has(.is-saved) { border-color: var(--accent); }
.tool-config .btn-icon,
.tool-config .select-btn { height: calc(2.25rem - 2px); border: 0; background: none; box-shadow: none; }
.tool-config .btn-icon { padding: 0 .6875rem; border-right: 1px solid var(--module-line); border-radius: calc(var(--r-field) - 1px) 0 0 calc(var(--r-field) - 1px); }
.tool-config .btn-icon:hover { background: rgb(255 255 255 / .05); }
.tool-config .select-btn { border-radius: 0 calc(var(--r-field) - 1px) calc(var(--r-field) - 1px) 0; }
/* The word stays readable to screen readers; it shows only while "Saved" confirms the click. */
.tool-config .btn-icon:not(.is-saved) #save-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Search: an icon at the end of the toolbar that opens into a field while focused or filled. */
.search {
  position: relative;
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  width: 2.25rem;
  height: 2.25rem;
  margin-left: auto;
  border: 1px solid transparent;
  border-radius: var(--r-field);
  color: var(--muted);
  cursor: pointer;
  transition: border-color 150ms, background-color 150ms, color 150ms;
}
.search::before { content: ""; position: absolute; inset: -.25rem; }
.search:hover { background: var(--lift); color: var(--text); }
.search:focus-within,
.search:has(input:not(:placeholder-shown)) {
  justify-content: flex-start;
  width: 15rem;
  padding: 0 .375rem 0 .75rem;
  border-color: var(--module-line);
  background: var(--well);
  box-shadow: inset 0 1px 2px rgb(0 0 0 / .4);
  color: var(--faint);
  cursor: text;
}
.search:has(input:focus-visible) { border-color: var(--accent); outline: 2px solid var(--accent); outline-offset: 2px; }
.search input {
  flex: 0 0 0;
  width: 0;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  outline: none;
  box-shadow: none;
}
.search input::placeholder { color: var(--faint); opacity: 1; }
.search input::-webkit-search-cancel-button { display: none; }
.search:focus-within input,
.search:has(input:not(:placeholder-shown)) input { flex: 1; }
.search kbd { display: none; min-width: 1.5rem; height: 1.375rem; padding: 0 .375rem; }
.search:focus-within kbd { display: inline-grid; }
.search:has(input:not(:placeholder-shown)) kbd { visibility: hidden; }

/* Category views: two independent columns of modules */

.views {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: .875rem var(--pad-x) 1rem;
  scrollbar-width: thin;
  container: views / inline-size;
}
.view { display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; gap: var(--module-gap); }
.col { display: flex; flex-direction: column; gap: var(--stack-gap); min-width: 0; }
.mount { display: contents; }

@container views (min-width: 44rem) {
  .view { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .view-skins { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
  .view-scripts { grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); align-items: stretch; }
}

/* Modules: a small uppercase label above a raised panel. The panel carries the surface; rows sit on it split by faint lines. */

.group { position: relative; transition: opacity 150ms; }
.group:has(.is-open) { z-index: 3; }
.group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  min-height: 1.5rem;
  margin-bottom: .375rem;
  padding: 0 .25rem;
}
.group-title {
  margin: 0;
  color: var(--faint);
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .08em;
  line-height: 1.3;
  text-transform: uppercase;
}
.group-title:focus { outline: none; }
.group-meta { overflow: hidden; color: var(--faint); font-size: .75rem; text-overflow: ellipsis; white-space: nowrap; }
.panel {
  padding: .125rem 1rem;
  border: 1px solid var(--module-line);
  border-radius: var(--r-module);
  background: var(--module);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / .065),
    0 1px 2px rgb(0 0 0 / .35),
    0 .75rem 1.75rem -.5rem rgb(0 0 0 / .35);
  transition: border-radius 150ms;
}
.panel .row + .row:not(.popover .row) { border-top: 1px solid var(--row-line); }

/* Rows: label left, controls right, one line each */

.row {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .375rem .75rem;
  min-height: var(--row-min);
  padding-block: .25rem;
  transition: opacity 150ms;
}
.row > :last-child:not(.row-text) { margin-left: auto; }
.row-text { display: flex; flex: 1 1 8rem; flex-direction: column; justify-content: center; min-width: 0; }
.row-label { color: var(--label); font-size: .8125rem; font-weight: 500; line-height: 1.35; }
.row-note { display: none; color: var(--faint); font-size: .75rem; }
.is-disabled .row-label { color: var(--muted); }
.is-disabled .row-note { display: block; }

/* Control row system, piloted on Ragebot: a view opts in with .ctl-rows.
   Every row is 48px: label left, control right. Fields (selects, key binds, sliders) share one control column,
   so their left edges line up down the panel; switches and segmented controls keep their width at the right edge.
   A ••• button sits just left of its control. */
.ctl-rows {
  --row-min: 3rem;
  --row-pad: .25rem;
  --row-line: rgb(255 255 255 / .04);
  --ctl-w: clamp(9.5rem, 50%, 16rem); /* % of the row */
  --ctl-gap: .75rem;
  --more-gap: .375rem; /* the dots sit 9px inside their 32px box, so the visible gap matches the slider's track-to-value gap */
}
:root[data-density="compact"] .ctl-rows { --row-min: 2.625rem; --row-pad: .125rem; }
.ctl-rows .row { gap: .375rem var(--ctl-gap); padding-block: var(--row-pad); }
.ctl-rows .row-text { flex-basis: 6rem; }
.ctl-rows .row > .more { margin-right: calc(var(--more-gap) - var(--ctl-gap)); }
.ctl-rows .row > :is(.select:not(.more), .keybind, .range) { width: var(--ctl-w); }
.ctl-rows .row > .select:not(.more) > .select-btn { width: 100%; max-width: none; }
/* The track starts on the column edge (the thumb overhangs it at zero); a fixed value chip anchors the right edge. */
.ctl-rows .range-box { margin-left: -.5rem; }
.ctl-rows .range-value { flex: none; width: 3.75rem; }

/* Control type, sized to the 48px row the way the reference sizes it: label cap height about a quarter of the row,
   field text (selects, key binds, segments) the same size as the label, numbers a step smaller. Regular weights;
   only the rows themselves change, ••• panels and lists keep theirs. */
.ctl-rows {
  --t-label: 1rem;
  --t-field: 1rem;
  --t-value: .875rem;
  --w-label: 400;
  --w-field: 400;
  --w-value: 450;
}
.ctl-rows .panel > .row > .row-text > .row-label { font-size: var(--t-label); font-weight: var(--w-label); line-height: 1.3; }
.ctl-rows .panel > .row > .select:not(.more) > .select-btn,
.ctl-rows .panel > .row > .keybind,
.ctl-rows .panel > .row > .seg span { font-size: var(--t-field); font-weight: var(--w-field); letter-spacing: 0; line-height: 1.4; }
/* Archivo's width axis narrows the numbers a little so "1000 ms" keeps air inside the fixed 60px chip. */
.ctl-rows .panel > .row > .range .range-value { font-size: var(--t-value); font-weight: var(--w-value); font-stretch: 92%; }

/* Row selects, built like the reference's: a 30px field raised a step above the panel (not sunk into it),
   a near-invisible rim with a lit top edge, 6px corners, 8px of inset, and a chevron as bright as the text.
   Open keeps the accent rim and the turned chevron; focus keeps the global ring. */
.ctl-rows .panel > .row > .select:not(.more) > .select-btn {
  height: 1.875rem;
  padding: 0 .375rem 0 .5rem;
  border-color: rgb(255 255 255 / .018);
  border-radius: var(--r-chip);
  background: rgb(255 255 255 / .03);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .025);
  color: var(--label);
}
.ctl-rows .panel > .row > .select:not(.more) > .select-btn .icon { width: 1.25rem; height: 1.25rem; color: var(--label); stroke-width: 2.2; }
.ctl-rows .panel > .row > .select:not(.more) > .select-btn:hover { border-color: rgb(255 255 255 / .04); background: rgb(255 255 255 / .065); color: var(--text); }
.ctl-rows .panel > .row > .select:not(.more) > .select-btn:hover .icon { color: var(--text); }
.ctl-rows .panel > .row > .select.is-open:not(.more) > .select-btn { border-color: var(--accent); background: rgb(255 255 255 / .07); color: var(--text); }
.ctl-rows .panel > .row > .select.is-open:not(.more) > .select-btn .icon { color: var(--accent); }
/* The open list matches its field: same corners, option text at the field's size and on the field's 8px inset. */
.ctl-rows .panel > .row > .select:not(.more) > .popover { padding: .25rem; border-radius: var(--r-chip); }
.ctl-rows .panel > .row > .select:not(.more) .option { padding: 0 .375rem 0 .25rem; border-radius: 4px; font-size: var(--t-field); font-weight: var(--w-field); }

/* Row single-selects (pilot): the list floats as wide as its field and centred on it (app.js places it), in the panel's
   own tone with a faint rim and a soft shadow. Options are 36px; the one under the pointer gets a soft fill, the chosen
   one brighter text. No checkmark: in the reference the selection is carried by the text alone. */
.ctl-rows .panel > .row > :is(.select-single, .select-multi):not(.more) > .popover {
  right: auto;
  bottom: auto;
  left: 0;
  min-width: 0;
  max-width: none;
  padding: .625rem .5625rem;
  border: 1px solid rgb(255 255 255 / .05);
  border-radius: var(--r-card);
  background: rgb(var(--surface) / .97);
  -webkit-backdrop-filter: blur(20px) saturate(1.15);
          backdrop-filter: blur(20px) saturate(1.15);
  box-shadow: 0 .75rem 1.75rem rgb(0 0 0 / .5);
  transform-origin: 50% 50%;
}
.ctl-rows .panel > .row > :is(.select-single, .select-multi):not(.more) .options { gap: .1875rem; }
.ctl-rows .panel > .row > :is(.select-single, .select-multi):not(.more) .option { min-height: 2.25rem; padding: 0 .875rem; border-radius: var(--r-chip); color: var(--muted); }
.ctl-rows .panel > .row > :is(.select-single, .select-multi):not(.more) .option:hover { background: rgb(255 255 255 / .05); color: var(--label); }
.ctl-rows .panel > .row > :is(.select-single, .select-multi):not(.more) .option:has(input:checked) { color: var(--text); }
.ctl-rows .panel > .row > .select-single:not(.more) .tick { display: none; }
/* Row multi-selects (pilot: Zones) share that list, grown to fit the longest option, and add the reference's checkmark
   column on the left: always reserved so labels never shift, drawn in the accent on the options that are on. */
.ctl-rows .panel > .row > .select-multi:not(.more) .option { gap: .625rem; padding-left: .625rem; white-space: nowrap; }
.ctl-rows .panel > .row > .select-multi:not(.more) .tick { order: -1; width: 1rem; height: 1rem; margin: 0; color: var(--accent); stroke-width: 2.6; }
/* While its field shows a tooltip or its list is open, the row lights edge to edge across the panel, as in the reference. */
.ctl-rows .panel > .row:is(.is-hinted, :has(> :is(.select-single, .select-multi).is-open))::before {
  content: "";
  position: absolute;
  inset: 0 -1rem;
  background: rgb(255 255 255 / .03);
  pointer-events: none;
}
.ctl-rows .panel > .row:is(.is-hinted, :has(> :is(.select-single, .select-multi).is-open)):first-child::before { border-radius: calc(var(--r-module) - 1px) calc(var(--r-module) - 1px) 0 0; }
.ctl-rows .panel > .row:is(.is-hinted, :has(> :is(.select-single, .select-multi).is-open)):last-child::before { border-radius: 0 0 calc(var(--r-module) - 1px) calc(var(--r-module) - 1px); }

/* Search: rows that do not match fade, catalog items and scripts that do not match hide. */
.row.is-filtered { opacity: .3; }
.group.is-filtered { opacity: .45; }
.group.is-filtered .row.is-filtered { opacity: 1; }

/* Switch: native checkbox. Recessed track with a grey thumb off; filled accent track and a white thumb on. */

.switch {
  position: relative;
  flex: none;
  width: 2.75rem;
  height: 1.5rem;
  margin: 0;
  border: 1px solid var(--module-line);
  border-radius: 999px;
  background: var(--well);
  box-shadow: inset 0 1px 3px rgb(0 0 0 / .5);
  cursor: pointer;
  appearance: none;
  transition: background-color 200ms var(--ease-out), border-color 200ms, box-shadow 200ms;
}
.switch::before {
  content: "";
  position: absolute;
  top: 50%;
  left: .125rem;
  width: 1.125rem;
  height: 1.125rem;
  margin-top: -.5625rem;
  border-radius: 50%;
  background: var(--knob);
  box-shadow: 0 1px 3px rgb(0 0 0 / .5), inset 0 1px 0 rgb(255 255 255 / .22);
  transition: transform 200ms var(--ease-out), background-color 200ms;
}
.switch::after { content: ""; position: absolute; inset: -.625rem -.375rem; }
.switch:hover:not(:checked):not(:disabled) { border-color: var(--control-hover); }
.switch:active::before { transform: scale(.9); }
.switch:checked {
  border-color: transparent;
  background: var(--accent);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / .3),
    inset 0 -1px 0 rgb(0 0 0 / .15),
    0 0 calc(.75rem * var(--glow)) color-mix(in srgb, var(--accent) calc(var(--glow-mix) * .7), transparent);
}
.switch:checked::before {
  transform: translateX(1.25rem);
  background: #fff;
  box-shadow: 0 1px 3px rgb(0 0 0 / .45);
}
.switch:checked:active::before { transform: translateX(1.25rem) scale(.9); }
.switch:disabled { cursor: not-allowed; opacity: .55; }

/* Segmented control: native radios in a recessed well; the choice is lifted and underlined. */

.seg {
  display: inline-flex;
  flex: none;
  gap: .125rem;
  padding: .1875rem;
  border: 1px solid var(--module-line);
  border-radius: var(--r-control);
  background: var(--well);
  box-shadow: inset 0 1px 2px rgb(0 0 0 / .4);
}
.seg label { position: relative; }
.seg label::before { content: ""; position: absolute; inset: -.5rem 0; }
.seg input { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.seg span {
  position: relative;
  display: block;
  min-width: 3rem;
  padding: .25rem .6875rem;
  border-radius: var(--r-control);
  color: var(--muted);
  font-weight: 500;
  text-align: center;
  white-space: nowrap;
  transition: color 150ms, background-color 150ms, box-shadow 150ms;
}
.seg span::after,
.profile-name::after,
.tile-name::after,
.script-name::after {
  content: "";
  position: absolute;
  right: .6875rem;
  bottom: .125rem;
  left: .6875rem;
  height: 1px;
  background: var(--accent);
  box-shadow: 0 0 calc(.375rem * var(--glow)) color-mix(in srgb, var(--accent) var(--glow-mix), transparent);
  transform: scaleX(0);
  transition: transform 150ms var(--ease-out);
}
.seg label:hover span { color: var(--text); }
.seg input:checked + span {
  background: var(--lift);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .08), 0 1px 2px rgb(0 0 0 / .45);
  color: var(--text);
}
.seg input:checked + span::after { transform: scaleX(1); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Range: native input over a recessed 4px track; the fill is a scaled lavender bar, the value sits beside it. */

.range { display: flex; flex: none; align-items: center; gap: .5rem; width: max(10rem, min(13.5rem, 56%)); }
/* The input is 44px tall for the pointer but takes 28px of the row. */
.range-box { position: relative; flex: 1; height: 2.75rem; margin-block: -.5rem; }
.range-track {
  position: absolute;
  top: 50%;
  right: .5rem;
  left: .5rem;
  height: 4px;
  margin-top: -2px;
  overflow: hidden;
  border-radius: 2px;
  background: var(--well);
  box-shadow: inset 0 1px 1px rgb(0 0 0 / .5);
}
.range-fill {
  position: absolute;
  inset: 0;
  background: var(--accent);
  transform: scaleX(var(--p, .5));
  transform-origin: 0 50%;
  transition: background-color 150ms;
}
.range input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  background: none;
  cursor: pointer;
  appearance: none;
}
.range input::-webkit-slider-runnable-track { height: 100%; background: none; }
.range input::-moz-range-track { background: none; }
.range input::-webkit-slider-thumb {
  width: 1rem;
  height: 1rem;
  margin-top: .875rem;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow:
    0 1px 3px rgb(0 0 0 / .55),
    0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent),
    0 0 calc(.5rem * var(--glow)) color-mix(in srgb, var(--accent) var(--glow-mix), transparent);
  appearance: none;
  transition: box-shadow 150ms;
}
.range input::-moz-range-thumb {
  width: 1rem;
  height: 1rem;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow:
    0 1px 3px rgb(0 0 0 / .55),
    0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent),
    0 0 calc(.5rem * var(--glow)) color-mix(in srgb, var(--accent) var(--glow-mix), transparent);
}
.range input:hover::-webkit-slider-thumb { box-shadow: 0 1px 3px rgb(0 0 0 / .55), 0 0 0 4px color-mix(in srgb, var(--accent) 40%, transparent); }
.range input:hover::-moz-range-thumb { box-shadow: 0 1px 3px rgb(0 0 0 / .55), 0 0 0 4px color-mix(in srgb, var(--accent) 40%, transparent); }
.range input:focus-visible { outline-offset: -.375rem; border-radius: var(--r-chip); }
.range-value {
  min-width: 3.375rem;
  padding: .1875rem .375rem;
  border-radius: var(--r-chip);
  background: var(--well);
  box-shadow: inset 0 1px 2px rgb(0 0 0 / .35);
  color: var(--text);
  font-size: .75rem;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
}
.is-disabled .range input { cursor: not-allowed; }
.is-disabled .range-fill { background: var(--faint); }
.is-disabled .range input::-webkit-slider-thumb { background: var(--knob); box-shadow: 0 1px 3px rgb(0 0 0 / .5); }
.is-disabled .range input::-moz-range-thumb { background: var(--knob); box-shadow: 0 1px 3px rgb(0 0 0 / .5); }
.is-disabled .range-value { color: var(--faint); }

/* Dropdowns and "more" menus: a recessed field that opens a glass list */

.select { position: relative; flex: none; }
.select-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  min-width: 8.5rem;
  max-width: 13rem;
  height: 2rem;
  padding: 0 .5rem 0 .75rem;
  border: 1px solid var(--module-line);
  border-radius: var(--r-field);
  background: var(--well);
  box-shadow: inset 0 1px 2px rgb(0 0 0 / .35);
  color: var(--text);
  font-weight: 500;
  cursor: pointer;
  transition: border-color 150ms, background-color 150ms;
}
.select-btn::before { content: ""; position: absolute; inset: -.375rem 0; }
.select-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.select-btn .icon { color: var(--faint); transition: transform 150ms var(--ease-out), color 150ms; }
.select-btn:hover { border-color: var(--control-hover); }
.select.is-open .select-btn { border-color: var(--accent); }
.select.is-open .select-btn .icon { color: var(--accent); transform: rotate(180deg); }

.more-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--r-field);
  background: none;
  color: var(--faint);
  cursor: pointer;
  transition: background-color 150ms, color 150ms, border-color 150ms;
}
.more-btn::before { content: ""; position: absolute; inset: -.375rem -.125rem; }
.more-btn:hover { background: var(--lift); color: var(--text); }
.select.is-open .more-btn { border-color: var(--accent); color: var(--accent); }

.popover {
  position: absolute;
  top: calc(100% + .375rem);
  right: 0;
  z-index: 8;
  min-width: 100%;
  width: max-content;
  max-width: 16rem;
  padding: .3125rem;
  border: 1px solid var(--module-line);
  border-radius: var(--r-card);
  background: rgb(36 32 42 / .9);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
          backdrop-filter: blur(16px) saturate(1.2);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .07), 0 1rem 2.5rem rgb(0 0 0 / .55);
  transform-origin: 100% 0;
}
.popover.up { top: auto; bottom: calc(100% + .375rem); transform-origin: 100% 100%; }
.toolbar .popover.up { transform-origin: 0 100%; }
.more .popover { min-width: 11rem; }
.options-hint { max-width: 15rem; margin: 0; padding: .375rem .5rem .5rem; color: var(--faint); font-size: .75rem; white-space: normal; }
.options { display: grid; gap: .0625rem; }
.option {
  position: relative;
  display: flex;
  align-items: center;
  gap: .75rem;
  min-height: 2.75rem;
  padding: 0 .5rem 0 .625rem;
  border-radius: calc(var(--r-card) - 2px);
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 150ms, color 150ms;
}
.option input { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.option:hover { background: rgb(255 255 255 / .05); color: var(--text); }
.option .tick { margin-left: auto; color: var(--accent); opacity: 0; }
.option:has(input:checked) { color: var(--text); }
.option:has(input:checked) .tick { opacity: 1; }
.option:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Key binds, number and text fields */

.keybind {
  position: relative;
  flex: none;
  min-width: 5.5rem;
  height: 2rem;
  padding: 0 .75rem;
  border: 1px solid var(--module-line);
  border-radius: var(--r-field);
  background: var(--well);
  box-shadow: inset 0 1px 2px rgb(0 0 0 / .35);
  color: var(--text);
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 150ms, color 150ms;
}
.keybind::before { content: ""; position: absolute; inset: -.375rem 0; }
.keybind:hover { border-color: var(--control-hover); }
.keybind.is-listening { border-color: var(--accent); color: var(--accent); }

.field-input {
  flex: none;
  width: 8.5rem;
  height: 2rem;
  padding: 0 .625rem;
  border: 1px solid var(--module-line);
  border-radius: var(--r-field);
  background: var(--well);
  box-shadow: inset 0 1px 2px rgb(0 0 0 / .35);
  color: var(--text);
  transition: border-color 150ms;
}
.field-input[type="number"] { width: 5.5rem; }
.field-input::placeholder { color: var(--faint); opacity: 1; }
.field-input:hover { border-color: var(--control-hover); }
.field-input:focus-visible { border-color: var(--accent); outline-offset: 1px; }

/* Buttons */

.btn {
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: .5rem;
  height: 2rem;
  padding: 0 .875rem;
  border: 1px solid var(--module-line);
  border-radius: var(--r-control);
  background: var(--lift);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .07), 0 1px 2px rgb(0 0 0 / .35);
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 150ms, background-color 150ms;
}
.btn::before { content: ""; position: absolute; inset: -.375rem 0; }
.btn:hover:not(:disabled) { border-color: var(--control-hover); background: rgb(255 255 255 / .1); }
.btn:disabled { color: var(--faint); background: var(--module); box-shadow: none; cursor: not-allowed; }

.text-btn {
  position: relative;
  padding: .5rem .25rem;
  border: 0;
  background: none;
  color: var(--muted);
  font-weight: 500;
  cursor: pointer;
}
.text-btn::before { content: ""; position: absolute; inset: -.25rem -.5rem; }
.text-btn:hover:not(:disabled) { color: var(--text); }
.text-btn:disabled { color: var(--faint); cursor: default; }

.badge, .pill {
  display: inline-flex;
  flex: none;
  align-items: center;
  height: 1.375rem;
  padding: 0 .5rem;
  border-radius: var(--r-chip);
  background: var(--lift);
  color: var(--muted);
  font-size: .75rem;
  font-weight: 500;
  white-space: nowrap;
}
.pill { background: color-mix(in srgb, var(--accent) 22%, rgb(var(--ground))); color: var(--text); }
.limit-note { margin: 0 0 .5rem; color: var(--faint); font-size: .75rem; }

/* Legitbot response curve */

.curve {
  position: relative;
  height: 6.5rem;
  margin: .25rem 0 .625rem;
  border: 1px solid var(--module-line);
  border-radius: var(--r-card);
  background: var(--well);
  box-shadow: inset 0 1px 2px rgb(0 0 0 / .35);
}
.curve svg { position: absolute; top: .625rem; left: .75rem; width: calc(100% - 1.5rem); height: calc(100% - 1.25rem); overflow: visible; }
.curve-grid { fill: none; stroke: rgb(255 255 255 / .06); stroke-width: 1; vector-effect: non-scaling-stroke; }
.curve-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.curve span { position: absolute; color: var(--faint); font-size: .75rem; line-height: 1; }
.curve span:first-of-type { right: .75rem; bottom: .5rem; }
.curve span:last-of-type { top: .5rem; left: .75rem; }

/* Visual selectors: UI scale and sidebar shown as tiles over the same radios */

.tiles { display: flex; flex: none; gap: .375rem; }
.tile {
  position: relative;
  display: grid;
  gap: .25rem;
  width: 4.25rem;
  padding: .3125rem .3125rem .1875rem;
  border: 1px solid var(--module-line);
  border-radius: var(--r-card);
  background: var(--well);
  cursor: pointer;
  transition: border-color 150ms, background-color 150ms, box-shadow 150ms;
}
.tile input { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.tile:hover { border-color: var(--control-hover); }
.tile:has(input:checked) {
  border-color: var(--accent);
  background: var(--module-hover);
  box-shadow: 0 0 calc(.75rem * var(--glow)) color-mix(in srgb, var(--accent) calc(var(--glow-mix) * .45), transparent);
}
.tile:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.tile-art {
  display: grid;
  place-items: center;
  height: 2.25rem;
  border-radius: calc(var(--r-card) - 3px);
  background: rgb(0 0 0 / .28);
  box-shadow: inset 0 1px 2px rgb(0 0 0 / .45);
}
.tile-aa { color: var(--text); font-size: calc(1.0625rem * var(--s)); font-weight: 600; line-height: 1; }
.tile-name { position: relative; justify-self: center; padding-bottom: .125rem; color: var(--muted); font-size: .75rem; font-weight: 500; line-height: 1.3; transition: color 150ms; }
.tile-name::after { right: 0; bottom: 0; left: 0; }
.tile input:checked ~ .tile-name { color: var(--text); }
.tile input:checked ~ .tile-name::after { transform: scaleX(1); }

.tile-side { display: flex; place-items: stretch; gap: 3px; padding: 4px; }
.ts-rail, .ts-body { display: grid; align-content: start; gap: 3px; padding: 3px; border-radius: 2px; }
.ts-rail { width: 40%; background: rgb(255 255 255 / .07); }
.ts-body { flex: 1; background: rgb(255 255 255 / .03); }
.ts-rail i { height: 3px; border-radius: 2px; background: rgb(255 255 255 / .22); }
.ts-rail i:first-child { background: var(--accent); }
.ts-body i { height: 5px; border-radius: 2px; background: rgb(255 255 255 / .1); }
.is-rail .ts-rail { width: 20%; justify-items: center; }
.is-rail .ts-rail i { width: 4px; height: 4px; border-radius: 50%; }

/* Session log and keyboard list */

.log { margin: 0; padding: .125rem 0; list-style: none; }
.log li { display: flex; align-items: baseline; gap: .75rem; min-width: 0; padding: .375rem 0; }
.log-what { flex: none; color: var(--muted); }
.log-value { overflow: hidden; color: var(--text); font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.log-time { flex: none; margin-left: auto; color: var(--faint); font-size: .75rem; }
.log-more { color: var(--faint); }
.empty { margin: 0; padding: .625rem 0; color: var(--muted); }

.keys { margin: 0; }
.keys dt { color: var(--label); font-size: .8125rem; font-weight: 500; }
.keys dd { display: flex; align-items: center; gap: .375rem; margin: 0; color: var(--faint); }
kbd {
  display: inline-grid;
  place-items: center;
  min-width: 1.875rem;
  height: 1.625rem;
  padding: 0 .5rem;
  border: 1px solid var(--module-line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--lift);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .07);
  color: var(--text);
  font: inherit;
  font-size: .75rem;
  font-weight: 600;
}

/* Page tabs: Visuals and Skins split into sections, each with its own composition */

.view.tabbed { display: flex; flex-direction: column; align-items: stretch; gap: var(--module-gap); }
.page-tabs .seg { align-self: flex-start; }
.page-tabs { display: flex; align-items: center; gap: .75rem; }
.tab-pane { display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; gap: var(--module-gap); }

@container views (min-width: 44rem) {
  .tab-pane { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tab-pane.has-preview { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, .8fr); }
  .pane-skins { grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); }
}
@container views (min-width: 44rem) and (max-width: 62rem) {
  .tab-pane.has-preview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tab-pane.has-preview > .col-preview { grid-column: 1 / -1; }
  .col-preview .vis-stage { aspect-ratio: 16 / 9; }
}

/* Visuals preview: a sample figure or object that shows the highlight, label and bar settings */

.vis-stage {
  position: relative;
  aspect-ratio: 3 / 4;
  margin: .5rem 0 .375rem;
  overflow: hidden;
  border: 1px solid var(--module-line);
  border-radius: var(--r-card);
  background:
    radial-gradient(80% 55% at 50% 100%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%),
    #100d13;
  font-size: .75rem;
}
.vis-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgb(255 255 255 / .03) 1px, transparent 1px),
    linear-gradient(90deg, rgb(255 255 255 / .03) 1px, transparent 1px);
  background-size: 1.5rem 1.5rem;
}
.vis-subject {
  position: absolute;
  inset: 20% 16% 12%;
  opacity: var(--op, 1);
  transition: opacity 150ms, filter 150ms;
}
.vis-shape {
  position: absolute;
  inset: 0;
  background: #3a3341;
  -webkit-mask: var(--mark) center / contain no-repeat;
          mask: var(--mark) center / contain no-repeat;
  transition: background-color 150ms;
}
.vis-stage[data-kind="entities"] .vis-subject { inset: 34% 30% 24%; }
.vis-stage[data-kind="entities"] .vis-shape { inset: 14%; border-radius: 6px; -webkit-mask: none; mask: none; transform: rotate(45deg); }
.vis-stage[data-style="fill"] .vis-shape,
.vis-stage[data-style="both"] .vis-shape { background: color-mix(in srgb, var(--accent) var(--fill, 35%), #3a3341); }
.vis-stage[data-style="outline"] .vis-subject,
.vis-stage[data-style="both"] .vis-subject {
  filter:
    drop-shadow(var(--t, 1.5px) 0 0 var(--hl, var(--accent)))
    drop-shadow(calc(var(--t, 1.5px) * -1) 0 0 var(--hl, var(--accent)))
    drop-shadow(0 var(--t, 1.5px) 0 var(--hl, var(--accent)))
    drop-shadow(0 calc(var(--t, 1.5px) * -1) 0 var(--hl, var(--accent)));
}
.vis-stage[data-edges="on"]:not([data-style="off"]) .vis-subject { filter: drop-shadow(0 0 .5rem var(--hl, var(--accent))); }
.vis-label {
  position: absolute;
  top: 9%;
  left: 50%;
  display: flex;
  align-items: center;
  gap: .375rem;
  font-size: var(--ts, .75rem);
  white-space: nowrap;
  translate: -50% 0;
}
.vis-stage[data-pos="below"] .vis-label { top: auto; bottom: 3.5%; }
.vis-label b { color: var(--text); font-weight: 600; }
.vis-label em { padding: 0 .3125rem; border-radius: 3px; background: color-mix(in srgb, var(--accent) 28%, transparent); color: var(--text); font-style: normal; font-weight: 600; }
.vis-bar { position: absolute; top: 20%; bottom: 12%; left: 9%; width: 4px; overflow: hidden; border-radius: 2px; background: rgb(0 0 0 / .5); }
.vis-stage[data-bar="right"] .vis-bar { right: 9%; left: auto; }
.vis-bar i { position: absolute; inset: 30% 0 0; border-radius: 2px; background: var(--accent); }
.vis-dist { position: absolute; right: .625rem; bottom: .5rem; color: var(--muted); }
.vis-marker { position: absolute; top: 18%; left: 50%; width: .75rem; height: .75rem; border: 1.5px solid var(--accent); transform: translateX(-50%) rotate(45deg); }

/* Settings: a compact floating window over the menu, opened from the profile row */

.settings {
  position: absolute;
  bottom: 4.75rem;
  left: .75rem;
  z-index: 9;
  display: grid;
  gap: .5rem;
  width: 21rem;
  padding: 0 .5rem .5rem;
  border: 1px solid var(--module-line);
  border-radius: var(--r-module);
  background: rgb(var(--ground) / .9);
  -webkit-backdrop-filter: blur(20px) saturate(1.15);
          backdrop-filter: blur(20px) saturate(1.15);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .07), 0 1.25rem 3rem rgb(0 0 0 / .6);
}
.settings-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 2.5rem;
  margin: 0 -.5rem;
  padding: 0 .25rem 0 .875rem;
  border-bottom: 1px solid var(--line);
  border-radius: calc(var(--r-module) - 1px) calc(var(--r-module) - 1px) 0 0;
  background: rgb(0 0 0 / .22);
}
.settings-title { font-size: .8125rem; font-weight: 600; }
.settings-title:focus { outline: none; }
.settings-close {
  position: relative;
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 0;
  border-radius: var(--r-field);
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.settings-close::before { content: ""; position: absolute; inset: -.25rem; }
.settings-close:hover { background: rgb(255 255 255 / .07); color: var(--text); }
.settings .group-head { margin-bottom: .25rem; }
.settings .panel { padding: 0 .75rem; }
.settings .row { min-height: 2.5rem; }
.settings .row-text { flex-basis: 5.5rem; }
.settings .select-btn { min-width: 9.5rem; max-width: 10.5rem; }

/* Accent picker: solid colors only (saturation and brightness area, hue strip, hex field) */

.color-select .popover { width: 15rem; max-width: 15rem; padding: .625rem; }
.accent-btn { justify-content: flex-start; }
.accent-btn .select-value { flex: 1; font-family: var(--mono); font-size: .75rem; }
.accent-dot { width: .875rem; height: .875rem; flex: none; border-radius: 3px; background: var(--accent); box-shadow: inset 0 0 0 1px rgb(255 255 255 / .2); }
.sv {
  position: relative;
  height: 8.5rem;
  border-radius: var(--r-field);
  background:
    linear-gradient(to top, #000, transparent),
    linear-gradient(to right, #fff, hsl(var(--hue, 285) 100% 50%));
  cursor: crosshair;
  touch-action: none;
}
.sv-dot {
  position: absolute;
  top: calc((1 - var(--v, .5)) * 100%);
  left: calc(var(--s, .5) * 100%);
  width: .875rem;
  height: .875rem;
  margin: -.4375rem;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgb(0 0 0 / .55);
  pointer-events: none;
}
.hue { display: block; width: 100%; height: 1.75rem; margin: .375rem 0 0; background: none; cursor: pointer; appearance: none; }
.hue::-webkit-slider-runnable-track { height: .625rem; border-radius: 999px; background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00); }
.hue::-moz-range-track { height: .625rem; border-radius: 999px; background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00); }
.hue::-webkit-slider-thumb { width: 1rem; height: 1rem; margin-top: -.1875rem; border: 2px solid #fff; border-radius: 50%; background: hsl(var(--hue, 285) 100% 50%); box-shadow: 0 0 0 1px rgb(0 0 0 / .55); appearance: none; }
.hue::-moz-range-thumb { width: .75rem; height: .75rem; border: 2px solid #fff; border-radius: 50%; background: hsl(var(--hue, 285) 100% 50%); box-shadow: 0 0 0 1px rgb(0 0 0 / .55); }
.hue:focus-visible { outline-offset: 0; border-radius: 999px; }
.color-row { display: flex; gap: .5rem; margin-top: .375rem; }
.hex { flex: 1; width: auto; min-width: 0; font-family: var(--mono); font-size: .75rem; text-transform: uppercase; }
.hex[aria-invalid="true"] { border-color: var(--text); border-style: dashed; }
.color-hint { margin: .5rem 0 0; color: var(--faint); font-size: .75rem; }

/* Secondary options: the ••• button opens a small floating panel of compact rows */

.more-pop { width: 16.5rem; max-width: 16.5rem; padding: .25rem .75rem .375rem; }
.more-title {
  margin: 0 -.75rem .25rem;
  padding: .375rem .75rem .5rem;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.more-pop .row { min-height: 2.5rem; }
.more-pop .row-text { flex-basis: 4.5rem; }
.more-pop .range { width: 9rem; }
.more-pop .range-value { min-width: 2.875rem; }

/* Advanced settings panel (pilot: Ragebot > Precision •••). A side sheet beside the ••• button (app.js places it):
   a sentence-case title, then the rows in a recessed inner list with a soft hover, compact bar sliders whose value
   floats above while the row is active, and one tooltip beside the panel describing the row under the pointer. */
.adv-pop {
  right: auto;
  width: 20.5rem;
  max-width: 20.5rem;
  padding: .875rem .625rem .625rem;
  border-radius: var(--r-module);
  background: rgb(var(--surface) / .97);
  -webkit-backdrop-filter: blur(20px) saturate(1.15);
          backdrop-filter: blur(20px) saturate(1.15);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .07), 0 1.5rem 3rem rgb(0 0 0 / .6);
  transform-origin: 0 0;
}
.adv-pop[data-side="left"] { transform-origin: 100% 0; }
.adv-pop .more-title {
  margin: 0;
  padding: 0 .5rem .75rem;
  border: 0;
  color: var(--text);
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.3;
  text-transform: none;
}
.adv-list {
  display: grid;
  gap: .125rem;
  padding: .3125rem;
  border: 1px solid rgb(255 255 255 / .04);
  border-radius: var(--r-card);
  background: rgb(255 255 255 / .015);
}
.adv-pop .adv-list > .row {
  gap: .75rem;
  min-height: 2.5rem;
  padding: .25rem .875rem;
  border-radius: var(--r-chip);
  transition: background-color 100ms;
}
.adv-pop .adv-list > .row:is(:hover, :focus-within) { background: rgb(255 255 255 / .05); }
.adv-pop .adv-list > .row > .row-text { flex-basis: 6rem; }
.adv-pop .adv-list .row-label { font-size: var(--t-label, 1rem); font-weight: var(--w-label, 400); }
/* Bar slider: a 6px track without a visible thumb; the native input stays on top for pointer and keys. */
.adv-pop .adv-list > .row > .range { position: relative; width: 7.25rem; gap: 0; }
.adv-pop .adv-list .range-box { height: 2rem; margin: -.25rem 0; }
.adv-pop .adv-list .range-track { right: 0; left: 0; height: 6px; margin-top: -3px; border-radius: 3px; }
.adv-pop .adv-list .range input::-webkit-slider-thumb { width: 6px; opacity: 0; }
.adv-pop .adv-list .range input::-moz-range-thumb { width: 6px; opacity: 0; }
.adv-pop .adv-list .range-value {
  position: absolute;
  bottom: calc(50% + .5rem);
  left: calc(var(--p, .5) * 100%);
  width: auto;
  min-width: 1.75rem;
  padding: .0625rem .375rem;
  border: 1px solid var(--module-line);
  background: rgb(var(--surface));
  box-shadow: 0 .25rem .75rem rgb(0 0 0 / .45);
  font-size: var(--t-value, .875rem);
  font-weight: var(--w-value, 450);
  translate: -50% 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 100ms;
}
.adv-pop .adv-list > .row:is(:hover, :focus-within) .range-value { opacity: 1; }
.adv-tip, .ctx-tip {
  position: absolute;
  z-index: 1;
  width: 16rem;
  padding: .75rem .875rem .8125rem;
  border: 1px solid var(--module-line);
  border-radius: var(--r-module);
  background: rgb(var(--surface) / .97);
  -webkit-backdrop-filter: blur(20px) saturate(1.15);
          backdrop-filter: blur(20px) saturate(1.15);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .07), 0 1rem 2.5rem rgb(0 0 0 / .55);
  pointer-events: none;
}
.adv-tip-title, .ctx-tip-title { margin: 0 0 .25rem; color: var(--text); font-size: 1rem; font-weight: 600; line-height: 1.3; }
.adv-tip-desc, .ctx-tip-desc { margin: 0; color: var(--muted); font-size: .9375rem; line-height: 1.45; }
/* The field tooltip lives on the page (fixed), so the scroll area never clips it; a quieter shadow than the panels. */
.ctx-tip.field-tip { position: fixed; z-index: 25; box-shadow: inset 0 1px 0 rgb(255 255 255 / .06), 0 .5rem 1.5rem rgb(0 0 0 / .45); }

.swatches { display: flex; flex: none; gap: .375rem; }
.swatch { position: relative; display: grid; place-items: center; width: 1.5rem; height: 1.5rem; cursor: pointer; }
.swatch::before { content: ""; position: absolute; inset: -.625rem -.125rem; }
.swatch input { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.swatch span { width: 1rem; height: 1rem; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgb(255 255 255 / .2); transition: box-shadow 150ms; }
.swatch input:checked + span { box-shadow: 0 0 0 2px rgb(var(--ground)), 0 0 0 3px var(--c); }
.swatch:has(input:focus-visible) { border-radius: 50%; outline: 2px solid var(--accent); outline-offset: 2px; }

/* Toolbar save control */

.btn-icon { height: 2rem; padding: 0 .75rem 0 .625rem; }
.btn-icon .icon { color: var(--faint); }
.btn-icon.is-saved { border-color: var(--accent); }
.btn-icon.is-saved .icon { color: var(--accent); }

/* Watermark and keybind list: floating strips over the stage, like an overlay */

.watermark, .keylist {
  position: fixed;
  z-index: 30;
  border: 1px solid var(--module-line);
  border-radius: var(--r-field);
  background: rgb(var(--ground) / .86);
  -webkit-backdrop-filter: blur(12px);
          backdrop-filter: blur(12px);
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--accent) 70%, transparent), 0 .5rem 1.25rem rgb(0 0 0 / .45);
  color: var(--muted);
  font-size: .75rem;
  font-weight: 500;
  pointer-events: none; /* display only, like an in-game overlay: never blocks the menu */
}
.watermark { top: .75rem; right: .75rem; display: flex; align-items: center; height: 1.875rem; padding: 0 .125rem; white-space: nowrap; }
.wm-field { display: flex; align-items: center; gap: .375rem; padding: 0 .5rem; }
.wm-field:not([hidden]) ~ .wm-field { border-left: 1px solid var(--line); }
.wm-brand { color: var(--text); font-weight: 640; font-stretch: 125%; letter-spacing: .14em; }
.wm-brand i {
  width: .875rem;
  height: .875rem;
  background: var(--accent);
  -webkit-mask: var(--mark) center / contain no-repeat;
          mask: var(--mark) center / contain no-repeat;
}
:root[data-window="max"] .watermark { top: auto; right: .75rem; bottom: .75rem; }
.keylist { top: .75rem; left: .75rem; width: 12.5rem; padding: .375rem .625rem .5rem; }
.keylist-title { margin: 0 0 .25rem; padding-bottom: .375rem; border-bottom: 1px solid var(--line); color: var(--text); font-weight: 600; }
.keylist ul { display: grid; gap: .125rem; margin: 0; padding: 0; list-style: none; }
.keylist li { display: flex; justify-content: space-between; gap: .75rem; }
.keylist li b { color: var(--text); font-weight: 500; }

/* Skins: catalog cards drawn from the winged figure, and a large preview */

.skin-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .5rem;
  min-width: 0;
  margin: 0;
  padding: .375rem 0 .625rem;
  border: 0;
}
@container views (max-width: 56rem) { .skin-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@container views (max-width: 30rem) { .skin-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.skin-card {
  position: relative;
  display: grid;
  overflow: hidden;
  border: 1px solid var(--module-line);
  border-radius: var(--r-card);
  background: var(--well);
  cursor: pointer;
  transition: border-color 150ms, background-color 150ms, box-shadow 200ms;
}
.skin-card input { position: absolute; inset: 0; z-index: 3; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.skin-card:hover { border-color: var(--control-hover); }
.skin-card:has(input:checked) {
  border-color: var(--accent);
  background: var(--module-hover);
  box-shadow: 0 0 calc(.875rem * var(--glow)) color-mix(in srgb, var(--accent) calc(var(--glow-mix) * .5), transparent);
}
.skin-card:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.skin-card.is-filtered, .skin-card.is-kind-hidden { display: none; }
.skin-meta { display: grid; min-width: 0; padding: .4375rem .5625rem .5rem; line-height: 1.35; }
.skin-name { overflow: hidden; color: var(--text); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.skin-kind { color: var(--faint); font-size: .75rem; }
.skin-kind b { color: var(--muted); font-weight: 500; }
.skin-card .skin-eq { position: absolute; top: .3125rem; right: .3125rem; z-index: 2; height: 1.25rem; padding: 0 .375rem; background: rgb(0 0 0 / .55); color: var(--text); }

.skin-art {
  position: relative;
  display: block;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(90% 70% at 50% 110%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%),
    #110e14;
}
.skin-art::before {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 12% 24%;
  background: var(--accent);
  opacity: var(--a);
  -webkit-mask: var(--mark) center / contain no-repeat;
          mask: var(--mark) center / contain no-repeat;
}
.skin-art i { position: absolute; inset: 0; }
.art-halo i, .art-ring i {
  inset: auto;
  top: 50%;
  left: 50%;
  width: 64%;
  aspect-ratio: 1;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 18%, transparent), transparent);
  translate: -50% -50%;
}
.art-ring i { width: 56%; border-width: 2px; border-color: color-mix(in srgb, var(--accent) 70%, transparent); background: none; }
.art-ring::before { inset: 26% 34%; }
.art-wing::before { inset: 6% 14%; }
.art-wing i { background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 20%, transparent), transparent 70%); }
.art-pattern i {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  -webkit-mask: var(--mark) 0 0 / 2rem 2rem space;
          mask: var(--mark) 0 0 / 2rem 2rem space;
}
.art-feather i { background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--accent) 14%, transparent) 0 1px, transparent 1px 9px); }
.art-mist i { background: radial-gradient(60% 60% at 50% 45%, color-mix(in srgb, var(--accent) 32%, transparent), transparent 70%); }
.art-solid i { inset: auto 18% 9%; height: 1px; background: color-mix(in srgb, var(--accent) 45%, transparent); }
.art-duo::before { inset: 16% 50% 16% 8%; }
.art-duo i {
  z-index: 1;
  inset: 16% 8% 16% 50%;
  background: var(--accent);
  opacity: var(--a);
  -webkit-mask: var(--mark) center / contain no-repeat;
          mask: var(--mark) center / contain no-repeat;
  transform: scaleX(-1);
}

.skin-stage { position: relative; margin-top: .5rem; overflow: hidden; border: 1px solid var(--module-line); border-radius: var(--r-card); }
.skin-art.big { aspect-ratio: 16 / 10; }
.skin-art.big::before, .art-duo.big i { opacity: calc(var(--a) * (.35 + .65 * var(--k, .7))); }
.stage-caption { position: absolute; bottom: .625rem; left: .75rem; z-index: 2; display: grid; line-height: 1.3; }
.stage-caption b { color: var(--text); font-size: .9375rem; font-weight: 600; }
.stage-caption span { color: var(--muted); font-size: .75rem; }

.slots { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; padding: .625rem 0 .25rem; }
.slot {
  position: relative;
  display: flex;
  align-items: center;
  gap: .5rem;
  min-width: 0;
  min-height: 3rem;
  padding: .375rem .5rem;
  border: 1px solid var(--module-line);
  border-radius: var(--r-card);
  background: var(--well);
  color: var(--muted);
  text-align: left;
  cursor: pointer;
  transition: border-color 150ms;
}
.slot .skin-art { width: 2.25rem; flex: none; border-radius: 4px; }
.slot-text { display: grid; min-width: 0; line-height: 1.3; }
.slot-kind { color: var(--faint); font-size: .75rem; }
.slot-name { overflow: hidden; color: var(--text); font-size: .75rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.slot:hover { border-color: var(--control-hover); }
.slot[aria-pressed="true"] { border-color: var(--accent); }

/* Shadow side: the same catalog on a darker ground, the figure facing the other way */
.view-skins[data-side="shadow"] .skin-art {
  background:
    radial-gradient(90% 70% at 50% -10%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%),
    #0b090d;
}
.view-skins[data-side="shadow"] .skin-art::before { transform: scaleX(-1); }

/* Scripts: library, read-only editor and console. Nothing here runs. */

.script-list { display: grid; gap: .125rem; padding-block: .25rem; }
.script-item { position: relative; display: flex; align-items: center; gap: .75rem; }
.script-item.is-filtered { display: none; }
.script-pick {
  position: relative;
  display: flex;
  flex: 1;
  align-items: center;
  gap: .625rem;
  min-width: 0;
  min-height: 2.875rem;
  padding: .25rem .625rem;
  border-radius: var(--r-card);
  cursor: pointer;
  transition: background-color 150ms, box-shadow 150ms;
}
.script-pick input { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.script-pick .icon { color: var(--faint); transition: color 150ms; }
.script-pick:hover { background: rgb(255 255 255 / .03); }
.script-pick:has(input:checked) { background: var(--lift); box-shadow: inset 0 1px 0 rgb(255 255 255 / .06), 0 1px 2px rgb(0 0 0 / .3); }
.script-pick:has(input:checked) .icon { color: var(--accent); }
.script-pick:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }
.script-text { display: grid; min-width: 0; line-height: 1.35; }
.script-name { position: relative; justify-self: start; padding-bottom: .125rem; color: var(--text); font-family: var(--mono); font-size: .75rem; }
.script-name::after { right: 0; bottom: 0; left: 0; }
.script-pick input:checked ~ .script-text .script-name::after { transform: scaleX(1); }
.script-desc { overflow: hidden; color: var(--faint); font-size: .75rem; text-overflow: ellipsis; white-space: nowrap; }

.editor { display: flex; flex: 1; flex-direction: column; min-height: 0; }
.code-title { color: var(--text); font-family: var(--mono); letter-spacing: 0; text-transform: none; }
.code-panel { display: flex; flex: 1; min-height: 0; padding: 0; }
.code {
  flex: 1;
  min-height: 12rem;
  margin: 0;
  padding: .75rem .75rem .75rem 0;
  overflow: auto;
  border-radius: 0 0 calc(var(--r-module) - 1px) calc(var(--r-module) - 1px);
  background: rgb(0 0 0 / .24);
  color: var(--muted);
  font: 400 .75rem/1.75 var(--mono);
  counter-reset: ln;
  tab-size: 2;
  scrollbar-width: thin;
}
.code:focus-visible { outline-offset: -2px; }
.code code { font: inherit; }
.ln { position: relative; display: block; padding-left: 3rem; white-space: pre; }
.ln::before { content: counter(ln); counter-increment: ln; position: absolute; left: 0; width: 2rem; color: var(--faint); text-align: right; }
.tok-k { color: var(--accent); }
.tok-f { color: var(--text); }
.tok-s { color: #dccbe5; }
.tok-n { color: #ebe1f1; }
.tok-c { color: var(--faint); font-style: italic; }

.console { margin: 0; padding: .375rem 0 .5rem; list-style: none; color: var(--muted); font: 400 .75rem/1.7 var(--mono); }
.console li { overflow: hidden; padding-left: .625rem; border-left: 1px solid transparent; text-overflow: ellipsis; white-space: nowrap; }
.console li.is-new { border-left-color: var(--accent); color: var(--text); }

/* Closed state */

.closed { position: relative; display: grid; justify-items: center; }
.open-btn {
  display: inline-flex;
  align-items: center;
  gap: .75rem;
  height: 3rem;
  padding: 0 1.25rem 0 .75rem;
  border: 1px solid var(--module-line);
  border-radius: var(--r-control);
  background: rgb(var(--ground) / .85);
  -webkit-backdrop-filter: blur(12px);
          backdrop-filter: blur(12px);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .07), 0 .75rem 2rem rgb(0 0 0 / .45);
  color: var(--text);
  font-size: .9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 150ms;
}
.open-btn:hover { border-color: var(--accent); }

/* Reduced transparency: the glass turns solid. */
@media (prefers-reduced-transparency: reduce) {
  .window { background: rgb(var(--ground)); -webkit-backdrop-filter: none; backdrop-filter: none; }
}

/* Motion levels: app.js sets data-motion-level; transitions that travel stop outside "full". */

:root:not([data-motion-level="full"]) .switch::before,
:root:not([data-motion-level="full"]) .seg span::after,
:root:not([data-motion-level="full"]) .profile-name::after,
:root:not([data-motion-level="full"]) .tile-name::after,
:root:not([data-motion-level="full"]) .script-name::after,
:root:not([data-motion-level="full"]) .select-btn .icon { transition: none; }
:root[data-motion-level="none"] *,
:root[data-motion-level="none"] *::before,
:root[data-motion-level="none"] *::after { transition: none !important; }
@media (prefers-reduced-motion: reduce) {
  .switch::before, .seg span::after, .profile-name::after, .tile-name::after, .script-name::after, .select-btn .icon { transition: none; }
}

/* Medium: the window grows with its content and the page scrolls */

@media (max-width: 1279.98px) {
  body { display: block; padding: 3.25rem 1rem 1rem; }
  .window { height: auto; min-height: calc(100dvh - 2rem); margin: 0 auto; }
  :root[data-window="max"] .window { height: auto; min-height: 100dvh; }
  .sidebar { position: sticky; top: 1rem; align-self: start; min-height: calc(100dvh - 2rem); }
  .toolbar {
    position: sticky;
    top: 0;
    background: rgb(var(--ground) / .94);
    -webkit-backdrop-filter: blur(16px);
            backdrop-filter: blur(16px);
  }
  .views { overflow: visible; }
  .closed { min-height: calc(100dvh - 2rem); align-content: center; }
}

/* Narrow: one column, the categories move to a bottom bar */

@media (max-width: 767.98px) {
  body { padding: 0; }
  :root { --pad-x: 1rem; }
  .window,
  :root[data-sidebar="icons"] .window {
    width: 100%;
    min-height: 100dvh;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto 1fr auto;
    grid-template-areas: "brand" "main" "nav";
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .sidebar { display: contents; }
  #minimize, #maximize { display: none; }
  .brand { grid-area: brand; height: 3.5rem; margin: 0; padding: 0 1rem; }
  .brand-tile { width: 2.25rem; height: 2.25rem; }
  .nav-wrap {
    grid-area: nav;
    position: sticky;
    bottom: 0;
    z-index: 6;
    align-self: end;
    padding: .25rem .25rem calc(.25rem + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: rgb(var(--ground) / .92);
    -webkit-backdrop-filter: blur(16px);
            backdrop-filter: blur(16px);
  }
  .nav { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0; }
  .nav-group { display: none; }
  .nav-item,
  :root[data-sidebar="icons"] .nav-item {
    flex-direction: column;
    justify-content: center;
    gap: .25rem;
    min-height: 3.5rem;
    padding: 0;
    font-size: .75rem;
  }
  .nav-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .nav-short { display: block; }
  .toolbar { position: relative; top: auto; min-height: 0; gap: .5rem; padding: .75rem var(--pad-x); }
  .toolbar .select-btn { min-width: 7rem; }
  .search:focus-within,
  .search:has(input:not(:placeholder-shown)) { flex: 1 1 100%; width: auto; }
  /* Close moves up into the brand bar, which sits right above the toolbar. */
  .window-controls { position: absolute; top: -3.5rem; right: 0; height: 3.5rem; margin: 0; }
  .views { padding: .75rem var(--pad-x) 1.25rem; }
  .popover { max-width: calc(100vw - 2rem); }
  .profile-chip { position: absolute; top: .5rem; right: 2.875rem; z-index: 5; display: flex; width: auto; min-height: 0; margin: 0; padding: .25rem; border: 0; border-radius: 50%; background: none; }
  .profile-chip .chip-text, .profile-chip .icon { display: none; }
  .settings { position: fixed; top: 4rem; right: .5rem; bottom: auto; left: .5rem; width: auto; }
  .watermark { top: auto; right: .5rem; bottom: calc(4.5rem + env(safe-area-inset-bottom)); }
  .keylist { top: auto; bottom: calc(7rem + env(safe-area-inset-bottom)); left: .5rem; }
  .slots { grid-template-columns: minmax(0, 1fr); }
  .closed { min-height: 100dvh; align-content: center; }
}
