:root {
  --ink: #080809;
  --paper: #f3efe6;
  --coral: #ff644f;
  --yellow: #f4c84e;
  --muted: rgba(243, 239, 230, .68);
  --line: rgba(243, 239, 230, .26);
  --serif: Georgia, "Times New Roman", serif;
  --sans: Arial, Helvetica, sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--ink); }
body { margin: 0; overflow: hidden; background: var(--ink); color: var(--paper); font-family: var(--sans); }
button, input, a { color: inherit; font: inherit; -webkit-tap-highlight-color: transparent; }
button { border: 0; }
a { text-decoration: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--yellow); outline-offset: 4px; }

.skip-link { position: fixed; z-index: 30; top: 12px; left: 12px; padding: 12px 16px; color: var(--ink); background: var(--yellow); transform: translateY(-160%); }
.skip-link:focus { transform: translateY(0); }

/* Family access */
.family-gate { width: 100%; min-height: 100svh; position: relative; display: grid; grid-template-rows: auto 1fr auto; overflow: auto; padding: 42px clamp(32px, 7vw, 108px) 35px; background: var(--ink) url("assets/family-gate-filmstrip.webp") right center / auto 100% no-repeat; isolation: isolate; }
.family-gate::after { content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .07; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitchTiles'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.42'/%3E%3C/svg%3E"); }
.gate-wordmark { justify-self: start; z-index: 1; font: 400 20px/1 var(--serif); letter-spacing: .28em; }
.gate-content { width: min(570px, 62vw); z-index: 1; align-self: center; padding: 45px 0 30px; }
.gate-content h1 { margin: 0; font: italic 400 clamp(54px, 6.5vw, 92px)/.93 var(--serif); letter-spacing: -.045em; }
.gate-content h1 em { color: var(--paper); font-style: italic; }
.gate-content > p { max-width: 460px; margin: 30px 0 0; color: var(--muted); font-size: 15px; line-height: 1.7; }
.family-join-form { width: min(500px, 100%); display: grid; gap: 25px; margin-top: 38px; }
.family-join-form label { display: grid; gap: 9px; color: var(--paper); font-size: 10px; letter-spacing: .18em; text-transform: uppercase; }
.family-join-form input { width: 100%; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 10px 2px 12px; outline: 0; background: transparent; font-size: 17px; letter-spacing: normal; }
.family-join-form input:focus { border-color: var(--paper); }
.family-join-form button { min-height: 54px; margin-top: 6px; border: 1px solid var(--coral); background: transparent; color: var(--coral); cursor: pointer; text-transform: uppercase; letter-spacing: .16em; font-size: 11px; transition: background .2s, color .2s; }
.family-join-form button:hover { background: var(--coral); color: var(--ink); }
.family-join-form button:disabled { opacity: .55; cursor: wait; }
.family-join-form output { min-height: 17px; color: var(--coral); font-size: 12px; }
.gate-footnote { z-index: 1; align-self: end; margin: 0; color: rgba(243,239,230,.48); font-size: 11px; }

/* Immersive viewer */
.moments-stream { height: 100svh; overflow-y: auto; overscroll-behavior: contain; scroll-snap-type: y mandatory; scrollbar-width: none; }
.moments-stream::-webkit-scrollbar { display: none; }
.moment-slide { height: 100svh; min-height: 100svh; position: relative; display: grid; place-items: center; overflow: hidden; padding: 105px 120px 145px; scroll-snap-align: start; scroll-snap-stop: always; touch-action: pan-y; background: var(--ink); }
.moment-slide img, .moment-slide video { width: auto; height: auto; max-width: min(68vw, 1100px); max-height: calc(100svh - 235px); display: block; object-fit: contain; background: var(--ink); border: 1px solid rgba(243,239,230,.42); box-shadow: 0 22px 55px rgba(0,0,0,.36); }
.moment-slide video { cursor: pointer; }
.heart-burst { position: absolute; z-index: 7; width: 96px; height: 96px; opacity: 0; pointer-events: none; transform: scale(.5); }
.heart-burst svg { width: 100%; height: 100%; fill: var(--coral); filter: drop-shadow(0 10px 22px rgba(0,0,0,.45)); }
.heart-burst.animate { animation: heart-burst .72s ease both; }
@keyframes heart-burst { 0% { opacity: 0; transform: scale(.5); } 28% { opacity: 1; transform: scale(1.13); } 70% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(1.2); } }

.viewer-header { position: fixed; z-index: 8; inset: 0 0 auto; height: 100px; padding: max(30px, env(safe-area-inset-top)) 42px 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; pointer-events: none; }
.viewer-header > * { pointer-events: auto; }
.viewer-wordmark { font: 400 19px/1 var(--serif); letter-spacing: .34em; }
#viewer-context { padding-top: 2px; font-size: 11px; letter-spacing: .24em; text-transform: uppercase; }
.mode-trigger { justify-self: center; display: grid; justify-items: center; gap: 7px; padding: 0 12px 8px; background: transparent; cursor: pointer; }
.mode-trigger svg { width: 16px; height: 9px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.member-avatar { justify-self: end; width: 42px; height: 42px; margin-top: -10px; display: grid; place-items: center; border: 1px solid rgba(243,239,230,.48); border-radius: 50%; background: rgba(8,8,9,.52); cursor: pointer; font: 18px var(--serif); }
.icon-control { width: 44px; height: 44px; padding: 10px; display: grid; place-items: center; cursor: pointer; background: transparent; }
.icon-control svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.35; stroke-linecap: round; stroke-linejoin: round; }

.edge-control { position: fixed; z-index: 8; top: 50%; width: 72px; height: 90px; display: grid; place-items: center; background: transparent; cursor: pointer; transform: translateY(-50%); }
.edge-control svg { width: 36px; fill: none; stroke: currentColor; stroke-width: 1.1; stroke-linecap: round; stroke-linejoin: round; }
.edge-previous { left: 0; }
.edge-next { right: 0; }
.edge-control:disabled { opacity: .2; cursor: default; }

.viewer-footer { position: fixed; z-index: 8; inset: auto 0 0; min-height: 124px; padding: 0 42px max(30px, env(safe-area-inset-bottom)); display: grid; grid-template-columns: minmax(230px, 1fr) minmax(360px, 1.65fr) minmax(220px, 1fr); gap: 34px; align-items: end; pointer-events: none; }
.viewer-footer > * { pointer-events: auto; }
.moment-copy time { display: block; font-size: 10px; line-height: 1; letter-spacing: .24em; text-transform: uppercase; }
.moment-copy p { max-width: 350px; margin: 14px 0 0; color: var(--paper); font: 400 clamp(23px, 2.1vw, 32px)/1.1 var(--serif); }
.moment-progress { display: flex; align-items: center; height: 28px; gap: 0; }
.progress-marker { flex: 1; min-width: 1px; height: 20px; padding: 0; position: relative; cursor: pointer; background: transparent; }
.progress-marker::after { content: ""; position: absolute; left: 50%; top: 7px; width: 1px; height: 7px; background: rgba(243,239,230,.48); transform: translateX(-50%); transition: height .2s, top .2s, background .2s; }
.progress-marker[aria-current="true"]::after { width: 3px; height: 16px; top: 2px; background: var(--coral); }
.media-controls { display: flex; justify-content: flex-end; gap: 8px; }
.sound-on, .play-icon { display: none; }
body.sound-enabled .sound-on, body.video-paused .play-icon { display: block; }
body.sound-enabled .sound-off, body.video-paused .pause-icon { display: none; }

.reel-actions { position: fixed; z-index: 9; right: 88px; top: 50%; display: grid; justify-items: center; gap: 13px; transform: translateY(-30%); }
.like-control { min-width: 50px; display: grid; justify-items: center; gap: 5px; padding: 4px; background: transparent; cursor: pointer; }
.like-control svg { width: 38px; height: 38px; fill: transparent; stroke: var(--paper); stroke-width: 1.25; transition: transform .2s, fill .2s, stroke .2s; }
.like-control:hover svg { transform: scale(1.08); }
.like-control.liked svg { fill: var(--coral); stroke: var(--coral); }
.like-control span { font-size: 11px; }
.liked-by { max-width: 95px; min-height: 15px; color: var(--muted); font-size: 10px; line-height: 1.4; text-align: center; }
.original-control { min-width: 52px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 10px 5px; background: transparent; cursor: pointer; font-size: 9px; font-weight: 700; letter-spacing: .18em; }
.voice-memory-control { min-width: 54px; display: grid; justify-items: center; gap: 5px; border: 1px solid rgba(244,200,78,.62); padding: 8px 5px; background: rgba(8,8,9,.34); color: var(--yellow); cursor: pointer; font-size: 8px; font-weight: 700; letter-spacing: .12em; }
.voice-memory-control svg { width: 28px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.voice-memory-control.has-voices { background: var(--yellow); color: var(--ink); }

.viewer-chrome { opacity: 1; transition: opacity .4s ease; }
body.chrome-hidden .viewer-chrome { opacity: 0; pointer-events: none; }
.viewer-empty { height: 100svh; display: grid; place-items: center; color: var(--muted); font: italic 22px var(--serif); }

/* Family account */
.family-menu { width: min(300px, calc(100% - 28px)); margin: 92px 42px auto auto; border: 1px solid var(--line); padding: 26px; background: rgba(8,8,9,.96); color: var(--paper); box-shadow: 0 24px 60px rgba(0,0,0,.55); }
.family-menu::backdrop { background: rgba(0,0,0,.34); }
.family-menu h2 { margin: 0 0 20px; font: 400 30px/1 var(--serif); }
.family-menu p { margin: 0; padding: 18px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11px; letter-spacing: .1em; }
.family-menu strong { color: var(--paper); font-weight: 400; }
.family-menu > a, .family-menu > button:not(.menu-close) { display: block; margin-top: 18px; padding: 0; border: 0; background: transparent; color: var(--coral); cursor: pointer; font-size: 10px; letter-spacing: .18em; text-transform: uppercase; }
.menu-close { position: absolute; top: 10px; right: 10px; width: 32px; height: 32px; padding: 8px; background: transparent; cursor: pointer; }
.menu-close svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.3; }

/* Voice memories */
.voice-memory-menu { width: min(560px, calc(100% - 28px)); max-height: min(760px, calc(100svh - 34px)); margin: auto; padding: 30px 34px 34px; border: 1px solid rgba(244,200,78,.42); overflow: auto; background: rgba(8,8,9,.98); color: var(--paper); box-shadow: 0 32px 80px rgba(0,0,0,.72); }
.voice-memory-menu::backdrop { background: rgba(0,0,0,.56); }
.voice-memory-heading { display: flex; justify-content: space-between; gap: 24px; align-items: start; }
.voice-memory-heading span { color: var(--yellow); font-size: 9px; letter-spacing: .17em; text-transform: uppercase; }
.voice-memory-heading h2 { margin: 8px 0 0; font: italic 400 38px/1 var(--serif); }
.voice-memory-heading button { width: 38px; height: 38px; padding: 8px; border: 0; background: transparent; }
.voice-memory-heading svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.25; }
.voice-memory-menu > p { margin: 20px 0; color: var(--muted); font: 15px/1.5 var(--serif); }
.voice-memory-list { border-top: 1px solid var(--line); }
.voice-memory-empty { margin: 0; padding: 24px 0; color: var(--muted); font: italic 15px var(--serif); }
.voice-memory-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); }
.voice-memory-row audio { width: 100%; min-width: 0; height: 36px; accent-color: var(--yellow); }
.voice-memory-row button { border: 0; padding: 8px 0; background: transparent; color: var(--coral); font-size: 8px; letter-spacing: .12em; text-transform: uppercase; }
.voice-recorder { display: grid; justify-items: center; gap: 14px; margin-top: 28px; padding-top: 26px; border-top: 1px solid var(--line); text-align: center; }
.voice-recording-orbit { width: 78px; height: 78px; position: relative; display: grid; place-items: center; border: 1px solid rgba(244,200,78,.52); border-radius: 50%; color: var(--yellow); font: italic 27px var(--serif); }
.voice-recording-orbit i { position: absolute; inset: 8px; border: 1px solid rgba(244,200,78,.26); border-radius: 50%; }
.voice-recorder.is-recording .voice-recording-orbit { border-color: var(--coral); color: var(--coral); animation: voice-pulse 1.2s ease-in-out infinite; }
.voice-recorder button { min-height: 46px; border: 1px solid var(--yellow); padding: 0 18px; background: transparent; color: var(--yellow); font-size: 9px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; }
.voice-recorder.is-recording button { border-color: var(--coral); color: var(--coral); }
.voice-recorder output { color: var(--muted); font-size: 10px; line-height: 1.45; }
@keyframes voice-pulse { 50% { transform: scale(1.04); box-shadow: 0 0 0 10px rgba(255,100,79,.05); } }

/* Viewing modes */
.mode-menu { width: min(610px, calc(100% - 28px)); max-height: min(760px, calc(100svh - 34px)); margin: auto; padding: 30px 34px 34px; border: 1px solid var(--line); border-radius: 0; overflow: auto; background: rgba(8,8,9,.98); color: var(--paper); box-shadow: 0 32px 80px rgba(0,0,0,.7); }
.mode-menu::backdrop { background: rgba(0,0,0,.52); }
.mode-menu-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.mode-menu-heading h2 { margin: 0; font: 400 13px var(--sans); letter-spacing: .2em; text-transform: uppercase; }
.mode-menu-heading button { width: 38px; height: 38px; padding: 8px; background: transparent; cursor: pointer; }
.mode-menu-heading svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.25; }
.mode-options > button { width: 100%; min-height: 86px; display: grid; grid-template-columns: 48px 1fr; gap: 18px; align-items: center; border-bottom: 1px solid var(--line); padding: 0; background: transparent; cursor: pointer; text-align: left; }
.mode-options > button > i { width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid var(--paper); border-radius: 50%; }
.mode-options > button.selected > i { border-color: var(--coral); background: var(--coral); }
.mode-options > button.selected > i::after { content: ""; width: 9px; height: 5px; border-left: 2px solid var(--ink); border-bottom: 2px solid var(--ink); transform: rotate(-45deg) translateY(-1px); }
.mode-options span { display: grid; gap: 6px; }
.mode-options strong { font: italic 400 25px var(--serif); }
.mode-options small { color: var(--muted); font-size: 9px; letter-spacing: .14em; text-transform: uppercase; }
.album-mode-heading { display: flex; align-items: center; gap: 18px; padding: 30px 0 15px; font-size: 10px; letter-spacing: .17em; text-transform: uppercase; }
.album-mode-heading i { height: 1px; flex: 1; background: var(--line); }
.album-mode-list > p { margin: 8px 0; color: var(--muted); font: italic 15px/1.5 var(--serif); }
.album-mode-row { width: 100%; min-height: 94px; display: grid; grid-template-columns: minmax(170px, 1.1fr) minmax(120px, 1fr) 18px; gap: 18px; align-items: center; border-bottom: 1px solid var(--line); padding: 12px 0; background: transparent; cursor: pointer; text-align: left; }
.album-mode-row.selected { color: var(--coral); }
.album-strip { height: 66px; display: flex; overflow: hidden; }
.album-strip img { width: 25%; min-width: 25%; height: 100%; object-fit: cover; }
.album-mode-row > span:nth-child(2) { display: grid; gap: 6px; }
.album-mode-row strong { font: italic 400 22px var(--serif); }
.album-mode-row small { color: var(--muted); font-size: 9px; letter-spacing: .1em; text-transform: uppercase; }
.album-mode-row > svg { width: 12px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }

@media (max-width: 900px) and (min-width: 701px) {
  .moment-slide { padding-inline: 90px; }
  .moment-slide img, .moment-slide video { max-width: calc(100vw - 230px); }
  .reel-actions { right: 45px; }
  .viewer-footer { grid-template-columns: 190px 1fr 150px; }
}

@media (max-width: 700px) {
  .family-gate { min-height: 100svh; padding: max(28px, env(safe-area-inset-top)) 26px max(24px, env(safe-area-inset-bottom)); background-position: 48% center; background-size: auto 100%; }
  .family-gate::before { content: ""; position: fixed; inset: 0; z-index: 0; background: linear-gradient(90deg, rgba(8,8,9,.15), rgba(8,8,9,.05) 72%, rgba(8,8,9,.2)); pointer-events: none; }
  .gate-wordmark { font-size: 18px; }
  .gate-content { width: 100%; align-self: end; padding: 100px 0 36px; }
  .gate-content h1 { max-width: 335px; font-size: clamp(48px, 14.7vw, 62px); }
  .gate-content > p { max-width: 310px; margin-top: 24px; font-size: 14px; }
  .family-join-form { margin-top: 31px; gap: 20px; }
  .family-join-form button { min-height: 52px; }
  .gate-footnote { justify-self: center; font-size: 9px; }

  .moment-slide { padding: 0; }
  .moment-slide img, .moment-slide video { width: 100%; height: 100%; max-width: none; max-height: none; border: 0; box-shadow: none; object-fit: contain; }
  .moment-slide::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(to bottom, rgba(0,0,0,.62), transparent 19%, transparent 66%, rgba(0,0,0,.82)); }
  .viewer-header { height: 86px; padding: max(23px, env(safe-area-inset-top)) 20px 0; }
  .viewer-wordmark { font-size: 16px; letter-spacing: .22em; }
  #viewer-context { font-size: 9px; letter-spacing: .16em; padding-top: 3px; }
  .mode-trigger { gap: 5px; margin-top: -2px; padding-bottom: 4px; }
  .mode-trigger svg { width: 13px; }
  .member-avatar { width: 34px; height: 34px; margin-top: -7px; font-size: 14px; }
  .edge-control { display: grid; left: auto; right: 2px; width: 38px; height: 38px; transform: rotate(90deg); }
  .edge-control svg { width: 22px; }
  .edge-previous { top: 19%; }
  .edge-next { top: 73%; }
  .viewer-footer { min-height: 190px; padding: 0 20px max(24px, env(safe-area-inset-bottom)); grid-template-columns: 1fr auto; grid-template-rows: auto auto; gap: 12px 10px; }
  .moment-copy time { font: italic clamp(26px, 9vw, 38px)/1 var(--serif); letter-spacing: .02em; }
  .moment-copy p { max-width: 235px; margin-top: 10px; color: var(--muted); font: 11px/1.45 var(--sans); }
  .media-controls { gap: 2px; }
  .media-controls .icon-control { width: 42px; height: 42px; border: 1px solid rgba(243,239,230,.45); border-radius: 50%; padding: 11px; }
  .fullscreen-control { display: none; }
  .moment-progress { grid-column: 1 / -1; grid-row: 2; height: 24px; }
  .progress-marker::after { width: 1px; height: 8px; top: 8px; }
  .progress-marker[aria-current="true"]::after { width: 3px; height: 15px; top: 4px; }
  .reel-actions { top: auto; right: 11px; bottom: max(176px, calc(env(safe-area-inset-bottom) + 158px)); gap: 8px; transform: none; }
  .like-control svg { width: 34px; height: 34px; filter: drop-shadow(0 2px 5px rgba(0,0,0,.6)); }
  .liked-by { display: none; }
  .original-control { min-width: 44px; border: 1px solid rgba(243,239,230,.45); border-radius: 50%; padding: 13px 4px; background: rgba(8,8,9,.28); }
  .voice-memory-control { min-width: 44px; width: 44px; height: 54px; border-radius: 22px; padding: 7px 3px; background: rgba(8,8,9,.36); }
  .voice-memory-control svg { width: 24px; height: 15px; }
  .family-menu { margin: max(70px, env(safe-area-inset-top)) 14px auto auto; padding: 24px; }
  .mode-menu { width: 100%; max-width: none; max-height: min(74svh, 690px); margin: auto 0 0; padding: 26px 22px max(30px, env(safe-area-inset-bottom)); border-left: 0; border-right: 0; border-bottom: 0; }
  .voice-memory-menu { width: 100%; max-width: none; max-height: min(78svh, 720px); margin: auto 0 0; padding: 28px 22px max(30px, env(safe-area-inset-bottom)); border-left: 0; border-right: 0; border-bottom: 0; }
  .mode-menu::backdrop { background: rgba(0,0,0,.3); }
  .mode-menu-heading h2 { font-size: 11px; }
  .mode-options > button { min-height: 76px; grid-template-columns: 42px 1fr; gap: 14px; }
  .mode-options > button > i { width: 28px; height: 28px; }
  .mode-options strong { font-size: 23px; }
  .album-mode-row { grid-template-columns: minmax(138px, 1.15fr) minmax(105px, 1fr) 14px; gap: 13px; min-height: 90px; }
  .album-strip { height: 60px; }
  .album-mode-row strong { font-size: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .moments-stream { scroll-behavior: auto !important; }
  .viewer-chrome, .progress-marker::after { transition: none; }
  .heart-burst.animate { animation: none; }
}
