/* EZ-PNG2SVG — styles
   Light professional theme. App shell: everything fits one viewport on
   desktop (no page scroll); rails scroll internally only if needed. */

:root {
  /* palette — light, neutral, single teal accent */
  --c-bg: #f4f5f7;
  --c-surface: #ffffff;
  --c-surface-2: #f1f3f6;
  --c-surface-3: #e7eaf0;
  --c-border: #dfe3ea;
  --c-text: #191c22;
  --c-text-dim: #4d5563;
  --c-text-faint: #6b7688;
  --c-accent: #0b7f74;
  --c-accent-hover: #0a857a;
  --c-accent-soft: #e4f5f2;
  --c-accent-ink: #ffffff;
  --c-danger: #d64545;
  --c-ok: #2e9e5b;

  /* transparency checker */
  --checker-light: #e9ebee;
  --checker-dark: #dfe3e8;

  /* elevation */
  --shadow-s: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-m: 0 6px 20px rgba(16, 24, 40, 0.08);

  /* shape */
  --radius-s: 6px;
  --radius-m: 10px;

  /* type */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;

  /* motion */
  --fast: 120ms ease;
  --med: 240ms ease;

  /* app chrome — --chrome-h is measured at runtime (JS) from the real
     header + footer bar heights, so the tool shell always meets the
     bottom bar exactly, even when a taller ad unit loads */
  --header-h: 56px;
  --footer-h: 145px;   /* docked footer bar height fallback before JS runs */
}

* { box-sizing: border-box; }

/* author display values must not defeat the hidden attribute */
[hidden] { display: none !important; }

html { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--c-text);
  background: var(--c-bg);
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* on tool/doc pages the footer bar is fixed; keep end-of-page content and
   the pinned gutter units clear of it: content clears the bar by 16px, and
   the sticky side track ends exactly at the pinned line so the unit stays
   fully visible between topbar and bar at max scroll */
body:has(.footerbar) { padding-bottom: calc(var(--footer-h, 145px) + 16px); }


button { font: inherit; color: inherit; }

/* ---------------------------------------------------------------- *
 *  Top bar — sticky, doubles as the page H1
 * ---------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 56px;
  padding: 0 16px;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  box-shadow: var(--shadow-s);
}

.brand {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.brand .logo { width: 20px; height: 20px; }

.brand-dot { color: var(--c-accent); }

.brand .tag {
  font-size: 12px;
  font-weight: 400;
  color: var(--c-text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar .actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------------------------------------------------------------- *
 *  Ad slots — designated, integrated, labeled.
 *  Styled as regular surface cards with a small "Sponsored" disclosure;
 *  .ad-inner:empty keeps the reserved placeholder until code is pasted.
 * ---------------------------------------------------------------- */

.ad-slot {
  position: relative;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-s);
  padding: 12px 4px 4px;  /* slim top strip for the disclosure, few-px
                             margins elsewhere: the reserved area belongs
                             to the ad */
}

/* identical disclosure on every sponsor area; lives in the 12px strip so
   it can never touch the ad space or get clipped by rounded corners */
.ad-slot::before {
  content: "Sponsored";
  position: absolute;
  top: 1px;
  left: 8px;
  font-size: 9px;
  font-weight: 600;
  line-height: 10px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--c-text-faint);
}

.ad-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  height: 100%;       /* the creative zone fills the whole reserved panel */
  border: 1px dashed var(--c-border);
  border-radius: var(--radius-s);
  color: var(--c-text-faint);
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  user-select: none;
}

.ad-inner:empty::after { content: "ad space"; }
.ad-inner:not(:empty) { border-style: solid; }

/* Placeholder policy (ad-driven site): every reserved slot is ALWAYS
   visible, configured or not. Empty slots show the dashed "ad space"
   placeholder; slots with unit code keep their exact reserved space
   whether Google filled that request or not, so the shell is
   pixel-identical between filled and unfilled requests (zero layout
   shift). Reserved min-heights inside .ad-inner keep this free of
   layout shift when ads load. Sizes reserved: right rail IAB
   300×250 / 336×280; footer IAB 728×90 / 970×90; mobile 320×50 / 320×100. */

/* Official AdSense technique: hide the unfilled unit itself
   (support.google.com/adsense/answer/10762946) while the slot KEEPS its
   reserved space, so an unfilled request never shifts the layout. A
   waiting cell stays quietly dashed under the "Sponsored" label. */
ins.adsbygoogle[data-ad-status="unfilled"] { display: none !important; }
.ad-inner:has(> ins.adsbygoogle[data-ad-status="unfilled"]) {
  border-style: dashed;
}

/* second footer area: IAB Medium/Large Rectangle beside the leaderboard */
.footer-col-ads {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 12px;
  min-width: 0;
}
/* both footer areas use the horizontal leaderboard family (728x90 /
   970x90 / 468x60 / 320x50-100): a 250px-tall rectangle would balloon
   the sticky bar. Area 1 gets the wide share, area 2 the remainder. */
.ad-footer-leaderboard { flex: 1 1 728px; }
.ad-footersq { flex: 1 1 340px; max-width: 970px; min-width: 234px; }
.ad-footersq .ad-inner { min-height: 90px; }

/* in-article unit (tool deep-dives + guides/trust pages): fluid native unit */
/* compact in-flow reserve: a tall empty band between content cards
   reads as a bug when the unit is unfilled; the fluid creative grows
   naturally when Google serves it */
.ad-inline { margin: 8px 0; }
.ad-inline .ad-inner { min-height: 96px; }

/* right rail: IAB Medium Rectangle 300×250 and Large Rectangle 336×280 */
.ad-tile .ad-inner { min-height: 280px; max-width: 336px; }

/* left rail: text/link unit */
.ad-strip .ad-inner { min-height: 60px; }
.ad-strip::before { content: "Sponsored links"; }

/* ---------------------------------------------------------------- *
 *  Buttons
 * ---------------------------------------------------------------- */

.btn {
  appearance: none;
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  color: var(--c-text);
  padding: 7px 14px;
  border-radius: var(--radius-s);
  cursor: pointer;
  box-shadow: var(--shadow-s);
  transition: background var(--fast), border-color var(--fast), transform var(--fast);
}

.btn:hover { background: var(--c-surface-2); }
.btn:active { transform: translateY(1px); }

.btn.primary {
  background: var(--c-accent);
  border-color: transparent;
  color: var(--c-accent-ink);
  font-weight: 600;
}

.btn.primary:hover { background: var(--c-accent-hover); }

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn.block { width: 100%; }

.btn:focus-visible,
.range-btn:focus-visible,
select:focus-visible,
.slider:focus-visible,
.chip:focus-visible,
.zoom-btn:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------- *
 *  App shell — the tool fills the first viewport exactly; the SEO
 *  guide flows below it. 56px header + 84px footer bar.
 * ---------------------------------------------------------------- */

.app {
  flex: none;
  height: calc(100dvh - var(--chrome-h, 142px));
  min-height: 480px;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 290px;
  gap: 12px;
  padding: 12px;
}

.rail {
  min-height: 0;
  overflow: hidden;            /* rails never scroll — data sections do */
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* scrollable data region of the left rail (controls + palette) */
.rail-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  padding-right: 2px;
}

.rail-left .ad-strip { flex: none; margin: 0; }

.rail-group {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-s);
  padding: 12px 14px 14px;
  flex: none;
}

.rail-group > h2 {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--c-text-faint);
}

.rail-hint {
  margin: -4px 0 10px;
  font-size: 11px;
  color: var(--c-text-faint);
}

.rail-note {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-s);
  padding: 10px 14px;
  font-size: 12px;
  color: var(--c-text-dim);
  flex: none;
}

.rail-note strong { color: var(--c-text); }

.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.control-row:last-child { margin-bottom: 0; }

.control-label { color: var(--c-text-dim); }

/* steppers */
.stepper {
  display: flex;
  align-items: center;
  gap: 4px;
}

.range-btn {
  width: 26px;
  height: 26px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-s);
  background: var(--c-surface);
  color: var(--c-text);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  transition: background var(--fast);
}

.range-btn:hover { background: var(--c-surface-2); }

.stepper .value {
  min-width: 34px;
  text-align: center;
  font-family: var(--mono);
  font-size: 13px;
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-s);
  padding: 4px 6px;
}

select {
  background: var(--c-surface);
  color: var(--c-text);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-s);
  padding: 6px 8px;
  font: inherit;
}

/* sliders */
.slider-row { margin-bottom: 10px; }
.slider-row:last-of-type { margin-bottom: 4px; }

.slider-row .slider-head {
  display: flex;
  justify-content: space-between;
  color: var(--c-text-dim);
  margin-bottom: 2px;
}

.slider-row output {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--c-text-faint);
}

.slider {
  width: 100%;
  accent-color: var(--c-accent);
  margin: 0;
}

.adjustments { margin-top: 10px; }

.adjustments summary {
  cursor: pointer;
  color: var(--c-text-dim);
  font-size: 13px;
  user-select: none;
  padding: 4px 0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.adjustments summary::-webkit-details-marker { display: none; }

.adjustments summary::before {
  content: "▸";
  transition: transform var(--fast);
  color: var(--c-text-faint);
}

.adjustments[open] summary::before { transform: rotate(90deg); }

.adjustments .adjust-body { padding-top: 10px; }

.reset-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.reset-row .btn { padding: 4px 10px; font-size: 12px; }

.rail > .btn.block { flex: none; }

/* anchor the sponsored strip at the rail bottom — with a clear gap below
   the Regenerate button so an ad click can never be confused with a tool
   click (accidental-clicks policy). Layout stays anchored; margin adds
   the tolerance band. */
.rail-left .rail-scroll + .ad-strip { margin-top: 26px; }

/* palette chips: scroll internally so the merge block stays visible */
#palettePanel .chips {
  max-height: 176px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.rail .hint {
  color: var(--c-text-faint);
  font-size: 12px;
  text-align: center;
  margin: 0;
}

/* ---------------------------------------------------------------- *
 *  Palette rail group
 * ---------------------------------------------------------------- */

#palettePanel .chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 999px;
  padding: 3px 8px 3px 5px;
  cursor: pointer;
  transition: border-color var(--fast), background var(--fast), opacity var(--fast);
  color: var(--c-text-dim);
  font-size: 12px;
  font-family: var(--mono);
}

.chip:hover { background: var(--c-surface-2); }

.chip .swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.15);
  flex: none;
}

.chip .hex {
  padding: 1px 2px;
  border-radius: 4px;
  transition: background var(--fast), color var(--fast);
}

.chip .hex:hover {
  background: var(--c-surface-3);
  color: var(--c-text);
}

.chip .pct { color: var(--c-text-faint); }

.chip.selected-from {
  border-color: var(--c-accent);
  background: var(--c-accent-soft);
  box-shadow: 0 0 0 1px var(--c-accent);
}

.chip.selected-to {
  border-color: var(--c-ok);
  background: #eaf6ef;
  box-shadow: 0 0 0 1px var(--c-ok);
}

.chip.off { opacity: 0.4; }

.chip .knock {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--c-text-faint);
  cursor: pointer;
  /* 24×24 hit area (WCAG 2.5.8) around a compact glyph */
  min-width: 24px;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 13px;
  line-height: 1;
  border-radius: 50%;
}

.chip .knock:hover { color: var(--c-danger); }

/* custom merge-target chip with color input */
.chip.custom-to {
  padding: 3px 6px;
  gap: 4px;
  border-style: dashed;
}

.chip.custom-to input[type="color"] {
  appearance: none;
  width: 18px;
  height: 18px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 50%;
  padding: 0;
  background: none;
  cursor: pointer;
}

.chip.custom-to input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.chip.custom-to input[type="color"]::-webkit-color-swatch { border: none; border-radius: 50%; }
.chip.custom-to input[type="color"]::-moz-color-swatch { border: none; border-radius: 50%; }

.chip.custom-to .custom-plus {
  font-size: 12px;
  color: var(--c-text-faint);
  line-height: 1;
}

.chip.custom-to.selected-to {
  border-style: solid;
  border-color: var(--c-ok);
}

/* merge block inside rail */
.merge-block {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.merge-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.merge-line .chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.merge-line .chips:empty::after {
  content: "none picked";
  color: var(--c-text-faint);
  font-size: 11px;
  font-style: italic;
  font-family: var(--font);
}

.group-label {
  color: var(--c-text-faint);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  min-width: 72px;
}

.merge-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.merge-actions .btn { padding: 5px 14px; font-size: 12px; }

.merge-note {
  color: var(--c-text-faint);
  font-size: 11px;
}

/* ---------------------------------------------------------------- *
 *  Stage — single pane: before/after split + zoom/pan
 * ---------------------------------------------------------------- */

.stage-col {
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.pane {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-s);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.pane > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--c-text-faint);
  border-bottom: 1px solid var(--c-border);
  flex: none;
}

.pane .pane-note {
  font-size: 10px;
  letter-spacing: 0;
  text-transform: none;
  font-weight: 400;
  color: var(--c-text-faint);
}

/* zoomable viewport */
.viewport {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  background-image:
    linear-gradient(45deg, var(--checker-dark) 25%, transparent 25%,
      transparent 75%, var(--checker-dark) 75%),
    linear-gradient(45deg, var(--checker-dark) 25%, transparent 25%,
      transparent 75%, var(--checker-dark) 75%);
  background-color: var(--checker-light);
  background-size: 18px 18px;
  background-position: 0 0, 9px 9px;
}

.viewport.panning { cursor: grabbing; }

.zoom-layer {
  position: absolute;
  inset: 0;
  transform-origin: 0 0;
}

.layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.layer-before {
  clip-path: inset(0 calc(100% - var(--split-layer, 0%)) 0 0);
}

/* comparison divider — viewport space */
.divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--split, 0%);
  width: 0;
  cursor: ew-resize;
  touch-action: none;
}

.divider::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -1.5px;
  width: 3px;
  background: var(--c-accent);
  opacity: 0.9;
}

.divider:focus-visible::before,
.divider:focus::before {
  opacity: 1;
  width: 5px;
  left: -2.5px;
}

.divider .grip {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translate(-50%, -50%);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--c-accent);
  color: var(--c-accent-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  letter-spacing: 1px;
  box-shadow: 0 2px 10px rgba(16, 24, 40, 0.35);
  cursor: ew-resize;
}

.divider:focus-visible .grip,
.divider:focus .grip {
  outline: 3px solid var(--c-accent-hover);
  outline-offset: 2px;
}

/* corner tags */
.stage-tag {
  position: absolute;
  top: 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--c-text-dim);
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--c-border);
  border-radius: 999px;
  padding: 3px 10px;
  pointer-events: none;
  z-index: 3;
}

.tag-before { left: 10px; }
.tag-after { right: 10px; }

/* zoom controls */
.zoom-controls {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-s);
  padding: 4px;
  box-shadow: var(--shadow-m);
  z-index: 3;
}

.zoom-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--c-text);
  width: 26px;
  height: 26px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

.zoom-btn:hover { background: var(--c-surface-2); }

.zoom-level {
  min-width: 44px;
  text-align: center;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--c-text-dim);
}

/* loading overlay — purely visual */
.load-overlay {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(1px);
  pointer-events: none;
  z-index: 4;
  font-size: 13px;
  color: var(--c-text-dim);
}

.load-overlay.active { display: flex; }

.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--c-border);
  border-top-color: var(--c-accent);
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; opacity: .5; }
}

/* empty / dropzone state */
.empty {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--c-surface);
  border: 2px dashed var(--c-border);
  border-radius: var(--radius-m);
  color: var(--c-text-dim);
  text-align: center;
  padding: 24px;
  cursor: pointer;
  transition: border-color var(--fast), background var(--fast);
}

.empty:hover, .empty:focus-visible {
  border-color: var(--c-accent);
  background: var(--c-surface-2);
}

.empty .big {
  font-size: 17px;
  font-weight: 600;
  color: var(--c-text);
}

.empty svg { opacity: 0.5; }

/* ---------------------------------------------------------------- *
 *  Stats strip
 * ---------------------------------------------------------------- */

.statsbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px 14px;
  flex-wrap: wrap;
  min-height: 34px;
  padding: 6px 14px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-s);
  color: var(--c-text-dim);
  font-size: 12px;
  font-family: var(--mono);
}

.statsbar:empty { display: none; }

.statsbar .dot { opacity: 0.5; }

/* posterization expectation hint (photo/gradient-like sources) */
.trace-hint {
  flex: none;
  margin: 6px 0 0;
  padding: 8px 12px;
  background: var(--c-accent-soft);
  border: 1px solid var(--c-accent);
  border-radius: var(--radius-m);
  color: var(--c-text-dim);
  font-size: 12px;
  line-height: 1.5;
}
.trace-hint strong { color: var(--c-text); }

/* copy-paste prompt blocks (ChatGPT prep guide) */
.prompt-box {
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-left: 3px solid var(--c-accent);
  border-radius: var(--radius-m);
  padding: 12px 14px;
  margin: 10px 0 14px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  color: var(--c-text);
}

/* ---------------------------------------------------------------- *
 *  Layers rail (right)
 * ---------------------------------------------------------------- */

.rail-right {
  flex: none;
  overflow: hidden;
}

#layersPanel {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.layer-list {
  flex: 1 1 auto;
  min-height: 60px;
  overflow-y: auto;
  scrollbar-width: thin;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.layer-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-s);
  padding: 6px 8px;
}

.layer-card .swatch {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-s);
  border: 1px solid rgba(0, 0, 0, 0.12);
  flex: none;
}

.layer-card .meta {
  display: flex;
  flex-direction: column;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--c-text-dim);
  line-height: 1.3;
  min-width: 0;
}

.layer-card .meta .hex { color: var(--c-text); }

.layer-card .btn {
  margin-left: auto;
  padding: 4px 10px;
  font-size: 11px;
}

/* ---------------------------------------------------------------- *
 *  Footer bar — brand line + leaderboard, sticky so the ad unit
 *  stays on screen across the whole page
 * ---------------------------------------------------------------- */

.footerbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  flex: none;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
  min-height: var(--footer-h);
  padding: 10px 16px;
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
  box-shadow: 0 -1px 2px rgba(16, 24, 40, 0.05);
}

/* column 1: brand mark / text ad / designer credit.
   The credit stays pinned at the same bottom spot; the logo + links
   cluster centers itself in the space above it instead of being
   spread across the full bar height */
.footer-col-brand {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
}

.footer-mark {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: auto;  /* pulls the rows down toward the credit */
  font-weight: 700;
  font-size: 13px;
  color: var(--c-text-dim);
  white-space: nowrap;
  flex: none;
}

.footer-mark strong { color: var(--c-accent); }

/* site-wide navigation inside footer column 1 (About / Guides / legal) */
.footer-links {
  flex: none;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 3px 14px;
  font-size: 11.5px;
  line-height: 1.3;
}

.footer-links a { color: var(--c-text-dim); text-decoration: none; }
.footer-links a:hover { color: var(--c-accent); text-decoration: underline; }
.footer-links .sep { color: var(--c-text-faint); user-select: none; }

/* subtle designer credit, pinned at the bottom of column 1
   (unchanged spot; its auto margin centers the rows above it) */
.kynex-credit {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: auto;
  font-size: 10px;
  color: var(--c-text-faint);
  white-space: nowrap;
  flex: none;
}

.kynex-credit a {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.kynex-credit img {
  height: 18px;
  width: auto;
  opacity: 0.9;
  transition: opacity var(--fast);
}

.kynex-credit a:hover img { opacity: 1; }

/* same credit, slightly smaller, inside doc-page footers (guides/trust) */
.kynex-credit-doc img { height: 16px; }

/* column 2: IAB Leaderboard 728×90, Super Leaderboard 970×90 —
   grows automatically for a 970×250 Billboard (shell re-measures via JS) */
.ad-footer-leaderboard {
  display: flex;
  width: min(100%, 970px);
  min-height: 120px;
  max-width: 970px;
  align-self: stretch;
  padding: 12px 4px 4px;  /* same slim skin as every other sponsor area */
}

.ad-footer-leaderboard .ad-inner {
  flex: 1;
  min-height: 90px;
}

/* ---------------------------------------------------------------- *
 *  SEO guide content (below the tool)
 * ---------------------------------------------------------------- */

.seo {
  max-width: 880px;
  margin: 0 auto 42px;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.seo-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-s);
  padding: 22px 26px;
}

.seo-card h2 {
  margin: 0 0 12px;
  font-size: 20px;
  line-height: 1.3;
}

.seo-card p { margin: 0 0 10px; color: var(--c-text-dim); }
.seo-card p strong, .seo-card li strong { color: var(--c-text); }
.seo-card ul, .seo-card ol { margin: 0 0 6px; padding-left: 22px; color: var(--c-text-dim); }
.seo-card li { margin: 6px 0; }

.steps li { margin: 9px 0; }

.format-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.format-card {
  display: block;
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-m);
  padding: 14px 16px;
  text-decoration: none;
  color: var(--c-text);
  transition: border-color var(--fast), background var(--fast), transform var(--fast);
}

.format-card:hover {
  border-color: var(--c-accent);
  background: var(--c-accent-soft);
  transform: translateY(-1px);
}

/* flat file-format icon inline in each card (no image requests):
   a sheet with folded corner, image glyph, and a colored label band */
.fmt-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 8px;
}

.fmt-head h3 { margin: 0; }

.fico {
  flex: none;
  width: 28px;
  height: 34px;
  display: block;
}

.format-card h3 {
  margin: 0 0 6px;
  font-size: 14px;
  color: var(--c-accent);
}

.format-card p {
  margin: 0;
  font-size: 13px;
  color: var(--c-text-dim);
}

.seo details {
  border-bottom: 1px solid var(--c-border);
  padding: 2px 0;
}

.seo details:last-child { border-bottom: 0; }

.seo summary {
  cursor: pointer;
  font-weight: 600;
  padding: 9px 0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}

.seo summary::-webkit-details-marker { display: none; }

.seo summary::before {
  content: "▸";
  color: var(--c-accent);
  transition: transform var(--fast);
}

.seo details[open] summary::before { transform: rotate(90deg); }

.seo details p { margin: 0 0 12px; }

/* ---------------------------------------------------------------- *
 *  Doc pages — About / Contact / legal / guide articles
 * ---------------------------------------------------------------- */

.doc-page {
  max-width: 860px;
  margin: 26px auto 46px;
  padding: 0 16px;
  flex: 1 1 auto;
}

.doc-cover h1 {
  margin: 4px 0 10px;
  font-size: 30px;
  line-height: 1.2;
}

.doc-meta {
  font-size: 12px;
  color: var(--c-text-faint);
  margin: 0 0 18px;
}

.doc-page p,
.doc-page li {
  color: var(--c-text-dim);
  line-height: 1.65;
}

.doc-page .seo-card p:last-child,
.doc-page .seo-card li:last-child { margin-bottom: 0; }

.doc-page a:link,
.doc-page a:visited { color: var(--c-accent); }

.doc-list { margin: 10px 0 14px; padding-left: 22px; }
.doc-list li { margin: 6px 0; }

.doc-footer {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
  font-size: 11.5px;
  color: var(--c-text-faint);
}

.doc-footer nav {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px 14px;
}

.doc-footer .btn { padding: 4px 10px; font-size: 12px; margin-left: auto; }

.drop-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(244, 245, 247, 0.85);
  z-index: 50;
  font-size: 20px;
  font-weight: 600;
  color: var(--c-accent);
  pointer-events: none;
  border: 3px dashed var(--c-accent);
}

.drop-overlay.active { display: flex; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: #23272f;
  color: #ffffff;
  border-radius: var(--radius-s);
  padding: 10px 16px;
  font-size: 13px;
  opacity: 0;
  transition: opacity var(--med), transform var(--med);
  pointer-events: none;
  z-index: 60;
  max-width: min(90vw, 480px);
  box-shadow: var(--shadow-m);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.error { background: var(--c-danger); cursor: pointer; }
.toast.error::after { content: " ✕"; opacity: .7; font-size: 11px; white-space: nowrap; }

/* ---------------------------------------------------------------- *
 *  Responsive — small screens reflow and allow page scroll
 * ---------------------------------------------------------------- */

@media (max-width: 1180px) {
  body { overflow: auto; height: auto; min-height: 100dvh; }
  .app {
    height: auto;
    min-height: calc(100dvh - 190px);
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "stage stage"
      "left right";
  }
  .stage-col { grid-area: stage; }
  .rail-left { grid-area: left; overflow: visible; }
  .rail-right { grid-area: right; overflow: visible; }
  .rail-scroll { overflow: visible; }
  .layer-list { flex: none; max-height: 340px; }
  .viewport { min-height: 380px; }
}

@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; grid-template-areas: "stage" "left" "right"; height: auto; }
  .topbar { height: auto; flex-wrap: wrap; padding: 8px 12px; }
  .brand .tag { display: none; }
  .viewport { min-height: 320px; }
  .footerbar { grid-template-columns: 1fr; gap: 8px; }
  .footer-note { display: none; }
  /* mobile: IAB Mobile Leaderboard 320×50 / Large Mobile Banner 320×100 */
  .ad-footer-leaderboard { width: 100%; max-width: 640px; }
  .ad-footer-leaderboard .ad-inner { min-height: 100px; }
  .ad-footersq { display: none; }
  .ad-tile .ad-inner { min-height: 250px; }
  .kynex-credit { font-size: 10px; }
  .kynex-credit img { height: 14px; }
}

/* sticky gutter units on desktop: IAB half-page/skyscraper down the two
   blank sides of the content column */
.ad-side { display: none; }
@media (min-width: 1280px) {
  /* The content column keeps its 880/860 reading width; the gutters take
     the genuine leftover space on each side.
     Pitfall avoided on purpose: with an all-implicit grid, grid-row: 1/-1
     resolves to line 1, so in-flow spanning asides would inflate row one
     to their 600px reserve and open a phantom gap under the first card.
     Instead the asides leave grid flow entirely and stretch absolute
     across the full section height; the sticky does the work on the
     inner wrapper. */
  /* auto horizontal margins + flex parent means fit-content sizing: give
     an explicit full width so the 1fr gutters get real room */
  .seo {
    position: relative;
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 940px) minmax(0, 1fr);
    gap: 16px 24px;
    align-items: start;
    max-width: none;
    /* no bottom margin: the docked bar owns the page end; the 16px of
       sticky slack lives in the body padding below */
    padding: 0 16px;
    margin-bottom: 0;
  }
  .seo > *:not(.ad-side) { grid-column: 2; }

  /* guide/trust article pages get the same sticky gutters */
  .doc-page {
    position: relative;
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 900px) minmax(0, 1fr);
    gap: 16px 24px;
    align-items: start;
    max-width: none;
    padding: 0 16px;
    margin-bottom: 0;
  }
  .doc-page > *:not(.ad-side) { grid-column: 2; }

  /* the stretched aside must stay a transparent positioning column: the
     slot chrome (surface, border, label) lives on the sticky inner so the
     gutter shows a compact pinned unit, not a full-height band */
  .ad-side {
    display: block;
    position: absolute;
    top: 0;
    bottom: -64px;  /* stretch the sticky track past the section end so the
                       pinned [topbar+4, footer-4] window stays reachable at
                       max scroll; absolute, so page height is unchanged */
    background: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
  }
  .ad-side::before { content: none; }  /* label moves to the inner */
  /* Ad-side gutters: Google's sticky-ad policy allows only units up to
     300px wide (support.google.com/adsense/answer/10734935), and the
     vertical formats it serves in sidebars are 300x600 / 160x600 /
     120x600 (support.google.com/admanager/answer/1100453). Cap the wing
     at 300px; below ~160px of room the responsive unit serves 120x600.
     940+900 center columns + 2x24 gaps -> 988px / 948px offsets. */
  .seo .ad-side { width: min(calc((100% - 988px) / 2), 300px); }      /* 940 main + 2x24 gaps */
  .doc-page .ad-side { width: min(calc((100% - 948px) / 2), 300px); } /* 900 main + 2x24 gaps */
  .ad-side-left  { left: 8px; }   /* hug the outer edges, not the content */
  .ad-side-right { right: 8px; }

  .ad-side .ad-inner {
    position: sticky;
    top: 72px;                                    /* 16px under the sticky topbar */
    bottom: calc(var(--footer-h, 145px) + 16px);  /* 16px over the docked bar */
    height: calc(100dvh - 56px - var(--footer-h, 145px) - 32px);
    min-height: 600px;
    width: 100%;   /* fill the gutter: 8px outer edge, 16px gap to content */
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-m);
    box-shadow: var(--shadow-s);
    padding: 12px 4px 4px;  /* same slim-strip skin as every other slot */
  }
  .ad-side .ad-inner::before {
    content: "Sponsored";
    position: absolute;
    top: 1px;
    left: 8px;
    font-size: 9px;
    font-weight: 600;
    line-height: 10px;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    color: var(--c-text-faint);
  }
  /* the side panels carry the card chrome on .ad-inner itself (the aside is
     only a positioning column), so the creative zone is drawn as an inset
     frame layer: identical states to every other slot — dashed + blank
     placeholder until configured, quiet solid frame once the ins exists */
  .ad-side .ad-inner::after {
    content: "";
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    inset: 16px 4px 4px;
    border: 1px dashed var(--c-border);
    border-radius: var(--radius-s);
    color: var(--c-text-faint);
    font-size: 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
    user-select: none;
    pointer-events: none;
  }
  .ad-side .ad-inner:empty::after { content: "ad space"; }
  .ad-side .ad-inner:has(> ins)::after { border-style: solid; }
  .ad-side .ad-inner > ins { position: relative; z-index: 1; }
  .ad-side-left .ad-inner { margin-left: 0; margin-right: auto; }  /* hug the viewing edge */
  .ad-side-right .ad-inner { margin-right: 0; margin-left: auto; }
}
/* a 600px-tall gutter unit cannot fit between the pinned bars on short
   viewports; hiding beats letting half the unit vanish under the bars */
@media (min-width: 1280px) and (max-height: 832px) {
  .ad-side { display: none; }
}
