/* ==========================================================
   MANDELBROT · precision fractal observatory
   Style: Fluent / research instrument, glassmorphism kept restrained, no gaudy gradients
   ========================================================== */

:root {
  color-scheme: dark;
  --bg: #08090b;
  --glass: rgba(20, 22, 27, 0.66);
  --glass-strong: rgba(24, 26, 32, 0.86);
  --glass-soft: rgba(255, 255, 255, 0.035);
  --line: rgba(255, 255, 255, 0.085);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #e9ebef;
  --text-2: #9aa1ac;
  --text-3: #6b7280;
  --accent: #6ea8fe;
  --accent-dim: rgba(110, 168, 254, 0.16);
  --danger: #f2777a;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.35);
  --blur: blur(10px) saturate(125%);
  /* glass dropdown (v4) */
  --dd-bg: rgba(15, 17, 22, 0.86);
  --dd-line: rgba(255, 255, 255, 0.13);
  --dd-item: rgba(255, 255, 255, 0.062);
  --dd-hi: rgba(255, 255, 255, 0.10);
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "Cascadia Mono", "Consolas", "SF Mono", ui-monospace, monospace;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #e9ebef;
  --glass: rgba(255, 255, 255, 0.88);
  --glass-strong: rgba(255, 255, 255, 0.93);
  --glass-soft: rgba(15, 18, 24, 0.04);
  --line: rgba(12, 16, 24, 0.10);
  --line-strong: rgba(12, 16, 24, 0.18);
  --text: #16181d;
  --text-2: #5a626e;
  --text-3: #8b929d;
  --accent: #2f6fdb;
  --accent-dim: rgba(47, 111, 219, 0.12);
  --shadow: 0 18px 44px rgba(20, 26, 40, 0.16), 0 2px 8px rgba(20, 26, 40, 0.08);
  --dd-bg: rgba(250, 250, 252, 0.88);
  --dd-line: rgba(14, 18, 26, 0.15);
  --dd-item: rgba(14, 18, 26, 0.06);
  --dd-hi: rgba(255, 255, 255, 0.92);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 400 13px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* Touch devices: no rubber-band scroll and no tap flash over the canvas.
   * The gesture handlers own pan/pinch (touch-action: none on #fractal). */
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

#fractal {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: auto;
  cursor: grab;
  touch-action: none;
}
#fractal.dragging { cursor: grabbing; }

/* GPU shading surface.
 *
 * A real, visible layer stacked *under* #fractal.  Two properties matter and
 * both were learned the hard way:
 *
 *  - It has to be composited, not hidden.  A canvas with `visibility: hidden`
 *    (or `display: none`) is not guaranteed to keep its drawing buffer, and
 *    reading it back — with drawImage or with readPixels — can return an empty
 *    surface.  So it is always laid out and always painted.
 *  - It must not swallow input.  #fractal stays on top and receives every
 *    pointer event; the shader layer only opts out of hit-testing.
 *
 * `html.gl-surface` hides #fractal with `opacity`, not `display`: the element
 * keeps its layout and its event listeners, so panning and zooming keep
 * working while the GPU picture is the one on screen.
 */
#glfractal {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  pointer-events: none;
}
#fractal { z-index: 1; }
html.gl-surface #fractal { opacity: 0; }

/* WebGPU deep-engine surface.  Same stacking contract as #glfractal: a real
 * composited layer under #fractal, never hit-tested.  `transform-origin: 0 0`
 * lets a pan/pinch be a single compositor transform of the last committed
 * frame, which is what keeps a gesture at 60 fps while the engine is busy. */
#wgpu-fractal {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  pointer-events: none;
  transform-origin: 0 0;
  will-change: transform;
}
html.wgpu-surface #fractal { opacity: 0; }
html.wgpu-surface #glfractal { opacity: 0; }
html.gl-surface #wgpu-fractal { opacity: 0; }
/* Each GPU layer is on screen only while its own class says so.
 *
 * The two rules above only hide the *other* layer, so with neither class set
 * both sat visible underneath #fractal and were relied on to be covered by an
 * opaque 2D canvas.  A canvas is transparent wherever it has not been painted
 * -- after a resize, or in a strip a partial frame did not reach -- and what
 * showed through was the *previous* GPU frame: two different views spliced
 * along a straight edge, which reads as "the picture jumped somewhere else".
 * Hiding them by default makes a missing paint show the page colour, not a
 * stale picture. */
html:not(.wgpu-surface) #wgpu-fractal { opacity: 0; }
html:not(.gl-surface) #glfractal { opacity: 0; }
html.wgpu-surface #wgpu-fractal { opacity: 1; }
html.gl-surface #glfractal { opacity: 1; }

/* "No structure in this area".
 *
 * The status row is one line and clips this on a narrow window, so the same
 * fact is also stated in the middle of the picture: a frame whose pixels all
 * escape at the same iteration has nothing to draw, and a flat field reads as
 * a broken renderer unless it says what it is. */
.nodetail {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  padding: 14px 22px;
  border-radius: 12px;
  background: rgba(12, 14, 18, 0.72);
  border: 1px solid var(--line);
  color: var(--text);
  text-align: center;
  font-size: 13px;
  line-height: 1.5;
  max-width: min(420px, 80vw);
}
.nodetail[hidden] { display: none; }
.nodetail b { font-weight: 600; }
.nodetail span { color: var(--text-dim); }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.glass {
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

/* ---------------- Top bar ---------------- */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 40.5px;                 /* 54px × 0.75 */
  display: flex;
  align-items: center;
  gap: 13.5px;
  padding: 0 10px;
  border-left: 0; border-right: 0; border-top: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03), 0 10px 30px rgba(0, 0, 0, 0.25);
  z-index: 40;
  user-select: none;
}

.brand { display: flex; align-items: center; gap: 6.5px; padding-right: 4px; }
.brand-mark { display: grid; place-items: center; color: var(--text-2); }
.brand-mark svg { width: 14px; height: 14px; }
.brand-name { font-weight: 600; letter-spacing: 0.11em; font-size: 10.5px; }
.brand-sub {
  font-size: 9.5px; color: var(--text-3); letter-spacing: 0.05em;
  border-left: 1px solid var(--line-strong); padding-left: 8px; margin-left: 1px;
}

.topnav { display: flex; align-items: center; gap: 2px; }

.topbtn {
  display: inline-flex; align-items: center; gap: 4.5px;
  height: 24px; padding: 0 8px;
  background: transparent; color: var(--text-2);
  border: 1px solid transparent; border-radius: 6px;
  font: inherit; font-size: 11.5px; cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.topbtn:hover { background: var(--glass-soft); color: var(--text); }
.topbtn:active { transform: translateY(0.5px); }
.topbtn.open { background: var(--glass-soft); color: var(--text); border-color: var(--line); }
.topbtn .chev { opacity: .55; }

.badge {
  font: 500 9px/1 var(--mono);
  padding: 2px 4px; border-radius: 4px;
  background: var(--accent-dim); color: var(--accent);
  letter-spacing: .02em;
}

.top-spacer { flex: 1; }
.top-right { display: flex; align-items: center; gap: 11px; }
#chip-precision { margin-right: 3px; }

.chip {
  font: 500 10px/1 var(--mono);
  color: var(--text-2);
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--glass-soft);
  white-space: nowrap;
}

.iconbtn {
  display: grid; place-items: center;
  width: 32px; height: 32px;
  background: transparent; color: var(--text-2);
  border: 1px solid transparent; border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .12s, color .12s;
}
.iconbtn:hover { background: var(--glass-soft); color: var(--text); }
.iconbtn.tiny { width: 24px; height: 24px; }
/* top bar shrinks to 75%: keep its icons inside the new 40.5px band */
.topbar .iconbtn { width: 24px; height: 24px; }
.topbar .iconbtn.tiny { width: 18px; height: 18px; }
#btn-console .ct-ico { width: 12px; height: 12px; }

/* ---------------- Dropdowns (glass v4) ----------------
   Rebuilt from scratch: a real frosted slab (blur + saturation over
   the fractal), a top sheen, a hairline bevel, and hover rows with
   an accent rail. The old flat panel is gone.
   ------------------------------------------------------- */
.menu-wrap { position: relative; }

.dropdown {
  position: absolute; top: calc(100% + 10px); left: 0;
  min-width: 216px; padding: 8px;
  border-radius: 16px;
  z-index: 60;
  display: flex; flex-direction: column; gap: 3px;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(255,255,255,.06) 0%, rgba(255,255,255,.012) 46%, rgba(255,255,255,.022) 100%),
    var(--dd-bg);
  -webkit-backdrop-filter: blur(14px) saturate(130%);
  backdrop-filter: blur(14px) saturate(130%);
  border: 1px solid var(--dd-line);
  box-shadow:
    0 28px 64px -20px rgba(0, 0, 0, .74),
    0 10px 26px -12px rgba(0, 0, 0, .46),
    inset 0 1px 0 var(--dd-hi),
    inset 0 -1px 0 rgba(0, 0, 0, .22);
  transform-origin: 50% 0;
  animation: ddIn .17s cubic-bezier(.2, .72, .3, 1) both;
  isolation: isolate;
}
.dropdown.right { left: auto; right: 0; min-width: 244px; }

/* soft light falling in from the top edge */
.dropdown::before {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(120% 62% at 50% -18%, rgba(255, 255, 255, .14), transparent 68%);
  opacity: .9;
}
[data-theme="light"] .dropdown::before { opacity: .55; }

@keyframes ddIn {
  from { opacity: 0; transform: translateY(-7px) scale(.972); }
  to   { opacity: 1; transform: none; }
}

.dropdown > button {
  position: relative;
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 9px 12px;
  border: 1px solid transparent; border-radius: 10px;
  background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer;
  transition: background .12s ease, border-color .12s ease, transform .12s ease;
}
.dropdown > button::before {
  content: "";
  position: absolute; left: 3px; top: 50%;
  width: 2px; height: 0; border-radius: 2px;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-dim);
  transform: translateY(-50%);
  transition: height .14s ease;
}
.dropdown > button:hover { background: var(--dd-item); border-color: var(--dd-line); }
.dropdown > button:hover::before { height: 20px; }
.dropdown > button:active { transform: scale(.99); }
.dropdown > button b { font-weight: 500; font-size: 12.5px; }
.dropdown > button small { color: var(--text-3); font-size: 10.5px; letter-spacing: .045em; }

.dd-group {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 7px 9px;
}
.dd-label { color: var(--text-2); font-size: 11.5px; }
.dd-sep {
  height: 1px; margin: 6px 6px;
  background: linear-gradient(90deg, transparent, var(--dd-line) 12%, var(--dd-line) 88%, transparent);
}
.dd-item {
  padding: 9px 12px; border: 1px solid transparent; border-radius: 10px; background: transparent;
  color: var(--text); font: inherit; text-align: left; cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
}
.dd-item:hover { background: var(--dd-item); border-color: var(--dd-line); }
.dd-check {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 12px; border: 1px solid transparent; border-radius: 10px;
  color: var(--text); font-size: 12px; cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
}
.dd-check:hover { background: var(--dd-item); border-color: var(--dd-line); }
.dd-check input { accent-color: var(--accent); }
/* The label stays on one line; the select takes the remaining width instead of
 * squeezing the text into a vertical stack (AA「原版 High res（4 采样）」). */
.dd-check > span { flex: 0 0 auto; white-space: nowrap; }
.dd-check > select { flex: 1 1 auto; min-width: 0; }
/* Effective appdata\mandelbrot.json readout (see applyConfig). */
.dd-note { padding: 2px 9px 6px; font-size: 10.5px; line-height: 1.45; opacity: .62; }

/* ---------------- Segmented control ---------------- */
.segment {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--glass-soft);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 2px;
  gap: 2px;
}
.segment button {
  padding: 6px 6px; border: 0; border-radius: 7px;
  background: transparent; color: var(--text-2);
  font: inherit; font-size: 11.5px; cursor: pointer;
  transition: background .12s, color .12s;
  white-space: nowrap;
}
.segment button:hover { color: var(--text); }
.segment button.on {
  background: var(--glass-strong);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,.35), inset 0 0 0 1px var(--line);
}
.segment.mini { width: 108px; }
.segment.mini button { font-size: 11px; padding: 4px; }

/* ---------------- Console ---------------- */
.panel {
  position: fixed;
  top: 55px; right: 18px;
  width: 318px;
  max-height: calc(100vh - 78px);
  border-radius: var(--radius);
  display: flex; flex-direction: column;
  z-index: 30;
  overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 14px 9px;
  cursor: grab;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent);
}
.panel-head:active { cursor: grabbing; }
.panel-title { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--text-2); }
.panel-body { overflow-y: auto; padding: 4px 14px 16px; scrollbar-width: thin; }
.panel.collapsed .panel-body { display: none; }

.grp { padding: 12px 0 4px; border-bottom: 1px solid var(--line); }
.grp:last-child { border-bottom: 0; }
.grp h4 {
  margin: 0 0 9px;
  font-size: 10.5px; font-weight: 500; letter-spacing: .14em;
  text-transform: uppercase; color: var(--text-3);
}

.row { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.row.two > label { width: 52px; }
.row > label { width: 74px; flex: none; color: var(--text-2); font-size: 12px; }
.row .val { width: 46px; text-align: right; color: var(--text-2); font-size: 11.5px; }

.ctl {
  flex: 1; min-width: 0;
  height: 28px; padding: 0 8px;
  background: var(--glass-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text); font: inherit; font-size: 12px;
  outline: none;
}
.ctl:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.ctl.num { width: 66px; flex: none; text-align: right; }
select.ctl { appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 13px) 12px, calc(100% - 9px) 12px;
  background-size: 4px 4px, 4px 4px; background-repeat: no-repeat;
  padding-right: 22px;
}

input[type="range"] {
  flex: 1; min-width: 0; height: 18px; appearance: none;
  background: transparent; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 3px; border-radius: 2px; background: var(--line-strong);
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none; width: 12px; height: 12px; margin-top: -4.5px;
  border-radius: 50%; background: var(--text);
  border: 1px solid rgba(0,0,0,.4);
  box-shadow: 0 1px 3px rgba(0,0,0,.4);
}
input[type="range"]:focus { outline: none; }
input[type="range"]:focus::-webkit-slider-thumb { box-shadow: 0 0 0 4px var(--accent-dim); }

.check { display: inline-flex; align-items: center; gap: 7px; color: var(--text-2); font-size: 12px; cursor: pointer; }
.check input { accent-color: var(--accent); }

.palette-strip {
  height: 8px; border-radius: 4px; margin: 2px 0 9px;
  border: 1px solid var(--line);
  opacity: .9;
}

/* ---------------- gradient editor ----------------
 * Three full-width ramps stacked vertically, each showing one third of the
 * palette.  Three bars of the same width = three times the ramp length and
 * three times the pixels per unit of position, which is what makes a stop at
 * 0.334 distinguishable from one at 0.333 with a mouse. */
.grad-ed { margin: 3px 0 10px; }
.grad-stack { display: flex; flex-direction: column; gap: 22px; }
.grad-lane { position: relative; }
.grad-bar {
  position: relative; height: 17px; border-radius: 5px;
  border: 1px solid var(--line); cursor: copy;
  background-color: var(--glass-soft);
  touch-action: none;
}
.grad-fill {
  position: absolute; inset: 0; border-radius: 4px;
  pointer-events: none;
  /* The full ramp is painted one bar wide per stacked row; the size and the
   * pan position are set per bar by syncPaletteStrip(), because the number of
   * rows grows with the number of stops (3 minimum, 15 handles per bar). */
  background-repeat: no-repeat;
  background-size: 300% 100%;
}
.grad-lane-tag {
  position: absolute; left: 6px; top: 50%; transform: translateY(-50%);
  z-index: 2; pointer-events: none;
  font-size: 9px; letter-spacing: .4px; font-weight: 600;
  color: rgba(255,255,255,.82); text-shadow: 0 1px 3px rgba(0,0,0,.9);
}
.grad-handles { position: absolute; inset: 0; }
/* Little house whose apex sits exactly on the ramp's lower edge — it never
 * intrudes into the colour strip.  A rounded path dulls the roof tip, the two
 * shoulders and the bottom corners; polygon() is the fallback for engines
 * without clip-path: path(). */
.grad-handle {
  position: absolute; top: 100%; width: 10px; height: 15px;
  margin-left: -5px;
  clip-path: polygon(50% 0%, 100% 34%, 100% 100%, 0% 100%, 0% 34%);
  clip-path: path("M 4.3 0.7 Q 5 -0.1 5.7 0.7 L 9.55 4.35 Q 10 4.8 10 5.4 L 10 13.7 Q 10 15 8.8 15 L 1.2 15 Q 0 15 0 13.7 L 0 5.4 Q 0 4.8 0.45 4.35 Z");
  cursor: ew-resize;
  transition: box-shadow .1s;
}
.grad-handle::after {
  content: ''; position: absolute; inset: 0;
  clip-path: polygon(50% 0%, 100% 34%, 100% 100%, 0% 100%, 0% 34%);
  clip-path: path("M 4.3 0.7 Q 5 -0.1 5.7 0.7 L 9.55 4.35 Q 10 4.8 10 5.4 L 10 13.7 Q 10 15 8.8 15 L 1.2 15 Q 0 15 0 13.7 L 0 5.4 Q 0 4.8 0.45 4.35 Z");
  box-shadow: inset 0 0 0 1px var(--text);
}
/* Selected handles are highlighted by the outline only: scaling them would
 * lift the apex back into the ramp. */
.grad-handle.sel { z-index: 3; }
.grad-handle.sel::after { box-shadow: inset 0 0 0 1.8px var(--accent); }
/* Extra breathing room below the last lane: its handles hang 15px past the
 * ramp, so the colour/position buttons must clear them, not just the ramp. */
.grad-row { display: flex; align-items: center; gap: 6px; margin-top: 28px; flex-wrap: wrap; }
.grad-color {
  width: 30px; height: 24px; padding: 0; border: 1px solid var(--line);
  border-radius: 6px; background: transparent; cursor: pointer;
}
.grad-color::-webkit-color-swatch-wrapper { padding: 2px; }
.grad-color::-webkit-color-swatch { border: none; border-radius: 4px; }
.grad-row .ctl.num { width: 62px; }
.btn.tiny { height: 24px; padding: 0 7px; font-size: 11px; flex: 1 1 auto; }
.grad-row .btn.tiny { min-width: 0; }

/* One control per row: a 2x4 grid put two sliders on every line, which made
 * the value you were dragging hard to read and the labels easy to mis-click. */
/* Official GLSL schemes: exactly nparam sliders, one row each, generated
 * from the scheme's own JSON.  Kept visually separate from the tone stage so
 * it is obvious these belong to the colour recipe, not to the view. */
.scheme-params {
  margin: 6px 0 10px; padding: 8px 10px 6px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--glass-soft);
}
.scheme-params[hidden] { display: none; }
.scheme-title {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 8px; font-size: 11.5px; color: var(--text); margin-bottom: 4px;
}
.scheme-hint { font-size: 10px; color: var(--text-2); opacity: .8; }
.scheme-params .row.tight { margin-bottom: 2px; gap: 8px; }
.scheme-params .row.tight > label { width: 76px; font-size: 11.5px; }
.scheme-params input[type="range"] { min-width: 0; flex: 1 1 auto; }
.scheme-params .row.tight .val { width: 40px; font-size: 11px; }
.scheme-view-row {
  display: flex; align-items: center; gap: 8px;
  margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line);
}
.scheme-view-row .chk {
  display: flex; align-items: center; gap: 4px; flex: 1 1 auto;
  font-size: 10.5px; color: var(--text-2); cursor: pointer;
}
.scheme-view-row .chk input { margin: 0; }
.scheme-view-row .btn { flex: 0 0 auto; }

/* ---- official Julia preview window -------------------------------------
 * The reference pins a 56x56 viewport top-right (004169c0.c:130-155).  Here
 * it is the first block of the console and scrolls with everything else, so
 * it belongs to the settings rather than floating over the picture.
 * It is a real WebGL surface, not a screenshot of the main canvas: it has
 * its own iteration field and shares only the shader and Params. */
.julia-dock { padding-top: 10px; }
.julia-dock[hidden] { display: none; }
.julia-dock-head {
  display: flex; align-items: center; gap: 6px; margin: 0 0 8px;
  font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--text-3); user-select: none;
}
.julia-dock-title { color: var(--text-3); }
.julia-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 6px var(--accent);
}
/* In focus mode the caption is the way back to the previous view. */
.julia-back {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 1px 8px 1px 5px; margin-left: -2px;
  font-size: 10.5px; letter-spacing: .04em; text-transform: none;
  border: 1px solid var(--accent); border-radius: 999px;
  background: var(--accent-dim); color: var(--text); cursor: pointer;
}
.julia-back[hidden] { display: none; }
.julia-back:hover { background: var(--accent); color: #05060a; }
.julia-btn {
  margin-left: auto; padding: 1px 7px; font-size: 10px;
  letter-spacing: 0; text-transform: none;
  border: 1px solid var(--line); border-radius: 5px;
  background: var(--glass-soft); color: var(--text-2); cursor: pointer;
}
.julia-btn:hover { color: var(--text); border-color: var(--accent); }
/* The reference's small window is a plain rectangle in the picture, not a
 * white card: the frame here is the panel's own line colour.  The fill follows
 * the theme (`--bg`), not a fixed near-black: in the light theme a hardcoded
 * #050609 left a black hole in the middle of the console while every other
 * surface turned light. */
.julia-frame {
  width: 168px; height: 168px; margin: 0 auto; padding: 0;
  box-sizing: border-box; background: var(--bg);
  border: 1px solid var(--line); border-radius: 6px; overflow: hidden;
  transition: width .12s, height .12s;
}
.julia-frame:hover { border-color: var(--accent); }
.julia-dock.big .julia-frame { width: 100%; height: auto; aspect-ratio: 1; }
#julia-canvas { display: block; width: 100%; height: 100%; cursor: zoom-in; }
.julia-seed {
  margin-top: 6px; font-size: 9.5px; color: var(--text-2); text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.julia-dock-ctl { margin-top: 9px; }
.julia-dock-ctl .btnrow { gap: 6px; margin-bottom: 7px; }
.julia-dock-ctl .btnrow .btn { flex: 1 1 0; height: 24px; font-size: 11px; }
.julia-dock-ctl .btnrow .btn.on {
  border-color: var(--accent); color: var(--text); background: var(--accent-dim);
}
.julia-dock-ctl .chk {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--text-2); margin-bottom: 6px; cursor: pointer;
}
.julia-dock-ctl .chk input { margin: 0; }
.julia-dock-ctl .row.tight { gap: 6px; margin-bottom: 4px; }
.julia-dock-ctl .row.tight > label { width: 40px; font-size: 11px; }
.julia-dock-ctl .row.tight input[type="range"] { min-width: 0; flex: 1 1 auto; }
.julia-dock-ctl .row.tight .val { width: 40px; font-size: 10px; }

/* The pinned seed, marked in the Mandelbrot plane. */
.julia-mark {
  position: fixed; z-index: 8; width: 22px; height: 22px;
  margin: -11px 0 0 -11px; pointer-events: none;
}
.julia-mark[hidden] { display: none; }
.julia-mark i, .julia-mark b {
  position: absolute; inset: 0; display: block;
  border: 1px solid rgba(255,255,255,.85);
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0,0,0,.55), inset 0 0 0 1px rgba(0,0,0,.45);
}
.julia-mark b {
  inset: 9px; border-radius: 50%; background: rgba(255,255,255,.9);
  box-shadow: 0 0 6px rgba(255,255,255,.9);
}
.julia-pick-hint {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  z-index: 45; padding: 7px 14px; border-radius: 999px;
  font-size: 12px; color: var(--text);
  background: var(--glass); border: 1px solid var(--accent);
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
}
.julia-pick-hint[hidden] { display: none; }
body.julia-picking #fractal { cursor: crosshair; }

.tone-grid {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 3px;
  margin-top: 4px; padding-top: 8px; border-top: 1px dashed var(--line);
}
.tone-grid .row.tight { margin-bottom: 2px; gap: 8px; }
.tone-grid input[type="range"] { min-width: 0; flex: 1 1 auto; }
.tone-grid .row.tight > label { width: 34px; font-size: 11.5px; }
.tone-grid .row.tight .val { width: 40px; font-size: 11px; }
.tone-grid .row.gain > label.gain-lab {
  width: 34px; padding-left: 10px; font-family: var(--mono); font-weight: 700;
  font-size: 11.5px;
}
/* Named classes, not :nth-of-type: the tone grid gained rows (contrast,
 * gamma, saturation) and positional selectors silently painted them red,
 * green and blue while R/G/B fell back to the body colour. */
.tone-grid .row.gain > label.gain-r { color: #e8746f; }
.tone-grid .row.gain > label.gain-g { color: #79c98a; }
.tone-grid .row.gain > label.gain-b { color: #6ea8fe; }
.tone-grid > .btn { grid-column: 1 / -1; margin-top: 2px; }

/* Rows the active scheme cannot consume are shown dimmed and non-interactive
 * rather than left as controls that do nothing. */
.row.inert { opacity: 0.42; }
#grad-ed.inert { opacity: 0.42; pointer-events: none; }

.kv { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 7px; }
.kv > span { color: var(--text-2); font-size: 12px; flex: none; }
.kv code {
  font-family: var(--mono); font-size: 10.5px; color: var(--text);
  letter-spacing: -0.1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right;
}

.btnrow { display: grid; grid-auto-flow: column; gap: 7px; margin-bottom: 8px; }
.btn {
  height: 30px; padding: 0 10px;
  background: var(--glass-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text); font: inherit; font-size: 12px; cursor: pointer;
  transition: background .12s, border-color .12s;
  white-space: nowrap;
}
.btn:hover { background: rgba(255,255,255,.07); border-color: var(--line-strong); }
[data-theme="light"] .btn:hover { background: rgba(0,0,0,.05); }
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }

/* ---------------- HUD ---------------- */
.hud {
  position: fixed; left: 14px; bottom: 12px;
  display: flex; flex-direction: column; gap: 2px;
  padding: 7px 10px;
  font-size: 11px; color: var(--text);
  pointer-events: none;
  background: rgba(10, 12, 16, 0.42);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 9px;
  z-index: 20;
  max-width: 62vw;
}
[data-theme="light"] .hud {
  background: rgba(255,255,255,.72);
  border-color: rgba(12,16,24,.08);
  color: #2a2f37;
}
.hud-line { display: flex; align-items: center; gap: 8px; white-space: nowrap; overflow: hidden; }
.hud-line.dim { color: var(--text-2); font-size: 10.5px; }
[data-theme="light"] .hud-line.dim { color: #5a626e; }
.hud .dot { width: 2px; height: 2px; border-radius: 50%; background: currentColor; opacity: .6; flex: none; }
.hud .mono { font-size: 10.5px; text-overflow: ellipsis; overflow: hidden; }

/* ---------------- Modals ---------------- */
.modal-root { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; }
.modal-scrim { position: absolute; inset: 0; background: rgba(4,5,7,.55); backdrop-filter: blur(3px); }
[data-theme="light"] .modal-scrim { background: rgba(220,225,235,.55); }

.modal {
  position: relative;
  width: min(1120px, calc(100vw - 48px));
  max-height: 84vh;
  border-radius: 16px;
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: modalIn .16s ease-out;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(8px) scale(.995); } to { opacity: 1; transform: none; } }
.modal.narrow { width: min(640px, calc(100vw - 48px)); }
.modal.mid { width: min(860px, calc(100vw - 48px)); }

.modal-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; padding: 16px 18px 12px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: .01em; }
.modal-head .sub { margin: 3px 0 0; font-size: 11.5px; color: var(--text-3); }
.modal-body { padding: 14px 18px; overflow-y: auto; }
.modal-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 12px 18px; border-top: 1px solid var(--line);
}
.modal-foot:empty { display: none; }

/* Preset library */
.preset-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.preset-toolbar .ctl { max-width: 300px; }
.cats { display: flex; gap: 4px; }
.cats button {
  height: 28px; padding: 0 10px;
  background: transparent; border: 1px solid transparent; border-radius: 7px;
  color: var(--text-2); font: inherit; font-size: 11.5px; cursor: pointer;
}
.cats button:hover { color: var(--text); background: var(--glass-soft); }
.cats button.on { background: var(--glass-soft); border-color: var(--line); color: var(--text); }

.preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 10px;
}
.pcard {
  border: 1px solid var(--line);
  border-radius: 10px; overflow: hidden;
  background: var(--glass-soft);
  cursor: pointer; text-align: left; padding: 0;
  transition: border-color .12s, transform .12s;
  font: inherit; color: var(--text);
}
.pcard:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.pcard .thumb {
  display: block; width: 100%; aspect-ratio: 8 / 5;
  background: #0a0c10;
}
.pcard .meta { padding: 7px 9px 8px; }
.pcard .nm { font-size: 11.5px; line-height: 1.35; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard .tag { font: 500 9.5px/1 var(--mono); color: var(--text-3); letter-spacing: .05em; margin-top: 4px; display: block; }

/* user presets: same card, distinct delete affordance */
.pcard-wrap { position: relative; }
.pcard-wrap .pcard { width: 100%; display: block; }
.pcard-del {
  position: absolute; top: 6px; right: 6px;
  width: 20px; height: 20px; padding: 0;
  display: grid; place-items: center;
  border: 1px solid var(--line-strong); border-radius: 50%;
  background: rgba(10, 12, 16, .62);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  color: var(--text-2); font: 12px/1 var(--mono); cursor: pointer;
  opacity: .55; transition: opacity .12s, color .12s, border-color .12s;
}
.pcard-wrap:hover .pcard-del, .pcard-del:focus-visible { opacity: 1; }
.pcard-del:hover { color: var(--danger); border-color: rgba(242, 119, 122, .45); }
.preset-count { margin-left: auto; color: var(--text-3); font-size: 11px; }
.preset-empty { color: var(--text-3); font-size: 12px; padding: 20px 4px; }

/* Formula editor */
.formula-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 18px; }
@media (max-width: 780px) { .formula-grid { grid-template-columns: 1fr; } }
.expr-box {
  width: 100%; min-height: 86px; resize: vertical;
  padding: 12px 13px;
  background: rgba(0,0,0,.28);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font: 500 15px/1.6 var(--mono);
  outline: none;
}
[data-theme="light"] .expr-box { background: rgba(255,255,255,.6); }
.expr-box:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }

.status-line { display: flex; align-items: center; gap: 7px; margin: 8px 0 12px; font-size: 11.5px; }
.status-line .dotmark { width: 7px; height: 7px; border-radius: 50%; background: #4ec9a0; }
.status-line.err .dotmark { background: var(--danger); }
.status-line.err { color: var(--danger); }
.status-line.ok { color: var(--text-2); }

.example-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.example-list button {
  padding: 5px 9px; font: 500 11px/1 var(--mono);
  background: var(--glass-soft); border: 1px solid var(--line); border-radius: 6px;
  color: var(--text-2); cursor: pointer;
}
.example-list button:hover { color: var(--text); border-color: var(--line-strong); }

.legend { font-size: 11px; color: var(--text-3); line-height: 1.7; }
.legend b { color: var(--text-2); font-weight: 500; }
.legend code {
  font-family: var(--mono); font-size: 10.5px; color: var(--text-2);
  display: inline-block; margin: 1px 4px 1px 0; padding: 1px 5px;
  background: var(--glass-soft); border: 1px solid var(--line); border-radius: 4px;
}

.param-sliders { display: grid; gap: 7px; margin-top: 6px; }
.param-sliders .row > label { width: 40px; }

#formula-preview {
  width: 100%; aspect-ratio: 16 / 10; border-radius: 10px;
  border: 1px solid var(--line); background: #07080b; display: block;
}

/* Custom presets */
.saved-list { display: flex; flex-direction: column; gap: 8px; }
.saved-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--glass-soft);
}
.saved-item .info { flex: 1; min-width: 0; }
.saved-item .nm { font-size: 12.5px; }
.saved-item .sub { font-size: 10.5px; color: var(--text-3); font-family: var(--mono); }
.save-row { display: flex; gap: 8px; margin-bottom: 14px; }
.save-row .ctl { max-width: 320px; }

/* About */
.about-body { font-size: 12.5px; color: var(--text-2); line-height: 1.75; white-space: pre-line; }
.about-stats { display: flex; gap: 22px; margin: 16px 0 4px; }
.about-stats div { display: flex; flex-direction: column; gap: 2px; }
.about-stats b { font: 500 18px/1 var(--mono); color: var(--text); }
.about-stats span { font-size: 10.5px; color: var(--text-3); letter-spacing: .1em; text-transform: uppercase; }
.shortcut-grid { display: grid; grid-template-columns: auto 1fr; gap: 7px 16px; margin-top: 14px; font-size: 12px; color: var(--text-2); }
.shortcut-grid kbd {
  font: 500 11px/1 var(--mono); padding: 4px 7px; border-radius: 5px;
  border: 1px solid var(--line-strong); background: var(--glass-soft); color: var(--text);
}

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  padding: 9px 15px; border-radius: 9px;
  background: var(--glass-strong); border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-size: 12px; color: var(--text);
  z-index: 100;
  animation: toastIn .18s ease-out;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 6px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* Scrollbars */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: rgba(140,150,165,.28); border-radius: 6px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(140,150,165,.45); background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 900px) {
  .panel { width: calc(100vw - 24px); right: 12px; top: 66px; max-height: 62vh; }
  .brand-sub { display: none; }
  .topnav { gap: 0; }
  .topbtn { padding: 0 8px; }
}

/* ==========================================================
   Panel visibility — single source of truth for both the
   top-bar toggle and the in-panel minimize button.
   ========================================================== */
body.panel-closed .panel { display: none; }

#btn-console.on {
  color: var(--text);
  background: var(--glass-soft);
  border-color: var(--line);
}
#btn-console .ct-ico { opacity: .8; }
#btn-console.on .ct-ico { color: var(--accent); opacity: 1; }

.panel-grab { display: none; }
.panel-head-actions { display: flex; align-items: center; gap: 2px; }

/* ==========================================================
   Boot diagnostics (see the inline bootstrap guard)
   ========================================================== */
.boot.failed .boot-fill::after { animation: none; opacity: 0; }
.boot.failed .boot-mark { color: var(--danger); opacity: .85; }

.boot-note {
  width: min(468px, calc(100vw - 44px));
  margin-top: 26px;
  padding: 16px 17px 15px;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.035);
  text-align: left;
  animation: bootNoteIn .32s cubic-bezier(.2, .7, .3, 1) both;
}
[data-theme="light"] .boot-note { background: rgba(255, 255, 255, .6); }
@keyframes bootNoteIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.boot-note-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; font-weight: 600; color: var(--text);
  letter-spacing: .01em;
}
.boot-note-dot {
  width: 7px; height: 7px; border-radius: 50%; flex: none;
  background: #e0b23c;
  box-shadow: 0 0 0 3px rgba(224, 178, 60, .12);
}
.boot-note-dot.bad { background: var(--danger); box-shadow: 0 0 0 3px rgba(242, 119, 122, .12); }

#boot-note-desc {
  margin: 9px 0 0;
  font-size: 11.8px; line-height: 1.78; color: var(--text-2);
}
#boot-note-desc code {
  font-family: var(--mono); font-size: 11px; color: var(--text);
  padding: 1px 5px; border-radius: 4px;
  background: rgba(255, 255, 255, .07);
  border: 1px solid var(--line);
}
[data-theme="light"] #boot-note-desc code { background: rgba(0, 0, 0, .05); }

.boot-cmd {
  display: flex; align-items: center; gap: 8px;
  margin-top: 12px; padding: 8px 8px 8px 11px;
  border-radius: 8px;
  background: rgba(0, 0, 0, .38);
  border: 1px solid var(--line);
}
[data-theme="light"] .boot-cmd { background: rgba(0, 0, 0, .04); }
.boot-cmd code {
  flex: 1; min-width: 0;
  font: 500 12px/1.4 var(--mono); color: var(--text);
  overflow-x: auto; white-space: nowrap;
}
.boot-copy {
  flex: none; height: 24px; padding: 0 9px;
  border-radius: 6px; cursor: pointer;
  background: var(--glass-soft); color: var(--text-2);
  border: 1px solid var(--line); font: inherit; font-size: 11px;
}
.boot-copy:hover { color: var(--text); border-color: var(--line-strong); }

.boot-note-actions { display: flex; gap: 8px; margin-top: 14px; }
.boot-note-actions .btn { flex: 1; height: 32px; display: grid; place-items: center; text-decoration: none; }
.boot-note-actions .btn.ghost { flex: none; padding: 0 12px; color: var(--text-2); }
/* LaTeX typesetting display */
.latex-view {
  margin: 2px 0 14px;
  padding: 12px 14px;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0,0,0,.18);
  font: 400 17px/1.9 "Cambria Math", "Latin Modern Math", Cambria, Georgia, serif;
  color: var(--text);
  overflow-x: auto;
  white-space: nowrap;
}
[data-theme="light"] .latex-view { background: rgba(255,255,255,.55); }
.latex-view i { font-style: italic; }
.latex-view sup, .latex-view sub { font-size: .68em; }
.latex-view .frac {
  display: inline-flex; flex-direction: column; vertical-align: middle;
  text-align: center; margin: 0 .18em; font-size: .94em;
  transform: translateY(-.12em);
}
.latex-view .frac .num { border-bottom: 1px solid currentColor; padding: 0 .18em .06em; }
.latex-view .frac .den { padding: .06em .18em 0; }
.latex-view .sqrt { display: inline-block; }
.latex-view .sqrt .radical { font-size: 1.05em; }
.latex-view .sqrt .radicand { border-top: 1px solid currentColor; padding: 0 .14em; }
.latex-view .ovl { text-decoration: overline; }
.latex-view .op { font-style: normal; padding-right: .06em; }
.latex-view .bigop { display: inline-flex; align-items: center; vertical-align: middle; }
.latex-view .bigop .op-sym { font-size: 1.5em; line-height: 1; }
.latex-view .bigop .op-lim { display: inline-flex; flex-direction: column; font-size: .6em; line-height: 1.1; margin-left: .1em; }
.latex-view .cases { font-size: 1.5em; vertical-align: middle; }
.latex-view .cases-body { display: inline-flex; flex-direction: column; font-size: .9em; vertical-align: middle; }

/* ---------------- Formula panel (Desmos style) ---------------- */
.modal.wide { width: min(1240px, calc(100vw - 40px)); }

.fx-wrap {
  display: grid;
  /* Left column: expression, hints, parameter sliders.  Right column: the
   * preview, deliberately narrower than the list and pinned to the dialog's
   * right edge.  At `1fr` it grew to ~716px, whose 16:10 height (448px)
   * exceeded the body's 422px — the branch caption sits at the bottom of the
   * stage, so it was the first thing cut off.  The cap also follows the
   * viewport height, so a short window shrinks the picture instead of
   * cropping it. */
  /* The picture is the working surface, so it takes the larger share; only the
   * detail inset stays small.  The cap follows the viewport height, so a short
   * window shrinks the picture instead of cropping its caption. */
  --fx-pv: min(700px, calc((100vh - 330px) * 1.6));
  grid-template-columns: minmax(300px, 420px) minmax(200px, var(--fx-pv));
  gap: 20px;
  align-items: start;
  justify-content: space-between;
}
/* The preview is flush with the dialog's edge: the body's own 18px inset is
 * cancelled here, and the picture keeps its rounded corners only on the side
 * that touches the list. */
.modal-body.fx-fit .fx-preview { margin-right: -18px; }

/* The formula panel fills the dialog instead of scrolling as a whole: the
 * expression box, hint and example chips stay put, and only the parameter
 * sliders — the one part whose length depends on the formula — scroll, in the
 * narrow left column.  Scrolling the whole dialog meant the preview drifted
 * out of view exactly when you were adjusting a parameter to look at it. */
.modal-body.fx-fit {
  overflow: hidden; display: flex; flex-direction: column; min-height: 0;
  padding-bottom: 4px;
}
.modal-body.fx-fit .fx-wrap { flex: 1 1 auto; min-height: 0; align-items: stretch; }
.modal-body.fx-fit .fx-list { max-height: none; height: 100%; overflow: hidden; }
.modal-body.fx-fit .fx-list > .fx-row,
.modal-body.fx-fit .fx-list > .fx-hint,
.modal-body.fx-fit .fx-list > .fx-examples { flex: 0 0 auto; }
.modal-body.fx-fit #fx-params {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden;
  padding-right: 6px;
}
.modal-body.fx-fit #fx-params::-webkit-scrollbar { width: 7px; }
.modal-body.fx-fit #fx-params::-webkit-scrollbar-thumb {
  background: var(--line-strong); border-radius: 4px;
}
@media (max-width: 900px) { .fx-wrap { grid-template-columns: 1fr; } }

.fx-list {
  display: flex; flex-direction: column;
  max-height: 62vh; overflow-y: auto;
  padding-right: 4px;
}

.fx-row {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 8px;
  padding: 9px 4px;
  border-bottom: 1px solid var(--line);
}
.fx-row:first-child { border-top: 1px solid var(--line); }
.fx-idx {
  font: 500 10.5px/22px var(--mono);
  color: var(--text-3);
  text-align: right;
  user-select: none;
}
.fx-cell { min-width: 0; }
.fx-tex {
  font: 400 15px/1.7 "Cambria Math", Cambria, Georgia, serif;
  color: var(--text);
  padding: 1px 0 2px;
  white-space: nowrap; overflow-x: auto;
}
.fx-tex.big { font-size: 17px; }
.fx-err { color: var(--danger); font-style: normal; }

.fx-expr {
  width: 100%;
  height: 81px;            /* exactly 3 lines of 13.5px/1.55 + padding */
  min-height: 81px;
  max-height: 81px;
  overflow-y: auto;
  resize: none;
  padding: 8px 10px;
  background: rgba(0,0,0,.22);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font: 500 13.5px/1.55 var(--mono);
  outline: none;
}
[data-theme="light"] .fx-expr { background: rgba(255,255,255,.6); }
.fx-expr:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }

.fx-hint { font-size: 11px; color: var(--text-3); padding: 8px 4px 6px; line-height: 1.6; }
.fx-deep {
  font: 500 10.5px/1.6 var(--mono);
  color: var(--text-3);
  padding: 2px 4px 10px;
}
.fx-deep.warn { color: var(--warn, #d9a441); }

.fx-param .fx-cell { display: flex; flex-direction: column; gap: 2px; }
.fx-slider { display: flex; align-items: center; gap: 8px; }
.fx-slider span { font: 500 9.5px/1 var(--mono); color: var(--text-3); }
.fx-slider input[type="range"] { flex: 1; }
.fx-slider input[type="range"]::-webkit-slider-runnable-track { height: 2px; }
.fx-slider input[type="range"]::-webkit-slider-thumb { width: 11px; height: 11px; margin-top: -4.5px; background: var(--accent); border: 2px solid var(--bg); }
.fx-val { font-family: var(--mono); }

.fx-examples { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 0 4px; }
.fx-examples button {
  padding: 5px 9px; font: 500 11px/1 var(--mono);
  background: var(--glass-soft); border: 1px solid var(--line); border-radius: 6px;
  color: var(--text-2); cursor: pointer;
}
.fx-examples button:hover { color: var(--text); border-color: var(--line-strong); }

.fx-preview { display: flex; flex-direction: column; gap: 8px; }
.fx-stage { position: relative; }
#formula-preview {
  width: 100%;
  aspect-ratio: 16 / 10;
  /* Square on the right: this edge is the dialog's own border (see .fx-wrap). */
  border-radius: 12px 0 0 12px;
  border: 1px solid var(--line);
  border-right: 0;
  background: var(--bg);
  display: block;
  image-rendering: auto;
}
.fx-insetbox {
  /* A third of the old 12px inset: the detail window sits on the picture's
   * corner rather than floating inside it. */
  position: absolute; right: 4px; bottom: 4px; width: 31.5%;
  border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden;
  background: var(--bg); box-shadow: 0 10px 30px rgba(0,0,0,.65);
}
.fx-insetbox canvas { display: block; width: 100%; height: auto; }
.fx-inset-cap {
  position: absolute; left: 6px; bottom: 5px;
  font: 500 10px/1 var(--mono); color: #fff;
  background: rgba(0,0,0,.6); padding: 4px 6px; border-radius: 4px;
}
.fx-marker {
  position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px;
  border: 1.5px solid #fff; border-radius: 50%;
  box-shadow: 0 0 0 1px #000, 0 0 8px rgba(255,255,255,.8);
  pointer-events: none;
}
.fx-zoomrow {
  display: flex; align-items: center; gap: 8px;
  font: 500 11px/1 var(--mono); color: var(--text-3);
}
.fx-branch-btn { position: absolute; right: 10px; top: 10px; z-index: 3; }
.fx-branch-info {
  position: absolute; left: 12px; bottom: 10px; z-index: 3;
  font: 500 10px/1.2 var(--mono); color: #cfd3dc;
  background: rgba(0,0,0,.5); padding: 5px 7px; border-radius: 4px;
  max-width: 58%; pointer-events: none;
}
.fx-meta { font: 500 11px/1.5 var(--mono); color: var(--text-3); min-height: 18px; }
.fx-expr.bad { border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger) inset; }
.fx-meta.ok { color: var(--text-2); }
.fx-meta.err { color: var(--danger); }

/* ==========================================================
   Palette editor (user colour sets)
   ========================================================== */
.pal-edit { display: flex; flex-direction: column; gap: 10px; }

/* The colour set's ruler: one bar per 25 handles, a new bar below as soon as
 * one fills up.  The gap leaves room for the handles hanging under each ramp. */
.pal-stack {
  display: flex; flex-direction: column; gap: 26px;
  margin-bottom: 16px;
  touch-action: none;
}
.pal-stack .grad-bar {
  height: 18px; border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .18);
}

.pal-stops {
  display: flex; flex-direction: column; gap: 6px;
  max-height: 42vh; overflow-y: auto; padding-right: 4px;
}

.pal-stop {
  display: grid;
  grid-template-columns: 22px 34px 1fr 24px;
  align-items: center; gap: 10px;
  padding: 5px 8px;
  background: var(--glass-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
}
.pal-stop:hover { border-color: var(--line-strong); }
.pal-idx { font-size: 10px; color: var(--text-3); text-align: right; }
.pal-hex { font-size: 11px; color: var(--text-2); letter-spacing: .2px; }

.pal-stop input[type="color"] {
  width: 34px; height: 24px; padding: 0;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 5px;
  cursor: pointer;
}
.pal-stop input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
.pal-stop input[type="color"]::-webkit-color-swatch { border: none; border-radius: 3px; }

.btn.danger { color: var(--danger); border-color: rgba(242, 119, 122, .35); }
.btn.danger:hover { background: rgba(242, 119, 122, .12); }

/* ==========================================================
   Boot splash
   ========================================================== */
.boot {
  position: fixed; inset: 0; z-index: 900;
  display: grid; place-items: center;
  background:
    radial-gradient(60% 55% at 50% 45%, rgba(12, 14, 18, 0.55), rgba(6, 7, 10, 0.86) 78%);
  backdrop-filter: blur(12px) saturate(125%);
  -webkit-backdrop-filter: blur(12px) saturate(125%);
  transition: opacity .55s cubic-bezier(.4, 0, .2, 1), visibility .55s;
}
[data-theme="light"] .boot {
  background: radial-gradient(60% 55% at 50% 45%, rgba(255,255,255,.55), rgba(233,235,239,.9) 78%);
}
.boot.hide { opacity: 0; visibility: hidden; pointer-events: none; }

/* The main UI is blurred while the splash is up */
body.booting #fractal,
body.booting .topbar,
body.booting .panel,
body.booting .hud {
  filter: blur(9px);
  transform: scale(1.01);
  transition: filter .5s ease, transform .5s ease;
}

.boot-inner {
  display: flex; flex-direction: column; align-items: center;
  gap: 0; padding: 0 24px; min-width: 300px;
  animation: bootIn .6s cubic-bezier(.2, .7, .3, 1) both;
}
@keyframes bootIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.boot-mark { color: var(--accent); opacity: .9; margin-bottom: 16px; }
.boot-title {
  font: 300 21px/1 var(--font);
  letter-spacing: .42em; text-indent: .42em;
  color: var(--text);
}
.boot-sub {
  margin-top: 7px;
  font: 400 11px/1 var(--font);
  letter-spacing: .22em; text-indent: .22em;
  color: var(--text-3);
}

/* Thin gradient progress bar */
.boot-bar {
  position: relative;
  margin-top: 30px;
  width: 268px; height: 2px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
}
.boot-fill {
  position: absolute; inset: 0 auto 0 0;
  width: 0%;
  border-radius: 2px;
  background: linear-gradient(90deg, rgba(110,168,254,0) 0%, rgba(110,168,254,.55) 22%, #9fc6ff 62%, #dfeaff 100%);
  box-shadow: 0 0 10px rgba(110, 168, 254, .55);
  transition: width .38s cubic-bezier(.3, .8, .3, 1);
}
/* Sweeping highlight */
.boot-fill::after {
  content: '';
  position: absolute; top: 0; bottom: 0; right: 0;
  width: 46px;
  background: linear-gradient(90deg, rgba(255,255,255,0), rgba(255,255,255,.85));
  animation: bootShine 1.5s linear infinite;
}
@keyframes bootShine {
  0% { transform: translateX(-46px); opacity: 0; }
  30% { opacity: .9; }
  100% { transform: translateX(6px); opacity: 0; }
}
[data-theme="light"] .boot-fill {
  background: linear-gradient(90deg, rgba(47,111,219,0) 0%, rgba(47,111,219,.5) 22%, #4d86e6 62%, #7aa8f2 100%);
  box-shadow: 0 0 10px rgba(47, 111, 219, .35);
}

.boot-meta {
  display: flex; align-items: baseline; gap: 14px;
  margin-top: 12px; width: 268px;
  font-size: 10.5px; letter-spacing: .04em;
  color: var(--text-3);
}
#boot-status { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#boot-pct { font-variant-numeric: tabular-nums; color: var(--text-2); }

/* ==========================================================
   Render core panel (download the out-of-browser kernel)
   ========================================================== */
.core-status {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 13px; margin-bottom: 14px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--glass-soft);
  font-size: 12.5px; color: var(--text);
}
.core-status .cs-dot {
  width: 7px; height: 7px; border-radius: 50%; flex: none;
  background: var(--text-3);
}
.core-status.ok .cs-dot { background: #4ec9a0; box-shadow: 0 0 0 3px rgba(78, 201, 160, .13); }
.core-status.busy .cs-dot { background: #e0b23c; box-shadow: 0 0 0 3px rgba(224, 178, 60, .13); }
.core-status .cs-sub { margin-left: auto; font: 500 10.5px/1 var(--mono); color: var(--text-3); }

.core-body p { margin: 0 0 11px; font-size: 12.5px; line-height: 1.75; color: var(--text-2); }
.core-body p code, .core-steps code {
  font-family: var(--mono); font-size: 11.5px; color: var(--text);
  padding: 1px 5px; border-radius: 4px;
  background: rgba(255, 255, 255, .06); border: 1px solid var(--line);
}
[data-theme="light"] .core-body p code,
[data-theme="light"] .core-steps code { background: rgba(0, 0, 0, .05); }

.core-steps {
  counter-reset: cs; list-style: none;
  margin: 14px 0 0; padding: 0;
  display: grid; gap: 9px;
}
.core-steps li {
  position: relative; padding-left: 30px;
  font-size: 12.5px; line-height: 1.6; color: var(--text-2);
}
.core-steps li::before {
  counter-increment: cs; content: counter(cs);
  position: absolute; left: 0; top: .1em;
  width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center;
  font: 500 10px/1 var(--mono); color: var(--text-2);
  border: 1px solid var(--line-strong); background: var(--glass-soft);
}
.core-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.core-actions .btn { height: 32px; display: inline-flex; align-items: center; gap: 7px; padding: 0 13px; }
.core-note {
  margin-top: 14px; padding: 9px 11px;
  border-left: 2px solid var(--line-strong);
  font-size: 11.5px; line-height: 1.7; color: var(--text-3);
}

/* ==========================================================
   Responsive — tablet (≤ 900px) and phone (≤ 640px)
   The layout turns into an app shell: compact top bar, the
   console becomes a bottom sheet, modals become full sheets.
   ========================================================== */
@media (max-width: 900px) {
  .topbar { height: 50px; gap: 10px; padding: 0 max(10px, env(safe-area-inset-left)); }
  .brand { gap: 7px; padding-right: 2px; }
  .brand-name { font-size: 11.5px; letter-spacing: .1em; }
  .top-spacer { min-width: 0; }
  .top-right { gap: 6px; flex: none; }
  .chip { font-size: 10px; padding: 6px 7px; }
  .topbtn { height: 30px; font-size: 12px; }

  /* Console → bottom sheet */
  .panel {
    left: 0 !important; right: 0 !important;
    top: auto !important; bottom: 0;
    width: 100%;
    max-height: 74dvh;
    border-radius: 18px 18px 0 0;
    border-left: 0; border-right: 0; border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -18px 46px rgba(0, 0, 0, .5);
  }
  .panel-head { cursor: default; padding: 4px 14px 10px; }
  .panel-head:active { cursor: default; }
  .panel-grab { display: flex; justify-content: center; padding: 9px 0 2px; }
  .panel-grab span {
    width: 38px; height: 4px; border-radius: 2px;
    background: var(--line-strong);
  }
  .panel-body { padding: 4px 16px calc(18px + env(safe-area-inset-bottom, 0px)); }
  body.panel-open .panel { animation: sheetIn .26s cubic-bezier(.2, .8, .3, 1) both; }
  @keyframes sheetIn { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
  body.panel-open .hud { opacity: 0; transform: translateY(6px); pointer-events: none; }

  #btn-console .ct-lbl { display: none; }
  #btn-console { width: 34px; padding: 0; justify-content: center; }

  /* HUD */
  .hud {
    left: 9px; bottom: calc(9px + env(safe-area-inset-bottom, 0px));
    max-width: calc(100vw - 18px);
    padding: 6px 9px;
    transition: opacity .2s, transform .2s;
  }

  /* Modals */
  .modal, .modal.wide, .modal.mid, .modal.narrow {
    width: calc(100vw - 20px);
    max-height: 88dvh;
  }
  .modal-root { align-items: end; padding-bottom: 0; }
  .modal { border-radius: 16px; }
  .modal-head { padding: 14px 15px 11px; }
  .modal-body { padding: 12px 15px; }
  .modal-foot { padding: 11px 15px; }
  .preset-grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 8px; }
  .fx-list { max-height: none; }
  .formula-grid, .fx-wrap { grid-template-columns: 1fr; }
  .fx-preview { position: sticky; top: 0; z-index: 2; background: var(--glass); }

  .boot-bar, .boot-meta { width: 232px; }

  input[type="range"] { height: 24px; }
  input[type="range"]::-webkit-slider-thumb { width: 15px; height: 15px; margin-top: -6px; }
  .ctl { height: 32px; font-size: 13px; }
  .btn { height: 34px; }
  .iconbtn { width: 34px; height: 34px; }
}

@media (max-width: 560px) {
  .topbar { gap: 6px; }
  .brand-name { display: none; }
  .brand-mark svg { width: 20px; height: 20px; }
  #chip-precision { display: none; }
  .topnav {
    overflow-x: auto; overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    max-width: 100%;
  }
  .topnav::-webkit-scrollbar { display: none; }
  .topbtn { padding: 0 9px; flex: none; }

  .panel { max-height: 78dvh; }
  .row > label { width: 66px; }

  .modal, .modal.wide, .modal.mid, .modal.narrow {
    width: 100%; max-height: 92dvh;
    border-radius: 18px 18px 0 0;
    border-left: 0; border-right: 0; border-bottom: 0;
  }
  .modal-body { padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
  .preset-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pcard .nm { font-size: 11px; }
  .about-stats { gap: 16px; }
  .toast { bottom: calc(20px + env(safe-area-inset-bottom, 0px)); max-width: calc(100vw - 32px); }
  .boot-title { font-size: 18px; }
}

/* Landscape phones: keep the sheet from eating the whole screen */
@media (max-width: 900px) and (orientation: landscape) {
  .panel { max-height: 86dvh; }
}

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

/* ---- Parameter sliders (Desmos style) ---- */
#grp-params h4 { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.prm { margin-bottom: 10px; }
.prm:last-child { margin-bottom: 2px; }
.prm-top { display: flex; align-items: center; gap: 8px; }
.prm-name { width: 18px; text-align: center; font-size: 13px; }
.prm-name i { font-style: italic; font-weight: 600; }
.prm-val { width: 76px; margin-left: auto; text-align: right; }
.prm-gear { flex: 0 0 auto; opacity: .6; }
.prm-gear:hover { opacity: 1; }
.prm-slider { width: 100%; margin: 6px 0 0; }
.prm-range { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 6px; }
.prm-range label { display: flex; flex-direction: column; gap: 3px; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.prm-range input { width: 100%; }

/* ---- desktop-only: self-drawn frosted <select> (kept with the native controller) ---- */
/* ==========================================================
   Self-drawn glass select
   Native <select> pop-ups are OS-drawn and cannot be frosted, so the
   native control is kept only as the data model (hidden, 1px) and every
   visible part is drawn here: a frosted trigger plus a portal pop-up with
   blur, translucency, rounded corners, fade-in, hover/keyboard highlight
   and both light/dark palettes.
   ========================================================== */
.gsel {
  position: relative;
  flex: 1 1 auto; min-width: 0;
  display: flex;
}
.gsel-native {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  opacity: 0; pointer-events: none;
  border: 0; padding: 0;
}
.gsel-btn {
  display: flex; align-items: center; gap: 6px;
  width: 100%; height: 28px;
  padding: 0 7px 0 10px;
  background: var(--glass-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text); font: inherit; font-size: 12px;
  text-align: left; cursor: pointer;
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.gsel-btn:hover { border-color: var(--line-strong); }
.gsel-btn.open,
.gsel-btn:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.gsel-label {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.gsel-chev {
  flex: none; opacity: .55;
  transition: transform .18s cubic-bezier(.2,.72,.3,1);
}
.gsel-btn.open .gsel-chev { transform: rotate(180deg); }

.gsel-pop {
  position: fixed; z-index: 95;
  max-height: 300px; overflow-y: auto;
  padding: 6px;
  display: flex; flex-direction: column; gap: 2px;
  border-radius: 13px;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(255,255,255,.06) 0%, rgba(255,255,255,.012) 46%, rgba(255,255,255,.022) 100%),
    var(--dd-bg);
  -webkit-backdrop-filter: blur(14px) saturate(130%);
  backdrop-filter: blur(14px) saturate(130%);
  border: 1px solid var(--dd-line);
  box-shadow:
    0 28px 64px -20px rgba(0, 0, 0, .74),
    0 10px 26px -12px rgba(0, 0, 0, .46),
    inset 0 1px 0 var(--dd-hi),
    inset 0 -1px 0 rgba(0, 0, 0, .22);
  transform-origin: 50% 0;
  animation: gselIn .16s cubic-bezier(.2,.72,.3,1) both;
  overscroll-behavior: contain;
}
.gsel-pop[hidden] { display: none !important; }
@keyframes gselIn {
  from { opacity: 0; transform: translateY(-6px) scale(.98); }
  to   { opacity: 1; transform: none; }
}
.gsel-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  border: 1px solid transparent; border-radius: 8px;
  background: transparent; color: var(--text);
  font: inherit; font-size: 12px; text-align: left; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background .1s ease, border-color .1s ease, color .1s ease;
}
.gsel-item.active,
.gsel-item:hover { background: var(--dd-item); border-color: var(--dd-line); }
.gsel-item.on { color: var(--accent); }
.gsel-item.on::after {
  content: ""; flex: none;
  width: 5px; height: 5px; margin-left: auto;
  border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 8px var(--accent-dim);
}
.gsel-group {
  padding: 7px 10px 4px;
  font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--text-3);
  user-select: none;
}
@media (max-width: 900px) { .gsel-btn { height: 32px; font-size: 13px; } }

/* ------------------------------------------------------------------
 * Native surface mode.
 *
 * The product image is presented by a D3D child window that sits UNDER the
 * WebView2, so the page has to be see-through: an opaque html/body (or the
 * 2D canvas, which is created with alpha:false) would hide every frame that
 * the shell commits.  `app.js` adds this class only after a pass has actually
 * been committed to the swapchain, and removes it whenever a pass takes the
 * JS fallback path (custom formulas), so the screen always shows the most
 * recent surface.
 * ---------------------------------------------------------------- */
html.native-surface,
html.native-surface body { background: transparent; }
html.native-surface #fractal { opacity: 0; }
/* The shell's canvas is *behind* this page.  The page's own shader layer is a
 * sibling of #fractal, not a child, so hiding #fractal alone left the WebGL
 * copy on top: two renderers of the same view, one of them the page's, and
 * whichever had drawn last was what the user saw.  That is the flicker. */
html.native-surface #glfractal { opacity: 0; }

/* ------------------------------------------------------------------
 * Presets panel: library toolbar, colour footer.
 *
 * The colour block is a footer of the panel rather than another modal: the
 * point of the sliders is to watch the picture change, so they have to stay on
 * screen while the user drags them, and the modal's scrim is cleared for the
 * same reason (see .previewing below).
 * ---------------------------------------------------------------- */
.modal-root.previewing .modal-scrim,
#modal-root.previewing .modal-scrim { background: rgba(4, 5, 7, .16); backdrop-filter: none; }

.preset-grow { flex: 1 1 auto; }
.preset-toolbar .btn.tiny { flex: 0 0 auto; }
.pcard.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }

.pce {
  position: sticky; bottom: -14px; z-index: 3;
  margin: 14px -18px -14px; padding: 10px 18px 12px;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--glass-strong, rgba(16,18,24,.92)) 92%, transparent);
  backdrop-filter: blur(14px);
}
.pce-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.pce-title { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--text-3); }
.pce-hint { font: 500 10.5px/1 var(--mono); color: var(--text-3); }
.pce-head .btn.tiny { flex: 0 0 auto; }

/* Three lanes, but flatter than the console's: the panel is about the picture. */
.pce-stack { gap: 14px; }
.pce-stack .grad-bar { height: 14px; }
.pce-stack .grad-lane-tag { font-size: 8.5px; }

.pce-rgb { display: flex; gap: 14px; margin-top: 22px; flex-wrap: wrap; }
.pce-slide { flex: 1 1 150px; display: flex; align-items: center; gap: 8px; min-width: 130px; }
.pce-ch { font: 600 10px/1 var(--mono); color: var(--text-3); width: 8px; }
.pce-slide input[type="range"] { flex: 1 1 auto; min-width: 40px; accent-color: var(--accent); }
.pce-slide b { font: 500 10.5px/1 var(--mono); color: var(--text-2); width: 26px; text-align: right; }

/* Mathematics guide: the whole document in one readable sheet. */
.modal.doc {
  background: var(--bg);
  box-shadow: 0 24px 80px rgba(0,0,0,.75), 0 0 0 1px var(--line, rgba(128,140,160,.24));
  width: min(1400px, calc(100vw - 32px));
  height: min(920px, 88vh);
  max-height: none;
  display: flex;
  flex-direction: column;
}
.modal.doc .modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 26px 30px;
  scroll-behavior: smooth;
}
.doc-md { max-width: 1080px; margin: 0 auto; line-height: 1.75; color: var(--text); font-size: 14px; }
.doc-md h1 { font-size: 25px; line-height: 1.3; margin: 4px 0 18px; letter-spacing: -.01em; }
.doc-md h2 { font-size: 19px; margin: 30px 0 12px; padding-bottom: 7px; border-bottom: 1px solid var(--line, rgba(128,140,160,.22)); }
.doc-md h3 { font-size: 16px; margin: 24px 0 10px; }
.doc-md h4, .doc-md h5, .doc-md h6 { font-size: 14px; margin: 18px 0 8px; }
.doc-md p { margin: 9px 0; }
.doc-md ul, .doc-md ol { margin: 8px 0 8px 22px; padding: 0; }
.doc-md li { margin: 4px 0; }
.doc-md code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; padding: 1px 5px; border-radius: 4px; background: rgba(128,140,160,.14); }
.doc-md pre { margin: 12px 0; padding: 13px 15px; overflow-x: auto; border-radius: 9px; border: 1px solid var(--line, rgba(128,140,160,.22)); background: rgba(10,13,20,.72); color: #d6e2f0; }
[data-theme="light"] .doc-md pre { background: #f3f5f9; color: #243044; }
.doc-md pre code { padding: 0; background: none; font-size: 12px; line-height: 1.55; }
.doc-md blockquote { margin: 12px 0; padding: 8px 15px; border-left: 3px solid var(--accent); background: rgba(128,140,160,.09); color: var(--text-2, var(--text)); }
.doc-md hr { margin: 26px 0; border: 0; border-top: 1px solid var(--line, rgba(128,140,160,.22)); }
.doc-md a { color: var(--accent); text-decoration: none; }
.doc-md a:hover { text-decoration: underline; }
.doc-table { overflow-x: auto; margin: 12px 0; }
.doc-table table { border-collapse: collapse; min-width: 100%; font-size: 12.5px; }
.doc-table th, .doc-table td { border: 1px solid var(--line, rgba(128,140,160,.22)); padding: 7px 10px; text-align: left; vertical-align: top; }
.doc-table th { background: rgba(128,140,160,.09); font-weight: 600; }
.doc-loading { color: var(--text-3, var(--text)); padding: 30px 0; text-align: center; }
