/* Roll — Gold Coast evening, film-roll vibe. Warm, not medical. */
:root {
  --navy: #1B2A4A;
  --navy-deep: #0F1A33;
  --coral: #FF6B5A;
  --coral-deep: #E24B3C;
  --sun: #FFB347;
  --sun-hot: #FFE08A;
  --paper: #FBF4EA;
  --cream: #FFF8F0;
  --ink: #1A1423;
  --muted: #6E5D52;
  --film: #2A1F16;
  --sprocket: #C9A227;
  --danger: #C21F14;
  --ok: #2A9D8F;
  --shadow: 0 18px 40px rgba(15, 26, 51, 0.28);
  --radius: 22px;
  --font-ui: "Nunito", system-ui, sans-serif;
  --font-display: "Fraunces", "Palatino Linotype", Georgia, serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
  --bar: calc(58px + var(--safe-top));
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--font-ui);
  background: var(--navy-deep);
  color: var(--ink);
  min-height: 100dvh;
  min-height: 100svh;
  line-height: 1.45;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
textarea { resize: vertical; }
input, textarea { font-size: 16px; } /* iOS: avoid focus zoom */
a { color: inherit; text-decoration: none; }

.sky {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(900px 480px at 88% -8%, rgba(255, 179, 71, 0.42), transparent 58%),
    radial-gradient(700px 420px at -10% 110%, rgba(255, 107, 90, 0.32), transparent 55%),
    linear-gradient(180deg, #1B2A4A 0%, #243256 42%, #3A2C48 100%);
}
.grain {
  position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: 0.07;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='140' height='140' filter='url(%23n)' opacity='0.9'/></svg>");
}

h1, h2, .brand-text strong, .empty-word {
  font-family: var(--font-display);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.35rem;
  padding: 0.55rem 0.95rem;
  border-radius: 999px;
  font-weight: 800;
  min-height: 44px;
}
.btn-coral {
  background: var(--coral);
  color: #fff;
  box-shadow: 0 4px 0 var(--coral-deep);
}
.btn-coral:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--coral-deep); }
.btn-coral:disabled { opacity: 0.45; box-shadow: none; transform: none; }
.btn-ghost {
  background: transparent;
  color: var(--paper);
  border: 1.5px solid color-mix(in srgb, var(--paper) 28%, transparent);
}
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn.lg { width: 100%; min-height: 52px; font-size: 1.05rem; }
.btn.xl {
  width: 92px; height: 92px; border-radius: 50%;
  font-size: 3.2rem; line-height: 1; padding: 0;
  box-shadow: 0 8px 0 var(--coral-deep), 0 18px 36px rgba(226, 75, 60, 0.35);
}
.linkish {
  color: var(--coral-deep);
  font-weight: 800;
  background: none;
  padding: 0.2rem;
  min-height: auto;
}

/* Gate / lock — display:flex MUST pair with [hidden] */
.gate[hidden] { display: none !important; }
.gate {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center;
  padding: calc(1.2rem + var(--safe-top)) 1rem calc(1.2rem + var(--safe-bot));
}
.gate-card {
  width: min(400px, 100%);
  background: var(--paper);
  color: var(--ink);
  border-radius: 28px;
  padding: 1.7rem 1.45rem 1.5rem;
  text-align: center;
  box-shadow: var(--shadow);
  position: relative; z-index: 2;
}
.gate-card h1 {
  margin: 0.15rem 0 0;
  font-size: 2.6rem;
  font-style: italic;
  font-weight: 800;
  color: var(--navy);
}
.gate-sub {
  margin: 0.15rem 0 0.8rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--muted);
}
.privacy {
  margin: 0 auto 1.1rem;
  max-width: 32ch;
  font-size: 0.88rem;
  color: var(--muted);
}
.reel { margin-bottom: 0.2rem; }
.panel { text-align: left; }
.panel[hidden] { display: none !important; }
.panel h2 {
  margin: 0 0 0.4rem;
  font-size: 1.25rem;
  color: var(--navy);
}
.boot-line { text-align: center; color: var(--muted); font-weight: 700; }
.tiny { font-size: 0.78rem; color: var(--muted); }
.tiny code {
  font-size: 0.74rem;
  background: color-mix(in srgb, var(--sun) 35%, #fff);
  padding: 0.05rem 0.28rem;
  border-radius: 6px;
}

#auth-form { display: grid; gap: 0.7rem; }
#auth-form label, .caption-label {
  display: grid; gap: 0.3rem;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: left;
}
#auth-form input, .caption-label textarea {
  width: 100%;
  border: 2px solid color-mix(in srgb, var(--navy) 16%, transparent);
  border-radius: 14px;
  padding: 0.7rem 0.8rem;
  background: #fff;
  color: var(--ink);
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
}
.form-error { min-height: 1.2em; color: var(--danger); font-size: 0.88rem; font-weight: 700; margin: 0; }
.auth-switch { text-align: center; margin: 0.9rem 0 0; color: var(--muted); font-size: 0.9rem; }

#app { position: relative; z-index: 2; min-height: 100dvh; }
#app[hidden] { display: none !important; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(0.55rem + var(--safe-top)) 0.9rem 0.55rem;
  background: linear-gradient(180deg, rgba(15,26,51,0.92), rgba(15,26,51,0.55) 70%, transparent);
  backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 0.65rem; color: var(--paper); }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-text strong { font-size: 1.55rem; font-style: italic; font-weight: 800; }
.brand-text em {
  font-style: normal;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.78;
  font-weight: 800;
}

.feed-wrap {
  width: min(560px, 100%);
  margin: 0 auto;
  padding: 0.4rem 0.7rem calc(7.2rem + var(--safe-bot));
}
.feed-status {
  color: var(--paper);
  text-align: center;
  font-weight: 700;
  opacity: 0.8;
  padding: 1rem;
}
.feed-status[hidden] { display: none !important; }

.feed { display: flex; flex-direction: column; gap: 1.15rem; }

.card {
  background: var(--cream);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.card-media {
  position: relative;
  background: var(--film);
  /* film sprockets */
  padding: 0 14px;
  background-image:
    repeating-linear-gradient(
      to bottom,
      var(--film) 0 6px,
      transparent 6px 18px
    ),
    repeating-linear-gradient(
      to bottom,
      var(--film) 0 6px,
      transparent 6px 18px
    );
  background-size: 10px 24px, 10px 24px;
  background-position: left top, right top;
  background-repeat: repeat-y;
}
.carousel {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.carousel::-webkit-scrollbar { display: none; }
.slide {
  flex: 0 0 100%;
  scroll-snap-align: center;
  min-height: 220px;
  max-height: 72vh;
  background: #111;
  display: flex;
  align-items: center;
  justify-content: center;
}
.slide img, .slide video {
  width: 100%;
  height: 100%;
  max-height: 72vh;
  object-fit: contain;
  background: #111;
  display: block;
}
.dots {
  display: flex; justify-content: center; gap: 0.35rem;
  padding: 0.45rem 0 0.15rem;
}
.dots button {
  width: 7px; height: 7px; border-radius: 50%;
  background: color-mix(in srgb, var(--paper) 35%, transparent);
  padding: 0; min-width: 7px;
}
.dots button.on { background: var(--sun); width: 16px; border-radius: 99px; }
.card-body { padding: 0.75rem 1rem 1rem; }
.card-meta {
  display: flex; justify-content: space-between; align-items: baseline; gap: 0.6rem;
  margin-bottom: 0.35rem;
}
.when { color: var(--muted); font-size: 0.78rem; font-weight: 800; }
.caption { margin: 0; white-space: pre-wrap; font-weight: 600; }
.btn-del {
  color: var(--muted);
  font-weight: 800;
  font-size: 0.82rem;
  min-height: 36px;
  padding: 0.2rem 0.4rem;
}

.empty[hidden] { display: none !important; }
.empty {
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
  color: var(--paper);
  padding: 2.4rem 1rem 1rem;
  gap: 0.4rem;
}
.empty h2 { margin: 0.4rem 0 0; font-size: 1.8rem; font-style: italic; }
.empty p { margin: 0 0 1rem; max-width: 28ch; opacity: 0.85; }
.empty-reel {
  width: 120px; height: 120px; border-radius: 50%;
  background: radial-gradient(circle at 70% 28%, var(--sun-hot), var(--sun) 42%, var(--coral) 100%);
  display: grid; place-items: center;
  box-shadow: 0 10px 0 rgba(0,0,0,0.18);
  position: relative;
}
.empty-sun { position: absolute; top: 10px; right: 14px; font-size: 1.2rem; }
.empty-word { font-size: 1.4rem; font-style: italic; font-weight: 800; color: var(--navy); }

.fab {
  position: fixed;
  z-index: 30;
  right: max(1.1rem, env(safe-area-inset-right, 0px));
  bottom: calc(1.15rem + var(--safe-bot));
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--coral);
  color: #fff;
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 6px 0 var(--coral-deep), 0 16px 28px rgba(226, 75, 60, 0.35);
}
.fab:active { transform: translateY(3px); box-shadow: 0 3px 0 var(--coral-deep); }

/* Bottom sheet */
.sheet[hidden] { display: none !important; }
.sheet {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: flex-end; justify-content: center;
}
.scrim {
  position: absolute; inset: 0;
  background: rgba(15, 26, 51, 0.52);
  width: 100%; height: 100%;
  border: 0; padding: 0;
}
.sheet-card {
  position: relative; z-index: 1;
  width: min(560px, 100%);
  max-height: min(92dvh, 100%);
  overflow: auto;
  background: var(--paper);
  border-radius: 24px 24px 0 0;
  padding: 0.9rem 1rem calc(1.1rem + var(--safe-bot));
  box-shadow: var(--shadow);
}
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.7rem;
}
.sheet-head h2 {
  margin: 0;
  font-size: 1.35rem;
  color: var(--navy);
  font-style: italic;
}
.sheet-head .btn-ghost { color: var(--navy); border-color: color-mix(in srgb, var(--navy) 18%, transparent); }

.pick-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; margin-bottom: 0.8rem; }
.pick {
  display: flex; align-items: center; justify-content: center;
  min-height: 52px;
  border-radius: 16px;
  background: #fff;
  border: 2px dashed color-mix(in srgb, var(--navy) 22%, transparent);
  font-weight: 800;
  color: var(--navy);
}
.pick input { display: none; }
.pick:has(input:focus-visible) { outline: 3px solid var(--sun); }

.compose-preview[hidden] { display: none !important; }
.compose-preview {
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  margin-bottom: 0.8rem;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.compose-preview .thumb {
  flex: 0 0 auto;
  width: 112px; height: 112px;
  border-radius: 14px;
  overflow: hidden;
  background: var(--film);
  scroll-snap-align: start;
  position: relative;
}
.compose-preview img, .compose-preview video {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.compose-preview .kind {
  position: absolute; bottom: 4px; left: 4px;
  background: rgba(15,26,51,0.7); color: #fff;
  font-size: 0.65rem; font-weight: 800;
  padding: 0.1rem 0.35rem; border-radius: 999px;
}

.caption-label { margin-bottom: 0.7rem; color: var(--muted); }

.modal[hidden] { display: none !important; }
.modal {
  position: fixed; inset: 0; z-index: 70;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal-card {
  position: relative; z-index: 1;
  width: min(400px, 100%);
  background: var(--paper);
  border-radius: 22px;
  padding: 1.3rem 1.2rem 1.1rem;
  box-shadow: var(--shadow);
}
.modal-card h2 { margin: 0 0 0.4rem; color: var(--navy); font-size: 1.35rem; }
.modal-card p { margin: 0 0 1rem; color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.45rem; }

.install-hint[hidden] { display: none !important; }
.install-hint {
  position: fixed;
  left: 0.8rem; right: 0.8rem;
  bottom: calc(5.6rem + var(--safe-bot));
  z-index: 25;
  display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
  background: var(--cream);
  color: var(--ink);
  border-radius: 16px;
  padding: 0.7rem 0.9rem;
  box-shadow: var(--shadow);
  font-size: 0.85rem;
  font-weight: 700;
}
.install-hint p { margin: 0; }

.toasts {
  position: fixed;
  left: 0.8rem; right: 0.8rem;
  bottom: calc(1rem + var(--safe-bot));
  z-index: 90;
  display: flex; flex-direction: column; gap: 0.4rem;
  pointer-events: none;
}
.toast {
  background: var(--cream);
  color: var(--ink);
  border-radius: 14px;
  padding: 0.7rem 0.9rem;
  font-weight: 800;
  box-shadow: var(--shadow);
}
.toast.err { color: var(--danger); }
.toast.ok { color: var(--ok); }

[hidden] { display: none !important; }

@media (min-width: 720px) {
  .fab { right: calc(50vw - 280px + 1rem); }
}
