/* ============================================================
   Aether Studio — base, layout and components
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  overflow: hidden;
  background: var(--bg-app);
  color: var(--ink);
  font-family: var(--font);
  font-size: calc(var(--fs-base) * var(--ui-scale, 1));
  line-height: var(--lh-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; padding: 0; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: var(--r-xs); }
:root[data-a11y-focus="on"] :focus { outline: 2px solid var(--accent); outline-offset: 1px; }

::selection { background: var(--accent-soft); color: var(--ink); }

/* scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: var(--r-full);
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--line-bright); background-clip: content-box; }
::-webkit-scrollbar-corner { background: transparent; }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }

/* ============================================================ APP SHELL */
#app {
  display: grid;
  grid-template-rows: var(--topbar-h) var(--optionsbar-h) 1fr var(--statusbar-h);
  grid-template-columns: auto 1fr auto;
  grid-template-areas:
    "top   top    top"
    "opts  opts   opts"
    "rail  stage  dock"
    "status status status";
  height: 100vh;
  width: 100vw;
}
:root[data-statusbar="off"] #app { grid-template-rows: var(--topbar-h) var(--optionsbar-h) 1fr 0; }

/* ============================================================ TOP BAR */
.topbar {
  grid-area: top;
  display: flex; align-items: center; gap: var(--s2);
  padding: 0 var(--s3) 0 var(--s4);
  background: var(--bg-chrome);
  border-bottom: 1px solid var(--line);
  z-index: var(--z-chrome);
  position: relative;
}

.brand {
  display: flex; align-items: center; gap: var(--s3);
  padding-right: var(--s4);
  margin-right: var(--s2);
  border-right: 1px solid var(--line);
  height: 60%;
}
.brand-mark { width: 24px; height: 24px; flex: none; color: var(--ink); }
.brand-name {
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  letter-spacing: -0.015em;
  white-space: nowrap;
}
.brand-name .dim { color: var(--ink-faint); font-weight: var(--fw-regular); }

.menubar { display: flex; align-items: center; gap: 1px; }
.menu-btn {
  padding: var(--s2) var(--s4);
  border-radius: var(--r-sm);
  font-size: var(--fs-small);
  color: var(--ink-dim);
  white-space: nowrap;
  transition: background var(--t-fast) var(--ease-out), color var(--t-fast);
}
.menu-btn:hover, .menu-btn.open { background: var(--bg-hover); color: var(--ink); }

.topbar-spacer { flex: 1 1 auto; min-width: var(--s4); }

/* document tabs */
.doctabs {
  display: flex; align-items: center; gap: var(--s1);
  max-width: 42vw; overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none;
  mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 16px), transparent 100%);
}
.doctabs::-webkit-scrollbar { display: none; }
.doctab {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s2) var(--s3) var(--s2) var(--s4);
  border-radius: var(--r-sm);
  font-size: var(--fs-small);
  color: var(--ink-dim);
  background: transparent;
  border: 1px solid transparent;
  white-space: nowrap;
  max-width: 190px;
  transition: all var(--t-fast) var(--ease-out);
}
.doctab:hover { background: var(--bg-hover); color: var(--ink); }
.doctab.active {
  background: var(--bg-raised); color: var(--ink);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}
.doctab .label { overflow: hidden; text-overflow: ellipsis; }
.doctab .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); flex: none; }
.doctab .close {
  width: 16px; height: 16px; border-radius: var(--r-xs);
  display: grid; place-items: center; color: var(--ink-faint);
  opacity: 0; transition: opacity var(--t-fast);
}
.doctab:hover .close, .doctab.active .close { opacity: 1; }
.doctab .close:hover { background: var(--bg-active); color: var(--ink); }

/* mode switch */
.modeswitch {
  display: flex; align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  padding: 2px;
  position: relative;
  height: 28px;
}
.modeswitch .seg {
  position: relative; z-index: 1;
  padding: 0 var(--s5);
  height: 100%;
  display: grid; place-items: center;
  font-size: var(--fs-tiny);
  font-weight: var(--fw-medium);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--ink-faint);
  border-radius: var(--r-full);
  transition: color var(--t-base) var(--ease-out);
  white-space: nowrap;
}
.modeswitch .seg.on { color: var(--accent-ink); }
.modeswitch .thumb {
  position: absolute; top: 2px; bottom: 2px; left: 2px;
  background: var(--accent);
  border-radius: var(--r-full);
  transition: transform var(--t-base) var(--ease-spring), width var(--t-base) var(--ease-spring);
  box-shadow: 0 1px 6px rgba(var(--accent-rgb), 0.5);
}

/* ============================================================ OPTIONS BAR */
.optionsbar {
  grid-area: opts;
  display: flex; align-items: center; gap: var(--s2);
  padding: 0 var(--s4);
  background: var(--bg-panel);
  border-bottom: 1px solid var(--line);
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none;
  z-index: calc(var(--z-chrome) - 1);
}
.optionsbar::-webkit-scrollbar { display: none; }
.optionsbar .tool-badge {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s2) var(--s4) var(--s2) var(--s3);
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-weight: var(--fw-medium);
  font-size: var(--fs-small);
  white-space: nowrap; flex: none;
}
.optionsbar .tool-badge svg { color: var(--accent); }
.opt-sep { width: 1px; height: 20px; background: var(--line); flex: none; margin: 0 var(--s2); }

/* a single option control */
.opt {
  display: flex; align-items: center; gap: var(--s3);
  flex: none; white-space: nowrap;
}
.opt > label {
  font-size: var(--fs-tiny);
  color: var(--ink-dim);
  letter-spacing: 0.02em;
}

/* ============================================================ TOOL RAIL */
.rail {
  grid-area: rail;
  width: var(--rail-w);
  background: var(--bg-chrome);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  align-items: center;
  padding: var(--s3) 0;
  gap: var(--s1);
  overflow-y: auto; overflow-x: visible;
  scrollbar-width: none;
  z-index: var(--z-dock);
}
.rail::-webkit-scrollbar { display: none; }

.rail-btn {
  position: relative;
  width: calc(var(--rail-w) - 14px);
  height: calc(var(--rail-w) - 14px);
  border-radius: var(--r-md);
  display: grid; place-items: center;
  color: var(--ink-dim);
  transition: background var(--t-fast) var(--ease-out), color var(--t-fast), transform var(--t-fast);
  flex: none;
}
.rail-btn:hover { background: var(--bg-hover); color: var(--ink); }
.rail-btn:active { transform: scale(0.94); }
.rail-btn.active { background: var(--accent-soft); color: var(--accent); }
.rail-btn.active::before {
  content: ''; position: absolute; left: -7px; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 18px;
  background: var(--accent);
  border-radius: 0 var(--r-full) var(--r-full) 0;
}
.rail-btn .more {
  position: absolute; right: 3px; bottom: 3px;
  width: 0; height: 0;
  border-left: 4px solid transparent;
  border-bottom: 4px solid currentColor;
  opacity: 0.5;
}
.rail-btn .rail-label {
  position: absolute; bottom: -2px; left: 0; right: 0;
  font-size: 8px; text-align: center; letter-spacing: 0;
  color: var(--ink-faint); pointer-events: none;
}
:root[data-rail-labels="on"] .rail-btn { height: calc(var(--rail-w) - 4px); padding-bottom: 8px; }

.rail-sep { width: 60%; height: 1px; background: var(--line); margin: var(--s3) 0; flex: none; }
.rail-spacer { flex: 1 1 auto; }

/* colour well in the rail footer */
.colorwell {
  position: relative;
  width: 38px; height: 38px;
  flex: none; margin-top: var(--s2);
}
.colorwell .sw {
  position: absolute; width: 24px; height: 24px;
  border-radius: var(--r-sm);
  border: 2px solid var(--bg-chrome);
  box-shadow: 0 0 0 1px var(--line-strong), var(--shadow-sm);
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease-out);
}
.colorwell .sw:hover { transform: scale(1.08); }
.colorwell .fg { left: 0; top: 0; z-index: 2; }
.colorwell .bg { right: 0; bottom: 0; z-index: 1; }

/* ============================================================ STAGE */
.stage {
  grid-area: stage;
  position: relative;
  background: var(--bg-canvas);
  overflow: hidden;
  min-width: 0;
}
.stage canvas.viewport { display: block; position: absolute; inset: 0; }
.stage.is-panning { cursor: grabbing; }
.stage.want-pan { cursor: grab; }

.stage-overlay {
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: var(--z-overlay);
}
.stage-overlay > * { pointer-events: auto; }

/* floating zoom pill */
.zoompill {
  position: absolute; left: 50%; bottom: var(--s5);
  transform: translateX(-50%);
  display: flex; align-items: center; gap: var(--s1);
  background: color-mix(in srgb, var(--bg-panel) 88%, transparent);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-full);
  padding: var(--s1);
  box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateX(-50%) translateY(8px);
  transition: opacity var(--t-base) var(--ease-out), transform var(--t-base) var(--ease-out);
}
.stage:hover .zoompill, .zoompill.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.zoompill button {
  width: 28px; height: 28px; border-radius: var(--r-full);
  display: grid; place-items: center; color: var(--ink-dim);
  transition: background var(--t-fast), color var(--t-fast);
}
.zoompill button:hover { background: var(--bg-hover); color: var(--ink); }
.zoompill .readout {
  min-width: 56px; text-align: center;
  font-size: var(--fs-tiny); font-variant-numeric: tabular-nums;
  color: var(--ink-dim); padding: 0 var(--s2);
  cursor: pointer;
}
.zoompill .readout:hover { color: var(--ink); }

/* ============================================================ DOCKS */
.dock {
  grid-area: dock;
  width: var(--dock-w);
  background: var(--bg-chrome);
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
  overflow: hidden;
  z-index: var(--z-dock);
  position: relative;
}
.dock.collapsed { width: 0; border-left: none; }
.dock-resizer {
  position: absolute; left: -3px; top: 0; bottom: 0; width: 6px;
  cursor: col-resize; z-index: 5;
}
.dock-resizer:hover { background: var(--accent-line); }

.dock-scroll { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; }

.panel {
  border-bottom: 1px solid var(--line);
  display: flex; flex-direction: column;
  min-height: 0;
}
.panel.collapsed .panel-body { display: none; }
.panel-head {
  display: flex; align-items: center; gap: var(--s3);
  height: 32px; padding: 0 var(--s4);
  font-size: var(--fs-tiny);
  font-weight: var(--fw-medium);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--ink-faint);
  cursor: pointer;
  user-select: none;
  transition: color var(--t-fast), background var(--t-fast);
  position: sticky; top: 0;
  background: var(--bg-chrome);
  z-index: 2;
}
.panel-head:hover { color: var(--ink-dim); background: var(--bg-panel); }
.panel-head .chev {
  transition: transform var(--t-base) var(--ease-out);
  color: var(--ink-ghost);
}
.panel.collapsed .panel-head .chev { transform: rotate(-90deg); }
.panel-head .title { flex: 1 1 auto; }
.panel-head .actions { display: flex; gap: var(--s1); opacity: 0; transition: opacity var(--t-fast); }
.panel-head:hover .actions { opacity: 1; }
.panel-head .actions button {
  width: 20px; height: 20px; border-radius: var(--r-xs);
  display: grid; place-items: center; color: var(--ink-faint);
}
.panel-head .actions button:hover { background: var(--bg-active); color: var(--ink); }
.panel-body { padding: var(--s3) var(--s4) var(--s5); }

/* ============================================================ STATUS BAR */
.statusbar {
  grid-area: status;
  display: flex; align-items: center; gap: var(--s5);
  padding: 0 var(--s4);
  background: var(--bg-chrome);
  border-top: 1px solid var(--line);
  font-size: var(--fs-tiny);
  color: var(--ink-faint);
  overflow: hidden; white-space: nowrap;
  z-index: var(--z-chrome);
}
.statusbar .grow { flex: 1 1 auto; }
.statusbar .stat { display: flex; align-items: center; gap: var(--s2); flex: none; }
.statusbar .stat b { font-weight: var(--fw-medium); color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.statusbar .hint { color: var(--ink-dim); overflow: hidden; text-overflow: ellipsis; }
.statusbar .pro-chip {
  padding: 1px var(--s3);
  border-radius: var(--r-full);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: var(--fs-micro);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
}

/* ============================================================ CONTROLS */
.field { display: flex; flex-direction: column; gap: var(--s2); margin-bottom: var(--s4); }
.field-row {
  display: flex; align-items: center; gap: var(--s3);
  min-height: 26px;
}
.field-row > .lbl {
  flex: 0 0 88px;
  font-size: var(--fs-tiny);
  color: var(--ink-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.field-row > .ctl { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: var(--s3); }

/* slider */
.slider { position: relative; flex: 1 1 auto; height: 22px; display: flex; align-items: center; min-width: 60px; }
.slider .track {
  position: absolute; left: 0; right: 0; height: 4px;
  background: var(--bg-input);
  border-radius: var(--r-full);
  overflow: hidden;
  border: 1px solid var(--line);
}
.slider .fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: var(--r-full); }
.slider input[type=range] {
  position: relative; width: 100%; margin: 0;
  -webkit-appearance: none; appearance: none; background: transparent; height: 22px;
  cursor: ew-resize;
}
.slider input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--ink);
  border: 2px solid var(--bg-panel);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--line-strong);
  transition: transform var(--t-fast) var(--ease-out);
}
.slider input[type=range]::-webkit-slider-thumb:hover { transform: scale(1.15); }
.slider input[type=range]::-webkit-slider-thumb:active { transform: scale(1.05); background: var(--accent); }
.slider input[type=range]::-moz-range-thumb {
  width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--bg-panel);
  background: var(--ink); box-shadow: var(--shadow-sm);
}

.numbox {
  width: 56px; flex: none;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 3px var(--s3);
  font-size: var(--fs-tiny);
  font-variant-numeric: tabular-nums;
  text-align: right;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.numbox:hover { border-color: var(--line-strong); }
.numbox:focus { border-color: var(--accent); background: var(--bg-raised); }
.numbox.wide { width: 76px; }

select.sel {
  flex: 1 1 auto; min-width: 0;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 3px var(--s6) 3px var(--s3);
  font-size: var(--fs-tiny);
  cursor: pointer;
  appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 10px center, right 6px center;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
  transition: border-color var(--t-fast);
}
select.sel:hover { border-color: var(--line-strong); }
select.sel:focus { border-color: var(--accent); }
select.sel option { background: var(--bg-raised); color: var(--ink); }

/* switch */
.switch {
  position: relative; width: 30px; height: 17px; flex: none;
  background: var(--bg-input);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-full);
  cursor: pointer;
  transition: background var(--t-base) var(--ease-out), border-color var(--t-base);
}
.switch::after {
  content: ''; position: absolute; top: 1px; left: 1px;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--ink-dim);
  transition: transform var(--t-base) var(--ease-spring), background var(--t-base);
}
.switch.on { background: var(--accent); border-color: var(--accent); }
.switch.on::after { transform: translateX(13px); background: #fff; }

/* checkbox */
.check {
  width: 15px; height: 15px; flex: none;
  border: 1px solid var(--line-bright);
  border-radius: var(--r-xs);
  background: var(--bg-input);
  display: grid; place-items: center;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.check.on { background: var(--accent); border-color: var(--accent); }
.check svg { opacity: 0; color: #fff; }
.check.on svg { opacity: 1; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s3);
  padding: var(--s3) var(--s5);
  border-radius: var(--r-sm);
  background: var(--bg-raised);
  border: 1px solid var(--line);
  font-size: var(--fs-tiny);
  font-weight: var(--fw-medium);
  color: var(--ink-dim);
  transition: all var(--t-fast) var(--ease-out);
  white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); color: var(--ink); border-color: var(--line-strong); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.12); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--bg-hover); }
.btn.danger { color: var(--err); border-color: color-mix(in srgb, var(--err) 35%, transparent); }
.btn.danger:hover { background: color-mix(in srgb, var(--err) 14%, transparent); color: var(--err); }
.btn.sm { padding: 2px var(--s3); font-size: var(--fs-micro); }
.btn.block { width: 100%; }
.btn[disabled], .btn.disabled { opacity: 0.38; pointer-events: none; }

.iconbtn {
  width: 26px; height: 26px; flex: none;
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  color: var(--ink-dim);
  transition: background var(--t-fast), color var(--t-fast);
}
.iconbtn:hover { background: var(--bg-hover); color: var(--ink); }
.iconbtn.active { background: var(--accent-soft); color: var(--accent); }
.iconbtn[disabled] { opacity: 0.35; pointer-events: none; }

/* segmented control */
.segmented {
  display: flex; background: var(--bg-input);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 2px; gap: 2px; flex: 1 1 auto; min-width: 0;
}
.segmented button {
  flex: 1 1 0; min-width: 0;
  padding: 2px var(--s2);
  border-radius: calc(var(--r-sm) - 1px);
  font-size: var(--fs-micro);
  color: var(--ink-faint);
  display: grid; place-items: center;
  transition: background var(--t-fast), color var(--t-fast);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.segmented button:hover { color: var(--ink-dim); background: var(--bg-hover); }
.segmented button.on { background: var(--bg-active); color: var(--ink); box-shadow: var(--shadow-sm); }

/* colour input */
.colorinput {
  width: 26px; height: 22px; flex: none;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  cursor: pointer; padding: 0; overflow: hidden;
  background-image:
    linear-gradient(45deg, var(--line) 25%, transparent 25%),
    linear-gradient(-45deg, var(--line) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--line) 75%),
    linear-gradient(-45deg, transparent 75%, var(--line) 75%);
  background-size: 8px 8px;
  background-position: 0 0, 0 4px, 4px -4px, -4px 0;
}

/* text input */
.input {
  flex: 1 1 auto; min-width: 0;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: var(--s2) var(--s3);
  font-size: var(--fs-tiny);
  transition: border-color var(--t-fast), background var(--t-fast);
}
.input:hover { border-color: var(--line-strong); }
.input:focus { border-color: var(--accent); background: var(--bg-raised); }
.input::placeholder { color: var(--ink-ghost); }

/* search field */
.search {
  display: flex; align-items: center; gap: var(--s3);
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: var(--s2) var(--s3);
  transition: border-color var(--t-fast);
}
.search:focus-within { border-color: var(--accent); }
.search svg { color: var(--ink-faint); flex: none; }
.search input { flex: 1 1 auto; min-width: 0; background: none; border: none; font-size: var(--fs-tiny); }
.search input::placeholder { color: var(--ink-ghost); }

/* ============================================================ FLYOUTS */
.flyout {
  position: fixed;
  background: color-mix(in srgb, var(--bg-panel) 92%, transparent);
  backdrop-filter: blur(24px) saturate(1.5);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-flyout);
  overflow: hidden;
  animation: flyIn var(--t-base) var(--ease-out);
  max-height: 78vh;
  display: flex; flex-direction: column;
}
@keyframes flyIn {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}
.flyout-head {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s4) var(--s5) var(--s3);
  font-size: var(--fs-tiny);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--ink-faint);
  border-bottom: 1px solid var(--line);
  flex: none;
}
.flyout-body { overflow-y: auto; padding: var(--s2); flex: 1 1 auto; }
.flyout-foot {
  padding: var(--s3) var(--s5); border-top: 1px solid var(--line);
  font-size: var(--fs-micro); color: var(--ink-ghost); flex: none;
  display: flex; align-items: center; gap: var(--s4);
}

/* menu items */
.mi {
  display: flex; align-items: center; gap: var(--s4);
  width: 100%;
  padding: var(--s3) var(--s4);
  border-radius: var(--r-sm);
  font-size: var(--fs-small);
  color: var(--ink-dim);
  text-align: left;
  transition: background var(--t-fast), color var(--t-fast);
}
.mi:hover, .mi.sel { background: var(--accent-soft); color: var(--ink); }
.mi.active { color: var(--accent); }
.mi .ico { width: 16px; height: 16px; flex: none; display: grid; place-items: center; opacity: 0.9; }
.mi .lbl { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mi .kbd { flex: none; color: var(--ink-ghost); font-size: var(--fs-micro); font-family: var(--font-mono); }
.mi .sub { font-size: var(--fs-micro); color: var(--ink-ghost); }
.mi[disabled] { opacity: 0.35; pointer-events: none; }
.mi-sep { height: 1px; background: var(--line); margin: var(--s2) var(--s3); }
.mi-title {
  padding: var(--s4) var(--s4) var(--s2);
  font-size: var(--fs-micro);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--ink-ghost);
}

/* ============================================================ MODALS */
.scrim {
  position: fixed; inset: 0;
  background: var(--bg-scrim);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: var(--z-modal);
  display: grid; place-items: center;
  animation: fadeIn var(--t-base) var(--ease-out);
  padding: var(--s8);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg-panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  max-height: 88vh; max-width: 96vw;
  overflow: hidden;
  animation: modalIn var(--t-slow) var(--ease-out);
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}
.modal-head {
  display: flex; align-items: center; gap: var(--s4);
  padding: var(--s5) var(--s6);
  border-bottom: 1px solid var(--line);
  flex: none;
}
.modal-head h2 { margin: 0; font-size: var(--fs-lg); font-weight: var(--fw-bold); letter-spacing: -0.01em; }
.modal-head .sub { font-size: var(--fs-tiny); color: var(--ink-faint); }
.modal-body { padding: var(--s6); overflow-y: auto; flex: 1 1 auto; }
.modal-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: var(--s3);
  padding: var(--s4) var(--s6);
  border-top: 1px solid var(--line);
  background: var(--bg-chrome);
  flex: none;
}

/* ============================================================ COMMAND PALETTE */
.palette {
  position: fixed; top: 12vh; left: 50%; transform: translateX(-50%);
  width: min(660px, 92vw);
  background: color-mix(in srgb, var(--bg-panel) 94%, transparent);
  backdrop-filter: blur(30px) saturate(1.6);
  -webkit-backdrop-filter: blur(30px) saturate(1.6);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-modal);
  overflow: hidden;
  display: flex; flex-direction: column;
  animation: paletteIn var(--t-base) var(--ease-out);
}
@keyframes paletteIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px) scale(0.98); }
  to   { opacity: 1; transform: translateX(-50%); }
}
.palette-input {
  display: flex; align-items: center; gap: var(--s4);
  padding: var(--s5) var(--s6);
  border-bottom: 1px solid var(--line);
}
.palette-input input {
  flex: 1; background: none; border: none;
  font-size: var(--fs-lg); font-weight: var(--fw-regular);
}
.palette-input input::placeholder { color: var(--ink-ghost); }
.palette-results { max-height: 52vh; overflow-y: auto; padding: var(--s2); }
.palette-results .mi { padding: var(--s3) var(--s4); }
.palette-results .mi .kind {
  font-size: var(--fs-micro); color: var(--ink-ghost);
  padding: 1px var(--s2); border: 1px solid var(--line);
  border-radius: var(--r-xs); flex: none;
}
.palette-empty { padding: var(--s8); text-align: center; color: var(--ink-faint); font-size: var(--fs-small); }

/* ============================================================ TOASTS */
.toasts {
  position: fixed; bottom: calc(var(--statusbar-h) + var(--s5)); left: 50%;
  transform: translateX(-50%);
  display: flex; flex-direction: column; gap: var(--s3);
  z-index: var(--z-toast);
  pointer-events: none;
  align-items: center;
}
.toast {
  display: flex; align-items: center; gap: var(--s4);
  padding: var(--s3) var(--s6);
  background: color-mix(in srgb, var(--bg-raised) 94%, transparent);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-full);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-small);
  animation: toastIn var(--t-slow) var(--ease-spring);
  pointer-events: auto;
  max-width: 60vw;
}
.toast.leaving { animation: toastOut var(--t-base) var(--ease-out) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(0.94); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px) scale(0.97); } }
.toast .dot { width: 6px; height: 6px; border-radius: 50%; flex: none; background: var(--info); }
.toast.success .dot { background: var(--ok); }
.toast.warn .dot { background: var(--warn); }
.toast.error .dot { background: var(--err); }

/* ============================================================ TOOLTIP */
.tip {
  position: fixed;
  background: var(--bg-raised);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  padding: var(--s2) var(--s4);
  font-size: var(--fs-tiny);
  color: var(--ink);
  box-shadow: var(--shadow-md);
  z-index: var(--z-tooltip);
  pointer-events: none;
  white-space: nowrap;
  display: flex; align-items: center; gap: var(--s4);
  animation: fadeIn var(--t-fast) var(--ease-out);
}
.tip .kbd {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  color: var(--ink-faint);
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  padding: 0 var(--s2);
}

/* ============================================================ MISC */
.grid-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: var(--s2);
}
.tile {
  aspect-ratio: 1;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--bg-input);
  overflow: hidden;
  display: grid; place-items: center;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease-out);
  position: relative;
}
.tile:hover { border-color: var(--line-bright); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.tile.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.tile canvas, .tile img, .tile svg { max-width: 100%; max-height: 100%; display: block; }
.tile .cap {
  position: absolute; left: 0; right: 0; bottom: 0;
  font-size: 8px; text-align: center;
  background: linear-gradient(transparent, rgba(0,0,0,0.75));
  color: #fff; padding: 6px 2px 2px;
  opacity: 0; transition: opacity var(--t-fast);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tile:hover .cap { opacity: 1; }

.swatches { display: flex; flex-wrap: wrap; gap: 3px; }
.swatch {
  width: 18px; height: 18px;
  border-radius: var(--r-xs);
  border: 1px solid var(--line-strong);
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease-out);
}
.swatch:hover { transform: scale(1.15); z-index: 2; box-shadow: var(--shadow-sm); }
.swatch.on { box-shadow: 0 0 0 2px var(--accent); }

.empty {
  padding: var(--s7) var(--s5);
  text-align: center;
  color: var(--ink-ghost);
  font-size: var(--fs-tiny);
  line-height: 1.6;
}

.hr { height: 1px; background: var(--line); margin: var(--s4) 0; }

.pro-only { display: none; }
:root[data-pro="on"] .pro-only { display: revert; }
:root[data-pro="on"] .simple-only { display: none; }

.badge-pro {
  font-size: 8px; font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-caps);
  color: var(--accent);
  border: 1px solid var(--accent-line);
  border-radius: var(--r-xs);
  padding: 0 3px;
  flex: none;
}

.kbd {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  color: var(--ink-faint);
}

/* boot splash */
#boot {
  position: fixed; inset: 0; z-index: 200;
  background: var(--bg-app);
  display: grid; place-items: center;
  transition: opacity var(--t-slow) var(--ease-out);
}
#boot.done { opacity: 0; pointer-events: none; }
#boot .inner { display: flex; flex-direction: column; align-items: center; gap: var(--s5); }
#boot svg { color: var(--ink); animation: bootPulse 1.6s var(--ease-in-out) infinite; }
@keyframes bootPulse { 0%,100% { opacity: 0.45; transform: scale(0.97); } 50% { opacity: 1; transform: scale(1); } }
#boot .bar { width: 160px; height: 2px; background: var(--bg-raised); border-radius: var(--r-full); overflow: hidden; }
#boot .bar i { display: block; height: 100%; width: 30%; background: var(--accent); border-radius: var(--r-full); animation: bootBar 1.1s var(--ease-in-out) infinite; }
@keyframes bootBar { 0% { transform: translateX(-100%); } 100% { transform: translateX(430%); } }
#boot .msg { font-size: var(--fs-tiny); color: var(--ink-faint); font-variant-numeric: tabular-nums; }

/* ============================================================
   HISTORY & NAVIGATOR PANELS
   Appended by js/ui/panel-history.js and js/ui/panel-navigator.js.
   Additive only — no rule above this banner is modified.
   ============================================================ */

/* `.pro-only` resolves to `display: revert`, which for a <div> is `block` and
   would flatten the flex layout of a Pro-marked .field-row / .opt produced by
   UD.ui.row / UD.ui.inline. Restore their intended display. */
:root[data-pro="on"] .field-row.pro-only { display: flex; }
:root[data-pro="on"] .opt.pro-only { display: flex; }

/* ---- shared panel furniture ---- */
.panel-strip {
  display: flex; align-items: center; gap: var(--s3);
  min-height: 22px;
  font-size: var(--fs-tiny);
  color: var(--ink-faint);
}
.panel-strip .grow { flex: 1 1 auto; min-width: 0; }
.panel-strip b {
  color: var(--ink-dim);
  font-weight: var(--fw-medium);
  font-variant-numeric: tabular-nums;
}
.panel-strip .caps {
  font-size: var(--fs-micro);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--ink-ghost);
}
.panel-strip .iconbtn { width: 22px; height: 22px; }

.meter {
  height: 3px;
  margin: var(--s2) 0 var(--s3);
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  overflow: hidden;
}
.meter > i {
  display: block; height: 100%; width: 0;
  background: var(--accent);
  border-radius: var(--r-full);
  transition: width var(--t-base) var(--ease-out), background var(--t-base);
}
.meter.warn > i { background: var(--warn); }
.meter.over > i { background: var(--err); }

.btn-row { display: flex; gap: var(--s2); margin-top: var(--s3); }
.btn-row > .btn { flex: 1 1 0; min-width: 0; padding-left: var(--s2); padding-right: var(--s2); }

/* ---- history list ---- */
.hist-list {
  max-height: 214px;
  overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column; gap: 1px;
  margin: 0 calc(var(--s2) * -1);
  padding: 0 var(--s2);
}
.hist-row { position: relative; padding: 3px var(--s3); gap: var(--s3); }
.hist-row .ico { width: 14px; height: 14px; opacity: 0.7; }
.hist-row .lbl { font-size: var(--fs-tiny); }
.hist-row .sub { flex: none; font-variant-numeric: tabular-nums; }
.hist-row.current { background: var(--accent-soft); color: var(--ink); }
.hist-row.current .ico { color: var(--accent); opacity: 1; }
.hist-row.current::before {
  content: ''; position: absolute; left: 0; top: 3px; bottom: 3px;
  width: 2px; border-radius: var(--r-full);
  background: var(--accent);
}
.hist-row.future { opacity: 0.42; }
.hist-row.future:hover { opacity: 0.8; }
.hist-origin .ico { color: var(--ink-faint); }

/* ---- snapshots ---- */
.snap-section .grid-tiles { margin-top: var(--s3); }
.snap-tile .cap { opacity: 1; }

/* ---- navigator ---- */
.nav-thumb {
  position: relative;
  width: 100%; height: 136px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  transition: border-color var(--t-fast);
}
.nav-thumb:hover { border-color: var(--line-strong); }
.nav-thumb.grabbing { cursor: grabbing; }
.nav-thumb canvas.nav-canvas {
  position: absolute; display: block;
  box-shadow: var(--shadow-sm);
}
.nav-thumb.gray canvas.nav-canvas { filter: grayscale(1); }
.nav-rect {
  position: absolute; pointer-events: none;
  border: 1px solid var(--accent);
  background: rgba(var(--accent-rgb), 0.12);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.28);
}
.nav-rect.covers {
  background: none;
  border-style: dashed;
  box-shadow: none;
  opacity: 0.55;
}

/* ============================================================
   SHELL STATES — focus mode, status bar, accessibility, bottom dock
   ============================================================ */

/* Focus mode: strip the chrome down to the artwork. Chrome returns on hover
   near the edges so the user is never trapped. */
body.focus-mode .rail,
body.focus-mode .dock,
body.focus-mode .optionsbar { display: none; }
body.focus-mode #app {
  grid-template-columns: 0 1fr 0;
  grid-template-rows: var(--topbar-h) 0 1fr var(--statusbar-h);
}
body.focus-mode .topbar { opacity: 0.25; transition: opacity var(--t-base) var(--ease-out); }
body.focus-mode .topbar:hover { opacity: 1; }

:root[data-statusbar="off"] .statusbar { display: none; }

/* Larger hit targets for touch and motor accessibility */
:root[data-hit="large"] .iconbtn { width: 34px; height: 34px; }
:root[data-hit="large"] .rail-btn { width: calc(var(--rail-w) - 6px); height: calc(var(--rail-w) - 6px); }
:root[data-hit="large"] .mi { padding: var(--s4) var(--s5); }
:root[data-hit="large"] .switch { width: 38px; height: 21px; }
:root[data-hit="large"] .switch::after { width: 17px; height: 17px; }
:root[data-hit="large"] .switch.on::after { transform: translateX(17px); }
:root[data-hit="large"] .swatch { width: 24px; height: 24px; }

/* Colour-vision simulation applied to the canvas stage only, so the UI stays
   readable while the artwork is previewed as a viewer with CVD would see it. */
:root[data-cvd="protanopia"]  .stage canvas.viewport { filter: url(#cvd-protanopia); }
:root[data-cvd="deuteranopia"] .stage canvas.viewport { filter: url(#cvd-deuteranopia); }
:root[data-cvd="tritanopia"]  .stage canvas.viewport { filter: url(#cvd-tritanopia); }
:root[data-cvd="mono"]        .stage canvas.viewport { filter: grayscale(1); }

/* Bottom dock (animation timeline and any other bottom-group panel) */
#app.has-bottom {
  grid-template-rows: var(--topbar-h) var(--optionsbar-h) 1fr var(--bottom-h, 168px) var(--statusbar-h);
  grid-template-areas:
    "top    top    top"
    "opts   opts   opts"
    "rail   stage  dock"
    "bottom bottom bottom"
    "status status status";
}
.dock-bottom {
  grid-area: bottom;
  background: var(--bg-chrome);
  border-top: 1px solid var(--line);
  display: flex; flex-direction: column;
  overflow: hidden;
  position: relative;
  z-index: var(--z-dock);
}
.dock-bottom .bottom-resizer {
  position: absolute; left: 0; right: 0; top: -3px; height: 6px;
  cursor: row-resize; z-index: 5;
}
.dock-bottom .bottom-resizer:hover { background: var(--accent-line); }

/* Rail scroll affordance when there are more tool groups than fit */
.rail { position: relative; }
.rail::after {
  content: ''; position: sticky; bottom: 0; left: 0; right: 0;
  height: 18px; flex: none; margin-top: -18px;
  background: linear-gradient(transparent, var(--bg-chrome));
  pointer-events: none;
}

/* ============================================================
   SHORTCUT EDITOR — js/ui/shortcuts-editor.js
   Appended section. Adds only new, prefixed rules; nothing above
   this line is modified.
   ============================================================ */

/* the modal body becomes a column so the toolbar stays put and only
   the list scrolls — group headers can then stick to the list top */
.modal.sc-modal .modal-body {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.sc-toolbar {
  flex: none;
  display: flex; align-items: center; gap: var(--s3);
  flex-wrap: wrap;
  padding: var(--s4) var(--s5);
  border-bottom: 1px solid var(--line);
  background: var(--bg-chrome);
}
.sc-toolbar .sc-search { flex: 1 1 240px; min-width: 170px; }
.sc-toolbar .opt { flex: none; }

.sc-listen {
  flex: 1 1 240px; min-width: 170px;
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s2) var(--s3);
  min-height: 26px;
  border: 1px dashed var(--accent-line);
  border-radius: var(--r-sm);
  background: var(--accent-soft);
  font-size: var(--fs-tiny);
  color: var(--ink-dim);
  cursor: text;
}
.sc-listen svg { color: var(--accent); }
.sc-listen b.kbd { color: var(--accent); font-size: var(--fs-tiny); }

.sc-list { flex: 1 1 auto; overflow-y: auto; }
.sc-list-inner { padding: 0 var(--s5) var(--s7); }

.sc-group { margin-bottom: var(--s3); }
.sc-group-head {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: var(--s4);
  padding: var(--s5) var(--s3) var(--s2);
  background: var(--bg-panel);
  font-size: var(--fs-micro);
  font-weight: var(--fw-medium);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--ink-faint);
}
.sc-group-head::after { content: ''; flex: 1 1 auto; height: 1px; background: var(--line); }

.sc-row { align-items: center; gap: var(--s3); }
.sc-row.sc-capturing { background: var(--accent-soft); }
.sc-tag {
  flex: none;
  font-size: var(--fs-micro);
  color: var(--ink-ghost);
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  padding: 0 3px;
}

.sc-keys { flex: none; display: flex; align-items: center; gap: var(--s2); }
.sc-actions {
  flex: none; display: flex; align-items: center; gap: var(--s1);
  opacity: 0; transition: opacity var(--t-fast) var(--ease-out);
}
.sc-row:hover .sc-actions, .sc-row:focus-within .sc-actions { opacity: 1; }
.sc-actions .iconbtn { width: 22px; height: 22px; }

.sc-key {
  flex: none;
  min-width: 84px;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  padding: 2px var(--s3);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--bg-input);
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  color: var(--ink);
  white-space: nowrap;
  transition: border-color var(--t-fast), color var(--t-fast), background var(--t-fast);
}
button.sc-key:hover { border-color: var(--accent); color: var(--accent); background: var(--bg-raised); }
.sc-key.unset { color: var(--ink-ghost); border-style: dashed; }
.sc-key.custom { border-color: var(--accent-line); color: var(--accent); }
.sc-key.alt { min-width: 0; opacity: 0.6; }
.sc-key.fixed { border-style: dotted; color: var(--ink-dim); }
.sc-key .dot { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); flex: none; }
.sc-key.capturing {
  border-color: var(--accent); color: var(--accent); background: var(--accent-soft);
  animation: scPulse 1.3s var(--ease-in-out) infinite;
}
@keyframes scPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.4); }
  50%      { box-shadow: 0 0 0 5px rgba(var(--accent-rgb), 0); }
}

.sc-clash {
  display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap;
  margin: var(--s1) var(--s4) var(--s3) var(--s4);
  padding: var(--s3) var(--s4);
  border: 1px solid color-mix(in srgb, var(--warn) 42%, transparent);
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--warn) 13%, transparent);
  font-size: var(--fs-tiny);
  color: var(--ink);
  line-height: 1.5;
}
.sc-clash > svg { color: var(--warn); }
.sc-clash .grow { flex: 1 1 200px; }

.sc-hint {
  margin-right: auto;
  font-size: var(--fs-micro);
  color: var(--ink-ghost);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sc-hint.on { color: var(--accent); }

/* ---------------------------------------------------------- cheat sheet */
.sc-sheet-wrap { flex: 1 1 auto; overflow-y: auto; padding: var(--s5) var(--s6) var(--s8); }
.sc-print-title {
  display: flex; align-items: baseline; gap: var(--s4);
  padding-bottom: var(--s3); margin-bottom: var(--s5);
  border-bottom: 1px solid var(--line);
}
.sc-print-title b { font-size: var(--fs-md); font-weight: var(--fw-bold); }
.sc-print-title span { font-size: var(--fs-micro); color: var(--ink-faint); }

.sc-sheet { columns: 3; column-gap: var(--s8); }
@media (max-width: 860px) { .sc-sheet { columns: 2; } }
.sc-sheet-group { break-inside: avoid; page-break-inside: avoid; margin: 0 0 var(--s6); }
.sc-sheet-group h3 {
  margin: 0 0 var(--s2);
  padding-bottom: 2px;
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-micro);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--accent);
}
.sc-sheet-row {
  display: flex; align-items: baseline; gap: var(--s4);
  padding: 1px 0;
  font-size: var(--fs-tiny);
  color: var(--ink-dim);
}
.sc-sheet-row .t { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sc-sheet-row .k { flex: none; font-family: var(--font-mono); color: var(--ink); }

/* ---------------------------------------------------------------- print */
@media print {
  html, body { overflow: visible !important; height: auto !important; background: #fff !important; }
  body > * { display: none !important; }
  body > .sc-print-root {
    display: block !important;
    position: static !important;
    padding: 0 !important;
    background: #fff !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    animation: none !important;
  }
  .sc-print-root .modal {
    display: block !important;
    width: auto !important; height: auto !important;
    max-width: none !important; max-height: none !important;
    border: none !important; box-shadow: none !important;
    background: #fff !important; color: #000 !important;
    animation: none !important;
  }
  .sc-print-root .modal-head,
  .sc-print-root .modal-foot,
  .sc-print-root .sc-toolbar,
  .sc-print-root .sc-list { display: none !important; }
  .sc-print-root .modal-body { display: block !important; overflow: visible !important; padding: 0 !important; }
  .sc-print-root .sc-sheet-wrap { display: block !important; overflow: visible !important; padding: 0 !important; }
  .sc-print-root .sc-print-title { border-bottom: 1px solid #999 !important; }
  .sc-print-root .sc-print-title b,
  .sc-print-root .sc-print-title span { color: #000 !important; }
  .sc-print-root .sc-sheet { columns: 3; column-gap: 18px; }
  .sc-print-root .sc-sheet-group h3 { color: #000 !important; border-bottom: 1px solid #999 !important; }
  .sc-print-root .sc-sheet-row { color: #333 !important; }
  .sc-print-root .sc-sheet-row .k { color: #000 !important; }
}

/* ============================================================
   ADJUSTMENTS PANEL + FILTER DIALOG
   Appended by js/ui/panel-adjust.js. Additive only — nothing above
   this comment is modified. Everything else in these two surfaces
   reuses .field-row / .btn / .iconbtn / .tile / .mi / .search /
   .empty / .hr / .badge-pro.
   ============================================================ */

/* Adjustment tiles need a permanently legible label — an icon alone
   cannot distinguish "Levels" from "Curves" — so this variant swaps the
   square tile for an icon-over-caption cell. */
.grid-tiles.adjust-tiles { grid-template-columns: repeat(auto-fill, minmax(66px, 1fr)); }
.tile.tile-labeled {
  aspect-ratio: auto;
  height: 56px;
  display: grid;
  grid-template-rows: 1fr auto;
  place-items: center;
  gap: var(--s1);
  padding: var(--s3) var(--s1) var(--s2);
  color: var(--ink-dim);
}
.tile.tile-labeled > svg { align-self: end; color: var(--accent); opacity: 0.85; }
.tile.tile-labeled:hover { color: var(--ink); }
.tile.tile-labeled:hover > svg { opacity: 1; }
.tile.tile-labeled .cap {
  position: static;
  opacity: 1;
  background: none;
  color: var(--ink-faint);
  font-size: var(--fs-micro);
  line-height: 1.2;
  padding: 0 var(--s1);
  max-width: 100%;
}
.tile.tile-labeled:hover .cap { color: var(--ink-dim); }
.tile[disabled] { opacity: 0.38; pointer-events: none; }

/* recent-filter chips: one horizontal line that scrolls rather than wraps */
.adjust-recents {
  display: flex; align-items: center; gap: var(--s2);
  min-width: 0;
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none;
  padding-bottom: 1px;
}
.adjust-recents::-webkit-scrollbar { display: none; }
.adjust-recents > .btn { flex: none; max-width: 130px; overflow: hidden; text-overflow: ellipsis; }

/* section rule inside the panel body */
.adjust-section {
  display: flex; align-items: center; gap: var(--s3);
  margin: var(--s5) 0 var(--s3);
  font-size: var(--fs-micro);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--ink-ghost);
}
.adjust-section .ln { flex: 1 1 auto; height: 1px; background: var(--line); }

/* The filter dialog previews on the real canvas, so the scrim must not
   dim or blur the artwork, and the canvas stays pannable behind it. */
.scrim.filter-scrim {
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  pointer-events: none;
}
.scrim.filter-scrim > .modal { pointer-events: auto; justify-self: end; }
.modal.filter-modal .modal-body { padding: var(--s5) var(--s6); }
.modal.filter-modal .modal-foot { flex-wrap: wrap; gap: var(--s3); }

/* preview-quality note under the dialog's parameter rows */
.adjust-note {
  display: flex; align-items: center; gap: var(--s2);
  min-width: 0;
  margin-top: var(--s4);
  font-size: var(--fs-micro);
  color: var(--ink-faint);
  line-height: 1.4;
}
.adjust-note:empty { display: none; }
.adjust-note .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--warn); flex: none; }

/* which layer the dialog is about to write to */
.adjust-target {
  display: flex; align-items: center; gap: var(--s3);
  padding-bottom: var(--s4);
  margin-bottom: var(--s4);
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-tiny);
  color: var(--ink-dim);
}
.adjust-target .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adjust-target .tag {
  margin-left: auto; flex: none;
  padding: 0 var(--s2);
  border: 1px solid var(--accent-line);
  border-radius: var(--r-xs);
  font-size: var(--fs-micro);
  color: var(--accent);
}

/* ============================================================
   SETTINGS DIALOG — js/ui/settings.js
   Appended section. Adds new selectors only; no rule above is modified.
   ============================================================ */

/* the settings modal is a two-column shell: nav rail + scrolling pane */
.modal.settings .modal-body { padding: 0; display: flex; min-height: 0; overflow: hidden; }
.set-split { display: flex; flex: 1 1 auto; min-width: 0; min-height: 0; width: 100%; overflow: hidden; }

.set-side {
  flex: 0 0 212px; min-width: 0;
  display: flex; flex-direction: column;
  background: var(--bg-chrome);
  border-right: 1px solid var(--line);
}
.set-side-search { padding: var(--s5) var(--s4) var(--s3); flex: none; }
.set-nav {
  flex: 1 1 auto; overflow-y: auto;
  padding: 0 var(--s3) var(--s5);
  display: flex; flex-direction: column; gap: 1px;
}
.set-nav .mi { padding: var(--s3); }
.set-nav .mi .n {
  flex: none; font-size: var(--fs-micro); color: var(--ink-ghost);
  font-variant-numeric: tabular-nums;
}
.set-nav .mi[aria-current="true"] { color: var(--ink); }
.set-nav .mi[aria-current="true"] .ico { color: var(--accent); }
.set-nav .mi[aria-current="true"] .n { color: var(--accent); }

.set-pane { flex: 1 1 auto; min-width: 0; overflow-y: auto; padding: var(--s6) var(--s7) var(--s8); }

.set-head { margin-bottom: var(--s6); }
.set-head h3 {
  margin: 0 0 var(--s2);
  display: flex; align-items: center;
  font-size: var(--fs-md); font-weight: var(--fw-bold); letter-spacing: -0.01em;
}
.set-head p { margin: 0; max-width: 64ch; font-size: var(--fs-tiny); color: var(--ink-faint); line-height: 1.65; }

.set-subhead {
  font-size: var(--fs-micro); text-transform: uppercase;
  letter-spacing: var(--tracking-caps); color: var(--ink-faint);
  margin: 0 0 var(--s4);
}
.set-note {
  margin-top: var(--s4);
  font-size: var(--fs-micro); color: var(--ink-ghost);
  line-height: 1.6; max-width: 70ch;
}

/* ---- one setting -------------------------------------------------------- */
.set-row { padding: var(--s2) 0; }
.set-row + .set-row { border-top: 1px solid color-mix(in srgb, var(--line) 55%, transparent); }
.set-row > .field-row { min-height: 30px; gap: var(--s4); }
.set-row > .field-row > .lbl { flex: 0 0 172px; font-size: var(--fs-small); }
.set-row.modified > .field-row > .lbl { color: var(--ink); }
.set-help {
  padding: 0 0 var(--s2) calc(172px + var(--s4));
  max-width: 76ch;
  font-size: var(--fs-micro); color: var(--ink-faint); line-height: 1.55;
}
.set-reset {
  width: 22px; height: 22px; flex: none;
  opacity: 0; pointer-events: none;
  transition: opacity var(--t-fast) var(--ease-out), color var(--t-fast);
}
.set-reset.on { opacity: 0.5; pointer-events: auto; }
.set-row:hover .set-reset.on { opacity: 0.9; }
.set-reset.on:hover, .set-reset.on:focus-visible { opacity: 1; color: var(--accent); }

/* ---- section footer ----------------------------------------------------- */
.set-foot {
  display: flex; align-items: center; gap: var(--s4);
  margin-top: var(--s6); padding-top: var(--s5);
  border-top: 1px solid var(--line);
}
.set-foot .note { flex: 1 1 auto; font-size: var(--fs-micro); color: var(--ink-ghost); }

/* ---- callouts ----------------------------------------------------------- */
.set-callout {
  display: flex; gap: var(--s5);
  padding: var(--s5);
  margin-bottom: var(--s6);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: var(--r-md);
}
.set-callout > .ico { color: var(--accent); flex: none; line-height: 1; }
.set-callout h4 { margin: 0 0 var(--s3); display: flex; align-items: center; font-size: var(--fs-small); font-weight: var(--fw-bold); }
.set-callout p { margin: 0 0 var(--s3); font-size: var(--fs-tiny); color: var(--ink-dim); line-height: 1.65; }
.set-callout ul { margin: 0 0 var(--s4); padding-left: var(--s6); font-size: var(--fs-tiny); color: var(--ink-dim); line-height: 1.75; }

/* ---- appearance preview ------------------------------------------------- */
.set-preview {
  margin-bottom: var(--s6);
  border: 1px solid var(--line); border-radius: var(--r-md);
  overflow: hidden; background: var(--bg-panel);
}
.set-mock { display: flex; flex-direction: column; height: 108px; }
.set-mock .bar {
  height: 24px; flex: none;
  display: flex; align-items: center; gap: var(--s3);
  padding: 0 var(--s4);
  background: var(--bg-chrome); border-bottom: 1px solid var(--line);
}
.set-mock .bar .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.set-mock .bar i { display: block; height: 5px; border-radius: var(--r-full); background: var(--ink-ghost); flex: none; }
.set-mock .body { flex: 1 1 auto; display: flex; min-height: 0; }
.set-mock .rail {
  width: 28px; flex: none;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding-top: 6px;
  background: var(--bg-chrome); border-right: 1px solid var(--line);
}
.set-mock .rail i { width: 15px; height: 15px; border-radius: var(--r-sm); background: var(--bg-hover); }
.set-mock .rail i.on { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-line); }
.set-mock .canvas { flex: 1 1 auto; display: grid; place-items: center; background: var(--bg-canvas); }
.set-mock .canvas i {
  width: 58%; height: 64%;
  background: var(--bg-panel);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-sm);
}
.set-mock .dock {
  width: 78px; flex: none;
  display: flex; flex-direction: column; gap: 5px;
  padding: 7px;
  background: var(--bg-panel); border-left: 1px solid var(--line);
}
.set-mock .dock i { height: 5px; border-radius: var(--r-full); background: var(--bg-input); }
.set-mock .dock i.k { background: var(--accent); width: 58%; }

.set-swatches {
  display: flex; flex-wrap: wrap; gap: var(--s2);
  padding: var(--s4); border-top: 1px solid var(--line);
}
.set-swatches .swatch { width: 22px; height: 22px; cursor: default; }
.set-preview-meta {
  padding: 0 var(--s4) var(--s4);
  font-size: var(--fs-micro); color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

/* ---- stats, meters and key/value lists ---------------------------------- */
.set-stats {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(122px, 1fr));
  gap: var(--s3); margin-bottom: var(--s4);
}
.set-stat {
  padding: var(--s4);
  background: var(--bg-panel);
  border: 1px solid var(--line); border-radius: var(--r-sm);
}
.set-stat .k {
  margin-bottom: var(--s1);
  font-size: var(--fs-micro); color: var(--ink-faint);
  text-transform: uppercase; letter-spacing: var(--tracking-caps);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.set-stat .v { font-size: var(--fs-md); font-weight: var(--fw-medium); font-variant-numeric: tabular-nums; }
.set-stat .v small { margin-left: 3px; font-size: var(--fs-micro); color: var(--ink-faint); font-weight: var(--fw-regular); }

.set-bar {
  height: 6px; margin: var(--s3) 0 0;
  background: var(--bg-input);
  border: 1px solid var(--line); border-radius: var(--r-full);
  overflow: hidden;
}
.set-bar i { display: block; height: 100%; background: var(--accent); transition: width var(--t-slow) var(--ease-out); }
.set-bar i.warn { background: var(--warn); }
.set-bar i.err { background: var(--err); }

.set-list { display: flex; flex-direction: column; }
.set-kv {
  display: flex; align-items: center; gap: var(--s4);
  padding: var(--s2) 0;
  font-size: var(--fs-tiny);
  border-top: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
}
.set-kv:first-child { border-top: none; }
.set-kv .k {
  flex: 1 1 auto; min-width: 0;
  color: var(--ink-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.set-kv .v { flex: none; color: var(--ink-faint); font-variant-numeric: tabular-nums; }

/* ---- search results ----------------------------------------------------- */
.set-group { margin-bottom: var(--s6); }
.set-group-head {
  display: flex; align-items: center; gap: var(--s3);
  width: 100%; padding: 0 0 var(--s3);
  font-size: var(--fs-micro); text-transform: uppercase;
  letter-spacing: var(--tracking-caps); color: var(--ink-faint);
  text-align: left;
  transition: color var(--t-fast);
}
.set-group-head:hover { color: var(--accent); }
.set-group-head .n {
  padding: 0 var(--s2);
  border: 1px solid var(--line); border-radius: var(--r-xs);
  color: var(--ink-ghost); letter-spacing: 0;
}
.set-group-head svg:last-child { margin-left: auto; opacity: 0.5; }
.set-hl { background: var(--accent-soft); color: var(--ink); border-radius: var(--r-xs); padding: 0 1px; }

/* ---- narrow windows: stack the nav above the pane ----------------------- */
@media (max-width: 760px) {
  .modal.settings .modal-body { flex-direction: column; }
  .set-split { flex-direction: column; }
  .set-side { flex: 0 0 auto; max-height: 38%; border-right: none; border-bottom: 1px solid var(--line); }
  .set-nav { flex-direction: row; flex-wrap: wrap; gap: var(--s1); }
  .set-nav .mi { width: auto; flex: 0 1 auto; }
  .set-pane { padding: var(--s5); }
  .set-row > .field-row > .lbl { flex-basis: 116px; }
  .set-help { padding-left: calc(116px + var(--s4)); }
}

/* ============================================================
   BRUSH LIBRARY PANEL + BRUSH STUDIO
   Owned by js/ui/panel-brush.js and js/ui/brushstudio.js.
   Appended section — adds new rules only, modifies none above.
   ============================================================ */

/* ---- brush library grid: wide stroke swatches, two to a dock ---- */
.brush-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }

.brush-tile {
  aspect-ratio: auto;
  height: 58px;
  display: flex; flex-direction: column; align-items: stretch;
  padding: 0;
}
.brush-tile .pv { flex: 1 1 auto; min-height: 0; display: block; overflow: hidden; }
.brush-tile .pv canvas { display: block; max-width: none; max-height: none; }
.brush-tile .name {
  flex: none;
  padding: 0 var(--s2) 3px;
  font-size: var(--fs-micro);
  color: var(--ink-faint);
  text-align: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.brush-tile.on .name { color: var(--accent); }
.brush-tile .flag {
  position: absolute; top: 4px; right: 4px;
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 0 2px var(--bg-input);
}

/* ---- active-brush strip + its live swatch ---- */
.brush-active { display: flex; align-items: center; gap: var(--s3); min-height: 24px; }
.brush-active .nm {
  flex: 1 1 auto; min-width: 0;
  font-size: var(--fs-tiny); color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.brush-modified {
  flex: none; cursor: pointer;
  padding: 0 4px;
  font-size: 8px; font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-caps); text-transform: uppercase;
  color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 42%, transparent);
  border-radius: var(--r-xs);
}
.brush-modified:hover { background: color-mix(in srgb, var(--warn) 14%, transparent); }
.brush-live {
  display: block; width: 100%; height: 46px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--bg-input);
}

/* ---- Brush Studio: nav | pane, with the live preview pinned below ---- */
.bstudio { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; min-width: 0; }
.bstudio-main { flex: 1 1 auto; display: flex; min-height: 0; }
.bstudio-nav {
  flex: none; width: 188px;
  padding: var(--s3);
  border-right: 1px solid var(--line);
  background: var(--bg-chrome);
  overflow-y: auto;
}
.bstudio-nav .mi { margin-bottom: 1px; }
.bstudio-pane { flex: 1 1 auto; min-width: 0; overflow-y: auto; padding: var(--s5) var(--s6) var(--s7); }
.bstudio-pane .field-row { min-height: 30px; }
.bstudio-pane .field-row > .lbl { flex: 0 0 132px; }
.bstudio-sechead h3 { margin: 0; font-size: var(--fs-md); font-weight: var(--fw-bold); letter-spacing: -0.01em; }
.bstudio-sechead p { margin: 3px 0 0; max-width: 56ch; font-size: var(--fs-tiny); color: var(--ink-faint); line-height: 1.55; }

.bstudio-preview {
  flex: none; height: 146px;
  position: relative;
  border-top: 1px solid var(--line);
  background: var(--bg-canvas);
}
.bstudio-preview canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.bstudio-preview .pv-tools { position: absolute; top: var(--s3); right: var(--s3); display: flex; gap: var(--s1); }
.bstudio-preview .pv-hint {
  position: absolute; left: var(--s5); bottom: var(--s2);
  font-size: var(--fs-micro); color: var(--ink-ghost);
  pointer-events: none;
}

.bstudio-shapes {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  gap: var(--s2); padding: 2px;
  max-height: 196px; overflow-y: auto;
}

/* ============================================================
   LAYERS PANEL  (js/ui/panel-layers.js)
   Row anatomy: [tag] [indent] [chevron] [clip] [thumb+mask]
                [name + chips] [lock flags] [eye]
   ============================================================ */

.lyr-panel {
  --lyr-row-h: 36px;
  display: flex; flex-direction: column;
  gap: var(--s3);
}
:root[data-density="compact"]  .lyr-panel { --lyr-row-h: 30px; }
:root[data-density="spacious"] .lyr-panel { --lyr-row-h: 40px; }

/* ---------------------------------------------------------------- header */
.lyr-head {
  display: flex; flex-direction: column; gap: var(--s2);
  padding-bottom: var(--s3);
  border-bottom: 1px solid var(--line);
}
.lyr-head.is-empty { display: none; }
/* the dock is narrow — give the controls more of the row than the labels */
.lyr-head .field-row > .lbl { flex: 0 0 52px; }

.lyr-toggles { display: flex; align-items: center; gap: var(--s1); margin-top: var(--s1); }
.lyr-toggles .iconbtn { width: 24px; height: 24px; }
.lyr-spacer { flex: 1 1 auto; }
.lyr-type {
  font-size: var(--fs-micro);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--ink-ghost);
}

.lyr-chip {
  flex: none;
  padding: 0 3px;
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  background: var(--bg-input);
  font-size: var(--fs-micro);
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
  color: var(--ink-faint);
}
.lyr-chip.dim { color: var(--ink-ghost); }
.lyr-chip-mask {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent);
  cursor: pointer;
}
.lyr-chip-mask:hover { filter: brightness(1.15); }

/* ------------------------------------------------------------------ list */
.lyr-list {
  position: relative;
  min-height: 64px;
  max-height: clamp(150px, 42vh, 560px);
  overflow-y: auto; overflow-x: hidden;
  margin: 0 calc(var(--s4) * -1);
  padding: 0 var(--s3);
  overscroll-behavior: contain;
}
.lyr-list.is-dragging .lyr-row { cursor: grabbing; }

.lyr-row {
  position: relative;
  display: flex; align-items: center; gap: var(--s3);
  min-height: var(--lyr-row-h);
  padding: var(--s1) var(--s2);
  border-radius: var(--r-sm);
  transition: background var(--t-fast) var(--ease-out);
}
.lyr-row:hover { background: var(--bg-hover); }
.lyr-row.sel { background: var(--accent-soft); }
.lyr-row.sel::before {
  content: ''; position: absolute; left: 0; top: 6px; bottom: 6px;
  width: 2px; border-radius: var(--r-full);
  background: var(--accent);
}
.lyr-row.off .lyr-thumbs, .lyr-row.off .lyr-meta { opacity: 0.42; }
.lyr-row.dragging { opacity: 0.4; }
.lyr-row.drop-into {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}

/* colour tag strip, far right so it never fights the selection bar */
.lyr-tag {
  position: absolute; right: 0; top: 6px; bottom: 6px;
  width: 3px; border-radius: var(--r-full);
  pointer-events: none;
}

.lyr-indent { flex: none; }
.lyr-chev-gap { width: 14px; flex: none; }
.lyr-chev {
  width: 14px; height: 14px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--r-xs);
  color: var(--ink-faint);
  transition: transform var(--t-base) var(--ease-out), color var(--t-fast), background var(--t-fast);
}
.lyr-chev:hover { background: var(--bg-active); color: var(--ink); }
.lyr-chev.closed { transform: rotate(-90deg); }

.lyr-clip { flex: none; display: grid; place-items: center; color: var(--ink-faint); }
.lyr-row.sel .lyr-clip { color: var(--accent); }

/* --------------------------------------------------------- thumbnails */
.lyr-thumbs { display: flex; align-items: center; gap: 3px; flex: none; }
.lyr-thumbbox, .lyr-maskbox {
  position: relative; flex: none; line-height: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-xs);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.lyr-maskbox { cursor: pointer; }
.lyr-maskbox.off { opacity: 0.4; }
.lyr-thumbbox.target, .lyr-maskbox.target {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}
.lyr-thumb, .lyr-mask { display: block; }

/* --------------------------------------------------------- name + chips */
.lyr-meta { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: var(--s2); }
.lyr-name {
  flex: 1 1 auto; min-width: 0;
  font-size: var(--fs-small);
  color: var(--ink-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lyr-row.sel .lyr-name { color: var(--ink); }
.lyr-chips { display: flex; align-items: center; gap: 3px; flex: none; }
.lyr-nameinput { width: 100%; padding: 1px var(--s2); font-size: var(--fs-small); }

/* -------------------------------------------------------- flags and eye */
.lyr-flags { display: flex; align-items: center; gap: 1px; flex: none; }
.lyr-flagbtn {
  width: 18px; height: 18px;
  display: grid; place-items: center;
  border-radius: var(--r-xs);
  color: var(--ink-ghost);
  opacity: 0;
  transition: opacity var(--t-fast), color var(--t-fast), background var(--t-fast);
}
.lyr-row:hover .lyr-flagbtn, .lyr-flagbtn:focus-visible { opacity: 1; }
.lyr-flagbtn.on { opacity: 1; color: var(--warn); }
.lyr-flagbtn:hover { background: var(--bg-active); color: var(--ink); }

.lyr-eye {
  width: 24px; height: 24px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  color: var(--ink-dim);
  transition: background var(--t-fast), color var(--t-fast);
}
.lyr-eye:hover { background: var(--bg-active); color: var(--ink); }
.lyr-eye.off { color: var(--ink-ghost); }

/* ---------------------------------------------------------- drop marker */
.lyr-dropline {
  position: absolute; right: var(--s3);
  height: 2px;
  background: var(--accent);
  border-radius: var(--r-full);
  transform: translateY(-1px);
  opacity: 0;
  pointer-events: none;
  z-index: 3;
}
.lyr-dropline.show { opacity: 1; }
.lyr-dropline::before {
  content: ''; position: absolute; left: -3px; top: -2px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
}

/* ---------------------------------------------------------------- footer */
.lyr-foot {
  display: flex; align-items: center; gap: var(--s1);
  padding-top: var(--s3);
  border-top: 1px solid var(--line);
}
.lyr-foot .iconbtn { width: 26px; height: 26px; }
.lyr-foot .lyr-danger:hover {
  background: color-mix(in srgb, var(--err) 16%, transparent);
  color: var(--err);
}

/* colour tag picker inside the layer context menu */
.lyr-tags { padding: var(--s2) var(--s4) var(--s3); }
.lyr-tags .swatch { display: grid; place-items: center; color: var(--ink-faint); }

/* ============================================================
   ASSETS + INFO PANELS
   Appended by js/ui/panel-assets.js and js/ui/panel-info.js.
   Nothing above this line is modified — these are additive only,
   and every value resolves through the existing token set.
   ============================================================ */

/* ---- assets: wide preview tiles (gradients, palettes) ---- */
.tile.wide { aspect-ratio: 2 / 1; }

/* favourite marker, pinned to the tile corner */
.tile .fav {
  position: absolute; top: 2px; right: 2px;
  width: 13px; height: 13px;
  display: grid; place-items: center;
  color: var(--warn);
  background: color-mix(in srgb, var(--bg-panel) 72%, transparent);
  border-radius: var(--r-full);
  pointer-events: none;
}

.assets-foot {
  display: flex; align-items: center; gap: var(--s3);
  margin-top: var(--s3);
  font-size: var(--fs-micro);
  color: var(--ink-ghost);
  font-variant-numeric: tabular-nums;
}

/* the shape being dragged from the panel to the canvas */
.asset-ghost {
  position: fixed; left: 0; top: 0;
  z-index: var(--z-drag);
  pointer-events: none;
  opacity: 0.9;
  filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.55));
}

/* ---- info: key / value readouts ---- */
.info-grid { display: flex; flex-direction: column; gap: 1px; }
.info-row {
  display: flex; align-items: center; gap: var(--s3);
  min-height: 19px;
  font-size: var(--fs-tiny);
}
.info-row > .k { flex: 0 0 76px; color: var(--ink-faint); }
.info-row > .v {
  flex: 1 1 auto; min-width: 0;
  text-align: right;
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.info-color { display: flex; align-items: center; gap: var(--s4); margin-bottom: var(--s3); }
.info-swatch {
  width: 44px; height: 44px; flex: none;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  background-image:
    linear-gradient(45deg, var(--bg-input) 25%, transparent 25%),
    linear-gradient(-45deg, var(--bg-input) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--bg-input) 75%),
    linear-gradient(-45deg, transparent 75%, var(--bg-input) 75%);
  background-size: 10px 10px;
  background-position: 0 0, 0 5px, 5px -5px, -5px 0;
  transition: transform var(--t-fast) var(--ease-out), border-color var(--t-fast);
}
.info-swatch:hover { border-color: var(--line-bright); transform: scale(1.03); }
.info-hex {
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  font-weight: var(--fw-medium);
  color: var(--ink);
  letter-spacing: 0.02em;
}
.info-sub {
  font-size: var(--fs-micro);
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.info-sub.dim { color: var(--ink-faint); }

.info-ch {
  font-size: var(--fs-micro);
  font-weight: var(--fw-bold);
  color: var(--ink-dim);
  cursor: pointer;
  user-select: none;
}

/* ---- info: histogram ---- */
.histo {
  display: block;
  width: 100%; height: 76px;
  margin-top: var(--s3);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--bg-input);
  cursor: crosshair;
}
.info-histinfo {
  margin-top: var(--s2);
  font-size: var(--fs-micro);
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* clipping / out-of-gamut indicators */
.info-chips { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s3); }
.info-chip {
  font-size: var(--fs-micro);
  letter-spacing: 0.02em;
  padding: 1px var(--s3);
  border-radius: var(--r-full);
  border: 1px solid var(--line-strong);
  color: var(--ink-faint);
  white-space: nowrap;
}
.info-chip.ok {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 38%, transparent);
  background: color-mix(in srgb, var(--ok) 12%, transparent);
}
.info-chip.warn {
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 45%, transparent);
  background: color-mix(in srgb, var(--warn) 14%, transparent);
}

/* ============================================================ COLOUR PANEL & PICKER
   Added by js/ui/panel-color.js and js/ui/colorpicker.js.
   Nothing above this line is modified. Everything here is additive and
   namespaced with .ae- so it cannot collide with the base component set.
   ============================================================ */

.ae-cp-body { display: flex; flex-direction: column; }

/* small section rule: LABEL ─────────── [buttons] */
.ae-sec {
  display: flex; align-items: center; gap: var(--s3);
  margin: var(--s5) 0 var(--s3);
  font-size: var(--fs-micro);
  font-weight: var(--fw-medium);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--ink-ghost);
  white-space: nowrap;
}
.ae-sec > span:first-child { overflow: hidden; text-overflow: ellipsis; }
.ae-sec .line { flex: 1 1 auto; min-width: var(--s4); height: 1px; background: var(--line); }
.ae-sec .btns { display: flex; align-items: center; gap: var(--s1); flex: none; }
.ae-sec .btns .iconbtn { width: 20px; height: 20px; }

/* the picking canvas */
.ae-surface { display: flex; justify-content: center; padding: var(--s2) 0 var(--s4); }
.ae-surface canvas {
  display: block;
  touch-action: none;
  cursor: crosshair;
  border-radius: var(--r-sm);
}
.ae-surface canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* foreground / background pair + readout */
.ae-pair { display: flex; align-items: center; gap: var(--s4); min-height: 40px; }
.ae-pair .colorwell { margin-top: 0; }
.ae-pair .colorwell .sw.on { box-shadow: 0 0 0 1px var(--line-strong), 0 0 0 3px var(--accent); }
.ae-info { flex: 1 1 auto; min-width: 0; line-height: 1.35; }
.ae-info .name {
  font-size: var(--fs-tiny); color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ae-info .hex {
  font-family: var(--font-mono); font-size: var(--fs-micro);
  color: var(--ink-faint); text-transform: uppercase;
}

/* channel sliders want a narrow label column, not the 88px field default */
.ae-cp-body .field-row.ae-ch > .lbl { flex: 0 0 14px; text-align: center; }

/* wide harmony chips */
.swatch.ae-swatch-lg { width: auto; height: 26px; flex: 1 1 0; min-width: 12px; }

/* before / after chip pair in the picker popover */
.ae-chip {
  display: flex; flex: none;
  width: 40px; height: 26px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  overflow: hidden;
}
.ae-chip i { display: block; flex: 1 1 0; }

/* eyedropper loupe */
.ae-loupe {
  position: fixed; left: 0; top: 0;
  width: 104px; height: 104px;
  padding: 6px;
  border-radius: 50%;
  box-shadow: var(--shadow-lg), 0 0 0 1px var(--line-bright);
  z-index: var(--z-drag);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease-out);
}
.ae-loupe.show { opacity: 1; }
.ae-loupe canvas { display: block; border-radius: 50%; background: var(--bg-input); }
.ae-loupe .hex {
  position: absolute; left: 50%; bottom: -20px;
  transform: translateX(-50%);
  font-family: var(--font-mono); font-size: var(--fs-micro);
  color: var(--ink);
  background: var(--bg-raised);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-xs);
  padding: 0 var(--s2);
  white-space: nowrap;
  text-transform: uppercase;
}

/* Tool picker: make the corner wedge a real hit target, and give picker rows
   room for the pin affordance. */
.rail-btn .more {
  width: 12px; height: 12px;
  border: none; background: transparent;
  right: 1px; bottom: 1px;
  cursor: pointer;
  display: grid; place-items: end;
  opacity: 1;
}
.rail-btn .more::after {
  content: ''; display: block;
  width: 0; height: 0;
  border-left: 4px solid transparent;
  border-bottom: 4px solid currentColor;
  opacity: 0.45;
  transition: opacity var(--t-fast);
}
.rail-btn:hover .more::after { opacity: 0.9; }
.rail-btn .more:hover::after { opacity: 1; border-bottom-color: var(--accent); }

/* ============================================================
   DOCUMENT DIALOGS — js/ui/dialogs.js
   New Document / Image Size / Canvas Size / Rotate / Fill /
   Export / Adjustment picker. Layout scaffolding only: every
   control inside these is a standard .field-row / .btn / .tile.
   ============================================================ */

/* two-column body: fields on the left, live preview on the right */
.dlg-split { display: flex; align-items: flex-start; gap: var(--s6); }
.dlg-main { flex: 1 1 auto; min-width: 0; }
.dlg-aside {
  flex: 0 0 248px;
  display: flex; flex-direction: column; gap: var(--s4);
  min-width: 0;
}
.dlg-aside.narrow { flex-basis: 224px; }

/* proportion / thumbnail previews */
.dlg-proof, .dlg-thumb, .dlg-fillproof {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--bg-input);
  box-shadow: var(--shadow-inset);
}
/* The preview canvases size themselves from the layout — their backing store
   is re-measured on every paint, so no fixed pixel width is needed here. */
.dlg-proof, .dlg-thumb, .dlg-fillproof { box-sizing: border-box; }

/* key/value readout under a preview */
.dlg-facts { display: flex; flex-direction: column; }
.dlg-fact {
  display: flex; align-items: baseline; gap: var(--s3);
  padding: 3px 0;
  font-size: var(--fs-micro);
  border-top: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}
.dlg-fact:first-child { border-top: none; }
.dlg-fact > .k {
  flex: 0 0 66px;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
}
.dlg-fact > .v {
  flex: 1 1 auto; min-width: 0;
  text-align: right;
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dlg-fact > .v.strong { color: var(--ink); font-weight: var(--fw-medium); }

/* unit suffix pinned after a number box */
.dlg-unit {
  flex: none;
  font-size: var(--fs-micro);
  color: var(--ink-faint);
  min-width: 18px;
}

/* width/height pair with the constrain-proportions chain bracket.
   The control cells shrink to their content so the bracket hugs the fields
   instead of drifting to the far edge of the dialog. */
.dlg-pair { display: flex; align-items: stretch; gap: var(--s2); }
.dlg-pair-rows { flex: 0 1 auto; min-width: 0; }
.dlg-pair .field-row > .ctl { flex: 0 0 auto; }
.dlg-chain {
  flex: none;
  width: 26px;
  display: flex; flex-direction: column; align-items: center;
  color: var(--ink-ghost);
}
.dlg-chain .arm {
  flex: 1 1 0;
  width: 9px;
  border-color: currentColor;
  border-style: solid;
  border-width: 0;
}
.dlg-chain .arm.top { border-top-width: 1px; border-right-width: 1px; align-self: flex-start; margin-left: 4px; }
.dlg-chain .arm.bot { border-bottom-width: 1px; border-right-width: 1px; align-self: flex-start; margin-left: 4px; }
.dlg-chain .iconbtn { width: 24px; height: 22px; flex: none; }
.dlg-chain.on { color: var(--accent); }
.dlg-chain.on .iconbtn { color: var(--accent); }

/* 3x3 anchor picker */
.dlg-anchor-row > .ctl { align-items: flex-start; }
.dlg-anchor {
  display: grid;
  grid-template-columns: repeat(3, 26px);
  grid-template-rows: repeat(3, 26px);
  gap: 2px;
}
.dlg-anchor-cell {
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  background: var(--bg-input);
  color: var(--ink-faint);
  display: grid; place-items: center;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out);
}
.dlg-anchor-cell:hover { background: var(--bg-hover); border-color: var(--line-strong); color: var(--ink-dim); }
.dlg-anchor-cell.on {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.dlg-anchor-cell .pip {
  width: 8px; height: 8px;
  border-radius: 2px;
  background: var(--accent);
}

/* chip row of quick presets */
.dlg-chips { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s4); }

/* inline control that appears/disappears under a segmented row */
.dlg-inline-ctl { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s2); }

/* small caption under a row */
.dlg-sub {
  font-size: var(--fs-micro);
  color: var(--ink-ghost);
  padding: 2px 0 var(--s2);
}

/* a scrolling region inside a modal body (preset and adjustment lists) */
.dlg-scroll { max-height: 232px; overflow-y: auto; overflow-x: hidden; padding-right: var(--s2); }
.dlg-scroll.tall { max-height: 46vh; }

/* count badge on a section rule */
.dlg-count {
  flex: none;
  font-size: var(--fs-micro);
  color: var(--ink-ghost);
  font-variant-numeric: tabular-nums;
}

/* template tiles keep their caption visible — the name is the whole point */
.dlg-tplgrid { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
.tile.dlg-tpl .cap { opacity: 1; font-size: 8px; }
.tile.dlg-tpl:focus-visible { border-color: var(--accent); }

/* a row whose control does not apply to the current format */
.field-row.is-disabled > .lbl { color: var(--ink-ghost); }

/* These dialogs use longer, sentence-like labels ("Transparent Background",
   "Preserve Transparency") than the panels the 88px default was tuned for. */
.modal.dlg-newdoc .field-row > .lbl,
.modal.dlg-size .field-row > .lbl,
.modal.dlg-fill .field-row > .lbl,
.modal.dlg-export .field-row > .lbl { flex: 0 0 128px; }
/* "Transparent Background" is the longest label in the set. */
.modal.dlg-export .field-row > .lbl { flex-basis: 150px; }
/* The fill dialog's preview is a swatch, not a diagram — give the controls
   the room instead. */
.modal.dlg-fill .dlg-aside { flex-basis: 176px; }

@media (max-width: 620px) {
  .dlg-split { flex-direction: column; }
  .dlg-aside, .dlg-aside.narrow { flex: 0 0 auto; width: 100%; }
  .dlg-fillproof { max-width: none; }
}

/* The document dialogs are dense forms — tighten the generic modal padding a
   little and let the tallest of them use more of the viewport. */
.modal.dlg-newdoc .modal-body,
.modal.dlg-size .modal-body,
.modal.dlg-fill .modal-body,
.modal.dlg-export .modal-body,
.modal.dlg-adjust .modal-body { padding: var(--s5) var(--s6) var(--s6); }
.modal.dlg-newdoc, .modal.dlg-adjust { max-height: 90vh; }

/* ============================================================
   LAYERS PANEL — MASK VIEW + CLIPPING INDENT
   Appended by js/ui/panel-layers.js. Additive only: nothing above
   this line is modified, and every value resolves through the
   existing token set.
   ============================================================ */

/* Spec: "clipped layers indent with an elbow glyph." The glyph already
   exists as .lyr-clip; this is the indent that goes with it. */
.lyr-row.clipped { padding-left: calc(var(--s2) + 16px); }

/* A mask thumbnail whose mask is currently previewed alone or as rubylith. */
.lyr-maskbox.viewing {
  border-color: var(--warn);
  box-shadow: 0 0 0 2px var(--warn);
}

/* Header chip for the mask-view preview state — same shape as .lyr-chip-mask,
   warning-coloured because it is a temporary view, not an edit target. */
.lyr-chip-view {
  background: color-mix(in srgb, var(--warn) 18%, transparent);
  border-color: color-mix(in srgb, var(--warn) 45%, transparent);
  color: var(--warn);
  cursor: pointer;
}
.lyr-chip-view:hover { filter: brightness(1.15); }

/* ============================================================
   ANIMATION TIMELINE — js/ui/timeline.js
   Appended section. Adds only new, `ae-tl-` prefixed rules;
   nothing above this line is modified.
   ============================================================ */

.ae-tl {
  /* keep in step with THUMB_H in js/ui/timeline.js */
  --tl-thumb-h: 46px;
  display: flex; flex-direction: column;
  height: 100%; min-height: 0;
}

/* ---- transport strip ---- */
.ae-tl-bar {
  flex: none;
  display: flex; align-items: center; gap: var(--s2);
  padding: var(--s2) var(--s4);
  border-bottom: 1px solid var(--line);
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none;
}
.ae-tl-bar::-webkit-scrollbar { display: none; }
.ae-tl-bar .numbox { width: 44px; }
.ae-tl-bar .opt { flex: none; }
.ae-tl-grow { flex: 1 1 auto; min-width: var(--s4); }
.ae-tl-off { opacity: 0.45; }
.ae-tl-danger:hover { color: var(--err); }

.ae-tl-readout {
  flex: none; white-space: nowrap;
  font-size: var(--fs-tiny); color: var(--ink-faint);
}
.ae-tl-readout b {
  color: var(--ink-dim);
  font-weight: var(--fw-medium);
  font-variant-numeric: tabular-nums;
}

/* ---- filmstrip ---- */
.ae-tl-stripwrap {
  flex: 1 1 auto; min-height: 0;
  overflow-x: auto; overflow-y: hidden;
  overscroll-behavior-x: contain;
}
.ae-tl-track {
  position: relative;
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s4) var(--s5);
  min-height: 100%;
  min-width: min-content;
}
.ae-tl-track > .empty { flex: 1 1 auto; }
.ae-tl-track.is-dragging .ae-tl-frame { transition: none; }

.ae-tl-frame {
  position: relative; flex: none;
  display: flex; align-items: center; justify-content: center;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--bg-input);
  touch-action: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast),
              transform var(--t-fast) var(--ease-out);
}
.ae-tl-frame:hover { border-color: var(--line-bright); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.ae-tl-frame.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.ae-tl-frame.dragging { opacity: 0.5; transform: scale(0.95); box-shadow: var(--shadow-md); cursor: grabbing; }
.ae-tl-frame canvas.ae-tl-thumb { display: block; border-radius: 2px; }

.ae-tl-num, .ae-tl-hold {
  position: absolute;
  font-size: var(--fs-micro); line-height: 1.5;
  font-variant-numeric: tabular-nums;
  color: #fff; background: rgba(0, 0, 0, 0.58);
  border-radius: var(--r-xs);
  padding: 0 3px;
  pointer-events: none;
}
.ae-tl-num { top: 3px; left: 4px; }
.ae-tl-hold { bottom: 3px; right: 4px; }
.ae-tl-frame.sel .ae-tl-num { background: var(--accent); color: var(--accent-ink); }

.ae-tl-add {
  flex: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  height: calc(var(--tl-thumb-h) + 8px);
  min-width: 54px; padding: 0 var(--s4);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-sm);
  color: var(--ink-faint);
  font-size: var(--fs-micro);
  transition: all var(--t-fast) var(--ease-out);
}
.ae-tl-add:hover { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }

/* ---- playhead: a nib + stem over the live frame, with a progress sweep
        driven by --tl-p (0..1) and the frame width in --tl-w ---- */
.ae-tl-playhead {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0;
  z-index: 3; pointer-events: none;
  opacity: 0;
  transition: transform var(--t-base) var(--ease-out), opacity var(--t-fast);
}
.ae-tl-playhead.show { opacity: 1; }
.ae-tl-playhead .stem {
  position: absolute; left: -1px; top: 0; bottom: 0; width: 2px;
  background: var(--accent); opacity: 0.45;
  border-radius: var(--r-full);
}
.ae-tl-playhead .nib {
  position: absolute; top: 0; left: -5px;
  width: 10px; height: 6px;
  background: var(--accent);
  border-radius: 0 0 var(--r-xs) var(--r-xs);
  box-shadow: var(--shadow-sm);
}
.ae-tl-playhead::after {
  content: ''; position: absolute; bottom: 0;
  left: calc(var(--tl-w, 0px) / -2);
  height: 2px;
  width: calc(var(--tl-w, 0px) * var(--tl-p, 0));
  background: var(--accent);
  border-radius: var(--r-full);
}

.ae-tl-drop {
  position: absolute; top: var(--s3); bottom: var(--s3); left: 0;
  width: 2px; margin-left: -1px;
  background: var(--accent);
  border-radius: var(--r-full);
  z-index: 4; pointer-events: none;
  opacity: 0;
  transition: opacity var(--t-fast), transform var(--t-fast) var(--ease-out);
}
.ae-tl-drop.show { opacity: 1; }

/* ---- empty state ---- */
.ae-tl-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--s1);
  max-width: 520px; margin: 0 auto;
}
.ae-tl-empty .dim { color: var(--ink-ghost); }
.ae-tl-emptybtns { margin-top: var(--s4); }
.ae-tl-emptybtns > .btn { flex: none; padding-left: var(--s5); padding-right: var(--s5); }

/* ---- export dialog ---- */
.ae-tl-note {
  text-align: left;
  padding: var(--s4) var(--s5);
  margin-bottom: var(--s5);
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--ink-dim);
  font-size: var(--fs-tiny);
}
.ae-tl-note b { color: var(--ink); font-weight: var(--fw-medium); }
.ae-tl-estimate { font-size: var(--fs-tiny); color: var(--ink-faint); }
.ae-tl-estimate b {
  color: var(--ink); font-weight: var(--fw-medium);
  font-variant-numeric: tabular-nums;
}
.ae-tl-warn {
  display: flex; align-items: center; gap: var(--s2);
  margin-top: var(--s3);
  color: var(--warn); font-size: var(--fs-micro);
}

/* ---- floating fallback, used only on a shell with no bottom dock ---- */
.ae-tl-float {
  position: absolute; left: var(--s5); right: var(--s5); bottom: var(--s5);
  height: 172px;
  display: flex; flex-direction: column;
  background: var(--bg-chrome);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: var(--z-dock);
}
.ae-tl-floatgrip {
  position: absolute; left: 0; right: 0; top: 0; height: 6px;
  cursor: row-resize; z-index: 5;
}
.ae-tl-floatgrip:hover { background: var(--accent-line); }
.ae-tl-floatbody { flex: 1 1 auto; min-height: 0; }

/* ============================================================
   WELCOME / ABOUT  —  js/ui/welcome.js
   SCRIPTING CONSOLE —  js/ui/console.js
   Appended section. Every selector below is new and prefixed
   (.wel-* and .cons-*); no rule above this banner is modified.
   ============================================================ */

/* ---------------------------------------------------------- welcome shell */
.modal.wel .modal-body { padding: 0; }
.modal.wel .modal-foot { gap: var(--s4); }

.wel-hero {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  gap: var(--s3);
  padding: var(--s9) var(--s8) var(--s7);
  text-align: center;
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(120% 150% at 50% -40%, var(--accent-soft), transparent 60%),
    var(--bg-chrome);
}
.wel-hero .brand-mark { width: 48px; height: 48px; color: var(--ink); }
.wel-close { position: absolute; top: var(--s4); right: var(--s4); }

.wel-title {
  margin: var(--s1) 0 0;
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  letter-spacing: -0.02em;
  line-height: var(--lh-tight);
}
.wel-title .dim { color: var(--ink-faint); font-weight: var(--fw-regular); }

.wel-tag {
  margin: 0;
  max-width: 56ch;
  font-size: var(--fs-small);
  color: var(--ink-dim);
  line-height: 1.6;
}

.wel-chips {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: var(--s2);
  margin-top: var(--s2);
}
.wel-chip {
  display: inline-flex; align-items: center; gap: var(--s2);
  padding: 2px var(--s3);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  background: var(--bg-panel);
  font-size: var(--fs-micro);
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}
.wel-chip svg { opacity: 0.75; }

/* ------------------------------------------------------- welcome columns */
.wel-cols {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: var(--s7);
  padding: var(--s6) var(--s7) var(--s7);
  align-items: start;
}
.wel-col { min-width: 0; display: flex; flex-direction: column; gap: var(--s2); }
@media (max-width: 720px) {
  .wel-cols { grid-template-columns: minmax(0, 1fr); gap: var(--s6); }
}

.wel-sec {
  display: flex; align-items: center; gap: var(--s3);
  margin: var(--s5) 0 var(--s3);
  font-size: var(--fs-micro);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--ink-ghost);
}
.wel-col > .wel-sec:first-child { margin-top: 0; }
.wel-sec .n { flex: none; }
.wel-sec .line { flex: 1 1 auto; height: 1px; background: var(--line); }
.wel-sec .btn { flex: none; }

/* ----------------------------------------------------- document templates */
.wel-tpls {
  display: flex; gap: var(--s3);
  overflow-x: auto; overflow-y: hidden;
  padding-bottom: var(--s2);
  scrollbar-width: none;
}
.wel-tpls::-webkit-scrollbar { display: none; }

.wel-tpl {
  flex: none; width: 96px;
  display: flex; flex-direction: column; align-items: center; gap: var(--s1);
  padding: var(--s3) var(--s2) var(--s4);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--bg-input);
  color: var(--ink-dim);
  text-align: center;
  transition: border-color var(--t-fast), background var(--t-fast),
              transform var(--t-fast) var(--ease-out), color var(--t-fast);
}
.wel-tpl:hover {
  border-color: var(--accent-line);
  background: var(--bg-hover);
  color: var(--ink);
  transform: translateY(-2px);
}
.wel-tpl:active { transform: translateY(0); }
.wel-tpl .pv {
  height: 38px; width: 100%;
  display: grid; place-items: center;
  color: var(--ink-faint);
}
.wel-tpl .pv i {
  display: block;
  border: 1px solid var(--line-bright);
  border-radius: 2px;
  background: var(--bg-panel);
  box-shadow: var(--shadow-sm);
}
.wel-tpl:hover .pv i { border-color: var(--accent); }
.wel-tpl .nm {
  font-size: var(--fs-tiny);
  font-weight: var(--fw-medium);
  max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wel-tpl .sz {
  font-size: var(--fs-micro);
  color: var(--ink-ghost);
  font-variant-numeric: tabular-nums;
}
.wel-tpl-custom { border-style: dashed; }
.wel-tpl-custom .pv { color: var(--accent); }

/* ------------------------------------------------------ recent documents */
.wel-recents { display: flex; flex-direction: column; gap: 1px; }
.mi.wel-recent { padding: var(--s3); }
.mi.wel-recent .ico { width: 30px; height: 22px; }
.mi.wel-recent .lbl {
  display: flex; flex-direction: column; gap: 1px;
  white-space: normal; overflow: hidden;
}
.mi.wel-recent .lbl .n {
  font-size: var(--fs-small);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mi.wel-recent .lbl .sub {
  font-size: var(--fs-micro);
  color: var(--ink-ghost);
  font-variant-numeric: tabular-nums;
}
.mi.wel-recent .kbd { opacity: 0; transition: opacity var(--t-fast); }
.mi.wel-recent:hover .kbd, .mi.wel-recent:focus-visible .kbd { opacity: 1; }
.wel-thumb {
  width: 30px; height: 22px;
  object-fit: cover;
  border-radius: var(--r-xs);
  border: 1px solid var(--line);
  background: var(--bg-input);
}

/* --------------------------------------------------------- pro explainer */
.wel-pro {
  padding: var(--s4) var(--s5) var(--s5);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--bg-input);
  transition: border-color var(--t-base), background var(--t-base);
}
.wel-pro.on {
  border-color: var(--accent-line);
  background: color-mix(in srgb, var(--accent) 7%, var(--bg-input));
}
.wel-pro-top { display: flex; align-items: center; gap: var(--s4); }
.wel-pro-title {
  flex: 1 1 auto; min-width: 0;
  display: flex; align-items: center; gap: var(--s3);
  font-size: var(--fs-small);
  font-weight: var(--fw-bold);
  color: var(--ink);
}
.wel-pro-body {
  margin: var(--s3) 0 0;
  font-size: var(--fs-tiny);
  color: var(--ink-dim);
  line-height: 1.65;
}

/* -------------------------------------------------------- shortcut lines */
.wel-keys { display: flex; flex-direction: column; gap: 1px; }
.mi.wel-key { padding: var(--s2) var(--s3); }
.mi.wel-key .lbl { font-size: var(--fs-tiny); }
.mi.wel-key .kbd {
  flex: none;
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  padding: 0 var(--s2);
  color: var(--ink-dim);
}
.mi.wel-key:hover .kbd { border-color: var(--accent-line); color: var(--accent); }

/* ---------------------------------------------------------- live figures */
.wel-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--s2);
}
.wel-stat {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: var(--s3) var(--s1);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--bg-input);
}
.wel-stat b {
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  line-height: 1.1;
}
.wel-stat span {
  font-size: 9px;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--ink-ghost);
}
.wel-stat.zero b { color: var(--ink-ghost); }

/* ---------------------------------------------------------------- footer */
.wel-dontshow {
  display: flex; align-items: center; gap: var(--s3);
  font-size: var(--fs-tiny);
  color: var(--ink-dim);
  cursor: pointer;
  user-select: none;
}
.wel-dontshow:hover { color: var(--ink); }
.wel-foot-gap { flex: 1 1 auto; }

/* ============================================================
   SCRIPTING CONSOLE
   ============================================================ */
.cons {
  position: absolute;
  display: flex; flex-direction: column;
  min-width: 340px; min-height: 190px;
  background: color-mix(in srgb, var(--bg-panel) 95%, transparent);
  backdrop-filter: blur(22px) saturate(1.4);
  -webkit-backdrop-filter: blur(22px) saturate(1.4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 4;
  animation: consIn var(--t-base) var(--ease-out);
}
@keyframes consIn {
  from { opacity: 0; transform: translateY(8px) scale(0.99); }
  to   { opacity: 1; transform: none; }
}
.cons.cons-busy { user-select: none; }
.cons.cons-flash { animation: consFlash var(--t-slow) var(--ease-out); }
@keyframes consFlash {
  0%, 100% { box-shadow: var(--shadow-lg); }
  40%      { box-shadow: var(--shadow-lg), 0 0 0 2px var(--accent); }
}

.cons-head {
  flex: none;
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s2) var(--s2) var(--s2) var(--s4);
  border-bottom: 1px solid var(--line);
  background: var(--bg-chrome);
  touch-action: none;
  user-select: none;
}
.cons-head .ico { display: grid; place-items: center; color: var(--accent); }
.cons-head .title {
  font-size: var(--fs-tiny);
  font-weight: var(--fw-medium);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--ink-dim);
}
.cons-head .grow { flex: 1 1 auto; }
.cons-head .iconbtn { width: 24px; height: 24px; }

/* ------------------------------------------------------------ transcript */
.cons-out {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; overflow-x: hidden;
  padding: var(--s3) var(--s3) var(--s4);
  font-family: var(--font-mono);
  font-size: var(--fs-tiny);
  line-height: 1.55;
  user-select: text; -webkit-user-select: text;
}
.cons-row {
  display: flex; gap: var(--s3);
  padding: 2px var(--s2);
  border-radius: var(--r-xs);
  word-break: break-word;
}
.cons-row .gut {
  flex: none; width: 10px;
  text-align: center;
  color: var(--ink-ghost);
  user-select: none;
}
.cons-row .body { flex: 1 1 auto; min-width: 0; }
.cons-row .src { margin: 0; font: inherit; white-space: pre-wrap; }

.cons-row.in { color: var(--ink); background: color-mix(in srgb, var(--ink) 4%, transparent); }
.cons-row.in .gut { color: var(--accent); }
.cons-row.res { color: var(--ink-dim); }
.cons-row.res .gut { color: var(--ink-faint); }
.cons-row.res.pending { opacity: 0.7; }
.cons-row.log { color: var(--ink-dim); }
.cons-row.note {
  color: var(--ink-faint);
  font-family: var(--font);
  font-size: var(--fs-tiny);
}
.cons-row.note.warn { color: var(--warn); }
.cons-row.err {
  color: var(--err);
  background: color-mix(in srgb, var(--err) 9%, transparent);
}
.cons-row.err .gut { color: var(--err); }
.cons-errhead b { font-weight: var(--fw-bold); }
.cons-stack {
  margin: var(--s2) 0 0;
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  color: var(--ink-faint);
  white-space: pre-wrap;
  line-height: 1.5;
  max-height: 160px; overflow: auto;
}

.cons-row.help { padding-top: 0; padding-bottom: 0; }
.cons-row.help .body { display: flex; gap: var(--s4); }
.cons-help-k {
  flex: 0 0 128px;
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  color: var(--accent);
}
.cons-help-v { flex: 1 1 auto; min-width: 0; color: var(--ink-faint); font-size: var(--fs-micro); }

.cons-args { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s3); }

/* ------------------------------------------------------- value inspector */
.cons-val { display: block; }
.cons-tog {
  display: inline-flex; align-items: center; gap: var(--s2);
  border-radius: var(--r-xs);
  color: inherit; font: inherit;
  text-align: left;
  max-width: 100%;
}
.cons-tog:hover { color: var(--ink); }
.cons-tog .chev {
  display: grid; place-items: center;
  color: var(--ink-faint);
  transition: transform var(--t-fast) var(--ease-out);
}
.cons-tog.open .chev { transform: rotate(90deg); }

.cons-kids {
  margin: 1px 0 var(--s2) var(--s5);
  padding-left: var(--s4);
  border-left: 1px solid var(--line);
}
.cons-kid { display: flex; gap: var(--s3); padding: 1px 0; }
.cons-kid .k {
  flex: 0 0 auto; max-width: 42%;
  color: var(--ink-faint);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cons-kid .k::after { content: ':'; color: var(--ink-ghost); }

.cons-str  { color: var(--ok); }
.cons-num  { color: var(--info); }
.cons-bool { color: var(--warn); }
.cons-nul  { color: var(--ink-ghost); font-style: italic; }
.cons-fn   { color: var(--accent); }
.cons-ref  { color: var(--ink); }

.cons-thumbwrap { padding: var(--s2) 0; }
.cons-thumb {
  display: block;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-xs);
  background-image:
    linear-gradient(45deg, var(--line) 25%, transparent 25%),
    linear-gradient(-45deg, var(--line) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--line) 75%),
    linear-gradient(-45deg, transparent 75%, var(--line) 75%);
  background-size: 10px 10px;
  background-position: 0 0, 0 5px, 5px -5px, -5px 0;
}

/* ----------------------------------------------------------- input line */
.cons-in {
  flex: none;
  display: flex; align-items: flex-start; gap: var(--s3);
  padding: var(--s3) var(--s3) var(--s3) var(--s4);
  border-top: 1px solid var(--line);
  background: var(--bg-chrome);
}
.cons-in .caret {
  flex: none;
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  color: var(--accent);
  line-height: 22px;
  user-select: none;
}
.cons-src {
  flex: 1 1 auto; min-width: 0;
  height: 22px; max-height: 150px;
  resize: none;
  background: none; border: none; padding: 0;
  font-family: var(--font-mono);
  font-size: var(--fs-tiny);
  line-height: 1.6;
  color: var(--ink);
  overflow-y: auto;
  user-select: text; -webkit-user-select: text;
}
.cons-src::placeholder { color: var(--ink-ghost); }
.cons-in .cons-run { width: 24px; height: 24px; flex: none; }

/* -------------------------------------------------------- resize handles */
.cons-edge { position: absolute; touch-action: none; }
.cons-edge.n { left: 8px; right: 8px; top: 0; height: 5px; }
.cons-edge.w { top: 8px; bottom: 8px; left: 0; width: 5px; }
.cons-edge:hover { background: var(--accent-line); }
.cons-corner {
  position: absolute; right: 0; bottom: 0;
  width: 16px; height: 16px;
  touch-action: none;
  background:
    linear-gradient(135deg, transparent 52%, var(--line-bright) 52%, var(--line-bright) 60%, transparent 60%,
                    transparent 70%, var(--line-bright) 70%, var(--line-bright) 78%, transparent 78%);
}
.cons-corner:hover { background-color: var(--accent-soft); }

/* --------------------------------------------------------- snippet menu */
.mi.cons-snip { padding: var(--s3); align-items: flex-start; }
.mi.cons-snip .ico { margin-top: 1px; color: var(--accent); }
.mi.cons-snip .lbl {
  display: flex; flex-direction: column; gap: 1px;
  white-space: normal; overflow: hidden;
}
.mi.cons-snip .lbl .n { font-size: var(--fs-small); color: var(--ink-dim); }
.mi.cons-snip:hover .lbl .n { color: var(--ink); }
.mi.cons-snip .lbl .sub {
  font-size: var(--fs-micro);
  color: var(--ink-ghost);
  line-height: 1.45;
}

/* ============================================================
   MODES REMOVED — every capability is available all the time, so the
   Pro badges, the mode switch and the status-bar chip no longer mean
   anything and would only add noise.
   ============================================================ */
.badge-pro,
.modeswitch,
.statusbar .pro-chip { display: none !important; }
.pro-only { display: revert !important; }

/* ============================================================
   OPTIONS BAR OVERFLOW
   Tool option sets can be several thousand pixels wide. The bar scrolls, but
   with the scrollbar hidden that is invisible — so fade the edges and offer
   arrows whenever there is more to reach.
   ============================================================ */
#app { position: relative; }

.optionsbar { position: relative; scroll-behavior: smooth; }
.optionsbar.fade-l { mask-image: linear-gradient(90deg, transparent 0, #000 34px, #000 100%); }
.optionsbar.fade-r { mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 34px), transparent 100%); }
.optionsbar.fade-l.fade-r {
  mask-image: linear-gradient(90deg, transparent 0, #000 34px, #000 calc(100% - 34px), transparent 100%);
}

.optbar-arrow {
  position: absolute;
  top: calc(var(--topbar-h) + 4px);
  height: calc(var(--optionsbar-h) - 8px);
  width: 26px;
  display: none; place-items: center;
  color: var(--ink-dim);
  background: color-mix(in srgb, var(--bg-panel) 88%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  z-index: calc(var(--z-chrome) + 1);
  box-shadow: var(--shadow-sm);
}
.optbar-arrow.show { display: grid; }
.optbar-arrow:hover { color: var(--ink); background: var(--bg-hover); }
.optbar-arrow.left  { left: 3px; }
.optbar-arrow.right { right: 3px; }

/* ============================================================
   BOTTOM DOCK SIZING
   The timeline's empty state and its frame strip need more than the old
   168px, which cut the strip off under the status bar.
   ============================================================ */
:root { --bottom-h: 214px; }
.dock-bottom .ae-tl-stripwrap,
.dock-bottom [class*="stripwrap"] { overflow-y: auto; }

/* Status-bar chips (guides indicator) */
.status-chip {
  display: inline-flex; align-items: center; gap: var(--s2);
  padding: 1px var(--s3);
  border-radius: var(--r-full);
  border: 1px solid var(--line-strong);
  background: var(--bg-raised);
  color: var(--ink-faint);
  font-size: var(--fs-micro);
  flex: none;
  transition: color var(--t-fast), background var(--t-fast), border-color var(--t-fast);
}
.status-chip:hover { color: var(--ink); background: var(--bg-hover); }
.status-chip.on {
  color: var(--accent);
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

/* ============================================================
   WELCOME — colour pass
   The start screen was entirely greyscale, which made a drawing app look
   like a settings dialog. Everything below is presentation only; no layout
   or behaviour changes.
   ============================================================ */

.modal.wel, .scrim .modal:has(.wel-hero) { overflow: hidden; }

/* Aurora wash behind the hero, built from the live accent so it follows the
   user's theme instead of hardcoding a palette. */
.wel-hero {
  position: relative;
  isolation: isolate;
  padding-top: var(--s8);
  padding-bottom: var(--s7);
  overflow: hidden;
}
.wel-hero::before {
  content: '';
  position: absolute; inset: -60% -20% auto -20%;
  height: 320px;
  z-index: -2;
  background:
    radial-gradient(48% 60% at 18% 42%, rgba(var(--accent-rgb), 0.55) 0%, transparent 68%),
    radial-gradient(42% 56% at 78% 34%, rgba(255, 106, 168, 0.42) 0%, transparent 70%),
    radial-gradient(50% 62% at 52% 78%, rgba(86, 214, 196, 0.38) 0%, transparent 72%),
    radial-gradient(38% 50% at 92% 76%, rgba(255, 186, 84, 0.34) 0%, transparent 70%);
  filter: blur(38px) saturate(1.25);
  opacity: 0.9;
  animation: welDrift 22s var(--ease-in-out) infinite alternate;
}
:root[data-theme="light"] .wel-hero::before,
:root[data-theme="paper"] .wel-hero::before { opacity: 0.55; filter: blur(44px) saturate(1.1); }
@keyframes welDrift {
  from { transform: translate3d(-3%, -2%, 0) scale(1); }
  to   { transform: translate3d(4%, 3%, 0) scale(1.12); }
}
.wel-hero::after {
  content: '';
  position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
  background: linear-gradient(90deg, transparent,
    rgba(var(--accent-rgb), 0.55) 22%, rgba(255, 106, 168, 0.5) 50%,
    rgba(86, 214, 196, 0.5) 76%, transparent);
}

/* The mark gets the accent and a soft halo so it reads as a logo, not an icon */
.wel-hero .brand-mark {
  color: var(--accent);
  filter: drop-shadow(0 3px 14px rgba(var(--accent-rgb), 0.55));
}

.wel-title {
  background: linear-gradient(92deg, var(--ink) 12%, rgba(var(--accent-rgb), 0.92) 58%, var(--ink) 96%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.wel-title .dim { -webkit-text-fill-color: var(--ink-faint); color: var(--ink-faint); }

.wel-chip {
  border-color: color-mix(in srgb, var(--accent) 26%, var(--line-strong));
  background: color-mix(in srgb, var(--accent) 8%, var(--bg-raised));
}
.wel-chip:nth-child(2) { border-color: rgba(255, 106, 168, 0.32); background: rgba(255, 106, 168, 0.09); }
.wel-chip:nth-child(3) { border-color: rgba(86, 214, 196, 0.32); background: rgba(86, 214, 196, 0.09); }
.wel-chip svg { opacity: 1; color: var(--accent); }
.wel-chip:nth-child(2) svg { color: #ff6aa8; }
.wel-chip:nth-child(3) svg { color: #56d6c4; }

/* Section rules get a coloured leader */
.wel-sec .n { color: var(--ink-dim); }
.wel-sec .line {
  background: linear-gradient(90deg, rgba(var(--accent-rgb), 0.45), var(--line) 55%, transparent);
}

/* Template cards: give each a distinct hue so the row reads as a palette */
.wel-tpl { position: relative; overflow: hidden; transition: all var(--t-base) var(--ease-out); }
.wel-tpl::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  opacity: 0; transition: opacity var(--t-base);
  background: linear-gradient(150deg, rgba(var(--accent-rgb), 0.16), transparent 60%);
}
.wel-tpl:hover { transform: translateY(-2px); border-color: var(--accent-line); box-shadow: var(--shadow-md); }
.wel-tpl:hover::after { opacity: 1; }
.wel-tpl:nth-child(5n+1) .wel-tpl-thumb { background: linear-gradient(140deg, #5b8cff, #8f6bff); }
.wel-tpl:nth-child(5n+2) .wel-tpl-thumb { background: linear-gradient(140deg, #ff6aa8, #ff9a5b); }
.wel-tpl:nth-child(5n+3) .wel-tpl-thumb { background: linear-gradient(140deg, #56d6c4, #3fa8ff); }
.wel-tpl:nth-child(5n+4) .wel-tpl-thumb { background: linear-gradient(140deg, #ffba54, #ff7a59); }
.wel-tpl:nth-child(5n+5) .wel-tpl-thumb { background: linear-gradient(140deg, #a78bfa, #f472b6); }
.wel-tpl-thumb, .wel-tpl > div:first-child {
  border-radius: var(--r-sm);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.14);
}

/* Stat tiles: numbers in accent, tiles tinted, zeroes stay quiet */
.wel-stat {
  background: linear-gradient(160deg,
    color-mix(in srgb, var(--accent) 10%, var(--bg-input)),
    var(--bg-input));
  border-color: color-mix(in srgb, var(--accent) 18%, var(--line));
  transition: transform var(--t-fast) var(--ease-out), border-color var(--t-fast);
}
.wel-stat:hover { transform: translateY(-1px); border-color: var(--accent-line); }
.wel-stat b, .wel-stat .n, .wel-stat strong {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.wel-stat:nth-child(6n+2) { background: linear-gradient(160deg, rgba(255,106,168,0.13), var(--bg-input)); border-color: rgba(255,106,168,0.24); }
.wel-stat:nth-child(6n+2) b, .wel-stat:nth-child(6n+2) .n, .wel-stat:nth-child(6n+2) strong { color: #ff6aa8; }
.wel-stat:nth-child(6n+3) { background: linear-gradient(160deg, rgba(86,214,196,0.13), var(--bg-input)); border-color: rgba(86,214,196,0.24); }
.wel-stat:nth-child(6n+3) b, .wel-stat:nth-child(6n+3) .n, .wel-stat:nth-child(6n+3) strong { color: #56d6c4; }
.wel-stat:nth-child(6n+4) { background: linear-gradient(160deg, rgba(255,186,84,0.13), var(--bg-input)); border-color: rgba(255,186,84,0.24); }
.wel-stat:nth-child(6n+4) b, .wel-stat:nth-child(6n+4) .n, .wel-stat:nth-child(6n+4) strong { color: #ffba54; }
.wel-stat:nth-child(6n+5) { background: linear-gradient(160deg, rgba(167,139,250,0.13), var(--bg-input)); border-color: rgba(167,139,250,0.24); }
.wel-stat:nth-child(6n+5) b, .wel-stat:nth-child(6n+5) .n, .wel-stat:nth-child(6n+5) strong { color: #a78bfa; }
.wel-stat.zero { background: var(--bg-input); border-color: var(--line); }
.wel-stat.zero b, .wel-stat.zero .n, .wel-stat.zero strong { color: var(--ink-ghost); }

/* Shortcut list: keys get real key-caps */
.wel-keys .kbd, .wel-keys kbd {
  background: var(--bg-input);
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: var(--r-xs);
  padding: 1px var(--s3);
  color: var(--ink-dim);
}

/* Primary action reads as the primary action */
.wel-foot .btn.primary, .modal-foot .btn.primary {
  background: linear-gradient(140deg, var(--accent), color-mix(in srgb, var(--accent) 62%, #ff6aa8));
  border-color: transparent;
  box-shadow: 0 2px 14px rgba(var(--accent-rgb), 0.4);
}
.wel-foot .btn.primary:hover, .modal-foot .btn.primary:hover { filter: brightness(1.08); }

.wel-recents .empty { border-radius: var(--r-md); background: var(--bg-input); }

/* ---- options bar: overflow popover + pinning ---- */
.optbar-more { flex: none; gap: var(--s2); }
.optbar-more .count {
  font-size: var(--fs-micro);
  padding: 0 var(--s2);
  border-radius: var(--r-full);
  background: var(--accent-soft);
  color: var(--accent);
}
.optrow-pin { opacity: 0; margin-left: var(--s2); flex: none; }
.field-row:hover .optrow-pin { opacity: 0.55; }
.optrow-pin:hover { opacity: 1; color: var(--accent); }

/* ---- rail on the right ---- */
:root[data-rail="right"] #app {
  grid-template-areas:
    "top    top   top"
    "opts   opts  opts"
    "dock   stage rail"
    "status status status";
  grid-template-columns: auto 1fr auto;
}
:root[data-rail="right"] .rail { border-right: none; border-left: 1px solid var(--line); }
:root[data-rail="right"] .dock { border-left: none; border-right: 1px solid var(--line); }
:root[data-rail="right"] .rail-btn.active::before { left: auto; right: -7px; border-radius: var(--r-full) 0 0 var(--r-full); }
:root[data-rail="right"] .dock-resizer { left: auto; right: -3px; }

:root[data-zoompill="off"] .zoompill { display: none; }
