/* Original Garet Book/Heavy webfonts from Type Forward; see assets/fonts/garet/SOURCE.md. */
@font-face {
  font-family: "Garet";
  src: url("/assets/fonts/garet/Garet-Book.woff2") format("woff2");
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Garet";
  src: url("/assets/fonts/garet/Garet-Heavy.woff2") format("woff2");
  font-weight: 850;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #080611;
  color: #f8f7ff;
  --panel: rgba(25, 21, 45, 0.82);
  --panel-border: rgba(255, 255, 255, 0.11);
  --muted: #aaa6bb;
  --violet: #8157ff;
  --pink: #ef4ac5;
  --success: #43d59f;
  --danger: #ff7791;
}

html,
body {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden;
  overflow-x: clip;
  overscroll-behavior-x: none;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100svh;
  touch-action: manipulation;
  background:
    radial-gradient(circle at 12% 0%, rgba(128, 78, 255, 0.22), transparent 36rem),
    radial-gradient(circle at 100% 28%, rgba(239, 74, 197, 0.12), transparent 31rem),
    #080611;
}

html.is-text-editing {
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
}

body.is-text-editing {
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
}

html.is-text-editing .story-frame {
  position: fixed;
  z-index: 10;
  top: var(--story-editor-top);
  left: var(--story-editor-left);
  width: var(--story-editor-width);
  height: var(--story-editor-height);
  max-width: none;
  aspect-ratio: auto;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(100%, 1060px);
  max-width: 100%;
  min-width: 0;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px max(32px, env(safe-area-inset-bottom));
  overflow-x: hidden;
  touch-action: pan-x pan-y;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 54px;
}

.brand-mark {
  position: relative;
  width: 36px;
  height: 36px;
  border: 2px solid #8c61ff;
  border-radius: 50%;
  transform: rotate(-19deg);
}

.brand-mark::before,
.brand-mark::after,
.brand-mark span {
  content: "";
  position: absolute;
  border-radius: 50%;
}

.brand-mark::before {
  inset: 8px;
  background: linear-gradient(145deg, #ffbd35, #ff7046);
}

.brand-mark::after {
  left: -6px;
  right: -6px;
  top: 15px;
  height: 2px;
  background: #8c61ff;
}

.eyebrow {
  margin: 0 0 1px;
  color: #9c8ed1;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.18em;
}

h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.05;
}

.stage-pill {
  margin-left: auto;
  padding: 8px 11px;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  color: #c8c3d9;
  font-size: 12px;
  font-weight: 700;
}

.template-picker {
  margin: 26px 0 10px;
  max-width: 100%;
  min-width: 0;
  overflow-x: clip;
}

.template-picker h2 {
  margin-bottom: 16px;
  font-size: clamp(26px, 5vw, 38px);
}

.template-carousel {
  display: flex;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  gap: 14px;
  padding: 2px 2px 12px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scroll-padding-inline: 2px;
  overscroll-behavior-x: contain;
  overscroll-behavior-y: auto;
  scrollbar-width: none;
  touch-action: pan-x pan-y;
  -webkit-overflow-scrolling: touch;
}

.template-carousel::-webkit-scrollbar {
  display: none;
}

.template-card {
  position: relative;
  flex: 0 0 clamp(154px, 28vw, 214px);
  padding: 7px 7px 13px;
  border: 2px solid transparent;
  border-radius: 20px;
  background: rgba(25, 21, 45, 0.82);
  color: #f8f7ff;
  text-align: left;
  scroll-snap-align: start;
  scroll-snap-stop: normal;
  user-select: none;
  -webkit-user-select: none;
  transition: border-color 160ms ease, background-color 160ms ease;
  cursor: pointer;
}

.template-card img {
  display: block;
  width: 100%;
  aspect-ratio: 9 / 16;
  object-fit: cover;
  border-radius: 14px;
  -webkit-user-drag: none;
}

.template-card strong,
.template-card span {
  display: block;
  padding-inline: 5px;
}

.template-card strong {
  margin-top: 10px;
  font-size: 14px;
}

.template-card span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.template-card.is-active {
  border-color: #9b75ff;
  box-shadow: 0 0 0 3px rgba(129, 87, 255, 0.18);
}

.template-card.is-active span {
  color: #bca8ff;
  font-weight: 800;
}

.step {
  margin: 0 0 9px;
  color: #9b7cff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h2 {
  margin: 0;
  font-size: clamp(34px, 7vw, 54px);
  letter-spacing: -0.045em;
}

.workspace {
  display: grid;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  gap: 30px;
  align-items: start;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.upload-column {
  display: grid;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  gap: 15px;
  align-content: start;
  padding-top: 3px;
}

.upload-options {
  display: grid;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.upload-card {
  display: grid;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  place-items: center;
  min-height: 230px;
  padding: 28px 16px;
  border: 1px dashed rgba(173, 145, 255, 0.55);
  border-radius: 22px;
  background: rgba(129, 87, 255, 0.07);
  text-align: center;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.upload-card:hover,
.upload-card.is-dragging {
  border-color: #b79cff;
  background: rgba(129, 87, 255, 0.13);
  transform: translateY(-1px);
}

.upload-card input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-icon {
  display: grid;
  place-items: center;
  width: 55px;
  height: 55px;
  margin-bottom: 18px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--violet), var(--pink));
  font-size: 32px;
  line-height: 1;
  box-shadow: 0 13px 34px rgba(129, 87, 255, 0.3);
}

.upload-card strong {
  font-size: 18px;
}

.upload-card small {
  margin-top: 8px;
  color: var(--muted);
}

.source-preview {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 13px;
  align-items: center;
  padding: 11px;
  border: 1px solid var(--panel-border);
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.04);
}

.source-preview img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 12px;
}

.source-preview strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-button {
  margin-top: 7px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #ad97ff;
  font-weight: 700;
  cursor: pointer;
}

.system-status {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 24px;
  color: var(--muted);
  font-size: 13px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #8e899b;
}

.system-status.is-ready .status-dot {
  background: var(--success);
  box-shadow: 0 0 0 5px rgba(67, 213, 159, 0.1);
}

.system-status.is-error .status-dot {
  background: var(--danger);
}

.generate-button {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 56px;
  border: 0;
  border-radius: 17px;
  background: linear-gradient(115deg, var(--violet), var(--pink));
  color: white;
  font-size: 17px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 14px 34px rgba(130, 66, 247, 0.26);
}

.generate-button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.6);
  opacity: 0.42;
  box-shadow: none;
}

/* Keep cost accounting and automatic family copy mounted, without intermediate UI. */
#generation-cost,
#brand-story-copy {
  display: none !important;
}

.result-column {
  display: grid;
  max-width: 100%;
  min-width: 0;
  gap: 11px;
}

.story-frame {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 9 / 16;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 20px;
  background: #100c24;
  box-shadow: 0 20px 55px rgba(0, 0, 0, 0.34);
  touch-action: manipulation;
}

.template-chrome,
.template-text-host {
  position: absolute;
  inset: 0;
}

.template-chrome {
  z-index: 1;
  pointer-events: none;
}

.template-text-host {
  z-index: 2;
  pointer-events: none;
}

/* Artwork uses project typography. Browser text-only zoom/autosizing must not
   change glyphs independently of the photo and masks. Keep the surrounding
   editor controls and conversation subject to the user's accessibility zoom. */
.story-frame :is(.story-text, .template-text-host, .template-chrome),
.story-frame :is(.story-text, .template-text-host, .template-chrome) * {
  -webkit-text-zoom: reset;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
}

/* Editor controls must stay above text, artwork and CTA in every template. */
.story-frame > div[data-template-product-ui] {
  z-index: 30;
}

.template-copy-layer {
  position: absolute;
  display: flex;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  white-space: pre-wrap;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
  overflow: visible;
  pointer-events: auto;
  touch-action: none;
  cursor: grab;
}

.template-copy-layer[data-vertical-align="center"] {
  align-items: center;
}

.template-copy-layer > span {
  display: block;
  width: 100%;
}

.template-chrome-piece {
  position: absolute;
  pointer-events: none;
}

.template-chrome [data-template-color-key] {
  pointer-events: auto;
  cursor: pointer;
  touch-action: manipulation;
}

.template-chrome [data-template-color-key]:focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 3px;
}

html.is-text-editing .template-chrome [data-template-color-key] {
  pointer-events: none;
}

.template-element-color-picker {
  position: fixed;
  z-index: -1;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.gold-frame-shadow {
  border-radius: 2px;
}

.gold-frame {
  border-style: solid;
  background: transparent;
}

.gold-tape {
  opacity: 0.78;
  filter: saturate(0.55);
  transform-origin: center;
}

.gold-cta-shape {
  border-radius: 999px;
}

.template-002-canvas {
  background: #fff;
}

.template-002-window {
  position: absolute;
  overflow: hidden;
}

.template-002-window img {
  position: absolute;
  display: block;
  max-width: none;
  object-fit: fill;
}

.template-002-panel {
  position: absolute;
  overflow: hidden;
  background: #cdd3d8;
}

.template-002-branch {
  position: absolute;
  width: 58%;
  height: 34%;
  border: 7px solid currentColor;
  border-color: currentColor transparent transparent;
  border-radius: 50%;
  color: #414c54;
  filter: blur(4px);
  opacity: 0.13;
  transform: rotate(-28deg);
}

.template-002-branch::before,
.template-002-branch::after {
  content: "";
  position: absolute;
  width: 24%;
  height: 48%;
  border-radius: 80% 10% 80% 10%;
  background: currentColor;
}

.template-002-branch::before {
  left: 18%;
  top: -20%;
  transform: rotate(-24deg);
}

.template-002-branch::after {
  right: 18%;
  top: -14%;
  transform: rotate(34deg);
}

.template-002-divider {
  height: 1px;
  background: #000;
}

.canvas-background-control {
  position: absolute;
  /* Keep brand colors above artwork, active text and product effect menus. */
  z-index: 31;
  top: auto;
  bottom: 12px;
  left: 12px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 8px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.84);
  color: #111;
  font-size: 12px;
  font-weight: 800;
  backdrop-filter: blur(10px);
  box-shadow: 0 5px 18px rgba(0, 0, 0, 0.14);
}

.brand-color-field {
  display: grid;
  justify-items: center;
  gap: 1px;
  line-height: 1;
}

.brand-color-field small {
  font-size: 9px;
  font-weight: 800;
}

.canvas-background-control input {
  width: 28px;
  height: 28px;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 50%;
  background: transparent;
}

.story-text {
  position: absolute;
  z-index: 10;
  box-sizing: border-box;
  left: 3.5%;
  top: 50%;
  max-width: 94%;
  padding: 5px 8px;
  color: #fff;
  font-size: 30px;
  font-weight: 800;
  line-height: 1.02;
  text-align: left;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.72);
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
  overflow: visible;
  transform: translateY(-50%);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}

.story-text > span {
  display: inline-block;
  min-width: 2ch;
  min-height: 1.05em;
  outline: 0;
  white-space: inherit;
}

/* A manual scale freezes the actual rendered lines, then expands the whole box. */
[data-manual-text-layout="true"] > span {
  white-space: pre;
  overflow-wrap: normal;
}

/* Selected template labels keep the exact same box layout as their preview. */
.story-text.is-template-text {
  display: flex;
  white-space: pre-wrap;
}

.story-text.is-template-text > span {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 0;
}

.story-text.is-editing {
  z-index: 12;
  pointer-events: none;
}

.story-text.is-moving {
  cursor: grabbing;
}

.canvas-add-text,
.canvas-done {
  position: absolute;
  z-index: 13;
  top: 14px;
  right: 14px;
  border: 0;
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.canvas-add-text {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(8, 7, 14, 0.68);
  font-size: 18px;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(12px);
}

.canvas-undo {
  position: absolute;
  top: 136px;
  right: 14px;
  z-index: 12;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  background: rgba(35, 35, 40, 0.8);
  color: #fff;
  touch-action: manipulation;
}
.canvas-undo svg { width: 100%; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.canvas-trash {
  position: fixed;
  z-index: 40;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  padding: 15px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  background: rgba(25, 24, 30, 0.9);
  color: #fff;
  transform: translateX(-50%);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(12px);
  pointer-events: none;
}
.canvas-trash svg { width: 100%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.canvas-trash.is-over { background: #d62d51; border-color: #fff; box-shadow: 0 0 0 8px rgba(214, 45, 81, 0.25); }
html.is-text-editing .canvas-trash { display: none; }
.gold-cta-shape, .template-003-cta, .template-004-cta, .template-005-cta, .template-006-cta, .cutout-series-cta { touch-action: none !important; cursor: grab; }
.canvas-undo:disabled { opacity: 0.35; }
.canvas-undo[hidden], html.is-text-editing .canvas-undo { display: none; }
.story-frame img[data-product-transform-id] { touch-action: manipulation !important; user-select: none; -webkit-user-select: none; -webkit-user-drag: none; -webkit-touch-callout: none; cursor: grab; }
.story-frame img[data-product-transform-id].is-product-moving { cursor: grabbing; }
.story-frame img.is-product-picked-up { animation: product-pick-up 180ms ease-out; }
@keyframes product-pick-up { 0%, 100% { opacity: 1; } 45% { opacity: 0.82; } }

/* Native vertical scrolling belongs to the unrotated story frame. A child
   must not rotate that axis or disable it before the short hold is resolved. */
.story-frame .story-text, .story-frame .story-text *,
.story-frame .template-copy-layer, .story-frame .template-copy-layer *,
.story-frame .template-chrome, .story-frame .template-chrome * {
  touch-action: manipulation !important;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.story-frame .is-element-picked-up { animation: product-pick-up 180ms ease-out; }

.canvas-cta-toggle {
  position: absolute;
  z-index: 13;
  top: 68px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 46px;
  min-height: 50px;
  padding: 5px 3px 4px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 15px;
  background: rgba(8, 7, 14, 0.68);
  color: #fff;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(12px);
  cursor: pointer;
}

.canvas-cta-toggle[hidden],
html.is-text-editing .canvas-cta-toggle {
  display: none;
}

.canvas-cta-toggle > span {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 7px;
  color: transparent;
  font-size: 16px;
  font-weight: 900;
  line-height: 1;
}

.canvas-cta-toggle.is-active > span {
  border-color: #fff;
  background: #fff;
  color: #17131f;
}

.canvas-cta-toggle > small {
  font-size: 9px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.04em;
}

.canvas-done {
  padding: 10px 4px;
  background: transparent;
  font-size: 16px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.75);
}

.text-style-panel {
  position: fixed;
  z-index: 20;
  left: 12px;
  right: 12px;
  top: var(--editor-panel-top, auto);
  bottom: var(--editor-panel-bottom, max(10px, env(safe-area-inset-bottom)));
  width: auto;
  max-width: 560px;
  margin-inline: auto;
  padding: 5px 6px;
  background: transparent;
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.52);
  transform: none;
  overflow: hidden;
  overscroll-behavior: none;
}

.text-edit-input {
  display: block;
  width: min(72%, 360px);
  min-height: 32px;
  max-height: 62px;
  margin: 0 0 5px;
  padding: 5px 9px;
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 9px;
  outline: 0;
  background: #2d2d32;
  color: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  font-size: 16px;
  line-height: 1.15;
  text-align: left;
  resize: none;
}

.font-strip {
  display: flex;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  gap: 6px;
  overflow-x: auto;
  padding: 2px 0 6px;
  scrollbar-width: none;
  overscroll-behavior: contain;
  touch-action: pan-x pan-y;
}

.font-strip::-webkit-scrollbar {
  display: none;
}

.font-strip button {
  flex: 0 0 auto;
  min-width: 86px;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 13px;
  background: rgba(35, 34, 39, 0.82);
  color: #fff;
  font-size: 14px;
  white-space: nowrap;
  backdrop-filter: blur(14px);
}

.font-strip button.is-active,
.font-strip button[aria-pressed="true"] {
  border-color: #fff;
  background: #fff;
  color: #111;
  box-shadow: inset 0 0 0 1px #6d35cf;
}

.font-strip [data-font="anton"] { font-family: "Anton", sans-serif; }
.font-strip [data-font="inter"] { font-family: "Inter", sans-serif; }
.font-strip [data-font="garet"] { font-family: "Garet", sans-serif; font-weight: 850; }
.font-strip [data-font="archivo"] { font-family: "Archivo", sans-serif; }
.font-strip [data-font="ibm-plex-mono"] { font-family: "IBM Plex Mono", monospace; }
.font-strip [data-font="playfair-display"] { font-family: "Playfair Display", serif; }
.font-strip [data-font="poiret-one"] { font-family: "Poiret One", sans-serif; }
.font-strip [data-font="big-shoulders-display"] { font-family: "Big Shoulders Display", sans-serif; }
.font-strip [data-font="courier-prime"] { font-family: "Courier Prime", monospace; }
.font-strip [data-font="shantell-sans"] { font-family: "Shantell Sans", cursive; }
.font-strip [data-font="bodoni-moda"] { font-family: "Bodoni Moda", serif; }
.font-strip [data-font="lora"] { font-family: "Lora", serif; }
.font-strip [data-font="prompt"] { font-family: "Prompt", sans-serif; }
.font-strip [data-font="pirata-one"] { font-family: "Pirata One", serif; }
.font-strip [data-font="oswald"] { font-family: "Oswald", sans-serif; }
.font-strip [data-font="typewriter"] { font-family: "Courier New", monospace; }
.font-strip [data-font="strong"] { font-family: Impact, "Arial Black", sans-serif; }
.font-strip [data-font="meme"] { font-family: "Comic Sans MS", cursive; font-weight: 800; }
.font-strip [data-font="elegant"] { font-family: Georgia, serif; font-style: italic; }

.editor-tools {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 2px;
  padding: 5px;
  border-radius: 15px;
  background: rgba(54, 54, 57, 0.94);
  backdrop-filter: blur(18px);
}

.text-size-controls {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 5px 6px;
}

.text-size-controls button {
  min-width: 48px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: rgba(54, 54, 57, 0.94);
  color: #fff;
  font: 700 16px Inter, sans-serif;
  touch-action: manipulation;
}

.text-size-controls button:disabled { opacity: .35; }

.editor-tools button {
  position: relative;
  min-width: 0;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #fff;
  font-size: 18px;
  font-weight: 800;
}

.editor-tools button.is-active,
.editor-tools button[aria-pressed="true"],
.text-style-panel:has(.color-strip:not([hidden])) .editor-tools [data-tool="color"] {
  background: #fff;
  color: #17131f;
  box-shadow: inset 0 0 0 2px #6d35cf;
}

.editor-tools button:is(.is-active, [aria-pressed="true"])::after,
.story-frame > div[data-template-product-ui] button[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  top: 4px;
  right: 5px;
  width: 4px;
  height: 7px;
  border: solid currentColor;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  pointer-events: none;
}

.story-frame > div[data-template-product-ui] button {
  position: relative;
}

.story-frame > div[data-template-product-ui] .product-outline-custom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: inherit;
  font-size: 11px;
  font-weight: 800;
}

.story-frame > div[data-template-product-ui] .product-outline-custom input {
  width: 30px;
  height: 22px;
  padding: 0;
  border: 1px solid #fff;
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
}

.story-frame > div[data-template-product-ui] .product-outline-custom.is-active input {
  box-shadow: 0 0 0 2px #6d35cf;
}

.story-frame > div[data-template-product-ui] button[aria-pressed="true"] {
  border-color: #fff;
  background: #fff;
  color: #17131f;
  box-shadow: inset 0 0 0 2px #6d35cf;
}

.canvas-background-control .brand-color-field:focus-within {
  color: #5023a4;
}

.canvas-background-control input:focus-visible,
.text-style-panel button:focus-visible,
.story-frame > div[data-template-product-ui] button:focus-visible {
  outline: 2px solid #6d35cf;
  outline-offset: 2px;
}

.rainbow-tool::before {
  content: "";
  display: block;
  width: 24px;
  height: 24px;
  margin: auto;
  border: 2px solid #fff;
  border-radius: 50%;
  background: conic-gradient(#ff4646, #ffe44a, #49e879, #4bc6ff, #924cff, #ff46b7, #ff4646);
}

.color-strip {
  flex-wrap: wrap;
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 6px 4px 0;
}

.text-color-target { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.text-color-target select { max-width: 150px; border: 1px solid #b9aec9; border-radius: 9px; padding: 6px; font: inherit; color: #242126; background: #fff; }
#text-custom-color { width: 34px; height: 34px; padding: 2px; border: 2px solid #7250aa; border-radius: 9px; background: #fff; }
.text-outline-options { align-items: center; gap: 6px; font-size: 12px; }
label.text-outline-options { display: flex; flex: 1 1 180px; }
#text-outline-width { min-width: 60px; max-width: 180px; accent-color: #7537d0; }
.color-strip #text-outline-fill { width: auto; height: 32px; padding: 0 10px; border-radius: 9px; font-size: 12px; color: #252027; background: #eee8f5; }
.color-strip #text-outline-fill[aria-pressed="true"] { color: #fff; background: #7537d0; }

.color-strip button {
  position: relative;
  width: 27px;
  height: 27px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  background: var(--swatch);
}

.color-strip button:is(.is-active, [aria-pressed="true"]) {
  border-color: #17131f;
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #6d35cf;
}

.color-strip button:is(.is-active, [aria-pressed="true"])::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font: 700 16px/1 system-ui, sans-serif;
  text-shadow: 0 1px 2px #111, 0 -1px 2px #111;
  pointer-events: none;
}

.color-strip button[data-color="#ffffff"] { --swatch: #fff; }
.color-strip button[data-color="#111111"] { --swatch: #111; }
.color-strip button[data-color="#ffe24a"] { --swatch: #ffe24a; }
.color-strip button[data-color="#ff4d8d"] { --swatch: #ff4d8d; }
.color-strip button[data-color="#59ddff"] { --swatch: #59ddff; }
.color-strip button[data-color="#7cff83"] { --swatch: #7cff83; }

.story-frame > img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.rotation-guide {
  position: absolute;
  z-index: 6;
  left: 0;
  right: 0;
  top: 50%;
  border-top: 2px dashed #ffd25c;
  pointer-events: none;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
}

.center-guide-vertical {
  position: absolute;
  z-index: 6;
  top: 0;
  bottom: 0;
  left: 50%;
  border-left: 2px dashed #32d8ff;
  pointer-events: none;
  transform: translateX(-1px);
  filter: drop-shadow(1px 0 2px rgba(0, 0, 0, 0.45));
}

.story-placeholder,
.generating-layer {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 32px;
  text-align: center;
}

.story-placeholder {
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    #100c24;
  background-size: 24px 24px;
  color: #88829a;
}

.story-placeholder span {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 19px;
  color: #b8b2ca;
  font-weight: 800;
}

.story-placeholder p {
  max-width: 200px;
  margin: 15px 0 0;
  font-size: 13px;
  line-height: 1.45;
}

.generating-layer {
  background: rgba(8, 6, 17, 0.86);
  backdrop-filter: blur(11px);
}

.story-frame > #generating-layer {
  z-index: 80;
}

.generation-progress-card {
  display: grid;
  justify-items: center;
  gap: 0;
  max-width: 320px;
}

.story-frame > #generating-layer[data-phase="copy"] {
  background: rgba(0, 0, 0, 0.2);
  backdrop-filter: none;
}

#generating-layer[data-phase="copy"] .generation-progress-card {
  padding: 24px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.96);
  color: #242421;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  font-size: 16px;
  line-height: 1.45;
}

#generating-layer[data-phase="copy"] small {
  color: #69645d;
}

.generating-layer small {
  margin-top: 7px;
  color: var(--muted);
}

.spinner {
  width: 38px;
  height: 38px;
  margin-bottom: 17px;
  border: 3px solid rgba(255, 255, 255, 0.18);
  border-top-color: #b594ff;
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

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

.result-caption {
  display: none;
}

.message {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 5;
  width: min(100%, 650px);
  margin: 18px auto 0;
  padding: 14px 16px;
  border: 1px solid rgba(255, 119, 145, 0.35);
  border-radius: 15px;
  background: rgba(61, 16, 34, 0.96);
  color: #ffdce3;
  font-size: 14px;
  line-height: 1.45;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
}

[hidden] {
  display: none !important;
}

@media (max-width: 720px) {
  .app-shell {
    padding-left: 8px;
    padding-right: 8px;
    padding-bottom: 36px;
  }

  .workspace {
    grid-template-columns: 1fr;
    padding: 0;
    border-radius: 0;
  }

  .upload-card {
    min-height: 170px;
    padding: 18px 5px;
    overflow: hidden;
  }

  .upload-options {
    gap: 6px;
  }

  .upload-icon {
    width: 46px;
    height: 46px;
    margin-bottom: 12px;
  }

  .upload-card strong {
    font-size: 15px;
  }

  .upload-card small {
    font-size: 11px;
  }

  .result-column {
    width: min(100%, 390px);
    margin: 0 auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0s !important;
  }
}

/* The page stays at its normal scale. Custom photo/text pinch is owned
   by the canvas controllers, while normal one-finger scrolling is retained. */
html, body { touch-action: pan-x pan-y !important; }
html.is-text-editing,
html.is-chat-text-editing,
body.is-text-editing { touch-action: pan-y !important; }
html.is-chat-text-editing .chat-studio-canvas-host .story-frame,
html.is-chat-text-editing .chat-studio-canvas-host .story-frame *,
html.is-chat-text-editing .text-style-panel { touch-action: pan-x pan-y !important; }

/* iOS must not zoom the entire page when a small form field receives focus. */
@media (pointer: coarse) {
  .brand-chat input, .brand-chat textarea, .brand-chat select,
  .chat-studio input, .chat-studio textarea, .chat-studio select,
  #text-edit-input { font-size: max(16px, 1em) !important; }
}

/* Explicit on controls, including disabled Undo and its SVG children. */
button, button *, [role="button"] { touch-action: manipulation !important; }

/* Permit shrinking a browser-restored page zoom on the surrounding UI.
   Canvas touch ownership and its image/text gestures remain unchanged. */
html.is-page-zoomed,
html.is-page-zoomed body { touch-action: manipulation !important; }

/* WebKit starts touch-action afresh inside every scroll container (menus,
   dialogs, rails), where the html/body value above no longer applies. Give
   every element the same no-zoom panning, with zero specificity so that any
   explicit rule still wins. Safari then blocks pinch-zoom by itself, and no
   blocking JavaScript touch listener has to run before a swipe may scroll. */
:where(*:not(input[type="range"])) { touch-action: pan-x pan-y; }
:where(html.is-page-zoomed) :where(*:not(input[type="range"])),
html.is-page-zoomed :is(.app-shell, .template-carousel, .font-strip) { touch-action: manipulation; }

/* Horizontal choice rails scroll sideways only. Without a vertical scroll
   range iOS never splits a swipe between two directions or bounces them. */
.chat-app__drawer .brand-picker__brands,
.brand-chat__industry-choices,
.studio-industry-rail,
.chat-studio__industry-options { overflow-y: hidden; }
