* { box-sizing: border-box; }
html {
  overscroll-behavior: none;
}
:root {
  --bg: #f5eee7;
  --card: rgba(255,255,255,.72);
  --text: #211b18;
  --muted: #746a63;
  --line: rgba(33,27,24,.12);
  --accent: #211b18;
  --danger: #9b2c2c;
  --ok: #23613a;
}
body {
  margin: 0;
  min-height: 100vh;
  overscroll-behavior: none;
  touch-action: pan-y;
  background: radial-gradient(circle at top, #fff8f0 0, var(--bg) 45%, #e9ded4 100%);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
}
a { color: inherit; }
.auth-page { display: flex; align-items: center; justify-content: center; padding: 28px 16px; }
.auth-card { width: min(520px, 100%); }
.brand { font-size: 14px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 14px; }
.form-link { margin: 14px 0 0; text-align: center; color: var(--muted); font-size: 14px; }
.form-link a { font-weight: 800; text-decoration: none; }
h1 { font-size: clamp(34px, 8vw, 56px); line-height: .95; letter-spacing: -0.06em; margin: 0 0 16px; }
h2 { font-size: 18px; margin: 0 0 14px; }
.muted, .hint { color: var(--muted); line-height: 1.55; }
.panel, .hero-card, .diptych-card, .upload-card, .waiting, .archive-item, .empty {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 22px;
  margin: 16px 0;
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 60px rgba(54,43,35,.08);
}
.panel.ghost { background: rgba(255,255,255,.45); }
.compact-panel { padding: 16px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0; }
label span { opacity: .72; }
.checkbox-row { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; }
.checkbox-row input { width: 18px; height: 18px; accent-color: var(--accent); }
input[type="email"], input[type="password"], input[type="text"] {
  width: 100%; margin-top: 7px; padding: 14px 14px; border-radius: 16px; border: 1px solid var(--line); background: rgba(255,255,255,.82); font-size: 16px; outline: none;
}
button, .button {
  display: inline-flex; align-items: center; justify-content: center; width: 100%; min-height: 48px; padding: 12px 18px; border: 0; border-radius: 999px; background: var(--accent); color: #fff; font-size: 15px; font-weight: 700; text-decoration: none; cursor: pointer;
}
.button.secondary { background: rgba(33,27,24,.08); color: var(--text); }
.alert { padding: 12px 14px; border-radius: 16px; margin: 12px 0; font-size: 14px; }
.alert.error { background: rgba(155,44,44,.1); color: var(--danger); }
.alert.ok { background: rgba(35,97,58,.1); color: var(--ok); }
.relationship-list { display: grid; gap: 10px; }
.relationship-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 10px 14px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.46); }
.relationship-row span { color: var(--muted); font-size: 13px; }
.relationship-row .button { width: auto; min-height: 38px; padding: 8px 12px; font-size: 13px; }
.relationship-row .button + .button { margin-left: 4px; }
.relationship-tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.relationship-tabs a { flex: 0 0 auto; padding: 10px 14px; border-radius: 999px; background: rgba(33,27,24,.08); color: var(--muted); text-decoration: none; font-weight: 800; font-size: 13px; }
.relationship-tabs a.active { background: var(--text); color: #fff; }
.archive-setting { padding: 12px 0; border-top: 1px solid var(--line); }
.top { position: sticky; top: 0; z-index: 2; padding: 14px 18px; background: rgba(245,238,231,.82); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.top div { max-width: 740px; margin: 0 auto; display:flex; justify-content:space-between; gap: 12px; }
.top span { color: var(--muted); }
.container { width: min(740px, 100%); margin: 0 auto; padding: 18px; }
.with-nav { padding-bottom: 96px; }
.label { margin: 0 0 12px; color: var(--muted); font-size: 13px; letter-spacing: .12em; text-transform: uppercase; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 32px; letter-spacing: .08em; padding: 18px; background: rgba(255,255,255,.8); border: 1px dashed var(--line); border-radius: 20px; text-align: center; }
.diptych-frame { display: grid; grid-template-columns: 1fr 1fr; overflow: hidden; border-radius: 22px; background: #1c1714; aspect-ratio: 4 / 3; border: 1px solid rgba(0,0,0,.18); }
.diptych-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.diptych-frame.small { border-radius: 18px; }
.caption { display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; color: var(--muted); font-size: 13px; margin-top: 12px; }
.file-picker { display: flex; align-items: center; justify-content: center; border: 1px dashed rgba(33,27,24,.24); border-radius: 24px; background: rgba(255,255,255,.55); min-height: 180px; color: var(--text); font-size: 18px; font-weight: 700; cursor: pointer; }
.file-picker input { display: none; }
.upload-card button { margin-top: 14px; }
.waiting { text-align: center; }
.placeholder.filled { overflow:hidden; border-radius:24px; aspect-ratio: 3 / 4; max-height: 360px; background:#241f1c; }
.placeholder.filled img { width:100%; height:100%; object-fit:cover; }
.archive-list { display: grid; gap: 4px; }
.archive-head { display:flex; justify-content:space-between; align-items:center; margin-bottom: 12px; color: var(--muted); }
.archive-head strong { color: var(--text); }
.missing { min-height: 170px; display:flex; align-items:center; justify-content:center; border: 1px dashed var(--line); border-radius: 22px; color: var(--muted); background: rgba(255,255,255,.38); }
.empty { text-align:center; padding: 40px 24px; }
.bottom-nav { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); width: min(520px, calc(100% - 28px)); display:grid; grid-template-columns: repeat(var(--nav-count, 4),1fr); gap: 6px; padding: 8px; border-radius: 999px; background: rgba(255,255,255,.78); border: 1px solid var(--line); backdrop-filter: blur(18px); box-shadow: 0 18px 50px rgba(45,35,28,.14); }
.bottom-nav a { text-align:center; text-decoration:none; padding: 12px 8px; border-radius: 999px; color: var(--muted); font-size: 13px; font-weight: 700; }
.bottom-nav a.active { background: var(--text); color: #fff; }
@media (max-width: 520px) {
  .container { padding: 14px; }
  .panel, .hero-card, .diptych-card, .upload-card, .waiting, .archive-item, .empty { border-radius: 24px; padding: 18px; }
  .relationship-row { grid-template-columns: 1fr 1fr; }
  .relationship-row strong, .relationship-row span { grid-column: 1 / -1; }
}
.upload-preview { margin: 14px 0 0; }
.upload-preview img { width: 100%; max-height: 320px; object-fit: cover; border-radius: 22px; display: block; background: #1c1714; }
.progress-wrap { margin-top: 14px; }
.progress-bar { height: 10px; width: 100%; overflow: hidden; border-radius: 999px; background: rgba(33,27,24,.1); border: 1px solid var(--line); }
.progress-bar span { display: block; height: 100%; width: 0%; border-radius: inherit; background: var(--text); transition: width .18s ease; }
button:disabled { opacity: .55; cursor: not-allowed; }
.live-hint { font-size: 13px; }

.archive-summary {
  text-align: center;
  background: rgba(255,255,255,.74);
  border: 1px solid var(--line);
  border-radius: 30px;
  padding: 28px 22px;
  margin: 16px 0 20px;
  box-shadow: 0 18px 60px rgba(54,43,35,.08);
}
.archive-summary .pair-names { margin: 0 0 8px; color: var(--muted); font-weight: 700; }
.archive-summary h1 { margin-bottom: 8px; }
.big-number { font-size: clamp(30px, 9vw, 52px); line-height: 1; letter-spacing: -0.06em; font-weight: 800; margin: 4px 0 8px; }
.diptych-open { width: 100%; min-height: 0; padding: 0; border-radius: 18px; background: transparent; color: inherit; display: block; cursor: zoom-in; }
.diptych-open:focus-visible { outline: 3px solid rgba(33,27,24,.28); outline-offset: 4px; }
.lightbox[hidden] { display: none; }
.lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(20,16,14,.78); backdrop-filter: blur(18px); padding: 18px; display: flex; align-items: center; justify-content: center; }
.lightbox-inner { width: min(980px, 100%); }
.lightbox .label { color: rgba(255,255,255,.72); text-align: center; }
.lightbox-frame { border-radius: 24px; max-height: 82vh; width: 100%; }
.lightbox-close { position: fixed; top: 14px; right: 14px; width: 44px; min-height: 44px; padding: 0; border-radius: 50%; background: rgba(255,255,255,.86); color: #211b18; font-size: 28px; line-height: 1; }
.modal-open { overflow: hidden; }

/* Today split upload layout */
.split-upload-card { padding: 18px; }
.upload-diptych-frame {
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  border-radius: 22px;
  background: #1c1714;
  aspect-ratio: 4 / 3;
  border: 1px solid rgba(0,0,0,.18);
}
.upload-half {
  position: relative;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.05);
}
.upload-half:last-child { border-right: 0; }
.upload-half img { width: 100%; height: 100%; object-fit: cover; display: block; }
.upload-half.mine.empty-half { background: rgba(255,255,255,.09); }
.upload-half.partner.empty-half { background: repeating-linear-gradient(135deg, rgba(255,255,255,.08), rgba(255,255,255,.08) 10px, rgba(255,255,255,.035) 10px, rgba(255,255,255,.035) 20px); }
.half-label {
  position: absolute;
  z-index: 2;
  top: 10px;
  left: 10px;
  max-width: calc(100% - 20px);
  padding: 6px 9px;
  border-radius: 999px;
  background: rgba(20,16,14,.58);
  color: rgba(255,255,255,.86);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .02em;
  backdrop-filter: blur(10px);
}
.half-picker {
  width: 100%;
  height: 100%;
  min-height: 100%;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: rgba(255,255,255,.92);
  text-align: center;
  padding: 42px 12px 16px;
  font-size: 15px;
}
.half-picker span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.22);
}
.locked-half {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 42px 14px 14px;
  color: rgba(255,255,255,.58);
  text-align: center;
  font-size: 13px;
  font-weight: 700;
}
.half-preview {
  position: absolute;
  inset: 0;
  margin: 0;
  z-index: 1;
}
.half-preview img {
  width: 100%;
  height: 100%;
  max-height: none;
  border-radius: 0;
  object-fit: cover;
}
.split-upload-card .progress-wrap { margin: 16px 4px 0; }
.split-upload-card button { margin-top: 14px; }
@media (max-width: 520px) {
  .upload-diptych-frame { border-radius: 20px; }
  .half-label { font-size: 10px; top: 8px; left: 8px; }
  .half-picker { font-size: 13px; }
}

/* Completed frame ritual */
.developing-card {
  min-height: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: rgba(255,255,255,.74);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 28px 22px;
  margin: 16px 0;
  box-shadow: 0 18px 60px rgba(54,43,35,.08);
  overflow: hidden;
  position: relative;
}
.developing-card::before {
  content: "";
  position: absolute;
  inset: -40%;
  background: radial-gradient(circle at 50% 50%, rgba(255,255,255,.85), rgba(255,255,255,0) 42%);
  animation: filmPulse 1.1s ease-in-out infinite;
}
.developing-card > * { position: relative; z-index: 1; }
.developing-word {
  font-size: clamp(36px, 10vw, 64px);
  line-height: .95;
  letter-spacing: -0.06em;
  font-weight: 850;
  margin: 6px 0 12px;
}
.completed-reveal {
  animation: completedRise .48s ease-out both;
}
.completed-reveal .diptych-frame img:first-child {
  animation: leftHalfIn .55s ease-out both;
}
.completed-reveal .diptych-frame img:last-child {
  animation: rightHalfIn .55s ease-out both;
}
.complete-label { text-align: center; }
.celebration-line {
  text-align: center;
  font-size: 18px;
  line-height: 1.35;
  letter-spacing: -0.02em;
  font-weight: 750;
  margin: 16px auto 2px;
  max-width: 520px;
}
.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 80;
  overflow: hidden;
}
.confetti-layer span {
  position: absolute;
  top: -20px;
  width: 7px;
  height: 12px;
  border-radius: 2px;
  background: rgba(33,27,24,.42);
  opacity: .78;
  animation-name: confettiFall;
  animation-timing-function: cubic-bezier(.18,.72,.32,1);
  animation-fill-mode: forwards;
}
.confetti-layer span:nth-child(3n) { width: 5px; height: 10px; background: rgba(155,118,82,.42); }
.confetti-layer span:nth-child(3n+1) { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.88); }
@keyframes filmPulse {
  0%, 100% { opacity: .38; transform: scale(.92); }
  50% { opacity: .88; transform: scale(1.04); }
}
@keyframes completedRise {
  from { opacity: 0; transform: translateY(10px); filter: blur(6px); }
  to { opacity: 1; transform: translateY(0); filter: blur(0); }
}
@keyframes leftHalfIn {
  from { opacity: 0; transform: translateX(-8%); filter: blur(7px); }
  to { opacity: 1; transform: translateX(0); filter: blur(0); }
}
@keyframes rightHalfIn {
  from { opacity: 0; transform: translateX(8%); filter: blur(7px); }
  to { opacity: 1; transform: translateX(0); filter: blur(0); }
}
@keyframes confettiFall {
  0% { opacity: 0; transform: translateY(0) rotate(0deg); }
  12% { opacity: .78; }
  100% { opacity: 0; transform: translateY(72vh) rotate(260deg); }
}
@media (prefers-reduced-motion: reduce) {
  .developing-card::before,
  .completed-reveal,
  .completed-reveal .diptych-frame img,
  .confetti-layer span { animation: none !important; }
  .confetti-layer { display: none; }
}
