:root {
  color-scheme: light;
  --bg: #fafaf7;
  --surface: #f0f1ed;
  --surface-soft: #f5f6f2;
  --line: #e4e6e0;
  --ink: #282e2b;
  --muted: #737a74;
  --faint: #a3a9a3;
  --accent: #446858;
  --accent-deep: #365544;
  --mine: #e2ebe3;
  --mine-line: #c6d6ca;
  --night: #101311;
  --gold-ink: #8d6514;
  --gold: #e0b04a;
  --moth-size: 56px;
  --moth-gap: 10px;
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --settle: cubic-bezier(.22, 1, .36, 1);
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  font-synthesis: none;
  -webkit-tap-highlight-color: transparent;
}
* { box-sizing: border-box; }
body { margin: 0; font-size: 15px; line-height: 1.5; background: var(--bg); }
button, input, textarea { font: inherit; }
button { color: inherit; cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { opacity: .45; cursor: default; }
button, a, input, textarea { touch-action: manipulation; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 3px;
}
img { display: block; max-width: 100%; }
h1, h2, h3, p, blockquote { margin: 0; }
h1, h2 { font-weight: 550; font-size: 19px; letter-spacing: -.025em; }
[hidden] { display: none !important; }
svg { display: block; }
.muted { color: var(--muted); }
.error { color: #a63d34; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.error:empty { display: none; }
.sr-only, .skip-link:not(:focus) {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap; border: 0;
}
.skip-link:focus { position: fixed; top: 8px; left: 8px; padding: 12px; background: var(--bg); z-index: 100; }

/* Touch-down compresses, release springs back. Only on interactive controls. */
.tactile { transition: transform .32s var(--spring), background-color .15s, color .15s, opacity .15s; }
.tactile:active:not(:disabled), .tactile.pressed:not(:disabled) { transform: scale(.96); transition-duration: .08s; }

.button { min-height: 46px; border-radius: 24px; padding: 11px 22px; font-weight: 550; }
.primary { background: var(--accent); color: #fff; }
.primary:hover:not(:disabled) { background: var(--accent-deep); }
.secondary { background: var(--surface); }
.text-button { min-height: 44px; padding: 10px 0; font-size: 13px; }
.icon-button {
  display: grid; place-items: center; min-width: 44px; min-height: 44px; font-size: 26px; line-height: 1;
  border-radius: 50%;
}
.icon-button:hover:not(:disabled) { background: var(--surface); }
label { display: block; font-size: 13px; margin-bottom: 8px; }
input, textarea {
  display: block; width: 100%; min-width: 0; font-size: 16px; line-height: 1.5; background: #fff;
  border: 1px solid var(--line); color: var(--ink); border-radius: 12px; padding: 12px; outline-offset: 3px;
}
textarea { resize: none; }
input::placeholder, textarea::placeholder { color: var(--muted); }

/* ---------- Join and identity ---------- */
.join-screen {
  min-height: 100svh; display: grid; place-items: center;
  padding: 40px 26px max(40px, env(safe-area-inset-bottom));
}
.join-content { width: 100%; max-width: 340px; }
.wordmark { font-family: var(--serif); font-weight: 400; letter-spacing: -.055em; }
.join-content > .wordmark { font-size: 52px; margin-bottom: 40px; }
.join-logo { width: 104px; height: 104px; margin: 0 0 6px -5px; user-select: none; -webkit-user-drag: none; }
.join-logo.small { width: 76px; height: 76px; margin: 0 0 16px -3px; }
#join-form .button { width: 100%; margin-top: 18px; }
#join-form .error { margin-top: 14px; }
#returning-fields { margin-top: 18px; }
#join-code { font-family: ui-monospace, monospace; letter-spacing: .25em; text-transform: uppercase; }
.join-switch { font-size: 12px; color: var(--muted); margin-top: 20px; }
.join-switch button { margin-left: 3px; color: var(--ink); }
/* A known name: "Welcome back" with the backup code, or one question before making another. */
.join-welcome { margin-bottom: 18px; }
.join-welcome-title { font-size: 22px; line-height: 1.3; letter-spacing: -.03em; overflow-wrap: anywhere; text-wrap: balance; }
.join-welcome-text { margin-top: 6px; font-size: 14px; line-height: 1.6; color: var(--muted); }
.join-welcome + #name-field[hidden] + #returning-fields { margin-top: 0; }
.join-links { display: flex; flex-wrap: wrap; gap: 0 20px; margin-top: 12px; }
.join-links .text-button { font-size: 13px; color: var(--muted); }
.join-links .text-button:hover { color: var(--ink); }
.join-confirm-text { font-size: 19px; line-height: 1.4; letter-spacing: -.02em; overflow-wrap: anywhere; text-wrap: balance; }
.join-confirm-hint { margin-top: 8px; font-size: 14px; line-height: 1.6; color: var(--muted); text-wrap: balance; }
#join-new-yes { display: block; width: 100%; margin-top: 24px; }
#join-new-no { display: block; width: 100%; margin-top: 6px; color: var(--muted); }
#join-new-no:hover { color: var(--ink); }
#join-confirm .error { margin-top: 10px; }
.identity-content { max-width: 400px; }
.identity-content h1 { font-size: 18px; }
.identity-value {
  font-size: clamp(24px, 6vw, 34px); line-height: 1.35; overflow-wrap: anywhere; margin: 26px 0 20px;
  letter-spacing: -.04em;
}
.identity-value strong { font-family: ui-monospace, monospace; font-weight: 500; letter-spacing: .05em; white-space: nowrap; }
.identity-content > .muted { font-size: 14px; line-height: 1.75; }
#copy-code { margin-top: 14px; text-decoration: underline; text-underline-offset: 4px; }
#copy-status { font-size: 12px; }
#identity-continue { display: block; width: 100%; margin-top: 26px; }

/* ---------- Shell ---------- */
.app-shell { display: flex; justify-content: center; height: var(--viewport-height, 100dvh); position: relative; }
.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.conversation {
  width: 100%; max-width: 760px; height: 100%; display: flex; flex-direction: column;
  position: relative; min-width: 0;
}

/* ---------- Header: one compact row, plus the #1 line when something is ranked ---------- */
.app-header {
  flex-shrink: 0; background: var(--bg); border-bottom: 1px solid var(--line);
  padding: env(safe-area-inset-top) max(10px, env(safe-area-inset-right)) 0 max(18px, env(safe-area-inset-left));
}
.header-row { display: flex; align-items: center; gap: 12px; height: 48px; }
.brand { display: flex; align-items: center; gap: 6px; margin-left: -4px; }
.brand-logo { width: 32px; height: 32px; flex-shrink: 0; user-select: none; -webkit-user-drag: none; }
.brand .wordmark { font-size: 25px; line-height: 1; }
#albums-open svg, #compare-open svg { width: 21px; height: 21px; fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
#albums-open + #compare-open, #compare-open + #menu-open, #albums-open + #menu-open { margin-left: -6px; }
@media (max-width: 380px) { .header-row { gap: 8px; } }
.presence { margin-left: auto; font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; flex-shrink: 0; }
.presence.live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #6f9a80; }
#menu-open svg { width: 22px; height: 22px; fill: var(--ink); }
.banner-row { padding: 0 0 9px; margin-top: -4px; }
.top-banner {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%; height: 32px; padding: 0 4px 0 11px;
  border-radius: 16px; background: var(--surface-soft); border: 1px solid var(--line); overflow: hidden;
  position: relative; font-size: 13px;
}
.top-banner:hover { background: var(--surface); }
.banner-content { display: inline-flex; align-items: center; gap: 8px; min-width: 0; white-space: nowrap; }
.banner-content img { width: 24px; height: 24px; border-radius: 12px; object-fit: cover; flex-shrink: 0; background: var(--surface); }
.banner-content { gap: 7px; }
.banner-content .crown { margin-right: 2px; }
.banner-rank { font-weight: 650; color: var(--gold-ink); font-variant-numeric: tabular-nums; }
.banner-name { font-weight: 560; overflow: hidden; text-overflow: ellipsis; }
.banner-dot { color: var(--faint); }
.banner-content img { margin-left: 3px; }
.banner-content.leaving { position: absolute; left: 11px; top: 3px; pointer-events: none; }

/* ---------- The photo stream ---------- */
.chat-history {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior-y: contain; overflow-anchor: none;
  padding: 6px 22px var(--chat-end); scroll-padding-bottom: var(--chat-end); --chat-w: calc(100vw - 44px);
  --chat-end: calc(132px + env(safe-area-inset-bottom));
}
.chat-history:focus-visible { outline: none; }
.chat-history > #load-messages { display: block; margin: auto; color: var(--muted); font-size: 12px; }
#chat-load-status { font-size: 12px; text-align: center; }
#chat-load-status:empty { display: none; }
.stream { display: flex; flex-direction: column; gap: 30px; padding: 16px 0 4px; }
/* One column for everyone. The item is exactly as wide as its photo; the text beside it wraps to fit. */
.stream-item { display: grid; width: fit-content; max-width: 100%; min-width: 0; position: relative; }
.stream-item > :not(.photo-frame) { width: 0; min-width: 100%; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: #e9eae3; color: #5d6e61; flex-shrink: 0;
  display: grid; place-items: center; font-size: 12px; font-weight: 600;
}
.photo-head { display: flex; align-items: center; gap: 9px; margin: 0 0 8px; min-height: 30px; }
.photo-who { min-width: 0; line-height: 1.3; }
.photo-name { display: block; font-size: 14px; font-weight: 600; letter-spacing: -.01em; overflow-wrap: anywhere; }
.photo-when { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.photo-when time { white-space: nowrap; }
.when-sent { white-space: nowrap; }
.when-dot { color: var(--faint); }
/* The photographer's own words: only there when they wrote some. */
.photo-caption {
  font-family: var(--serif); font-size: 15.5px; line-height: 1.45; color: #39403c; margin: 10px 2px 0;
  overflow-wrap: anywhere;
}
.photo-frame {
  --pw: min(calc(var(--chat-w) * .8), 440px);
  --maxh: min(360px, 48svh);
  position: relative; display: block; overflow: hidden; border-radius: 16px; background: var(--surface);
  aspect-ratio: var(--ar, 4 / 3); width: min(var(--pw), calc(var(--maxh) * var(--ar, 1.333)));
}
.photo-frame.square { --pw: min(calc(var(--chat-w) * .68), 340px); }
.photo-frame.portrait { --pw: min(calc(var(--chat-w) * .6), 280px); }
.photo-frame img { width: 100%; height: 100%; object-fit: cover; }
.photo-frame .image-error {
  position: absolute; inset: auto 8px 8px; font-size: 12px; background: #fffd; border-radius: 10px; padding: 6px 8px;
}
.photo-frame.is-hidden, .lib-thumb.is-hidden { visibility: hidden; }
.photo-footer { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; min-width: 0; }
/* No reactions yet: the add-reaction action sits on the score line instead of its own row. */
.photo-footer.quiet { flex-direction: row; flex-wrap: wrap; align-items: center; column-gap: 2px; }
.photo-footer.quiet .score-panel { order: 3; flex-basis: 100%; }

/* Rank and score line */
.score-line { display: flex; align-items: center; gap: 2px; min-height: 30px; }
.score-line:empty { display: none; }
.rank-chip {
  font-size: 12px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; padding: 0 6px 0 3px;
}
.rank-chip.first { color: var(--gold-ink); }
.rank-chip.crowned { display: inline-flex; align-items: center; gap: 4px; }
.score-toggle {
  display: inline-flex; align-items: center; gap: 4px; min-height: 30px; padding: 0 9px; border-radius: 15px;
  font-size: 12.5px; color: var(--muted); position: relative; font-variant-numeric: tabular-nums;
}
.score-toggle::after { content: ""; position: absolute; inset: -7px -2px; }
.score-toggle:hover { background: var(--surface); color: var(--ink); }
.score-toggle strong { color: var(--ink); font-weight: 600; }
.score-toggle svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .3s var(--settle); }
.score-toggle[aria-expanded=true] svg { transform: rotate(180deg); }
.score-toggle[aria-expanded=true] { background: var(--surface); color: var(--ink); }

/* Details unfold: height via grid rows, the content itself only fades and shifts. */
.score-panel { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .34s var(--settle); width: 100%; }
.score-panel.open { grid-template-rows: 1fr; }
.score-panel-inner { min-height: 0; overflow: hidden; }
.score-sheet {
  opacity: 0; transform: translateY(-6px); transition: opacity .22s ease-out, transform .34s var(--settle);
  padding: 8px 4px 6px; max-width: 340px;
}
.score-panel.open .score-sheet { opacity: 1; transform: none; transition-delay: .04s; }
.score-note { font-family: var(--serif); font-style: italic; font-size: 13.5px; line-height: 1.5; color: #5d675f; margin: 0 2px 8px; overflow-wrap: anywhere; }
.score-rows { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 18px; margin: 0; padding: 0; list-style: none; }
.score-row { display: flex; align-items: center; gap: 7px; min-height: 26px; font-size: 12.5px; }
.score-row .ring { width: 15px; height: 15px; flex-shrink: 0; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 2.4; }
.ring .track { stroke: var(--line); }
.ring .fill { stroke: var(--accent); stroke-linecap: round; }
.score-label { color: var(--muted); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-value { font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 550; }

/* Reactions: compact chips; mine slightly stronger. */
.reaction-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; position: relative; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 32px; padding: 0 11px 0 9px; border-radius: 16px;
  background: var(--surface); position: relative; font-variant-numeric: tabular-nums; user-select: none;
  -webkit-user-select: none; -webkit-touch-callout: none;
}
.chip::after, .react-add::after { content: ""; position: absolute; inset: -6px -3px; }
.chip:hover { background: #e9ebe5; }
.chip .emoji { font-size: 18px; line-height: 1; display: inline-block; }
.chip .count { font-size: 12.5px; color: var(--muted); font-weight: 550; }
.chip[aria-pressed=true] { background: var(--mine); box-shadow: inset 0 0 0 1px var(--mine-line); }
.chip[aria-pressed=true] .count { color: var(--accent-deep); }
.reactor-names { font-size: 11.5px; color: var(--faint); margin: 0 2px; overflow-wrap: anywhere; }
.react-add {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 16px; color: var(--muted);
  position: relative; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.react-add:hover, .react-add[aria-expanded=true] { background: var(--surface); color: var(--ink); }
.react-add svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }

.reaction-picker {
  position: fixed; z-index: 60; display: flex; gap: 2px; padding: 5px; border-radius: 30px; background: #fff;
  border: 1px solid var(--line); box-shadow: 0 10px 34px #23332924, 0 1px 3px #2333291a;
  transform-origin: var(--origin, 50% 100%);
}
.reaction-picker button {
  width: 48px; height: 48px; border-radius: 24px; display: grid; place-items: center; font-size: 27px; line-height: 1;
  transition: transform .2s var(--spring), background-color .15s;
}
.reaction-picker button[aria-checked=true] { background: var(--mine); }
.reaction-picker button.hot, .reaction-picker button:hover { transform: scale(1.3) translateY(-5px); }
.reaction-picker button:focus-visible { outline-offset: -2px; }

.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
.particle { position: absolute; font-size: 15px; line-height: 1; will-change: transform, opacity; }
.reactor-pop {
  position: fixed; z-index: 65; max-width: min(280px, calc(100vw - 24px)); background: var(--ink); color: #fff;
  font-size: 12.5px; line-height: 1.45; padding: 7px 11px; border-radius: 11px; box-shadow: 0 6px 20px #23332926;
  pointer-events: none; overflow-wrap: anywhere;
}

/* Sending state */
.pending-message { transform-origin: 0 100%; }
.send-status { font-size: 11.5px; color: var(--muted); margin: 6px 2px 0; transition: opacity .4s; }
.send-status.fade { opacity: 0; }
.send-bar { position: absolute; left: 10px; right: 10px; bottom: 8px; height: 3px; border-radius: 2px; background: #ffffff70; overflow: hidden; }
.send-bar span { display: block; height: 100%; width: 100%; background: #fff; transform-origin: 0 50%; transform: scaleX(var(--p, .04)); transition: transform .25s ease-out; }
.send-failed img { filter: saturate(.6) brightness(.92); }
.retry-pill {
  position: absolute; left: 50%; top: 50%; translate: -50% -50%; min-height: 40px; padding: 0 18px; border-radius: 20px; white-space: nowrap;
  background: #fff; color: var(--ink); font-size: 14px; font-weight: 600; box-shadow: 0 4px 16px #1d272140;
}
.pending-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 4px; }
.pending-actions .error { font-size: 12px; }
.pending-actions .text-button { min-height: 32px; padding: 4px 0; color: var(--muted); }

/* ---------- The one action: a camera, alone, centred at the bottom ---------- */
.capture-bar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center; pointer-events: none;
  padding: 30px 0 max(16px, env(safe-area-inset-bottom));
  background: linear-gradient(rgb(250 250 247 / 0), rgb(250 250 247 / .92) 46%, var(--bg));
}
.capture-bar > * { pointer-events: auto; }
.camera-button {
  position: relative; width: 68px; height: 68px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: #fff; box-shadow: 0 0 0 5px var(--bg), 0 0 0 6px #44685821, 0 10px 24px #44685845;
}
/* A fine inner ring, like a lens. */
.camera-button::before { content: ""; position: absolute; inset: 5px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px #ffffff4d; }
.camera-button svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.camera-button:hover { background: var(--accent-deep); }
.camera-button:active, .camera-button.pressed { transform: scale(.9); }
.new-messages {
  position: absolute; bottom: calc(100% - 14px); left: 50%; translate: -50% 0; min-height: 38px;
  border: 1px solid var(--line); border-radius: 19px; padding: 6px 15px; background: #fff;
  box-shadow: 0 3px 15px #23332914; font-size: 12.5px; white-space: nowrap;
}
.empty-state { color: var(--muted); text-align: center; padding: 70px 20px; font-size: 15px; line-height: 1.7; }
.empty-state .empty-hint { font-size: 13px; color: var(--faint); }
.notice {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 18px;
  background: #f6eee3; flex-shrink: 0; font-size: 12px;
}
.notice button { flex-shrink: 0; }

/* ---------- Dialogs ---------- */
dialog {
  color: var(--ink); background: var(--bg); border: 1px solid var(--line); padding: 22px; border-radius: 18px;
  max-height: calc(100dvh - 32px); width: min(480px, calc(100% - 28px)); box-shadow: 0 20px 80px #17241c1f;
}
dialog::backdrop { background: #23332945; }
.modal-open { overflow: hidden; }
.dialog-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.dialog-header h2 { font-size: 18px; }
.menu-dialog { width: min(320px, calc(100% - 28px)); padding: 14px 22px 20px; }
.sheet-close { margin-left: auto; }
.choice-button { display: block; min-height: 56px; width: 100%; text-align: left; padding: 12px 0; }
.choice-button + .choice-button { border-top: 1px solid var(--line); }
.button.ghost { background: #ffffff1c; color: #fff; }
.button.ghost:hover { background: #ffffff2b; }
.button.light { background: #fafaf7; color: var(--ink); }
.button.light:hover { background: #fff; }

/* ---------- Camera: full screen, the frame exactly as it will be captured ---------- */
.camera, .post-dialog, .albums, .compare {
  position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0;
  border: 0; border-radius: 0; box-shadow: none; overflow: hidden;
}
.camera { background: #0d0f0e; color: #fff; }
.camera::backdrop, .post-dialog::backdrop { background: #0d0f0e; }
.cam-stage {
  position: absolute; left: 0; right: 0; top: calc(62px + env(safe-area-inset-top)); bottom: calc(136px + env(safe-area-inset-bottom));
  display: grid; place-items: center;
}
.cam-frame { position: relative; width: 75vw; height: 100vw; max-width: 100%; max-height: 100%; overflow: hidden; background: #161917; border-radius: 3px; }
.cam-frame video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .3s ease-out; }
.cam-frame.live video { opacity: 1; }
.cam-frame.mirrored video { transform: scaleX(-1); }
/* Zoom (js/camera/zoom.js): a pinch on the frame never zooms the page. Without the camera's own
   zoom the video is scaled about its centre (--cam-zoom); the adjusted canvas draws the same crop. */
.cam-frame { touch-action: none; }
.cam-frame video { transform: scale(var(--cam-zoom, 1)); }
.cam-frame.mirrored video { transform: scaleX(-1) scale(var(--cam-zoom, 1)); }
/* The chip: a 44px touch area; its disc grows into a pill for "2.5x". */
.cam-zoom {
  position: absolute; z-index: 1; left: 50%; bottom: 12px; translate: -50% 0; min-width: 44px; height: 44px; padding: 0 12px;
  display: grid; place-items: center; background: none; color: #fff; font-size: 12.5px; font-weight: 600; white-space: nowrap;
  font-variant-numeric: tabular-nums; letter-spacing: .01em; -webkit-tap-highlight-color: transparent;
}
.cam-zoom::before {
  content: ""; position: absolute; inset: 5px; border-radius: 17px; z-index: -1; transition: inset .15s ease-out;
  background: rgb(18 21 19 / .55); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); box-shadow: inset 0 0 0 1px #ffffff1f;
}
.cam-zoom.zoomed { color: #f1c56a; }
.cam-frame.pinching .cam-zoom::before { inset: 2px; border-radius: 20px; }
.cam-grid { position: absolute; inset: 0; pointer-events: none; transition: opacity .2s ease-out; }
.cam-frame.grid-off .cam-grid { opacity: 0; }
.cam-grid span { position: absolute; background: #ffffff5c; box-shadow: 0 0 1px #0000002e; }
.cam-grid .v1, .cam-grid .v2 { top: 0; bottom: 0; width: 1px; }
.cam-grid .h1, .cam-grid .h2 { left: 0; right: 0; height: 1px; }
.cam-grid .v1 { left: 33.333%; } .cam-grid .v2 { left: 66.667%; }
.cam-grid .h1 { top: 33.333%; } .cam-grid .h2 { top: 66.667%; }
.cam-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.cam-top {
  position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center;
  padding: calc(9px + env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
}
.cam-icon {
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: #ffffff1c; color: #fff;
}
.cam-icon:hover { background: #ffffff2e; }
.cam-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.cam-icon[aria-pressed=false] { color: #ffffff8a; background: #ffffff0d; }
/* Moth's suggestion: small, quiet, one at a time. */
.cam-tip {
  position: absolute; left: 50%; top: calc(100% + 12px); translate: -50% 0; z-index: 2; display: flex; align-items: center; gap: 8px;
  max-width: calc(100vw - 28px); padding: 5px 15px 5px 5px; border-radius: 22px; pointer-events: none;
  background: rgb(18 21 19 / .66); -webkit-backdrop-filter: blur(14px) saturate(1.2); backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: 0 4px 18px #0000002e, inset 0 0 0 1px #ffffff14; font-size: 13.5px; line-height: 1.3;
}
.cam-tip img { width: 26px; height: 26px; border-radius: 50%; background: #f6f0e3; padding: 2px; flex-shrink: 0; }
.cam-tip-who { font-weight: 600; color: #f1e4c4; flex-shrink: 0; }
.cam-tip-text { color: #ffffffe6; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cam-bottom {
  position: absolute; left: 0; right: 0; bottom: 0; height: calc(136px + env(safe-area-inset-bottom));
  padding: 0 max(30px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(30px, env(safe-area-inset-left));
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; justify-items: center;
}
.cam-bottom #cam-grid-toggle { justify-self: start; }
.cam-bottom #cam-flip { justify-self: end; grid-column: 3; }
.cam-shutter {
  position: relative; width: 80px; height: 80px; border-radius: 50%; display: grid; place-items: center;
  box-shadow: inset 0 0 0 4px #fff; touch-action: manipulation;
}
.cam-shutter-core { width: 64px; height: 64px; border-radius: 50%; background: #fff; transition: transform .34s var(--spring), background-color .15s; }
.cam-shutter:active .cam-shutter-core, .cam-shutter.pressed .cam-shutter-core { transform: scale(.86); background: #ecece6; transition-duration: .08s; }
.cam-shutter:focus-visible { outline: 2px solid #fff; outline-offset: 4px; }
.cam-ring { position: absolute; inset: 0; border-radius: 50%; box-shadow: inset 0 0 0 2px #fff; pointer-events: none; }
.cam-fallback { position: absolute; inset: 0; display: grid; place-items: center; }
.cam-native { min-height: 52px; padding: 0 28px; border-radius: 26px; background: #fafaf7; color: var(--ink); font-weight: 600; font-size: 16px; }
@media (orientation: landscape) and (max-height: 540px) {
  .cam-stage { top: 0; bottom: 0; right: calc(118px + env(safe-area-inset-right)); left: env(safe-area-inset-left); }
  .cam-top { right: calc(118px + env(safe-area-inset-right)); }
  .cam-bottom {
    left: auto; top: 0; width: calc(118px + env(safe-area-inset-right)); height: auto; padding: 14px env(safe-area-inset-right) 14px 0;
    grid-template-columns: 1fr; grid-template-rows: 1fr auto 1fr;
  }
  .cam-bottom #cam-grid-toggle { justify-self: center; align-self: end; grid-row: 3; }
  .cam-bottom #cam-flip { justify-self: center; align-self: start; grid-row: 1; grid-column: 1; }
  .cam-bottom .cam-shutter { grid-row: 2; }
}

/* ---------- Preview: the photo, an optional note, Retake or Send ---------- */
.post-dialog { height: var(--viewport-height, 100dvh); background: #0d0f0e; color: #f3f4f0; }
.post-form { display: flex; flex-direction: column; height: 100%; padding-top: calc(14px + env(safe-area-inset-top)); }
.preview-wrap { position: relative; flex: 1; min-height: 120px; }
.preview-wrap img {
  position: absolute; inset: 0; margin: auto; max-width: calc(100% - 28px); max-height: 100%; border-radius: 6px;
}
.preview-wrap p { position: absolute; inset: 0; display: grid; place-items: center; padding: 22px; font-size: 13px; color: #ffffffa3; text-align: center; }
.post-panel {
  width: 100%; max-width: 560px; margin: 0 auto;
  padding: 18px max(18px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
}
.post-label { font-size: 14px; font-weight: 550; color: #f3f4f0; margin-bottom: 8px; }
.post-optional { font-weight: 400; color: #ffffff85; margin-left: 2px; }
.post-field { position: relative; }
#post-caption {
  background: #ffffff12; border: 1px solid #ffffff24; color: #fff; border-radius: 14px; padding: 12px 74px 12px 14px;
  caret-color: #f1e4c4;
}
#post-caption::placeholder { color: #ffffff5c; }
#post-caption:focus-visible { outline: none; border-color: #ffffff6b; background: #ffffff1a; }
.post-count { position: absolute; right: 14px; top: 50%; translate: 0 -50%; font-size: 12px; color: #ffffff85; font-variant-numeric: tabular-nums; pointer-events: none; }
.post-count.full { color: #f1d9a0; }
.preview-actions { display: flex; gap: 12px; margin-top: 14px; }
.preview-actions button { flex: 1; min-height: 50px; border-radius: 25px; font-size: 16px; }
.post-dialog .button:focus-visible { outline-color: #fff; }

/* ---------- Albums: everyone's photos, person by person ---------- */
.albums { background: var(--bg); color: var(--ink); }
.albums[open] { display: flex; flex-direction: column; }
.albums::backdrop { background: var(--bg); }
.albums-head {
  flex-shrink: 0; display: flex; align-items: center; gap: 4px; width: 100%; max-width: 760px; margin: 0 auto; height: calc(54px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(12px, env(safe-area-inset-right)) 0 max(6px, env(safe-area-inset-left));
}
.albums-head h2 { font-family: var(--serif); font-weight: 400; font-size: 25px; letter-spacing: -.045em; line-height: 1; }
.albums-head svg { width: 24px; height: 24px; fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.albums-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; border-top: 1px solid var(--line); }
.albums-people {
  max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 34px;
  padding: 18px max(16px, env(safe-area-inset-right)) calc(32px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.albums-people:empty { display: none; }
.albums-status { text-align: center; font-size: 13px; color: var(--muted); padding: 28px 20px; }
.albums-status:empty { display: none; }
.lib-head { display: flex; align-items: center; gap: 11px; margin-bottom: 12px; }
.lib-head .avatar { width: 38px; height: 38px; font-size: 14.5px; }
.lib-who { min-width: 0; line-height: 1.3; }
.lib-line { display: flex; align-items: center; gap: 9px; min-width: 0; }
.lib-name { font-size: 17px; font-weight: 600; letter-spacing: -.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-best { display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0; font-size: 12.5px; font-weight: 650; color: var(--muted); font-variant-numeric: tabular-nums; }
.lib-best.first { color: var(--gold-ink); }
.lib-best .crown-1 { --crown-w: 21px; }
.lib-best .crown-2 { --crown-w: 14px; }
.lib-count { font-size: 12px; color: var(--muted); }
.lib-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px 10px; }
.lib-tile { display: flex; flex-direction: column; gap: 7px; width: 100%; text-align: left; border-radius: 12px; }
.lib-tile:focus-visible { outline-offset: 2px; }
.lib-thumb { position: relative; display: block; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--surface); transition: transform .3s var(--spring); }
.lib-tile:active .lib-thumb { transform: scale(.97); transition-duration: .08s; }
.lib-thumb img { width: 100%; height: 100%; object-fit: cover; }
.lib-tag {
  position: absolute; left: 6px; top: 6px; padding: 1px 7px; border-radius: 9px; font-size: 11px; font-weight: 650; line-height: 1.55;
  background: rgb(255 255 255 / .92); color: #59605b; font-variant-numeric: tabular-nums; box-shadow: 0 1px 4px #0000001f;
}
.lib-times { display: flex; flex-direction: column; font-size: 11px; line-height: 1.45; color: var(--muted); font-variant-numeric: tabular-nums; padding: 0 2px; }
.lib-times time { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-more { font-size: 12px; color: var(--muted); margin-top: 12px; }

/* ---------- Top 5 entries: pale butter, one card at a time ---------- */
.top-entry-layer {
  position: fixed; z-index: 75; top: calc(10px + env(safe-area-inset-top)); left: max(10px, env(safe-area-inset-left)); right: max(10px, env(safe-area-inset-right));
  display: flex; justify-content: center; pointer-events: none;
}
.top-entry {
  pointer-events: auto; display: flex; align-items: center; width: min(100%, 380px); border-radius: 14px;
  background: #fff9df; border: 1px solid #e6d397; color: #3b3323; touch-action: none; user-select: none; -webkit-user-select: none;
}
.top-entry.first { background: #fff5d2; border-color: #dec17b; }
.top-entry-open { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; min-height: 56px; padding: 11px 0 11px 13px; text-align: left; }
.top-entry-text { min-width: 0; font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; }
.top-entry-rank { font-weight: 750; white-space: nowrap; }
.top-entry-next { color: #625239; }
.top-entry-dismiss { min-width: 44px; min-height: 44px; align-self: flex-start; margin-top: 6px; font-size: 22px; color: #78633d; }
.top-entry .crown-1 { --crown-w: 30px; }
.top-entry .crown-2 { --crown-w: 19px; }

/* ---------- Full-screen viewer ---------- */
.viewer {
  position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0;
  border: 0; border-radius: 0; background: transparent; box-shadow: none; overflow: hidden; color: #f3f4f0;
}
.viewer::backdrop { background: transparent; }
.viewer-backdrop { position: absolute; inset: 0; background: var(--night); }
.viewer-stage { position: absolute; inset: 0; touch-action: none; overflow: hidden; }
#viewer-image {
  position: absolute; left: 0; top: 0; max-width: none; transform-origin: 0 0; user-select: none;
  -webkit-user-select: none; -webkit-user-drag: none; will-change: transform;
}
.viewer-stage .image-error {
  position: absolute; left: 50%; bottom: 30%; translate: -50% 0; font-size: 13px; background: #ffffff1a; color: #fff;
  border-radius: 12px; padding: 10px 14px; text-align: center;
}
.viewer-chrome { transition: opacity .22s ease-out; }
.viewer.chrome-off .viewer-chrome, .viewer.dragging .viewer-chrome { opacity: 0; pointer-events: none; }
.viewer-top {
  position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: flex-start; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 26px max(18px, env(safe-area-inset-left));
  background: linear-gradient(#101311b8, #10131100);
}
.viewer-who { flex: 1; min-width: 0; padding-top: 4px; }
.viewer-who h2 { font-size: 15.5px; font-weight: 600; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; overflow-wrap: anywhere; }
.viewer-who .rank-chip { font-size: 12.5px; padding: 1px 8px; border-radius: 10px; background: #ffffff1f; color: #fff; flex-shrink: 0; }
.viewer-who .rank-chip.crowned { gap: 6px; padding-left: 6px; }
.viewer-who .rank-chip.first { background: #ffd77a26; color: #ffe6a6; }
.viewer-who .crown-1 { --crown-w: 26px; }
.viewer-who .crown-2 { --crown-w: 17px; }
.viewer-caption { font-family: var(--serif); font-size: 15px; line-height: 1.4; color: #fffffff0; margin-top: 3px; overflow-wrap: anywhere; }
.viewer-meta { font-size: 12px; color: #ffffffa3; margin-top: 3px; }
.viewer-times { display: flex; flex-direction: column; line-height: 1.45; font-variant-numeric: tabular-nums; }
.viewer-icon {
  width: 44px; height: 44px; border-radius: 22px; display: grid; place-items: center; background: #ffffff1a; color: #fff; flex-shrink: 0;
}
.viewer-icon:hover { background: #ffffff2e; }
.viewer-icon svg, .viewer-nav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.viewer-nav {
  position: absolute; top: 50%; margin-top: -24px; width: 48px; height: 48px; border-radius: 24px; display: none;
  place-items: center; background: #ffffff14; color: #fff;
}
.viewer-nav:hover:not(:disabled) { background: #ffffff2b; }
.viewer-nav:disabled { opacity: 0; pointer-events: none; }
.viewer-nav.prev { left: 20px; }
.viewer-nav.next { right: 20px; }
.viewer-bottom {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 30px max(14px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  background: linear-gradient(#10131100, #101311cc 46%);
}
.viewer-bottom > * { max-width: 520px; }
.viewer-bottom .score-line { justify-content: center; }
.viewer-bottom .score-toggle { color: #ffffffb8; }
.viewer-bottom .score-toggle strong { color: #fff; }
.viewer-bottom .score-toggle:hover, .viewer-bottom .score-toggle[aria-expanded=true] { background: #ffffff1a; color: #fff; }
.viewer-bottom .score-sheet { margin: 0 auto; }
.viewer-bottom .score-note { color: #ffffffc4; text-align: center; }
.viewer-bottom .score-label { color: #ffffffa3; }
.viewer-bottom .score-value { color: #fff; }
.viewer-bottom .ring .track { stroke: #ffffff2b; }
.viewer-bottom .ring .fill { stroke: #c9dccf; }
.viewer-bottom .reaction-row { justify-content: center; }
.viewer-bottom .chip { background: #ffffff1a; }
.viewer-bottom .chip:hover { background: #ffffff29; }
.viewer-bottom .chip .count { color: #ffffffc4; }
.viewer-bottom .chip[aria-pressed=true] { background: #e2ebe3; box-shadow: none; color: var(--ink); }
.viewer-bottom .chip[aria-pressed=true] .count { color: var(--accent-deep); }
.viewer-bottom .reactor-names { color: #ffffff8c; }
.viewer-bottom .error { color: #ffb4a8; }

.toast {
  position: fixed; z-index: 80; bottom: 100px; left: 50%; translate: -50% 0; max-width: calc(100% - 32px); width: max-content;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 13px;
  box-shadow: 0 4px 20px #23332920; pointer-events: none; overflow-wrap: anywhere;
}

/* ---------- Crowns: #1 large and softly shining, #2 small and still ---------- */
.crown { --crown-w: 17px; position: relative; display: inline-block; flex-shrink: 0; width: var(--crown-w); aspect-ratio: 24 / 18; line-height: 0; }
.crown-2 { --crown-w: 13px; }
.crown-shape { position: relative; width: 100%; height: 100%; overflow: visible; }
.crown-1 .crown-shape { filter: drop-shadow(0 0 2px #f3bd4a8c) drop-shadow(0 1px .5px #a0700f40); }
.crown-2 .crown-shape { filter: drop-shadow(0 .5px .5px #8a733f33); }
.crown-gem { fill: #fff2c4; }
.crown-2 .crown-gem { fill: #f4ead0; }
.crown-shine { fill: none; stroke: #fff8de; stroke-width: .9; stroke-linecap: round; opacity: .7; }
.crown-2 .crown-shine { opacity: .45; }
.crown-glow {
  position: absolute; inset: -38% -26%; border-radius: 50%; opacity: .45;
  background: radial-gradient(closest-side, #ffd36a99, #ffd36a00);
}
.crown-sparkle { position: absolute; width: 38%; height: auto; right: -22%; top: -26%; fill: #ffe9a3; opacity: 0; overflow: visible; }
.top-banner .crown-1, .hl-rank .crown-1 { --crown-w: 22px; }
.hl-rank .crown-2 { --crown-w: 15px; }

/* ---------- Moth bubbles ---------- */
.moth {
  position: absolute; z-index: 30; display: flex; flex-direction: column; align-items: center; gap: var(--moth-gap);
  right: max(12px, env(safe-area-inset-right)); bottom: calc(126px + env(safe-area-inset-bottom)); pointer-events: none;
}
.moth-variants { display: flex; flex-direction: column; gap: var(--moth-gap); }
.moth-bubble {
  --tint: #f6f2ea; --tint-edge: #ebe3d4; --ring: #d9ccb4;
  position: relative; display: grid; place-items: center; width: var(--moth-size); height: var(--moth-size); border-radius: 50%;
  pointer-events: auto; touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  background: radial-gradient(circle at 34% 28%, #fffdf9 0%, var(--tint) 58%, var(--tint-edge) 100%);
  box-shadow: inset 0 0 0 1px #ffffffb3, 0 1px 2px #4a3c2414, 0 5px 14px #4a3c241c;
  transition: scale .34s var(--spring);
}
.moth-bubble.top { --tint: #fbf2d9; --tint-edge: #f2e1b2; --ring: #e8c56a; }
.moth-bubble.reacted { --tint: #fcecec; --tint-edge: #f5d6d8; --ring: #efa9b3; }
.moth-bubble.bottom { --tint: #edf1fa; --tint-edge: #d9e2f5; --ring: #a7bbe8; }
/* Stronger shadow and a thin ring when selected: faded in, never animated as a shadow. */
.moth-bubble::before, .moth-bubble::after { content: ""; position: absolute; border-radius: 50%; opacity: 0; transition: opacity .22s ease-out; pointer-events: none; }
.moth-bubble::before { inset: 0; box-shadow: 0 10px 26px #4a3c2433, 0 2px 6px #4a3c241f; }
.moth-bubble::after { inset: -3px; box-shadow: 0 0 0 1.5px var(--ring); }
.moth-bubble.selected { scale: 1.08; }
.moth-bubble.selected::before, .moth-bubble.selected::after { opacity: 1; }
.moth-bubble.pressed { scale: .92; transition-duration: .08s; }
.moth-bubble:focus-visible { outline: none; }
.moth-bubble:focus-visible::after { opacity: 1; box-shadow: 0 0 0 2px var(--accent); }
.moth-bubble img {
  position: relative; width: 84%; height: 84%; object-fit: contain; pointer-events: none;
  transition: rotate .3s var(--settle);
}
.moth.open .moth-bubble.main { --tint-edge: #e4dac8; }

.particle.moth-spark { width: 7px; height: 7px; font-size: 0; color: #dccbb0; }
.moth-spark.dot { border-radius: 50%; background: currentColor; width: 6px; height: 6px; }
.moth-spark svg { width: 100%; height: 100%; fill: currentColor; overflow: visible; }
.moth-spark.top { color: #edc65c; width: 9px; height: 9px; }
.moth-spark.reacted { color: #f2a2b2; width: 8px; height: 8px; }
.moth-spark.bottom { color: #a3b7e6; }

/* The card for the selected Moth: quiet, floating, beside the stack. */
.moth-card {
  position: fixed; z-index: 45; display: flex; flex-direction: column; width: 320px; min-height: 0;
  background: #fff; border: 1px solid var(--line); border-radius: 18px; overflow: hidden;
  box-shadow: 0 14px 40px #23332924, 0 2px 6px #2333290f; transform-origin: var(--origin, 100% 50%);
}
.moth-card-head { display: flex; align-items: center; gap: 10px; padding: 10px 6px 6px 12px; flex-shrink: 0; }
.moth-card-head h2 { flex: 1; min-width: 0; font-size: 16px; font-weight: 600; letter-spacing: -.015em; }
.moth-card-mascot {
  --tint: #f6f2ea; --tint-edge: #ebe3d4;
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  background: radial-gradient(circle at 34% 28%, #fffdf9 0%, var(--tint) 58%, var(--tint-edge) 100%);
}
.moth-card-mascot[data-moth=top] { --tint: #fbf2d9; --tint-edge: #f2e1b2; }
.moth-card-mascot[data-moth=reacted] { --tint: #fcecec; --tint-edge: #f5d6d8; }
.moth-card-mascot[data-moth=bottom] { --tint: #edf1fa; --tint-edge: #d9e2f5; }
.moth-card-mascot img { width: 86%; height: 86%; object-fit: contain; }
.moth-card-close { font-size: 0; color: var(--muted); }
/* In the bottom sheet the stack is covered, so the other two Moths sit in the header. */
.moth-card-switch { display: none; gap: 2px; }
.moth-card.sheet .moth-card-switch { display: flex; }
.moth-card-switch button { width: 40px; height: 44px; display: grid; place-items: center; border-radius: 12px; }
.moth-card-switch button:hover { background: var(--surface-soft); }
.moth-card-switch img { width: 34px; height: 34px; object-fit: contain; opacity: .9; }
.moth-card-close svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.moth-card-list { list-style: none; margin: 0; padding: 2px 6px 8px; overflow-y: auto; min-height: 0; overscroll-behavior: contain; }
.moth-card-list[data-loading=true]:empty { min-height: 120px; }
.hl-row {
  display: grid; grid-template-columns: 34px 44px minmax(0, 1fr); align-items: center; gap: 10px; width: 100%; min-height: 58px;
  padding: 6px 8px 6px 4px; border-radius: 12px; text-align: left; transition: background-color .15s;
}
.moth-card[data-moth=reacted] .hl-row { grid-template-columns: 44px minmax(0, 1fr) auto; padding-left: 8px; }
.hl-row:hover { background: var(--surface-soft); }
.hl-row:active { background: var(--surface); }
.hl-row:focus-visible { outline-offset: -2px; }
.hl-row img { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: var(--surface); }
.hl-rank { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-height: 40px; }
.hl-number { font-size: 12.5px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; line-height: 1.2; }
.moth-card[data-moth=top] li:first-child .hl-number { color: var(--gold-ink); }
.hl-name { font-size: 14px; font-weight: 520; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hl-reactions { display: flex; gap: 8px; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 550; }
.hl-reaction { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.hl-reaction .emoji { font-size: 14px; line-height: 1; }
.moth-card-empty { font-size: 13px; line-height: 1.6; color: var(--muted); padding: 6px 16px 18px 62px; }
.moth-card.sheet {
  left: 0; right: 0; bottom: 0; top: auto; width: auto; max-height: min(78dvh, 520px); border-radius: 22px 22px 0 0;
  border-bottom: 0; padding-bottom: env(safe-area-inset-bottom); transform-origin: 50% 100%;
}
.moth-card.sheet .moth-card-head { padding: 14px 8px 8px 16px; }
.moth-card.sheet .moth-card-head::before {
  content: ""; position: absolute; left: 50%; top: 6px; width: 36px; height: 4px; margin-left: -18px; border-radius: 2px; background: var(--line);
}
.moth-card.sheet .moth-card-mascot { width: 48px; height: 48px; }
.moth-card.sheet .moth-card-list { padding: 2px 10px 14px; }
.moth-scrim { position: fixed; inset: 0; z-index: 44; background: #2333293d; }

@media (min-width: 1000px) {
  /* Desktop: the stack lives in the margin to the right of the conversation. */
  .moth { --moth-size: 54px; right: calc((100vw - 760px) / 2 - var(--moth-size) - 30px); bottom: 34px; }
}
@media (hover: hover) and (pointer: fine) {
  .moth-bubble:hover img { rotate: -6deg; }
  .moth-bubble:hover::before { opacity: .6; }
}
@media (prefers-reduced-motion: no-preference) {
  .moth-bubble img { animation: moth-float 3.6s ease-in-out infinite; }
  .moth-bubble.top img { animation-delay: -.9s; animation-duration: 3.9s; }
  .moth-bubble.reacted img { animation-delay: -2.1s; animation-duration: 3.4s; }
  .moth-bubble.bottom img { animation-delay: -1.4s; animation-duration: 3.7s; }
  @keyframes moth-float { 50% { translate: 0 -2px; } }
  .crown-glow { animation: crown-glow 3.2s ease-in-out infinite; }
  .crown-sparkle { animation: crown-sparkle 3.2s ease-in-out infinite; }
  @keyframes crown-glow { 0%, 100% { opacity: .35; } 50% { opacity: .85; } }
  @keyframes crown-sparkle { 0%, 30% { opacity: 0; transform: scale(.4) rotate(0); } 46% { opacity: 1; transform: scale(1) rotate(45deg); } 64%, 100% { opacity: 0; transform: scale(.5) rotate(90deg); } }
}

@media (min-width: 800px) {
  .conversation { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
  .app-header { padding-left: 24px; padding-right: 14px; }
  .chat-history { padding: 6px 28px var(--chat-end); --chat-w: calc(min(100vw, 760px) - 58px); }
  .photo-frame { --maxh: 380px; }
  .viewer-nav { display: grid; }
  .top-entry-layer { left: auto; right: 20px; top: 18px; width: 380px; justify-content: flex-end; }
  /* Desktop camera: the controls stay near the frame instead of the far corners. */
  .cam-bottom { left: 50%; right: auto; width: min(100%, 560px); translate: -50% 0; }
}
@media (max-width: 600px) {
  .chat-history { padding: 4px 16px var(--chat-end); --chat-w: calc(100vw - 32px); }
  .menu-dialog { margin: auto auto max(14px, env(safe-area-inset-bottom)); max-height: 85dvh; }
  .toast { bottom: calc(126px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: no-preference) {
  dialog[open]:is(.menu-dialog) { animation: appear .18s var(--settle); }
  dialog[open]:is(.camera, .post-dialog) { animation: fade-in .2s ease-out; }
  @keyframes appear { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
  @keyframes fade-in { from { opacity: 0; } }
}
@media (prefers-reduced-motion: reduce) {
  .tactile, .tactile:active:not(:disabled), .tactile.pressed:not(:disabled), .camera-button:active, .camera-button.pressed { transform: none; transition: background-color .1s; }
  .cam-shutter-core, .cam-shutter:active .cam-shutter-core, .cam-shutter.pressed .cam-shutter-core, .lib-thumb, .lib-tile:active .lib-thumb { transform: none; transition: background-color .1s; }
  .cam-frame video, .cam-grid { transition: none; }
  .score-panel, .score-sheet, .score-toggle svg, .reaction-picker button, .send-bar span { transition: none; }
  .score-panel .score-sheet { transform: none; }
  .reaction-picker button.hot, .reaction-picker button:hover { transform: none; }
  .viewer-chrome { transition: none; }
  .moth-bubble, .moth-bubble img { transition: none; }
  .moth-bubble.selected, .moth-bubble.pressed { scale: 1; }
  .moth-bubble:hover img { rotate: none; }
  .crown-glow { opacity: .55; }
}

/* Current positions stay readable at every rank; the crown sits below the image. */
.rank-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 20px; line-height: 1.3; font-weight: 650; color: #424640; padding: 0 8px 0 2px; }
.rank-chip.second, .rank-label.rank-second { color: #887249; }
.rank-label { position: relative; display: inline-block; vertical-align: bottom; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rank-label.rank-first { color: var(--gold-ink); }
.rank-current { display: inline-block; }
.rank-old { position: absolute; inset: 0 auto auto 0; pointer-events: none; }
.score-line { gap: 5px; min-height: 44px; }
.score-toggle { min-height: 44px; font-size: 13px; }
.photo-footer.quiet { flex-direction: column; align-items: stretch; }
.photo-footer.quiet .score-panel { order: initial; flex-basis: auto; }
.photo-caption { margin-top: 6px; }
.hl-rank { color: #55594f; }

/* Stacks are the only previews on the Albums index. */
.albums-head { max-width: 960px; height: calc(64px + env(safe-area-inset-top)); }
#albums-close { width: auto; min-width: 44px; display: inline-flex; align-items: center; gap: 3px; padding: 0 8px; font-size: 15px; }
.albums-head h2 { margin: 0; }
.albums-body { overflow-anchor: none; }
.albums-people { max-width: 760px; gap: 0; padding-top: 10px; }
.album-entry { display: flex; align-items: center; gap: 24px; width: 100%; min-height: 132px; padding: 20px 12px; text-align: left; border-bottom: 1px solid var(--line); }
.album-entry:last-child { border-bottom: 0; }
.album-stack { position: relative; width: 96px; height: 88px; flex-shrink: 0; }
.stack-photo { position: absolute; width: 82px; height: 82px; left: 3px; top: 3px; object-fit: cover; border: 3px solid var(--bg); border-radius: 10px; box-shadow: 0 3px 9px #28271b26; }
.stack-0 { transform: rotate(-3deg); }
.stack-1 { transform: translate(7px,-3px) rotate(5deg); }
.stack-2 { transform: translate(12px,-5px) rotate(10deg); }
.album-who { display: flex; flex: 1; flex-direction: column; align-items: flex-start; min-width: 0; gap: 3px; }
.album-name { font-size: 17px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.album-count, .album-best { font-size: 13px; color: var(--muted); line-height: 1.5; }
.album-best .rank-label { font-weight: 650; }
.album-arrow { color: #888b80; font-size: 23px; }
.album-person { max-width: 960px; margin: auto; padding: 22px max(18px,env(safe-area-inset-right)) calc(36px + env(safe-area-inset-bottom)) max(18px,env(safe-area-inset-left)); }
.album-person-name { font-family: var(--serif); font-size: 32px; font-weight: 400; line-height: 1.2; margin: 0; letter-spacing: -.03em; overflow-wrap: anywhere; }
.album-person-count { margin: 6px 0 24px; font-size: 13px; color: var(--muted); }
.album-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; list-style: none; padding: 0; margin: 0; }
.album-tile { display: block; width: 100%; border-radius: 12px; }
.album-tile .lib-thumb { width: 100%; }
.album-tag { position: absolute; left: 8px; bottom: 8px; padding: 2px 7px; border-radius: 7px; font-size: 13px; font-weight: 650; line-height: 1.5; color: #424640; background: #fffffff0; box-shadow: 0 1px 5px #00000014; }
.album-more { display: block; margin: 18px auto 0; min-height: 44px; color: var(--muted); }
.album-empty { text-align: center; color: var(--muted); margin: 36px 0; }
.album-empty:empty { display: none; }
@media (min-width: 620px) { .album-grid { grid-template-columns: repeat(3,minmax(0,1fr)); gap: 16px; } }
@media (min-width: 940px) { .album-grid { grid-template-columns: repeat(4,minmax(0,1fr)); } }
@media (prefers-reduced-motion: reduce) { .rank-old { display: none; } }
.viewer-who .rank-chip { font-size: 18px; }
.viewer-who .rank-first { color: #ffe6a6; }
.viewer-who .rank-second { color: #e4d1aa; }
.moth-card[data-moth=reacted] .hl-row { grid-template-columns: 36px 44px minmax(0,1fr) auto; padding-left: 8px; }
.rank-label { overflow: hidden; }
.photo-footer .crown-1 { --crown-w: 32px; }
.photo-footer .crown-2 { --crown-w: 17px; }

/* ---------- Compare: two prints on the page; lift the stronger one up, or tap it ---------- */
.compare { --gold: #e0b04a; --gold-deep: #b4862a; --heart: #d4574b; background: var(--bg); color: var(--ink); }
.compare[open] { display: flex; flex-direction: column; }
.compare::backdrop { background: var(--bg); }
#compare-close { min-width: 44px; }
.compare-body {
  position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; container-type: size;
  overflow: hidden auto; overscroll-behavior: none;
  padding: 0 max(16px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  /* Each photo gets a box about 45% of the usable width; portrait photos are held to a maximum height. */
  --bw: min(45.5cqw, 380px);
  --bh: max(110px, min(calc(var(--bw) * 1.4), calc(100cqh - 222px)));
}
.compare-group { position: relative; margin: auto 0; padding-bottom: 4cqh; display: flex; flex-direction: column; align-items: center; }
.compare-title { font-family: var(--serif); font-weight: 400; font-size: 24px; letter-spacing: -.035em; line-height: 1.15; text-align: center; transition: opacity .24s ease-out; }
.compare-hint { margin-top: 5px; font-size: 13px; line-height: 1.4; color: var(--muted); text-align: center; transition: opacity .2s ease-out; }
/* While a print is lifted toward the heading, the words step back so the photo has the room. */
.compare-body.lifting .compare-title { opacity: .22; }
.compare-body.lifting .compare-hint { opacity: 0; }
.compare-pair {
  margin-top: 34px; display: grid; grid-template-columns: var(--bw) var(--bw); column-gap: clamp(12px, 4.5cqw, 40px);
  align-items: center; justify-content: center; user-select: none; -webkit-user-select: none;
}
/* Perspective lives on the column so a lifted print can tilt a degree or two, never more. */
.compare-option { display: flex; flex-direction: column; align-items: center; min-width: 0; perspective: 900px; }
.compare-lift {
  position: relative; width: min(var(--bw), calc(var(--bh) * var(--ar, 1.333))); aspect-ratio: var(--ar, 1.333);
  transform-origin: 50% 70%; will-change: transform, opacity;
}
/* Only the photos claim the gesture; the page still scrolls from anywhere else. */
.compare-pick { position: absolute; inset: 0; display: block; border-radius: 10px; touch-action: none; -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
.compare-pick:focus-visible { outline: none; }
.compare-pick:focus-visible .compare-photo { outline: 2px solid var(--accent); outline-offset: 5px; }
/* A print resting just above the page: a thin white border and a short, close shadow. */
.compare-photo {
  position: relative; display: block; width: 100%; height: 100%; border-radius: 10px; overflow: hidden; background: #fff;
  box-shadow: 0 0 0 3px #fff, 0 1px 1.5px 3px #2333291a, 0 6px 12px -4px #23332929;
}
.compare-photo img { width: 100%; height: 100%; object-fit: contain; background: var(--surface); -webkit-user-drag: none; pointer-events: none; }
.compare-photo.is-hidden { visibility: hidden; }
/* The lifted print's deeper, softer shadow: faded in by opacity, never animated as a shadow. */
.compare-shadow {
  position: absolute; inset: 0; border-radius: 10px; pointer-events: none; opacity: 0;
  box-shadow: 0 0 0 3px #fff, 0 26px 44px -14px #3a2c1259, 0 12px 18px -10px #3a2c1238;
}
/* A warm light across the top of the lifted print. */
.compare-glow {
  position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: linear-gradient(172deg, #fff1d0a6 0%, #ffe9b84d 34%, #ffe9b800 62%);
}
/* The print left on the page softens toward the paper colour. */
.compare-veil { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: var(--bg); }
.hint-fine { display: none; }
@media (hover: hover) and (pointer: fine) {
  .hint-touch { display: none; }
  .hint-fine { display: inline; }
  .compare-pick { cursor: pointer; }
  .compare-photo { transition: outline-color .2s ease-out; outline: 2px solid transparent; outline-offset: 6px; }
  .compare-body:not(.locked) .compare-pick:hover .compare-photo { outline-color: #e0b04a73; }
}
.compare-body.locked .compare-pick { cursor: default; }
/* The heart rides on the lifted print's top edge: faint, then growing, then full. Driven frame by frame. */
.compare-heart {
  position: absolute; left: 50%; top: -21px; width: 38px; height: 38px; margin-left: -19px; pointer-events: none;
  opacity: 0; transform: scale(0); transform-origin: 50% 60%; filter: drop-shadow(0 3px 5px #5a2a0a33);
}
.compare-heart svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.heart-soft circle { fill: #fffdf7; stroke: #f0d9b0; stroke-width: 1.2; }
.heart-soft path { fill: #fbe3dc; stroke: var(--heart); stroke-width: 1.7; stroke-linejoin: round; }
.heart-full { opacity: 0; }
.heart-full circle { fill: #fffdf7; stroke: var(--gold); stroke-width: 1.6; }
.heart-full path { fill: var(--heart); stroke: var(--heart); stroke-width: 1.2; stroke-linejoin: round; }
/* Look closer sits on the photo's own bottom-right corner, small and quiet. */
.compare-view { position: absolute; right: 0; bottom: 0; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; transition: opacity .2s ease-out, transform .32s var(--spring); }
.compare-view svg { width: 28px; height: 28px; padding: 6px; border-radius: 50%; background: #fffdf8e0; box-shadow: 0 1px 4px #0000001c; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.compare-view:focus-visible { outline-offset: -4px; border-radius: 50%; }
.compare-body.locked .compare-view, .compare-body.lifting .compare-view { opacity: 0; pointer-events: none; }
.compare-wait { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; display: grid; place-items: center; border-radius: 50%; background: #fafaf7e6; pointer-events: none; }
.compare-wait img { width: 34px; height: 34px; object-fit: contain; }
.compare-empty { padding: 40px 20px; }
.compare-status { max-width: 34ch; margin-top: 16px; text-align: center; font-size: 13px; line-height: 1.4; color: var(--ink); }
.compare-status:empty { display: none; }
.compare-foot { margin-top: 22px; display: flex; justify-content: center; }
.compare-skip { min-width: 96px; padding: 10px 18px; font-size: 14px; color: var(--muted); border-radius: 22px; }
.compare-skip:hover:not(:disabled) { color: var(--ink); background: var(--surface); }
.compare-body.locked .compare-skip:disabled { opacity: 1; }
/* Inspect: one photo larger over the pair. */
.compare-inspect { position: fixed; inset: 0; z-index: 4; }
.compare-inspect-backdrop { position: absolute; inset: 0; background: #f4f4efF5; }
.compare-inspect-image { position: fixed; border-radius: 6px; object-fit: contain; transform-origin: 0 0; box-shadow: 0 18px 50px -20px #1c241f66; -webkit-user-drag: none; }
.compare-inspect-close {
  position: fixed; top: calc(8px + env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right)); width: 44px; height: 44px;
  display: grid; place-items: center; border-radius: 50%;
}
.compare-inspect-close svg { width: 22px; height: 22px; fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; }
@media (max-height: 520px) {
  .compare-body { --bh: max(96px, min(calc(var(--bw) * 1.4), calc(100cqh - 166px))); }
  .compare-hint { margin-top: 2px; }
  .compare-title { font-size: 20px; }
  .compare-pair { margin-top: 18px; }
  .compare-foot { margin-top: 4px; }
  .compare-group { padding-bottom: 0; }
}
@media (prefers-reduced-motion: no-preference) {
  .compare-wait img { animation: compare-flutter 1.1s ease-in-out infinite; }
  @keyframes compare-flutter { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-3px) rotate(4deg); } }
}
@media (max-height: 400px) {
  .compare-body { --bh: max(84px, min(calc(var(--bw) * 1.4), calc(100cqh - 140px))); }
  .compare-hint { display: none; }
  .compare-grip { margin-top: 4px; }
}
@media (prefers-reduced-motion: reduce) { .compare-photo, .compare-view, .compare-title, .compare-hint, .compare-grip, .grip-release, .grip-steps { transition: none; } }

/* The guide. A ghost fingertip that shows the lift; driven only by the demonstration, never by a real touch. */
.compare-finger { position: absolute; left: 50%; top: 60%; width: 32px; height: 32px; margin: -16px 0 0 -16px; pointer-events: none; opacity: 0; }
.finger-dot {
  position: absolute; inset: 0; border-radius: 50%; background: #fffdf8d6;
  box-shadow: inset 0 0 0 2px #ffffff, 0 0 0 1px #23332942, 0 4px 14px -3px #23332985;
}
.finger-trail {
  position: absolute; left: 50%; top: 50%; width: 8px; height: 36px; margin-left: -4px; border-radius: 4px;
  background: linear-gradient(#fffdf8b8, #fffdf800); transform: scaleY(0); transform-origin: 50% 0;
}
/* Under each print: three chevrons pointing up. Newcomers see them pulse upward, the two prints out of step. */
.compare-grip {
  position: relative; display: grid; place-items: center; width: 100%; height: 22px; margin-top: 9px;
  touch-action: none; user-select: none; -webkit-user-select: none; transition: opacity .2s ease-out;
}
.grip-steps { display: flex; flex-direction: column-reverse; align-items: center; transition: opacity .16s ease-out; }
.grip-step { position: relative; display: block; width: 18px; height: 8px; }
.grip-step + .grip-step { margin-bottom: -1px; }
.grip-step svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.step-dim { stroke: #8d9288; opacity: .75; }
.step-lit { stroke: var(--gold-deep); opacity: 0; }
.compare-body:not(.dragging) .step-lit { transition: opacity .22s ease-out; }
.grip-release {
  position: absolute; left: 50%; top: 50%; translate: -50% -50%; white-space: nowrap; pointer-events: none;
  font-size: 12px; font-weight: 600; line-height: 1; letter-spacing: .01em; color: var(--gold-deep);
  opacity: 0; transform: translateY(3px); transition: opacity .16s ease-out, transform .2s ease-out;
}
/* Past the threshold the chevrons give way to the words; the other print's chevrons step back. */
.compare-grip.armed .grip-steps { opacity: 0; }
.compare-grip.armed .grip-release { opacity: 1; transform: none; }
.compare-grip.aside { opacity: .25; }
.compare-body.locked .compare-grip { opacity: 0; }
/* After three lifts on this device, a quiet static mark; mouse users get the same. A lift in progress shows in full. */
.compare-body[data-guide=known]:not(.dragging):not(.locked) .compare-grip { opacity: .4; }
@media (hover: hover) and (pointer: fine) {
  .compare-body:not(.dragging):not(.locked) .compare-grip { opacity: .45; }
  .compare-finger { display: none; }
}
@media (prefers-reduced-motion: no-preference) and (hover: none), (prefers-reduced-motion: no-preference) and (pointer: coarse) {
  .grip-step { animation: grip-chase 2.4s ease-in-out infinite; }
  .grip-step:nth-child(2) { animation-delay: .16s; }
  .grip-step:nth-child(3) { animation-delay: .32s; }
  .compare-option[data-index="1"] .grip-step { animation-delay: 1.2s; }
  .compare-option[data-index="1"] .grip-step:nth-child(2) { animation-delay: 1.36s; }
  .compare-option[data-index="1"] .grip-step:nth-child(3) { animation-delay: 1.52s; }
  .compare-body:not([data-guide=new]) .grip-step, .compare-body.dragging .grip-step, .compare-body.locked .grip-step { animation: none; }
  @keyframes grip-chase {
    0%, 55%, 100% { opacity: .5; transform: none; }
    18% { opacity: 1; transform: translateY(-2.5px); }
  }
}

/* Ranking belongs to the photo, with no blocking overlay or simulated progress. */
.score-line { position: relative; flex-wrap: wrap; }
.rank-chip { padding-right: 2px; }
.rank-title { font-size: 11px; font-weight: 550; white-space: nowrap; }
.placing { display: inline-flex; align-items: center; gap: 3px; min-height: 52px; max-width: 100%; color: #626a60; }
.placing-stage { display: block; position: relative; width: 56px; height: 52px; flex-shrink: 0; }
.placing-orbit { position: absolute; left: 12px; top: 10px; width: 32px; height: 32px; }
.placing-moth { width: 32px; height: 32px; object-fit: contain; }
.placing-label { font-size: 12px; line-height: 1.4; }
.placing.settling { position: absolute; left: 0; top: 50%; transform: translateY(-50%); pointer-events: none; }
.placing.settling .placing-label { display: none; }
.placing.settling .placing-orbit, .placing.settling .placing-moth { animation: none; }
.rank-revealing { min-height: 52px; }
.rank-failure { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 4px; font-size: 12px; color: #737269; }
.rank-retry { min-width: 44px; padding: 10px 5px; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.rank-speck { position: absolute; left: 26px; top: 24px; width: 4px; height: 4px; border-radius: 50%; background: #e9c570; opacity: 0; pointer-events: none; }
.speck-0 { --sx: -22px; --sy: -17px; background: #f6e8bb; }
.speck-1 { --sx: 3px; --sy: -27px; width: 3px; height: 3px; }
.speck-2 { --sx: 25px; --sy: -12px; background: #f5dda0; }
.speck-3 { --sx: 24px; --sy: 17px; width: 3px; height: 3px; }
.speck-4 { --sx: -2px; --sy: 25px; background: #f5dda0; }
.speck-5 { --sx: -25px; --sy: 10px; width: 3px; height: 3px; }
.viewer-bottom .rank-chip { color: #f3f4f0; }
.viewer-bottom .rank-first, .viewer-bottom .rank-chip.first { color: #ffe6a6; }
.viewer-bottom .rank-second, .viewer-bottom .rank-chip.second { color: #e4d1aa; }
.viewer-bottom .placing, .viewer-bottom .rank-failure { color: #d2d6cc; }
.viewer-bottom .rank-retry { color: #fff; }
.viewer-bottom .placing.settling { left: calc(50% - 92px); }
@media (prefers-reduced-motion: no-preference) {
  .placing-orbit { animation: placing-orbit 2s linear infinite; }
  .placing-moth { animation: placing-bob 1s ease-in-out infinite; }
  .rank-speck { animation: rank-speck 320ms 100ms ease-out both; }
  @keyframes placing-orbit {
    from { transform: rotate(0deg) translateX(11px) rotate(0deg); }
    to { transform: rotate(360deg) translateX(11px) rotate(-360deg); }
  }
  @keyframes placing-bob { 50% { transform: translateY(-2px); } }
  @keyframes rank-speck {
    0% { transform: translate(calc(var(--sx) * .25), calc(var(--sy) * .25)) scale(.5); opacity: 0; }
    20% { opacity: .95; }
    100% { transform: translate(var(--sx), var(--sy)) scale(.4); opacity: 0; }
  }
}
@media (prefers-reduced-motion: reduce) {
  .rank-speck { display: none; }
  .placing-stage { width: 40px; }
  .placing-orbit { left: 4px; }
}

/* ---------- A newer version is ready: one quiet pill under the header, clear of the camera button ---------- */
.update-pill {
  position: fixed; z-index: 70; top: var(--pill-top, calc(62px + env(safe-area-inset-top))); left: 50%; translate: -50% 0;
  display: flex; align-items: center; gap: 2px; max-width: calc(100% - 24px); padding: 0 2px 0 16px; border-radius: 22px;
  background: #fffdf8; color: var(--ink); font-size: 13px; line-height: 1.3; white-space: nowrap;
  box-shadow: 0 0 0 1px var(--line), 0 6px 18px -8px #2333293d;
}
.update-text { overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.update-dot { color: var(--faint); padding: 0 2px 0 6px; }
.update-refresh { min-height: 44px; padding: 0 8px; font-weight: 600; color: var(--accent); }
.update-dismiss { width: 40px; height: 44px; font-size: 19px; line-height: 1; color: var(--faint); }
.update-dismiss:hover, .update-refresh:hover { color: var(--ink); }

/* The photo preview can always be closed, even with no browser chrome around it (Home Screen app). */
.post-close {
  position: absolute; z-index: 1; top: calc(6px + env(safe-area-inset-top)); left: max(6px, env(safe-area-inset-left));
  width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%;
}
.post-close svg { width: 22px; height: 22px; fill: none; stroke: #f3f4f0; stroke-width: 1.8; stroke-linecap: round; }
.post-dialog .post-form { padding-top: calc(52px + env(safe-area-inset-top)); }
.join-screen { padding-top: max(40px, calc(24px + env(safe-area-inset-top))); }

/* A newer version is known: one small gold dot on the ⋯ button and on the menu's Update Moth entry. */
#menu-open { position: relative; }
.update-badge {
  display: block; width: 10px; height: 10px; border-radius: 50%;
  background: var(--gold); box-shadow: 0 0 0 1.5px #fffdf7, 0 1px 2px #5a3f0a33;
}
.update-badge[hidden] { display: none; }
#menu-open .update-badge { position: absolute; top: 8px; right: 7px; pointer-events: none; }
.update-choice { display: flex; flex-direction: column; justify-content: center; gap: 1px; }
.update-choice-label { display: inline-flex; align-items: center; gap: 8px; }
.update-choice-label .update-badge { width: 9px; height: 9px; }
.update-note { font-size: 13px; line-height: 1.35; color: var(--muted); }
.update-note:empty { display: none; }
@media (prefers-reduced-motion: no-preference) {
  #menu-open .update-badge:not([hidden]) { animation: badge-in .32s var(--spring) both; }
  @keyframes badge-in { from { transform: scale(0); } to { transform: none; } }
}

/* ---------- 👎: last, smaller in the picker, a little quieter in the stream ---------- */
.chip[data-reaction=down] .emoji { font-size: 16px; opacity: .78; }
.reaction-picker button[data-pick=down] { width: 42px; font-size: 22px; margin-left: 4px; position: relative; }
.reaction-picker button[data-pick=down]::before { content: ""; position: absolute; left: -4px; top: 12px; bottom: 12px; width: 1px; background: var(--line); }

/* ---------- Danger Zone: crimson mascot, muted amber review controls ---------- */
:root { --amber: #d49a45; --amber-soft: #fbf1df; --amber-line: #ecd6ad; --amber-ink: #7d5418; --keep: #93ab9b; }
.moth-bubble.danger { --tint: #fcf0ef; --tint-edge: #f1d8d6; --ring: #dca6a2; }
.moth-spark.danger { color: #e3b46b; }
.moth-card-mascot[data-moth=danger] { --tint: #fcf0ef; --tint-edge: #f1d8d6; }
.moth-card-note { margin: 0 14px 6px; padding: 8px 11px; border-radius: 10px; background: var(--amber-soft); color: #6a5230; font-size: 12.5px; line-height: 1.45; flex-shrink: 0; }
.moth-card.sheet .moth-card-note { margin: 0 16px 8px; }
.danger-item { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 12px; padding: 10px 8px 12px; }
.danger-item + .danger-item { border-top: 1px solid var(--line); }
.danger-thumb { width: 64px; height: 64px; border-radius: 10px; overflow: hidden; background: var(--surface); }
.danger-thumb img { width: 100%; height: 100%; object-fit: cover; }
.danger-thumb:focus-visible { outline-offset: 2px; }
.danger-body { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.danger-title { font-size: 14px; font-weight: 600; letter-spacing: -.01em; line-height: 1.3; color: var(--ink); }
.danger-sub { margin-top: -3px; font-size: 12.5px; color: var(--muted); line-height: 1.35; }
/* One segment per person in the review: Delete gathers from the left, Keep from the right. */
.danger-meter { display: flex; gap: 2px; height: 5px; margin: 2px 0 1px; }
.danger-seg { position: relative; flex: 1; border-radius: 3px; background: #ebe8df; overflow: hidden; }
.danger-seg::before, .danger-seg::after { content: ""; position: absolute; inset: 0; opacity: 0; transition: opacity .32s ease-out; }
.danger-seg::before { background: var(--amber); }
.danger-seg::after { background: var(--keep); }
.danger-seg[data-vote=delete]::before, .danger-seg[data-vote=keep]::after { opacity: 1; }
.danger-totals { display: flex; flex-wrap: wrap; gap: 2px 14px; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.danger-totals span:first-child { color: var(--amber-ink); }
.danger-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 3px; }
.danger-vote {
  min-width: 78px; min-height: 40px; padding: 0 16px; border-radius: 20px; font-size: 14px; font-weight: 560;
  background: var(--surface); color: var(--ink); position: relative;
}
.danger-vote::after { content: ""; position: absolute; inset: -2px 0; }
.danger-vote.delete { background: var(--amber-soft); color: var(--amber-ink); box-shadow: inset 0 0 0 1px var(--amber-line); }
.danger-vote:hover:not(:disabled) { background: #e9ebe5; }
.danger-vote.delete:hover:not(:disabled) { background: #f8e7c9; }
.danger-yours { font-size: 13px; font-weight: 560; color: var(--ink); }
.danger-yours.delete { color: var(--amber-ink); }
.danger-change { min-height: 44px; padding: 0 6px; font-size: 13px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line); }
.danger-change:hover:not(:disabled) { color: var(--ink); }

/* Under review: a small amber tag beside the rank and score; the photo itself stays as it is. */
.review-tag {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px 0 8px; margin-left: 4px; border-radius: 12px;
  background: var(--amber-soft); color: var(--amber-ink); font-size: 11.5px; font-weight: 560; white-space: nowrap;
  box-shadow: inset 0 0 0 1px var(--amber-line);
}
.review-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--amber); }
.viewer-bottom .review-tag { background: #f3c77a24; color: #f3d8a6; box-shadow: inset 0 0 0 1px #f3c77a40; }

/* Danger Zone notices: the Top 5 card's size and place, in muted amber. */
.top-entry.review-entry { background: #fdf4e4; border-color: #ead2a4; color: #4a3a22; }
.review-entry .top-entry-text { font-weight: 520; }
.review-entry .top-entry-dismiss { color: #8a6a3a; }
.review-mark { position: relative; flex-shrink: 0; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: radial-gradient(circle at 34% 28%, #fffdf9 0%, #fcf1de 58%, #f2ddb7 100%); }
.review-mark img { width: 26px; height: 26px; object-fit: contain; }
.review-mark-dot { position: absolute; right: 0; top: 1px; width: 8px; height: 8px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 1.5px #fdf4e4; }
@media (prefers-reduced-motion: reduce) { .danger-seg::before, .danger-seg::after { transition: none; } }
/* The last removed photo: one quiet tile, blurred and veiled so it reads as gone. Not tappable. */
.removed-slot { display: grid; flex-shrink: 0; margin: 0 14px 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.moth-card.sheet .removed-slot { margin: 0 18px 14px; }
.moth-card-empty:not([hidden]) + .removed-slot { border-top: 0; padding-top: 0; }
.removed-tile { grid-area: 1 / 1; display: grid; grid-template-columns: 64px minmax(0, 1fr); align-items: center; gap: 12px; padding-top: 2px; }
.removed-tile.entering { opacity: 0; }
.removed-frame {
  position: relative; width: 64px; height: calc(64px * var(--removed-ratio, .75)); border-radius: 10px; overflow: hidden;
  background: #dfe1dc; isolation: isolate;
}
.removed-frame img { width: 100%; height: 100%; object-fit: cover; filter: blur(3px) saturate(.7); transform: scale(1.12); }
.removed-frame::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, #1f262233, #1f262266); }
.removed-tile.blank .removed-frame img { display: none; }
.removed-tile.blank .removed-frame::after { background: #1f26221a; }
.removed-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.removed-label { font-size: 13.5px; font-weight: 560; color: var(--muted); letter-spacing: -.005em; }
.removed-reason { font-size: 12.5px; color: var(--muted); opacity: .85; }
/* Four Moths in the small sheet's header: narrower switches so "Danger Zone" stays on one line. */
.moth-card.sheet .moth-card-head h2 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.moth-card.sheet .moth-card-switch button { width: 36px; }
.moth-card.sheet .moth-card-switch img { width: 30px; height: 30px; }
.moth-card.sheet .moth-card-head { gap: 8px; }

/* ---------- Avatars: a small round picture beside a name, the first letter when there is none ---------- */
.avatar { overflow: hidden; }
.avatar.has-photo { background: var(--surface); }
.avatar.has-photo img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
/* The picture and name lead to that person's profile; the tap area reaches past the text. */
.person-link {
  display: flex; align-items: center; gap: 9px; min-width: 0; max-width: 100%; text-align: left;
  margin: -7px -10px -7px -6px; padding: 7px 10px 7px 6px; border-radius: 14px; transition: background-color .15s;
}
.person-link:active { background: var(--surface-soft); }
.album-name-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.album-avatar { width: 24px; height: 24px; font-size: 10.5px; }
.album-person-head { display: flex; align-items: center; gap: 12px; }
.album-person-avatar { width: 44px; height: 44px; font-size: 17px; }
.viewer-person-link { display: inline-flex; align-items: center; gap: 9px; min-width: 0; min-height: 40px; margin: -6px 0 -6px -6px; padding: 4px 8px 4px 6px; border-radius: 20px; text-align: left; transition: background-color .15s; }
.viewer-person-link:active { background: #ffffff1f; }
.viewer-avatar { width: 28px; height: 28px; font-size: 11.5px; background: #ffffff29; color: #fff; }
@media (hover: hover) and (pointer: fine) {
  .person-link:hover { background: var(--surface-soft); }
  .viewer-person-link:hover { background: #ffffff1a; }
}

/* ---------- Profile: one person's photos and how they've done ---------- */
.profile, .selfie {
  position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0;
  border: 0; border-radius: 0; box-shadow: none; overflow: hidden; background: var(--bg); color: var(--ink);
}
.profile[open] { display: flex; flex-direction: column; }
.profile::backdrop, .selfie::backdrop { background: var(--bg); }
#profile-close { width: auto; min-width: 44px; display: inline-flex; align-items: center; padding: 0 8px; }
.profile-body { overflow-anchor: none; }
.profile-card {
  max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 30px max(22px, env(safe-area-inset-right)) 4px max(22px, env(safe-area-inset-left));
}
.profile-avatar { width: 108px; height: 108px; font-family: var(--serif); font-size: 44px; font-weight: 400; box-shadow: 0 0 0 4px var(--bg), 0 0 0 5px var(--line); }
.profile-name { font-family: var(--serif); font-size: 32px; line-height: 1.15; letter-spacing: -.035em; margin-top: 16px; overflow-wrap: anywhere; }
.profile-joined { font-size: 13px; color: var(--muted); margin-top: 5px; }
.profile-note { margin-top: 16px; max-width: 360px; padding: 10px 14px; border-radius: 12px; background: #f6eee3; color: #5d4a2c; font-size: 13.5px; line-height: 1.5; }
.profile-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(60px, 1fr)); gap: 8px; width: 100%; margin: 24px 0 0; }
.profile-stat { display: flex; flex-direction: column-reverse; justify-content: flex-end; gap: 1px; padding: 12px 4px 10px; border-radius: 14px; background: var(--surface-soft); border: 1px solid var(--line); min-width: 0; }
.profile-stat dt { font-size: 11.5px; color: var(--muted); line-height: 1.3; }
.profile-stat dd { margin: 0; font-size: 22px; font-weight: 650; line-height: 1.3; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.profile-best { display: inline-flex; align-items: center; justify-content: center; gap: 4px; }
.profile-best .crown-1 { --crown-w: 22px; }
.profile-best .crown-2 { --crown-w: 15px; }
.profile-stat.best-1 dd { color: var(--gold-ink); }
.profile-stat.best-2 dd { color: #887249; }
.profile-reactions { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; margin-top: 12px; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 550; }
.profile-reactions .hl-reaction { display: inline-flex; align-items: center; gap: 4px; }
.profile-own { display: flex; flex-direction: column; align-items: center; width: 100%; max-width: 340px; margin-top: 26px; }
#profile-chat { width: 100%; }
.profile-selfie { display: flex; justify-content: center; gap: 24px; margin-top: 4px; }
.profile-insights { display: inline-flex; align-items: center; align-self: center; color: var(--muted); text-decoration: none; } /* v29 */
.profile-insights[hidden] { display: none; }
.profile-insights:hover { color: var(--ink); }
.profile-selfie .text-button { color: var(--muted); }
.profile-selfie .text-button:hover { color: var(--ink); }
.profile-confirm { width: 100%; margin-top: 12px; padding: 14px 16px 6px; border-radius: 14px; background: var(--surface-soft); border: 1px solid var(--line); font-size: 13.5px; line-height: 1.5; }
.profile-confirm-actions { display: flex; justify-content: center; align-items: center; gap: 18px; margin-top: 10px; }
.profile-confirm-actions .button { min-height: 40px; padding: 8px 20px; }
.profile-confirm-actions .text-button { color: var(--muted); }
.profile-photos {
  max-width: 960px; margin: 0 auto;
  padding: 28px max(18px, env(safe-area-inset-right)) calc(36px + env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
}
.profile-section { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 14px; padding-top: 22px; border-top: 1px solid var(--line); }
.profile-photos .album-empty { margin: 26px 0; }

/* ---------- Selfie: a round, mirrored preview from the front camera ---------- */
.selfie { overflow-y: auto; overscroll-behavior: contain; }
.selfie[open] { display: grid; place-items: center; }
.selfie-content {
  width: 100%; max-width: 380px; display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: max(28px, calc(18px + env(safe-area-inset-top))) 26px max(24px, env(safe-area-inset-bottom));
}
.selfie-title { font-size: 21px; line-height: 1.3; letter-spacing: -.03em; max-width: 310px; text-wrap: balance; }
.selfie-text, .selfie-status, .profile-note, .profile-confirm p { text-wrap: balance; }
.selfie-text { margin-top: 8px; font-size: 14px; line-height: 1.6; color: var(--muted); max-width: 320px; }
.selfie-frame {
  position: relative; width: min(64vw, 248px, 36dvh); aspect-ratio: 1; margin: 26px 0 14px; border-radius: 50%; overflow: hidden;
  background: var(--surface); transform: translateZ(0); box-shadow: 0 0 0 5px var(--bg), 0 0 0 6px var(--line);
}
.selfie-frame video, .selfie-still { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
/* A mirror for the person; the picture sent is not mirrored. */
.selfie-frame video { transform: scaleX(-1); opacity: 0; transition: opacity .3s ease-out; }
.selfie-frame.live video { opacity: 1; }
.selfie-placeholder { position: absolute; left: 20%; top: 18%; width: 60%; height: 60%; fill: none; stroke: var(--faint); stroke-width: 3; stroke-linecap: round; }
.selfie-frame.live .selfie-placeholder { display: none; }
.selfie-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.selfie-ring { position: absolute; inset: 0; border-radius: 50%; pointer-events: none; box-shadow: inset 0 0 0 0 transparent; }
.selfie-frame.checking .selfie-ring { box-shadow: inset 0 0 0 4px var(--accent); }
.selfie-frame.waiting .selfie-placeholder { opacity: .55; }
.selfie-tries { display: inline-flex; align-items: center; gap: 9px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.selfie-dots { display: inline-flex; gap: 5px; }
.selfie-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); transition: background-color .3s; }
.selfie-dot.used { background: var(--line); }
.selfie-status { min-height: 22px; margin-top: 8px; font-size: 14px; line-height: 1.5; color: var(--muted); max-width: 320px; }
.selfie-status[data-kind="error"] { color: #a63d34; }
#selfie-shoot { width: 100%; max-width: 320px; margin-top: 14px; }
.selfie-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 24px; margin-top: 6px; }
.selfie-other { color: var(--muted); }
.selfie-other:hover { color: var(--ink); }
.selfie-back { position: absolute; z-index: 1; top: calc(6px + env(safe-area-inset-top)); left: max(6px, env(safe-area-inset-left)); }
.selfie-back svg { width: 24px; height: 24px; fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
@media (prefers-reduced-motion: no-preference) {
  .selfie-frame.checking .selfie-ring { animation: selfie-pulse 1.3s ease-in-out infinite; }
  @keyframes selfie-pulse { 50% { box-shadow: inset 0 0 0 7px #44685866; } }
  dialog[open]:is(.profile, .selfie) { animation: fade-in .18s ease-out; }
}
@media (prefers-reduced-motion: reduce) {
  .selfie-frame video, .selfie-dot, .person-link, .viewer-person-link { transition: none; }
}

/* ---------- v19 My profile details and the Edit profile sheet (profile-ui) ---------- */
.profile-card .profile-avatar { width: 136px; height: 136px; font-size: 56px; }
.profile-details { width: 100%; max-width: 420px; margin: 16px 0 0; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-soft); text-align: left; }
.profile-detail { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 48px; padding: 6px 16px; }
.profile-detail + .profile-detail { border-top: 1px solid var(--line); }
.profile-detail dt { flex-shrink: 0; font-size: 13px; color: var(--muted); }
.profile-detail dd { margin: 0; min-width: 0; font-size: 14px; line-height: 1.4; text-align: right; overflow-wrap: anywhere; }
.profile-detail .text-button { min-height: 36px; padding: 6px 0; font-size: 14px; font-weight: 550; color: var(--accent); }
.profile-detail .text-button:hover { color: var(--accent-deep); }
#profile-edit-open { width: 100%; margin-top: 10px; }
.profile-edit { width: min(440px, calc(100% - 28px)); padding: 0; overflow: hidden; }
.profile-edit[open] { display: flex; flex-direction: column; }
/* The form takes its content's height (flex-basis auto, not `flex: 1`'s 0%): Safari sizes a
   fit-content dialog from its items' flex-basis, and a 0% basis left the sheet 1px tall on iPhones. */
.profile-edit-form { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.profile-edit-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; padding: 4px 18px; border-bottom: 1px solid var(--line); }
.profile-edit-head h2 { font-size: 16px; text-align: center; }
.profile-edit-cancel { justify-self: start; font-size: 15px; color: var(--muted); }
.profile-edit-cancel:hover { color: var(--ink); }
.profile-edit-save { justify-self: end; font-size: 15px; font-weight: 650; color: var(--accent); }
.profile-edit-save:hover:not(:disabled) { color: var(--accent-deep); }
.profile-edit-save:disabled { opacity: .55; }
.profile-edit-body { overflow-y: auto; overscroll-behavior: contain; padding: 22px 22px max(24px, env(safe-area-inset-bottom)); }
.profile-edit-selfie { display: flex; flex-direction: column; align-items: center; text-align: center; }
.profile-edit-selfie:not([hidden]) + .profile-edit-fields { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line); }
.profile-edit-avatar { width: 96px; height: 96px; font-family: var(--serif); font-size: 40px; font-weight: 400; box-shadow: 0 0 0 4px var(--bg), 0 0 0 5px var(--line); }
.profile-edit-selfie-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 20px; margin-top: 16px; }
.profile-edit-selfie-actions .button { min-height: 40px; padding: 8px 18px; font-size: 14px; }
.profile-edit-selfie-actions .text-button { font-size: 14px; color: var(--muted); }
.profile-edit-selfie-actions .text-button:hover { color: var(--ink); }
.profile-edit-hint { max-width: 300px; margin-top: 6px; font-size: 12.5px; line-height: 1.5; color: var(--muted); text-wrap: balance; }
.profile-edit-field + .profile-edit-field { margin-top: 18px; }
.profile-edit-field label { font-weight: 550; }
.profile-edit-optional { font-weight: 400; color: var(--muted); }
.profile-edit-note { margin-top: 6px; font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.profile-edit-field .error { margin-top: 6px; line-height: 1.45; }
.profile-edit input[aria-invalid="true"] { border-color: #d39a93; }
.profile-edit-error { margin-top: 14px; }
@media (max-width: 600px) {
  .profile-edit { width: 100%; max-width: none; margin: auto 0 0; border-width: 1px 0 0; border-radius: 22px 22px 0 0; max-height: calc(100dvh - max(24px, env(safe-area-inset-top))); }
}
@media (prefers-reduced-motion: no-preference) {
  dialog[open].profile-edit { animation: profile-edit-in .2s var(--settle); }
  @keyframes profile-edit-in { from { opacity: 0; transform: translateY(8px); } }
}
@media (prefers-reduced-motion: no-preference) and (max-width: 600px) {
  dialog[open].profile-edit { animation: profile-edit-rise .28s var(--settle); }
  @keyframes profile-edit-rise { from { opacity: .4; transform: translateY(48px); } }
}
/* ---------- /v19 profile ---------- */

/* ---------- v19 camera adjust: brightness, contrast, looks (js/camera/adjust.js) ---------- */
.cam-adjusted { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; display: none; }
.cam-frame.live.adjusting .cam-adjusted { display: block; }
.cam-frame.mirrored .cam-adjusted { transform: scaleX(-1); }
.cam-adjust-toggle { position: relative; margin-left: auto; }
.cam-adjust-toggle[aria-expanded=true] { background: #ffffff3d; }
.adj-dot { position: absolute; top: 8px; right: 8px; width: 7px; height: 7px; border-radius: 50%; background: #f1c56a; box-shadow: 0 0 0 2px #0d0f0e; pointer-events: none; }
.adj-strip { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; color: #fff; font-size: 13px; overscroll-behavior: contain; }
.adj-strip-camera {
  position: absolute; z-index: 3; left: 50%; translate: -50% 0; bottom: calc(140px + env(safe-area-inset-bottom));
  width: min(calc(100% - 24px), 420px); padding: 8px 14px 10px; border-radius: 18px;
  background: rgb(18 21 19 / .74); -webkit-backdrop-filter: blur(14px) saturate(1.2); backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: 0 6px 22px #00000038, inset 0 0 0 1px #ffffff14;
}
.adj-row { display: grid; grid-template-columns: 74px 1fr 30px; align-items: center; gap: 8px; min-height: 44px; }
.adj-label { margin: 0; font-size: 13px; color: #ffffffd9; font-weight: 500; }
.adj-value { text-align: right; font-variant-numeric: tabular-nums; color: #ffffff8c; font-size: 12.5px; }
.adj-range.moved + .adj-value { color: #f1e4c4; }
/* The slider (our own, js/camera/adjust.js): a 44px tall touch area that never scrolls the page, a
   thin track with a mark at 0, a fill from 0 to the thumb, and a thumb that grows while held.
   Thumb and fill move by transform only. The 14px insets match INSET in adjust.js. */
.adj-range {
  position: relative; height: 44px; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent; outline: none; border-radius: 10px;
}
.adj-range.held { cursor: grabbing; }
.adj-range::before { content: ""; position: absolute; left: 50%; top: 50%; width: 2px; height: 12px; margin: -6px 0 0 -1px; border-radius: 1px; background: #ffffff8c; }
.adj-track { position: absolute; left: 14px; right: 14px; top: 50%; height: 3px; margin-top: -1.5px; border-radius: 2px; background: #ffffff38; }
.adj-fill { position: absolute; left: 50%; top: 0; width: 50%; height: 100%; background: #f1e4c4; transform-origin: 0 50%; transform: scaleX(0); will-change: transform; }
.adj-thumb-pos { position: absolute; left: 14px; top: 50%; width: 0; height: 0; pointer-events: none; will-change: transform; transform: translateX(0); }
.adj-thumb {
  position: absolute; left: -11px; top: -11px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 4px #0000005c; transition: transform .14s cubic-bezier(.22, 1, .36, 1), box-shadow .14s;
}
.adj-range.held .adj-thumb { transform: scale(1.18); box-shadow: 0 2px 10px #00000070; }
.adj-range:focus-visible { box-shadow: 0 0 0 2px #fff; }
.adj-actions { display: flex; align-items: center; gap: 10px; min-width: 0; padding-top: 6px; }
/* The looks: one row that scrolls sideways when it doesn't fit, with Reset kept at the end. */
.adj-looks {
  display: flex; gap: 8px; flex: 1 1 auto; min-width: 0; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
  padding: 2px; margin: -2px; -webkit-overflow-scrolling: touch;
}
.adj-looks::-webkit-scrollbar { display: none; }
.adj-chip {
  flex: none; min-height: 34px; padding: 0 15px; border-radius: 17px; color: #fff; font-weight: 550; font-size: 13.5px; white-space: nowrap;
  background: #ffffff0f; box-shadow: inset 0 0 0 1px #ffffff47; transition: background-color .12s, color .12s, box-shadow .12s;
}
.adj-chip[aria-pressed=true] { background: #f1e4c4; color: #1d1b16; box-shadow: none; }
.adj-reset { flex: none; min-height: 34px; padding: 0 6px; color: #ffffffbf; font-size: 13.5px; }
.adj-reset:disabled { color: #ffffff52; }
/* The review step (phone's own camera): an Adjust button above the note, the same strip below it. */
.adj-review { margin-bottom: 12px; }
.adj-review-toggle {
  position: relative; display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 0 14px 0 10px; border-radius: 18px;
  background: #ffffff14; color: #f3f4f0; font-size: 13.5px; font-weight: 550;
}
.adj-review-toggle[aria-expanded=true] { background: #ffffff2b; }
.adj-review-toggle svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.adj-review-toggle .adj-dot { position: static; order: 2; box-shadow: none; }
.adj-strip-review { margin-top: 8px; padding: 4px 12px 8px; border-radius: 14px; background: #ffffff0d; }
.adj-review-view { position: absolute; inset: 0; margin: auto; max-width: calc(100% - 28px); max-height: 100%; border-radius: 6px; }
.preview-wrap.adj-on #post-preview { visibility: hidden; }
@media (max-width: 370px) {
  .adj-chip { padding: 0 12px; }
  .adj-actions { gap: 8px; }
}
@media (orientation: landscape) and (max-height: 540px) {
  .adj-strip-camera { left: auto; right: calc(130px + env(safe-area-inset-right)); translate: none; bottom: 12px; width: min(calc(100% - 154px), 380px); }
}
@media (prefers-reduced-motion: reduce) {
  .adj-chip, .adj-thumb { transition: none; }
}
/* ---------- /v19 camera adjust ---------- */

/* ---------- v20 notifications and sound: the ⋯ menu rows, My profile rows, the one-time card ---------- */
.choice-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 56px; padding: 10px 0; }
.choice-button + .choice-row, .choice-row + .choice-row, .choice-row + .choice-button { border-top: 1px solid var(--line); }
.choice-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.choice-note { font-size: 13px; line-height: 1.35; color: var(--muted); text-wrap: pretty; }
.choice-note:empty { display: none; }
.choice-action { flex-shrink: 0; padding: 10px 2px; font-size: 14px; font-weight: 600; color: var(--accent); }
.choice-action:hover:not(:disabled) { color: var(--accent-deep); }
/* An on/off switch with a 44 px tap area around a small track. */
.sound-switch { flex-shrink: 0; display: grid; place-items: center; width: 52px; height: 44px; margin-right: -4px; }
.sound-switch::before {
  content: ""; grid-area: 1 / 1; width: 40px; height: 24px; border-radius: 12px; background: #d6dad3;
  transition: background-color .18s ease-out;
}
.sound-knob {
  grid-area: 1 / 1; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px #1d272140;
  translate: -8px 0; transition: translate .22s var(--settle);
}
.sound-switch[aria-checked=true]::before { background: var(--accent); }
.sound-switch[aria-checked=true] .sound-knob { translate: 8px 0; }
.profile-alerts { margin-top: 12px; }
.profile-alert-label { flex-shrink: 0; font-size: 13px; color: var(--muted); }
.profile-alert-value { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: 14px; line-height: 1.4; text-align: right; }
.profile-alert-value .text-button { min-height: 36px; padding: 6px 0; font-size: 14px; font-weight: 550; color: var(--accent); }
.profile-alert-value .text-button:hover { color: var(--accent-deep); }
.profile-alert-note { padding: 0 16px 12px; font-size: 13px; line-height: 1.45; color: var(--muted); text-wrap: pretty; }
.profile-alerts .sound-row { border-top: 1px solid var(--line); }
.profile-alerts .notify-row[hidden] ~ .sound-row { border-top: 0; }
.notify-card {
  position: fixed; z-index: 70; top: var(--card-top, calc(62px + env(safe-area-inset-top))); left: 50%; translate: -50% 0;
  display: grid; grid-template-columns: 28px 1fr; align-items: center; gap: 4px 12px; width: min(360px, calc(100% - 24px));
  padding: 14px 14px 8px 16px; border-radius: 18px; background: #fffdf8; color: var(--ink);
  box-shadow: 0 0 0 1px var(--line), 0 10px 28px -12px #23332947;
}
.notify-card-logo { width: 28px; height: 28px; border-radius: 8px; }
.notify-card-text { font-size: 14.5px; line-height: 1.4; font-weight: 550; text-wrap: pretty; }
.notify-card-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; align-items: center; gap: 16px; }
.notify-card-actions .text-button { padding: 10px 4px; font-size: 14px; color: var(--muted); }
.notify-card-actions .text-button:hover { color: var(--ink); }
.notify-card-actions .button { min-height: 40px; padding: 8px 20px; font-size: 14px; }
@media (prefers-reduced-motion: reduce) {
  .sound-switch::before, .sound-knob { transition: none; }
}
/* ---------- /v20 ---------- */

/* ---------- v21 Shorts (shorts.js): Albums tabs, the Shorts list, Create 10s Highlight, the player ---------- */
/* Small segmented control: a sliding thumb (transform only) under two options. */
.albums-tabs, .shorts-seg { position: relative; display: inline-grid; grid-template-columns: 1fr 1fr; padding: 3px; border-radius: 999px; background: var(--surface); flex-shrink: 0; }
.albums-tabs { margin-left: auto; }
.seg-thumb { position: absolute; top: 3px; bottom: 3px; left: 3px; width: calc(50% - 3px); border-radius: 999px; background: #fff; box-shadow: 0 1px 3px #23332918, 0 0 0 .5px #2333290d; transition: transform .34s var(--spring); }
.albums-tabs[data-tab="shorts"] .seg-thumb, .shorts-seg[data-source="mine"] .seg-thumb { transform: translateX(100%); }
.seg-option { position: relative; min-height: 32px; padding: 4px 14px; border-radius: 999px; font-size: 13px; font-weight: 550; color: var(--muted); }
.seg-option[aria-selected="true"], .seg-option[aria-checked="true"] { color: var(--ink); }
.shorts-seg .seg-option { min-height: 36px; padding: 6px 18px; font-size: 14px; }

/* The Shorts tab */
.shorts-list { max-width: 960px; margin: 0 auto; padding: 18px max(16px, env(safe-area-inset-right)) calc(36px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.shorts-list-head { display: flex; justify-content: flex-start; margin-bottom: 18px; }
.shorts-create-open { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 10px 20px 10px 16px; font-size: 15px; }
.shorts-plus { font-size: 20px; line-height: 1; font-weight: 400; margin-top: -2px; }
.shorts-empty { text-align: center; padding: 64px 12px 40px; }
.shorts-empty-title { font-family: var(--serif); font-weight: 400; font-size: 30px; letter-spacing: -.035em; line-height: 1.15; }
.shorts-empty-text { margin: 0 auto 26px; font-family: var(--serif); font-size: 30px; letter-spacing: -.035em; line-height: 1.15; color: var(--muted); }
.shorts-cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 12px; }
.short-item { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.short-card { display: flex; flex-direction: column; gap: 8px; width: 100%; text-align: left; border-radius: 14px; }
.short-poster { position: relative; display: block; aspect-ratio: 9 / 16; border-radius: 14px; overflow: hidden; background: var(--surface); }
.short-poster img { width: 100%; height: 100%; object-fit: cover; }
.short-badge { position: absolute; right: 8px; bottom: 8px; padding: 2px 8px; border-radius: 8px; font-size: 12px; font-weight: 650; line-height: 1.5; color: #424640; background: #fffffff0; box-shadow: 0 1px 5px #00000014; font-variant-numeric: tabular-nums; }
.short-wait { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 12px; text-align: center; font-size: 13px; color: var(--muted); }
.short-wait.failed { color: #8c5048; }
.short-wait-pct:empty { display: none; }
.short-wait-pct { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--faint); }
.short-meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; padding: 0 2px; }
.short-who { display: flex; align-items: center; gap: 7px; min-width: 0; }
.short-avatar { width: 22px; height: 22px; font-size: 10px; flex-shrink: 0; }
.short-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.short-sub { font-size: 12.5px; color: var(--muted); }
.short-remove { align-self: flex-start; min-height: 36px; padding: 6px 2px; color: var(--muted); }
@media (min-width: 620px) { .shorts-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px 16px; } }
@media (min-width: 940px) { .shorts-cards { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* Create 10s Highlight: full screen, light, one step at a time */
.shorts-create, .short-player {
  position: fixed; inset: 0; width: 100%; height: 100%; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0;
  border: 0; border-radius: 0; box-shadow: none; overflow: hidden;
}
.shorts-create { background: var(--bg); color: var(--ink); }
.shorts-create[open] { display: flex; flex-direction: column; }
.shorts-create::backdrop { background: var(--bg); }
.shorts-head h2 { margin: 0; }
#shorts-back .close-mark, #shorts-back.closes .back-mark { display: none; }
#shorts-back.closes .close-mark { display: block; }
.shorts-flow { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; border-top: 1px solid var(--line); }
.shorts-panel { max-width: 960px; margin: 0 auto; padding: 16px max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left)); }
.shorts-fill:not([hidden]) { height: 100%; display: flex; flex-direction: column; align-items: center; gap: 14px; padding-bottom: 16px; }
/* Ready and Creating have no footer: their own controls keep clear of the home indicator. */
.shorts-create[data-step="ready"] .shorts-panel, .shorts-create[data-step="creating"] .shorts-panel { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }

.shorts-choose-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.shorts-picks.button { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 18px 6px 10px; background: var(--mine); color: var(--accent-deep); box-shadow: inset 0 0 0 1px var(--mine-line); font-size: 15px; font-weight: 600; }
.shorts-picks.button:hover:not(:disabled) { background: #d8e5da; }
.shorts-picks img { width: 30px; height: 30px; object-fit: contain; }
.shorts-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
.shorts-tile { position: relative; display: block; width: 100%; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--surface); transition: transform .3s var(--spring); }
.shorts-tile:active { transform: scale(.97); transition-duration: .08s; }
.shorts-tile img { width: 100%; height: 100%; object-fit: cover; }
.shorts-tile::after { content: ''; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 2.5px var(--accent); opacity: 0; transition: opacity .18s ease-out; pointer-events: none; }
.shorts-tile.picked::after { opacity: 1; }
.shorts-mark { position: absolute; top: 6px; right: 6px; width: 20px; height: 20px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px #ffffffe6, 0 1px 3px #0000002e; transition: opacity .15s; }
.shorts-tile.picked .shorts-mark { opacity: 0; }
.shorts-badge { position: absolute; top: 5px; right: 5px; display: inline-flex; align-items: center; gap: 2px; height: 22px; padding: 0 7px 0 5px; border-radius: 11px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 650; font-variant-numeric: tabular-nums; box-shadow: 0 1px 4px #0000002e; opacity: 0; transform: scale(.6); transition: opacity .15s, transform .26s var(--spring); }
.shorts-badge svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.shorts-tile.picked .shorts-badge { opacity: 1; transform: none; }
@media (min-width: 620px) { .shorts-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; } }
@media (min-width: 800px) { .shorts-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
@media (min-width: 1000px) { .shorts-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); } }

/* v27 Choose moments: the Top 10 first, a row of larger tiles with their rank (and the small crowns) */
.shorts-top { margin: -2px 0 16px; }
.shorts-top-title { margin: 0 0 8px; font-family: var(--serif); font-weight: 400; font-size: 19px; letter-spacing: -.03em; }
.shorts-top-row {
  list-style: none; display: flex; gap: 8px; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity; scrollbar-width: none;
  margin: 0 calc(-1 * max(16px, env(safe-area-inset-right))) 0 calc(-1 * max(16px, env(safe-area-inset-left)));
  padding: 2px max(16px, env(safe-area-inset-right)) 4px max(16px, env(safe-area-inset-left)); scroll-padding-inline: max(16px, env(safe-area-inset-left));
}
.shorts-top-row::-webkit-scrollbar { display: none; }
.shorts-top-row li { flex: none; width: 104px; scroll-snap-align: start; }
.shorts-top-tile.shorts-tile { aspect-ratio: 4 / 5; border-radius: 12px; }
.shorts-rank { position: absolute; left: 6px; bottom: 6px; display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 11px; background: #fffffff0; color: var(--ink); font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; box-shadow: 0 1px 4px #0000002e; }
.shorts-rank.crowned { padding-left: 6px; }
.shorts-rank .crown-1 { --crown-w: 15px; }
.shorts-rank .crown-2 { --crown-w: 12px; }
@media (min-width: 620px) { .shorts-top-row li { width: 128px; } }

.shorts-foot {
  flex-shrink: 0; display: flex; align-items: center; gap: 12px; width: 100%; max-width: 960px; margin: 0 auto;
  padding: 10px max(16px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  border-top: 1px solid var(--line); background: var(--bg);
}
.shorts-count { flex: 1; min-width: 0; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.shorts-foot .button { min-width: 128px; }
.shorts-foot #shorts-foot-back { min-width: 0; }

/* v27 Edit: a dark, quiet editor in Moth's charcoal with one warm accent. The preview takes the room
   left over; the timeline, the open tool and the tab bar keep their heights, so nothing jumps. */
.shorts-create[data-step="edit"] {
  --ed-bg: #131614; --ed-panel: #1a1e1b; --ed-raised: #242925; --ed-raised-2: #2e3430; --ed-line: #ffffff17;
  --ed-ink: #f2eee5; --ed-muted: #f2eee5a8; --ed-faint: #f2eee56b; --ed-warm: #e8bf72; --ed-warm-ink: #2b2213; --ed-warm-soft: #e8bf7224;
  background: var(--ed-bg); color: var(--ed-ink); color-scheme: dark;
}
.shorts-create[data-step="edit"]::backdrop { background: #131614; }
.shorts-create[data-step="edit"] .shorts-head { max-width: 1180px; }
.shorts-create[data-step="edit"] .albums-head svg { stroke: var(--ed-ink); }
.shorts-create[data-step="edit"] .icon-button:hover:not(:disabled) { background: #ffffff14; }
.shorts-create[data-step="edit"] .shorts-flow { border-top-color: var(--ed-line); }
.shorts-create[data-step="edit"] :focus-visible { outline-color: var(--ed-warm); }
.edit-create.button { margin-left: auto; min-height: 44px; padding: 9px 24px; background: var(--ed-warm); color: var(--ed-warm-ink); font-size: 15px; font-weight: 650; }
.edit-create.button:hover:not(:disabled) { background: #f0cb85; }
.shorts-edit:not([hidden]) { max-width: 1180px; height: 100%; min-height: 520px; padding: 0; display: flex; flex-direction: column; }

/* The live preview */
.edit-stage.shorts-stage { flex: 1 1 auto; min-height: 190px; padding: 12px max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left)); }
.edit-frame.shorts-frame { background: #0b0d0c; border-radius: 16px; box-shadow: 0 0 0 1px var(--ed-line), 0 18px 40px #0000004d; }
.edit-frame .shorts-video { background: #0b0d0c; }
.edit-still { position: absolute; inset: -12%; width: 124%; max-width: none; height: 124%; object-fit: cover; filter: blur(18px) brightness(.45) saturate(.9); }
.shorts-edit .shorts-frame-wait { color: var(--ed-muted); }
.shorts-edit .shorts-pct { color: var(--ed-muted); }
.shorts-edit .shorts-fail-title { color: var(--ed-ink); }
.shorts-edit .shorts-note { color: var(--ed-muted); }
.shorts-edit .button.primary { background: var(--ed-warm); color: var(--ed-warm-ink); }
.shorts-edit .video-load { background: #0b0d0c; }

/* The timeline: the photos in order, the last one the ending; 10 seconds, always */
.edit-timeline { flex: none; padding-top: 2px; }
.timeline-bar { display: flex; align-items: center; gap: 10px; min-height: 30px; padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); }
.edit-length { flex: none; display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px 3px 7px; border-radius: 999px; background: var(--ed-raised); color: var(--ed-ink); font-size: 12px; font-weight: 650; font-variant-numeric: tabular-nums; }
.edit-length svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; opacity: .7; }
.timeline-hint { flex: 1; min-width: 0; margin: 0; font-size: 12.5px; color: var(--ed-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timeline-reset.text-button { flex: none; margin: -7px 0; padding: 10px 0 10px 8px; font-size: 13px; font-weight: 650; color: var(--ed-warm); }
.timeline {
  position: relative; list-style: none; margin: 0; display: flex; gap: 6px; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scrollbar-width: none;
  padding: 8px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left)); scroll-padding-inline: max(16px, env(safe-area-inset-left)); touch-action: pan-x;
}
.timeline::-webkit-scrollbar { display: none; }
.timeline-item { position: relative; z-index: 0; flex: none; }
.timeline-item.lifted, .timeline-item.settling { z-index: 2; }
.timeline.dragging .timeline-item:not(.lifted):not(.settling) { transition: transform .3s var(--settle); }
.timeline-tile {
  position: relative; display: block; width: 58px; height: 78px; border-radius: 10px; overflow: hidden; background: var(--ed-raised);
  -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
  transition: transform .22s var(--settle), box-shadow .22s var(--settle);
}
.timeline-tile:focus-visible { outline: 2px solid var(--ed-ink); outline-offset: 2px; }
.timeline-tile img, .timeline-tile .look-canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.timeline-tile::after { content: ''; position: absolute; inset: 0; z-index: 2; border-radius: inherit; box-shadow: inset 0 0 0 2px var(--ed-warm); opacity: 0; transition: opacity .18s ease-out; pointer-events: none; }
.timeline-item.selected .timeline-tile::after { opacity: 1; }
.timeline-item.lifted .timeline-tile { transform: scale(1.08); box-shadow: 0 12px 24px #00000080, 0 3px 8px #00000059; }
.timeline-num { position: absolute; top: 4px; left: 4px; z-index: 1; display: grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #000000a6; color: #fff; font-size: 11px; font-weight: 650; font-variant-numeric: tabular-nums; }
.timeline-dot { position: absolute; top: 6px; right: 6px; z-index: 1; width: 7px; height: 7px; border-radius: 50%; background: var(--ed-warm); box-shadow: 0 0 0 1.5px #0000008c; opacity: 0; transition: opacity .15s; }
.timeline-item.looked .timeline-dot { opacity: 1; }
.timeline-end { position: absolute; left: 0; right: 0; bottom: 0; z-index: 1; padding: 12px 0 4px; background: linear-gradient(#0000, #000000c2); color: var(--ed-warm); font-size: 9.5px; font-weight: 700; letter-spacing: .06em; line-height: 1.2; text-transform: uppercase; text-align: center; opacity: 0; transition: opacity .18s; }
.timeline-item.ending .timeline-end { opacity: 1; }

/* The open tool */
.edit-tools { flex: none; height: 150px; padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); border-top: 1px solid var(--ed-line); overflow: hidden; }
.edit-tool { padding-top: 12px; }
/* Presets: Cinematic and Pulse side by side, each with its tiny moving reel */
.shorts-presets { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.preset-card {
  position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: 1fr auto auto 1fr; column-gap: 11px;
  min-height: 104px; padding: 12px 12px 12px 11px; text-align: left; border-radius: 16px; background: var(--ed-raised); color: var(--ed-ink);
}
.preset-card::after { content: ''; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 2px var(--ed-warm); opacity: 0; transition: opacity .18s ease-out; pointer-events: none; }
.preset-card[aria-checked="true"] { background: #2a2a22; }
.preset-card[aria-checked="true"]::after { opacity: 1; }
.preset-name { grid-area: 2 / 2; font-family: var(--serif); font-size: 19px; line-height: 1.1; letter-spacing: -.03em; }
.preset-words { grid-area: 3 / 2; margin-top: 4px; font-size: 12px; line-height: 1.3; color: var(--ed-muted); }
.preset-reel { grid-area: 1 / 1 / 5 / 2; position: relative; align-self: center; width: 38px; aspect-ratio: 9 / 16; border-radius: 7px; overflow: hidden; background: var(--ed-raised-2); box-shadow: 0 2px 8px #00000052; }
.preset-reel img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; }
.preset-reel img:first-child { opacity: 1; }
@media (prefers-reduced-motion: no-preference) {
  .preset-reel img, .preset-reel img:first-child { opacity: 0; animation-fill-mode: backwards; animation-iteration-count: infinite; }
  /* Cinematic: one photo at a time, a slow push-in and a soft cross-fade. */
  [data-preset="cinematic"] .preset-reel img { animation-name: reel-cine; animation-duration: 6s; animation-timing-function: linear; }
  [data-preset="cinematic"] .preset-reel img:nth-child(2) { animation-delay: 2s; }
  [data-preset="cinematic"] .preset-reel img:nth-child(3) { animation-delay: 4s; }
  /* Pulse: quick cuts with a small punch. */
  [data-preset="pulse"] .preset-reel img { animation-name: reel-pulse; animation-duration: 1.5s; animation-timing-function: ease-out; }
  [data-preset="pulse"] .preset-reel img:nth-child(2) { animation-delay: .5s; }
  [data-preset="pulse"] .preset-reel img:nth-child(3) { animation-delay: 1s; }
  @keyframes reel-cine { 0% { opacity: 0; transform: scale(1); } 7% { opacity: 1; } 33% { opacity: 1; } 40%, 100% { opacity: 0; transform: scale(1.1); } }
  @keyframes reel-pulse { 0% { opacity: 1; transform: scale(1.12); } 9% { transform: scale(1); } 33.2% { opacity: 1; } 33.4%, 100% { opacity: 0; transform: scale(1); } }
}
.preset-check { position: absolute; top: 8px; right: 8px; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--ed-warm); color: var(--ed-warm-ink); opacity: 0; transform: scale(.6); transition: opacity .15s, transform .28s var(--spring); }
.preset-check svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.preset-card[aria-checked="true"] .preset-check { opacity: 1; transform: none; }
/* Filters: the selected photo through each look; Apply to all */
.filters-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 26px; }
.filters-for { min-width: 0; margin: 0; font-size: 13px; font-weight: 600; color: var(--ed-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.filters-all.text-button { flex: none; margin: -9px 0; padding: 10px 0 10px 10px; font-size: 13px; font-weight: 650; color: var(--ed-warm); }
.filters-all.text-button:disabled { color: var(--ed-faint); opacity: 1; }
.filters, .shorts-tracks {
  display: flex; gap: 10px; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity; scrollbar-width: none;
  margin: 0 calc(-1 * max(16px, env(safe-area-inset-right))) 0 calc(-1 * max(16px, env(safe-area-inset-left)));
  padding: 3px max(16px, env(safe-area-inset-right)) 5px max(16px, env(safe-area-inset-left)); scroll-padding-inline: max(16px, env(safe-area-inset-left));
}
.filters::-webkit-scrollbar, .shorts-tracks::-webkit-scrollbar { display: none; }
.filters { margin-top: 6px; }
.filter-swatch { flex: none; display: flex; flex-direction: column; align-items: center; gap: 5px; width: 60px; color: var(--ed-muted); font-size: 11.5px; font-weight: 600; scroll-snap-align: start; }
.filter-frame { position: relative; width: 60px; height: 60px; border-radius: 12px; overflow: hidden; background: var(--ed-raised); }
.filter-frame img, .filter-frame canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.filter-frame::after { content: ''; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 2px var(--ed-warm); opacity: 0; transition: opacity .15s; }
.filter-swatch[aria-checked="true"] { color: var(--ed-warm); }
.filter-swatch[aria-checked="true"] .filter-frame::after { opacity: 1; }
.filter-name { line-height: 1.2; }
/* Sound: the bar (the chosen track across the 10 seconds), the tracks under it */
.sound-bar { position: relative; display: flex; flex-direction: column; gap: 3px; height: 56px; padding: 6px 12px 7px; border-radius: 14px; background: var(--ed-panel); box-shadow: inset 0 0 0 1px var(--ed-line); transition: box-shadow .15s, background-color .15s; }
.sound-bar-head { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; font-weight: 650; line-height: 1.3; }
.sound-bar-length { color: var(--ed-faint); font-variant-numeric: tabular-nums; }
.sound-wave { position: relative; flex: 1; min-height: 0; transition: opacity .2s; }
.sound-wave svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.sound-wave-base path { fill: #f2eee559; }
.sound-wave-played { clip-path: inset(0 100% 0 0); }
.sound-wave-played path { fill: var(--ed-warm); }
.sound-bar.off .sound-wave-base path { fill: #f2eee52e; }
.sound-bar.loading .sound-wave { opacity: .45; }
.sound-bar-drop { position: absolute; inset: 0; display: grid; place-items: center; border-radius: inherit; background: #131614e0; color: var(--ed-warm); font-size: 13px; font-weight: 650; opacity: 0; pointer-events: none; transition: opacity .15s; }
.sound-bar.drop-ready { outline: 1.5px dashed var(--ed-warm); outline-offset: -1.5px; }
.sound-bar.drop-ready .sound-bar-drop { opacity: 1; }
.sound-bar.drop-over { outline-style: solid; background: #2a2a22; }
.sound-bar.drop-over .sound-bar-drop { background: #2b2a21f0; }
.edit-tool .shorts-tracks { margin-top: 8px; }
.track-chip {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 16px 8px 13px; border-radius: 999px;
  background: var(--ed-raised); color: var(--ed-muted); font-size: 14px; font-weight: 550; box-shadow: inset 0 0 0 1px var(--ed-line); scroll-snap-align: start;
  touch-action: pan-x; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
  transition: transform .32s var(--spring), background-color .15s, color .15s, box-shadow .15s, opacity .15s;
}
.track-chip.track-off { padding-left: 16px; }
.track-chip[aria-checked="true"] { background: #2d2a20; color: var(--ed-ink); box-shadow: inset 0 0 0 1.5px var(--ed-warm); }
.track-chip.lifting { opacity: .35; }
.track-eq { display: inline-flex; align-items: flex-end; gap: 2px; width: 12px; height: 12px; }
.track-eq i { flex: 1; height: 100%; border-radius: 1px; background: currentColor; opacity: .45; transform: scaleY(.5); transform-origin: bottom; transition: opacity .15s; }
.track-eq i:nth-child(2) { transform: scaleY(.85); }
.track-eq i:nth-child(3) { transform: scaleY(.65); }
.track-chip[aria-checked="true"] .track-eq i { background: var(--ed-warm); opacity: 1; }
.track-chip.playing .track-eq i { animation: track-eq .8s ease-in-out infinite; }
.track-chip.playing .track-eq i:nth-child(2) { animation-delay: -.3s; }
.track-chip.playing .track-eq i:nth-child(3) { animation-delay: -.55s; }
@keyframes track-eq { 0%, 100% { transform: scaleY(.3); } 50% { transform: scaleY(1); } }
/* The chip being dragged, above everything in the dialog */
.chip-ghost { position: fixed; z-index: 40; margin: 0; pointer-events: none; background: var(--ed-raised-2); color: var(--ed-ink); box-shadow: inset 0 0 0 1.5px var(--ed-warm), 0 14px 30px #000000a6; will-change: transform; transition: none; }
.shorts-music-note { margin: 4px 0 0; min-height: 1.4em; font-size: 12.5px; line-height: 1.4; color: var(--ed-muted); }
/* Moth Motion: the switch, what's left of the outside motion, and what it does */
.motion-row { display: flex; align-items: center; gap: 10px; }
.motion-chip { padding: 6px 12px 6px 9px; }
.motion-chip img { width: 26px; height: 26px; margin: -4px -1px; opacity: .55; filter: grayscale(.7); transition: opacity .15s, filter .15s; }
.motion-chip[aria-checked="true"] img { opacity: 1; filter: none; }
.motion-check { display: grid; place-items: center; width: 18px; height: 18px; margin-left: 2px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--ed-faint); transition: background-color .15s, box-shadow .15s; }
.motion-check svg { width: 11px; height: 11px; fill: none; stroke: var(--ed-warm-ink); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; opacity: 0; transition: opacity .15s; }
.motion-chip[aria-checked="true"] .motion-check { background: var(--ed-warm); box-shadow: none; }
.motion-chip[aria-checked="true"] .motion-check svg { opacity: 1; }
.motion-left { padding: 3px 10px; border-radius: 999px; background: var(--ed-warm-soft); color: var(--ed-warm); font-size: 12px; font-weight: 650; font-variant-numeric: tabular-nums; }
.motion-left.used { background: var(--ed-raised); color: var(--ed-muted); }
#edit-panel-motion .shorts-music-note { max-width: 34em; margin-top: 10px; }

/* The tab bar */
.edit-tabs {
  flex: none; display: flex; justify-content: space-around; gap: 4px; border-top: 1px solid var(--ed-line); background: var(--ed-panel);
  padding: 4px max(8px, env(safe-area-inset-right)) calc(4px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
}
.edit-tab { flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 52px; padding: 4px 2px; border-radius: 12px; color: var(--ed-faint); font-size: 11.5px; font-weight: 600; transition: color .15s, background-color .15s; }
.edit-tab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.edit-tab img { width: 26px; height: 26px; margin: -2px 0; object-fit: contain; opacity: .5; filter: grayscale(.8); transition: opacity .15s, filter .15s; }
.edit-tab:hover:not([aria-selected="true"]) { color: var(--ed-muted); }
.edit-tab[aria-selected="true"] { color: var(--ed-warm); }
.edit-tab[aria-selected="true"] img { opacity: 1; filter: none; }
.edit-tab:focus-visible { outline-offset: -2px; }

/* Short phones: a little less of everything around the preview */
@media (max-height: 700px) {
  .timeline-tile { width: 50px; height: 66px; }
  .edit-tools { height: 140px; }
  .edit-tool { padding-top: 10px; }
  .sound-bar { height: 48px; padding-top: 5px; padding-bottom: 6px; }
  .edit-tool .shorts-tracks { margin-top: 5px; }
  .preset-card { min-height: 96px; }
  .edit-tab { min-height: 48px; }
}
/* A wide screen: the preview on the left, the timeline and the tools beside it */
@media (min-width: 900px) and (min-height: 620px) {
  .shorts-edit:not([hidden]) { display: grid; grid-template-columns: minmax(0, 1fr) 440px; grid-template-rows: auto auto minmax(0, 1fr); padding: 0 max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left)); }
  .edit-stage.shorts-stage { grid-area: 1 / 1 / 4 / 2; padding: 20px 20px 24px; }
  .edit-timeline { grid-area: 1 / 2; padding-top: 16px; }
  .edit-tabs { grid-area: 2 / 2; justify-content: flex-start; gap: 6px; padding: 6px 16px 10px; border-top: 0; background: none; }
  .edit-tab { flex: none; max-width: none; flex-direction: row; gap: 7px; min-height: 44px; padding: 6px 14px 6px 11px; border-radius: 999px; font-size: 13px; }
  .edit-tab svg { width: 19px; height: 19px; }
  .edit-tab img { width: 22px; height: 22px; margin: -2px -2px; }
  .edit-tab[aria-selected="true"] { background: var(--ed-warm-soft); }
  .edit-tools { grid-area: 3 / 2; height: auto; border-top: 1px solid var(--ed-line); }
  .edit-tool { padding-top: 16px; }
  .timeline-tile { width: 62px; height: 84px; }
}

/* Preview and Ready: a 9:16 frame that fits the room left on screen */
.shorts-stage { flex: 1 1 auto; min-height: 180px; width: 100%; display: flex; justify-content: center; container-type: size; }
.shorts-frame { position: relative; height: 100%; aspect-ratio: 9 / 16; width: min(100cqw, 100cqh * 9 / 16); height: min(100cqh, 100cqw * 16 / 9); border-radius: 18px; overflow: hidden; background: var(--surface); }
.shorts-video { display: block; width: 100%; height: 100%; object-fit: cover; background: var(--surface); }
.shorts-frame-wait { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 16px; text-align: center; font-size: 14px; color: var(--muted); }
.shorts-fail-title { font-family: var(--serif); font-size: 19px; letter-spacing: -.02em; color: var(--ink); }
.shorts-frame-wait .button { margin-top: 8px; }
.shorts-pct { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; min-height: 1.5em; }
.shorts-pct:empty { visibility: hidden; }
.shorts-ready-title { font-family: var(--serif); font-size: 22px; letter-spacing: -.03em; text-align: center; }
/* v26: how Moth Motion turned out, small, under the title */
.made-by-moth { display: inline-flex; align-items: center; gap: 5px; margin: -6px 0 0; padding: 3px 11px 3px 5px; border-radius: 999px; background: var(--surface-soft); box-shadow: inset 0 0 0 1px var(--line); font-size: 12.5px; font-weight: 600; color: #4c534f; }
.made-by-moth img { width: 22px; height: 22px; }
.shorts-kept { margin-top: -6px; font-size: 13px; line-height: 1.4; text-align: center; }
.shorts-again.button { width: 100%; max-width: 420px; min-height: 44px; padding: 9px 20px; }

/* Creating: the neutral Moth gently circling a tiny film frame */
.shorts-creating:not([hidden]) { min-height: 100%; display: grid; place-items: center; }
.shorts-creating-busy { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 24px 8px; }
.shorts-creating-title { font-family: var(--serif); font-size: 24px; letter-spacing: -.03em; margin-top: 10px; }
/* v26: with Moth Motion, the line takes turns with "Bringing a few frames to life…" (shorts.js sets .alt) */
#shorts-creating-title { display: grid; justify-items: center; }
.creating-line { grid-area: 1 / 1; transition: opacity .6s ease; }
.creating-line + .creating-line, #shorts-creating-title.alt .creating-line:first-child { opacity: 0; }
#shorts-creating-title.alt .creating-line + .creating-line { opacity: 1; }
.shorts-note { font-size: 14px; color: var(--muted); max-width: 300px; }
.shorts-note:empty { display: none; }
.shorts-note.faint { color: var(--faint); font-size: 13px; margin-top: 18px; }
.shorts-creating-busy .button { margin-top: 16px; }
/* Small photo frames drift toward the Moth, it nudges them, they settle into one tiny vertical
   frame, then it starts again. Sized in em so one drawing serves every size. */
.shorts-orbit { position: relative; display: block; width: 10em; height: 10em; font-size: 15px; flex-shrink: 0; }
.shorts-orbit.small { font-size: 7.6px; }
.gather-moth { position: absolute; left: 3.3em; top: 1em; width: 3.4em; height: 3.4em; object-fit: contain; }
.gather-frame { position: absolute; left: 4.25em; top: 6.3em; width: 1.5em; height: 1.15em; border-radius: .2em; border: .1em solid #fff; box-shadow: 0 .08em .3em #2333292e; opacity: 0; }
.gather-frame.f1 { background: #cfe0d3; --x: -3.7em; --y: -2.6em; --r: -14deg; }
.gather-frame.f2 { background: #ead9bd; --x: 3.6em; --y: -2.2em; --r: 12deg; }
.gather-frame.f3 { background: #d9d5ea; --x: -3em; --y: 1.6em; --r: 9deg; }
.gather-reel { position: absolute; left: 4.35em; top: 5.75em; width: 1.3em; height: 2.3em; border-radius: .25em; border: .1em solid #fff; box-shadow: 0 .1em .4em #2333292e; background: linear-gradient(#cfe0d3 0 33%, #ead9bd 33% 66%, #d9d5ea 66%); }
@media (prefers-reduced-motion: no-preference) {
  .gather-frame { animation: gather-frame 5.2s cubic-bezier(.45, .05, .35, 1) infinite backwards; }
  .gather-frame.f2 { animation-delay: .12s; }
  .gather-frame.f3 { animation-delay: .24s; }
  .gather-moth { animation: gather-moth 5.2s ease-in-out infinite; }
  .gather-reel { opacity: 0; animation: gather-reel 5.2s ease-out infinite; }
  @keyframes gather-frame {
    0% { opacity: 0; transform: translate(var(--x), var(--y)) rotate(var(--r)) scale(.9); }
    12% { opacity: 1; }
    38% { opacity: 1; transform: translate(calc(var(--x) * .4), calc(var(--y) * .4 - .7em)) rotate(calc(var(--r) * .4)); }
    47% { transform: translate(calc(var(--x) * .3), calc(var(--y) * .3 - .4em)) rotate(calc(var(--r) * -.3)); }
    64% { opacity: .9; transform: translate(0, 0) rotate(0deg) scale(.62); }
    70%, 100% { opacity: 0; transform: translate(0, 0) scale(.55); }
  }
  @keyframes gather-moth { 0%, 34% { transform: none; } 40% { transform: translateY(.35em) rotate(-7deg) scale(.96); } 46% { transform: translateY(.1em) rotate(5deg); } 54%, 100% { transform: none; } }
  @keyframes gather-reel { 0%, 58% { opacity: 0; transform: scale(.7); } 68% { opacity: 1; transform: scale(1.06); } 74%, 88% { opacity: 1; transform: none; } 98%, 100% { opacity: 0; transform: scale(.96); } }
}

/* Share / Share to TikTok / Save: three tiles, icon over label */
.shorts-share-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; width: 100%; max-width: 420px; }
.share-tile { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; min-height: 64px; padding: 9px 4px; border-radius: 16px; background: var(--surface); color: var(--ink); text-decoration: none; font-size: 12.5px; font-weight: 600; text-align: center; }
.share-tile svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.share-label { line-height: 1.2; }
/* The raised one: a ledge and shadow (two layers swapped by opacity), pressed 2px down, springs back. */
.share-tile.raised { background: var(--accent); color: #fff; transition: transform .38s var(--spring); }
.share-tile.raised::before, .share-tile.raised::after { content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; transition: opacity .38s var(--spring); }
.share-tile.raised::before { box-shadow: 0 3px 0 var(--accent-deep), 0 8px 18px #2333292e; }
.share-tile.raised::after { box-shadow: 0 1px 0 var(--accent-deep), 0 2px 6px #2333292a; opacity: 0; }
.share-tile.raised:active { transform: translateY(2px) scale(.98); transition-duration: .08s; }
.share-tile.raised:active::before { opacity: 0; transition-duration: .08s; }
.share-tile.raised:active::after { opacity: 1; transition-duration: .08s; }
.shorts-ready .shorts-share-row { margin-top: 2px; }
/* Sound (owner, 2026-10-06): a speaker on every Shorts video, bottom-right; slashed while muted. */
.short-sound { position: absolute; right: 10px; bottom: 10px; z-index: 2; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: #00000057; color: #fff; -webkit-tap-highlight-color: transparent; transition: transform .3s var(--spring), background-color .15s; }
.short-sound:active { transform: scale(.92); transition-duration: .08s; }
.short-sound svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.short-sound .sound-body { fill: currentColor; }
.short-sound .sound-slash, .short-sound.muted .sound-waves { display: none; }
.short-sound.muted .sound-slash { display: inline; }
.short-sound:focus-visible { outline-color: #fff; }
.shorts-video[hidden] ~ .short-sound { display: none; }
/* Loading a Short's video (shorts.js): the poster, or the first chosen photo, under the shared shimmer,
   with the small Moth and one line; it fades away as the first frame paints. Nothing plays before. */
.video-load {
  position: absolute; inset: 0; z-index: 1; display: grid; place-items: center; overflow: hidden; border-radius: inherit;
  background: var(--surface); transition: opacity .2s ease-out;
}
.video-load.leaving { opacity: 0; pointer-events: none; }
.video-load-poster { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.video-load-veil { position: absolute; inset: 0; opacity: .6; }
.video-load-note {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; max-width: calc(100% - 28px);
  padding: 6px 18px 12px 10px; border-radius: 18px; background: #fafaf7eb; color: var(--ink); text-align: center;
  box-shadow: 0 4px 18px #2333291f;
}
.video-load-note .moth-wait { min-height: 48px; color: var(--ink); }
.video-load-note .placing-label { font-size: 14px; text-wrap: balance; }
.video-load-pct { margin-top: -6px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.video-load-pct:empty { display: none; }
.video-load-retry.button { min-height: 44px; margin-top: 8px; padding: 8px 22px; font-size: 14px; }
/* Ran dry while playing: the last frame stays, a lighter veil and the same note over it. */
.video-load.stalled { background: none; }
.video-load.stalled .video-load-veil { opacity: .35; }
.shorts-video, .short-player-video { transition: opacity .2s ease-out; }
.shorts-video.video-wait, .short-player-video.video-wait { opacity: .001; }
.short-player-stage .video-load {
  inset: auto; left: 50%; top: 50%; translate: -50% -50%; border-radius: 16px; background: #1a1d1b;
  width: min(100cqw, 100cqh * 9 / 16); height: min(100cqh, 100cqw * 16 / 9);
}
@media (prefers-reduced-motion: reduce) { .video-load, .shorts-video, .short-player-video { transition: none; } }
/* The player's stage is wider than its 9:16 video: sit inside the video's own corner. */
.short-player-stage .short-sound { right: calc((100cqw - min(100cqw, 100cqh * 9 / 16)) / 2 + 10px); bottom: calc((100cqh - min(100cqh, 100cqw * 16 / 9)) / 2 + 10px); }
.share-note { width: 100%; max-width: 420px; margin: 0; min-height: 1.4em; font-size: 13px; line-height: 1.4; text-align: center; color: var(--muted); }
.share-note:empty { min-height: 0; }
.short-player .share-note { color: #ffffffb8; }

/* The player: dark, the video as large as fits, quiet chrome */
.short-player { background: var(--night); color: #fff; }
.short-player::backdrop { background: var(--night); }
.short-player-stage { position: absolute; left: env(safe-area-inset-left); right: env(safe-area-inset-right); top: calc(60px + env(safe-area-inset-top)); bottom: calc(150px + env(safe-area-inset-bottom)); display: flex; align-items: center; justify-content: center; container-type: size; }
.short-player-video { width: min(100cqw, 100cqh * 9 / 16); height: min(100cqh, 100cqw * 16 / 9); border-radius: 16px; object-fit: cover; background: #1a1d1b; }
.short-player-tap { position: absolute; inset: 0; width: 100%; height: 100%; display: grid; place-items: center; border-radius: 0; }
.short-player-tap:focus-visible { outline-offset: -4px; outline-color: #fff; }
.short-paused { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: #0000004d; opacity: 0; transform: scale(.8); transition: opacity .18s, transform .28s var(--spring); }
.short-paused svg { width: 28px; height: 28px; fill: #fff; margin-left: 3px; }
.short-player.paused .short-paused { opacity: 1; transform: none; }
.short-player-track { position: absolute; left: 50%; bottom: -12px; width: min(100cqw, 100cqh * 9 / 16); height: 2px; translate: -50% 0; border-radius: 2px; background: #ffffff26; overflow: hidden; }
#short-player-bar { display: block; width: 100%; height: 100%; background: #ffffffc4; transform-origin: left center; transform: scaleX(0); }
.short-player-top { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 6px; max-width: 760px; margin: 0 auto; height: calc(60px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) max(12px, env(safe-area-inset-right)) 0 max(6px, env(safe-area-inset-left)); }
.short-player-top svg { width: 24px; height: 24px; fill: none; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.short-player-top .icon-button:hover:not(:disabled) { background: #ffffff1f; }
.short-player-info { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.short-player-who { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 15px; font-weight: 600; }
.short-player-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.short-player-avatar { width: 26px; height: 26px; font-size: 11px; background: #ffffff29; color: #fff; flex-shrink: 0; }
.short-player-sub { font-size: 12px; color: #ffffffa3; }
.short-player-actions { position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px max(16px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.short-player .share-tile:not(.raised) { background: #ffffff1a; color: #fff; }
.short-player .share-tile.raised { background: #fafaf7; color: var(--ink); }
.short-player .share-tile.raised::before { box-shadow: 0 3px 0 #b9beb6, 0 8px 18px #00000059; }
.short-player .share-tile.raised::after { box-shadow: 0 1px 0 #b9beb6, 0 2px 6px #00000052; }
.short-player-tail { display: flex; justify-content: center; min-height: 40px; }
.short-player .text-button { color: #ffffffb8; min-height: 40px; padding: 8px 10px; font-size: 14px; }
.short-player .short-delete { color: #ffb4a8; }
.short-confirm { display: flex; align-items: center; gap: 4px; }
.short-confirm-text { font-size: 14px; color: #ffffffd9; margin-right: 6px; }
.short-player .share-tile:focus-visible, .short-player .text-button:focus-visible, .short-player-top .icon-button:focus-visible { outline-color: #fff; }

@media (prefers-reduced-motion: reduce) {
  .seg-thumb, .shorts-tile, .shorts-badge, .preset-check, .share-tile.raised, .share-tile.raised::before, .share-tile.raised::after, .short-paused { transition: none; }
  .timeline.dragging .timeline-item:not(.lifted):not(.settling), .timeline-tile, .timeline-tile::after, .timeline-end, .timeline-dot, .track-chip, .short-sound { transition: none; }
  .filter-frame::after, .preset-card::after, .sound-bar, .sound-wave, .sound-bar-drop, .edit-tab, .edit-tab img { transition: none; }
  .motion-chip img, .motion-check, .motion-check svg, .creating-line { transition: none; }
  .track-chip.playing .track-eq i { animation: none; transform: scaleY(1); }
  .shorts-tile:active, .share-tile.raised:active { transform: none; }
}
/* ---------- /v21 Shorts ---------- */

/* ---------- Smooth loading (js/skeleton.js): placeholders in the final shape, one soft shimmer ---------- */
:root { --sk-base: #efeee8; --sk-glow: #f8f6f0; }
.sk {
  background-color: var(--sk-base); background-image: linear-gradient(100deg, #f8f6f000 30%, var(--sk-glow) 50%, #f8f6f000 70%);
  background-size: 250% 100%; background-position: 100% 0; background-repeat: no-repeat;
}
.viewer .sk, .short-player .sk { --sk-base: #ffffff0f; --sk-glow: #ffffff1a; background-image: linear-gradient(100deg, #ffffff00 30%, var(--sk-glow) 50%, #ffffff00 70%); }
@media (prefers-reduced-motion: no-preference) {
  .sk { animation: sk-shimmer 2.4s ease-in-out infinite; }
  @keyframes sk-shimmer { 0% { background-position: 100% 0; } 75%, 100% { background-position: 0 0; } }
}
.sk-line { display: block; height: 10px; border-radius: 5px; }
.sk-lines { display: flex; flex-direction: column; gap: 7px; }
.sk-name { width: 92px; height: 12px; }
.sk-meta { width: 136px; height: 9px; }
.sk-item { pointer-events: none; }
.sk-item .photo-frame { display: block; }
.sk-foot { display: flex; gap: 6px; margin-top: 12px; }
.sk-pill { display: block; width: 58px; height: 32px; border-radius: 16px; }
.sk-pill-short { width: 32px; }
.sk-row .hl-row { pointer-events: none; }
.sk-rank { width: 20px; height: 14px; border-radius: 7px; justify-self: center; }
.sk-thumb { width: 44px; height: 44px; border-radius: 10px; }
.danger-item.sk-row .danger-body { gap: 9px; padding-top: 4px; }
.sk-bar { width: 100%; height: 5px; border-radius: 3px; }
.sk-tile > span { display: block; width: 100%; }
.sk-entry { pointer-events: none; }
.sk-entry .stack-photo { display: block; }
.sk-entry .sk-name { width: 110px; height: 14px; }
.profile-stat { min-height: 70px; }
.sk-stat .sk-number { width: 34px; height: 20px; margin: 4px auto 5px; }
.sk-stat .sk-meta { width: 52px; height: 10px; margin: 3px auto 2px; }
.profile-reactions.sk-line { display: block; width: 150px; height: 14px; margin: 16px auto 2px; }
.profile-details.loading { min-height: 98px; }
.profile-details.loading > * { visibility: hidden; }
.sk-short .short-poster { display: block; }
.sk-short .sk-name { width: 70%; margin-top: 6px; }
.sk-short .sk-meta { width: 50%; margin-top: 6px; }
.sk-option .compare-photo { display: block; }
/* Pictures: the box waits, the picture eases in. On a slow line it shows as it arrives after a moment. */
img.img-wait { opacity: 0; animation: img-reveal 0s 1.2s forwards; }
@keyframes img-reveal { to { opacity: 1; } }
img.img-failed { opacity: 0; }
.img-failed::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 36px; height: 36px; margin: -18px 0 0 -18px; border-radius: 50%;
  background: #fffdf8e6 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23676e68' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19 12a7 7 0 1 1-2.05-4.95'/%3E%3Cpath d='M19.5 4.5V8H16'/%3E%3C/svg%3E") center / 20px no-repeat;
  box-shadow: 0 1px 4px #0000001a; pointer-events: none;
}
.danger-thumb { position: relative; }
@media (prefers-reduced-motion: no-preference) {
  img.img-in { animation: img-in .32s ease-out; }
  @keyframes img-in { from { opacity: 0; } }
}
/* Longer waits: the neutral Moth on its small orbit (the "Finding its place…" one) and one plain line. */
.moth-wait { justify-content: center; min-height: 52px; color: var(--muted); }
.moth-wait .placing-label { font-size: 14px; }
.moth-wait .placing-label:empty { display: none; }
.boot-wait { display: none; }
/* If the first answer never comes (12 s), the sign-in form shows anyway. */
html.booting #join-screen { animation: boot-late 0s 12s both; }
@keyframes boot-late { from { visibility: hidden; } to { visibility: visible; } }
html.booting .boot-wait { position: fixed; inset: 0; display: grid; place-items: center; pointer-events: none; animation: boot-show 0s .4s both, boot-gone 0s 12s forwards; }
html.booting .boot-wait .placing-label { animation: boot-show 0s 1.5s both; }
@keyframes boot-show { from { visibility: hidden; } }
@keyframes boot-gone { to { visibility: hidden; } }
@media (prefers-reduced-motion: no-preference) {
  html.booting .boot-wait { animation: boot-in .3s .4s ease-out both, boot-gone 0s 12s forwards; }
  html.booting .boot-wait .placing-label { animation: boot-in .3s 1.5s ease-out both; }
  @keyframes boot-in { from { opacity: 0; } }
}
.compare-wait { width: auto; height: auto; margin: 0; translate: -50% -50%; padding: 0 16px 0 2px; border-radius: 28px; }
.compare-wait .placing-moth { width: 32px; height: 32px; animation: none; }
@media (prefers-reduced-motion: no-preference) { .compare-wait .placing-moth { animation: placing-bob 1s ease-in-out infinite; } }
.compare-wait .placing-label { display: none; }
.compare-wait.slow .placing-label { display: inline; }
.selfie-status .moth-wait { min-height: 0; margin-top: -10px; }
/* A button whose action is in flight: its words stay, a small ring turns beside them. */
.is-busy { position: relative; }
.is-busy::after {
  content: ""; display: inline-block; width: 14px; height: 14px; margin: -3px -4px -3px 8px; vertical-align: middle; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; opacity: .7;
}
@media (prefers-reduced-motion: no-preference) {
  .is-busy::after { animation: busy-turn .8s linear infinite; }
  @keyframes busy-turn { to { transform: rotate(1turn); } }
}
.is-busy:disabled { opacity: .75; }
.shorts-picks.is-busy::after { display: none; }
@media (prefers-reduced-motion: no-preference) { .shorts-picks.is-busy img { animation: placing-bob 1s ease-in-out infinite; } }
/* Reconnecting: one slim line under the header, over the photos, gone by itself once back. */
.app-header { position: relative; z-index: 25; }
.net-line {
  position: absolute; left: 50%; top: calc(100% + 8px); translate: -50% 0; display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 14px 5px 11px; border-radius: 16px; background: #fffdf8; color: var(--muted); font-size: 13px; line-height: 1.4; white-space: nowrap;
  box-shadow: 0 0 0 1px var(--line), 0 4px 14px -6px #2333292e; pointer-events: none;
}
.net-line::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--amber, #d49a45); }
@media (prefers-reduced-motion: no-preference) {
  .net-line:not([hidden]) { animation: appear .24s var(--settle); }
  .net-line::before { animation: net-breathe 1.8s ease-in-out infinite; }
  @keyframes net-breathe { 50% { opacity: .35; } }
}
/* ---------- /Smooth loading ---------- */

/* ---------- Mobile pass (2026-10-05): readable grey, 12 px labels, 14 px sentences, 44 px targets ---------- */
/* Small grey text at least 4.5:1 on the warm-white ground and on the surface tone (was #737a74, about 4.2:1). */
:root { --muted: #676e68; }
.reactor-names, .empty-state .empty-hint, .short-wait-pct, .shorts-note.faint, .update-dismiss { color: var(--muted); }
.removed-reason { opacity: 1; }
.rank-failure { color: var(--muted); }
/* Labels never under 12 px. */
.photo-when, .reactor-names, .send-status, .lib-times, .profile-stat dt, .review-tag { font-size: 12px; }
.rank-title, .lib-tag { font-size: 12px; }
/* Sentences people read (status, empty states, errors, notices, prompts) at 14 px. */
.error, .albums-status, .moth-card-empty, .compare-status, .compare-hint, .toast, .empty-state .empty-hint, .notice,
#chat-load-status, .top-entry-text, .profile-confirm, .profile-note, .moth-card-note, .cam-tip, .update-pill, .shorts-note.faint,
.join-switch, .preview-wrap p, .viewer-stage .image-error { font-size: 14px; }
.pending-actions .error, .join-switch .text-button { font-size: 14px; }
/* Tap targets: at least 44 px, by the control itself or an invisible margin around it. */
.seg-option::after { content: ""; position: absolute; inset: -6px 0; }
.react-add::after { inset: -6px; }
.shorts-seg .seg-option::after { inset: -4px 0; }
.pending-actions .text-button, .short-remove, .short-player .text-button, .profile-detail .text-button, .profile-alert-value .text-button,
.rank-retry, .compare-skip, .new-messages, .viewer-person-link { min-height: 44px; }
.profile-confirm-actions .button, .notify-card-actions .button, .profile-edit-selfie-actions .button, .retry-pill { min-height: 44px; }
.adj-chip, .adj-reset, .adj-review-toggle { min-height: 44px; }
.update-dismiss { width: 44px; }
/* The #1 line: a 32 px pill drawn inside a 44 px button. */
.top-banner { height: 44px; margin: -6px 0; padding: 0 5px 0 12px; background: none; border: 0; overflow: visible; isolation: isolate; }
.top-banner::before { content: ""; position: absolute; inset: 6px 0; z-index: -1; border-radius: 16px; background: var(--surface-soft); border: 1px solid var(--line); transition: background-color .15s; }
.top-banner:hover { background: none; }
.top-banner:hover::before { background: var(--surface); }
.banner-content.leaving { left: 12px; top: 10px; }
/* The Moth sheet on small phones: full-size switches, a slightly smaller mascot. */
.moth-card.sheet .moth-card-switch button { width: 44px; }
.moth-card.sheet .moth-card-switch { gap: 0; }
@media (max-width: 380px) { .moth-card.sheet .moth-card-mascot { width: 40px; height: 40px; } .moth-card.sheet .moth-card-head { gap: 6px; padding-left: 12px; } }
/* The keyboard: the Edit profile sheet stays within what is visible above it. On iPhones the keyboard
   covers the page without resizing it, so the sheet also rises by what it covers (--sheet-lift, app.js). */
@media (max-width: 600px) {
  .profile-edit { max-height: calc(var(--viewport-height, 100dvh) - max(24px, env(safe-area-inset-top))); margin-bottom: var(--sheet-lift, 0px); }
}
/* Waiting for the camera: the dark frame breathes softly until the picture arrives. */
@media (prefers-reduced-motion: no-preference) {
  .cam-frame:not(.live) {
    background-image: linear-gradient(100deg, #ffffff00 30%, #ffffff0d 50%, #ffffff00 70%); background-size: 250% 100%; background-repeat: no-repeat;
    animation: sk-shimmer 2.4s ease-in-out infinite;
  }
  .cam-stage:has(.cam-fallback:not([hidden])) .cam-frame { animation: none; background-image: none; }
}
/* Taller than a landscape phone: the selfie step scrolls from its top instead of being cut off. */
.selfie[open] { place-items: start center; }
.selfie-content { margin: auto 0; }
/* ---------- /Mobile pass ---------- */

/* ---------- v22 Trips: the trip name under the wordmark, and the Trip sheet (the hero is css/hero.css) ---------- */
.brand { min-width: 0; }
.brand-stack { display: grid; justify-items: start; min-width: 0; }
.brand-stack:has(.trip-open:not([hidden])) .wordmark { font-size: 21px; }
.trip-open {
  position: relative; display: inline-flex; align-items: center; gap: 2px; max-width: 100%; min-width: 0; margin-top: 2px;
  font-family: var(--sans); font-size: 12.5px; line-height: 1.25; font-weight: 500; letter-spacing: 0; color: var(--muted);
}
.trip-open::after { content: ""; position: absolute; inset: -15px -8px -14px; } /* a 44px tap area */
.trip-open-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.trip-open svg { flex-shrink: 0; width: 10px; height: 10px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.trip-open:hover { color: var(--ink); }
.trip-sheet { width: min(380px, calc(100% - 28px)); padding: 8px 22px max(20px, env(safe-area-inset-bottom)); }
.trip-sheet-head { display: flex; align-items: center; justify-content: space-between; margin-right: -12px; }
.trip-sheet-kicker { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.trip-sheet-name { font-family: var(--serif); font-weight: 400; font-size: 26px; line-height: 1.2; letter-spacing: -.03em; overflow-wrap: anywhere; }
.trip-sheet-count { margin-top: 4px; font-size: 14px; color: var(--muted); }
.trip-sheet-count:empty { display: none; }
.trip-sheet-code { margin-top: 18px; padding: 16px; border-radius: 14px; background: #fff; border: 1px solid var(--line); }
.trip-sheet-label { font-size: 13px; color: var(--muted); }
.trip-sheet-code-value {
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: clamp(28px, 9vw, 34px); font-weight: 600;
  letter-spacing: .1em; line-height: 1.25; user-select: all; white-space: nowrap;
}
.trip-sheet-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.trip-sheet-row .button { min-width: 0; }
.trip-sheet-code .trip-sheet-row .button { flex: 1; }
.trip-sheet-status { margin-top: 10px; font-size: 14px; color: var(--accent); }
.trip-sheet-status:empty { display: none; }
.trip-sheet-note { margin-top: 10px; font-size: 13px; line-height: 1.5; color: var(--muted); }
.trip-organiser { margin-top: 8px; }
.trip-sheet-links { display: flex; gap: 24px; }
.trip-sheet .text-button { font-size: 14px; color: var(--muted); text-decoration: underline; text-underline-offset: 4px; text-decoration-color: var(--line); }
.trip-sheet .text-button:hover { color: var(--ink); text-decoration-color: currentColor; }
.trip-new-confirm { margin-top: 8px; }
.trip-new-text { font-size: 15px; line-height: 1.5; text-wrap: pretty; }
.trip-rename { margin-top: 2px; }
.trip-rename label { font-size: 13px; color: var(--muted); }
.trip-rename input { font-size: 18px; }
.trip-sheet .error { margin-top: 8px; font-size: 14px; }

/* ---------- Polish pass (2026-10-06) ---------- */
/* Short phones (an SE, a small Android): My profile is where people land after signing in, so its
   first screen keeps "Go to chat" in view: a smaller picture and tighter spacing. */
@media (max-height: 700px) {
  .profile-card { padding-top: 18px; }
  .profile-card .profile-avatar { width: 96px; height: 96px; font-size: 40px; }
  .profile-name { font-size: 28px; margin-top: 12px; }
  .profile-stats { margin-top: 18px; }
  .profile-own { margin-top: 18px; }
}
/* The Trip sheet on phones: like Edit profile, it rises above an iPhone keyboard (--sheet-lift, app.js)
   and never grows taller than what can be seen; it scrolls inside itself instead. */
@media (max-width: 600px) {
  .trip-sheet {
    margin-bottom: calc(max(14px, env(safe-area-inset-bottom)) + var(--sheet-lift, 0px));
    max-height: min(85dvh, calc(var(--viewport-height, 100dvh) - 28px)); overflow-y: auto; overscroll-behavior: contain;
  }
}
/* Under a screen that covers the page, its idle loops rest (battery): the Moths, the crown's glow, the hero. */
body.modal-open :is(#app, #join-screen) :is(.moth-bubble img, .crown-glow, .crown-sparkle, .placing-orbit, .placing-moth, .sk,
  .hero-moth-float, .hero-moth-shadow, .hero-lamp, .hero-print) { animation-play-state: paused; }
/* ---------- /Polish pass ---------- */
