:root {
  /* Aligned with DesignTokens — soft native feel, not a harsh web tool. */
  --bg: #0f1017;
  --bg-elev: rgba(255, 255, 255, 0.055);
  --border: rgba(255, 255, 255, 0.1);
  --text: #ffffff;
  --muted: rgba(255, 255, 255, 0.5);
  --accent: #53d5fd;
  --accent-2: #3f6ef5;
  --accent-interactive: #7ea6ff;
  --radius: 16px;
  --radius-control: 12px;
  --font: "SF Pro Display", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --shell-pad-x: 24px;
  --shell-pad-y: 18px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: transparent;
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(900px 320px at 12% -10%, rgba(83, 213, 253, 0.08), transparent 55%),
    radial-gradient(700px 280px at 92% 0%, rgba(63, 110, 245, 0.07), transparent 50%),
    var(--bg);
  border-radius: 16px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.phase {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: var(--shell-pad-y) var(--shell-pad-x) 18px;
}
.phase.hidden { display: none; }
.editor-phase { padding-bottom: 12px; }

button.compact {
  padding: 6px 10px;
  font-size: 11px;
  border-radius: 10px;
}
button.wide { width: 100%; }

.editor-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 140px minmax(220px, 1fr) minmax(220px, 280px);
  gap: 12px;
  overflow: hidden;
}

.film-rail,
.inspector {
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  padding: 12px;
  overflow: hidden;
}

.film-rail-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 2px;
}

.add-slide-btn {
  flex: 0 0 auto;
  margin-top: 10px;
  width: 100%;
  border-radius: 12px;
  border: 1px dashed rgba(126, 166, 255, 0.45);
  background: rgba(63, 110, 245, 0.12);
  color: var(--text);
  padding: 10px 8px;
  font-size: 12px;
  font-weight: 650;
}
.add-slide-btn:hover {
  border-style: solid;
  border-color: rgba(126, 166, 255, 0.7);
  background: rgba(63, 110, 245, 0.2);
}

.canvas-pane {
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rail-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: none;
  color: rgba(255, 255, 255, 0.55);
  margin-bottom: 8px;
  flex: 0 0 auto;
}
.inspector-gap {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.inspector { padding: 14px; gap: 0; }

.rail-thumb {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  text-align: left;
  color: inherit;
  width: 100%;
}
.rail-thumb.selected {
  border-color: transparent;
  background: linear-gradient(135deg, rgba(83, 213, 253, 0.28), rgba(63, 110, 245, 0.32));
  box-shadow: inset 0 0 0 1.5px rgba(126, 166, 255, 0.85);
}
.rail-thumb.selected .thumb-meta {
  color: #b8ecff;
}
.rail-thumb .thumb-preview {
  width: 100%;
  aspect-ratio: 9 / 16;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  background: #080a0e;
  margin-bottom: 6px;
}
.rail-thumb .thumb-preview .mini-slide {
  transform-origin: top left;
  pointer-events: none;
}
.rail-thumb .thumb-meta {
  font-size: 10px;
  color: var(--muted);
  font-weight: 600;
}

.canvas-pane .stage {
  flex: 1;
}

.focus-host {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.layer-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 0 0 auto;
  max-height: 168px;
  overflow: auto;
  margin-bottom: 2px;
}
.layer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
  transition: background 120ms ease, color 120ms ease;
}
.layer-row:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}
.layer-row.selected {
  border-color: transparent;
  color: #061018;
  font-weight: 650;
  background: linear-gradient(135deg, #53d5fd, #7ea6ff);
}
.layer-row.selected .z,
.layer-row.selected .grip {
  opacity: 0.7;
  color: #061018;
}
.layer-row .z {
  font-size: 10px;
  opacity: 0.45;
  width: 16px;
  font-variant-numeric: tabular-nums;
}

.inspector-empty {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
  padding: 6px 2px 10px;
}
.inspector-fields {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 2px;
  justify-content: flex-start;
  align-content: flex-start;
}
.inspector-fields.hidden,
.device-only.hidden,
.text-only.hidden,
.inspector-empty.hidden { display: none; }

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.55);
  flex: 0 0 auto;
  min-width: 0;
}
.field-row .field {
  flex: 1 1 0;
}
.field span { font-weight: 600; letter-spacing: 0.01em; }
.field em {
  font-style: normal;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.7);
  font-variant-numeric: tabular-nums;
}
.field input[type="range"] {
  width: 100%;
  accent-color: var(--accent-interactive);
  height: 18px;
}
.field input[type="number"] {
  width: 100%;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-control);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  padding: 8px 10px;
  outline: none;
}
.field input[type="number"]:hover,
.field input[type="number"]:focus {
  border-color: rgba(126, 166, 255, 0.45);
  background: rgba(255, 255, 255, 0.07);
}
.field input[type="color"] {
  width: 100%;
  height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-control);
  background: var(--bg-elev);
  padding: 3px;
}
.field select,
.field textarea {
  width: 100%;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-control);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  padding: 8px 10px;
  outline: none;
  resize: vertical;
  transition: border-color 120ms ease, background 120ms ease;
}
.field textarea {
  min-height: 64px;
  max-height: 120px;
  flex: none;
}
.field select:hover,
.field textarea:hover,
.field select:focus,
.field textarea:focus {
  border-color: rgba(126, 166, 255, 0.45);
  background: rgba(255, 255, 255, 0.07);
}
.field-row {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
  align-items: flex-end;
}
.z-row {
  display: flex;
  gap: 8px;
  margin-top: 2px;
}
.z-row .ghost { flex: 1; }

/* Quick layout chips in the editor chrome */
.layout-seg {
  gap: 6px;
  padding: 3px 6px 3px 10px;
}
.chip {
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.72);
}
.chip:hover {
  border-color: rgba(126, 166, 255, 0.45);
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}
.chip:focus,
.chip:focus-visible {
  outline: none;
  border-color: rgba(126, 166, 255, 0.55);
}
.chip.selected {
  background: linear-gradient(135deg, #53d5fd, #3f6ef5);
  border-color: transparent;
  color: #0a1446;
}
.chip.selected:hover {
  filter: brightness(1.05);
  color: #0a1446;
  border-color: transparent;
}

/* Background editor panel */
.bg-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 0 0 auto;
}
.bg-panel.hidden { display: none; }
.bg-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Free-position layers on the slide */
.slide .free-stage {
  position: absolute;
  inset: 0;
  z-index: 2;
}
.layer {
  position: absolute;
  transform: translate(-50%, -50%);
  cursor: grab;
  outline: 2px solid transparent;
  outline-offset: 4px;
  border-radius: 6px;
  max-width: 86%;
}
.layer:active { cursor: grabbing; }
.layer.selected {
  outline: 2.5px solid #53d5fd;
  outline-offset: 5px;
  box-shadow: 0 0 0 1px rgba(83, 213, 253, 0.45);
}
.layer.editing {
  outline-color: rgba(83, 213, 253, 0.95);
  cursor: text;
}
.layer.text-layer {
  padding: 4px 6px;
  -webkit-user-select: none;
  user-select: none;
  white-space: pre-wrap;
  /* Never split a word: app.js shrinks the font until every word fits. */
  word-break: normal;
  overflow-wrap: normal;
}
.layer.text-layer .text-edit {
  margin: 0;
  outline: none;
  min-width: 40px;
  pointer-events: none;
  cursor: inherit;
}
.layer.text-layer.editing .text-edit {
  pointer-events: auto;
  -webkit-user-select: text;
  user-select: text;
  cursor: text;
}
.layer.device-layer {
  width: 58%;
  transform-origin: center center;
  /* Panorama device can be wider than the slide (N× base) — never clamp it. */
  max-width: none;
  /* The layer also carries the type class "device", which matches the .device
     rule below. Without this the wrapper took the phone's 0.495 ratio (and a
     second shadow), so on iPad it was far taller than the tablet inside, the
     tablet sat at its top and covered the captions, and the PNG export (which
     centers the tablet itself) no longer matched the canvas. */
  aspect-ratio: auto;
  filter: none;
}
/* Fix 2 — hover Replace / Clear affordance on the device in the canvas. */
.device-actions-overlay {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  z-index: 5;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}
.device:hover .device-actions-overlay {
  opacity: 1;
  pointer-events: auto;
}
.device-act {
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.62);
  color: var(--text);
  border-radius: 7px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
}
.device-act:hover { border-color: var(--accent); }
/* Fix 2 — inspector Replace / Clear stack for the device layer. */
#device-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
#device-actions.hidden { display: none; }
/* Fix 4 — Panorama control in the editor chrome. */
.pano-seg { cursor: pointer; }
.pano-seg input[type="checkbox"] { margin: 0; accent-color: var(--accent); }
.pano-seg select {
  background: transparent;
  border: none;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  outline: none;
}
.pano-seg select.hidden { display: none; }
.layer.device-layer .device {
  width: 100%;
}
.layer.kicker .text-edit {
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.phase-head {
  flex: 0 0 auto;
  margin-bottom: 18px;
}
.phase-head h1 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.025em;
}
.phase-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  max-width: 520px;
  line-height: 1.45;
}

.template-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  overflow: auto;
  padding: 4px 4px 20px;
  align-content: start;
}

.template-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 12px 14px;
  cursor: pointer;
  text-align: left;
  color: inherit;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}
.template-card:hover {
  transform: translateY(-3px);
  border-color: rgba(126, 166, 255, 0.5);
  background: rgba(255, 255, 255, 0.05);
}
.template-card .preview {
  width: 100%;
  aspect-ratio: 9 / 16;
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 12px;
  position: relative;
  background: #080a0e;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.template-card .preview .mini-slide {
  transform-origin: top left;
  pointer-events: none;
}
.template-card strong {
  display: block;
  font-size: 13px;
  font-weight: 650;
  margin-bottom: 3px;
  letter-spacing: -0.01em;
}
.template-card span {
  display: block;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.35;
}

.editor-chrome {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  flex: 0 0 auto;
}
.chrome-group {
  display: flex;
  gap: 8px;
  flex: 1 1 auto;
  flex-wrap: wrap;
  min-width: 0;
}
.chrome-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
  flex: 0 0 auto;
}

.seg {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px 4px 12px;
}
.seg select {
  background: transparent;
  border: none;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  outline: none;
}

button {
  font: inherit;
  cursor: pointer;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
}
button.ghost {
  background: rgba(255, 255, 255, 0.055);
  color: var(--text);
}
button.ghost:hover {
  border-color: rgba(126, 166, 255, 0.35);
  background: rgba(255, 255, 255, 0.08);
}
button.primary {
  background: linear-gradient(135deg, #53d5fd, #3f6ef5);
  border: none;
  color: #0a1446;
}
button.primary:hover { filter: brightness(1.06); }
button:disabled { opacity: 0.45; cursor: default; }

.status {
  margin-bottom: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 12px;
  flex: 0 0 auto;
}

.stage {
  flex: 1;
  min-height: 0;
  border-radius: 16px;
  background:
    radial-gradient(1000px 360px at 18% 0%, rgba(61, 184, 197, 0.07), transparent 55%),
    #080a0e;
  border: 1px solid var(--border);
  overflow: auto;
  position: relative;
}

.filmstrip-track {
  display: flex;
  align-items: center;
  gap: 28px;
  min-height: 100%;
  padding: 40px 44px;
  width: max-content;
}

.stage.focus .filmstrip-track {
  justify-content: center;
  width: 100%;
}
.stage.focus .slide-card:not(.selected) {
  display: none;
}

.slide-card {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
}
.slide-card .slide-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--muted);
  padding: 0 4px;
}
.slide-card.selected .slide-meta { color: var(--accent); font-weight: 600; }

.slide {
  width: 320px;
  height: 690px;
  border-radius: 22px;
  overflow: hidden;
  position: relative;
  box-shadow: 0 28px 56px rgba(0, 0, 0, 0.5);
  outline: 2px solid transparent;
}
.slide-card.selected .slide {
  outline-color: rgba(126, 166, 255, 0.75);
}
.slide.ipad {
  width: 420px;
  height: 560px;
}

.slide .bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.slide .bg .wash {
  position: absolute;
  inset: 0;
}
.slide .bg .orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(2px);
  pointer-events: none;
}
.slide .bg .grain {
  position: absolute;
  inset: 0;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
  pointer-events: none;
}

.slide .layout {
  position: absolute;
  inset: 0;
  display: flex;
  padding: 32px 24px;
  z-index: 1;
}
.layout.hero-top { flex-direction: column; align-items: center; }
.layout.bold-center { flex-direction: column; align-items: center; justify-content: center; gap: 26px; }
.layout.caption-bottom { flex-direction: column; align-items: center; justify-content: flex-end; gap: 20px; padding-bottom: 44px; }
.layout.editorial { flex-direction: row; align-items: center; gap: 10px; padding: 36px 20px; }
.layout.bleed { flex-direction: column; align-items: center; padding: 36px 20px 0; overflow: hidden; }
.layout.float { flex-direction: column; align-items: center; justify-content: flex-start; padding-top: 40px; gap: 20px; }

.caption {
  text-align: center;
  width: 100%;
  z-index: 2;
}
.caption.tone-dark { color: #12151a; }
.caption.tone-light { color: #ffffff; }
.caption.tone-dark .subheadline { opacity: 0.72; }
.caption.tone-light .subheadline { opacity: 0.86; }

.layout.editorial .caption {
  text-align: left;
  width: 40%;
  flex-shrink: 0;
  padding-left: 4px;
  border-left: 3px solid var(--accent-line, rgba(255, 255, 255, 0.55));
  padding-left: 14px;
}
.layout.hero-top .caption { margin-top: 20px; margin-bottom: auto; }
.layout.caption-bottom .caption { order: 2; }
.layout.bleed .caption { margin-bottom: 18px; flex: 0 0 auto; }
.layout.float .caption { flex: 0 0 auto; }

.caption .kicker {
  margin: 0 0 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.7;
}
.caption .headline,
.caption .subheadline {
  margin: 0;
  outline: none;
  -webkit-user-select: text;
  user-select: text;
  border-radius: 6px;
  transition: background 120ms ease;
}
.caption .headline {
  font-size: 23px;
  font-weight: 760;
  letter-spacing: -0.035em;
  line-height: 1.12;
  margin-bottom: 9px;
}
.layout.bold-center .caption .headline { font-size: 27px; }
.layout.bleed .caption .headline { font-size: 25px; }
.caption .subheadline {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
}
.caption .headline:focus,
.caption .subheadline:focus,
.caption .kicker:focus {
  background: rgba(0, 0, 0, 0.22);
  box-shadow: 0 0 0 2px rgba(61, 184, 197, 0.55);
}
.caption.tone-dark .headline:focus,
.caption.tone-dark .subheadline:focus {
  background: rgba(255, 255, 255, 0.35);
}

.device-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 0;
  width: 100%;
}
.layout.bleed .device-wrap {
  align-items: flex-start;
  flex: 1;
  margin-top: 4px;
}
.layout.editorial .device-wrap { flex: 1; }
.layout.float .device-wrap { align-items: flex-start; padding-top: 4px; }

/* Real PNG device frames (iPhone / iPad) — screenshot under, bezel on top. */
.device {
  position: relative;
  flex-shrink: 0;
  width: 100%;
  aspect-ratio: 0.495;
  filter: drop-shadow(0 22px 40px rgba(0, 0, 0, 0.45));
}
.device.tablet {
  aspect-ratio: 0.767;
}
.device .frame-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
  z-index: 2;
  user-select: none;
}
.device .screen {
  position: absolute;
  z-index: 1;
  overflow: hidden;
  /* Fallback when JS hasn't set a device-specific radius yet */
  border-radius: 11.5% / 5.3%;
  isolation: isolate;
  background:
    linear-gradient(165deg, rgba(255, 255, 255, 0.08), transparent 40%),
    #14181f;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  color: rgba(255, 255, 255, 0.48);
  font-size: 11px;
  font-weight: 600;
}
.device.tablet .screen {
  border-radius: 3.6% / 2.8%;
}
.device .screen.has-image { background: #000; }
.device .screen .shot,
.device .screen img.shot {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: inherit;
}
.device .screen .drop-icon {
  width: 28px;
  height: 28px;
  opacity: 0.55;
}
/* Empty phone: one big, obvious action above the frame image. */
.device .empty-cta {
  position: absolute;
  inset: 18% 16%;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1.5px dashed rgba(255, 255, 255, 0.28);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.85);
  font: inherit;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}
.device .empty-cta:hover { background: rgba(83, 213, 253, 0.10); border-color: rgba(83, 213, 253, 0.7); }
.device .empty-cta:active { transform: scale(0.98); }
.device .empty-cta .plus {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(83, 213, 253, 0.18); color: #53d5fd;
  font-size: 22px; font-weight: 600; line-height: 1;
}
.device .empty-cta b { font-size: 13px; font-weight: 700; }
.device .empty-cta small { font-size: 10px; color: rgba(255, 255, 255, 0.5); }
.device.tablet .empty-cta { inset: 30% 26%; }
.device.drag-over .screen {
  outline: 2px dashed var(--accent);
  outline-offset: -3px;
}

.hint {
  margin: 12px 0 0;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  flex: 0 0 auto;
}

#export-root {
  position: fixed;
  left: -10000px;
  top: 0;
  pointer-events: none;
}

.export-slide {
  position: relative;
  overflow: hidden;
}
.export-slide .bg { position: absolute; inset: 0; }
.export-slide .layout {
  position: absolute;
  inset: 0;
  display: flex;
}
.export-slide .device { position: relative; }
.export-slide .device .screen { background: #14181f; }
.export-slide .device .screen .shot { width: 100%; height: 100%; object-fit: cover; }

/* ---- Edit / Preview mode toggle ---- */
.mode-seg {
  padding: 3px;
  gap: 3px;
}
.mode-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 5px 15px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
}
.mode-btn:hover { color: var(--text); }
.mode-btn.selected {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #061018;
}

.editor-body.hidden { display: none; }

/* ---- App Store horizontal preview gallery ---- */
.preview-strip {
  flex: 1;
  min-height: 0;
  overflow-x: auto;
  overflow-y: hidden;
  border-radius: 16px;
  border: 1px solid var(--border);
  background:
    radial-gradient(1000px 360px at 18% 0%, rgba(61, 184, 197, 0.07), transparent 55%),
    #080a0e;
}
.preview-strip.hidden { display: none; }
.preview-track {
  display: flex;
  align-items: center;
  justify-content: safe center;
  gap: 30px;
  height: 100%;
  width: max-content;
  min-width: 100%;
  padding: 30px 48px;
}
.preview-card {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 0;
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
}
.preview-holder {
  position: relative;
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.5);
  transition: transform 160ms ease, box-shadow 160ms ease;
}
.preview-card:hover .preview-holder {
  transform: translateY(-5px);
  box-shadow: 0 32px 62px rgba(0, 0, 0, 0.62);
}
.preview-holder .mini-slide {
  transform-origin: top left;
  pointer-events: none;
}
.preview-meta {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

/* ---- Slide rail: hover actions + drag reorder ---- */
.rail-thumb { position: relative; }
.rail-thumb .thumb-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.thumb-actions { display: none; gap: 4px; }
.rail-thumb:hover .thumb-actions,
.rail-thumb:focus-within .thumb-actions { display: flex; }
.mini-act {
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.45);
  color: var(--text);
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 11px;
  line-height: 1;
}
.mini-act:hover { border-color: var(--accent); }
.rail-thumb.dragging { opacity: 0.4; }
.rail-thumb.drag-over {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(61, 184, 197, 0.4);
}

/* ---- Layers list: drag reorder ---- */
.layer-row { user-select: none; }
.layer-row .grip {
  font-size: 11px;
  opacity: 0.4;
  cursor: grab;
}
.layer-row.dragging { opacity: 0.4; }
.layer-row.drag-over {
  border-color: rgba(83, 213, 253, 0.7);
  background: rgba(83, 213, 253, 0.18);
}

/* ---- Soft transitions: keep Edit/Preview switches + slide selection calm ---- */
@keyframes composeFade {
  from { opacity: 0; }
  to { opacity: 1; }
}
.focus-host > .slide { animation: composeFade 130ms ease; }
.preview-strip:not(.hidden) .preview-track { animation: composeFade 150ms ease; }
.editor-body:not(.hidden) { animation: composeFade 130ms ease; }
@media (prefers-reduced-motion: reduce) {
  .focus-host > .slide,
  .preview-strip:not(.hidden) .preview-track,
  .editor-body:not(.hidden) { animation: none; }
}

/* ===================================================================
   Midnight pass (Nov 2026): one calm editor in the app's own look.
   Slides run along the bottom like Keynote, the canvas gets the room,
   the layer list is gone (click the thing on the canvas to edit it),
   and controls use the app's sizes instead of 11px web chrome.
   =================================================================== */
:root {
  --bg: #0b0d16;
  --bg-elev: rgba(255, 255, 255, 0.05);
  --border: rgba(255, 255, 255, 0.08);
  --muted: rgba(255, 255, 255, 0.58);
  --grad: linear-gradient(100deg, #53d5fd 0%, #3f6ef5 52%, #8b4bf5 100%);
}

#app {
  border-radius: 18px;
  background:
    radial-gradient(800px 360px at 15% -15%, rgba(83, 213, 253, 0.07), transparent 60%),
    radial-gradient(700px 320px at 95% -10%, rgba(139, 75, 245, 0.08), transparent 55%),
    var(--bg);
}

button { font-size: 13px; padding: 7px 14px; }
button.primary {
  background: var(--grad);
  color: #fff;
  box-shadow: 0 6px 18px -8px rgba(63, 110, 245, 0.8);
}
button.ghost { border-color: rgba(255, 255, 255, 0.08); }

/* Toolbar */
.editor-chrome { gap: 8px; margin-bottom: 14px; }
.seg { font-size: 12px; padding: 4px 6px 4px 12px; border-color: rgba(255, 255, 255, 0.08); }
.seg select { font-size: 13px; }
.mode-seg { padding: 3px; gap: 2px; }
.mode-btn { font-size: 12px; }
.chip { font-size: 12px; }
#btn-add-slide { display: none; }

/* Layout: canvas + inspector on top, slides along the bottom */
.editor-body {
  grid-template-columns: minmax(320px, 1fr) minmax(240px, 280px);
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas:
    "canvas inspector"
    "strip strip";
  gap: 14px;
}
.canvas-pane { grid-area: canvas; }
.inspector { grid-area: inspector; }
.film-rail {
  grid-area: strip;
  flex-direction: row;
  align-items: stretch;
  gap: 10px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.03);
}
.film-rail > .rail-title { display: none; }
.film-rail-list {
  flex-direction: row;
  overflow-x: auto;
  overflow-y: hidden;
  gap: 10px;
  padding: 0 2px 2px 0;
  flex: 0 1 auto;
}
.rail-thumb { width: 78px; flex: 0 0 78px; padding: 4px; border-radius: 12px; }
.rail-thumb .thumb-preview { border-radius: 9px; margin-bottom: 4px; }
.rail-thumb .thumb-meta { font-size: 11px; display: flex; justify-content: space-between; align-items: center; }
.add-slide-btn {
  margin-top: 0;
  width: 78px;
  flex: 0 0 78px;
  display: grid;
  place-items: center;
  font-size: 12px;
  line-height: 1.3;
}

/* Inspector: style only */
.inspector > .rail-title:first-child,
#layer-list { display: none; }
.inspector-gap { margin-top: 0; padding-top: 0; border-top: 0; }
.rail-title { font-size: 12px; color: var(--muted); }
.inspector-empty { font-size: 13px; line-height: 1.45; }
.field span { font-size: 12px; }
.field select, .field textarea, .field input[type="number"] { font-size: 13px; }

.hint { font-size: 12px; }
.status { font-size: 13px; border-radius: 10px; }

/* Template gallery */
.phase-head h1 { font-size: 22px; letter-spacing: -0.02em; }
.phase-head p { font-size: 13px; max-width: 60ch; }
.template-grid { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 14px; }
.template-card { border-color: rgba(255, 255, 255, 0.06); padding: 10px 10px 12px; }
.template-card:hover {
  border-color: rgba(126, 166, 255, 0.55);
  box-shadow: 0 18px 40px -22px rgba(63, 110, 245, 0.9);
}
.template-card strong { font-size: 14px; }
.template-card span { font-size: 12px; }

/* The Mac app exports from its own toolbar (languages × devices); only the
   website, which has no such toolbar, shows the canvas's export button. */
html:not([data-host="web"]) #btn-export { display: none; }

/* Rare layer actions live behind "More". */
.more-actions { margin-top: 4px; }
.more-actions > summary {
  cursor: pointer;
  list-style: none;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  padding: 6px 2px;
}
.more-actions > summary::-webkit-details-marker { display: none; }
.more-actions > summary::before { content: "▸ "; }
.more-actions[open] > summary::before { content: "▾ "; }
.more-actions > .z-row { margin: 4px 0 8px; }
