:root {
  --bg: #fbf7f0;
  --bg-accent: #f3eadc;
  --surface: #ffffff;
  --surface-warm: #fffcf7;
  --border: #e7dccb;
  --border-strong: #d5c4aa;
  --text: #1f241f;
  --text-muted: #5c635c;
  --pine: #1b4332;
  --pine-dark: #133124;
  --crimson: #c1121f;
  --crimson-dark: #9b0f19;
  --gold: #c98f32;
  --gold-soft: #fdf3dc;
  --danger: #b42318;
  --shadow-sm: 0 2px 8px rgba(31, 36, 31, 0.05);
  --shadow-md: 0 10px 28px rgba(31, 36, 31, 0.08);
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 24px;
  --font-display: 'Fraunces', Georgia, serif;
  --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 15% 10%, rgba(193, 18, 31, 0.05), transparent 36%),
    radial-gradient(circle at 88% 12%, rgba(27, 67, 50, 0.07), transparent 38%);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  overflow-x: hidden;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

a {
  color: var(--pine);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}

img,
svg {
  max-width: 100%;
  height: auto;
  display: block;
}

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

.container {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding-left: 16px;
  padding-right: 16px;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(251, 247, 240, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--pine);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.18rem;
  letter-spacing: -0.01em;
}

.brand-mark {
  font-size: 1.3rem;
  line-height: 1;
}

.nav-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  color: var(--pine);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.nav-pill:hover {
  background: var(--bg-accent);
  border-color: var(--pine);
}

/* Main */
.main-content {
  flex: 1;
  padding: 20px 0 36px;
}

/* Stack helpers */
.stack-sm {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stack-md {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.stack-lg {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

/* Hero */
.hero-section {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.hero-badge {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--gold-soft);
  border: 1px solid rgba(201, 143, 50, 0.35);
  color: #7c510d;
  font-size: 0.84rem;
  font-weight: 600;
}

.hero-title {
  margin: 0;
  text-align: center;
  font-family: var(--font-display);
  font-size: 2rem;
  line-height: 1.12;
  letter-spacing: -0.02em;
  color: var(--pine);
}

.hero-subtitle {
  margin: 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.98rem;
  line-height: 1.5;
}

.parent-banner {
  background: #edf6f0;
  border: 1px solid #b9dac4;
  color: var(--pine-dark);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 0.9rem;
  font-weight: 500;
  text-align: center;
}

/* Forms */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.field-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.char-counter {
  font-size: 0.82rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.char-counter.is-near-limit {
  color: var(--crimson);
  font-weight: 700;
}

.text-input,
.text-area {
  width: 100%;
  font-family: inherit;
  font-size: 16px; /* Prevents iOS Safari zoom on focus */
  color: var(--text);
  background: var(--surface-warm);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.text-input:focus,
.text-area:focus {
  border-color: var(--pine);
  box-shadow: 0 0 0 3px rgba(27, 67, 50, 0.12);
}

.text-input:disabled {
  opacity: 0.55;
  background: var(--bg-accent);
}

.text-area {
  resize: vertical;
  min-height: 108px;
}

.mono-input {
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

.code-big-input {
  text-align: center;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 14px;
}

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-top: 4px;
  font-size: 0.92rem;
  color: var(--text-muted);
  cursor: pointer;
  min-height: 36px;
}

.checkbox-row input[type='checkbox'] {
  width: 19px;
  height: 19px;
  accent-color: var(--pine);
}

.form-error {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--danger);
  font-size: 0.88rem;
  font-weight: 500;
}

.form-hint {
  margin: 0;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Style selector */
.style-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.style-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 6px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border);
  background: var(--surface-warm);
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.12s ease, background-color 0.15s ease;
  text-align: center;
}

.style-card:hover {
  border-color: var(--border-strong);
}

.style-card.is-selected {
  border-color: var(--crimson);
  background: #fff6f4;
  box-shadow: 0 4px 12px rgba(193, 18, 31, 0.12);
}

.style-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 92px;
}

.style-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.1s ease, background-color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.985);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-lg {
  min-height: 52px;
  font-size: 1.02rem;
  border-radius: 14px;
}

.btn-sm {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 0.84rem;
}

.btn-full {
  width: 100%;
}

.btn-primary {
  background: var(--crimson);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--crimson-dark);
}

.btn-outline {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-outline:hover {
  background: var(--bg-accent);
  border-color: var(--pine);
}

.btn-gold {
  background: var(--gold-soft);
  border-color: rgba(201, 143, 50, 0.55);
  color: #6d4508;
}

.btn-gold:hover {
  background: #fbe8be;
}

.btn-whatsapp {
  background: #1f8a4c;
  color: #ffffff;
}

.btn-whatsapp:hover {
  background: #18703d;
}

.btn-messages {
  background: #1d6ef2;
  color: #ffffff;
}

.btn-messages:hover {
  background: #1659c7;
}

.btn-snapchat {
  background: #ffe600;
  border-color: #e6cf00;
  color: #1a1a1a;
}

.btn-snapchat:hover {
  background: #f5dc00;
}

.btn-danger-ghost {
  background: transparent;
  color: var(--danger);
  border-color: transparent;
  font-weight: 600;
  font-size: 0.88rem;
}

.btn-danger-ghost:hover {
  background: #fef2f2;
  border-color: #fecaca;
}

/* How grid */
.how-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.how-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 13px 14px;
}

.how-step {
  flex: 0 0 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--pine);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.how-item strong {
  display: block;
  font-size: 0.94rem;
  color: var(--pine);
}

.how-item p {
  margin: 2px 0 0;
  font-size: 0.86rem;
  color: var(--text-muted);
}

.secondary-links-bar {
  text-align: center;
  padding-top: 4px;
}

.text-link {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--pine);
}

.text-link-btn {
  background: none;
  border: none;
  padding: 8px 4px;
  font: inherit;
  font-size: 0.88rem;
  color: var(--text-muted);
  text-decoration: underline;
  cursor: pointer;
}

.text-link-btn:hover {
  color: var(--pine);
}

/* Stocking Page */
.stocking-page {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stocking-hero-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  background: linear-gradient(180deg, #ffffff 0%, #fffaf2 100%);
}

.countdown-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  background: #edf6f0;
  border: 1px solid #c3e2cd;
  color: var(--pine);
  font-size: 0.84rem;
  font-weight: 700;
}

.countdown-pill.is-unlocked {
  background: #fff2cc;
  border-color: #e9c46a;
  color: #7c4d03;
}

.stocking-stage {
  display: flex;
  justify-content: center;
  padding: 4px 0;
}

.stocking-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.65rem;
  line-height: 1.2;
  color: var(--pine);
  word-break: break-word;
}

.stocking-meta {
  margin: 0;
  font-size: 0.92rem;
  color: var(--text-muted);
}

.nudge-banner {
  background: var(--pine);
  color: #ffffff;
  border-radius: var(--radius-md);
  padding: 13px 16px;
  font-size: 0.93rem;
  font-weight: 600;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.section-heading {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.22rem;
  line-height: 1.25;
  color: var(--pine);
}

.section-sub {
  margin: 4px 0 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Share grid: 2 columns neatly at 375px */
.share-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.share-btn,
.story-btn {
  padding: 10px 8px;
  gap: 6px;
  font-size: 0.85rem;
  white-space: nowrap;
}

/* Code & passphrase card */
.codes-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.code-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.mini-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.mono-value {
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--pine);
  word-break: break-all;
}

.mini-hint {
  margin: 4px 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.divider {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 0;
}

/* Stickers */
.sticker-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.sticker-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 58px;
  padding: 6px 4px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface-warm);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.sticker-pill.is-selected {
  border-color: var(--crimson);
  background: #fff5f5;
  box-shadow: 0 2px 8px rgba(193, 18, 31, 0.12);
}

.sticker-emoji {
  font-size: 1.35rem;
  line-height: 1;
}

.sticker-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Notes list */
.notes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.lock-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-accent);
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.lock-badge.is-unlocked {
  background: #edf6f0;
  color: var(--pine);
}

.notes-list {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.notes-empty {
  padding: 20px 14px;
  text-align: center;
  border-radius: var(--radius-md);
  background: var(--surface-warm);
  border: 1px dashed var(--border-strong);
  color: var(--text-muted);
  font-size: 0.9rem;
}

.note-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-warm);
}

.note-item.is-openable {
  border-color: rgba(201, 143, 50, 0.65);
  background: #fffcf3;
}

.note-main {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.note-sticker {
  flex: 0 0 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.note-info {
  min-width: 0;
}

.note-author {
  font-weight: 700;
  font-size: 0.94rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.note-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.mini-action-btn {
  min-height: 34px;
  padding: 5px 10px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.mini-action-btn:hover {
  border-color: var(--pine);
  color: var(--pine);
}

.mini-action-btn.is-open {
  background: var(--pine);
  border-color: var(--pine);
  color: #ffffff;
}

.mini-action-btn.is-danger {
  color: var(--danger);
  border-color: #f3c4c0;
}

/* Success CTA card */
.success-card {
  text-align: center;
  background: linear-gradient(180deg, #fffdf8 0%, #edf6f0 100%);
  border-color: #b9dac4;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.success-icon {
  font-size: 2.4rem;
  line-height: 1;
}

.success-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.45rem;
  color: var(--pine);
}

.success-sub {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.94rem;
}

.make-own-cta {
  box-shadow: 0 6px 16px rgba(193, 18, 31, 0.22);
}

.limit-card {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.danger-zone,
.recover-footer {
  text-align: center;
  padding-top: 4px;
}

/* Static / Legal / Code pages */
.narrow-page,
.prose-page {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.page-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.65rem;
  line-height: 1.2;
  color: var(--pine);
}

.prose-card h2 {
  margin: 22px 0 8px;
  font-family: var(--font-display);
  font-size: 1.12rem;
  color: var(--pine);
}

.prose-card p,
.prose-card li {
  color: var(--text);
  font-size: 0.94rem;
  line-height: 1.62;
}

.prose-card ul {
  padding-left: 20px;
  margin: 8px 0;
}

.prose-lead {
  color: var(--text-muted) !important;
  margin-top: 6px;
}

.not-found-card {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 28px 20px;
}

.not-found-icon {
  font-size: 2.6rem;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(18, 24, 19, 0.62);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-sheet {
  width: 100%;
  max-width: 420px;
  max-height: 90dvh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-header h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--pine);
}

.modal-close {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-warm);
  font-size: 1rem;
  cursor: pointer;
}

.modal-sub {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.story-preview-wrap {
  display: flex;
  justify-content: center;
  background: #142b20;
  border-radius: var(--radius-md);
  padding: 10px;
}

#story-preview-img {
  max-height: 46dvh;
  width: auto;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Reveal modal */
.reveal-sheet {
  background: linear-gradient(180deg, #fffdf8 0%, #fff7ea 100%);
  border: 2px solid #e7c98b;
}

.reveal-sticker {
  font-size: 2rem;
  line-height: 1;
}

.reveal-from {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--pine);
}

.reveal-body {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  font-size: 1.05rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

.reveal-date {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 80;
  max-width: calc(100vw - 32px);
  padding: 11px 18px;
  border-radius: 999px;
  background: var(--pine-dark);
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
  text-align: center;
}

/* Footer */
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.65);
  padding: 20px 0 24px;
}

.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  font-size: 0.88rem;
  font-weight: 600;
}

.footer-links a {
  text-decoration: none;
  color: var(--pine);
}

.footer-links a:hover {
  text-decoration: underline;
}

.footer-meta,
.footer-copy {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

@media (min-width: 480px) {
  .hero-title {
    font-size: 2.35rem;
  }

  .card {
    padding: 24px;
  }
}
