/* ————— MediaPack editor chrome: a quiet backstage console ————— */

* { box-sizing: border-box; margin: 0; padding: 0; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* MediaPack brand: cool ink ground, paper text, vermilion signal */
:root {
  --c-bg: #121316;
  --c-panel: #191b20;
  --c-line: #2a2e35;
  --c-ink: #eceded;
  --c-dim: #8d93a0;
  --c-amber: #f0532e;      /* brand vermilion (var name kept for stability) */
  --c-amber-ink: #fff6f2;
  --font-ui: 'Inter', sans-serif;
  --font-brand: 'Instrument Serif', serif;
  --font-mono: 'DM Mono', monospace;
}

html, body { height: 100%; }

body {
  font-family: var(--font-ui);
  background: var(--c-bg);
  color: var(--c-ink);
  overflow: hidden;
}

/* faint grain so the chrome never feels flat */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
}

#chrome { position: relative; z-index: 1; display: flex; flex-direction: column; height: 100vh; }

/* ————— top bar ————— */

#topbar {
  display: flex; align-items: center; gap: 1rem;
  height: 54px; padding: 0 1.1rem;
  border-bottom: 1px solid var(--c-line);
  background: color-mix(in srgb, var(--c-panel) 80%, transparent);
}

.brand {
  display: flex; align-items: center; gap: .5rem;
  font-family: var(--font-brand);
  font-size: 1.25rem; font-weight: 560; letter-spacing: -.01em;
}
.brand .mark { width: 22px; height: 22px; flex: none; }
#topbar .brand { cursor: pointer; }
#topbar .brand:hover em { text-decoration: underline; text-underline-offset: 3px; }
.brand em {
  font-style: italic; color: var(--c-amber);
  font-size: .8em; margin-left: .45em; font-weight: 400;
}

.tb-shuffle {
  position: absolute; left: 50%; transform: translateX(-50%);
  display: flex; gap: .4rem; align-items: center;
}
#topbar { position: relative; }
.tb-shuffle .btn:disabled { opacity: .35; cursor: default; }

.src {
  flex: 1; text-align: right; padding-right: 1rem;
  font-family: var(--font-mono);
  font-size: .62rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--c-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.actions { display: flex; gap: .5rem; }

.btn {
  font-family: var(--font-ui); font-size: .8rem; font-weight: 600;
  padding: .48rem .85rem; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--c-line); background: transparent; color: var(--c-ink);
  transition: border-color .15s, background .15s, transform .1s;
}
.btn:hover { border-color: var(--c-dim); }
.btn:active { transform: translateY(1px); }
.btn.solid { background: var(--c-amber); border-color: var(--c-amber); color: var(--c-amber-ink); }
.btn.solid:hover { filter: brightness(1.08); }
.btn.icon { padding: .48rem .6rem; }
.btn.sm { font-size: .72rem; padding: .35rem .6rem; }

/* ————— workbench ————— */

#workbench { display: flex; flex: 1; min-height: 0; }

/* the panel is a slide-over drawer now — the page itself is the editor,
   the drawer is where the fine-tuning lives */
#panel {
  position: fixed; top: 55px; right: 0; bottom: 0; z-index: 60;
  width: min(360px, 94vw); display: flex; flex-direction: column;
  border-left: 1px solid var(--c-line); background: var(--c-panel);
  box-shadow: -18px 0 48px rgba(0,0,0,.35);
  transform: translateX(calc(100% + 30px));
  transition: transform .28s cubic-bezier(.2,.8,.25,1);
  min-height: 0;
}
body.panel-open #panel { transform: none; }

.tabs { display: flex; align-items: stretch; border-bottom: 1px solid var(--c-line); }
.tabs button {
  flex: 1; padding: .8rem 0; cursor: pointer;
  background: none; border: none; border-bottom: 2px solid transparent;
  font-family: var(--font-mono); font-size: .7rem; font-weight: 500;
  letter-spacing: .16em; text-transform: uppercase; color: var(--c-dim);
}
.tabs button.on { color: var(--c-amber); border-bottom-color: var(--c-amber); }
.tabs #panelClose {
  flex: none; width: 2.6rem; letter-spacing: 0; font-size: .85rem;
}
.tabs #panelClose:hover { color: var(--c-ink); }

.tab { display: none; overflow-y: auto; padding: 1.1rem; flex: 1; min-height: 0; }
.tab.on { display: block; }

.group { margin-bottom: 1.6rem; }
.group > h3 {
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; user-select: none;
  font-family: var(--font-mono);
  font-size: .62rem; font-weight: 500; letter-spacing: .18em; text-transform: uppercase;
  color: var(--c-dim); margin-bottom: .6rem;
}
.group > h3:hover { color: var(--c-ink); }
.group > h3 i { font-style: normal; font-size: .6rem; transition: transform .18s ease; }
.group.closed > h3 i { transform: rotate(-90deg); }
.group.closed > :not(h3) { display: none; }
.group.closed { margin-bottom: 1rem; }
.group .hint { font-size: .72rem; color: var(--c-dim); margin: -.35rem 0 .6rem; line-height: 1.4; }

/* chips (template / palette / preloader pickers) */

.chips { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .5rem; }
.chip {
  display: flex; flex-direction: column; align-items: center; gap: .3rem;
  padding: .6rem .3rem .55rem; cursor: pointer;
  background: var(--c-bg); color: var(--c-ink);
  border: 1px solid var(--c-line); border-radius: 9px;
  font-family: var(--font-ui);
  transition: border-color .15s, box-shadow .15s;
}
.chip:hover { border-color: var(--c-dim); }
.chip.on { border-color: var(--c-amber); box-shadow: 0 0 0 1px var(--c-amber); }
.chip b { font-size: .74rem; font-weight: 600; }
.chip small { font-size: .6rem; color: var(--c-dim); text-align: center; line-height: 1.25; }

/* live mini-preview: a real render, scaled way down */
.tpl-live {
  display: block; width: 100%; height: 58px;
  border-radius: 5px; overflow: hidden; position: relative;
  border: 1px solid rgba(255,255,255,.06);
  pointer-events: none;
}
.tpl-live .stage.mini {
  display: block; width: 1100px; min-height: 900px;
  transform: scale(.082); transform-origin: top left;
}
.h-card .tpl-live { height: 62px; }

/* generic template mini-preview, drawn from the template's thumb spec
   (--tb ground, --ti ink, --ta accent) + a layout archetype */
.tpl-thumb {
  position: relative; width: 100%; height: 46px; border-radius: 5px; overflow: hidden;
  display: block; background: var(--tb); border: 1px solid rgba(255,255,255,.06);
}
.tpl-thumb i { position: absolute; display: block; }
/* serif: editorial headline + rule + column */
.tpl-thumb[data-layout="serif"] i:nth-child(1) { left: 8%; top: 22%; width: 42%; height: 22%; background: var(--ti); border-radius: 2px 6px 2px 6px; }
.tpl-thumb[data-layout="serif"] i:nth-child(2) { left: 8%; top: 56%; width: 26%; height: 9%; background: var(--ta); }
.tpl-thumb[data-layout="serif"] i:nth-child(3) { right: 8%; top: 18%; width: 22%; height: 64%; background: color-mix(in srgb, var(--ti) 34%, var(--tb)); }
.tpl-thumb[data-layout="serif"] i:nth-child(4) { left: 8%; bottom: 14%; width: 50%; height: 4%; background: color-mix(in srgb, var(--ti) 40%, var(--tb)); }
/* caps: huge stacked display lines */
.tpl-thumb[data-layout="caps"] i:nth-child(1) { left: 8%; top: 18%; width: 66%; height: 18%; background: var(--ti); }
.tpl-thumb[data-layout="caps"] i:nth-child(2) { left: 16%; top: 42%; width: 48%; height: 18%; border: 1.5px solid var(--ti); }
.tpl-thumb[data-layout="caps"] i:nth-child(3) { left: 8%; bottom: 12%; width: 30%; height: 8%; background: var(--ta); }
.tpl-thumb[data-layout="caps"] i:nth-child(4) { display: none; }
/* mono: wall label + one hung object */
.tpl-thumb[data-layout="mono"] i:nth-child(1) { left: 10%; top: 16%; width: 18%; height: 5%; background: var(--ti); }
.tpl-thumb[data-layout="mono"] i:nth-child(2) { left: 10%; top: 26%; width: 12%; height: 4%; background: color-mix(in srgb, var(--ti) 45%, var(--tb)); }
.tpl-thumb[data-layout="mono"] i:nth-child(3) { right: 14%; top: 26%; width: 26%; height: 48%; background: color-mix(in srgb, var(--ti) 30%, var(--tb)); }
.tpl-thumb[data-layout="mono"] i:nth-child(4) { right: 14%; bottom: 12%; width: 10%; height: 4%; background: var(--ta); }
/* grid: contact-sheet cells */
.tpl-thumb[data-layout="grid"] i { width: 18%; height: 30%; background: color-mix(in srgb, var(--ti) 30%, var(--tb)); }
.tpl-thumb[data-layout="grid"] i:nth-child(1) { left: 8%; top: 14%; }
.tpl-thumb[data-layout="grid"] i:nth-child(2) { left: 32%; top: 14%; background: var(--ta); }
.tpl-thumb[data-layout="grid"] i:nth-child(3) { left: 56%; top: 14%; }
.tpl-thumb[data-layout="grid"] i:nth-child(4) { left: 8%; top: 54%; width: 66%; height: 8%; background: var(--ti); }
/* frame: thick accent border console */
.tpl-thumb[data-layout="frame"] { border: 2.5px solid var(--ta); }
.tpl-thumb[data-layout="frame"] i:nth-child(1) { left: 10%; bottom: 18%; width: 58%; height: 20%; background: var(--ta); }
.tpl-thumb[data-layout="frame"] i:nth-child(2) { left: 10%; top: 18%; width: 40%; height: 12%; background: var(--ti); }
.tpl-thumb[data-layout="frame"] i:nth-child(3) { right: 10%; top: 18%; width: 12%; height: 12%; background: color-mix(in srgb, var(--ti) 40%, var(--tb)); }
.tpl-thumb[data-layout="frame"] i:nth-child(4) { display: none; }
/* columns: centered playbill hierarchy */
.tpl-thumb[data-layout="columns"] i { left: 50%; transform: translateX(-50%); }
.tpl-thumb[data-layout="columns"] i:nth-child(1) { top: 14%; width: 20%; height: 5%; background: var(--ta); }
.tpl-thumb[data-layout="columns"] i:nth-child(2) { top: 26%; width: 56%; height: 20%; background: var(--ti); }
.tpl-thumb[data-layout="columns"] i:nth-child(3) { top: 54%; width: 38%; height: 8%; background: color-mix(in srgb, var(--ti) 50%, var(--tb)); }
.tpl-thumb[data-layout="columns"] i:nth-child(4) { top: 70%; width: 46%; height: 5%; background: color-mix(in srgb, var(--ti) 35%, var(--tb)); }

/* palette swatch grid — no names, the colours are the label */
.pal-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: .35rem; }
.pal {
  position: relative; height: 30px; cursor: pointer;
  border-radius: 6px; border: 1px solid rgba(255,255,255,.12);
  background: var(--bg, #222);
  transition: transform .12s ease;
}
.pal:hover { transform: translateY(-1px); border-color: rgba(255,255,255,.3); }
.pal .pi { position: absolute; left: 5px; bottom: 5px; width: 11px; height: 3px; border-radius: 2px; background: var(--ink, #eee); }
.pal .pa { position: absolute; right: 5px; top: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent, #f90); }
.pal.on { outline: 2px solid var(--c-amber); outline-offset: 1px; }

.pl-icon { font-size: 1rem; letter-spacing: .1em; height: 30px; display: flex; align-items: center; color: var(--c-amber); }

/* character segmented controls */
.seg-row { display: flex; align-items: center; gap: .6rem; margin-bottom: .5rem; }
.seg-label {
  flex: none; width: 74px;
  font-family: var(--font-mono); font-size: .56rem;
  letter-spacing: .12em; text-transform: uppercase; color: var(--c-dim);
}
.seg { flex: 1; display: flex; border: 1px solid var(--c-line); border-radius: 7px; overflow: hidden; }
.seg button {
  flex: 1; padding: .34rem 0; cursor: pointer;
  background: none; border: none; border-right: 1px solid var(--c-line);
  font-family: var(--font-ui); font-size: .66rem; font-weight: 600; color: var(--c-dim);
}
.seg button:last-child { border-right: none; }
.seg button.on { background: var(--c-line); color: var(--c-ink); }
.seg button:hover:not(.on) { color: var(--c-ink); }

/* custom palette wells */
.wells { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin-top: .7rem; }
.wells.on .well { border-color: var(--c-amber); }
.well {
  display: flex; flex-direction: column; align-items: center; gap: .3rem;
  padding: .5rem .3rem; border: 1px solid var(--c-line); border-radius: 9px;
  background: var(--c-bg); cursor: pointer;
}
.well input[type="color"] {
  width: 30px; height: 30px; padding: 0; border: none; border-radius: 50%;
  background: none; cursor: pointer;
}
.well input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.well input[type="color"]::-webkit-color-swatch { border: 1px solid rgba(255,255,255,.2); border-radius: 50%; }
.well span { font-family: var(--font-mono); font-size: .56rem; letter-spacing: .12em; text-transform: uppercase; color: var(--c-dim); }

/* logo dropzone */

.dropzone {
  position: relative; display: flex; align-items: center; justify-content: center;
  min-height: 92px; border: 1.5px dashed var(--c-line); border-radius: 10px;
  cursor: pointer; text-align: center; font-size: .78rem; color: var(--c-dim);
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--c-amber); background: rgba(226,166,61,.05); }
.dropzone small { font-size: .68rem; }
.dropzone img { max-height: 64px; max-width: 70%; object-fit: contain; }
.dropzone .rm {
  position: absolute; top: 6px; right: 6px;
  width: 22px; height: 22px; border-radius: 50%;
  border: none; cursor: pointer; font-size: .7rem;
  background: var(--c-line); color: var(--c-ink);
}
.dropzone .rm:hover { background: #a33; }

/* content fields */

.field { display: block; margin-bottom: .75rem; }
.field span {
  display: block; font-size: .66rem; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--c-dim); margin-bottom: .3rem;
}
.field input, .field textarea, .stat-row input {
  width: 100%; padding: .5rem .6rem;
  background: var(--c-bg); color: var(--c-ink);
  border: 1px solid var(--c-line); border-radius: 7px;
  font-family: var(--font-ui); font-size: .82rem; line-height: 1.45;
  resize: vertical;
}
.field input:focus, .field textarea:focus, .stat-row input:focus {
  outline: none; border-color: var(--c-amber);
}

/* design shuffle bar */
.shuffle-bar { display: flex; gap: .45rem; margin-bottom: 1.3rem; }
.shuffle-btn { flex: 1; font-size: .82rem; }
.shuffle-bar .btn:disabled { opacity: .35; cursor: default; }
.shuffle-bar .btn:disabled:hover { border-color: var(--c-line); }

/* custom sections editor */
.field-rename input {
  width: 100%; padding: .2rem 0; margin-bottom: .3rem;
  background: none; border: none; border-bottom: 1px dashed transparent;
  font-family: var(--font-mono); font-size: .66rem; font-weight: 500;
  letter-spacing: .12em; text-transform: uppercase; color: var(--c-dim);
}
.field-rename input:hover { border-bottom-color: var(--c-line); }
.field-rename input:focus { outline: none; border-bottom-color: var(--c-amber); color: var(--c-ink); }
.sec-card {
  margin-bottom: .7rem; padding: .6rem;
  border: 1px solid var(--c-line); border-radius: 9px; background: var(--c-bg);
}
.sec-card textarea {
  width: 100%; margin-top: .5rem; padding: .5rem .6rem; resize: vertical;
  background: var(--c-panel); color: var(--c-ink);
  border: 1px solid var(--c-line); border-radius: 7px;
  font-family: var(--font-ui); font-size: .8rem; line-height: 1.5;
}
.sec-card textarea:focus { outline: none; border-color: var(--c-amber); }
.sec-bar { display: flex; align-items: center; gap: .4rem; }
.sec-kind {
  flex: none; padding: .18rem .45rem; border-radius: 5px;
  background: var(--c-line);
  font-family: var(--font-mono); font-size: .56rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--c-dim);
}
.sec-title {
  flex: 1; min-width: 0; padding: .35rem .5rem;
  background: none; border: none; border-bottom: 1px solid transparent;
  color: var(--c-ink); font-family: var(--font-ui); font-size: .84rem; font-weight: 600;
}
.sec-title:focus { outline: none; border-bottom-color: var(--c-amber); }
.sec-btn {
  flex: none; width: 24px; height: 26px; cursor: pointer;
  border: 1px solid var(--c-line); border-radius: 5px;
  background: none; color: var(--c-dim); font-size: .68rem;
}
.sec-btn:hover:not(:disabled) { border-color: var(--c-dim); color: var(--c-ink); }
.sec-btn:disabled { opacity: .3; cursor: default; }
.sec-add { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; margin-top: .3rem; }
.sec-add > span {
  font-family: var(--font-mono); font-size: .58rem;
  letter-spacing: .12em; text-transform: uppercase; color: var(--c-dim);
  margin-right: .2rem;
}

/* fast bio rotator */
.bio-rotator { display: flex; align-items: center; gap: .5rem; margin: .1rem 0 .5rem; }
.bio-next { font-size: .78rem; }
.bio-counter {
  margin-left: auto;
  font-family: var(--font-mono); font-size: .6rem;
  letter-spacing: .1em; text-transform: uppercase; color: var(--c-dim);
}

/* curated lists */
.cur-list { display: flex; flex-direction: column; gap: .3rem; max-height: 300px; overflow-y: auto; padding-right: 2px; }
.cur-row { display: flex; gap: .35rem; align-items: center; }
.cur-row input { flex: 1; min-width: 0; padding: .38rem .55rem; background: var(--c-bg); color: var(--c-ink);
  border: 1px solid var(--c-line); border-radius: 6px; font-family: var(--font-ui); font-size: .78rem; }
.cur-row.off input { opacity: .38; text-decoration: line-through; }
.cur-pin, .cur-hide {
  flex: none; width: 26px; height: 28px; cursor: pointer;
  border: 1px solid var(--c-line); border-radius: 6px;
  background: none; color: var(--c-dim); font-size: .72rem;
}
.cur-pin:hover, .cur-hide:hover { border-color: var(--c-dim); }
.cur-row.pinned .cur-pin { color: var(--c-amber); border-color: var(--c-amber); }
.cur-add { display: flex; gap: .35rem; margin-top: .4rem; }
.cur-add input { flex: 1; min-width: 0; padding: .38rem .55rem; background: var(--c-bg); color: var(--c-ink);
  border: 1px dashed var(--c-line); border-radius: 6px; font-family: var(--font-ui); font-size: .78rem; }
.cur-add input:focus { outline: none; border-color: var(--c-amber); border-style: solid; }

/* image tray */
.tray-bar { margin-bottom: .5rem; font-family: var(--font-mono); font-size: .58rem;
  letter-spacing: .12em; text-transform: uppercase; color: var(--c-dim); }
.tray { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; max-height: 340px; overflow-y: auto; padding-right: 2px; }
.tray-cell { position: relative; aspect-ratio: 3/4; border-radius: 6px; overflow: hidden; background: var(--c-bg); }
.tray-cell img { width: 100%; height: 100%; object-fit: cover; display: block; transition: opacity .15s, filter .15s; }
.tray-cell.off img { opacity: .22; filter: grayscale(1); }
.tray-cell.feat { outline: 2px solid var(--c-amber); outline-offset: -2px; }
.tray-tags { position: absolute; top: 4px; left: 4px; display: flex; gap: 3px; }
.tray-tags b { padding: 2px 4px; border-radius: 3px; background: var(--c-amber); color: var(--c-amber-ink);
  font: 700 7px var(--font-mono); letter-spacing: .08em; }
.tray-tags b.tf { background: rgba(10,9,8,.8); color: var(--c-amber); border: 1px solid var(--c-amber); }
.tray-section {
  display: flex; align-items: center; justify-content: space-between;
  margin: .8rem 0 .4rem; font-family: var(--font-mono); font-size: .56rem;
  letter-spacing: .16em; text-transform: uppercase; color: var(--c-dim);
}
.tray-big { grid-template-columns: repeat(2, 1fr); }
.tray-big .tray-cell { aspect-ratio: 4/3; }
.tray-cell.tc-first { outline: 2px solid var(--c-amber); outline-offset: -2px; }
.tray-cell.tc-second { outline: 1px solid color-mix(in srgb, var(--c-amber) 55%, transparent); outline-offset: -1px; }
.tray-empty { grid-column: 1 / -1; padding: .6rem; border: 1px dashed var(--c-line); border-radius: 6px;
  font-size: .68rem; color: var(--c-dim); text-align: center; }
.tray-shuffle {
  cursor: pointer; padding: .2rem .5rem; border: 1px solid var(--c-line); border-radius: 999px;
  background: none; color: var(--c-amber);
  font: 500 .56rem var(--font-mono); letter-spacing: .1em; text-transform: uppercase;
}
.tray-shuffle:hover { border-color: var(--c-amber); }
.tray-acts {
  position: absolute; inset: auto 0 0; display: flex;
  background: rgba(10,9,8,.78); opacity: 0; transition: opacity .15s;
}
.tray-cell:hover .tray-acts, .tray-cell:focus-within .tray-acts { opacity: 1; }
.tray-acts button {
  flex: 1; padding: .35rem 0; cursor: pointer; border: none; background: none;
  color: #eee; font-size: .72rem;
}
.tray-acts button:hover { color: var(--c-amber); }

.stat-row { display: flex; gap: .4rem; margin-bottom: .4rem; }
.stat-row .v { width: 74px; flex: none; }
.stat-row .rm {
  flex: none; width: 30px; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--c-line); background: none; color: var(--c-dim);
}
.stat-row .rm:hover { color: #e66; border-color: #a33; }
.stats-ed > .btn { margin-top: .2rem; }

/* ————— preview side ————— */

#previewWrap {
  position: relative; flex: 1; display: flex; flex-direction: column; min-width: 0;
}

.pv-toolbar {
  display: flex; align-items: center; gap: 1rem;
  height: 42px; padding: 0 1rem;
  border-bottom: 1px solid var(--c-line);
  font-size: .72rem; color: var(--c-dim);
}
.pv-label { display: flex; align-items: center; gap: .45em; letter-spacing: .1em; text-transform: uppercase; font-weight: 600; }
.pv-label .dot { width: 7px; height: 7px; border-radius: 50%; background: #4cd964; animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.pv-size { display: flex; margin-left: auto; border: 1px solid var(--c-line); border-radius: 7px; overflow: hidden; }
.pv-size button {
  padding: .3rem .7rem; font-size: .7rem; font-weight: 600; cursor: pointer;
  background: none; border: none; color: var(--c-dim); font-family: var(--font-ui);
}
.pv-size button.on { background: var(--c-line); color: var(--c-ink); }

/* the preview floats as a framed sheet inside a neutral canvas */
#stageScroll { flex: 1; overflow-y: auto; min-height: 0; padding: 1.5rem; background: #0c0b0a; }
#stageScroll .stage {
  max-width: 1180px; margin: 0 auto; min-height: calc(100vh - 190px);
  border-radius: 10px; overflow: hidden;
  box-shadow: 0 1px 0 rgba(255,255,255,.06) inset, 0 14px 50px rgba(0,0,0,.55);
}
#stageScroll.mob { padding: 1.2rem 0; }
#stageScroll.mob .stage {
  max-width: 390px; min-height: calc(100vh - 140px);
  border-radius: 18px; box-shadow: 0 12px 50px rgba(0,0,0,.6);
}

/* fullscreen preview */

body.full #topbar, body.full #panel, body.full .pv-toolbar { display: none; }
body.full #stageScroll { padding: 0; background: none; }
body.full #stageScroll .stage { max-width: none; min-height: 100vh; border-radius: 0; box-shadow: none; }
/* showcase + mobile: keep the phone frame, floating on the dark canvas */
body.full #stageScroll.mob { padding: 4.4rem 0 1.2rem; background: #0c0b0a; }
body.full #stageScroll.mob .stage {
  max-width: 390px; min-height: calc(100vh - 5.6rem);
  border-radius: 18px; box-shadow: 0 12px 50px rgba(0,0,0,.6);
}
/* showcase pills: the whole first-visit UI */
#showBar {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 60;
  display: flex; gap: .5rem; padding: .4rem;
  background: rgba(14,15,18,.72); border: 1px solid rgba(255,255,255,.16);
  border-radius: 999px; backdrop-filter: blur(10px);
  box-shadow: 0 8px 30px rgba(0,0,0,.4);
  animation: homeRise .6s cubic-bezier(.2,.7,.2,1) .3s both;
}
#showBar[hidden] { display: none; }
#showBar .btn { border-radius: 999px; }
#showBar .btn.ghost { border-color: rgba(255,255,255,.22); color: #fff; }
#showBar .btn.mob-on { background: rgba(255,255,255,.16); }

/* the artist switcher — the home page's primary control */
#demoBar {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 60;
  display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; justify-content: center;
  max-width: min(92vw, 900px); padding: .45rem .7rem;
  background: rgba(14,15,18,.78); border: 1px solid rgba(255,255,255,.16);
  border-radius: 999px; backdrop-filter: blur(10px);
  box-shadow: 0 8px 30px rgba(0,0,0,.4);
  animation: homeRise .6s cubic-bezier(.2,.7,.2,1) .45s both;
}
#demoBar[hidden] { display: none; }
#demoBar .db-label {
  font-family: var(--font-mono); font-size: .58rem;
  letter-spacing: .16em; text-transform: uppercase; color: rgba(255,255,255,.55);
  margin-right: .25rem;
}
#demoBar button {
  padding: .32rem .75rem; cursor: pointer;
  background: none; border: 1px solid rgba(255,255,255,.2); border-radius: 999px;
  font-family: var(--font-ui); font-size: .76rem; color: #fff;
  transition: border-color .15s, background .15s;
}
#demoBar button:hover { border-color: var(--c-amber); }
#demoBar button.on { border-color: var(--c-amber); background: rgba(240,83,46,.18); }
#demoBar .db-back {
  background: var(--c-amber); border-color: var(--c-amber);
  color: var(--c-amber-ink); font-weight: 600;
}

/* welcome intro — the site's own cinematic intro, played once ever */
#welcomeIntro {
  position: fixed; inset: 0; z-index: 70;
  display: grid; place-items: center;
  background:
    radial-gradient(70rem 42rem at 80% -10%, rgba(240,83,46,.12), transparent 60%),
    rgba(14,15,18,.94);
  backdrop-filter: blur(8px);
  transition: opacity .6s ease, transform .65s cubic-bezier(.7, 0, .3, 1);
}
#welcomeIntro[hidden] { display: none; }
#welcomeIntro.lift { opacity: 0; transform: translateY(-4%); pointer-events: none; }
.wi-card { max-width: min(92vw, 470px); text-align: center; color: #fff; padding: 1rem; }
.wi-card .mark { width: 40px; height: 40px; animation: plateRise .6s cubic-bezier(.2,.7,.2,1) .1s both; }
.wi-card h2 {
  margin-top: 1.1rem;
  font-family: var(--font-brand); font-weight: 400; font-size: 2.2rem;
  animation: plateRise .6s cubic-bezier(.2,.7,.2,1) .22s both;
}
.wi-lede {
  margin-top: .7rem; font-size: .95rem; line-height: 1.6; color: rgba(255,255,255,.78);
  animation: plateRise .6s cubic-bezier(.2,.7,.2,1) .34s both;
}
.wi-hints {
  list-style: none; margin: 1.4rem auto 0; padding: 0;
  display: grid; gap: .55rem; text-align: left; width: fit-content;
  animation: plateRise .6s cubic-bezier(.2,.7,.2,1) .46s both;
}
/* was a fixed-width icon column; now these are words and must flow inline */
.wi-hints li { display: block; font-size: .85rem; line-height: 1.45; color: rgba(255,255,255,.85); }
.wi-hints li::before { content: '— '; color: rgba(255,255,255,.35); }
.wi-hints b { color: var(--c-amber); font-weight: 600; white-space: nowrap; }
#wiGo { margin-top: 1.6rem; animation: plateRise .6s cubic-bezier(.2,.7,.2,1) .58s both; }
.wi-fine {
  margin-top: 1rem;
  font-family: var(--font-mono); font-size: .58rem;
  letter-spacing: .16em; text-transform: uppercase; color: rgba(255,255,255,.45);
  animation: plateRise .6s cubic-bezier(.2,.7,.2,1) .7s both;
}
@media (prefers-reduced-motion: reduce) {
  #welcomeIntro, .wi-card * { animation: none !important; transition: opacity .2s ease; }
}
/* centred floating bars animate with their translateX preserved */
@keyframes barRise { from { opacity: 0; transform: translate(-50%, 14px); } to { opacity: 1; transform: translateX(-50%); } }
#demoBar, #showBar { animation-name: barRise; }
#welcomePlate { animation-name: plateRise; }
@keyframes plateRise { from { opacity: 0; transform: translateY(14px); } }

/* publish: the one money-action, in go-green */
#showPublish {
  /* was top-right, where it struck through template taglines */
  position: fixed; bottom: 20px; right: 20px; z-index: 61;
  padding: .62rem 1.25rem; border: none; border-radius: 999px; cursor: pointer;
  background: #2fbf71; color: #06130b;
  font-family: var(--font-ui); font-size: .88rem; font-weight: 700;
  box-shadow: 0 6px 24px rgba(47,191,113,.35);
  animation: homeRise .6s cubic-bezier(.2,.7,.2,1) .45s both;
  transition: filter .15s, transform .15s;
}
#showPublish:hover { filter: brightness(1.08); transform: translateY(-1px); }
#showPublish[hidden] { display: none; }

#pubSheet {
  position: fixed; inset: 0; z-index: 80;
  display: grid; place-items: center;
  background: rgba(8,9,11,.6); backdrop-filter: blur(6px);
}
#pubSheet[hidden] { display: none; }
.pub-card {
  width: min(460px, calc(100% - 2rem));
  padding: 2rem 2.1rem 1.8rem;
  background: var(--c-panel); border: 1px solid var(--c-line); border-radius: 16px;
  box-shadow: 0 24px 80px rgba(0,0,0,.5);
}
.pub-card .mark { width: 30px; height: 30px; margin-bottom: 1rem; }
.pub-card h3 { font-family: var(--font-brand); font-weight: 400; font-size: 1.5rem; margin-bottom: .7rem; }
.pub-card p { font-size: .88rem; line-height: 1.6; color: #aab0ba; }
.pub-card p b { color: var(--c-ink); }
.pub-card .pub-now { margin-top: .8rem; }
.pub-actions { display: flex; gap: .6rem; margin-top: 1.3rem; }

/* ————— preloader overlays ————— */

.pl {
  position: absolute; inset: 0; z-index: 40;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.2rem;
  background: var(--bg, #111); color: var(--ink, #eee);
  transition: opacity .5s ease, transform .6s cubic-bezier(.7, 0, .3, 1);
  overflow: hidden;           /* nothing ever escapes into the editor chrome */
  container-type: size;       /* children size against the frame, not the viewport */
  padding: 1rem;
}
.pl p { font-family: var(--font-brand); font-size: clamp(.95rem, 5cqmin, 1.35rem); opacity: .9; text-align: center; text-wrap: balance; }
.pl p.mono { font-family: var(--font-mono); font-size: clamp(.55rem, 2.6cqmin, .7rem); letter-spacing: .22em; text-transform: uppercase; }
.pl.out { opacity: 0; pointer-events: none; }
.pl-page.out { opacity: 1; transform: translateY(-101%); }

@media (prefers-reduced-motion: reduce) {
  .pl, .pl * { animation: none !important; }
  .pl { transition: opacity .2s ease; }
  .pl-page.out { transform: none; }
}

/* signal bars — audio bars resolve into the wordmark */
.pl .pl-bars { display: flex; align-items: flex-end; gap: 6px; height: 44px; }
.pl .pl-bars i { width: 8px; background: var(--accent, #f90); animation: eq 0.9s ease-in-out infinite; }
.pl .pl-bars i:nth-child(1) { animation-delay: 0s; }
.pl .pl-bars i:nth-child(2) { animation-delay: .15s; }
.pl .pl-bars i:nth-child(3) { animation-delay: .3s; }
.pl .pl-bars i:nth-child(4) { animation-delay: .45s; }
.pl .pl-bars i:nth-child(5) { animation-delay: .6s; }
@keyframes eq { 0%, 100% { height: 22%; } 50% { height: 100%; } }

/* needle drop — spindle spins while the progress groove completes */
.pl .pl-disc {
  width: clamp(52px, 22cqmin, 84px); height: clamp(52px, 22cqmin, 84px); border-radius: 50%;
  background: repeating-radial-gradient(circle, var(--ink, #eee) 0 1px, transparent 1px 5px),
              radial-gradient(circle, transparent 55%, color-mix(in srgb, var(--ink, #eee) 18%, transparent) 56%);
  border: 2px solid var(--ink, #eee);
  display: flex; align-items: center; justify-content: center;
  animation: spin 1.2s linear infinite;
}
.pl .pl-disc span { width: 32%; height: 32%; border-radius: 50%; background: var(--accent, #f90); }
@keyframes spin { to { transform: rotate(360deg); } }
.pl .pl-groove { width: clamp(110px, 42cqmin, 170px); height: 2px; background: color-mix(in srgb, var(--ink, #eee) 30%, transparent); }
.pl .pl-groove i { display: block; height: 100%; background: var(--accent, #f90); animation: groove 1.35s linear both; }
@keyframes groove { from { width: 0; } to { width: 100%; } }

/* page turn — a sheet turns away to reveal the name */
.pl .pl-sheet {
  position: absolute; inset: 12% 18%;
  background: var(--surface, #333);
  border: 1px solid color-mix(in srgb, var(--ink, #eee) 25%, transparent);
  transform-origin: left center;
  animation: pageTurn 1.15s cubic-bezier(.6, 0, .3, 1) .25s both;
}
@keyframes pageTurn { to { transform: perspective(900px) rotateY(-88deg); opacity: .1; } }
.pl .pl-name {
  font-family: var(--font-brand);
  font-size: clamp(1.6rem, 5vw, 3.2rem);
  animation: riseIn .9s cubic-bezier(.2, .7, .2, 1) both;
}
@keyframes riseIn { from { opacity: 0; transform: translateY(26px); } }

/* aperture — an iris ring widens around the name */
.pl .pl-iris {
  position: absolute; left: 50%; top: 50%;
  width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid var(--accent, #f90);
  transform: translate(-50%, -50%);
  animation: iris 1.3s cubic-bezier(.5, 0, .2, 1) both;
}
@keyframes iris {
  0% { width: 8cqmin; height: 8cqmin; opacity: 1; border-width: 16px; }
  100% { width: 160cqmax; height: 160cqmax; opacity: 0; border-width: 2px; }
}

/* film leader — 3·2·1 with a sweeping second hand */
.pl .pl-leader {
  position: relative;
  width: clamp(84px, 34cqmin, 130px); height: clamp(84px, 34cqmin, 130px); border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--ink, #eee) 45%, transparent);
  display: grid; place-items: center;
}
.pl .pl-leader::before, .pl .pl-leader::after {
  content: ''; position: absolute; background: color-mix(in srgb, var(--ink, #eee) 30%, transparent);
}
.pl .pl-leader::before { width: 100%; height: 1px; }
.pl .pl-leader::after { width: 1px; height: 100%; }
.pl .pl-leader i {
  position: absolute; inset: 0; border-radius: 50%; z-index: 1;
  background: conic-gradient(color-mix(in srgb, var(--accent, #f90) 30%, transparent) 0deg, transparent 0);
  animation: sweep 1.35s linear both;
}
@keyframes sweep {
  from { background: conic-gradient(color-mix(in srgb, var(--accent, #f90) 30%, transparent) 0deg, transparent 0); }
  to { background: conic-gradient(color-mix(in srgb, var(--accent, #f90) 30%, transparent) 360deg, transparent 0); }
}
.pl .pl-leader span {
  position: absolute; z-index: 2;
  font: 700 clamp(1.8rem, 12cqmin, 3rem) var(--font-ui); opacity: 0;
}
.pl .pl-leader span:nth-of-type(1) { animation: tick .45s steps(1) 0s both; }
.pl .pl-leader span:nth-of-type(2) { animation: tick .45s steps(1) .45s both; }
.pl .pl-leader span:nth-of-type(3) { animation: tick .45s steps(1) .9s both; }
@keyframes tick { 0% { opacity: 1; } 100% { opacity: 0; } }

/* arrival banner */
#arrivalBar {
  display: flex; align-items: center; gap: .8rem;
  padding: .55rem 1rem;
  background: color-mix(in srgb, var(--c-amber) 14%, var(--c-panel));
  border-bottom: 1px solid var(--c-amber);
  font-size: .78rem;
}
#arrivalBar span { flex: 1; }

/* curtain — two panels part around the name */
.pl-curtain::before, .pl-curtain::after {
  content: ''; position: absolute; top: 0; bottom: 0; width: 51%; z-index: 1;
  background: var(--surface, #333);
  border-right: 1px solid color-mix(in srgb, var(--ink, #eee) 20%, transparent);
}
.pl-curtain::before { left: 0; animation: curtL 1s cubic-bezier(.7, 0, .3, 1) .3s both; }
.pl-curtain::after { right: 0; border-right: none; border-left: 1px solid color-mix(in srgb, var(--ink, #eee) 20%, transparent); animation: curtR 1s cubic-bezier(.7, 0, .3, 1) .3s both; }
@keyframes curtL { to { transform: translateX(-101%); } }
@keyframes curtR { to { transform: translateX(101%); } }

/* develop — contact frames expose in sequence */
.pl .pl-frames { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.pl .pl-frames i {
  width: clamp(34px, 12cqmin, 52px); aspect-ratio: 3/4;
  background: var(--surface, #333);
  border: 1px solid color-mix(in srgb, var(--ink, #eee) 30%, transparent);
  opacity: 0; animation: expose .4s ease-out forwards;
}
.pl .pl-frames i:nth-child(1) { animation-delay: .1s; }
.pl .pl-frames i:nth-child(2) { animation-delay: .32s; }
.pl .pl-frames i:nth-child(3) { animation-delay: .54s; background: var(--accent, #f90); }
.pl .pl-frames i:nth-child(4) { animation-delay: .76s; }
@keyframes expose { from { opacity: 0; filter: brightness(3); } to { opacity: 1; filter: none; } }

/* stamp — the name lands like a rubber stamp */
.pl .pl-stampname {
  animation: stampIn .5s cubic-bezier(.2, 1.4, .4, 1) .25s both;
  border: 3px solid var(--accent, #f90); padding: .35em .7em; rotate: -2deg;
}
@keyframes stampIn { from { opacity: 0; transform: scale(2.4) rotate(4deg); } to { opacity: 1; transform: none; } }

/* spines — book spines shelve themselves */
.pl .pl-spines { display: flex; align-items: flex-end; gap: 5px; height: clamp(48px, 20cqmin, 72px); }
.pl .pl-spines i { width: clamp(9px, 3.4cqmin, 13px); background: var(--ink, #eee); animation: shelf .5s cubic-bezier(.2, .8, .3, 1) both; }
.pl .pl-spines i:nth-child(1) { height: 82%; animation-delay: .05s; }
.pl .pl-spines i:nth-child(2) { height: 100%; animation-delay: .17s; }
.pl .pl-spines i:nth-child(3) { height: 70%; animation-delay: .29s; background: var(--accent, #f90); }
.pl .pl-spines i:nth-child(4) { height: 92%; animation-delay: .41s; }
.pl .pl-spines i:nth-child(5) { height: 64%; animation-delay: .53s; }
@keyframes shelf { from { transform: translateY(110%); } }

/* flash — a photo flash, then the name */
.pl-flash::before { content: ''; position: absolute; inset: 0; background: var(--ink, #eee); animation: flashOut .55s ease-out both; pointer-events: none; }
.pl-flash .pl-name { animation-delay: .3s; }
@keyframes flashOut { from { opacity: 1; } to { opacity: 0; } }

/* billing — a title card assembles line by line */
.pl .pl-billing { display: grid; gap: .9rem; justify-items: center; text-align: center; }
.pl .pl-billing small {
  font-family: var(--font-mono); font-size: clamp(.5rem, 2.2cqmin, .62rem);
  letter-spacing: .34em; text-transform: uppercase; color: var(--accent, #f90);
  opacity: 0; animation: billLine .5s ease-out forwards;
}
.pl .pl-billing p {
  font-family: var(--font-brand); font-size: clamp(1.3rem, 6cqmin, 2.4rem);
  opacity: 0; animation: billLine .6s ease-out .3s forwards;
}
.pl .pl-billing small:last-child { animation-delay: .6s; }
@keyframes billLine { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* topbar divider + undo/redo */
.tb-div { width: 1px; height: 1.2rem; background: var(--c-line); margin: 0 .15rem; }
#tbUndo:disabled, #tbRedo:disabled { opacity: .3; cursor: default; }

/* floating item controls [↑ ↓ ✕] */
#itemCtl {
  position: absolute; z-index: 74;   /* inside #stageScroll: scrolls with the page */
  display: flex; gap: .15rem; padding: .2rem;
  background: rgba(14,15,18,.92); border: 1px solid rgba(255,255,255,.16);
  border-radius: 8px; backdrop-filter: blur(8px);
  box-shadow: 0 8px 26px rgba(0,0,0,.45);
  animation: popIn .12s ease-out both;
}
#itemCtl button {
  width: 1.6rem; height: 1.6rem; cursor: pointer;
  display: grid; place-items: center;
  background: none; border: none; border-radius: 5px;
  font-family: var(--font-ui); font-size: .78rem; color: #fff;
}
#itemCtl button:hover { background: var(--c-amber); color: #16110e; }

/* the photo manager overlay */
#imgMgr {
  position: fixed; inset: 0; z-index: 90;
  display: grid; place-items: center;
  background: rgba(10,11,13,.72); backdrop-filter: blur(8px);
  animation: fadeIn .18s ease-out both;
}
@keyframes fadeIn { from { opacity: 0; } }
.im-card {
  width: min(880px, 94vw); max-height: 88vh; overflow-y: auto;
  background: var(--c-panel); border: 1px solid var(--c-line);
  border-radius: 14px; padding: 1.1rem 1.2rem 1.4rem;
  box-shadow: 0 30px 80px rgba(0,0,0,.55);
}
.im-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .9rem; }
.im-head h3 {
  flex: 1; font-family: var(--font-brand); font-size: 1.15rem; font-weight: 560;
  color: var(--c-ink);
}
.im-hint { font-size: .8rem; color: var(--c-dim); margin: -.4rem 0 .8rem; }
.im-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: .6rem;
}
.im-tile {
  position: relative; border-radius: 9px; overflow: hidden;
  background: #0c0d10; border: 1px solid var(--c-line);
}
.im-tile img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.im-tile.pick { cursor: pointer; transition: transform .12s, border-color .12s; }
.im-tile.pick:hover { transform: scale(1.03); border-color: var(--c-amber); }
.im-class {
  position: absolute; top: .35rem; left: .35rem;
  padding: .15rem .45rem; border-radius: 999px;
  background: rgba(14,15,18,.85); color: #fff;
  font-family: var(--font-ui); font-size: .6rem; font-weight: 600; letter-spacing: .04em;
}
.im-class.hero { background: var(--c-amber); color: #16110e; }
.im-class.off { background: rgba(255,255,255,.25); }
/* choose a photo, then act on it in words along the bottom of the panel */
.im-tile.on { border-color: var(--c-amber); box-shadow: 0 0 0 2px var(--c-amber); }
.im-bar {
  position: sticky; bottom: -1.4rem; z-index: 2;
  display: flex; flex-wrap: wrap; align-items: center; gap: .35rem;
  margin: 1rem -1.2rem -1.4rem; padding: .75rem 1.2rem;
  background: color-mix(in srgb, var(--c-panel) 94%, transparent);
  border-top: 1px solid var(--c-line); backdrop-filter: blur(8px);
}
.im-bar > span {
  font-family: var(--font-mono); font-size: .58rem; letter-spacing: .14em;
  text-transform: uppercase; color: var(--c-dim); margin-right: .2rem;
}
.im-bar button {
  padding: .38rem .75rem; cursor: pointer;
  background: none; border: 1px solid var(--c-line); border-radius: 999px;
  font-family: var(--font-ui); font-size: .76rem; color: var(--c-ink);
  transition: border-color .12s, color .12s, background .12s;
}
.im-bar button:hover { border-color: var(--c-amber); color: var(--c-amber); }
.im-bar button:last-child:hover { border-color: #e5484d; color: #e5484d; }
.im-sec {
  margin: 1.2rem 0 .5rem;
  font-family: var(--font-mono); font-size: .64rem; font-weight: 500;
  letter-spacing: .16em; text-transform: uppercase; color: var(--c-dim);
}

/* first-run coach: three sentences, then never again */
#coach {
  position: fixed; right: 1.1rem; bottom: 1.1rem; z-index: 84; width: 290px;
  padding: .95rem 1.05rem 1rem;
  background: rgba(18,19,22,.97); border: 1px solid rgba(255,255,255,.16);
  border-radius: 13px; backdrop-filter: blur(12px);
  box-shadow: 0 18px 50px rgba(0,0,0,.55);
  animation: barRise .3s ease-out both;
}
#coach b { display: block; font-family: var(--font-ui); font-size: .9rem; color: #fff; margin-bottom: .55rem; }
#coach ul { list-style: none; display: flex; flex-direction: column; gap: .45rem; margin-bottom: .8rem; }
#coach li {
  display: flex; gap: .55rem; align-items: flex-start;
  font-family: var(--font-ui); font-size: .78rem; line-height: 1.35; color: #c3c8d0;
}
#coach li i { font-style: normal; width: 1.1rem; flex: none; text-align: center; }
#coach li b { display: inline; color: var(--c-amber); margin: 0; font-size: inherit; }
#coach button {
  width: 100%; padding: .5rem; cursor: pointer;
  background: var(--c-amber); border: none; border-radius: 8px;
  font-family: var(--font-ui); font-size: .82rem; font-weight: 600; color: #16110e;
}

/* the gutter: edit mode always keeps room on the right for the section rails */
#stageScroll { position: relative; }
body:not(.full) #stageScroll { padding-right: 7.2rem; }   /* room for word rails */
body:not(.full) #stageScroll.mob { padding-right: 0; }
/* one way to do each thing: on desktop the rail owns section actions, so the
   on-page chip and the between-sections "+" only appear in the phone preview */
#stageScroll:not(.mob) .stage.inline-editing .sec-ctl,
#stageScroll:not(.mob) .stage.inline-editing .sec-add { display: none; }

/* the halo: touch a rail, see exactly which band of the page it drives */
.sec-halo {
  position: absolute; z-index: 6; pointer-events: none;
  border: 2px solid var(--c-amber); border-radius: 8px;
  box-shadow: 0 0 0 9999px rgba(8,9,11,.34);
  animation: haloIn .14s ease-out both;
}
@keyframes haloIn { from { opacity: 0; } }

/* small "which part?" menu shared by the rails */
.mini-menu {
  position: fixed; z-index: 79; width: 168px;
  display: flex; flex-direction: column; gap: .2rem; padding: .5rem;
  background: rgba(14,15,18,.96); border: 1px solid rgba(255,255,255,.16);
  border-radius: 11px; backdrop-filter: blur(10px);
  box-shadow: 0 14px 44px rgba(0,0,0,.5);
  animation: popIn .14s ease-out both;
}
.mini-menu button {
  display: block; width: 100%; text-align: left; cursor: pointer;
  padding: .4rem .6rem; background: none; border: none; border-radius: 7px;
  font-family: var(--font-ui); font-size: .8rem; color: #fff;
}
.mini-menu button:hover { background: var(--c-amber); color: #16110e; }

/* words, not emoji: every control says what it does */
.gutter-rail {
  position: absolute; left: 0; z-index: 8;   /* left set per-rail: hugs the page */
  display: flex; flex-direction: column; align-items: stretch; gap: 1px;
  width: 88px; padding: .3rem; border-radius: 9px;
  background: rgba(24,26,31,.9); border: 1px solid rgba(255,255,255,.1);
  backdrop-filter: blur(8px);
  opacity: .9; transition: opacity .16s ease, box-shadow .16s ease;
}
.gutter-rail:hover, .gutter-rail:focus-within {
  opacity: 1; box-shadow: 0 8px 26px rgba(0,0,0,.45);
}
.gutter-rail button {
  width: 100%; cursor: pointer; text-align: left;
  padding: .34rem .5rem;
  background: none; border: none; border-radius: 5px;
  font-family: var(--font-ui); font-size: .76rem; line-height: 1.1; color: #d7dae0;
  transition: background .12s, color .12s;
}
.gutter-rail button:hover:not(:disabled) { background: var(--c-amber); color: #16110e; }
.gutter-rail button.danger { color: #f0959a; }
.gutter-rail button.danger:hover { background: #e5484d; color: #fff; }
.gutter-rail button:disabled { opacity: .3; cursor: default; }
.gutter-rail .gr-type {
  font-family: var(--font-mono); font-size: .5rem; font-style: normal;
  letter-spacing: .12em; text-transform: uppercase; color: #7c828d;
  padding: .3rem .5rem .1rem; border-top: 1px solid rgba(255,255,255,.08);
  margin-top: .15rem;
}

/* layout picker + add menu */
#addMenu {
  position: fixed; z-index: 78; width: 186px;
  display: flex; flex-direction: column; gap: .2rem; padding: .5rem;
  background: rgba(14,15,18,.96); border: 1px solid rgba(255,255,255,.16);
  border-radius: 11px; backdrop-filter: blur(10px);
  box-shadow: 0 14px 44px rgba(0,0,0,.5);
  animation: popIn .14s ease-out both;
}
#addMenu button {
  display: block; width: 100%; text-align: left; cursor: pointer;
  padding: .45rem .6rem; background: none; border: none; border-radius: 7px;
}
#addMenu button:hover { background: rgba(255,255,255,.08); }
#addMenu button b { display: block; font-family: var(--font-ui); font-size: .82rem; color: #fff; }
#addMenu button span { display: block; font-family: var(--font-ui); font-size: .7rem; color: #8d939d; }
.sm-head {
  font-family: var(--font-ui); font-size: .74rem; font-weight: 600; color: #fff;
  margin: .1rem .2rem .45rem;
}
.sm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .3rem; }
.sm-ly {
  display: flex; flex-direction: column; align-items: center; gap: .25rem;
  padding: .45rem .3rem; cursor: pointer;
  background: rgba(255,255,255,.04); border: 1.5px solid transparent; border-radius: 8px;
  color: #cfd3da;
}
.sm-ly:hover { background: rgba(255,255,255,.09); }
.sm-ly.on { border-color: var(--c-amber); color: var(--c-amber); }
.sm-ly .ly-thumb { width: 100%; height: 26px; }
.sm-ly span { font-family: var(--font-ui); font-size: .64rem; text-align: center; line-height: 1.2; }

/* section photo strip in the Details drawer (never raw data: URIs) */
.sec-thumbs { display: flex; flex-wrap: wrap; gap: .35rem; margin: .4rem 0 .55rem; }
.sec-thumbs span { position: relative; width: 54px; height: 54px; }
.sec-thumbs img { width: 100%; height: 100%; object-fit: cover; border-radius: 6px; display: block; }
.sec-thumbs button {
  position: absolute; top: -5px; right: -5px; width: 18px; height: 18px; cursor: pointer;
  display: grid; place-items: center;
  background: #e5484d; color: #fff; border: none; border-radius: 50%;
  font-size: .6rem; line-height: 1;
}

/* section menu */
#secMenu {
  position: fixed; z-index: 78; width: 252px;
  display: flex; flex-direction: column; gap: .45rem;
  padding: .6rem;
  background: rgba(14,15,18,.95); border: 1px solid rgba(255,255,255,.16);
  border-radius: 10px; backdrop-filter: blur(10px);
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
  animation: popIn .14s ease-out both;
}
#secMenu .sm-row { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; }
#secMenu .sm-row > span {
  flex-basis: 100%; font-family: var(--font-mono); font-size: .56rem;
  letter-spacing: .16em; text-transform: uppercase; color: #8a8f99;
}
#secMenu button {
  padding: .32rem .6rem; cursor: pointer;
  background: none; border: 1px solid rgba(255,255,255,.18); border-radius: 999px;
  font-family: var(--font-ui); font-size: .72rem; color: #fff;
}
#secMenu button:hover:not(:disabled) { border-color: var(--c-amber); color: var(--c-amber); }
#secMenu button.on { background: var(--c-amber); border-color: var(--c-amber); color: #16110e; }
#secMenu button.danger:hover { border-color: #e5484d; color: #e5484d; }
#secMenu button:disabled { opacity: .35; cursor: default; }

/* manager: paste row, add-selected foot, selected tiles */
.im-paste { display: flex; gap: .5rem; margin-bottom: .9rem; }
.im-paste input {
  flex: 1; padding: .5rem .7rem;
  background: #0c0d10; border: 1px solid var(--c-line); border-radius: 8px;
  font-family: var(--font-ui); font-size: .78rem; color: var(--c-ink);
}
.im-paste input:focus { outline: none; border-color: var(--c-amber); }
.im-foot {
  position: sticky; bottom: -1.4rem; margin: 1rem -1.2rem -1.4rem;
  padding: .8rem 1.2rem; text-align: right;
  background: color-mix(in srgb, var(--c-panel) 92%, transparent);
  border-top: 1px solid var(--c-line); backdrop-filter: blur(8px);
}
.im-foot button:disabled { opacity: .4; cursor: default; }
.im-tile.sel { border-color: var(--c-amber); box-shadow: 0 0 0 2px var(--c-amber); }
.im-tile.sel::after {
  content: '✓'; position: absolute; top: .3rem; right: .3rem;
  width: 1.3rem; height: 1.3rem; display: grid; place-items: center;
  background: var(--c-amber); color: #16110e; border-radius: 50%;
  font-size: .7rem; font-weight: 700;
}

/* undo chip */
#undoChip[hidden] { display: none; }
#undoChip {
  position: fixed; left: 1.1rem; bottom: 1.1rem; z-index: 80;
  display: flex; align-items: center; gap: .7rem;
  padding: .55rem .6rem .55rem 1rem;
  background: rgba(14,15,18,.92); border: 1px solid rgba(255,255,255,.16);
  border-radius: 999px; backdrop-filter: blur(10px);
  box-shadow: 0 10px 34px rgba(0,0,0,.5);
  animation: popIn .16s ease-out both;
  font-family: var(--font-ui); font-size: .78rem; color: #cfd3da;
}
#undoChip button {
  padding: .32rem .8rem; cursor: pointer;
  background: var(--c-amber); border: none; border-radius: 999px;
  font-family: var(--font-ui); font-size: .74rem; font-weight: 600; color: #16110e;
}
#undoChip button:hover { filter: brightness(1.08); }

/* image tap popover */
#imgPop {
  position: absolute; z-index: 75;   /* inside #stageScroll: scrolls with the page */
  display: flex; gap: .3rem; padding: .35rem;
  background: rgba(14,15,18,.92); border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px; backdrop-filter: blur(10px);
  box-shadow: 0 10px 34px rgba(0,0,0,.5);
  animation: popIn .16s ease-out both;
}
@keyframes popIn { from { opacity: 0; transform: scale(.92); } }
#imgPop button {
  padding: .38rem .7rem; cursor: pointer; white-space: nowrap;
  background: none; border: 1px solid transparent; border-radius: 999px;
  font-family: var(--font-ui); font-size: .74rem; color: #fff;
}
#imgPop button:hover { border-color: var(--c-amber); color: var(--c-amber); }

/* mini audio player */
#miniPlayer {
  position: fixed; right: 1.1rem; bottom: 1.1rem; z-index: 82;
  display: flex; align-items: center; gap: .6rem;
  width: min(360px, calc(100vw - 2rem));
  padding: .55rem .6rem;
  background: rgba(14,15,18,.94); border: 1px solid rgba(255,255,255,.16);
  border-radius: 12px; backdrop-filter: blur(12px);
  box-shadow: 0 14px 44px rgba(0,0,0,.55);
  animation: barRise .25s ease-out both;
}
#miniPlayer img { width: 42px; height: 42px; border-radius: 7px; object-fit: cover; flex: none; }
#miniPlayer .mp-meta { flex: 1; min-width: 0; }
#miniPlayer .mp-meta b {
  display: block; font-family: var(--font-ui); font-size: .8rem; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#miniPlayer .mp-meta span {
  display: block; font-family: var(--font-ui); font-size: .68rem; color: #9aa0ab;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#miniPlayer .mp-bar {
  position: absolute; left: .6rem; right: .6rem; bottom: .28rem; height: 2px;
  background: rgba(255,255,255,.14); border-radius: 2px; overflow: hidden;
}
#miniPlayer .mp-bar i { display: block; height: 100%; width: 0; background: var(--c-amber); }
#miniPlayer button {
  flex: none; width: 1.9rem; height: 1.9rem; cursor: pointer;
  display: grid; place-items: center;
  background: none; border: none; border-radius: 6px;
  font-size: .85rem; color: #fff;
}
#miniPlayer button:hover { background: rgba(255,255,255,.12); }
#miniPlayer .mp-alt { color: var(--c-amber); }
#miniPlayer .mp-menu {
  position: absolute; right: 0; bottom: calc(100% + .4rem);
  display: flex; flex-direction: column; gap: .1rem;
  width: 100%; max-height: 200px; overflow-y: auto;
  padding: .3rem;
  background: rgba(14,15,18,.97); border: 1px solid rgba(255,255,255,.16);
  border-radius: 10px;
}
#miniPlayer .mp-menu button {
  width: 100%; height: auto; padding: .4rem .6rem;
  font-size: .72rem; text-align: left; display: block;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* toast */

#toast {
  /* must sit above the publish sheet (80), photo manager (90) and coach (84),
     or "Copied!" silently happens behind them */
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 8px); z-index: 96;
  padding: .6rem 1rem; border-radius: 9px;
  background: var(--c-amber); color: var(--c-amber-ink);
  font-size: .8rem; font-weight: 600;
  opacity: 0; transition: opacity .25s, transform .25s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ————— polish ————— */

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #33383f; border-radius: 999px; border: 2px solid var(--c-bg); }
::-webkit-scrollbar-thumb:hover { background: #454b55; }

.chip { position: relative; overflow: hidden; }
.chip:active { transform: scale(.98); }
.chip.on::after {
  content: ''; position: absolute; top: 6px; right: 6px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--c-amber);
}

button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--c-amber); outline-offset: 2px;
}

#stage { transition: background .35s ease; }
.tab { scrollbar-gutter: stable; }

/* ————— home: the front door ————— */

#home {
  position: fixed; inset: 0; z-index: 90;
  overflow-y: auto;
  background:
    radial-gradient(90rem 50rem at 85% -20%, rgba(240,83,46,.14), transparent 60%),
    radial-gradient(70rem 40rem at -10% 110%, rgba(240,83,46,.05), transparent 55%),
    var(--c-bg);
  color: var(--c-ink);
  transition: opacity .45s ease, transform .45s cubic-bezier(.6,0,.3,1);
}
#home.leaving { opacity: 0; transform: translateY(-2.5%); pointer-events: none; }

#home .h-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.1rem clamp(1.2rem, 5vw, 4rem);
}
#home .brand { font-family: var(--font-brand); font-size: 1.35rem; }

.h-kicker {
  font-family: var(--font-mono); font-size: .66rem; font-weight: 500;
  letter-spacing: .26em; text-transform: uppercase; color: var(--c-amber);
}

.h-hero {
  padding: clamp(3rem, 10vh, 7rem) clamp(1.2rem, 5vw, 4rem) clamp(3rem, 8vh, 5rem);
  max-width: 1080px;
}
.h-hero h1 {
  margin: 1.6rem 0 1.4rem;
  font-family: var(--font-brand); font-weight: 400;
  font-size: clamp(3rem, 8.5vw, 6.4rem); line-height: .95; letter-spacing: -.01em;
  animation: homeRise .8s cubic-bezier(.2,.7,.2,1) both;
}
.h-hero h1 i { color: var(--c-amber); }
.h-sub {
  max-width: 56ch; color: #aab0ba; font-size: 1.02rem; line-height: 1.65;
  animation: homeRise .8s cubic-bezier(.2,.7,.2,1) .1s both;
}
.h-cta { display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap; margin-top: 2.2rem;
  animation: homeRise .8s cubic-bezier(.2,.7,.2,1) .18s both; }
.btn.lg { font-size: .95rem; padding: .85rem 1.5rem; border-radius: 9px; }
.h-note { font-family: var(--font-mono); font-size: .62rem; letter-spacing: .12em; text-transform: uppercase; color: var(--c-dim); }

#home .h-personas {
  display: flex; align-items: center; gap: .45rem; flex-wrap: wrap;
  margin-top: 1.3rem;
}
#home .h-personas span {
  font-family: var(--font-mono); font-size: .6rem;
  letter-spacing: .14em; text-transform: uppercase; color: var(--c-dim);
  margin-right: .3rem;
}
#home .h-personas button {
  padding: .34rem .8rem; cursor: pointer;
  background: none; border: 1px solid var(--c-line); border-radius: 999px;
  font-family: var(--font-ui); font-size: .78rem; color: var(--c-ink);
  transition: border-color .15s, color .15s;
}
#home .h-personas button:hover { border-color: var(--c-amber); color: var(--c-amber); }
#home .h-personas button.on { border-color: var(--c-amber); }
#home .h-persona-back {
  padding: .34rem .8rem; cursor: pointer;
  background: var(--c-amber); border: 1px solid var(--c-amber); border-radius: 999px;
  font-family: var(--font-ui); font-size: .78rem; font-weight: 600; color: var(--c-amber-ink);
}
@keyframes homeRise { from { opacity: 0; transform: translateY(22px); } }

.h-designs { padding: clamp(2rem, 6vh, 4rem) clamp(1.2rem, 5vw, 4rem) 3rem; border-top: 1px solid var(--c-line); }
.h-designs-head { display: grid; grid-template-columns: 1fr auto; gap: 1rem; align-items: end; margin-bottom: 2rem; }
.h-designs-head h2 { grid-column: 1; margin-top: 1rem; font-family: var(--font-brand); font-weight: 400; font-size: clamp(1.8rem, 4vw, 3rem); line-height: 1.02; }
.h-designs-sub { grid-column: 2; max-width: 34ch; color: var(--c-dim); font-size: .82rem; line-height: 1.55; text-align: right; }

.h-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .8rem; }
.h-card {
  display: grid; grid-template-columns: 84px 1fr auto; align-items: center; gap: .9rem;
  padding: .8rem; cursor: pointer; text-align: left;
  background: var(--c-panel); color: var(--c-ink);
  border: 1px solid var(--c-line); border-radius: 11px;
  font-family: var(--font-ui);
  animation: homeRise .7s cubic-bezier(.2,.7,.2,1) var(--d, 0ms) both;
  transition: border-color .18s ease, transform .18s ease;
}
.h-card:hover { border-color: var(--c-amber); transform: translateY(-2px); }
.h-card .tpl-thumb { height: 56px; }
.h-card-copy b { display: block; font-size: .88rem; font-weight: 600; }
.h-card-copy small { color: var(--c-dim); font-size: .68rem; line-height: 1.3; }
.h-card > i { font-style: normal; color: var(--c-dim); transition: color .18s, transform .18s; }
.h-card:hover > i { color: var(--c-amber); transform: translateX(3px); }

.h-palettes { display: flex; flex-wrap: wrap; gap: .55rem; margin-top: 1.6rem; }
.h-dot {
  display: inline-flex; width: 34px; height: 20px; border-radius: 999px; overflow: hidden;
  border: 1px solid rgba(255,255,255,.14);
}
.h-dot i { flex: 1; }
.h-dot .da { background: var(--bg); }
.h-dot .db { background: var(--accent); }

.h-foot {
  padding: 2.2rem clamp(1.2rem, 5vw, 4rem) 2.6rem;
  border-top: 1px solid var(--c-line);
  display: flex; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap;
  font-size: .8rem; color: #aab0ba;
}
.h-foot b { color: var(--c-ink); }
.h-fine { font-family: var(--font-mono); font-size: .6rem; letter-spacing: .12em; text-transform: uppercase; color: var(--c-dim); }

@media (max-width: 1620px) {
  .src { display: none; }
  .tb-shuffle { position: static; transform: none; margin-left: auto; }
}
@media (max-width: 800px) {
  #tbShuffle { font-size: .72rem; padding: .42rem .6rem; }
}

/* narrow topbar: buttons collapse to icons */
@media (max-width: 1080px) {
  .actions .bl { display: none; }
  .actions .btn { padding: .48rem .6rem; }
  #topbar { gap: .6rem; }
  #topbar .brand em { display: none; }
}
@media (max-width: 560px) {
  #topbar {
    flex-wrap: wrap; height: auto; min-height: 44px;
    padding: .35rem .6rem; gap: .3rem .4rem; row-gap: .3rem;
  }
  #topbar .brand { font-size: 0; gap: 0; }
  .tb-shuffle .bl { display: none; }
  .tb-shuffle { gap: .2rem; }
  #tbBack, #tbFwd { display: none; }
  .tb-div { display: none; }
  .actions { margin-left: auto; flex-wrap: wrap; justify-content: flex-end; row-gap: .3rem; }
}

/* small screens: the drawer rises as a bottom sheet instead */
@media (max-width: 860px) {
  #panel {
    top: auto; left: 0; width: 100%; height: min(72vh, 560px);
    border-left: none; border-top: 1px solid var(--c-line);
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -18px 48px rgba(0,0,0,.4);
    transform: translateY(calc(100% + 30px));
  }
  body.panel-open #panel { transform: none; }
  .src { display: none; }
  .h-designs-head { grid-template-columns: 1fr; }
  .h-designs-sub { grid-column: 1; text-align: left; }
}
