:root {
  --bg: #faf6f1;
  --bg-bottom: #f3e9dc;
  --surface: #ffffff;
  --ink: #2b2118;
  --ink-soft: #7a6a5a;
  --accent: #c9a47a;
  --accent-soft: #e8d6c0;
  --rose: #d49a8a;
  --success: #7a9b7a;
  --shadow-soft: 0 8px 30px rgba(43, 33, 24, 0.08);
  --shadow-press: 0 2px 8px rgba(43, 33, 24, 0.12);
  --serif: "Cormorant Garamond", "Playfair Display", Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  --radius: 20px;
  --radius-lg: 24px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(120% 60% at 50% 0%, #fffaf3 0%, transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-bottom) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 22px 96px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  min-height: 100vh;
  min-height: 100dvh;
}

#app[hidden] { display: none; }

.topbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  min-height: 24px;
}

.who {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.who::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.hero {
  text-align: center;
  margin-top: 8px;
}

.hero-portrait {
  display: block;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  object-fit: cover;
  margin: 0 auto 14px;
  border: 1.5px solid var(--accent);
  box-shadow: var(--shadow-soft);
  background: var(--surface);
}

.hero-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(34px, 9vw, 44px);
  letter-spacing: 0.01em;
  margin: 0 0 4px;
  color: var(--ink);
}

.hero-sub {
  font-family: var(--serif);
  font-style: italic;
  font-size: 18px;
  color: var(--ink-soft);
  margin: 0 0 6px;
}

.today {
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0;
}

.counter-wrap {
  text-align: center;
  margin-top: 4px;
}

.counter {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 72px;
  line-height: 1;
  color: var(--ink);
  letter-spacing: 0.02em;
  padding-bottom: 14px;
  transition: transform 200ms ease-out;
}

.counter.is-bump {
  animation: counter-bump 480ms ease-out;
}

@keyframes counter-bump {
  0% { transform: scale(1); }
  35% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

.counter-sep {
  color: var(--rose);
  font-style: italic;
  margin: 0 6px;
}

.counter-label {
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 8px 0 0;
}

.total-counter {
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  color: var(--ink-soft);
  margin: 10px 0 0;
  letter-spacing: 0.01em;
}

.total-counter[hidden] { display: none; }

.capture {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-top: auto;
  padding-top: 12px;
}

.capture[hidden] { display: none; }

.cam-button {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: var(--surface);
  border: 1.5px solid var(--accent);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  transition: transform 120ms ease-out, box-shadow 120ms ease-out;
  user-select: none;
}

.cam-button:active {
  transform: scale(0.97);
  box-shadow: var(--shadow-press);
}

.cam-button.is-flash {
  animation: cam-flash 520ms ease-out;
}

@keyframes cam-flash {
  0% { box-shadow: 0 0 0 0 rgba(201, 164, 122, 0.6), var(--shadow-soft); }
  60% { box-shadow: 0 0 0 22px rgba(201, 164, 122, 0), var(--shadow-soft); }
  100% { box-shadow: 0 0 0 22px rgba(201, 164, 122, 0), var(--shadow-soft); }
}

.cam-button[aria-disabled="true"] {
  opacity: 0.35;
  pointer-events: none;
}

.cam-caption {
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  color: var(--ink-soft);
  margin: 0;
}

.done-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  text-align: center;
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: auto;
}

.done-card[hidden] { display: none; }

.done-card h2 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 26px;
  margin: 4px 0 0;
  color: var(--ink);
}

.done-card p {
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  color: var(--ink-soft);
  margin: 0;
  line-height: 1.4;
  max-width: 28ch;
}

.sync-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 14px 22px calc(14px + env(safe-area-inset-bottom));
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(180deg, transparent 0%, rgba(243, 233, 220, 0.7) 60%, var(--bg-bottom) 100%);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.sync-bar .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  transition: background 200ms ease-out;
}

.sync-bar.is-success .dot { background: var(--success); }
.sync-bar.is-pending .dot {
  background: var(--rose);
  animation: dot-pulse 1.4s ease-in-out infinite;
}

@keyframes dot-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(1.35); }
}

.onboarding {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  z-index: 100;
  overflow-y: auto;
}

.onboarding[hidden] { display: none; }

.onboarding-inner {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  text-align: center;
}

.onboarding-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 32px;
  margin: 0;
  color: var(--ink);
}

.onboarding-sub {
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  color: var(--ink-soft);
  margin: -10px 0 0;
}

.who-choice {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 8px;
}

.who-card {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 500;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius);
  padding: 22px 16px;
  cursor: pointer;
  transition: background 150ms ease-out, transform 120ms ease-out;
  box-shadow: var(--shadow-soft);
}

.who-card:hover { background: var(--accent-soft); }
.who-card:active { transform: scale(0.98); }
.who-card.is-selected { background: var(--accent-soft); }

.pw-step {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
}

.pw-step[hidden] { display: none; }

.pw-label {
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  color: var(--ink-soft);
}

#pw {
  font-family: var(--sans);
  font-size: 18px;
  padding: 14px 16px;
  border: 1.5px solid var(--accent);
  background: var(--surface);
  border-radius: var(--radius);
  color: var(--ink);
  text-align: center;
  letter-spacing: 0.1em;
  outline: none;
  transition: border-color 150ms ease-out;
}

#pw:focus { border-color: var(--rose); }

.pw-error {
  font-family: var(--sans);
  font-size: 13px;
  color: #b8554a;
  margin: 0;
}

.pw-error[hidden] { display: none; }

.pw-submit {
  font-family: var(--sans);
  font-size: 14px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 14px 18px;
  cursor: pointer;
  margin-top: 4px;
  transition: background 150ms ease-out, transform 120ms ease-out;
}

.pw-submit:hover { background: #b9926a; }
.pw-submit:active { transform: scale(0.98); }

.toast-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(43, 33, 24, 0.22);
  -webkit-backdrop-filter: blur(8px) saturate(110%);
  backdrop-filter: blur(8px) saturate(110%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 240ms ease-out;
  z-index: 49;
}

.toast-backdrop[hidden] { display: none; }
.toast-backdrop.is-show { opacity: 1; }

.toast {
  position: fixed;
  left: 50%;
  top: 50%;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--serif);
  font-style: italic;
  font-size: 18px;
  padding: 14px 26px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  box-shadow: 0 12px 40px rgba(43, 33, 24, 0.18);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.94);
  transition: opacity 220ms ease-out, transform 260ms cubic-bezier(0.2, 0.8, 0.3, 1);
  z-index: 50;
  white-space: nowrap;
}

.toast[hidden] { display: none; }

.toast.is-show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

@media (prefers-reduced-motion: reduce) {
  .counter,
  .cam-button,
  .toast,
  .toast-backdrop,
  .sync-bar .dot {
    animation: none !important;
    transition: none !important;
  }
}

@media (min-height: 740px) {
  .capture { padding-top: 32px; }
}

@media (max-width: 360px) {
  .counter { font-size: 60px; }
  .hero-title { font-size: 32px; }
  .cam-button { width: 124px; height: 124px; }
}
