/* Snapnovel. Recipe adapted from the Pinterest design notes: white canvas that gets out of the photos' way,
   warm greys, one red action colour, rounded imagery, pill buttons. */
@font-face {
  font-family: "Figtree";
  src: url("fonts/figtree-latin-wght-normal.woff2") format("woff2-variations");
  font-weight: 300 900;
  font-display: swap;
}
@font-face {
  font-family: "Bricolage Grotesque";
  src: url("fonts/bricolage-grotesque-latin-wght-normal.woff2") format("woff2-variations");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --red: #e60023;
  --red-press: #cc001f;
  --ink: #211922;
  --body: #33332e;
  --mute: #62625b;
  --ash: #91918c;
  --line: #dadad3;
  --line-soft: #e5e5e0;
  --soft: #f6f6f3;
  --canvas: #ffffff;
  --cap: #ffe45c;
  --focus: #435ee5;
  --r-img: 16px;
  --r-card: 20px;
  --display: "Bricolage Grotesque", "Figtree", system-ui, sans-serif;
  --text: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
}
[hidden] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--body);
  font: 16px/1.5 var(--text);
}
h1, h2, h3 { color: var(--ink); font-family: var(--display); margin: 0; text-wrap: balance; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.mute { color: var(--mute); }
.small { font-size: 14px; }

.ic { width: 18px; height: 18px; flex: none; }
.ic-lg { width: 28px; height: 28px; color: var(--mute); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px;
  border: 0; border-radius: 999px;
  background: var(--line-soft); color: var(--ink);
  font-weight: 600; font-size: 15px; text-decoration: none; cursor: pointer;
  transition: background .15s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--line); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-press); }
.btn-ghost { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.btn-ghost:hover { background: var(--soft); }
.btn-lg { min-height: 52px; padding: 12px 22px; font-size: 16px; }
.btn-icon { min-height: 40px; width: 40px; padding: 0; background: transparent; }
.btn-icon:hover { background: var(--line-soft); }
.btn-small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.linkish { background: none; border: 0; padding: 0; color: var(--red); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* Header */
.bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px max(16px, calc((100vw - 1120px) / 2));
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line-soft);
}
.brand { font-family: var(--display); font-weight: 750; font-size: 22px; letter-spacing: -.4px; color: var(--ink); text-decoration: none; }
.bar-right { display: flex; align-items: center; gap: 12px; min-width: 0; }
.save { font-size: 13px; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

main { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
main > section, .foot { scroll-margin-top: 80px; }

/* Intro */
.intro { padding: 56px 0 24px; max-width: 760px; }
.intro h1 { font-size: clamp(36px, 7vw, 64px); line-height: 1.04; letter-spacing: -1.4px; font-weight: 700; }
.lede { margin-top: 18px; font-size: 19px; max-width: 58ch; color: var(--body); }
.intro-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.steps { list-style: none; counter-reset: s; margin: 44px 0 0; padding: 0; display: grid; border-top: 1px solid var(--line-soft); }
.steps li { counter-increment: s; position: relative; padding: 14px 0 14px 44px; border-bottom: 1px solid var(--line-soft); }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 12px; font-family: var(--display); font-weight: 700; font-size: 20px; color: var(--red); }
.steps strong { color: var(--ink); }

/* Editor */
.editor { padding-top: 28px; }
.project-head { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 12px; align-items: end; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 600; color: var(--mute); }
.field input, .field select, .box input, .box textarea, .box select {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 12px; background: #fff;
}
.field-title input { font-family: var(--display); font-size: 22px; font-weight: 650; color: var(--ink); }
.count-line { margin: 18px 0 10px; font-size: 14px; color: var(--ink); font-weight: 600; }
.count-line .mute { font-weight: 400; }

.scenes { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.scene {
  display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 20px;
  padding: 16px; border-radius: var(--r-card); background: var(--soft);
}
.scene.sortable-ghost { opacity: .35; }
.scene.sortable-chosen { box-shadow: 0 10px 30px rgba(33,25,34,.16); }
.scene-media { position: relative; min-width: 0; align-self: start; }
.scene-media img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--r-img); background: var(--line-soft); }
.scene-no {
  position: absolute; left: 10px; top: 10px;
  min-width: 32px; height: 32px; padding: 0 10px; border-radius: 999px;
  display: grid; place-items: center;
  background: rgba(255,255,255,.92); color: var(--ink); font-weight: 700; font-size: 14px;
}
.handle {
  position: absolute; right: 10px; top: 10px;
  width: 40px; height: 40px; border: 0; border-radius: 999px;
  display: grid; place-items: center;
  background: rgba(255,255,255,.92); color: var(--ink); cursor: grab; touch-action: none;
}
.handle:active { cursor: grabbing; }
.scene-media .replace { position: absolute; left: 10px; bottom: 10px; background: rgba(255,255,255,.92); }
.scene-body { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.scene-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.author-tag { font-size: 13px; font-weight: 600; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; }
.scene-meta .spacer { flex: 1; }
.boxes { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.box {
  display: grid; grid-template-columns: 140px minmax(0, 1fr) 40px; gap: 8px; align-items: start;
  padding: 10px; border-radius: 14px; background: #fff; border: 1px solid var(--line-soft);
}
.box-narration { background: #fff9d6; border-color: #f2e08a; }
.box .who-cell { display: grid; gap: 6px; }
.box select { min-height: 36px; padding: 6px 8px; font-size: 13px; }
.box textarea { min-height: 64px; resize: vertical; line-height: 1.4; }
.box-narration .speaker { display: none; }
.box-add { display: flex; gap: 8px; flex-wrap: wrap; }
.empty-boxes { font-size: 14px; color: var(--mute); }

/* Drop zone */
.drop {
  margin: 16px 0 0; padding: 28px 20px;
  border: 2px dashed var(--line); border-radius: var(--r-card);
  display: grid; justify-items: center; gap: 8px; text-align: center;
  transition: border-color .15s ease, background .15s ease;
}
.drop.over { border-color: var(--red); background: #fff5f6; }

/* Share */
.share { margin-top: 48px; }
.share h2, .plan h2 { font-size: 28px; letter-spacing: -.6px; }
.share-rows { margin: 16px 0 12px; border-top: 1px solid var(--line-soft); }
.share-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 0; border-bottom: 1px solid var(--line-soft); }
.share-row h3 { font-size: 18px; font-family: var(--text); font-weight: 700; }
.share-row p { color: var(--mute); max-width: 60ch; margin-top: 2px; }

/* Plan */
.plan {
  margin: 48px 0 0; padding: 28px; border-radius: var(--r-card);
  background: var(--ink); color: #f5f5f2;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
}
.plan h2 { color: #fff; }
.plan p { margin-top: 6px; max-width: 62ch; color: rgba(245,245,242,.78); }

.plan-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.plan .btn-ghost { color: #f5f5f2; }
.faq { margin-top: 48px; max-width: 72ch; }
.faq h2 { font-size: 28px; letter-spacing: -.6px; margin-bottom: 8px; }
.faq h3 { font-size: 17px; margin-top: 18px; }
.faq p { margin-top: 4px; }
.legal { margin-top: 8px; line-height: 1.5; }
.legal a { color: inherit; display: inline-block; min-height: 24px; }
.foot { max-width: 1120px; margin: 48px auto 0; padding: 24px 16px 40px; border-top: 1px solid var(--line-soft); font-size: 14px; display: grid; gap: 4px; }

/* Dialog + toast */
.dlg { border: 0; border-radius: var(--r-card); padding: 24px; width: min(520px, calc(100vw - 32px)); color: var(--body); }
.dlg::backdrop { background: rgba(33,25,34,.5); }
.dlg h2 { font-size: 24px; }
.dlg p { margin-top: 10px; }
.dlg-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.toast {
  position: fixed; left: 50%; bottom: calc(20px + var(--paybar-h, 0px)); transform: translateX(-50%); z-index: 60;
  width: max-content; max-width: min(560px, calc(100vw - 32px)); padding: 12px 18px; border-radius: 14px;
  background: var(--ink); color: #fff; font-size: 15px; box-shadow: 0 10px 30px rgba(0,0,0,.2);
}
body.reading { overflow: hidden; }

@media (max-width: 860px) {
  .project-head { grid-template-columns: 1fr 1fr; }
  .field-title { grid-column: 1 / -1; }
  .scene { grid-template-columns: minmax(0, 240px) minmax(0, 1fr); }
  .plan { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 600px) {
  .intro { padding-top: 36px; }
  .lede { font-size: 17px; }
  .intro-actions .btn { flex: 1 1 100%; }
  .scene { grid-template-columns: minmax(0, 1fr); padding: 12px; gap: 14px; }
  .box { grid-template-columns: minmax(0, 1fr) 40px; }
  .box .who-cell { grid-column: 1; grid-row: 1; grid-template-columns: 116px minmax(0, 1fr); }
  .box textarea { grid-column: 1 / -1; grid-row: 2; }
  .box .rm { grid-column: 2; grid-row: 1; }
  .share-row { flex-direction: column; align-items: stretch; }
  .share-row .btn { width: 100%; }
  .plan { padding: 22px; }
  .plan .btn, .plan-actions { width: 100%; }
  .save { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
