:root {
  --page-bg: #fbf3ea;
  --page-bg-2: #f3e6d8;
  --ink: #2d2a32;
  --ink-soft: #6b6470;
  --accent: #ff5e7e;
  --accent-2: #ffb703;
  --surface: #ffffff;
  --surface-line: rgba(45, 42, 50, 0.08);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 8px;
  --shadow-soft: 0 10px 30px rgba(30, 20, 40, 0.12);
  --shadow-deep: 0 20px 60px rgba(30, 20, 40, 0.22);
  --font-ui: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --page-bg: #17141d;
    --page-bg-2: #241f2e;
    --ink: #f3f0f6;
    --ink-soft: #b6aec2;
    --surface: #221e2a;
    --surface-line: rgba(255, 255, 255, 0.08);
    --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.4);
    --shadow-deep: 0 20px 60px rgba(0, 0, 0, 0.55);
  }
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: var(--font-ui);
  color: var(--ink);
  background: radial-gradient(circle at 50% -10%, var(--page-bg-2), var(--page-bg) 60%);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

a {
  color: inherit;
}

button {
  font-family: inherit;
}

img {
  max-width: 100%;
  display: block;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.container {
  max-width: 560px;
  margin: 0 auto;
  padding: 24px 20px calc(48px + var(--safe-bottom));
}

/* Centers the envelope/card vertically in the viewport with comfortable,
 * safe-area-aware top padding, independent of the (initially hidden)
 * actions below it. */
.hero-stage {
  min-height: calc(100dvh - 24px - var(--safe-top) - 48px - var(--safe-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-top: calc(12px + var(--safe-top));
  padding-bottom: 24px;
}

.center-stage {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px calc(24px + var(--safe-bottom));
}

/* ---- shared state screens (loading / expired / unavailable / not_found / error) ---- */
.state-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
  max-width: 360px;
  margin: 0 auto;
}

.state-emoji {
  font-size: 56px;
  line-height: 1;
}

.state-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
}

.state-body {
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1.5;
  margin: 0;
}

.spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 4px solid var(--surface-line);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 2.4s;
  }
}
