:root {
  --bg: #f4f1ea;
  --paper: #ffffff;
  --ink: #14231c;
  --muted: #3d5248;
  --primary: #1a5c3a;
  --primary-press: #13462c;
  --secondary: #2c4a6e;
  --danger: #a32020;
  --border: #c9c2b4;
  --notice: #fff6d6;
  --notice-ink: #5a4a12;
  --ok: #e6f6ec;
  --ok-ink: #0f5132;
  --err: #fde8e8;
  --err-ink: #7a1717;
  --radius: 20px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: transparent; color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 20px; line-height: 1.35;
  -webkit-text-size-adjust: 100%;
  height: 100%;
}
html { background: #f4f1ea; }
body { min-height: 100%; min-height: 100dvh; background: transparent; }
#app {
  max-width: 480px; margin: 0 auto;
  min-height: 100dvh;
  padding: 16px 16px calc(24px + var(--safe-bottom));
  background: transparent;
}
.screen[hidden] { display: none !important; }
.screen { display: flex; flex-direction: column; gap: 16px; }
.top h1 { margin: 8px 0 4px; font-size: 2rem; line-height: 1.15; }
.tag { margin: 0 0 8px; color: var(--muted); font-size: 1.05rem; }
.notice {
  background: var(--notice); color: var(--notice-ink);
  border: 2px solid #e6d48a; border-radius: var(--radius);
  padding: 14px 16px; font-size: 1.05rem; margin: 0;
}
.banner-ok {
  background: var(--ok); color: var(--ok-ink);
  border: 2px solid #9ad4b0; border-radius: var(--radius);
  padding: 14px 16px; font-size: 1.1rem; font-weight: 700; margin: 0;
}
.banner-err {
  background: var(--err); color: var(--err-ink);
  border: 2px solid #f0a0a0; border-radius: var(--radius);
  padding: 14px 16px; font-size: 1.05rem; font-weight: 600; margin: 0;
}
.label { margin: 0; font-size: 1.1rem; font-weight: 700; color: var(--muted); }
.prompt-box {
  background: var(--paper); border: 3px solid var(--ink);
  border-radius: var(--radius); padding: 22px 18px;
  font-size: 1.45rem; font-weight: 600; min-height: 120px;
}
.prompt-meta, .prompt-small { margin: 0; color: var(--muted); font-size: 1rem; }
.stack { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }
.btn {
  appearance: none; border: none; border-radius: var(--radius);
  font: inherit; font-weight: 700; padding: 18px 20px; cursor: pointer;
  text-align: center; width: 100%;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.btn:active { transform: scale(0.98); }
.btn-giant { font-size: 1.7rem; padding: 28px 22px; min-height: 96px; }
.btn-large { font-size: 1.35rem; padding: 22px 20px; min-height: 72px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-press); }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--ink); border: 3px solid var(--border); }
.btn-back {
  width: auto; align-self: flex-start; background: var(--paper);
  border: 2px solid var(--border); color: var(--ink);
  font-size: 1.05rem; padding: 10px 14px; min-height: 44px; flex: 0 0 auto;
}
.preview-wrap {
  background: #000; border-radius: var(--radius); overflow: hidden;
  min-height: 220px; display: flex; align-items: center; justify-content: center;
  flex-direction: column;
}
.preview-wrap video, .preview-wrap img {
  width: 100%; max-height: 50vh; display: block; background: #000; object-fit: contain;
}
.preview-wrap audio { width: 100%; margin: 40px 12px; }
/* iOS Safari often ignores [hidden] on <video controls> — force it off */
#review-video[hidden],
#review-audio[hidden],
#review-photo[hidden],
.preview-wrap .media-off {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
  max-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  position: absolute !important;
  left: -9999px !important;
  opacity: 0 !important;
  pointer-events: none !important;
}
.preview-wrap.preview-photo {
  background: #111;
}
.preview-wrap.preview-photo #review-photo {
  width: 100%;
  max-width: 100%;
  max-height: 55vh;
  object-fit: contain;
}
.voice-meter { color: #fff; text-align: center; padding: 40px 20px; }
.voice-meter .pulse {
  width: 72px; height: 72px; margin: 0 auto 16px; border-radius: 50%;
  background: #3ecf8e; animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(0.9); opacity: 0.7; }
  50% { transform: scale(1.15); opacity: 1; }
}
.timer {
  text-align: center; font-size: 2.4rem; font-weight: 700;
  font-variant-numeric: tabular-nums; margin: 0;
}
.field { display: flex; flex-direction: column; gap: 8px; font-weight: 700; }
.field input {
  font: inherit; font-weight: 500; font-size: 1.2rem; padding: 16px;
  border-radius: 14px; border: 3px solid var(--border);
  background: var(--paper); color: var(--ink);
}
.cat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cat-btn {
  background: var(--paper); color: var(--ink); border: 3px solid var(--border);
  font-size: 1.15rem; min-height: 64px; padding: 14px 10px;
}
.cat-btn-on { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ===== Family Stories: ONE scrollable column (iOS Safari) ===== */
#app.mode-feed,
#app:has(#screen-family:not([hidden])) {
  padding: 0;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.screen-feed {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  padding: 0;
  gap: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: block;
}
.feed-topbar {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(10px + var(--safe-top)) 12px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 5;
}
.feed-label {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  flex: 1 1 auto;
  min-width: 0;
}
.btn-filter-toggle {
  width: auto;
  flex: 0 0 auto;
  font-size: 0.95rem;
  padding: 10px 12px;
  min-height: 44px;
  background: var(--secondary);
  color: #fff;
  border-radius: 14px;
}
.filter-panel {
  position: sticky;
  top: 58px;
  z-index: 4;
  padding: 10px 12px 12px;
  background: var(--paper);
  border-bottom: 1px solid var(--border);
}
.filter-panel[hidden] { display: none !important; }
.search-field { margin: 0 0 10px; }
.search-field input { font-size: 1.15rem; min-height: 52px; }
.cat-chips {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}
.cat-chips .cat-btn {
  flex: 0 0 auto;
  width: auto;
  min-height: 44px;
  padding: 10px 14px;
  font-size: 1rem;
  white-space: nowrap;
  border-radius: 999px;
}
.empty-state {
  flex: 0 0 auto;
  margin: 12px;
  padding: 18px 16px;
  background: var(--paper); border: 3px solid var(--border);
  border-radius: var(--radius); text-align: center;
}
.empty-title { margin: 0 0 8px; font-size: 1.4rem; font-weight: 700; }
.empty-body { margin: 0 0 14px; color: var(--muted); font-size: 1.05rem; }
.empty {
  flex: 0 0 auto;
  background: var(--paper); border-radius: var(--radius);
  border: 2px dashed var(--border); padding: 16px; margin: 8px 12px;
  text-align: center; color: var(--muted); font-size: 1.05rem;
}

/* THE FEED — part of the parent scroll, not a nested trap */
.story-feed {
  display: block;
  width: 100%;
  min-height: 40vh;
  outline: none;
  background: #0b1210;
  scroll-snap-type: none;
}
.clip {
  position: relative;
  min-height: 70vh;
  height: auto;
  background: #0b1210; color: #fff;
  display: flex; flex-direction: column; justify-content: flex-end;
  border-bottom: 2px solid #1e2a24;
}
.clip-example { border-top: 4px solid #e6d48a; }
.clip-media {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center; background: #000;
}
.clip-media video, .clip-media img {
  width: 100%; height: 100%; object-fit: contain; background: #000;
}
.clip-media audio { width: 90%; z-index: 2; }
.clip-voice-bg, .clip-text-bg {
  position: absolute; inset: 0;
  background: linear-gradient(160deg, #1a5c3a, #0b1210 60%);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.45rem; font-weight: 700; padding: 28px; text-align: center;
}
.clip-overlay {
  position: relative; z-index: 3;
  padding: 20px 16px calc(24px + var(--safe-bottom));
  background: linear-gradient(transparent, rgba(0,0,0,0.78) 35%);
}
.clip-overlay .kind {
  display: inline-block; font-size: 0.95rem; font-weight: 700;
  background: var(--primary); color: #fff; border-radius: 999px;
  padding: 6px 12px; margin-bottom: 8px;
}
.clip-overlay .kind-example { background: #8a6d12; }
.clip-overlay .title { margin: 0 0 6px; font-size: 1.45rem; font-weight: 700; }
.clip-overlay .meta, .clip-overlay .prompt { margin: 0 0 6px; font-size: 1.05rem; color: #e8efe9; }
.clip-actions { display: flex; gap: 10px; margin-top: 12px; }
.clip-actions .btn { min-height: 56px; font-size: 1.1rem; padding: 14px 16px; width: auto; flex: 1; }
.clip-actions .btn-play { background: #fff; color: var(--ink); }
.clip-hint { text-align: center; font-size: 0.95rem; color: #c5d2c9; margin: 8px 0 0; }

/* Simple fallback list (always usable) */
.simple-list {
  display: block;
  padding: 12px 12px calc(24px + var(--safe-bottom));
  background: var(--bg);
}
.simple-list[hidden] { display: none !important; }
.simple-card {
  background: var(--paper);
  border: 3px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  text-align: left;
}
.simple-card .sc-kind {
  font-size: 0.95rem; font-weight: 700; color: var(--primary); margin-bottom: 4px;
}
.simple-card .sc-title { font-size: 1.25rem; font-weight: 700; margin: 0 0 4px; }
.simple-card .sc-meta { margin: 0 0 10px; color: var(--muted); font-size: 1rem; }
.simple-card .btn { min-height: 52px; font-size: 1.1rem; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 14px 22px; border-radius: 999px; font-weight: 700;
  font-size: 1.05rem; z-index: 100; max-width: 90vw;
}
.diag {
  margin: 8px 12px; padding: 10px 12px; font-size: 0.85rem;
  font-family: ui-monospace, Menlo, monospace; background: #111; color: #9f9;
  border-radius: 10px; white-space: pre-wrap; word-break: break-word;
}
@media (prefers-reduced-motion: reduce) {
  .voice-meter .pulse { animation: none; }
  .btn:active { transform: none; }
}


/* ===== Home menu button ===== */
.home-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.home-title-wrap { flex: 1 1 auto; min-width: 0; }
.home-title-wrap h1 { margin-top: 4px; }
.btn-menu {
  flex: 0 0 auto;
  width: 52px;
  min-height: 52px;
  padding: 8px 6px 6px;
  border: 2px solid var(--border);
  border-radius: 16px;
  background: rgba(255,255,255,0.88);
  color: var(--ink);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(20,35,28,0.06);
}
.btn-menu-bars {
  display: block;
  width: 18px;
  height: 12px;
  background:
    linear-gradient(var(--ink), var(--ink)) 0 0 / 100% 2px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 0 5px / 100% 2px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 0 10px / 100% 2px no-repeat;
  border-radius: 2px;
}
.btn-menu-label { line-height: 1; }
.info-card {
  background: rgba(255,255,255,0.92);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  font-size: 1.1rem;
}
.info-card p { margin: 0 0 12px; }
.info-card p:last-child { margin-bottom: 0; }
.info-card h2 {
  margin: 16px 0 6px;
  font-size: 1.15rem;
  color: var(--primary);
}
.info-card h2:first-child { margin-top: 0; }
.howto-list {
  margin: 0 0 12px;
  padding-left: 1.3em;
}
.howto-list li { margin-bottom: 10px; }
.coming-soon-badge {
  display: inline-block;
  background: var(--notice);
  color: var(--notice-ink);
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 999px;
  border: 2px solid #e6d48a;
  margin-bottom: 12px !important;
}
.coming-soon-inline { color: var(--muted); font-style: italic; }


/* ===== Famcorder brand mark ===== */
.brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}
.brand-row h1 { margin: 0; }
.brand-row-lg {
  margin: 12px 0 4px;
}
.brand-row-lg h1 { font-size: 2.2rem; }
.brand-mark {
  display: inline-block;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 12px;
  background: #1a5c3a;
  box-shadow: 0 2px 8px rgba(20,35,28,0.12);
  /* cream film reel via inline SVG mask-friendly background */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Crect width='64' height='64' rx='14' fill='%231a5c3a'/%3E%3Ccircle cx='32' cy='32' r='18' fill='none' stroke='%23f4f1ea' stroke-width='4'/%3E%3Ccircle cx='32' cy='32' r='5' fill='%23f4f1ea'/%3E%3Ccircle cx='32' cy='18' r='3.2' fill='%23f4f1ea'/%3E%3Ccircle cx='32' cy='46' r='3.2' fill='%23f4f1ea'/%3E%3Ccircle cx='18' cy='32' r='3.2' fill='%23f4f1ea'/%3E%3Ccircle cx='46' cy='32' r='3.2' fill='%23f4f1ea'/%3E%3Ccircle cx='22' cy='22' r='2.4' fill='%23f4f1ea'/%3E%3Ccircle cx='42' cy='22' r='2.4' fill='%23f4f1ea'/%3E%3Ccircle cx='22' cy='42' r='2.4' fill='%23f4f1ea'/%3E%3Ccircle cx='42' cy='42' r='2.4' fill='%23f4f1ea'/%3E%3C/svg%3E");
  background-size: cover;
  background-repeat: no-repeat;
}
.brand-row-lg .brand-mark { width: 56px; height: 56px; border-radius: 14px; }

.told-by-card {
  background: rgba(255,255,255,0.94);
  border: 3px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.told-by-label {
  margin: 0 0 4px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--muted);
}
.told-by-name {
  margin: 0 0 12px;
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--ink);
  min-height: 1.4em;
}
.told-by-name:empty { display: none; margin: 0; min-height: 0; }
#btn-add-name[hidden], #btn-not-you[hidden] { display: none !important; }

.name-change-panel {
  background: rgba(255,255,255,0.96);
  border: 3px solid var(--primary);
  border-radius: var(--radius);
  padding: 16px;
}
.name-change-panel[hidden] { display: none !important; }


/* ===== Seasonal backgrounds — visible on iOS Safari ===== */
html {
  background: #f4f1ea;
}
body {
  position: relative;
  background: transparent;
  min-height: 100%;
  min-height: 100dvh;
}
.season-bg {
  position: fixed;
  left: 0; right: 0; top: 0; bottom: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}
#app {
  position: relative;
  z-index: 1;
  background: transparent;
}

/* Stronger warm/cool base tints (still soft) */
body.season-winter .season-bg { background: linear-gradient(165deg, #d9e7f2 0%, #eef3f7 40%, #f4f1ea 100%); }
body.season-spring .season-bg { background: linear-gradient(165deg, #e4f0d8 0%, #eef5e8 40%, #f4f1ea 100%); }
body.season-summer .season-bg { background: linear-gradient(165deg, #f3e9b8 0%, #f7f1d4 35%, #eef6f0 100%); }
body.season-fall .season-bg { background: linear-gradient(165deg, #f0d5b0 0%, #f3e2c8 35%, #f4efe6 70%, #efe4d4 100%); }

/* SVG motif layer — corners/edges, soft opacity */
.season-motifs {
  position: absolute;
  left: 0; right: 0; top: 0; bottom: 0;
  width: 100%;
  height: 100%;
  opacity: 1;
}
.season-motifs svg {
  position: absolute;
  width: 100%;
  height: 100%;
  display: block;
}

/* Soft center veil so mid-screen UI stays crisp (not a hard mask) */
.season-veil {
  position: absolute;
  left: 0; right: 0; top: 0; bottom: 0;
  background: radial-gradient(ellipse 70% 55% at 50% 42%, rgba(244,241,234,0.72) 0%, rgba(244,241,234,0.28) 55%, rgba(244,241,234,0) 78%);
  pointer-events: none;
}

.feed-topbar { background: rgba(244,241,234,0.95); }
.filter-panel { background: rgba(255,255,255,0.97); }
.simple-list { background: rgba(244,241,234,0.94); }

@media (prefers-reduced-motion: reduce) {
  .season-motifs { opacity: 0.7; }
}

/* ===== Scan an Old Photo ===== */
.screen-scan { gap: 10px; }
.scan-topbar { display: flex; align-items: center; gap: 10px; }
.scan-topbar h1 { margin: 0; font-size: 1.35rem; }
.scan-topbar .btn-back { width: auto; flex: 0 0 auto; }
.scan-hint { margin: 0; font-size: 0.95rem; color: var(--muted); text-align: center; }
.scan-stage {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  width: 100%;
  aspect-ratio: 3 / 4;
  max-height: calc(100dvh - 260px);
  min-height: 200px;
  margin: 0 auto;
}
.scan-stage.scan-wide { aspect-ratio: 4 / 3; max-height: calc(100dvh - 260px); }
.scan-stage.scan-wide .scan-frame { left: 6%; right: 6%; top: 10%; bottom: 10%; }
.scan-capture { margin-top: 0; }
.btn-scan-shape { min-height: 48px; font-size: 1.05rem; padding: 10px; }
@media (orientation: landscape) and (max-height: 520px) {
  .scan-stage, .scan-stage.scan-wide { max-height: calc(100dvh - 150px); aspect-ratio: 4 / 3; }
  .scan-hint { display: none; }
}
.scan-stage video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #000;
  transform: scaleX(1);
}
.scan-frame {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 12%;
  bottom: 12%;
  border: 4px solid #fff;
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10px;
}
.scan-frame-label {
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  padding: 8px 12px;
  border-radius: 10px;
  text-align: center;
  max-width: 92%;
  line-height: 1.25;
}
.scan-preview-wrap {
  min-height: 240px;
  background: #1a1a1a;
}
.scan-preview-wrap canvas {
  width: 100%;
  max-height: 50vh;
  display: block;
  object-fit: contain;
  background: #111;
}
#scan-status { text-align: center; font-weight: 600; }

/* ===== Family sharing ===== */
.code-input { font-size: 2rem !important; letter-spacing: 0.3em; text-align: center; text-transform: uppercase; font-weight: 800 !important; }
.join-code-big {
  margin: 0; text-align: center; font-size: 3rem; font-weight: 800; letter-spacing: 0.25em;
  background: #fff; border: 3px solid var(--ink); border-radius: var(--radius); padding: 18px 8px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}
.share-link { margin: 0; word-break: break-all; font-size: 0.95rem; color: var(--muted); text-align: center; }
.upload-overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(20,35,28,0.72);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.upload-overlay[hidden] { display: none !important; }
.upload-box { background: #fff; border-radius: var(--radius); padding: 24px 20px; width: 100%; max-width: 440px; text-align: center; }
.upload-title { margin: 0 0 14px; font-size: 1.8rem; font-weight: 800; }
.upload-bar { height: 28px; background: #e7e2d6; border-radius: 14px; overflow: hidden; }
.upload-fill { height: 100%; width: 0%; background: var(--primary); transition: width 0.2s; }
.upload-pct { margin: 10px 0 6px; font-size: 1.6rem; font-weight: 800; }
.clip-pending { display:inline-block; margin-left:8px; font-size:0.85rem; background:#fff6d6; color:#5a4a12; padding:2px 8px; border-radius:8px; }

.family-name-big { margin: 0; text-align: center; font-size: 2.2rem; font-weight: 800; line-height: 1.15; }
.family-name-input { font-size: 1.6rem !important; font-weight: 700 !important; }
.joining-name { margin: 0; text-align: center; font-size: 1.6rem; font-weight: 800; background: #fff; border: 3px solid var(--primary); border-radius: var(--radius); padding: 16px; }
.joining-name[hidden] { display: none; }
.family-pick { text-align: left; }
.family-pick.current { outline: 5px solid #f2c94c; }
.family-pick small { display: block; font-size: 1rem; font-weight: 600; opacity: 0.85; margin-top: 4px; }

.member-row { display: flex; align-items: center; gap: 10px; background: #fff; border: 3px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.member-name { flex: 1; font-size: 1.35rem; font-weight: 700; margin: 0; }
.member-row .btn { width: auto; min-height: 60px; font-size: 1.15rem; padding: 12px 18px; }
.still-title { font-size: 2.2rem; }

.passcode-input { font-size: 2.6rem !important; letter-spacing: 0.35em; padding: 20px 10px !important; border-radius: 14px; border: 3px solid var(--ink); width: 100%; }
.passcode-status { margin: 0; text-align: center; font-size: 1.3rem; font-weight: 700; color: var(--err-ink); min-height: 1.4em; }
#founder-code-field[hidden] { display: none; }

/* ===== Batch: feed declutter, badges, more-below ===== */
.feed-label { font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-topbar .btn-back { width: auto; flex: 0 0 auto; min-height: 44px; padding: 8px 12px; font-size: 1rem; }
.clip-overlay { transition: opacity 0.4s ease; }
.clip-playing .clip-overlay { opacity: 0; pointer-events: none; }
.clip-overlay .prompt { font-style: italic; opacity: 0.9; }
.clip-overlay .kind-new { background: #c0392b; margin-right: 6px; }
.clip-voice .clip-media { align-items: flex-start; padding-top: 22%; }
.clip-voice .clip-media audio { position: relative; }
.told-by-link {
  background: none; border: 0; padding: 0; margin: 0; font: inherit; color: #fff;
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer; width: auto; min-height: 0;
}
.filter-label { margin: 8px 0 4px; font-size: 0.9rem; font-weight: 700; color: var(--muted); }
.person-filter-note { margin: 8px 12px; font-size: 1.05rem; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.person-filter-note[hidden] { display: none; }
.btn-clear-person { width: auto; min-height: 40px; padding: 6px 12px; font-size: 0.95rem; background: var(--secondary); color: #fff; border-radius: 999px; }
.btn-with-badge { position: relative; }
.count-badge {
  display: inline-flex; align-items: center; justify-content: center; margin-left: 10px;
  min-width: 28px; height: 28px; padding: 0 8px; border-radius: 999px;
  background: #c0392b; color: #fff; font-size: 0.95rem; font-weight: 800; vertical-align: middle;
}
.count-badge[hidden] { display: none; }
.photo-choice { display: flex; flex-direction: column; gap: 10px; padding: 10px; border: 2px dashed var(--border); border-radius: var(--radius); }
.photo-choice[hidden] { display: none; }
.more-below {
  position: fixed; right: 10px; bottom: calc(12px + var(--safe-bottom, 0px));
  z-index: 50; width: auto; min-height: 0; display: flex; flex-direction: column; align-items: center;
  padding: 4px 14px 6px; border: 0; border-radius: 999px; background: rgba(26,92,58,0.82); color: #fff;
  font-size: 0.8rem; font-weight: 700; line-height: 1; box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  animation: more-pulse 1.8s ease-in-out infinite;
}
.more-below span[aria-hidden] { font-size: 1.4rem; line-height: 0.9; }
.more-below[hidden] { display: none; }
@keyframes more-pulse { 0%,100% { transform: translateY(0); opacity: 0.8; } 50% { transform: translateY(5px); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .more-below { animation: none; } }

/* ===== Batch: small-phone declutter, More arrow placement, solid search panel ===== */
/* More arrow: bottom-center, clear of any bottom-right badge */
.more-below {
  right: auto; left: 50%; bottom: calc(10px + var(--safe-bottom, 0px));
  transform: translateX(-50%);
  padding: 2px 12px 4px; font-size: 0.72rem; background: rgba(26,92,58,0.7);
  animation: more-pulse-c 1.8s ease-in-out infinite;
}
.more-below span[aria-hidden] { font-size: 1.15rem; }
@keyframes more-pulse-c { 0%,100% { transform: translateX(-50%) translateY(0); opacity: 0.75; } 50% { transform: translateX(-50%) translateY(4px); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .more-below { animation: none; } }

/* Search panel: solid block in normal flow, the feed sits below it */
.filter-panel {
  position: relative; top: auto; z-index: 1;
  background: var(--paper); isolation: isolate;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.cat-chips {
  -webkit-mask-image: linear-gradient(to right, #000 85%, transparent);
  mask-image: linear-gradient(to right, #000 85%, transparent);
  padding-right: 24px; scrollbar-width: none;
}
.cat-chips::-webkit-scrollbar { display: none; }

@media (max-width: 390px) {
  #app { padding: 10px 12px calc(16px + var(--safe-bottom)); }
  .screen { gap: 10px; }
  .top h1 { font-size: 1.6rem; margin: 4px 0 2px; }
  .tag { font-size: 0.98rem; margin-bottom: 4px; }
  .prompt-box { padding: 14px 14px; font-size: 1.25rem; min-height: 88px; }
  .btn { padding: 14px 16px; }
  .btn-giant { font-size: 1.45rem; padding: 20px 16px; min-height: 76px; }
  .btn-large { font-size: 1.15rem; padding: 14px 14px; min-height: 56px; }
  .stack { gap: 8px; }
  .photo-choice { gap: 8px; padding: 8px; }
  .notice, .banner-ok, .banner-err { padding: 10px 12px; font-size: 0.98rem; }
  .feed-topbar { padding: calc(6px + var(--safe-top)) 8px 6px; gap: 6px; }
  .feed-topbar .btn-back, .btn-filter-toggle { min-height: 40px; padding: 6px 10px; font-size: 0.92rem; }
  .feed-label { font-size: 0.98rem; }
  .filter-panel { padding: 6px 10px 8px; }
  .search-field { margin-bottom: 4px; }
  .search-field > span { font-size: 0.9rem; }
  .search-field input { font-size: 1rem; min-height: 42px; }
  .filter-label { margin: 4px 0 2px; font-size: 0.8rem; }
  .cat-chips { gap: 6px; padding-bottom: 2px; }
  .cat-chips .cat-btn { min-height: 36px; padding: 6px 11px; font-size: 0.9rem; border-width: 2px; }
}

/* ===== Photo narration + compact review ===== */
.narr-box { margin: 10px 0 6px; }
.btn-narrate { width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 1.25rem; min-height: 64px; }
.btn-narrate .mic { font-size: 1.6rem; }
.narr-has { background: rgba(255,255,255,.85); border-radius: 14px; padding: 10px 12px; }
.narr-label { margin: 0 0 6px; font-weight: 700; }
.narr-has audio { width: 100%; }
.narr-actions { display: flex; gap: 8px; margin-top: 8px; }
.narr-actions .btn { flex: 1; min-height: 44px; }
.title-fold { margin: 8px 0; }
.title-fold summary { cursor: pointer; color: #555; font-size: .95rem; padding: 6px 0; }
.cat-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 6px 0; font-size: .95rem; color: #444; }
.btn-link { background: none; border: none; color: #1a5c3a; text-decoration: underline; padding: 6px 4px; min-height: 0; font-size: .95rem; }
#screen-review .preview-wrap.preview-photo #review-photo { max-height: 46vh; }
.clip-media.has-narration { position: relative; }
.narr-play { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); z-index: 3;
  display: flex; align-items: center; gap: 10px; padding: 14px 22px; border-radius: 999px; border: 0;
  background: rgba(0,0,0,.6); color: #fff; font-size: 1.1rem; font-weight: 700; box-shadow: 0 4px 16px rgba(0,0,0,.35); }
.narr-play .narr-ico { font-size: 1.4rem; }
.narr-play.playing { top: auto; bottom: 22%; transform: translateX(-50%); opacity: .85; }
.narr-play .narr-txt { white-space: nowrap; }
.narr-has[hidden], .narr-box[hidden] { display: none !important; }

.btn-rotate{display:block;margin:8px auto 12px;min-width:160px}
.btn-rotate[hidden]{display:none}

/* ===== Photo stories: tap to hide words, rotate, feed More arrow ===== */
.clip-photo .clip-media { cursor: pointer; }
.clip-playing .narr-play:not(.playing) { opacity: 0; pointer-events: none; }
.narr-play { transition: opacity .4s ease; }
.photo-hint { position: absolute; top: 64px; left: 50%; transform: translateX(-50%); z-index: 4;
  background: rgba(0,0,0,.55); color: #fff; font-size: .9rem; padding: 6px 14px; border-radius: 999px;
  pointer-events: none; white-space: nowrap; transition: opacity .8s ease; }
.photo-hint-out { opacity: 0; }
.more-below.more-feed { left: auto; right: 6px; top: 50%; bottom: auto; transform: translateY(-50%);
  padding: 6px 8px; animation: more-pulse-r 1.8s ease-in-out infinite; background: rgba(26,92,58,0.55); }
.more-below.more-feed .more-below-text { display: none; }
@media (prefers-reduced-motion: reduce) { .more-below.more-feed { animation: none; } }
@keyframes more-pulse-r { 0%,100% { transform: translateY(-50%); opacity: .75; } 50% { transform: translateY(calc(-50% + 5px)); opacity: 1; } }
.clip-overlay, .narr-play { transition: opacity 0.3s ease; }

/* ===== Batch 3 ===== */
/* Chip rows wrap where there is a mouse / wide screen (no sideways-only scroll) */
@media (min-width: 700px), (hover: hover) and (pointer: fine) {
  .cat-chips { flex-wrap: wrap; overflow-x: visible; -webkit-mask-image: none; mask-image: none; padding-right: 0; }
}
/* Words over a video never block the video's own play controls; buttons stay tappable */
.clip-overlay { pointer-events: none; }
.clip-overlay button, .clip-overlay a, .clip-overlay .btn { pointer-events: auto; }
.clip-playing .clip-overlay button { pointer-events: none; }
/* "Hear the story" always answers the first tap, faded or not */
.narr-play { z-index: 6; }
.clip-playing .narr-play:not(.playing) { opacity: .8; pointer-events: auto; }
.narr-play.playing { top: 16%; bottom: auto; transform: translateX(-50%); }
/* Hearts */
.clip-actions .btn-heart { flex: 0 0 auto; min-width: 84px; background: rgba(255,255,255,.18); color: #fff; border: 2px solid rgba(255,255,255,.6); }
.clip-actions .btn-heart.on { background: #fff; color: #c0392b; border-color: #fff; }
.btn-heart[hidden] { display: none !important; }
.heart-pop { animation: heart-pop .35s ease; }
@keyframes heart-pop { 50% { transform: scale(1.15); } }
.love-info { margin: 0 0 4px; font-size: .95rem; color: #f3d9d6; }
.love-info[hidden] { display: none; }
.home-hearts { margin: 0; text-align: center; font-size: 1.05rem; color: #8a2f25; font-weight: 600; pointer-events: none; user-select: none; }
.home-hearts[hidden] { display: none; }
/* Recording: countdown + flip */
.rec-wrap { position: relative; }
#preview.mirror { transform: scaleX(-1); }
.countdown { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(0,0,0,.45); color: #fff; pointer-events: none; border-radius: inherit; }
.countdown[hidden] { display: none; }
.countdown-num { font-size: 8rem; font-weight: 800; line-height: 1; text-shadow: 0 4px 18px rgba(0,0,0,.5); }
.countdown-sub { font-size: 1.2rem; margin-top: 8px; }
.cd-pop { animation: cd-pop .9s ease-out; }
@keyframes cd-pop { 0% { transform: scale(1.6); opacity: 0; } 30% { transform: scale(1); opacity: 1; } 100% { opacity: .9; } }
.rec-row { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; }
.rec-row .timer { margin: 0; }
.btn-flip { width: auto; min-height: 52px; padding: 10px 16px; font-size: 1.05rem; }
.btn-flip[hidden] { display: none; }
/* Photo editor (full screen, controls in their own rows, never under the picture) */
.photo-editor { position: fixed; inset: 0; z-index: 60; background: #111; color: #fff; display: flex; flex-direction: column;
  padding: calc(10px + var(--safe-top, 0px)) 12px calc(12px + var(--safe-bottom, 0px)); gap: 10px; }
.photo-editor[hidden] { display: none; }
.pe-title { margin: 0; text-align: center; font-size: 1.2rem; font-weight: 700; }
.pe-stage { position: relative; flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.pe-stage canvas { display: block; max-width: 100%; max-height: 100%; }
.pe-cropbox { position: absolute; border: 3px solid #fff; box-shadow: 0 0 0 9999px rgba(0,0,0,.55); touch-action: none; cursor: move; }
.pe-cropbox[hidden] { display: none; }
.pe-h { position: absolute; width: 34px; height: 34px; background: #fff; border-radius: 50%; border: 3px solid #1a5c3a; }
.pe-h[data-h="tl"] { left: -17px; top: -17px; } .pe-h[data-h="tr"] { right: -17px; top: -17px; }
.pe-h[data-h="bl"] { left: -17px; bottom: -17px; } .pe-h[data-h="br"] { right: -17px; bottom: -17px; }
.pe-tools, .pe-actions { display: flex; gap: 10px; }
.pe-tools .btn, .pe-actions .btn { flex: 1; min-height: 56px; }
.pe-bright { display: flex; align-items: center; gap: 12px; font-size: 1.05rem; }
.pe-bright input { flex: 1; height: 36px; }
/* Welcome video */
.welcome-video { position: fixed; inset: 0; z-index: 70; background: #000; display: flex; flex-direction: column; }
.welcome-video[hidden] { display: none; }
.welcome-video video { flex: 1 1 auto; min-height: 0; width: 100%; object-fit: contain; background: #000; }
.wv-bar { display: flex; gap: 10px; padding: 10px 12px calc(14px + var(--safe-bottom, 0px)); }
.wv-bar .btn { flex: 1; min-height: 60px; font-size: 1.25rem; }
@media (max-width: 390px) {
  .countdown-num { font-size: 6.5rem; }
  .clip-actions .btn-heart { min-width: 70px; }
  .clip-actions { gap: 8px; }
}
.pe-stage { padding: 18px; }
.photo-editor .btn-ghost { color: #fff; border: 2px solid rgba(255,255,255,.7); background: transparent; }
