:root {
  --dusk: #1D2832;
  --dusk-2: #243340;
  --dusk-3: #2E3F4D;
  --trim: #ECE8DF;
  --glass: #A9C0C9;
  --muted: #93A3AE;
  --porch: #F2B544;
  --porch-ink: #2A2110;
  --rec: #E5484D;
  --line: rgba(236, 232, 223, 0.14);
  --line-strong: rgba(236, 232, 223, 0.28);
  --serif: "Newsreader", Georgia, serif;
  --sans: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius-sm: 8px;
  --radius-md: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--dusk);
  color: var(--trim);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}
[hidden] { display: none !important; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px max(20px, env(safe-area-inset-left)) 18px max(20px, env(safe-area-inset-right));
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--trim);
  text-decoration: none;
  font-family: var(--sans);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.005em;
}
.brand-mark { width: 26px; height: 26px; color: var(--trim); }
.topbar-note { color: var(--muted); font-size: 15px; }

.view, .gate { box-sizing: border-box; }
.view { flex: 1; width: 100%; max-width: 1280px; margin: 0 auto; padding: 32px 20px 40px; }

/* ---------- Type ---------- */
h1 {
  font-family: var(--sans);
  font-weight: 800;
  font-size: clamp(30px, 3.2vw, 40px);
  line-height: 1.08;
  letter-spacing: -0.03em;
  margin: 0 0 20px;
}
p { margin: 0; }
.fine { color: var(--muted); font-size: 14.5px; margin-top: 12px; }
.tip { color: var(--muted); font-size: 15px; margin-top: 6px; }

/* ---------- Buttons ---------- */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  font: 600 16px/1 var(--sans);
  padding: 13px 22px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  min-height: 46px;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn:focus-visible, input:focus-visible, .homeowner:focus-visible {
  outline: 3px solid var(--porch);
  outline-offset: 3px;
}
.btn-primary { background: var(--porch); color: var(--porch-ink); }
.btn-primary:hover:not(:disabled) { background: #F6C567; }
.btn-large { width: 100%; min-height: 56px; font-size: 18px; margin-top: 8px; }
.btn-quiet { background: transparent; color: var(--trim); border-color: var(--line-strong); }
.btn-quiet:hover:not(:disabled) { background: rgba(236, 232, 223, 0.07); }
.btn-record { background: var(--trim); color: var(--dusk); }
.btn-record:hover:not(:disabled) { background: #fff; }
.rec-glyph { width: 12px; height: 12px; border-radius: 50%; background: var(--rec); }
.btn-record.is-recording, .btn-record.is-recording:hover:not(:disabled) { background: var(--rec); color: #fff; }
.btn-record.is-recording .rec-glyph { border-radius: 2px; background: #fff; }

/* ---------- Fields ---------- */
.field { display: block; margin: 22px 0 6px; }
.field span { display: block; font-size: 15px; color: var(--muted); margin-bottom: 8px; }
.field input {
  width: 100%;
  background: var(--dusk-2);
  color: var(--trim);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  font: 500 17px var(--sans);
}
.form-error { color: #FF9C9F; font-size: 15px; margin-top: 12px; }

/* ---------- Gate ---------- */
.gate {
  position: relative;
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 440px);
  gap: clamp(40px, 6vw, 96px);
  align-items: center;
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: clamp(28px, 5vw, 64px) clamp(20px, 4vw, 48px);
  min-height: 100dvh;
  isolation: isolate;
}
.gate-bg {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(900px 520px at 88% 8%, rgba(242, 181, 68, 0.16), transparent 60%),
    radial-gradient(700px 600px at 0% 100%, rgba(169, 192, 201, 0.10), transparent 60%),
    linear-gradient(180deg, #17212A 0%, #1D2832 55%, #15202A 100%);
}
.gate-bg::after {
  content: ""; position: absolute; inset: 0; opacity: 0.5;
  background-image: linear-gradient(rgba(236,232,223,0.035) 1px, transparent 1px), linear-gradient(90deg, rgba(236,232,223,0.035) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse at 30% 40%, #000 20%, transparent 75%);
}
.gate-brand {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--trim); text-decoration: none;
  font: 600 17px var(--sans); letter-spacing: -0.005em;
  margin-bottom: clamp(32px, 6vh, 64px);
}
.gate-brand .brand-mark { width: 24px; height: 24px; }
.manifesto {
  font-family: var(--sans);
  font-weight: 800;
  font-size: clamp(42px, 5.2vw, 80px);
  line-height: 1;
  text-wrap: balance;
  letter-spacing: -0.035em;
  margin: 0 0 28px;
}
.m-line { display: block; white-space: nowrap; }
@media (max-width: 560px) { .m-line { white-space: normal; } }
.m-dim { color: rgba(236, 232, 223, 0.38); }
.m-bright {
  background: linear-gradient(92deg, #ECE8DF 0%, #ECE8DF 55%, #F2B544 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.manifesto-sub { color: var(--muted); font-size: 18px; max-width: 52ch; line-height: 1.55; }

.tape { margin: clamp(28px, 4vh, 40px) 0 0; max-width: 440px; }
.tape-kicker { margin: 0 0 12px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.tape-kicker .tape-quote { font: 800 24px/1.1 var(--sans); letter-spacing: -0.02em; }
.tape-kicker .tape-answer { margin: 0; font: 700 17px var(--sans); color: var(--porch); }
.tape-frame-wrap { position: relative; border-radius: 16px; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(236,232,223,0.12), 0 24px 60px -24px rgba(0,0,0,0.6); background: #000; }
.tape-frame-wrap .tape-frame { border-radius: 0; }
.tape-poster, .tape-frame {
  display: block; width: 100%; aspect-ratio: 16 / 9; border-radius: 16px; border: 0;
}
.tape-poster {
  position: relative; overflow: hidden; cursor: pointer; text-align: left;
  padding: 26px 28px; color: var(--trim);
  background:
    radial-gradient(420px 240px at 100% 0%, rgba(242,181,68,0.28), transparent 60%),
    linear-gradient(135deg, #22303C, #141C24);
  box-shadow: inset 0 0 0 1px rgba(236,232,223,0.12), 0 24px 60px -24px rgba(0,0,0,0.6);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.tape-poster::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 100%;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,0.025) 0 2px, transparent 2px 4px);
  pointer-events: none;
}
.tape-poster:hover { transform: translateY(-2px); box-shadow: inset 0 0 0 1px rgba(242,181,68,0.45), 0 30px 70px -24px rgba(0,0,0,0.7); }
.tape-poster:focus-visible { outline: 3px solid var(--porch); outline-offset: 4px; }
.tape-quote { display: block; font: 800 clamp(30px, 3vw, 40px)/1 var(--sans); letter-spacing: -0.03em; }
.tape-answer { display: block; margin-top: 8px; font: 600 18px var(--sans); color: var(--porch); }
.tape-play {
  position: absolute; right: 22px; bottom: 22px;
  width: 58px; height: 58px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--porch); color: var(--porch-ink);
  box-shadow: 0 0 0 8px rgba(242,181,68,0.16);
  transition: box-shadow 0.25s ease;
}
.tape-poster:hover .tape-play { box-shadow: 0 0 0 12px rgba(242,181,68,0.22); }
.tape-play svg { width: 24px; height: 24px; margin-left: 3px; }
.tape figcaption { color: var(--muted); font-size: 14.5px; margin-top: 12px; }

.gate-panel {
  background: rgba(36, 51, 64, 0.55);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(236,232,223,0.12);
  border-radius: 24px;
  padding: clamp(26px, 3vw, 40px);
  box-shadow: 0 40px 80px -40px rgba(0,0,0,0.7);
}
.gate-card h2 { font: 700 30px/1.15 var(--sans); letter-spacing: -0.02em; margin: 0 0 10px; }
.gate-badge {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 600; color: var(--porch);
  border: 1px solid rgba(242, 181, 68, 0.4);
  border-radius: 999px; padding: 6px 12px 6px 10px; margin-bottom: 20px;
}
.gate-badge svg { width: 14px; height: 14px; }
.gate-lede { color: var(--muted); }
.gate-card .fine { margin-top: 18px; }
.gate-card.is-wrong { animation: nudge 0.38s ease; }
.gate-card.is-wrong .field input { border-color: #FF9C9F; }
@keyframes nudge { 20% { transform: translateX(-6px); } 45% { transform: translateX(5px); } 70% { transform: translateX(-3px); } 100% { transform: translateX(0); } }
.gate-error {
  margin-top: 12px; padding: 12px 14px;
  background: rgba(229, 72, 77, 0.1);
  border: 1px solid rgba(255, 156, 159, 0.3);
  border-radius: var(--radius-sm);
  color: #FFC7C9; font-size: 15px;
}
/* One orchestrated entrance: the manifesto, line by line. */
.gate:not([hidden]) .m-line, .gate:not([hidden]) .manifesto-sub, .gate:not([hidden]) .tape, .gate:not([hidden]) .gate-panel {
  animation: rise 0.7s cubic-bezier(.2,.7,.2,1) both;
}
.gate .m-bright { animation-delay: 0.18s !important; }
.gate .manifesto-sub { animation-delay: 0.32s !important; }
.gate .tape { animation-delay: 0.44s !important; }
.gate .gate-panel { animation-delay: 0.1s !important; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.gate.is-leaving { opacity: 0; transform: scale(0.99); transition: opacity 0.4s ease, transform 0.4s ease; }
@media (max-width: 960px) {
  .gate { grid-template-columns: 1fr; align-items: start; min-height: 0; }
  .gate-brand { margin-bottom: 28px; }
  .tape { max-width: none; }
}

/* ---------- Setup ---------- */
.setup {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 48px;
  align-items: start;
}
.window-frame {
  position: relative;
  aspect-ratio: 4 / 3;
  border: 10px solid var(--trim);
  border-radius: 6px;
  background: var(--dusk-2);
  overflow: hidden;
}
.window-frame video { width: 100%; height: 100%; object-fit: cover; display: block; transform: scaleX(-1); }
.preview-empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  color: var(--muted);
  text-align: center; padding: 20px;
}
.device-row { display: flex; align-items: center; gap: 14px; margin-top: 16px; }
.meter { width: 120px; height: 6px; border-radius: 3px; background: var(--dusk-3); overflow: hidden; flex: none; }
.meter span { display: block; height: 100%; width: 0; background: var(--glass); transition: width 0.08s linear; }
.device-status { font-size: 15px; }

.homeowners { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.homeowner {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 14px;
  align-items: start;
  padding: 14px 4px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  border-radius: 4px;
}
.homeowner input { position: absolute; opacity: 0; pointer-events: none; }
.radio {
  width: 20px; height: 20px; margin-top: 4px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  display: grid; place-items: center;
}
.homeowner[aria-checked="true"] .radio { border-color: var(--porch); }
.homeowner[aria-checked="true"] .radio::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--porch); }
.homeowner-name { font-family: var(--sans); font-weight: 700; font-size: 20px; line-height: 1.25; letter-spacing: -0.015em; }
.homeowner-town { color: var(--muted); font-family: var(--sans); font-size: 15px; margin-left: 8px; }
.homeowner-issue { color: var(--muted); font-size: 15.5px; margin-top: 2px; }
.homeowner:hover .radio { border-color: var(--trim); }

.pick-row { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 22px; }
.pick-label { display: block; font-size: 15px; color: var(--muted); margin-bottom: 8px; }
.segmented {
  display: inline-flex; padding: 4px; gap: 4px;
  background: var(--dusk-2); border: 1px solid var(--line-strong); border-radius: 999px;
}
.seg {
  appearance: none; border: 0; background: transparent; color: var(--trim);
  font: 600 15px/1 var(--sans); padding: 10px 16px; border-radius: 999px; cursor: pointer; min-height: 38px;
}
.seg:hover { background: rgba(236, 232, 223, 0.07); }
.seg[aria-checked="true"] { background: var(--trim); color: var(--dusk); }
.seg:focus-visible { outline: 3px solid var(--porch); outline-offset: 2px; }
.pick-note { margin-top: 10px; }

/* ---------- Live ---------- */
.live { max-width: 1400px; padding-top: 20px; }
.stage-wrap {
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: calc(100dvh - 190px);
  margin: 0 auto;
  display: flex; justify-content: center;
}
#stage { height: 100%; max-width: 100%; aspect-ratio: 16 / 9; border-radius: var(--radius-md); background: var(--dusk); display: block; }
.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
  flex-wrap: wrap;
}
.status { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.status-dot.is-ready { background: var(--glass); }
.status-dot.is-live { background: var(--rec); animation: pulse 1.6s ease-in-out infinite; }
.control-buttons { display: flex; gap: 10px; flex-wrap: wrap; }
@keyframes pulse { 50% { opacity: 0.35; } }

/* ---------- Review ---------- */
.review {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr);
  gap: 40px;
  align-items: start;
}
.review-player video { width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: var(--radius-md); display: block; }
.review-meta { color: var(--muted); margin-top: -8px; }
.review-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 26px; }
.review-actions .btn { width: 100%; }
.share-panel { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.progress { height: 6px; border-radius: 3px; background: var(--dusk-3); overflow: hidden; margin-bottom: 10px; }
.progress span { display: block; height: 100%; width: 0; background: var(--porch); transition: width 0.2s ease; }
.share-status { font-size: 15px; }
.share-link { display: flex; gap: 8px; margin-top: 10px; }
.share-link input {
  flex: 1; min-width: 0;
  background: var(--dusk-2); color: var(--trim);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 10px 12px; font: 500 15px var(--sans);
}
#btnNativeShare { margin-top: 10px; width: 100%; }
.review-nudge { margin-top: 30px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--porch); font-weight: 600; font-size: 15.5px; }
.review-next { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

/* ---------- Watch page ---------- */
.watch { max-width: 1100px; }
.watch-head { display: flex; align-items: end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 20px; }
.watch-head h1 { margin: 0; }
.watch video { width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: var(--radius-md); display: block; }
.watch-error { color: var(--muted); }

/* ---------- Responsive ---------- */
.rotate-hint { display: none; color: var(--muted); font-size: 15px; text-align: center; margin-top: 12px; }
@media (orientation: portrait) and (max-width: 1100px) {
  .rotate-hint { display: block; }
}
@media (max-width: 900px) {
  .setup, .review { grid-template-columns: 1fr; gap: 28px; }
  .window-frame { aspect-ratio: 16 / 10; max-height: 40vh; margin: 0 auto; }
  .topbar-note { display: none; }
  .controls { justify-content: center; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
