:root {
  --ink: #0f0f0f;
  --ink-soft: #2a2a2a;
  --ink-muted: #6b6b6b;
  --ink-ghost: #9c9c9c;
  --cream: #fef9f3;
  --sand: #efe8df;
  --shell: #e8e0d4;
  --coral: #ff6b47;
  --coral-deep: #c7321a;
  --coral-mist: #ffeee8;
  --line: rgba(15, 15, 15, 0.06);
  --shadow-sm: 0 1px 2px rgba(15, 15, 15, 0.04);
  --shadow-md: 0 4px 14px rgba(15, 15, 15, 0.08);
  --shadow-lg: 0 20px 50px rgba(15, 15, 15, 0.18);
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  background: #faf6f0;
  color: var(--ink);
  font-family: 'Space Grotesk', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

body {
  display: grid;
  grid-template-columns: 340px 1fr;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 22px 20px 32px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 4px;
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--coral);
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 800;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: -0.03em;
}
.brand-title {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.03em;
}
.brand-sub {
  font-size: 10px;
  color: var(--ink-ghost);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-top: 2px;
}

.panel {
  display: flex;
  flex-direction: column;
}
.label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-ghost);
  margin-bottom: 10px;
}
.mini-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-ghost);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding-right: 8px;
  align-self: center;
}

/* Template category tabs */
.tmpl-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 10px;
}
.tmpl-tab {
  padding: 5px 10px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--line);
  background: #faf6ef;
  color: var(--ink-muted);
  border-radius: 999px;
  cursor: pointer;
}
.tmpl-tab.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

/* Templates grid */
.templates {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}

/* Image library */
.library {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 260px;
  overflow-y: auto;
}
.lib-group {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  background: #faf6ef;
}
.lib-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.lib-group-name {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-muted);
}
.lib-group-count {
  font-size: 10px;
  color: var(--ink-ghost);
  font-family: 'JetBrains Mono', monospace;
}
.lib-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}
.lib-thumb {
  aspect-ratio: 1 / 2;
  border-radius: 4px;
  border: 2px solid transparent;
  background: #fff;
  cursor: pointer;
  overflow: hidden;
  padding: 0;
  transition: transform 0.1s;
}
.lib-thumb:hover {
  transform: scale(1.05);
  border-color: var(--coral);
}
.lib-thumb.selected {
  border-color: var(--coral);
  box-shadow: 0 0 0 2px var(--coral-mist);
}
.lib-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.lib-empty {
  font-size: 11px;
  color: var(--ink-ghost);
  text-align: center;
  padding: 10px;
}
.tmpl {
  position: relative;
  aspect-ratio: 1 / 1.4;
  border-radius: 10px;
  border: 1.5px solid transparent;
  cursor: pointer;
  overflow: hidden;
  padding: 0;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s;
}
.tmpl:hover {
  transform: translateY(-1px);
}
.tmpl.active {
  border-color: var(--coral);
  box-shadow: 0 0 0 3px var(--coral-mist);
}
.tmpl-preview {
  position: absolute;
  inset: 0;
}
.tmpl-name {
  position: absolute;
  left: 6px;
  bottom: 5px;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 6px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--ink);
  letter-spacing: -0.01em;
}

/* Dropzone */
.dropzone {
  display: block;
  cursor: pointer;
  border: 1.5px dashed #d9d1c4;
  border-radius: var(--radius);
  padding: 22px;
  text-align: center;
  color: var(--ink-muted);
  background: #faf6ef;
  transition: all 0.15s ease;
}
.dropzone:hover,
.dropzone.drag {
  border-color: var(--coral);
  background: var(--coral-mist);
  color: var(--coral-deep);
}
.dropzone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 500;
}
.thumb {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 10px;
  background: #faf6ef;
  border: 1px solid var(--line);
}
.thumb img {
  width: 34px;
  height: 54px;
  object-fit: cover;
  border-radius: 6px;
  background: #000;
}
.thumb .thumb-meta {
  font-size: 11px;
  color: var(--ink-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.thumb .thumb-clear {
  background: none;
  border: none;
  color: var(--ink-ghost);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.thumb .thumb-clear:hover {
  color: var(--coral-deep);
  background: var(--coral-mist);
}

.mini-btn {
  background: #faf6ef;
  border: 1px dashed var(--line);
  padding: 8px 10px;
  font-family: inherit;
  font-size: 11px;
  color: var(--ink-muted);
  border-radius: 8px;
  cursor: pointer;
  width: 100%;
}
.mini-btn:hover {
  border-color: var(--coral);
  color: var(--coral-deep);
}

/* Segmented */
.seg {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  background: #f2ece1;
  padding: 3px;
  border-radius: 10px;
  flex: 1;
}
.seg-grid {
  grid-template-columns: repeat(2, 1fr);
}
.seg-icons {
  grid-template-columns: repeat(6, 1fr);
  padding: 4px;
}
.font-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 5px;
}

/* Text style swatches */
.text-styles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}
.ts-chip {
  position: relative;
  padding: 14px 10px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #faf6ef;
  cursor: pointer;
  overflow: hidden;
  text-align: left;
  line-height: 1;
  height: 64px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  transition: all 0.12s;
}
.ts-chip:hover {
  border-color: var(--coral);
  background: #fff;
  transform: translateY(-1px);
}
.ts-chip.active {
  border-color: var(--coral);
  background: var(--coral-mist);
  box-shadow: 0 0 0 2px var(--coral-mist);
}
.ts-chip .ts-head {
  color: var(--ink);
  font-size: 15px;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ts-chip .ts-label {
  font-family: 'Inter', sans-serif;
  font-size: 9px;
  font-weight: 700;
  color: var(--ink-ghost);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Text case + tracking modifiers applied via JS classes */
.preview.case-upper .copy-head {
  text-transform: uppercase;
}
.preview.case-lower .copy-head {
  text-transform: lowercase;
}
.preview.tracking-tight .copy-head {
  letter-spacing: -0.06em;
}
.preview.tracking-wide .copy-head {
  letter-spacing: 0.04em;
}
.preview.weight-light .copy-head {
  font-weight: 300;
}
.preview.weight-normal .copy-head {
  font-weight: 500;
}
.preview.italic .copy-head {
  font-style: italic;
}
.font-chip {
  padding: 9px 8px;
  font-size: 13px;
  border: 1px solid var(--line);
  background: #faf6ef;
  color: var(--ink);
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.12s;
  text-align: center;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.font-chip:hover {
  border-color: var(--coral);
  background: #fff;
}
.font-chip.active {
  border-color: var(--coral);
  background: var(--coral-mist);
  color: var(--coral-deep);
  box-shadow: 0 0 0 1px var(--coral);
}
.seg-icons .seg-btn {
  aspect-ratio: 1;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.seg-icons .seg-btn svg {
  width: 16px;
  height: 16px;
  stroke-width: 2;
  stroke: currentColor;
  fill: none;
}
.seg-btn {
  background: transparent;
  border: none;
  padding: 7px 4px;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-muted);
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s;
}
.seg-btn:hover {
  color: var(--ink);
}
.seg-btn.active {
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.input {
  width: 100%;
  background: #faf6ef;
  border: 1px solid var(--line);
  padding: 10px 12px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
}
.input:focus {
  outline: none;
  border-color: var(--coral);
  background: #fff;
}
.row {
  display: flex;
  gap: 8px;
}

/* Background tabs + swatches */
.bg-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
}
.bg-tab {
  flex: 1;
  padding: 6px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #faf6ef;
  color: var(--ink-muted);
  cursor: pointer;
  font-family: inherit;
}
.bg-tab.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.swatches {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.swatch {
  aspect-ratio: 1 / 1.3;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06), var(--shadow-sm);
  transition: transform 0.15s;
}
.swatch:hover {
  transform: translateY(-1px);
}
.swatch.active::after {
  content: '';
  position: absolute;
  inset: -3px;
  border: 2px solid var(--coral);
  border-radius: 13px;
}

.check {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--ink-muted);
  cursor: pointer;
  user-select: none;
}
.check input {
  width: 14px;
  height: 14px;
  accent-color: var(--coral);
}

.export {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  border-radius: 12px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}
.btn-primary {
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow-md);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}
.btn-ghost {
  background: transparent;
  color: var(--ink-muted);
  margin-top: 8px;
}
.btn-ghost:hover {
  color: var(--ink);
  background: #faf6ef;
}
.hint {
  font-size: 11px;
  color: var(--ink-ghost);
  margin: 10px 0 0;
  line-height: 1.5;
}

/* ==================== STAGE ==================== */
.stage {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 30% 20%, #fff 0%, #f2ece1 70%);
}
.stage-toolbar {
  height: 52px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(10px);
}
.meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  color: var(--ink-muted);
}
.dot {
  color: var(--ink-ghost);
}
.zoom {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  color: var(--ink-muted);
}
.icon-btn {
  width: 26px;
  height: 26px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
}
/* Screen strip (multi-screen navigator) */
.screen-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 96px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(6px);
}
.strip-scroll {
  display: flex;
  gap: 10px;
  flex: 1;
  overflow-x: auto;
  padding: 2px;
}
.strip-scroll::-webkit-scrollbar {
  height: 6px;
}
.strip-scroll::-webkit-scrollbar-thumb {
  background: #d8cfc0;
  border-radius: 3px;
}
.strip-item {
  position: relative;
  width: 52px;
  height: 76px;
  border-radius: 10px;
  border: 2px solid transparent;
  flex-shrink: 0;
  cursor: pointer;
  background: #fff;
  overflow: hidden;
  padding: 0;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s;
}
.strip-item:hover {
  transform: translateY(-1px);
}
.strip-item.active {
  border-color: var(--coral);
  box-shadow: 0 0 0 2px var(--coral-mist), var(--shadow-md);
}
.strip-thumb {
  width: 100%;
  height: 100%;
  display: block;
}
.strip-index {
  position: absolute;
  top: 2px;
  left: 3px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.85);
  color: var(--ink);
}
.strip-actions {
  position: absolute;
  top: 2px;
  right: 2px;
  display: none;
  gap: 2px;
}
.strip-item:hover .strip-actions {
  display: flex;
}
.strip-action {
  width: 16px;
  height: 16px;
  border: none;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 4px;
  color: var(--ink-muted);
  font-size: 10px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.strip-action:hover {
  background: var(--coral);
  color: #fff;
}
.strip-add {
  width: 52px;
  height: 76px;
  border: 2px dashed #d8cfc0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-ghost);
  font-size: 24px;
  font-weight: 300;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
  font-family: inherit;
}
.strip-add:hover {
  border-color: var(--coral);
  color: var(--coral-deep);
  background: var(--coral-mist);
}

.stage-inner {
  flex: 1;
  padding: 0;
  overflow: hidden;
  position: relative;
}

/* Floating chip on phone */
.chip {
  position: absolute;
  top: 110px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 32px;
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(20px);
  border: 1.5px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  z-index: 4;
  font-family: 'Inter', sans-serif;
  font-size: 28px;
  font-weight: 600;
  color: #fff;
}
.preview.text-dark .chip {
  background: rgba(255, 255, 255, 0.8);
  border-color: rgba(0, 0, 0, 0.08);
  color: var(--ink);
}
.chip svg {
  width: 32px;
  height: 32px;
  stroke-width: 2;
  stroke: currentColor;
  fill: none;
}
.stage-inner .preview-host {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1284px;
  height: 2778px;
  transform: translate(-50%, -50%) scale(var(--stage-scale, 1));
  transform-origin: center center;
}

/* ==================== PREVIEW ==================== */
.preview {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 40px;
  box-shadow: var(--shadow-lg);
  isolation: isolate;
  background: #fff;
}

/* Background layer — dynamically set via JS */
.bg-layer {
  position: absolute;
  inset: 0;
  z-index: 0;
}

/* Mesh blobs */
.mesh-layer {
  position: absolute;
  inset: 0;
  opacity: 0.4;
  filter: blur(100px);
  pointer-events: none;
  z-index: 1;
}
.mesh-layer.hidden {
  display: none;
}
.blob {
  position: absolute;
  border-radius: 50%;
}
.blob-a {
  width: 800px;
  height: 800px;
  top: -200px;
  left: -200px;
  background: rgba(255, 255, 255, 0.45);
}
.blob-b {
  width: 600px;
  height: 600px;
  bottom: -100px;
  right: -100px;
  background: rgba(255, 255, 255, 0.3);
}
.blob-c {
  width: 500px;
  height: 500px;
  top: 35%;
  left: 55%;
  background: rgba(0, 0, 0, 0.12);
}

/* Noise */
.noise-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.28;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence baseFrequency='0.95' seed='5' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.7 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  z-index: 1;
}
.noise-layer.hidden {
  display: none;
}

/* ==================== COPY ==================== */
.copy-layer {
  position: absolute;
  z-index: 3;
  pointer-events: none;
}
.copy-block {
  display: flex;
  flex-direction: column;
  gap: 24px;
  pointer-events: auto;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  padding: 16px;
  margin: -16px;
  border-radius: 14px;
  transition: outline 0.1s;
  outline: 2px dashed transparent;
}
.copy-block:hover {
  outline-color: rgba(255, 107, 71, 0.4);
}
.copy-block.dragging {
  cursor: grabbing;
  outline-color: var(--coral);
}
.copy-block.editing {
  cursor: text;
  outline-color: var(--coral);
  outline-style: solid;
}
.copy-block.editing .copy-head,
.copy-block.editing .copy-sub {
  cursor: text;
  user-select: text;
  -webkit-user-select: text;
}
.copy-head[contenteditable='true'],
.copy-sub[contenteditable='true'] {
  outline: none;
  cursor: text;
}

/* Centering guides */
.guide {
  position: absolute;
  background: repeating-linear-gradient(
    0deg,
    var(--coral) 0 8px,
    transparent 8px 16px
  );
  pointer-events: none;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.08s;
}
.guide-v {
  top: 0;
  bottom: 0;
  left: 50%;
  width: 3px;
  transform: translateX(-50%);
  background: repeating-linear-gradient(0deg, var(--coral) 0 8px, transparent 8px 16px);
}
.guide-h {
  left: 0;
  right: 0;
  top: 50%;
  height: 3px;
  transform: translateY(-50%);
  background: repeating-linear-gradient(90deg, var(--coral) 0 8px, transparent 8px 16px);
}
.guide.visible {
  opacity: 0.85;
}
.copy-head {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 800;
  letter-spacing: -0.045em;
  margin: 0;
  color: #fff;
  line-height: 0.95;
}
.copy-sub {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.01em;
  margin: 0;
  color: rgba(255, 255, 255, 0.85);
}
.copy-sub:empty {
  display: none;
}

/* Font variants */
.preview.font-inter .copy-head {
  font-family: 'Inter', sans-serif;
  font-weight: 800;
  letter-spacing: -0.04em;
}
.preview.font-inter .copy-sub {
  font-family: 'Inter', sans-serif;
}
.preview.font-grotesk .copy-head {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  letter-spacing: -0.04em;
}
.preview.font-grotesk .copy-sub {
  font-family: 'Space Grotesk', sans-serif;
}
.preview.font-outfit .copy-head {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  letter-spacing: -0.035em;
}
.preview.font-outfit .copy-sub {
  font-family: 'Outfit', sans-serif;
}
.preview.font-jakarta .copy-head {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 800;
  letter-spacing: -0.035em;
}
.preview.font-jakarta .copy-sub {
  font-family: 'Plus Jakarta Sans', sans-serif;
}
.preview.font-archivo .copy-head {
  font-family: 'Archivo', sans-serif;
  font-weight: 800;
  letter-spacing: -0.04em;
  text-transform: uppercase;
}
.preview.font-archivo .copy-sub {
  font-family: 'Archivo', sans-serif;
}
.preview.font-serif .copy-head {
  font-family: 'Instrument Serif', serif;
  font-weight: 400;
  font-style: italic;
  letter-spacing: -0.02em;
}
.preview.font-playfair .copy-head {
  font-family: 'Playfair Display', serif;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.preview.font-playfair .copy-sub {
  font-family: 'Playfair Display', serif;
}
.preview.font-dm-serif .copy-head {
  font-family: 'DM Serif Display', serif;
  font-weight: 400;
  letter-spacing: -0.015em;
}
.preview.font-dm-serif .copy-sub {
  font-family: 'DM Serif Display', serif;
}
.preview.font-fraunces .copy-head {
  font-family: 'Fraunces', serif;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.preview.font-fraunces .copy-sub {
  font-family: 'Fraunces', serif;
}
.preview.font-crimson .copy-head {
  font-family: 'Crimson Pro', serif;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.preview.font-crimson .copy-sub {
  font-family: 'Crimson Pro', serif;
}
.preview.font-caveat .copy-head {
  font-family: 'Caveat', cursive;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.05;
}
.preview.font-caveat .copy-sub {
  font-family: 'Caveat', cursive;
}
.preview.font-mono .copy-head {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  letter-spacing: -0.04em;
}
.preview.font-mono .copy-sub {
  font-family: 'JetBrains Mono', monospace;
}

/* Text size (set by JS class) */
.preview.text-sm .copy-head {
  font-size: 70px;
}
.preview.text-sm .copy-sub {
  font-size: 30px;
}
.preview.text-md .copy-head {
  font-size: 110px;
}
.preview.text-md .copy-sub {
  font-size: 38px;
}
.preview.text-lg .copy-head {
  font-size: 150px;
}
.preview.text-lg .copy-sub {
  font-size: 46px;
}

/* Text color (applied via JS class) */
.preview.text-dark .copy-head {
  color: var(--ink);
}
.preview.text-dark .copy-sub {
  color: var(--ink-muted);
}
.preview.text-light .copy-head {
  color: #fff;
}
.preview.text-light .copy-sub {
  color: rgba(255, 255, 255, 0.85);
}

/* Align */
.preview.align-center .copy-block {
  text-align: center;
  align-items: center;
}
.preview.align-left .copy-block {
  text-align: left;
  align-items: flex-start;
}

/* ==================== DEVICE (iPhone 15 Pro style) ==================== */
.screen-wrap {
  position: absolute;
  z-index: 2;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.screen-wrap:active,
.screen-wrap.dragging {
  cursor: grabbing;
}

/* Resize handles (visible on hover/active) */
.handle {
  position: absolute;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--coral);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s;
  z-index: 10;
}
.screen-wrap:hover .handle,
.screen-wrap.dragging .handle,
.screen-wrap.resizing .handle {
  opacity: 1;
  pointer-events: auto;
}
.handle-nw {
  top: -30px;
  left: -30px;
  cursor: nwse-resize;
}
.handle-ne {
  top: -30px;
  right: -30px;
  cursor: nesw-resize;
}
.handle-sw {
  bottom: -30px;
  left: -30px;
  cursor: nesw-resize;
}
.handle-se {
  bottom: -30px;
  right: -30px;
  cursor: nwse-resize;
}

/* Reset button */
.reset-pos {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 20;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  box-shadow: var(--shadow-sm);
}
.preview-host:hover .reset-pos {
  opacity: 1;
}
.reset-pos:hover {
  color: var(--coral-deep);
  border-color: var(--coral);
}
/* Real-ish proportions: 720px wide, 24px chassis bezel, 4px titanium rim,
   internal screen corner radius ~50px, chassis corner radius ~74px. */
.device {
  width: 720px;
  position: relative;
  box-sizing: content-box;
}
.device-body {
  position: relative;
  background: linear-gradient(145deg, #1c1c1e 0%, #060607 50%, #1c1c1e 100%);
  border-radius: 78px;
  padding: 14px;
  box-shadow:
    0 50px 100px rgba(0, 0, 0, 0.35),
    0 0 0 1.5px #3a3a3c inset,
    0 2px 1px rgba(255, 255, 255, 0.08) inset,
    0 -2px 1px rgba(0, 0, 0, 0.5) inset;
}
/* Inner bezel ring */
.device-body::before {
  content: '';
  position: absolute;
  inset: 10px;
  border-radius: 70px;
  background: #000;
  z-index: 0;
  box-shadow: 0 0 0 2px #2a2a2c inset;
}
.device-body::after {
  /* Subtle light reflection on rim */
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 78px;
  background: linear-gradient(125deg, transparent 40%, rgba(255, 255, 255, 0.04) 50%, transparent 60%);
  pointer-events: none;
  z-index: 3;
}
.device-screen {
  position: relative;
  aspect-ratio: 1284 / 2778;
  border-radius: 60px;
  overflow: hidden;
  background: #fff8ef;
  z-index: 1;
}

/* Dynamic Island */
.device-island {
  position: absolute;
  top: 32px;
  left: 50%;
  transform: translateX(-50%);
  width: 210px;
  height: 50px;
  background: #000;
  border-radius: 28px;
  z-index: 4;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset, 0 0 0 1px #0a0a0a;
}

/* Side buttons */
.btn-side {
  position: absolute;
  background: linear-gradient(90deg, #2a2a2c 0%, #111 50%, #2a2a2c 100%);
  z-index: 2;
}
.btn-mute {
  left: -5px;
  top: 120px;
  width: 5px;
  height: 32px;
  border-radius: 1px 0 0 1px;
}
.btn-vol-up {
  left: -5px;
  top: 180px;
  width: 5px;
  height: 92px;
  border-radius: 2px 0 0 2px;
}
.btn-vol-down {
  left: -5px;
  top: 290px;
  width: 5px;
  height: 92px;
  border-radius: 2px 0 0 2px;
}
.btn-power {
  right: -5px;
  top: 220px;
  width: 5px;
  height: 130px;
  border-radius: 0 2px 2px 0;
}

/* Frame variants */
.device.frame-none .device-body {
  background: transparent;
  padding: 0;
  border-radius: 60px;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.22);
}
.device.frame-none .device-body::before,
.device.frame-none .device-body::after {
  display: none;
}
.device.frame-none .device-screen {
  border-radius: 60px;
}
.device.frame-none .btn-side,
.device.frame-none .device-island {
  display: none;
}
.device.frame-thin .device-island {
  display: block;
}
.device.frame-notch .device-island {
  display: block;
}
.device.frame-outline .device-body {
  background: transparent;
  border: 3px solid #0a0a0a;
  padding: 12px;
  box-shadow: none;
}
.device.frame-outline .device-body::before,
.device.frame-outline .device-body::after {
  display: none;
}
.device.frame-outline .device-screen {
  border-radius: 58px;
}
.device.frame-outline .btn-side,
.device.frame-outline .device-island {
  display: none;
}
.screen-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--ink-ghost);
  font-size: 28px;
  font-weight: 600;
  background: repeating-linear-gradient(45deg, rgba(0, 0, 0, 0.04) 0 20px, transparent 20px 40px), #faf3e8;
  text-align: center;
  padding: 40px;
}
.placeholder-sub {
  font-size: 20px;
  font-weight: 400;
  color: var(--ink-ghost);
  opacity: 0.7;
}
.screen-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.hidden {
  display: none !important;
}

/* Secondary device (multi layout) */
.device-2 {
  width: 620px;
}

/* ==================== LAYOUTS ====================
   Positioning is handled per-layout. Each layout sets:
    - .copy-layer inset
    - .screen-wrap inset/transform
    - Secondary device visibility + position
*/

/* Layout: TOP — text at top, phone centered lower */
.preview.layout-top .copy-layer {
  top: 140px;
  left: 80px;
  right: 80px;
}
.preview.layout-top .screen-wrap {
  top: 48%;
  left: 50%;
  transform: translate(-50%, -45%);
}

/* Layout: CENTER — phone centered, text overlays above (small) */
.preview.layout-center .copy-layer {
  top: 90px;
  left: 80px;
  right: 80px;
}
.preview.layout-center .screen-wrap {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -45%);
}

/* Layout: SPLIT — text left half, phone right half */
.preview.layout-split .copy-layer {
  top: 50%;
  left: 80px;
  right: 50%;
  transform: translateY(-50%);
  padding-right: 40px;
}
.preview.layout-split .screen-wrap {
  top: 50%;
  left: 65%;
  transform: translate(-50%, -50%);
}

/* Layout: TILT — phone rotated + cropped off edge */
.preview.layout-tilt .copy-layer {
  top: 110px;
  left: 80px;
  right: 80px;
}
.preview.layout-tilt .screen-wrap {
  top: 60%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-10deg);
}
.preview.layout-tilt .device {
  width: 820px;
}

/* Layout: BAND — color band at top 35%, phone below on white */
.preview.layout-band .copy-layer {
  top: 130px;
  left: 80px;
  right: 80px;
}
.preview.layout-band .screen-wrap {
  top: 62%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.preview.layout-band .band-fill {
  position: absolute;
  inset: 0 0 65% 0;
  z-index: 0;
}

/* Layout: MULTI — two phones, one tilted */
.preview.layout-multi .copy-layer {
  top: 140px;
  left: 80px;
  right: 80px;
}
.preview.layout-multi .screen-wrap {
  top: 58%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 55%;
}
.preview.layout-multi #device {
  position: absolute;
  top: 50%;
  left: 36%;
  transform: translate(-50%, -50%) rotate(-6deg);
  width: 600px;
  z-index: 1;
}
.preview.layout-multi #device2 {
  position: absolute;
  top: 50%;
  left: 64%;
  transform: translate(-50%, -50%) rotate(6deg);
  z-index: 2;
  display: block;
}

/* FEATURED badge */
.badge {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  padding: 16px 40px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.08);
  color: var(--ink);
  font-family: 'JetBrains Mono', monospace;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0.3em;
  z-index: 3;
}
.preview.badge-light .badge {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}
