/* Lana & Matt wedding feed. Mobile-first; desktop just centers a phone-width column. */

:root {
  --accent: #8d9478;          /* program sage */
  --accent-deep: #6f765c;
  --pale: #eefcd9;            /* program pale green */
  --blush: #f4c7c3;           /* program transport-panel pink */
  --bg: #0f100d;
  --fg: #ffffff;
  --fg-dim: rgba(255, 255, 255, 0.72);
  --ink: #2b2e24;             /* text on pale surfaces */
  --glass: rgba(20, 22, 17, 0.42);
  --glass-line: rgba(255, 255, 255, 0.16);

  --serif: 'Cormorant Garamond', 'Times New Roman', serif;
  --display: 'Italiana', 'Cormorant Garamond', serif;
  --script: 'Pinyon Script', cursive;
  --ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --vh: 100svh;               /* fallback for browsers without dvh */
  --col: min(100vw, 480px);   /* phone-width column on desktop */
  --rail-h: 58px;
  --feed-h: calc(var(--vh) - var(--rail-h) - var(--safe-b));
}
@supports (height: 100dvh) { :root { --vh: 100dvh; } }

/* Appearance tokens (surfaces around the media; photos/videos stay on black in both). */
:root, :root[data-theme="light"] {
  --surface: #ffffff; --surface-2: #f3f4ef; --line: #e6e8df; --field: #fafaf7;
  --text: #2b2e24; --text-2: #5e6254; --text-3: #a3a697;
  --sheet-shadow: 0 -10px 40px rgba(0,0,0,.18);
}
:root[data-theme="dark"] {
  --surface: #0f100d; --surface-2: #1c1e19; --line: rgba(255,255,255,.1); --field: rgba(255,255,255,.06);
  --text: #ffffff; --text-2: rgba(255,255,255,.72); --text-3: rgba(255,255,255,.45);
  --sheet-shadow: 0 -10px 40px rgba(0,0,0,.5);
}
/* Velo's overshooting ease for switches and segment indicators */
:root { --spring: cubic-bezier(.68,-.55,.265,1.55); }

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--surface);
  color: var(--fg);
  transition: background .3s ease;
  font-family: var(--ui);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

#app {
  position: relative;
  width: var(--col);
  height: var(--vh);
  margin: 0 auto;
  overflow: hidden;
  background: var(--surface);
  transition: background .3s ease;
}

/* ---------- Top bar ---------- */
.topbar {
  position: absolute; inset: 0 0 auto 0; z-index: 20;
  display: grid; grid-template-columns: 44px 1fr 44px; align-items: center;
  padding: calc(var(--safe-t) + 10px) 14px 10px;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.round-btn {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--glass); border: 1px solid var(--glass-line);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  transition: transform .15s ease, background .2s ease;
}
.round-btn:active { transform: scale(.92); }
.round-btn svg { width: 22px; height: 22px; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; fill: none; }
#btn-post { background: var(--accent); border-color: rgba(255,255,255,.25); }
.lang-btn { font-size: 13px; font-weight: 600; letter-spacing: .06em; }

.wordmark {
  margin: 0; text-align: center; pointer-events: none; white-space: nowrap;
  font-family: var(--script); font-weight: 400; font-size: 30px; line-height: 1; letter-spacing: 0;
  text-shadow: 0 1px 12px rgba(0,0,0,.45);
}
/* Over photos there is no solid color to cut the over/under gaps from, so draw plain rings. */
.wordmark .rings { height: .72em; color: #eef0e6; filter: drop-shadow(0 1px 6px rgba(0,0,0,.45)); }
.wordmark .rings .halo, .wordmark .rings .gem-bg { display: none; }

/* ---------- Toast / pills ---------- */
.toast, .pill, .upload-chip {
  position: absolute; left: 50%; transform: translateX(-50%); z-index: 30;
  border-radius: 999px; font-size: 14px; font-weight: 600; white-space: nowrap;
  box-shadow: 0 6px 24px rgba(0,0,0,.35);
}
.toast { bottom: calc(var(--safe-b) + var(--rail-h) + 20px); padding: 12px 18px; background: rgba(0,0,0,.82); max-width: calc(var(--col) - 40px); white-space: normal; text-align: center; }

/* ---------- Welcome (white like the program's cover; dark in dark mode) ---------- */
.welcome {
  position: absolute; inset: 0; z-index: 50;
  display: grid; place-items: center;
  padding: calc(var(--safe-t) + 24px) 24px calc(var(--safe-b) + 24px + var(--kb, 0px));
  background: var(--surface); color: var(--text);
  transition: opacity .35s ease, transform .35s ease, padding-bottom .2s ease, background .3s ease, color .3s ease;
}
.welcome.leaving { opacity: 0; transform: scale(1.03); pointer-events: none; }
.welcome-card { width: 100%; max-width: 360px; text-align: center; }
.welcome-controls { display: flex; justify-content: center; margin: 0 auto 42px; }
.welcome-theme { display: flex; justify-content: center; margin-top: 22px; }

/* Language switch: sliding pill (Velo .gran-toggle) */
.seg {
  position: relative; display: grid; grid-template-columns: 1fr 1fr; width: 232px; flex: 0 0 auto;
  padding: 3px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line);
}
.seg-pill {
  position: absolute; top: 3px; bottom: 3px; left: 3px; width: calc(50% - 3px); border-radius: 999px;
  background: var(--accent); box-shadow: 0 2px 8px rgba(141,148,120,.35);
  transition: transform .45s var(--spring);
}
.seg[data-lang="pt"] .seg-pill, .seg[data-idx="1"] .seg-pill { transform: translateX(100%); }
.seg button {
  position: relative; z-index: 1; height: 34px; border-radius: 999px;
  font-size: 15px; font-weight: 600; color: var(--text-3); transition: color .25s ease;
}
.seg button[aria-checked="true"] { color: #fff; }

/* Theme switch (Velo ThemeSwitch): 52×28 track, 20px thumb slides 24px, sun + moon on the track */
.theme-switch {
  position: relative; flex: 0 0 auto; width: 52px; height: 28px; border-radius: 999px; padding: 0;
  background: #e3e7d8; border: 1px solid #d5dbc6; transition: background .3s ease, border-color .3s ease;  /* pale sage (light) */
}
.theme-switch[aria-checked="true"] { background: var(--accent); border-color: transparent; }
.ts-thumb {
  position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: transform .45s var(--spring);
}
.theme-switch[aria-checked="true"] .ts-thumb { transform: translateX(24px); }
.ts-icon { position: absolute; top: 3px; width: 20px; height: 20px; display: grid; place-items: center; pointer-events: none; }
.ts-sun { left: 3px; } .ts-moon { right: 3px; }
.ts-icon svg { width: 12px; height: 12px; }
.ts-sun svg { fill: var(--accent); stroke: var(--accent); stroke-width: 2; stroke-linecap: round; }
.ts-moon svg { fill: #b3b8a2; }
.theme-switch[aria-checked="true"] .ts-sun svg { fill: rgba(255,255,255,.7); stroke: rgba(255,255,255,.7); }
/* the icon under the thumb is sage in both modes so it stays visible on the white thumb */
.theme-switch[aria-checked="true"] .ts-moon svg { fill: var(--accent); }
.ts-icon { z-index: 1; }

.rings { display: inline-block; height: .56em; width: auto; aspect-ratio: 56 / 36; margin: 0 .12em; vertical-align: .02em; overflow: visible; }
.rings path, .rings circle { fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.rings .halo { stroke: var(--halo, var(--surface)); stroke-width: 3.6; }
.rings .gem-bg { fill: var(--halo, var(--surface)); stroke: var(--halo, var(--surface)); stroke-width: 2.6; }
.welcome-names {
  margin: 0; font-family: var(--script); font-weight: 400; color: var(--accent);
  font-size: clamp(46px, 15vw, 64px); line-height: 1.15; white-space: nowrap;
  margin-top: 6px;
}
.welcome-names .rings { height: .62em; color: var(--accent); stroke-width: 1.2; }
.welcome-place { margin: 14px 0 0; font-family: var(--serif); font-size: 17px; font-weight: 500; letter-spacing: .18em; text-transform: uppercase; color: var(--text-2); }
.welcome-date { margin: 4px 0 34px; font-family: var(--serif); font-size: 15px; letter-spacing: .22em; color: var(--text-3); }
.welcome-form { display: grid; gap: 10px; text-align: left; }
.welcome-form input {
  width: 100%; height: 54px; padding: 0 16px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--field); color: var(--text);
  font: 500 17px var(--ui);  /* ≥16px so iOS doesn't zoom on focus */
}
.welcome-form input::placeholder { color: var(--text-3); }
.welcome-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(141,148,120,.2); }
.welcome .btn-primary:disabled { opacity: 1; background: var(--surface-2); color: var(--text-3); box-shadow: none; }
.btn-primary {
  height: 54px; border-radius: 14px; margin-top: 6px;
  background: var(--accent); color: #fff; font-size: 17px; font-weight: 600; letter-spacing: .01em;
  box-shadow: 0 8px 20px rgba(141,148,120,.3);
  transition: transform .12s ease, opacity .2s ease;
}
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled { opacity: .45; box-shadow: none; }

/* ---------- Feed ---------- */
.feed {
  position: absolute; inset: 0 0 calc(var(--rail-h) + var(--safe-b)) 0;
  overflow-y: scroll; overflow-x: hidden;
  scroll-snap-type: y mandatory;
  overscroll-behavior-y: contain;
  overflow-anchor: none;      /* we compensate scroll ourselves; avoid Chrome double-adjusting */
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.feed::-webkit-scrollbar { display: none; }
.feed.no-snap { scroll-snap-type: none; }

.card {
  position: relative; height: var(--feed-h); width: 100%;
  scroll-snap-align: start; scroll-snap-stop: always;
  overflow: hidden; background: #000;
  contain: layout paint;
}
.card.arrive { animation: arrive .45s cubic-bezier(.2,.8,.2,1); }
@keyframes arrive { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }

.media { position: absolute; inset: 0; }
.media-bg { position: absolute; inset: -40px; background-size: cover; background-position: center; filter: blur(28px) brightness(.55) saturate(1.1); display: none; }
.media-img, .media-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.fit-contain .media-bg { display: block; }
.fit-contain .media-img, .fit-contain .media-video { object-fit: contain; }
.card.video .media-video { opacity: 0; transition: opacity .25s ease; }
.card.video.playing .media-video { opacity: 1; }
.card.paused::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 76px; height: 76px; margin: -38px 0 0 -38px;
  border-radius: 50%; background: rgba(0,0,0,.35) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="white" d="M8 5.5v13l11-6.5z"/></svg>') center/40px no-repeat;
  pointer-events: none;
}

.scrim { position: absolute; left: 0; right: 0; pointer-events: none; }
.scrim-top { top: 0; height: 130px; background: linear-gradient(rgba(0,0,0,.45), transparent); }
.scrim-bottom { bottom: 0; height: 46%; background: linear-gradient(transparent, rgba(0,0,0,.25) 35%, rgba(0,0,0,.72)); }

/* Right rail */
.rail {
  position: absolute; right: 8px; bottom: 96px; z-index: 5;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.rail-btn { display: flex; flex-direction: column; align-items: center; gap: 3px; width: 52px; min-height: 44px; }
.rail-btn svg { width: 32px; height: 32px; fill: none; stroke: #fff; stroke-width: 1.8; stroke-linejoin: round; filter: drop-shadow(0 1px 6px rgba(0,0,0,.4)); transition: transform .2s ease; }
.rail-btn.more svg { fill: #fff; stroke: none; width: 26px; }
.rail-btn.save svg { fill: #fff; stroke: none; width: 28px; height: 28px; }
.rail-btn .count { font-size: 13px; font-weight: 600; text-shadow: 0 1px 4px rgba(0,0,0,.6); }
.heart.on svg { fill: var(--accent); stroke: var(--accent); }
.heart.on svg path { filter: drop-shadow(0 0 8px rgba(141,148,120,.8)); }
.heart.bump svg { animation: bump .35s ease; }
@keyframes bump { 40% { transform: scale(1.3); } 100% { transform: scale(1); } }

/* Author + caption */
.meta {
  position: absolute; left: 14px; right: 76px; bottom: 70px; z-index: 5;
  text-shadow: 0 1px 6px rgba(0,0,0,.55);
}
.who { display: flex; align-items: baseline; gap: 6px; font-size: 15px; }
.who b { font-weight: 700; max-width: 70%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who .dot, .who time { color: var(--fg-dim); font-size: 13px; }
.caption {
  margin: 6px 0 0; font-size: 15px; line-height: 1.35; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.caption.open { -webkit-line-clamp: unset; display: block; max-height: 40vh; overflow-y: auto; }

/* Video progress (tall invisible hit area, thin visible bar) */
.progress {
  position: absolute; left: 0; right: 0; bottom: 52px; height: 22px; z-index: 6;
  display: flex; align-items: flex-end; touch-action: none; cursor: pointer;
}
.progress::before { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: rgba(255,255,255,.25); }
.progress i { position: relative; display: block; width: 100%; height: 2px; background: #fff; transform-origin: left; transform: scaleX(0); }
.progress.scrubbing::before, .progress.scrubbing i { height: 5px; }
.progress.scrubbing i { background: var(--accent); }

/* Persistent comment bar */
.comment-bar {
  position: absolute; left: 12px; right: 12px; bottom: 8px; z-index: 6;
  height: 42px; padding: 0 16px; border-radius: 21px; text-align: left;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.18);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  color: var(--fg-dim); font-size: 15px;
}

/* Processing */
.processing {
  position: absolute; inset: 0; z-index: 4; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: rgba(0,0,0,.45); font-weight: 600; font-size: 15px;
}
.spinner { width: 40px; height: 40px; border-radius: 50%; border: 3px solid rgba(255,255,255,.25); border-top-color: var(--accent); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Double-tap hearts */
.burst { position: absolute; inset: 0; z-index: 7; pointer-events: none; }
.burst span { position: absolute; width: var(--s); height: var(--s); margin: calc(var(--s) / -2) 0 0 calc(var(--s) / -2); }
.burst svg { width: 100%; height: 100%; }
.burst .pop svg { fill: #fff; filter: drop-shadow(0 4px 18px rgba(0,0,0,.35)); }
.burst .pop { animation: pop .8s cubic-bezier(.2,1.4,.4,1) forwards; }
.burst .float { opacity: 0; animation: float 1.1s ease-out var(--d) forwards; }
.burst .sage svg { fill: var(--accent); }
.burst .blush svg { fill: var(--blush); }
@keyframes pop { 0% { transform: scale(0) rotate(-12deg); opacity: 0; } 25% { transform: scale(1.15) rotate(-6deg); opacity: 1; } 45% { transform: scale(.95); } 75% { opacity: 1; } 100% { transform: scale(1.1) translateY(-40px); opacity: 0; } }
@keyframes float { 0% { transform: translate(0, 0) scale(.6); opacity: 0; } 15% { opacity: 1; } 100% { transform: translate(var(--dx), -220px) scale(1.1); opacity: 0; } }

.sound-hint {
  position: absolute; left: 50%; top: calc(var(--safe-t) + 70px); transform: translateX(-50%); z-index: 8;
  padding: 8px 14px; border-radius: 999px; background: rgba(0,0,0,.55); font-size: 13px; font-weight: 600; white-space: nowrap;
  animation: fadeout 3.2s ease forwards; pointer-events: none;
}
@keyframes fadeout { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }

/* New-posts pill */
.pill {
  top: calc(var(--safe-t) + 66px); padding: 9px 16px; background: var(--accent); color: #fff;
  animation: drop .3s cubic-bezier(.2,1.2,.4,1);
}
@keyframes drop { from { transform: translate(-50%, -16px); opacity: 0; } }

.empty { height: var(--feed-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 32px; text-align: center; font-family: var(--serif); font-size: 22px; color: var(--fg-dim); }
/* Empty feed: sage camera badge with a flash + two sparkles. */
.empty-badge { position: relative; width: 112px; height: 112px; border-radius: 50%; display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 24%, transparent); animation: cam-bob 3.2s ease-in-out infinite; }
.empty-badge:active { transform: scale(.94); }
.empty-cam { width: 60px; height: 60px; fill: var(--accent-deep); }
:root[data-theme="dark"] .empty-cam { fill: #c9cfb8; }
.empty-cam .duo { opacity: .22; }
.empty-spark { position: absolute; fill: #e8a9a2; opacity: 0; animation: spark 3.2s ease-in-out infinite; }
.empty-spark:nth-of-type(2) { width: 22px; height: 22px; top: 8px; right: 6px; }
.empty-spark:nth-of-type(3) { width: 14px; height: 14px; top: 30px; right: -4px; animation-delay: .25s; }
@keyframes cam-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes spark { 0%, 55%, 100% { opacity: 0; transform: scale(.4) rotate(0); } 65% { opacity: 1; transform: scale(1.1) rotate(20deg); } 80% { opacity: 0; transform: scale(.8) rotate(35deg); } }
@media (prefers-reduced-motion: reduce) { .empty-badge, .empty-spark { animation: none; } .empty-spark { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .card.arrive, .burst .pop, .burst .float, .pill { animation: none; }
}

/* ---------- Upload chip ---------- */
.upload-chip {
  top: calc(var(--safe-t) + 66px); display: flex; align-items: center; gap: 10px;
  padding: 8px 16px 8px 8px; background: rgba(15,16,13,.88); border: 1px solid var(--glass-line);
}
.upload-chip .ring {
  width: 26px; height: 26px; border-radius: 50%;
  background: conic-gradient(var(--accent) var(--p, 0deg), rgba(255,255,255,.18) 0);
  -webkit-mask: radial-gradient(circle, transparent 8px, #000 9px); mask: radial-gradient(circle, transparent 8px, #000 9px);
}
.upload-chip.done { background: var(--accent); }
.upload-chip .chip-check { width: 26px; height: 26px; display: grid; place-items: center; font-size: 16px; }
.upload-chip.error { background: #7a2e2a; padding-left: 14px; cursor: pointer; }

/* ---------- Composer ---------- */
.composer {
  position: absolute; inset: 0; z-index: 40; display: flex; flex-direction: column;
  background: var(--bg); color: var(--fg);
  padding: calc(var(--safe-t) + 6px) 0 calc(var(--safe-b) + 14px + var(--kb, 0px));
  transform: translateY(100%); transition: transform .3s cubic-bezier(.2,.8,.2,1), padding-bottom .2s ease;
}
.composer.open { transform: none; }
.composer-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 6px 16px 10px; }
.composer-cancel { justify-self: start; min-height: 44px; font-size: 17px; color: var(--fg-dim); font-weight: 500; }
.composer-count { font-weight: 700; }
.composer-previews {
  flex: 1; min-height: 0; display: flex; gap: 10px; padding: 0 16px;
  overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none;
}
.composer-previews::-webkit-scrollbar { display: none; }
.composer-preview {
  flex: 0 0 100%; scroll-snap-align: center; border-radius: 18px; overflow: hidden; background: #1c1e18;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.composer-previews:has(.composer-preview + .composer-preview) .composer-preview { flex-basis: 82%; }
.composer-preview img, .composer-preview video { width: 100%; height: 100%; object-fit: contain; display: block; }
.composer-foot { display: grid; gap: 10px; padding: 14px 16px 0; }
.composer-caption {
  width: 100%; resize: none; border-radius: 14px; border: 1.5px solid rgba(255,255,255,.14);
  padding: 12px 14px; background: rgba(255,255,255,.06); color: #fff; font: 400 16px/1.35 var(--ui);
}
.composer-caption::placeholder { color: rgba(255,255,255,.4); }
.composer-caption:focus { outline: none; border-color: var(--accent); }
.composer-share { width: 100%; }

/* ---------- Action sheet ---------- */
.action-wrap { position: absolute; inset: 0; z-index: 60; }
.action-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.45); opacity: 0; transition: opacity .25s ease; }
.action-sheet {
  position: absolute; left: 10px; right: 10px; bottom: calc(var(--safe-b) + 10px);
  display: grid; gap: 8px; transform: translateY(120%); transition: transform .25s cubic-bezier(.2,.8,.2,1);
}
.action-wrap.open .action-backdrop { opacity: 1; }
.action-wrap.open .action-sheet { transform: none; }
.action-title { margin: 0; padding: 14px; border-radius: 14px 14px 0 0; background: rgba(40,42,36,.96); color: var(--fg-dim); font-size: 13px; text-align: center; }
.action-danger { margin-top: -8px; height: 56px; border-radius: 0 0 14px 14px; background: rgba(40,42,36,.96); color: #ff6b61; font-size: 18px; font-weight: 600; border-top: 1px solid rgba(255,255,255,.08); }
.action-cancel { height: 56px; border-radius: 14px; background: #2a2c26; font-size: 18px; font-weight: 600; }

/* ---------- Comments half-sheet ---------- */
.card { transition: none; }
.card.shrunk .media, .card.shrunk .burst { transform: scale(.45); transform-origin: top center; transition: transform .28s cubic-bezier(.2,.8,.2,1); }
.card .media { transition: transform .28s cubic-bezier(.2,.8,.2,1); }
.card.shrunk .rail, .card.shrunk .meta, .card.shrunk .comment-bar, .card.shrunk .progress, .card.shrunk .scrim-bottom { opacity: 0; pointer-events: none; transition: opacity .15s ease; }
.comments-wrap { position: absolute; inset: 0; z-index: 45; pointer-events: none; }
.comments-wrap.open { pointer-events: auto; }
.comments-top { position: absolute; left: 0; right: 0; top: 0; height: 45%; }
.comments-sheet {
  position: absolute; left: 0; right: 0; bottom: 0; height: calc(55% + var(--kb, 0px));
  display: flex; flex-direction: column;
  background: #fff; color: var(--ink); border-radius: 20px 20px 0 0;
  box-shadow: 0 -10px 40px rgba(0,0,0,.35);
  transform: translateY(100%); transition: transform .28s cubic-bezier(.2,.8,.2,1), height .2s ease;
}
.comments-wrap.open .comments-sheet { transform: none; }
.grab { display: grid; place-items: center; height: 22px; touch-action: none; }
.grab span { width: 40px; height: 5px; border-radius: 3px; background: #d6d8cf; }
.comments-title { margin: 0 0 6px; text-align: center; font: 600 16px var(--ui); touch-action: none; }
.comments-list { flex: 1; min-height: 0; margin: 0; padding: 4px 16px 10px; list-style: none; overflow-y: auto; overscroll-behavior: contain; }
.comments-empty { padding: 30px 10px; text-align: center; font-family: var(--serif); font-size: 19px; color: #7d826d; }
.cmt { position: relative; display: flex; gap: 10px; padding: 10px 28px 10px 0; }
.avatar { flex: 0 0 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 13px; font-weight: 700; }
.c-body { min-width: 0; }
.c-head { display: flex; gap: 8px; align-items: baseline; font-size: 13px; }
.c-head time { color: #8a8e80; }
.c-body p { margin: 2px 0 0; font-size: 15px; line-height: 1.35; overflow-wrap: anywhere; }
.c-more { position: absolute; right: 0; top: 6px; width: 32px; height: 32px; color: #8a8e80; font-size: 18px; }
.comments-compose { border-top: 1px solid #eceee6; padding: 8px 12px calc(var(--safe-b) + 8px); background: #fff; }
.emoji-row { display: flex; justify-content: space-between; padding: 2px 4px 8px; }
.emoji { width: 44px; height: 40px; font-size: 26px; border-radius: 10px; transition: transform .12s ease; }
.emoji:active { transform: scale(1.25); }
.comment-form { display: flex; gap: 8px; }
.comment-input { flex: 1; min-width: 0; height: 44px; padding: 0 16px; border-radius: 22px; border: 1.5px solid #dfe2d6; background: #f7f8f3; font: 16px var(--ui); color: var(--ink); }
.comment-send { width: 44px; height: 44px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; }
.comment-send:disabled { background: #d6d8cf; }
.comment-send svg { width: 20px; height: 20px; fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Themed surfaces (composer, sheets, empty state) ---------- */
.composer { background: var(--surface); color: var(--text); }
.composer-cancel { color: var(--text-2); }
.composer-caption { background: var(--field); border-color: var(--line); color: var(--text); }
.composer-caption::placeholder { color: var(--text-3); }
.empty { color: var(--text-2); }
.comments-sheet { background: var(--surface); color: var(--text); box-shadow: var(--sheet-shadow); }
.comments-compose { background: var(--surface); border-top-color: var(--line); }
.comment-input { background: var(--field); border-color: var(--line); color: var(--text); }
.comment-send:disabled { background: var(--surface-2); }
.c-head time, .c-more, .comments-empty { color: var(--text-3); }
.action-title, .action-danger { background: var(--surface); color: var(--text-3); }
.action-danger { color: #d9534a; border-top-color: var(--line); }
.action-cancel { background: var(--surface); color: var(--text); }

/* ---------- Settings sheet (Velo menu rows) ---------- */
.settings-wrap { position: absolute; inset: 0; z-index: 55; }
.settings-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.25); opacity: 0; transition: opacity .25s ease; }
.settings-sheet {
  /* Drops down from the settings button (top right) rather than rising from the bottom. */
  position: absolute; top: calc(var(--safe-t) + 62px); right: 12px; width: min(340px, calc(100% - 24px));
  padding: 6px 10px 12px; border-radius: 20px;
  background: var(--surface); color: var(--text); box-shadow: 0 16px 44px rgba(0,0,0,.28);
  transform-origin: calc(100% - 22px) -10px; transform: translateY(-8px) scale(.92); opacity: 0;
  transition: transform .35s var(--spring), opacity .2s ease, background .3s ease;
}
.settings-sheet::before {
  content: ''; position: absolute; top: -7px; right: 16px; width: 16px; height: 16px; background: var(--surface); transform: rotate(45deg); border-radius: 3px;
}
.settings-wrap.open .settings-sheet { transform: none; opacity: 1; }
.settings-wrap.open .settings-backdrop { opacity: 1; }
.set-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 60px; padding: 0 16px; margin-top: 8px; border-radius: 16px; background: var(--surface-2);
  font-size: 16px; font-weight: 600;
}
.set-row .seg { background: var(--surface); }

/* ---------- Coachmarks ---------- */
.coach { position: absolute; inset: 0; z-index: 70; opacity: 0; transition: opacity .3s ease; }
.coach.open { opacity: 1; }
.coach.leaving { opacity: 0; pointer-events: none; }
.coach-spot {
  position: absolute; box-shadow: 0 0 0 200vmax rgba(8,9,7,.72); pointer-events: none;
  outline: 2px solid rgba(141,148,120,.9); outline-offset: 0;
  transition: left .4s cubic-bezier(.2,.8,.2,1), top .4s cubic-bezier(.2,.8,.2,1), width .4s cubic-bezier(.2,.8,.2,1), height .4s cubic-bezier(.2,.8,.2,1), border-radius .4s ease;
}
.coach[data-gesture="swipe"] .coach-spot, .coach[data-gesture="doubletap"] .coach-spot { outline: none; }
.coach-tip {
  position: absolute; left: 16px; right: 16px; padding: 18px 18px 14px; border-radius: 18px;
  background: var(--surface); color: var(--text); box-shadow: 0 12px 40px rgba(0,0,0,.35);
  transition: top .4s cubic-bezier(.2,.8,.2,1), bottom .4s cubic-bezier(.2,.8,.2,1);
}
.coach-tip[data-arrow]:not([data-arrow=""])::before {
  content: ''; position: absolute; left: var(--ax, 50%); width: 16px; height: 16px; background: var(--surface); transform: rotate(45deg);
}
.coach-tip[data-arrow="up"]::before { top: -7px; }
.coach-tip[data-arrow="down"]::before { bottom: -7px; }
.coach-title { margin: 0; font-family: var(--serif); font-size: 23px; font-weight: 600; color: var(--accent); }
.coach-body { margin: 6px 0 14px; font-size: 15px; line-height: 1.4; color: var(--text-2); }
.coach-foot { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
.coach-skip { justify-self: start; min-height: 44px; padding: 0 4px; color: var(--text-3); font-size: 15px; font-weight: 600; }
.coach-dots { display: flex; gap: 6px; }
.coach-dots i { width: 6px; height: 6px; border-radius: 3px; background: var(--line); transition: width .3s var(--spring), background .3s ease; }
.coach-dots i.on { width: 18px; background: var(--accent); }
.coach-next { justify-self: end; min-height: 40px; padding: 0 18px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 15px; font-weight: 600; }

/* ---------- Bottom tab bar (Reels-style) ---------- */
.tabbar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 25;
  height: calc(var(--rail-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: 1fr 1fr auto 1fr 1fr; align-items: center; justify-items: center;
  background: var(--surface); border-top: 1px solid var(--line);
  transition: background .3s ease;
}
.tab { position: relative; width: 64px; height: 48px; display: grid; place-items: center; color: var(--text-3); transition: color .2s ease; }
.tab svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.tab .solid { fill: currentColor; stroke: none; }
.tab.on { color: var(--text); }
.tab::after { content: ''; position: absolute; bottom: 4px; width: 4px; height: 4px; border-radius: 2px; background: var(--accent); opacity: 0; transform: scale(0); transition: opacity .2s ease, transform .35s var(--spring); }
.tab.on::after { opacity: 1; transform: none; }
.tab:active svg { transform: scale(.9); }
.tab-post {
  width: 56px; height: 40px; border-radius: 14px; display: grid; place-items: center;
  background: var(--accent); box-shadow: 0 4px 14px rgba(141,148,120,.4); transition: transform .15s ease;
}
.tab-post:active { transform: scale(.94); }
.tab-post svg { width: 24px; height: 24px; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; fill: none; }
.tab-post.disabled { opacity: .45; }

/* ---------- Grid view ---------- */
.gridview {
  position: absolute; inset: 0 0 calc(var(--rail-h) + var(--safe-b)) 0; overflow-y: auto; overscroll-behavior: contain;
  padding-top: calc(var(--safe-t) + 64px); background: var(--surface);
}
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; }
.tile { position: relative; aspect-ratio: 3 / 4; padding: 0; overflow: hidden; background: var(--surface-2); }
.tile img, .tile video { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s ease; pointer-events: none; }
.tile:active img { transform: scale(.97); }
.tile-tag, .tile-hearts {
  position: absolute; display: flex; align-items: center; gap: 3px; padding: 2px 6px; border-radius: 6px;
  background: rgba(0,0,0,.45); color: #fff; font-size: 11px; font-weight: 700;
}
.tile-tag { top: 6px; right: 6px; }
.tile-tag svg { width: 12px; height: 12px; fill: #fff; }
.tile-hearts { left: 6px; bottom: 6px; }
.gridview ~ .topbar, #app:has(.gridview:not([hidden])) .topbar .wordmark { color: var(--text); text-shadow: none; }
#app:has(.gridview:not([hidden])) .wordmark .rings { color: var(--accent); filter: none; }
#app:has(.gridview:not([hidden])) .topbar { background: var(--surface); padding-bottom: 10px; }
/* Empty feed has a light background too: same dark wordmark as the grid. */
#app:has(#feed > .empty) .topbar .wordmark { color: var(--text); text-shadow: none; }
#app:has(#feed > .empty) .wordmark .rings { color: var(--accent); filter: none; }

/* ---------- Coach "touch" (borrowed from organizewithlana.com's spaces coachmark) ---------- */
.coach-touch { position: absolute; width: 58px; height: 58px; margin: -29px 0 0 -29px; pointer-events: none; z-index: 2;
  transition: left .4s cubic-bezier(.2,.8,.2,1), top .4s cubic-bezier(.2,.8,.2,1); }
.coach-ring { position: absolute; inset: 0; border-radius: 50%; border: 2px solid #fff; opacity: 0; animation: owl-pulse 1.9s cubic-bezier(.22,1,.36,1) infinite; }
.coach-ring:nth-child(2) { animation-delay: .63s; }
.coach-ring:nth-child(3) { animation-delay: 1.26s; }
.coach-cursor { position: absolute; left: 50%; top: 50%; width: 30px; height: 30px; color: #fff; filter: drop-shadow(0 2px 6px rgba(0,0,0,.5)); animation: owl-tap 1.9s cubic-bezier(.22,1,.36,1) infinite; }
@keyframes owl-pulse { 0% { transform: scale(.35); opacity: .9; } 70% { opacity: .22; } 100% { transform: scale(1.5); opacity: 0; } }
@keyframes owl-tap { 0%, 100% { transform: translate(-50%,-50%) scale(1); } 50% { transform: translate(-50%,-50%) scale(.82); } }
/* double-tap: two quick squeezes + two quick ripples, then a heart */
.coach[data-gesture="doubletap"] .coach-cursor { animation: owl-dtap 1.6s ease-in-out infinite; }
.coach[data-gesture="doubletap"] .coach-ring { animation: owl-dpulse 1.6s cubic-bezier(.22,1,.36,1) infinite; }
.coach[data-gesture="doubletap"] .coach-ring:nth-child(2) { animation-delay: .18s; }
.coach[data-gesture="doubletap"] .coach-ring:nth-child(3) { display: none; }
@keyframes owl-dtap { 0%, 100% { transform: translate(-50%,-50%) scale(1); } 8%, 26% { transform: translate(-50%,-50%) scale(.8); } 17% { transform: translate(-50%,-50%) scale(1); } }
@keyframes owl-dpulse { 0% { transform: scale(.35); opacity: .9; } 40% { transform: scale(1.4); opacity: 0; } 100% { opacity: 0; } }
.coach-heart { position: absolute; left: 50%; top: -34px; transform: translateX(-50%); width: 40px; height: 40px; opacity: 0; display: none; }
.coach-heart svg { width: 100%; height: 100%; fill: var(--accent); filter: drop-shadow(0 2px 8px rgba(0,0,0,.35)); }
.coach[data-gesture="doubletap"] .coach-heart { display: block; animation: coach-heart 1.6s ease-out infinite; }
/* swipe: the touch travels upward with a fading trail */
.coach[data-gesture="swipe"] .coach-touch { animation: owl-swipe 1.9s cubic-bezier(.5,0,.3,1) infinite; }
.coach[data-gesture="swipe"] .coach-ring { animation: none; opacity: .5; transform: scale(.9); }
.coach[data-gesture="swipe"] .coach-ring:nth-child(n+2) { display: none; }
.coach[data-gesture="swipe"] .coach-cursor { animation: none; }
.coach-trail { position: absolute; left: 50%; top: 50%; width: 4px; margin-left: -2px; height: 0; border-radius: 2px; background: linear-gradient(rgba(255,255,255,.7), transparent); display: none; }
.coach[data-gesture="swipe"] .coach-trail { display: block; animation: owl-trail 1.9s cubic-bezier(.5,0,.3,1) infinite; }
@keyframes owl-swipe { 0% { transform: translateY(90px); opacity: 0; } 12% { opacity: 1; } 72% { transform: translateY(-110px); opacity: 1; } 100% { transform: translateY(-130px); opacity: 0; } }
@keyframes owl-trail { 0%, 12% { height: 0; } 72% { height: 120px; } 100% { height: 120px; opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .coach-ring, .coach-cursor, .coach-touch, .coach-trail, .coach-heart { animation: none !important; } }
@keyframes coach-heart { 0%, 30% { opacity: 0; transform: translateX(-50%) scale(.3); } 44% { opacity: 1; transform: translateX(-50%) scale(1.15); } 78% { opacity: 1; transform: translateX(-50%) translateY(-18px) scale(1); } 100% { opacity: 0; transform: translateX(-50%) translateY(-30px); } }
.set-row .seg { width: 190px; }
.set-row .seg button { font-size: 14px; height: 32px; }
#btn-settings svg { width: 27px; height: 27px; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; fill: none; }
#btn-settings .knob { stroke-width: 1.5; stroke-linejoin: round; }
.tab .solid-icon { fill: currentColor; stroke: none; width: 27px; height: 27px; }
#btn-settings.on { color: var(--text); }

/* Sound toggle (videos only), above the heart. Phosphor speaker-simple-none / -slash. */
.rail-btn.sound svg { width: 28px; height: 28px; fill: #fff; stroke: none; }
.rail-btn.sound .snd-on { display: none; }
:root.sound-on .rail-btn.sound .snd-on { display: block; }
:root.sound-on .rail-btn.sound .snd-off { display: none; }

/* Translation toggle under captions/comments */
.tr-toggle { display: block; margin-top: 4px; padding: 2px 0; font-size: 12.5px; font-weight: 600; color: rgba(255,255,255,.62); text-shadow: 0 1px 4px rgba(0,0,0,.5); }
.c-body .tr-toggle { color: var(--text-3); text-shadow: none; font-size: 12px; }

/* "Me" header above your own posts */
.me-head { display: flex; align-items: center; gap: 14px; padding: 6px 16px 16px; color: var(--text); }
.me-avatar { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; font: 600 22px var(--ui); flex: 0 0 auto; }
.me-name { font-family: var(--serif); font-size: 24px; font-weight: 600; line-height: 1.1; }
.me-count { font-size: 14px; color: var(--text-3); margin-top: 2px; }
.me-empty { padding: 50px 30px; text-align: center; font-family: var(--serif); font-size: 20px; color: var(--text-2); }
.me-empty .btn-primary { margin-top: 18px; padding: 0 28px; }
/* Settings popover above the bottom bar (anchored to its button) */
.settings-sheet.from-bottom { top: auto; bottom: calc(var(--rail-h) + var(--safe-b) + 10px); right: 10px;
  transform-origin: var(--ax, 80%) calc(100% + 10px); transform: translateY(8px) scale(.92); }
.settings-sheet.from-bottom::before { top: auto; bottom: -7px; right: auto; left: calc(var(--ax, 80%) - 8px); }
.settings-wrap.open .settings-sheet.from-bottom { transform: none; }
.settings-sheet { border: 1px solid var(--line); }
.me-empty .btn-primary { font-family: var(--ui); }

/* ---------- Share sheet ---------- */
#btn-share { background: var(--accent); border-color: rgba(255,255,255,.25); box-shadow: 0 4px 14px rgba(141,148,120,.35); }
#btn-share svg { width: 22px; height: 22px; fill: #fff; stroke: none; }
.share-wrap { position: absolute; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; }
.share-backdrop { position: absolute; inset: 0; background: rgba(8,9,7,.6); opacity: 0; transition: opacity .25s ease; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.share-card {
  position: relative; width: min(340px, 100%); padding: 26px 22px 20px; border-radius: 24px; text-align: center;
  background: var(--surface); color: var(--text); border: 1px solid var(--line); box-shadow: 0 20px 60px rgba(0,0,0,.35);
  transform: translateY(16px) scale(.96); opacity: 0; transition: transform .4s var(--spring), opacity .2s ease;
}
.share-wrap.open .share-backdrop { opacity: 1; }
.share-wrap.open .share-card { transform: none; opacity: 1; }
.share-close { position: absolute; top: 8px; right: 10px; width: 40px; height: 40px; font-size: 26px; line-height: 1; color: var(--text-3); }
.share-title { margin: 0 0 16px; font-family: var(--script); font-weight: 400; font-size: 38px; color: var(--accent); line-height: 1.1; }
.share-sub { margin: 2px 0 16px; font-size: 14px; color: var(--text-2); }
.share-qr { width: 100%; aspect-ratio: 1; border-radius: 18px; overflow: hidden; background: #fff; display: grid; place-items: center; border: 1px solid var(--line); }
.share-qr .qr { width: 100%; height: 100%; display: block; }
.share-qr image { color: #8d9478; }
.share-url { margin: 12px 0 14px; font-size: 14px; font-weight: 600; letter-spacing: .02em; color: var(--text-2); }
.share-actions { display: grid; gap: 8px; margin-top: 16px; }
.share-native { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; }
.share-native svg { width: 20px; height: 20px; fill: #fff; }
.share-copy { height: 44px; border-radius: 14px; font-weight: 600; color: var(--accent); }

/* Tutorial stand-in post: sits over the feed only while the tour runs */
.tour-demo { position: absolute; inset: 0 0 calc(var(--rail-h) + var(--safe-b)) 0; z-index: 15; background: #000; transition: opacity .35s ease; pointer-events: none; }
.tour-demo.leaving { opacity: 0; }

/* ---------- Carousel posts (up to 10 photos/videos, swipe left/right) ---------- */
.slides {
  position: absolute; inset: 0; display: flex; overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory; overscroll-behavior-x: contain; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.slides::-webkit-scrollbar { display: none; }
.slide { position: relative; flex: 0 0 100%; height: 100%; scroll-snap-align: center; scroll-snap-stop: always; overflow: hidden; }
.card.multi .media-video { opacity: 0; transition: opacity .25s ease; }
.card.multi.playing .media-video { opacity: 1; }
.counter {
  position: absolute; top: calc(var(--safe-t) + 66px); right: 12px; z-index: 6;
  padding: 4px 10px; border-radius: 999px; background: rgba(0,0,0,.5); color: #fff;
  font-size: 13px; font-weight: 700; letter-spacing: .04em; font-variant-numeric: tabular-nums;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); pointer-events: none;
}
.dots { position: absolute; left: 0; right: 0; bottom: 64px; z-index: 6; display: flex; justify-content: center; gap: 5px; pointer-events: none; }
.dots i { width: 6px; height: 6px; border-radius: 3px; background: rgba(255,255,255,.45); transition: width .3s var(--spring), background .2s ease; }
.dots i.on { width: 16px; background: #fff; }
.card.multi .meta { bottom: 84px; }
.card.multi .progress { bottom: 72px; }

.settings-sheet { width: min(360px, calc(100% - 20px)); }
.set-row .seg { width: 206px; }

.feed.off { visibility: hidden; pointer-events: none; }

/* Video finished: dim slightly and offer a replay (no auto-loop). */
.replay { position: absolute; left: 50%; top: 50%; z-index: 4; width: 72px; height: 72px; margin: -36px 0 0 -36px; border-radius: 50%;
  display: grid; place-items: center; background: rgba(0,0,0,.42); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.28); animation: replay-in .22s ease-out; }
.replay svg { width: 34px; height: 34px; fill: #fff; }
.replay:active { transform: scale(.94); }
.card.ended .media-video { filter: brightness(.78); transition: filter .2s ease; }
@keyframes replay-in { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: none; } }
