@import url("expert.css");   /* expert: styles of the expert tools */
/* Layout: the plot fills the page, the selected completions sit in a rail, the controls float over it. */
/* Colors and fonts are the project site's (dpp-lm.github.io, css/tokens.css), under this page's token names.
   Light is the default; the OS setting applies unless <html data-theme> says otherwise (js/theme.js). */
:root {
  color-scheme: light dark;
  --bg: #fbfaf7;
  --surface: #ffffff;
  --surface-2: #f3f1ec;
  --border: #dedbd3;
  --text: #1b1c1e;
  --text-2: #4a4d52;
  --muted: #777b82;
  --ink: #b4441a;          /* slider, checkbox, toggle: the site's accent */
  --ink-fg: #ffffff;       /* text on the accent */
  --btn: #f3f1ec;          /* quiet filled controls */
  --btn-hover: #e9e6df;
  --btn-line: #bdb9ae;
  --focus: #1f6fd1;
  --accent: #b4441a;       /* the selected subset, its vectors and volume */
  --series-1: var(--accent);
  --series-2: var(--accent);
  --series-3: var(--accent);
  --point: #4a4d52;        /* completions that are not selected */
  --ramp-lo: #c2bfb7;      /* unlikely completions */
  --ramp-hi: #2a2c2f;      /* likely completions */
  --grid: #e8e5de;
  --field: #ffffff;        /* text fields and selects */
  --raise: #ffffff;        /* the pressed segment of a switch, a pressed step button */
  --tint: rgba(27, 28, 30, 0.05);          /* the track of switches, hover on quiet buttons */
  --lift: rgba(255, 255, 255, 0.6);        /* hover on a segment */
  --veil: rgba(251, 250, 247, 0.86);       /* text over the plot */
  --inspect-bg: rgba(255, 255, 255, 0.96);
  --shadow: none;
  --shadow-sm: 0 1px 3px rgba(20, 20, 20, 0.05);
  --shadow-pop: 0 6px 22px rgba(20, 20, 20, 0.12);
  --shadow-dock: 0 4px 20px rgba(20, 20, 20, 0.08);
  --shadow-up: 0 -6px 20px rgba(20, 20, 20, 0.08);
  --is-dark: 0;
  --grid-mix: 0.3;         /* 3-D floor: how far its lines go from the background toward the ink */
  --point-fade: 0.6;       /* 3-D points: fade toward the background at the far side */
  --c1: #5b8db8;   /* blue */
  --c2: #d08a4a;   /* orange */
  --c3: #5f9f78;   /* green */
  --c4: #a07bb4;   /* purple */
  --c5: #c4a13a;   /* mustard */
  --c6: #4fa3a8;   /* teal */
  --c7: #c47a93;   /* rose */
  --c8: #8c7a62;   /* brown */
  --display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --r: 6px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131415;
    --surface: #1b1c1e;
    --surface-2: #242628;
    --border: #33353a;
    --text: #ecebe7;
    --text-2: #b9b8b2;
    --muted: #8b8a85;
    --ink: #f08a56;
    --ink-fg: #1b1c1e;
    --btn: #242628;
    --btn-hover: #2f3134;
    --btn-line: #4b4e55;
    --focus: #6aa9ff;
    --accent: #f08a56;
    --point: #e2e1dc;
    --ramp-lo: #6f737b;
    --ramp-hi: #ecebe7;
    --grid: #2c2e32;
    --field: #131415;
    --raise: #34373b;
    --tint: rgba(255, 255, 255, 0.06);
    --lift: rgba(255, 255, 255, 0.08);
    --veil: rgba(19, 20, 21, 0.86);
    --inspect-bg: rgba(27, 28, 30, 0.96);
    --shadow: none;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-pop: 0 6px 22px rgba(0, 0, 0, 0.5);
    --shadow-dock: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-up: 0 -6px 20px rgba(0, 0, 0, 0.4);
    --is-dark: 1;
    --grid-mix: 0.06;
    --point-fade: 0.2;
    --c1: #7fb0dc;
    --c2: #e6a566;
    --c3: #7cc196;
    --c4: #bf9bd3;
    --c5: #dcbb55;
    --c6: #6cc0c5;
    --c7: #de97af;
    --c8: #ad9a80;
  }
}
:root[data-theme="dark"] {
  --bg: #131415;
  --surface: #1b1c1e;
  --surface-2: #242628;
  --border: #33353a;
  --text: #ecebe7;
  --text-2: #b9b8b2;
  --muted: #8b8a85;
  --ink: #f08a56;
  --ink-fg: #1b1c1e;
  --btn: #242628;
  --btn-hover: #2f3134;
  --btn-line: #4b4e55;
  --focus: #6aa9ff;
  --accent: #f08a56;
  --point: #e2e1dc;
  --ramp-lo: #6f737b;
  --ramp-hi: #ecebe7;
  --grid: #2c2e32;
  --field: #131415;
  --raise: #34373b;
  --tint: rgba(255, 255, 255, 0.06);
  --lift: rgba(255, 255, 255, 0.08);
  --veil: rgba(19, 20, 21, 0.86);
  --inspect-bg: rgba(27, 28, 30, 0.96);
  --shadow: none;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-pop: 0 6px 22px rgba(0, 0, 0, 0.5);
  --shadow-dock: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-up: 0 -6px 20px rgba(0, 0, 0, 0.4);
  --is-dark: 1;
  --grid-mix: 0.06;
  --point-fade: 0.2;
  --c1: #7fb0dc;
  --c2: #e6a566;
  --c3: #7cc196;
  --c4: #bf9bd3;
  --c5: #dcbb55;
  --c6: #6cc0c5;
  --c7: #de97af;
  --c8: #ad9a80;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
sub { font-size: .72em; line-height: 0; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--sans); }
.serif { font-family: var(--serif); }
.shell { max-width: 1360px; margin: 0 auto; padding-block: 12px 32px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); display: flex; flex-direction: column; gap: 12px; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
h1, h2 { font-family: var(--display); text-wrap: balance; margin: 0; }

/* ---------- header ---------- */
.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.top .brand { min-width: 0; }
.links { flex: none; padding-top: 6px; }
.brand { display: flex; align-items: center; gap: 10px; }
h1 { font-size: 29px; font-weight: 600; line-height: 1.15; }
.tag { margin: 2px 0 0; color: var(--text-2); font: italic 15.5px/1.35 var(--serif); }
.tag a { color: inherit; }
.links { display: flex; align-items: center; gap: 14px; font-size: 13px; }
.links a { color: var(--text-2); text-underline-offset: 2px; }
.links a:hover { color: var(--text); text-decoration: underline; }
.chip-quiet { font-size: 12px; color: var(--muted); }


/* ---------- app grid ---------- */
.app { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 12px; align-items: start; }
.controls { display: flex; flex-direction: column; gap: 10px; position: sticky; top: max(12px, env(safe-area-inset-top, 0px)); }
.step { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow); }
.step h2 { font-size: 17px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.step h2 .num { width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; font: 500 12px/1 var(--sans); color: var(--text-2); border: 1px solid var(--btn-line); }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.lab { font-size: 12px; color: var(--muted); }
.lab.row { display: flex; justify-content: space-between; align-items: baseline; }
.val { font: 12.5px var(--sans); color: var(--text); padding: 0; font-variant-numeric: tabular-nums; }
input[type=number], textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 4px; padding: 6px 9px; min-width: 0;
}
input[type=number] { font-family: var(--sans); font-size: 13px; font-variant-numeric: tabular-nums; }
textarea { resize: vertical; min-height: 64px; font: 15.5px/1.4 var(--serif); background: var(--field); }
input[type=number] { background: var(--field); }
input:focus, textarea:focus { outline: none; border-color: var(--focus); }
input:hover, textarea:hover { border-color: var(--btn-line); }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.actions { display: flex; gap: 8px; }
.row-between { display: flex; align-items: end; justify-content: space-between; gap: 12px; }

.btn { font: 14px var(--sans); color: var(--text-2); background: transparent; border: 1px solid var(--border); border-radius: 4px; padding: 6px 14px; cursor: pointer; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--tint); color: var(--text); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--btn); color: var(--text); border-color: var(--btn-line); flex: 1; }
.btn.primary:hover { background: var(--btn-hover); color: var(--text); }
.btn.icon { width: 32px; padding: 6px 0; font-size: 16px; line-height: 1; }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper input { width: 52px; text-align: center; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button { display: none; }
button.link { border: 0; background: none; padding: 0; font: inherit; color: var(--text); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }


/* step 1: header with the examples dropdown; settings + Generate on one row */
.step-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.btn.primary { flex: none; padding-inline: 18px; }

/* prompt composer: text on top, chips at bottom left, round send button at bottom right */
.step-1 { background: none; border: 0; padding: 0; box-shadow: none; gap: 6px; }
.composer { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 10px 10px 8px 14px; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow-sm); }
.composer:focus-within { border-color: var(--btn-line); }
.composer textarea { border: 0; padding: 2px 0; background: transparent; resize: none; min-height: 48px; }
.composer textarea:focus { outline: none; }
.comp-row { display: flex; align-items: center; gap: 6px; }
.comp-row .grow { flex: 1; }
.chip { font: 12.5px var(--sans); color: var(--text-2); background: var(--surface-2); border: 0; border-radius: 999px; padding: 5px 11px; cursor: pointer; max-width: 150px; }
.chip:hover { color: var(--text); background: var(--btn-hover); }
.chipmenu { position: relative; }
.chipmenu summary { list-style: none; white-space: nowrap; }
summary.chip { max-width: none; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 6px; }
summary.chip > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.comp-row .chipmenu { min-width: 0; }
/* The settings pill has a fixed width (text ellipsised), so it never crowds the send button. */
.comp-row #adv { flex: 0 1 170px; width: 170px; }
.chipmenu summary::-webkit-details-marker { display: none; }
.chipmenu .menu { position: absolute; left: 0; top: calc(100% + 6px); z-index: 60; display: grid; grid-template-columns: repeat(3, 84px); gap: 8px; padding: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-pop); }
.plusbtn { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: var(--surface-2); color: var(--text-2); cursor: pointer; list-style: none; }
.plusbtn::-webkit-details-marker { display: none; }
.plusbtn:hover, [open] > .plusbtn { background: var(--btn-hover); color: var(--text); }
.plusbtn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.chipmenu .menu.list { display: flex; flex-direction: column; gap: 0; padding: 6px; width: min(300px, calc(100vw - 48px)); }
.menu-head { font: 600 12px var(--sans); color: var(--muted); padding: 4px 8px 6px; }
.menu.list button { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left; border: 0; background: none; padding: 7px 8px; border-radius: 6px; cursor: pointer; color: var(--text); }
.menu.list button:hover { background: var(--surface-2); }
.menu.list button[aria-current] { background: var(--surface-2); }
.menu.list button b { font: 600 13px var(--sans); }
.menu.list button span { font: 13px/1.3 var(--serif); color: var(--text-2); }
.model-field { grid-column: 1 / -1; }
#model, #embedder, #target { font: 13px var(--sans); color: var(--text); background: var(--field); border: 1px solid var(--border); border-radius: 4px; padding: 5px 6px; width: 100%; }
.cache-row button.link { font-size: 12px; color: var(--text-2); }
.menu-note { grid-column: 1 / -1; margin: 0 0 2px; font: 12px var(--sans); color: var(--muted); }
.chip::after { content: ""; flex: none; margin-top: 2px; width: 12px; height: 12px; background: currentColor; color: var(--muted); -webkit-mask: var(--chev) center / contain no-repeat; mask: var(--chev) center / contain no-repeat; transform: rotate(90deg); transition: transform .15s; }
[open] > summary.chip::after { transform: rotate(-90deg); }
.sendbtn { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--accent); color: var(--ink-fg); cursor: pointer; padding: 0; transition: opacity .15s, filter .15s; }
.sendbtn:hover { filter: brightness(.94); }
.sendbtn:disabled { opacity: .35; cursor: default; filter: none; }
.sendbtn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.sendbtn.stop { background: var(--text); }
.sendbtn.stop svg { fill: currentColor; stroke: none; }
.step-1 .status, .step-1 .progress { padding-inline: 6px; }

/* step 2: T slider with its two ends inline */
.mode-row { display: flex; align-items: center; gap: 8px; }
.mode-row .grow { flex: 1; }
/* Two ways to choose the subset; the one in use looks pressed. "Sample" draws a new subset each time. */
.pick { display: flex; gap: 2px; padding: 2px; background: var(--tint); border-radius: 4px; }
.pick-btn { font: 12.5px var(--sans); color: var(--text-2); background: transparent; border: 0; border-radius: 3px; padding: 3px 10px; cursor: pointer; white-space: nowrap; }
.pick-btn:hover { color: var(--text); background: var(--lift); }
.pick-btn[aria-pressed="true"] { background: var(--raise); color: var(--text); box-shadow: 0 0 0 1px var(--btn-line); }
.pick-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
/* Subset controls: compact everywhere. */
.step-2 { gap: 8px; }
.step-2 .seg { padding: 2px; gap: 2px; grid-auto-columns: auto; }
.step-2 .seg span { padding: 2px 10px; font-size: 12.5px; white-space: nowrap; }
.step-2 .btn.icon { width: 28px; min-height: 28px; padding: 0; font-size: 15px; }
.step-2 .stepper input { width: 38px; min-height: 28px; padding-block: 2px; }
.kfield { flex-direction: row; align-items: center; gap: 8px; }
.kfield .lab { font: 500 13px var(--sans); color: var(--text-2); }
.step-2 .row-between { align-items: center; }
/* T on one row: label, ?, value, then quality ━━●━━ diversity */
.tfield { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: 10px; row-gap: 0; }
.tfield .ends { grid-column: 2; display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; line-height: 1.1; margin-top: -3px; }
.tlab { display: inline-flex; align-items: center; gap: 4px; font: 500 13px var(--sans); color: var(--text-2); white-space: nowrap; }
.tlab .val { min-width: 3.2em; }
.tfield input[type=range] { margin: 0; }

/* "?" explainer buttons and their popover */
/* Footnote-style: a small raised "?" right after the thing it explains. */
.fn { white-space: nowrap; }
.xbtn { display: inline-block; padding: 1px 3.5px; margin: 0 0 0 1px; vertical-align: baseline; position: relative; top: -0.55em; border: 1px solid var(--btn-line); border-radius: 999px; background: var(--surface); color: var(--text-2); font: 600 8.5px/1 var(--sans); cursor: pointer; position: relative; flex: none; }
.xbtn:hover, .xbtn[aria-expanded=true] { color: var(--text); border-color: var(--text-2); }
.xbtn::after { content: ""; position: absolute; inset: -10px; }
.xpop { position: absolute; z-index: 100; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-left: 3px solid var(--text-2); border-radius: var(--r); box-shadow: var(--shadow-pop); padding: 10px 34px 10px 14px; font: 14.5px/1.45 var(--serif); }
.xpop p { margin: .4em 0; }
.xpop ul { margin: .3em 0; padding-left: 1.2em; }
.xpop li { margin: .15em 0; }
.xpop .katex-display { margin: .5em 0; overflow-x: auto; overflow-y: hidden; }
.xpop .katex { font-size: 1.02em; }
.xp-title { font: 600 12.5px var(--sans); color: var(--text-2); margin-bottom: 2px; }
.xp-close { position: absolute; top: 2px; right: 2px; width: 32px; height: 32px; border: 0; background: none; color: var(--muted); font-size: 18px; cursor: pointer; border-radius: 4px; }
.xp-close:hover { background: var(--tint); color: var(--text); }

/* segmented control */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--tint); border-radius: 4px; padding: 3px; gap: 4px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: block; text-align: center; padding: 5px 12px; border-radius: 3px; font-size: 13px; color: var(--muted); }
.seg label:hover span { color: var(--text); }
.seg input:checked + span { background: var(--raise); color: var(--text); box-shadow: 0 0 0 1px var(--btn-line); }
.seg input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 1px; }
.seg.small span { padding: 3px 11px; font-size: 12.5px; }

input[type=range] { width: 100%; accent-color: var(--ink); margin: 4px 0 0; }

.status { margin: 0; color: var(--muted); font-size: 12px; }
.progress { display: flex; flex-direction: column; gap: 6px; }
.progress .bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress .bar span { display: block; height: 100%; width: 0; background: var(--text-2); transition: width .3s; }
.progress .last { margin: 0; font: italic 14px var(--serif); color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- stage ---------- */
.stage { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow); display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.stage-bar, .stage-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 7px 12px; }
.stage-bar { border-top: 1px solid var(--border); padding-block: 5px; }
.stage-foot { border-top: 1px solid var(--border); justify-content: space-between; }
.note { color: var(--muted); font-size: 12px; }
.hint-block { position: absolute; left: 12px; bottom: 12px; z-index: 5; max-width: calc(100% - 24px); pointer-events: none; }
.stage-hint { margin: 0; font: 12.5px var(--sans); color: var(--muted); text-wrap: balance; }
.stage-hint[hidden] { display: none; }
.stage-bar .note { flex: 1; min-width: 0; }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); cursor: pointer; }
.toggle input { accent-color: var(--ink); margin: 0; }
.plot-wrap { display: block; padding: 4px; }
.plot { position: relative; width: 100%; height: min(66vh, 620px); min-height: 300px; min-width: 0; }
.plot svg, .plot canvas { display: block; width: 100%; height: 100%; }
.plot canvas { cursor: grab; }
.plot canvas:active { cursor: grabbing; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--text-2); font-size: 12px; align-items: center; }
.lg { display: inline-flex; gap: 6px; align-items: center; }
.sw { display: inline-block; width: 11px; height: 11px; border-radius: 50%; }
.sw.ramp { background: linear-gradient(90deg, var(--ramp-lo), var(--ramp-hi)); border-radius: 3px; width: 26px; height: 8px; }
.sw.sel { border: 2.5px solid var(--accent); }
.sw-vol path { fill: color-mix(in srgb, var(--text) 8%, transparent); stroke: var(--text-2); stroke-width: 1; }
.readout { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.stat { display: flex; align-items: baseline; gap: 6px; font-size: 12px; color: var(--muted); }
.stat .v { font: 500 13px var(--sans); color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* View menu on the plot toolbar */
.viewmenu { position: relative; margin-left: auto; }
.viewmenu summary { list-style: none; cursor: pointer; font-size: 12.5px; color: var(--text-2); padding: 3px 10px; border-radius: 4px; border: 1px solid var(--border); }
.viewmenu summary::-webkit-details-marker { display: none; }
.viewmenu summary { display: inline-flex; align-items: center; gap: 6px; }
.viewmenu summary::after { content: ""; flex: none; width: 12px; height: 12px; background: currentColor; color: var(--muted); -webkit-mask: var(--chev) center / contain no-repeat; mask: var(--chev) center / contain no-repeat; transform: rotate(-90deg); transition: transform .15s; }
.viewmenu[open] summary::after { transform: rotate(90deg); }
.viewmenu summary:hover, .viewmenu[open] summary { border-color: var(--btn-line); background: var(--surface); }
.viewmenu .menu-field { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.viewmenu .menu { position: absolute; right: 0; bottom: calc(100% + 4px); z-index: 20; display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-pop); white-space: nowrap; }

/* labels on the selected points */
.plot-box { position: relative; min-width: 0; }
.labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.lbl { position: absolute; left: 0; top: 0; max-width: 190px; padding: 0 2px; font: italic 12.5px/1.2 var(--serif); color: var(--text); pointer-events: auto; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  /* no box: a thin halo in the plot's background colour keeps the text legible over points */
  text-shadow: 0 0 2px var(--surface), 0 0 2px var(--surface), 0 0 3px var(--surface), 0 0 4px var(--surface); }
.lbl:hover { color: var(--accent); }
.lbl span { display: inline; }
.labels.anim .lbl { transition: transform .45s cubic-bezier(.33,1,.68,1); }
@media (max-width: 600px) { .lbl { max-width: 130px; font-size: 11.5px; } }
/* full-sentence mode: two nowrap lines, no fixed cap (the script limits each line to the plot's width) */
.lbl.full { max-width: none; overflow: visible; text-overflow: clip; }
.lbl.full .ln { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toggle:has(input:disabled) { opacity: .5; }

/* inspector: the tapped point, pinned under the plot */
.plot-wrap { position: relative; }
.inspect { position: absolute; left: 12px; right: 12px; bottom: 10px; max-height: 48%; overflow-y: auto; padding: 10px 40px 10px 14px; background: var(--inspect-bg); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-pop); z-index: 5; }
.ins-txt { font: 15.5px/1.4 var(--serif); white-space: pre-wrap; overflow-wrap: anywhere; }
.ins-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 6px; font: 12px var(--sans); color: var(--muted); }
.pill { color: var(--ink-fg); border-radius: 3px; padding: 1px 6px; font-size: 11px; }
.ins-close { position: absolute; top: 4px; right: 4px; width: 32px; height: 32px; border: 0; background: none; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; border-radius: 4px; }
.ins-close:hover { background: var(--tint); color: var(--text); }
.card { cursor: pointer; }

/* ---------- subset ---------- */
.subset { display: flex; flex-direction: column; gap: 10px; }
.subset-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.subset h2 { font-size: 21px; font-weight: 600; }
.cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 12px 14px 10px; display: flex; flex-direction: column; gap: 8px; min-width: 0; transition: border-color .15s, box-shadow .15s; }
.card .txt { white-space: pre-wrap; overflow-wrap: anywhere; font: 15.5px/1.4 var(--serif); color: var(--text); }
.card .meta { display: flex; align-items: center; gap: 8px; color: var(--muted); font: 11.5px var(--sans); margin-top: auto; }
.card .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.card.hl { border-color: var(--text-2); box-shadow: var(--shadow); }
.cutoff { color: var(--text-2); font-style: italic; }   /* stopped at the token limit, not by the model */
.card .meta { flex-wrap: wrap; white-space: nowrap; }
.card .meta .cutoff { flex-basis: 100%; }   /* on its own line */

/* ---------- table ---------- */

.foot { color: var(--muted); font: 14px/1.45 var(--serif); max-width: 75ch; }
.foot p { margin: 0; }

/* chart text used by the 2D plot */
.direct-label { font: 11px var(--sans); fill: var(--muted); }

.tooltip { position: fixed; z-index: 10; pointer-events: none; max-width: 360px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--r); padding: 8px 11px; font: 14.5px/1.35 var(--serif); box-shadow: var(--shadow-pop); white-space: pre-wrap; overflow-wrap: anywhere; }
.tooltip .meta { font: 11.5px var(--sans); color: var(--text-2); margin-top: 6px; white-space: normal; }

@media (max-width: 900px) {
  h1 { font-size: 23px; }
  .tag { font-size: 14px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  /* Phones: prompt first, then the plot, then the subset controls. */
  .controls { display: contents; }
  .step-1 { order: 0; }
  .stage { order: 1; }
  .step-2 { order: 2; }
  .stage-bar { flex-wrap: nowrap; align-items: flex-start; }
  .plot { height: 58vh; }
}
/* Phones: each pool row becomes a short block, text first, numbers on one line. */
@media (max-width: 600px) {
}
/* ---------- touch screens: finger-sized targets, no zoom-on-focus ---------- */
@media (pointer: coarse), (max-width: 600px) {
  input[type=number], textarea { font-size: 16px; }
  input[type=number] { min-height: 34px; padding-block: 4px; }
  .btn { min-height: 34px; padding-block: 5px; }
  .btn.icon { width: 34px; font-size: 17px; }
  .stepper input { width: 48px; }
  .seg span { padding: 7px 10px; font-size: 13.5px; }
  .seg.small span { padding: 5px 11px; font-size: 12.5px; }
    .xbtn { font-size: 9.5px; }
  .chip { font-size: 14px; }
  .chipmenu .menu { grid-template-columns: repeat(3, minmax(0, 1fr)); width: min(320px, calc(100vw - 48px)); }
  .viewmenu summary { padding: 5px 10px; font-size: 13px; }
  .viewmenu .menu { gap: 0; padding: 4px 6px; }
  .viewmenu .menu .toggle { padding: 10px 6px; font-size: 14px; }
  .viewmenu .menu-field { padding: 8px 6px 10px; }
  .toggle input { width: 20px; height: 20px; }
  input[type=range] { height: 32px; margin: 0; }
  .ins-close { width: 36px; height: 36px; top: 0; right: 0; }
}

/* ---------- phones ---------- */
@media (max-width: 600px) {

  /* "Pick a subset" docks to the bottom of the screen while the plot is in view,
     so T and K can be changed while watching the selection move. */
  .step-2 {
    position: sticky; bottom: 0; z-index: 30;
    display: flex; flex-direction: column;
    gap: 6px; padding: 8px 16px calc(8px + env(safe-area-inset-bottom, 0px));
    margin: 0 -16px; border-radius: var(--r) var(--r) 0 0; border-bottom: 0;
    box-shadow: var(--shadow-up);
  }
  .step-2 .btn.icon { width: 28px; min-height: 28px; padding: 0; font-size: 15px; }
  .step-2 .stepper input { width: 36px; min-height: 28px; padding-block: 2px; }
  .step-2 .pick-btn { padding: 5px 10px; }
  .step-2 input[type=range] { height: 24px; }
  .step-2 .tlab { font-size: 12.5px; }

}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* No pool for the current settings: show nothing but the note under the stage. */

/* Messages in the plot area: nothing yet, a run in progress, a failure. */
.stage { position: relative; }
.stage-msg { position: absolute; inset: 0; z-index: 25; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; padding: 24px; background: transparent; animation: fadein .18s ease-out; }
.stage-msg.over { background: var(--veil); }
@keyframes fadein { from { opacity: 0; } }
.stage-msg p { margin: 0; max-width: 46ch; }
.stage-msg .t { font: 600 16.5px var(--serif); color: var(--text); }
.stage-msg .d { font-size: 13.5px; color: var(--text-2); line-height: 1.45; }
.stage-msg .a { margin-top: 8px; display: flex; gap: 8px; }
.stage-msg.error .t { color: var(--accent); }
.stage-msg.error { box-shadow: inset 0 3px 0 var(--accent); }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--accent); animation: spin .9s linear infinite; margin-bottom: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner, .stage-msg { animation: none; } }

/* The status line keeps one line of height even when empty. */
#live-status { min-height: 2.9em; line-height: 1.45; }   /* two lines, so the box below never moves */

/* The strip under the plot keeps one size: fixed slots and fixed-width numbers. */
.stage-foot { flex-wrap: nowrap; }
.legend { flex-wrap: nowrap; white-space: nowrap; overflow: hidden; min-width: 0; }
.readout { display: grid; grid-template-columns: repeat(4, auto); gap: 4px 16px; flex: none; }
.stat .v { display: inline-block; min-width: 7ch; text-align: right; }
.stat.off { visibility: hidden; }
@media (max-width: 760px) {
  .stage-foot { display: grid; grid-template-columns: 1fr; gap: 6px; }
  .readout { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 18px; }
  .readout .stat { display: grid; grid-template-columns: auto 1fr; align-items: baseline; }
}

/* Subset controls: T on top; K on the left and Most likely / Sample on the right below it. */
.step-2 .mode-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.step-2 .pick { display: inline-flex; vertical-align: middle; }

/* Menus that open from the prompt box sit above the plot. */
.step-1 { position: relative; z-index: 40; }
/* The legend under the plot fits narrow phones: grid items may shrink, and the self-explanatory
   "selected" key is dropped when space is short. */
.stage-foot > * { min-width: 0; }
@media (max-width: 420px) {
  .legend { gap: 6px 10px; }
}
/* The View menu opens above the subset controls docked at the bottom of phone screens. */
.viewmenu { z-index: 35; }
.xbtn:focus-visible { outline: 1.5px solid var(--focus); outline-offset: 1px; }

/* Spectrum panel, opened from the strip under the plot */
.specmenu { margin-left: 0; }
.specmenu .menu { min-width: 230px; gap: 4px; font: 11.5px var(--sans); color: var(--text-2); white-space: normal; }
.specmenu .sp-head { margin: 0 0 4px; font-weight: 500; color: var(--text); }
.specmenu .bar { display: grid; grid-template-columns: 12px minmax(0, 1fr) 4.5em; align-items: center; gap: 6px; font: 11px var(--sans); font-variant-numeric: tabular-nums; color: var(--muted); }
.specmenu .bar .fill { height: 8px; background: var(--text-2); border-radius: 0 2px 2px 0; min-width: 1px; }
.specmenu .bar .pv { text-align: right; }
.specmenu .sp-dims { display: flex; align-items: center; gap: 8px; margin: 8px 0 0; }
.specmenu .sp-note { margin: 6px 0 0; color: var(--muted); line-height: 1.35; max-width: 32ch; }
/* Pool fit: the number turns to the accent, and a note explains, when the pool is a poor match. */
.stat.warn .v { color: var(--accent); }
.fit-note { margin: 0; padding: 6px 12px 8px; font-size: 12.5px; line-height: 1.4; color: var(--text-2); border-top: 1px solid var(--border); }
.fit-note b { color: var(--accent); font-weight: 600; }
.menu-note.limits { grid-column: 1 / -1; margin: -2px 0 0; }
.muted { color: var(--muted); }
.ins-meta .pill { background: var(--accent); color: var(--ink-fg); }
.stat .v { min-width: 6.5ch; }
@media (max-width: 760px) {
  .stage-foot { grid-template-columns: minmax(0, 1fr) auto; }
  .stage-foot .legend { grid-column: 1 / -1; }
  .stage-foot .specmenu { align-self: end; }
}

/* =====================================================================================
   Full-page layout. Wide screens: the plot is the page's backdrop (everything left of the
   rail and above the dock); the selected completions sit in a rail on the right, each joined
   point labelled on the plot; the prompt and subset controls are in a column on the left;
   the health readouts and the table are in a drawer. Phones: one column in normal flow.
   ===================================================================================== */
:root { --rail-w: 340px; --ctl-w: 352px; }
.tooltip { z-index: 110; }
.details-btn { position: relative; font-size: 12.5px; padding: 3px 12px; background: var(--surface); }
.flag { display: none; position: absolute; top: -3px; right: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); border: 1.5px solid var(--surface); }
.warnflag .flag { display: block; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.drawer-title { position: relative; border: 0; background: none; padding: 0; font: 600 12.5px var(--sans); color: var(--text-2); cursor: pointer; }
.drawer-title .flag { top: -2px; right: -12px; }
.drawer-close { width: 32px; height: 32px; border: 0; background: none; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; border-radius: 4px; }
.drawer-close:hover { background: var(--tint); color: var(--text); }
.top-row { display: contents; }   /* holds only the Details button, hidden at every width */

@media (min-width: 901px) {
  html, body { height: 100%; overflow: hidden; }
  .shell { max-width: none; padding: 0; display: block; }
  .app { display: block; }

  /* title, note and Details: small, top left, over the plot */
  .top { position: fixed; top: 12px; left: 18px; z-index: 30; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; width: calc(var(--ctl-w) - 32px); pointer-events: none; }
  .top > * { pointer-events: auto; }
  .brand { align-items: baseline; gap: 14px; }
  h1 { font-size: 19px; }
  .links { padding-top: 0; }

  /* the plot: no box, the page itself */
  /* the plot fills the whole window; the controls, the rail and the bar float over it */
  .stage { position: fixed; inset: 0; background: transparent; border: 0; border-radius: 0; box-shadow: none; z-index: 1; }
  .plot-wrap { position: absolute; inset: 0; padding: 0; }
  .plot-box { height: 100%; }
  /* left edge of the dock; JS (placeHint) adds .beside when the dock reaches down to it and the block moves right of the dock */
  .hint-block { position: fixed; left: 16px; bottom: calc(var(--bar-h, 40px) + 12px); max-width: min(36rem, calc(100vw - var(--rail-w) - 48px)); }
  .hint-block.beside { left: calc(var(--ctl-w) + 12px); max-width: calc(100vw - var(--ctl-w) - var(--rail-w) - 24px); }
  .plot { height: 100%; min-height: 0; }
  .stage-msg.over { background: var(--veil); }
  .stage-msg.error { box-shadow: none; }

  /* the rail of selected completions */
  .rail { position: fixed; top: 0; right: 0; bottom: var(--bar-h, 40px); width: var(--rail-w); z-index: 20; overflow-y: auto; overscroll-behavior: contain;   /* full height, not floating */
    background: var(--surface); border-left: 1px solid var(--border); padding: 16px 14px 20px; display: flex; flex-direction: column; gap: 10px; }
  .rail .subset-head { flex-direction: column; gap: 2px; }
  .rail h2 { font-size: 19px; }
  .rail .cards { grid-template-columns: minmax(0, 1fr); }
  .rail .card { background: var(--surface); }


  /* the controls: prompt and subset controls in a column on the left, under the title, as before */
  .dock { position: fixed; left: 16px; top: calc(var(--top-h, 96px) + 10px); width: calc(var(--ctl-w) - 32px); z-index: 30; display: flex; flex-direction: column; gap: 10px; }
  .dock .step-1, .dock .step-2 { width: 100%; }
  .dock .composer, .dock .step-2 { box-shadow: var(--shadow-dock); }
  .dock .status { background: var(--veil); border-radius: 4px; padding: 2px 6px; }
  /* messages over the plot sit in the open area between the floating panels */
  .stage-msg { left: var(--ctl-w); right: var(--rail-w); bottom: var(--bar-h, 40px); }
  .dock .chipmenu .menu.list { max-height: calc(100vh - 220px); overflow-y: auto; }

  /* Details: a bar along the bottom of the page, under the controls, the plot and the rail. It always shows the
     readouts with the Spectrum and View menus. */
  #details-btn { display: none; }
  .drawer { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; background: var(--surface); border-top: 1px solid var(--border); padding: 4px 16px 6px; }   /* edge to edge, not floating */
  .drawer-head { display: none; }
  /* one row: readouts, the completions count, then Spectrum and View */
  .drawer-body { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; min-width: 0; }
  .drawer .stage-foot, .drawer .stage-bar { display: contents; }
  /* The legend's own items join the row: the "selected" key stays hidden (the red of the selection explains itself),
     but #vol-hint (the spanned-volume key, or the Fit axes button when the axes do not contain the selection) shows whenever it has
     content. It starts at zero width and grows up to its text, taking the free space before the stage note does. */
  .drawer .legend { display: contents; }
  .drawer .legend > .lg:first-child { display: none; }
  .drawer #vol-hint { order: 2; display: block; flex: 100 1 0; max-width: max-content; min-width: 0; padding-top: 3px; margin-top: -3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .drawer #vol-hint:empty { display: none; }
  /* From 901 to 1279 px the row has no room for the hint, so only the Fit axes button shows, at its full width (the
     bar may take a second row for it); the informational variants stay hidden, as before. */
  @media (max-width: 1279px) {
    .drawer #vol-hint:not(:has(.vol-fit)) { display: none; }
    .drawer #vol-hint:has(.vol-fit) { flex: none; max-width: none; overflow: visible; text-overflow: clip; }
  }
  .drawer .readout { order: 1; flex: none; display: flex; gap: 4px 12px; }
  .drawer .stat .v { min-width: 0; }
  .drawer #stage-note { order: 3; flex: 1 1 0; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .drawer .specmenu { order: 4; }
  .drawer #viewmenu { order: 5; margin-left: 0; }
  .drawer .viewmenu summary { white-space: nowrap; }
  /* the pool-fit note: a small popover above the bar, opened by clicking the red pool-fit value */
  .drawer .fit-note { position: absolute; left: 14px; bottom: calc(100% + 6px); max-width: 520px; z-index: 5; padding: 8px 12px; background: var(--surface);
    border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--r); box-shadow: var(--shadow-pop); }
  .drawer .fit-note:not(.show) { display: none; }
  .stat.warn.can-open .v { cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
}

/* Phones and narrow windows: one column in normal flow. */
@media (max-width: 900px) {
  .details-btn { display: none; }
  .dock { display: contents; }
  .app { display: flex; flex-direction: column; gap: 12px; align-items: stretch; }
  .top { flex-direction: column; align-items: stretch; gap: 8px; }
  /* The four header items (three links and the theme button) take a row of their own when the title leaves no room beside it. */
  .brand { justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 6px 12px; }
  .brand h1 { min-width: 0; flex: 1 1 14rem; }
  .links { flex-wrap: wrap; gap: 6px 14px; }
  .step-1 { order: 0; }
  .stage { order: 1; }
  .rail { order: 2; }
  /* The readouts: a bar attached to the bottom of the plot, always visible (no Details box). */
  .stage { border-radius: var(--r) var(--r) 0 0; }
  .drawer { order: 1; margin-top: -13px; background: var(--surface); border: 1px solid var(--border); border-top: 1px solid var(--border); border-radius: 0 0 var(--r) var(--r); padding: 6px 12px 4px; }
  .drawer-head { display: none; }
  .drawer .drawer-body { display: block !important; }
  /* Only #vol-hint is shown (the "selected" key explains itself), on a full-width row of the stage-foot grid, and
     only when it has content. */
  .drawer .stage-foot { flex-wrap: wrap; }
  .drawer .legend { flex: 1 1 100%; overflow: visible; white-space: normal; padding-top: 2px; }
  .drawer .legend > .lg:first-child { display: none; }
  .drawer .legend:has(> #vol-hint:empty) { display: none; }
  .drawer .stage-foot { border-top: 0; padding: 4px 0 0; }   /* room for the raised ? marks */
  .drawer .stage-bar { padding: 2px 0 0; border-top: 0; }
  .drawer .stat.warn.can-open .v { text-decoration: underline dotted; text-underline-offset: 3px; cursor: pointer; }
  .drawer .fit-note { padding: 6px 0 4px; }
  .drawer .fit-note:not(.show) { display: none; }   /* tap the red pool-fit value to read it */
  .drawer .viewmenu:not([open]) { z-index: auto; }   /* closed menus stay under the docked T/K bar */
  .plot { height: 55vh; }
  /* The docked T/K bar is the page's last item: no padding below it, so at the end of the page it stays flush
     with the bottom edge instead of lifting off it. */
  .shell { padding-bottom: 0; }
  /* T and K dock to the bottom of the screen while scrolling. */
  .step-2 {
    order: 4; position: sticky; bottom: 0; z-index: 30;
    gap: 6px; padding: 8px 16px calc(8px + env(safe-area-inset-bottom, 0px));
    margin: 0 -16px; border-radius: var(--r) var(--r) 0 0; border-bottom: 0;
    box-shadow: var(--shadow-up);
  }
}
/* Nothing in the plot is text to select: dragging rotates the view or pans, and labels open the inspector. */
.plot-box, .plot-box * , .stage-msg .t, .labels, .lbl { -webkit-user-select: none; user-select: none; }
.stage-msg .d { -webkit-user-select: text; user-select: text; }   /* error details can still be copied */

/* An open menu draws above the buttons next to it. */
.viewmenu[open] { z-index: 60; }

/* All completions: in the rail under the selected subset, in the same card style. */
.all-list { margin-top: 18px; }
.all-list > summary { list-style: none; cursor: pointer; }
.all-list > summary::-webkit-details-marker { display: none; }
.all-list > summary h2 { display: flex; align-items: center; gap: 6px; }
.all-list > summary h2::before { content: ""; flex: none; margin-top: 4px; width: 13px; height: 13px; background: currentColor; color: var(--muted); -webkit-mask: var(--chev) center / contain no-repeat; mask: var(--chev) center / contain no-repeat; transition: transform .15s; }
.all-list[open] > summary h2::before { transform: rotate(90deg); }
.all-list > summary:hover h2 { color: var(--text-2); }
.all-list[open] > summary { margin-bottom: 10px; }
#all-cards .card { padding: 9px 12px 8px; }
#all-cards .card .txt { font-size: 14px; }

/* Long completions are clipped to four lines in the rail. On wide screens clicking a card shows the whole
   text in the inspector; on phones the card unfolds in place (openCard in main.js). */
.rail .card .txt { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; line-clamp: 4; overflow: hidden; }
.rail .card.open .txt { display: block; -webkit-line-clamp: unset; line-clamp: none; overflow: visible; }   /* unfolded in place (phones) */
@media (min-width: 901px) {
  .inspect { position: fixed; left: calc(var(--ctl-w) + 24px); right: calc(var(--rail-w) + 24px); top: auto; bottom: calc(var(--bar-h, 40px) + 12px);
    max-height: 48vh; z-index: 40; }
}

/* Until the first complete render the page is hidden, so no half-built state shows (js/main.js: reveal). */
html.booting .shell { visibility: hidden; }

/* K: one pill in the style of the Most likely / Sample switch: minus, the number, plus. */
.stepper { gap: 2px; padding: 2px; background: var(--tint); border-radius: 4px; }
.step-btn { width: 28px; height: 26px; display: grid; place-items: center; border: 0; border-radius: 3px; background: transparent; color: var(--text-2); cursor: pointer; padding: 0; }
.step-btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.step-btn:hover { background: var(--lift); color: var(--text); }
.step-btn:active { background: var(--raise); box-shadow: 0 0 0 1px var(--btn-line); }
.step-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.step-2 .stepper input, .stepper input { width: 34px; min-height: 26px; padding: 0; border: 0; border-radius: 3px; background: var(--field); box-shadow: 0 0 0 1px var(--btn-line); font: 500 13px var(--sans); font-variant-numeric: tabular-nums; }
@media (pointer: coarse), (max-width: 600px) {
  .step-btn { width: 36px; height: 32px; }   /* finger-sized */
  .step-2 .stepper input, .stepper input { width: 38px; min-height: 32px; font-size: 16px; }
}

/* Room for a scroll bar is kept from the start, so nothing shifts sideways when one appears: the page
   scrolls on narrow screens, the rail scrolls on wide ones. */
@media (max-width: 900px) { html { scrollbar-gutter: stable; } }
.rail { scrollbar-gutter: stable; }

/* Theme button: one icon button in the top right of the plot (same look as the rail buttons). Narrow layouts: in the plot box corner. */
.theme-btn { position: absolute; top: 8px; right: 8px; z-index: 6; display: inline-grid; place-items: center; width: 28px; height: 28px; padding: 0; border-radius: 50%; background: var(--surface); border: 1px solid var(--btn-line); color: var(--text-2); cursor: pointer; }
.theme-btn:hover { background: var(--surface-2); }
.theme-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
@media (pointer: coarse) { .theme-btn { width: 44px; height: 44px; } }
@media (min-width: 901px) {
  :root { --theme-r: calc(var(--rail-w) + 12px); }
  html.rail-closed { --theme-r: 50px; }   /* left of the Show panel button */
  .theme-btn { position: fixed; top: 14px; right: var(--theme-r); z-index: 30; }
}
@media (pointer: coarse) and (min-width: 901px) { html.rail-closed { --theme-r: 66px; } }

/* The Selected subset rail can be hidden on wide screens; the plot already fills the window behind it. */
.rail-btn { display: none; }
@media (min-width: 901px) {
  .rail-btn { display: inline-grid; place-items: center; width: 28px; height: 28px; padding: 0; border-radius: 50%; background: var(--surface); border: 1px solid var(--btn-line); color: var(--text-2); cursor: pointer; }
  .rail-btn:hover { background: var(--surface-2); }
  .rail-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
  .rail-hide { position: absolute; top: 14px; right: 14px; z-index: 2; }
  .rail-show { position: fixed; top: 14px; right: 14px; z-index: 30; }
  .rail-show[hidden] { display: none; }
  html.rail-closed { --rail-w: 0px; }
  html.rail-closed .rail { display: none; }
}
@media (pointer: coarse) and (min-width: 901px) { .rail-btn { width: 44px; height: 44px; } }

/* one chevron for every disclosure marker (the same path as the project page) */
:root { --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M4 2 L8 6 L4 10' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
@media (prefers-reduced-motion: reduce) { .chip::after, .viewmenu summary::after, .all-list > summary h2::before, .xsec > summary::before { transition: none !important; } }
