  /* EIDOLON — styles. The header, panels, buttons, toggle and footer stamp are
     the shared cyberdeck.tools chrome (copied from the sibling apps, not
     imported); keep them in sync when the family's chrome changes. */
  :root {
    --yellow: #fcee0a;
    --cyan: #00f0ff;
    --magenta: #ff003c;
    --bg: #050507;
    --panel: #0b0b10;
    --panel-2: #14141c;
    --text: #e8e8ee;
    --dim: #7a7a88;
    --accent: #fcee0a;
    --accent-rgb: 252,238,10;
    --main: #00f0ff;
    --main-rgb: 0,240,255;
  }
  * { box-sizing: border-box; margin: 0; padding: 0; }
  .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

  /* ---------- Cyberpunk scrollbars (ported from commlink-ui) ---------- */
  /* NOTE: do NOT set standard `scrollbar-color` / `scrollbar-width` on `*`.
     In Chromium they take precedence and silently disable every
     `::-webkit-scrollbar*` pseudo. Firefox fallback is scoped via @supports. */
  ::-webkit-scrollbar { width: 8px; height: 8px; }
  ::-webkit-scrollbar-track {
    background: rgba(0, 240, 255, 0.05);
    border: 1px solid rgba(0, 240, 255, 0.35);
  }
  ::-webkit-scrollbar-thumb { background: var(--cyan); border-radius: 0; box-shadow: none; }
  ::-webkit-scrollbar-thumb:hover { background: var(--yellow); }
  ::-webkit-scrollbar-corner { background: var(--panel); }
  ::-webkit-scrollbar-button {
    background-color: rgba(0, 240, 255, 0.08);
    background-repeat: no-repeat; background-position: center; background-size: 100% 100%;
    display: block; height: 8px; width: 8px;
  }
  ::-webkit-scrollbar-button:hover { background-color: rgba(0, 240, 255, 0.2); }
  ::-webkit-scrollbar-button:vertical:decrement {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'><polygon points='5,0 10,10 0,10' fill='%2300f0ff'/></svg>");
  }
  ::-webkit-scrollbar-button:vertical:increment {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'><polygon points='0,0 10,0 5,10' fill='%2300f0ff'/></svg>");
  }
  ::-webkit-scrollbar-button:horizontal:decrement {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'><polygon points='0,5 10,0 10,10' fill='%2300f0ff'/></svg>");
  }
  ::-webkit-scrollbar-button:horizontal:increment {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'><polygon points='0,0 10,5 0,10' fill='%2300f0ff'/></svg>");
  }
  ::-webkit-scrollbar-button:start:increment,
  ::-webkit-scrollbar-button:end:decrement { display: none; }
  @supports (-moz-appearance: none) {
    * { scrollbar-color: var(--cyan) rgba(0, 240, 255, 0.06); scrollbar-width: thin; }
  }

  body {
    background: var(--bg);
    color: var(--text);
    font-family: 'JetBrains Mono', monospace;
    min-height: 100vh;
    padding: 28px 18px 64px 50px;   /* left room for the PRESETS edge tab */
    background-image: repeating-linear-gradient(0deg, rgba(var(--main-rgb),0.03) 0 1px, transparent 1px 3px);
  }
  .app { max-width: 1800px; margin: 0 auto; }

  /* ---------- Header (shared across cyberdeck.tools apps) ---------- */
  header.top {
    display: flex; align-items: center; gap: 18px;
    border-bottom: 1px solid rgba(252,238,10,0.25); padding-bottom: 16px; margin-bottom: 22px;
  }
  .logo-menu { position: relative; }
  .logo {
    font-family: 'JetBrains Mono', monospace;
    color: var(--yellow); font-size: 22px; letter-spacing: 2px; font-weight: 700;
    background: none; border: none; cursor: pointer; transition: filter .15s;
  }
  .logo:hover { filter: drop-shadow(0 0 6px rgba(var(--accent-rgb),0.6)); }
  .logo .chev { display: inline-block; transition: transform .2s ease; }
  .logo[aria-expanded="true"] .chev { transform: rotate(90deg); }
  .tag {
    color: var(--cyan); font-size: 12px; letter-spacing: 1px;
    border-left: 1px solid var(--dim); padding-left: 18px;
  }
  .tag .tag-meta { cursor: default; color: var(--cyan); }
  .lang-select {
    background: var(--panel); color: var(--main);
    border: 1px solid rgba(var(--main-rgb),0.4);
    padding: 6px 10px; font-family: 'JetBrains Mono', monospace;
    font-size: 12px; font-weight: 700; letter-spacing: 2px;
    text-transform: uppercase; cursor: pointer;
  }
  header.top .lang-select { margin-left: auto; }
  .app-menu {
    position: absolute; top: calc(100% + 12px); left: 0; z-index: 30;
    display: flex; flex-direction: column; gap: 4px;
    min-width: 240px; padding: 12px 14px;
    background: var(--panel);
    --aug-border-all: 1px; --aug-border-bg: rgba(var(--main-rgb),0.5);
    --aug-tl: 10px; --aug-br: 10px;
  }
  .app-menu[hidden] { display: none; }
  .app-menu-item {
    font-size: 16px; letter-spacing: 2px;
    color: var(--yellow); text-decoration: none; white-space: nowrap;
    padding: 6px 8px; transition: color .12s, background .12s;
  }
  .app-menu-item:hover { background: rgba(var(--main-rgb),0.12); color: var(--accent); }
  .app-menu-item.current { color: var(--main); cursor: default; }
  .app-menu-item.current:hover { background: none; }
  .glitchable { display: inline-block; white-space: pre; }
  .glitchable.glitching {
    color: var(--yellow);
    text-shadow: 2px 0 var(--cyan), -2px 0 var(--magenta);
    animation: tagGlitchJitter 0.08s steps(2) infinite;
  }
  @keyframes tagGlitchJitter {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(-1px, 1px); }
    50% { transform: translate(1px, -1px); }
    75% { transform: translate(-1px, -1px); }
  }

  /* ---------- Layout: config left + right, working area center ---------- */
  .layout { display: flex; gap: 22px; align-items: stretch; }
  .config {
    width: 340px; flex-shrink: 0; padding: 16px 16px 22px;
    background: var(--panel);
    --aug-border-all: 1px; --aug-border-bg: rgba(var(--main-rgb),0.35);
    --aug-tl: 12px; --aug-br: 12px;
    align-self: flex-start;
  }
  /* third column (OUTPUT / BATCH) holds less, so it runs narrower */
  .config-out { width: 290px; }
  .config h2, .side-inner h2 {
    font-size: 13px; letter-spacing: 2px; color: var(--dim);
    text-transform: uppercase; font-weight: 700; margin-bottom: 12px;
  }
  .config .hint, .side-inner .hint { color: var(--dim); font-size: 12px; line-height: 1.6; }

  /* shared primary button (augmented-ui clipped corners) */
  .btn {
    --btn-color: var(--accent);
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 44px; padding: 0 16px;
    background: transparent; color: var(--btn-color);
    font-family: 'JetBrains Mono', monospace; font-size: 14px; line-height: 1;
    letter-spacing: 3px; text-transform: uppercase; cursor: pointer; border: none;
    transition: background .15s, color .15s, box-shadow .15s, opacity .15s;
    --aug-border-all: 1px; --aug-border-bg: var(--btn-color);
    --aug-inlay-all: 0px; --aug-inlay-bg: transparent;
    --aug-tl: 12px; --aug-br: 12px;
  }
  .btn:hover { background: color-mix(in srgb, var(--btn-color) 22%, transparent); box-shadow: 0 0 12px color-mix(in srgb, var(--btn-color) 45%, transparent); }
  .btn:disabled { opacity: .4; cursor: not-allowed; background: transparent; box-shadow: none; }
  .btn-sm { height: 36px; padding: 0 12px; font-size: 12px; letter-spacing: 2px; }
  .btn-block { width: 100%; margin-top: 16px; }

  /* shared sliding two-state toggle (ported from chronos-ui .side-switch) */
  .fx-toggle { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; }
  .fx-label { font-size: 12px; letter-spacing: 1.5px; color: var(--main); text-transform: uppercase; }
  .side-switch {
    position: relative; height: 30px; width: 112px; background: var(--panel);
    border: 1px solid rgba(var(--main-rgb), 0.3); cursor: pointer;
    display: flex; align-items: stretch; overflow: hidden; flex-shrink: 0;
    font-family: 'JetBrains Mono', monospace; transition: border-color .15s;
  }
  .side-switch:hover { border-color: var(--main); }
  .side-switch .thumb {
    position: absolute; top: 0; left: 0; width: 50%; height: 100%;
    background: color-mix(in srgb, var(--main) 22%, transparent);
    transition: transform .22s cubic-bezier(.4, 0, .2, 1); z-index: 0;
  }
  .side-switch[data-pos="right"] .thumb { transform: translateX(100%); }
  .side-switch .lab {
    flex: 1; display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; letter-spacing: 1px; z-index: 1; position: relative;
    pointer-events: none; white-space: nowrap; color: var(--dim); transition: color .15s .08s;
  }
  .side-switch[data-pos="left"] .lab.l,
  .side-switch[data-pos="right"] .lab.r { color: var(--main); }
  /* multi-position variant: data-opts on the button, JS sets --n / --idx and .on */
  .side-switch.multi { width: 196px; }
  .side-switch.multi .thumb { width: calc(100% / var(--n, 4)); transform: translateX(calc(var(--idx, 0) * 100%)); }
  .side-switch.multi .lab { font-size: 10px; letter-spacing: .5px; }
  .side-switch.multi .lab.on { color: var(--main); }
  .fx-toggle.disabled { opacity: .4; pointer-events: none; }

  /* faded-edge cyan horizontal divider between config sections */
  .divider {
    border: none; height: 1px; margin: 18px 0;
    background: linear-gradient(90deg, transparent, rgba(var(--main-rgb),0.55), transparent);
  }

  /* ---------- Form controls (config panels) ---------- */
  .field { margin-bottom: 12px; }
  .field > label {
    display: block; font-size: 10px; letter-spacing: 1.5px; color: var(--dim);
    text-transform: uppercase; margin-bottom: 5px;
  }
  .config input[type="text"], .config input[type="number"], .side-inner input[type="text"] {
    width: 100%; background: var(--bg); color: var(--text);
    border: 1px solid rgba(var(--main-rgb),0.3);
    padding: 8px 10px; font-family: 'JetBrains Mono', monospace; font-size: 13px;
    transition: border-color .15s, box-shadow .15s;
  }
  .config input:focus, .side-inner input:focus {
    outline: none; border-color: var(--main);
    box-shadow: 0 0 8px rgba(var(--main-rgb),0.35);
  }
  .config input::placeholder, .side-inner input::placeholder { color: rgba(122,122,136,0.6); }
  .row { display: flex; gap: 10px; align-items: flex-end; }
  .row .field { flex: 1; margin-bottom: 0; }

  .config .hint { margin-top: 10px; }
  .config .hint-gap { margin-bottom: 4px; }
  .config input:disabled { opacity: .4; cursor: not-allowed; }

  /* button rows (LOAD / CLEAR, custom frame / mask, resets) */
  .btn-row { display: flex; gap: 8px; margin-top: 4px; }
  .btn-row .btn { flex: 1; min-width: 0; padding: 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .btn-row + .btn-row { margin-top: 8px; }
  .fx-toggle + .btn-row { margin-top: 16px; }
  .btn-alt { --btn-color: var(--main); }
  .btn-warn { --btn-color: var(--magenta); }
  .btn-block + .btn-block { margin-top: 10px; }
  .btn.busy { cursor: progress; }
  .url-row { display: flex; gap: 8px; margin-top: 10px; }
  .url-row input { flex: 1; min-width: 0; }
  .url-row .btn { flex: none; }

  /* name + badge fields (TOKEN) */
  .field-grow { flex: 1; }
  .row .field-badge { flex: 0 0 76px; }
  .field-badge input { text-align: center; text-transform: uppercase; }
  #nameInput { text-transform: uppercase; }

  /* FRAME picker: 6-column grid of live-drawn frame thumbnails */
  .frame-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; margin-bottom: 10px; }
  .frame-tile {
    aspect-ratio: 1; padding: 3px; cursor: pointer; line-height: 0;
    background: var(--bg); border: 1px solid rgba(var(--main-rgb),0.2);
    transition: border-color .12s, box-shadow .12s, background .12s;
  }
  .frame-tile canvas { width: 100%; height: 100%; display: block; }
  .frame-tile:hover { border-color: rgba(var(--main-rgb),0.6); }
  .frame-tile.active {
    border-color: var(--accent); background: rgba(var(--accent-rgb),0.08);
    box-shadow: 0 0 8px rgba(var(--accent-rgb),0.45);
  }

  /* colour swatches: a clickable augmented-ui rectangle hiding a colour input
     (ported from gridmap-ui); the group matches the 112px toggle footprint */
  .fill-group { display: flex; align-items: center; gap: 6px; width: 112px; flex-shrink: 0; }
  .fill-swatch, .fill-extend, .fill-transparent, .fill-swap {
    flex: 1; height: 30px; cursor: pointer; border: none; padding: 0;
    display: flex; align-items: center; justify-content: center;
    --aug-border-all: 1px; --aug-border-bg: rgba(255, 255, 255, 0.3);
    --aug-tl: 8px; --aug-br: 8px;
  }
  .fill-swap {
    flex: 0 0 30px; background: var(--panel); color: var(--main);
    font-family: 'JetBrains Mono', monospace; font-size: 15px; font-weight: 700;
    --aug-border-bg: rgba(var(--main-rgb),0.4);
  }
  .fill-swap:hover { background: rgba(var(--main-rgb),0.15); }
  /* EXTEND fill mode: the radial rainbow of gridmap-ui's VIBRANT fill button */
  .fill-extend {
    background: radial-gradient(circle at 32% 30%, #ff3d81 0%, #ff9e00 30%, #ffe600 48%, #2bd9a0 66%, #38a8ff 82%, #b15cff 100%);
  }
  /* TRANSPARENT fill mode: a checkerboard swatch */
  .fill-transparent {
    background-color: #cfcfcf;
    background-image:
      linear-gradient(45deg, #8a8a8a 25%, transparent 25%), linear-gradient(-45deg, #8a8a8a 25%, transparent 25%),
      linear-gradient(45deg, transparent 75%, #8a8a8a 75%), linear-gradient(-45deg, transparent 75%, #8a8a8a 75%);
    background-size: 10px 10px; background-position: 0 0, 0 5px, 5px -5px, -5px 0;
  }
  .fill-swatch.active, .fill-extend.active, .fill-transparent.active {
    --aug-border-bg: var(--main); --aug-border-all: 2px;
    filter: drop-shadow(0 0 5px rgba(var(--main-rgb), 0.9));
  }
  /* the real colour input is off-screen; the swatch opens it via showPicker() */
  .fill-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

  /* colour-source chooser (LABEL): FR / AC / BG / custom (/ AUTO) chips, each
     painted in the colour it resolves to; the active one gets a yellow ring */
  .src-group { display: flex; gap: 5px; flex-shrink: 0; }
  .src-chip {
    width: 26px; height: 26px; padding: 0; cursor: pointer; flex: none;
    display: flex; align-items: center; justify-content: center;
    font-family: 'JetBrains Mono', monospace; font-size: 9px; font-weight: 700; letter-spacing: 0;
    border: 1px solid rgba(255,255,255,0.25); transition: box-shadow .12s, border-color .12s;
  }
  .src-chip:hover { border-color: var(--main); }
  .src-chip.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 8px rgba(var(--accent-rgb),0.6); }
  .src-chip svg { width: 14px; height: 14px; display: block; pointer-events: none; }
  .src-chip.auto { background: linear-gradient(135deg, #050507 50%, #e8e8ee 50%); }

  /* quick palette chips: click = frame colour, right-click = accent colour */
  .palette { display: flex; gap: 6px; margin-top: 12px; }
  .palette .chip {
    flex: 1; height: 14px; border: 1px solid rgba(255,255,255,0.18); cursor: pointer; padding: 0;
    transition: transform .1s, box-shadow .1s;
  }
  .palette .chip:hover { transform: translateY(-1px); box-shadow: 0 0 8px rgba(var(--main-rgb),0.5); }

  /* range sliders — cyan thumb on a dim track (ported from gridmap-ui POTENCY) */
  .potency-slider {
    -webkit-appearance: none; appearance: none; width: 112px; height: 4px;
    background: rgba(var(--main-rgb),0.25); cursor: pointer; outline: none; flex-shrink: 0;
  }
  .potency-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none; width: 12px; height: 16px;
    background: var(--main); border: none; cursor: pointer;
  }
  .potency-slider::-moz-range-thumb {
    width: 12px; height: 16px; background: var(--main); border: none; border-radius: 0; cursor: pointer;
  }
  .potency-slider:hover::-webkit-slider-thumb { box-shadow: 0 0 8px rgba(var(--main-rgb),0.7); }
  .potency-slider:hover::-moz-range-thumb { box-shadow: 0 0 8px rgba(var(--main-rgb),0.7); }
  .potency-slider:focus-visible { outline: 1px solid var(--accent); outline-offset: 4px; }
  .potency-slider:disabled { opacity: .35; cursor: not-allowed; }
  .fx-label .val { color: var(--accent); font-weight: 700; letter-spacing: 1px; }

  /* dropdowns (ported from gridmap-ui .scale-select) */
  .scale-select {
    background: var(--panel); color: var(--main); border: 1px solid rgba(var(--main-rgb),0.4);
    padding: 6px 8px; font-family: 'JetBrains Mono', monospace;
    font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase;
    cursor: pointer; width: 158px; flex-shrink: 0;
  }
  .scale-select:focus { outline: none; border-color: var(--main); box-shadow: 0 0 6px rgba(var(--main-rgb),0.4); }
  .config input.set-count { width: 112px; flex-shrink: 0; text-align: center; padding: 6px 8px; }

  /* ---------- Center working area ---------- */
  .workspace { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 14px; align-self: flex-start; }
  .stage {
    /* hugs the preview: height = canvas + padding (the canvas is sized from the width) */
    padding: 22px; position: relative;
    display: flex; align-items: center; justify-content: center;
    border: 2px dashed rgba(var(--main-rgb),0.35);
    background: repeating-linear-gradient(45deg, rgba(var(--main-rgb),0.03) 0 12px, transparent 12px 24px);
    color: var(--dim); text-align: center; overflow: hidden;
    transition: border-color .12s, background-color .12s;
  }
  .stage.has-image { border-style: solid; border-color: rgba(var(--main-rgb),0.5); }
  .stage.dragover { border-color: var(--accent); background-color: rgba(var(--accent-rgb),0.06); }
  .token-wrap { position: relative; line-height: 0; }
  /* checkerboard behind the preview = transparent pixels */
  #tokenCanvas {
    display: block; cursor: pointer; outline: none; touch-action: none;
    background-color: #111116;
    background-image:
      linear-gradient(45deg, #1c1c24 25%, transparent 25%), linear-gradient(-45deg, #1c1c24 25%, transparent 25%),
      linear-gradient(45deg, transparent 75%, #1c1c24 75%), linear-gradient(-45deg, transparent 75%, #1c1c24 75%);
    background-size: 24px 24px; background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  }
  .stage.has-image #tokenCanvas { cursor: grab; }
  #tokenCanvas.grabbing { cursor: grabbing !important; }
  #tokenCanvas:focus-visible { outline: 1px solid var(--accent); outline-offset: 4px; }
  .token-wrap .placeholder {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 70%;
    pointer-events: none; font-size: 13px; letter-spacing: 1px; line-height: 1.8;
    padding: 14px; background: rgba(5,5,7,0.72);
  }
  .token-wrap .placeholder b { color: var(--main); font-size: 17px; letter-spacing: 3px; }
  .stage.has-image .placeholder { display: none; }
  .canvas-footer { text-align: center; margin-top: -4px; }
  .canvas-hint { font-size: 10px; letter-spacing: 1.5px; color: var(--dim); text-transform: uppercase; }

  /* REFERENCE bar above the stage: silhouette picker + opacity */
  .ref-bar {
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 10px 14px;
    background: var(--panel);
    --aug-border-all: 1px; --aug-border-bg: rgba(var(--main-rgb),0.35);
    --aug-tl: 10px; --aug-br: 10px;
  }
  .ref-bar .ref-label { cursor: help; }
  .ref-bar[hidden] { display: none; }
  /* POP-OUT BRUSH bar (same shell as the reference bar, yellow while painting) */
  .pop-bar { --aug-border-bg: rgba(var(--accent-rgb),0.6); }
  .pop-bar .pop-title { color: var(--accent); font-weight: 700; }
  .pop-bar .btn { flex: none; }
  /* FILL / CLEAR / DONE never split; DONE shortens to OK when the bar is tight */
  .pop-actions { display: flex; gap: 8px; flex-wrap: nowrap; }
  #popDone .lbl-short, #popDone.short .lbl-full { display: none; }
  #popDone.short .lbl-short { display: inline; }
  .side-switch.pop-mode { width: 150px; }
  .stage.brushing #tokenCanvas { cursor: crosshair; }
  .btn-row.pop-row { margin-top: 12px; }
  .btn.pop-paint.active { background: color-mix(in srgb, var(--btn-color) 28%, transparent); box-shadow: 0 0 12px color-mix(in srgb, var(--btn-color) 50%, transparent); }
  .ref-tiles { display: flex; gap: 6px; }
  .ref-tile {
    position: relative; width: 36px; height: 36px; padding: 3px; line-height: 0; cursor: pointer;
    background: var(--bg); color: var(--main); border: 1px solid rgba(var(--main-rgb),0.2);
    transition: border-color .12s, box-shadow .12s, color .12s, background .12s;
  }
  .ref-tile svg, .ref-tile canvas { width: 100%; height: 100%; display: block; }
  .ref-tile:hover { border-color: rgba(var(--main-rgb),0.6); }
  .ref-tile.active {
    border-color: var(--accent); color: var(--accent); background: rgba(var(--accent-rgb),0.08);
    box-shadow: 0 0 8px rgba(var(--accent-rgb),0.45);
  }
  .ref-tile .roster-x { width: 14px; height: 14px; line-height: 13px; font-size: 12px; }
  .ref-tile:hover .roster-x { opacity: 1; }
  .ref-op { display: flex; align-items: center; gap: 12px; margin-left: auto; }
  /* the overlay canvas sits exactly on the preview and never takes input */
  .token-wrap .ref-canvas { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; }

  /* roster: every loaded token as a live thumbnail */
  .roster { display: flex; flex-wrap: wrap; gap: 10px; min-height: 92px; }
  .roster-item, .roster-add {
    position: relative; width: 92px; height: 92px; padding: 3px; line-height: 0; cursor: pointer;
    background: var(--panel); border: 1px solid rgba(var(--main-rgb),0.25);
    transition: border-color .12s, box-shadow .12s;
  }
  .roster-item canvas { width: 84px; height: 84px; display: block; }
  .roster-item:hover { border-color: rgba(var(--main-rgb),0.7); }
  .roster-item.active { border-color: var(--accent); box-shadow: 0 0 10px rgba(var(--accent-rgb),0.45); }
  .roster-x {
    position: absolute; top: -1px; right: -1px; width: 20px; height: 20px; line-height: 18px;
    font-size: 15px; color: var(--bg); background: var(--magenta); text-align: center;
    opacity: 0; transition: opacity .12s;
  }
  .roster-item:hover .roster-x, .roster-item:focus-visible .roster-x { opacity: 1; }
  .roster-add {
    font-family: 'JetBrains Mono', monospace; font-size: 30px; color: var(--main);
    border-style: dashed; background: transparent;
  }
  .roster-add:hover { border-color: var(--accent); color: var(--accent); }

  @media (max-width: 1280px) {
    .layout { flex-wrap: wrap; }
    .config { width: 100%; }
    .workspace { order: -1; width: 100%; }
  }

  /* ---------- Side panels (ported from commlink-ui): fixed, slide in from
     the left edge; a vertical tab sticking out of the panel toggles it ---------- */
  .side-panel {
    position: fixed; top: 0; left: 0; z-index: 50;
    width: 345px; height: 100vh;
    display: flex; flex-direction: column;
    background: var(--panel); border-right: 1px solid rgba(var(--accent-rgb),0.35);
    transform: translateX(-100%); transition: transform .28s ease;
  }
  .side-panel.open { transform: translateX(0); box-shadow: 0 0 30px rgba(0,0,0,0.6); }
  /* one panel at a time: while one is open, the others (and their tabs) hide */
  .side-panel.peer-open { visibility: hidden; }
  /* FX tab sits under PRESETS (whose tab can grow to ~180px for long labels) */
  .side-panel[data-panel="fx"] .side-toggle { top: 290px; }
  /* tab stays yellow and glows brighter while any effect is live */
  .side-toggle.lit { color: var(--yellow); --aug-border-bg: rgba(var(--accent-rgb),0.9); box-shadow: 0 0 14px rgba(var(--accent-rgb),0.45); text-shadow: 0 0 6px rgba(var(--accent-rgb),0.7); }
  .side-toggle {
    position: absolute; left: 100%; top: 90px; width: 32px; min-height: 150px; /* grows with long labels (FR) */
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
    padding: 14px 0; border: none; cursor: pointer;
    background: var(--panel); color: var(--yellow); font-family: 'JetBrains Mono', monospace;
    --aug-border-all: 1px; --aug-border-bg: rgba(var(--accent-rgb),0.45);
    --aug-tr: 10px; --aug-br: 10px;
    transition: color .15s, box-shadow .15s;
  }
  .side-toggle .label {
    writing-mode: vertical-rl; transform: rotate(180deg);
    font-size: 14px; font-weight: 700; letter-spacing: 3px; text-transform: uppercase;
  }
  /* CJK reads top-to-bottom natively in vertical-rl; the Latin 180° flip would invert it */
  html[lang="ja"] .side-toggle .label, html[lang="zh"] .side-toggle .label { transform: none; }
  .side-toggle .arrow { font-size: 16px; line-height: 1; }
  .side-toggle:hover { color: var(--cyan); box-shadow: 8px 0 18px rgba(var(--accent-rgb),0.2); }
  .side-inner { padding: 22px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; min-height: 0; }

  /* PRESETS panel content */
  .preset-save { display: flex; gap: 8px; }
  .preset-save input { flex: 1; min-width: 0; text-transform: uppercase; }
  .preset-save .btn { flex: none; }
  .check-toggle {
    display: flex; align-items: center; gap: 8px; margin-top: 12px; cursor: pointer; user-select: none;
    color: var(--dim); font-size: 11px; letter-spacing: 2px; text-transform: uppercase; transition: color .15s;
  }
  .check-toggle:hover { color: var(--cyan); }
  .check-toggle input {
    appearance: none; -webkit-appearance: none; width: 14px; height: 14px; margin: 0; flex-shrink: 0;
    position: relative; cursor: pointer; background: var(--panel); border: 1px solid rgba(var(--main-rgb),0.45);
  }
  .check-toggle input:checked { background: var(--cyan); border-color: var(--cyan); box-shadow: 0 0 6px rgba(var(--main-rgb),0.5); }
  .check-toggle input:checked::after {
    content: ''; position: absolute; left: 4px; top: 1px; width: 4px; height: 8px;
    border: solid var(--bg); border-width: 0 2px 2px 0; transform: rotate(45deg);
  }
  .preset-list { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; flex: 1; overflow-y: auto; min-height: 0; }
  .preset-empty { color: var(--dim); font-size: 11px; letter-spacing: 2px; padding: 6px 0; }
  .preset-item {
    display: flex; gap: 12px; align-items: center; padding: 8px 10px;
    background: var(--panel-2); border-left: 2px solid var(--cyan);
  }
  .preset-item.active { border-left-color: var(--accent); box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb),0.25); }
  .preset-thumb { width: 56px; height: 56px; flex: none; cursor: pointer; }
  .preset-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
  .preset-name { font-size: 14px; letter-spacing: 1px; color: var(--text); word-break: break-all; line-height: 1.3; }
  .preset-item.active .preset-name { color: var(--accent); }
  .preset-meta { font-size: 10px; letter-spacing: 1px; color: var(--dim); }
  .preset-actions { display: flex; gap: 6px; }
  .preset-actions .btn { height: 30px; padding: 0 10px; font-size: 11px; letter-spacing: 2px; --aug-tl: 8px; --aug-br: 8px; }
  .preset-actions [data-apply] { flex: 1; }
  .preset-actions [data-override], .preset-actions [data-del] { width: 30px; padding: 0; font-size: 15px; letter-spacing: 0; }
  .preset-hint { margin-top: 14px; }   /* sits at the bottom: the list above flexes to fill */
  .preset-io { margin-top: 12px; }

  /* FX panel content */
  .fx-master { margin-top: 4px; }
  .fx-master .fx-label { color: var(--accent); font-weight: 700; font-size: 13px; }
  .fx-body.off { opacity: .4; pointer-events: none; }
  .fx-body .divider { margin: 16px 0 2px; }
  .fx-param .fx-label { padding-left: 14px; font-size: 11px; color: rgba(var(--main-rgb),0.75); }
  .fx-param .btn.fx-reroll { width: 112px; height: 30px; font-size: 11px; --aug-tl: 8px; --aug-br: 8px; }
  .fx-reset { margin-top: 20px; }

  /* ---------- Modal (ported from chronos-ui / commlink-ui .modal-overlay) ----------
     .modal-content also carries .config for the shared form styles; the
     rules below come later, so they win over .config's column sizing. */
  .modal-overlay {
    position: fixed; inset: 0; z-index: 200;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,0.75); backdrop-filter: blur(2px);
  }
  .modal-overlay[hidden] { display: none; }
  .modal-content {
    width: 90%; max-width: 420px; padding: 24px; align-self: center;
    background: var(--panel);
    --aug-border-all: 1px; --aug-border-bg: rgba(var(--accent-rgb),0.45);
    --aug-tl: 14px; --aug-tr: 14px; --aug-br: 14px; --aug-bl: 14px;
  }
  .modal-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
  .modal-head h2 { margin: 0; color: var(--accent); letter-spacing: 3px; }
  .batch-fmt { font-size: 11px; letter-spacing: 1.5px; color: var(--main); text-transform: uppercase; }
  .batch-count { font-size: 20px; letter-spacing: 1px; color: var(--accent); }
  .batch-block .btn-block { margin-top: 12px; }
  .modal-actions { display: flex; justify-content: flex-end; margin-top: 16px; }

  /* ---------- Toast (commlink-ui style, augmented-ui clipped): status messages
     rise from the bottom centre and fade out; yellow = info, cyan = done,
     magenta = problem. Sits above side panels (50) and modals (200). ---------- */
  .toast {
    --toast-color: var(--yellow);
    position: fixed; left: 50%; bottom: 28px; z-index: 300;
    max-width: min(560px, calc(100vw - 40px)); padding: 11px 20px;
    background: var(--panel); color: var(--toast-color);
    font-size: 12px; letter-spacing: 2px; text-transform: uppercase; text-align: center; line-height: 1.5;
    --aug-border-all: 1px; --aug-border-bg: var(--toast-color);
    --aug-tl: 10px; --aug-br: 10px;
    box-shadow: 0 0 18px color-mix(in srgb, var(--toast-color) 30%, transparent);
    opacity: 0; transform: translateX(-50%) translateY(20px);
    transition: opacity .2s, transform .2s; pointer-events: none;
  }
  .toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
  .toast.ok { --toast-color: var(--cyan); }
  .toast.warn { --toast-color: var(--magenta); }

  /* faint fixed footer stamp (shared across cyberdeck.tools apps) */
  .footer-stamp {
    position: fixed; left: 0; right: 0; bottom: 6px; z-index: 0;
    text-align: center; font-size: 10px; letter-spacing: 2px; text-transform: uppercase;
    color: rgba(255, 255, 255, 0.15); pointer-events: none; user-select: none;
  }
