:root {
  color-scheme: dark;
  --bg: #12110e;
  --bg-elev: #1c1b16;
  --line: rgba(246, 241, 231, 0.14);
  --text: #f6f1e7;
  --muted: #b7b1a6;
  --accent: #ff4d1c;
  --accent-ink: #2a100b;
  --danger: #ffb4a8;
  --ok: #d5e38a;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: "Avenir Next", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
}

body {
  min-height: 100dvh;
}

button, input, textarea {
  font: inherit;
  color: inherit;
}

button { touch-action: manipulation; }

#app { min-height: 100dvh; }

.screen {
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 20px calc(18px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 36px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  letter-spacing: 0.04em;
  font-size: 13px;
}

.mark {
  width: 20px;
  height: 20px;
  display: block;
}

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

.back, .text-button {
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 8px 0;
  cursor: pointer;
}

.icon-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-elev);
  color: var(--text);
  cursor: pointer;
}

.icon-button svg {
  width: 20px;
  height: 20px;
  display: block;
}

h1 {
  font-family: var(--serif);
  font-weight: 560;
  font-size: clamp(2rem, 8vw, 2.7rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin: 0;
}

.lede {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.45;
}

.body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.dock {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: auto;
}

a.button {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  text-align: center;
}

.button {
  appearance: none;
  border: 0;
  min-height: 56px;
  border-radius: 16px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 680;
  font-size: 1.05rem;
  cursor: pointer;
  padding: 0 18px;
}

.button:disabled { opacity: 0.55; cursor: default; }

.button.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.choice, .card {
  width: 100%;
  text-align: left;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  color: var(--text);
  cursor: pointer;
}

.choice.selected, .card.selected {
  border-color: var(--accent);
}

.choice.pending {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: default;
}

.spinner {
  width: 48px;
  height: 48px;
  display: block;
  flex: none;
}

.wait-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 8px 0 4px;
  text-align: center;
}

.hold {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(18, 17, 14, 0.92);
}

.hold .lede {
  max-width: 260px;
  margin: 0;
}

.wait-inline {
  display: flex;
  align-items: center;
  gap: 12px;
}

.wait-inline .spinner,
.choice.pending .spinner {
  width: 28px;
  height: 28px;
}

.card { display: flex; flex-direction: column; gap: 6px; min-height: 92px; }
.card h2 { margin: 0; font-size: 1.15rem; font-weight: 650; }
.card p { margin: 0; color: var(--muted); line-height: 1.35; }
.card.disabled { opacity: 0.48; cursor: default; }

.badge {
  align-self: flex-start;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
}

.stack { display: flex; flex-direction: column; gap: 6px; }
.label { color: var(--muted); font-size: 0.92rem; }

.field {
  width: 100%;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  font-size: 16px;
  min-height: 52px;
}

textarea.field { min-height: 140px; resize: vertical; line-height: 1.4; }
textarea.field.compact { min-height: 88px; }
.field:focus { outline: 2px solid var(--accent); border-color: transparent; }

.banner {
  margin: 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: #2a2118;
  color: var(--danger);
  line-height: 1.35;
}

.banner.ok { color: var(--ok); }
.banner.note { color: var(--text); }

.modal-back {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.62);
}

.modal {
  width: min(440px, 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: env(safe-area-inset-bottom);
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--bg-elev);
}

.modal h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.7rem;
  font-weight: 560;
}

.preview {
  width: 100%;
  aspect-ratio: 9 / 16;
  object-fit: cover;
  border-radius: 20px;
  background: #0c0b09;
}

video.preview { aspect-ratio: 9 / 16; max-height: 62dvh; object-fit: contain; background: #000; }

.meta { color: var(--muted); margin: 0; }
.script {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.45;
}

.row { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.price { font-family: var(--serif); font-size: 1.6rem; margin: 0; }

.langs { display: flex; gap: 8px; }
.langs button[aria-pressed="true"] { color: var(--text); }

.screen.landing {
  height: 100dvh;
  max-height: 100dvh;
  min-height: 0;
  overflow: hidden;
  gap: 10px;
  padding-top: calc(12px + env(safe-area-inset-top));
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}

.screen.landing h1 {
  font-size: clamp(1.45rem, 6vw, 2.05rem);
}

.screen.landing .lede {
  font-size: 0.92rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.screen.landing .body {
  min-height: 0;
  gap: 8px;
}

.screen.landing .langs,
.screen.landing .dock {
  flex: none;
}

.screen.landing .langs .text-button {
  padding: 0;
  font-size: 0.85rem;
}

.screen.landing .button {
  min-height: 48px;
}

.promo {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  place-items: center;
  border-radius: 16px;
  overflow: hidden;
  background: #000;
}

.promo video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  pointer-events: none;
}

.promo video::-webkit-media-controls,
.promo video::-webkit-media-controls-enclosure,
.promo video::-webkit-media-controls-panel {
  display: none !important;
  -webkit-appearance: none;
  opacity: 0;
  pointer-events: none;
}

.promo-replay {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  appearance: none;
  display: none;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 680;
  cursor: pointer;
}

.promo.is-ended .promo-replay {
  display: inline-flex;
}

.promo-sound {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  appearance: none;
  display: none;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 680;
  font-size: 0.9rem;
  cursor: pointer;
}

.promo.is-muted:not(.is-ended) .promo-sound {
  display: inline-flex;
}

.list { display: flex; flex-direction: column; gap: 8px; }
.list button { text-align: left; }

.hint { color: var(--muted); font-size: 0.92rem; margin: 0; }

.details { display: flex; flex-direction: column; gap: 10px; }

.portrait-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

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

.portrait-pick {
  position: relative;
  aspect-ratio: 9 / 16;
  width: 100%;
  border-radius: 18px;
  border: 1px solid var(--line);
  padding: 0;
  overflow: hidden;
  background: #0c0b09;
  cursor: pointer;
}

.portrait-pick.selected { border-color: var(--accent); }
.portrait-pick:disabled { cursor: default; }

.portrait-pick img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.portrait-wait {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
  padding: 12px;
  text-align: center;
  font-size: 0.92rem;
}

.portrait-wait .spinner {
  width: 42px;
  height: 42px;
}

.portrait-wait.overlay {
  position: absolute;
  inset: 0;
  background: rgba(12, 11, 9, 0.62);
  color: var(--text);
}

.portrait-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.portrait-nav, .portrait-regen {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-elev);
  color: var(--text);
  cursor: pointer;
  padding: 0;
}

.portrait-regen { font-size: 16px; }
.portrait-nav:disabled, .portrait-regen:disabled { opacity: 0.35; cursor: default; }

.length-picker {
  display: flex;
  gap: 8px;
}

.length-option {
  flex: 1;
  min-height: 52px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--muted);
  font-weight: 650;
  cursor: pointer;
}

.length-option[aria-pressed="true"] {
  color: var(--text);
  border-color: var(--accent);
  background: rgba(255, 77, 28, 0.12);
}

.frame-picker {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.frame-picker button {
  width: 72px;
  height: 52px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  padding: 8px 10px;
  cursor: pointer;
}

.frame-picker button[aria-pressed="true"] {
  color: var(--text);
  border-color: var(--accent);
  background: rgba(255, 77, 28, 0.12);
}

.frame-picker svg {
  width: 100%;
  height: 100%;
  display: block;
}

.portrait-caption { margin: 0; text-align: center; }
.portrait-caption strong { display: block; font-weight: 600; font-size: 0.95rem; }
.portrait-caption span { display: block; color: var(--muted); font-size: 0.78rem; margin-top: 2px; }

html.cookie-known .cookie-note { display: none; }

/* Keep the note in the page flow so it sits under the dock instead of covering Continue. */
html:not(.cookie-known) body:has(.cookie-note) {
  display: flex;
  flex-direction: column;
}

html:not(.cookie-known) body:has(.cookie-note) #app {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

html:not(.cookie-known) body:has(.cookie-note) .screen {
  flex: 1 1 auto;
  min-height: 0;
  width: min(480px, 100%);
}

html:not(.cookie-known) body:has(.cookie-note):has(.screen.landing) {
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

html:not(.cookie-known) body:has(.cookie-note) .screen.landing {
  height: auto;
  max-height: none;
  padding-bottom: 8px;
}

.cookie-note {
  position: static;
  z-index: 30;
  flex: none;
  width: min(440px, calc(100% - 40px));
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 auto calc(12px + env(safe-area-inset-bottom));
  padding: 12px 12px 12px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.cookie-note p {
  margin: 0;
  flex: 1;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.cookie-note button {
  appearance: none;
  flex: none;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 650;
  font-size: 0.85rem;
  padding: 8px 14px;
  cursor: pointer;
}

@media (min-width: 800px) {
  body { background: #0c0b09; }
  #app { background: var(--bg); }
}
