:root {
  --font-display: "Spectral", Georgia, "Times New Roman", serif;
  --font-sans: "Work Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  /* Strict 3-size body scale below hero */
  --text-h2: clamp(1.65rem, 2.8vw, 2.25rem);
  --text-body: 1rem;
  --text-sm: 0.875rem;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* Theme 1 (Default): Evergreen Nocturnal Atelier */
body[data-theme="evergreen"] {
  --bg: #0b1918;
  --bg-top: #102422;
  --candle-glow: rgba(223, 177, 91, 0.16);
  --ink: #f7f1e3;
  --ink-muted: #b9c9c0;
  --brass: #dfb15b;
  --accent: #dfb15b;
  --accent-hover: #ecc372;
  --accent-ink: #171208;
  --crimson: #b5362d;
  --hairline: rgba(247, 241, 227, 0.14);
  --control-bg: rgba(247, 241, 227, 0.06);
  --control-border: rgba(247, 241, 227, 0.16);
  --input-bg: rgba(8, 19, 18, 0.72);
  --input-ink: #f7f1e3;
  --pill-active-bg: #f7f1e3;
  --pill-active-ink: #13221f;
  --compare-highlight: #ecc372;
  --header-scrolled: rgba(11, 25, 24, 0.92);
  --door-empty-bg: rgba(247, 241, 227, 0.05);
  --door-empty-border: rgba(223, 177, 91, 0.34);
  --door-filled-bg: #f3e4c8;
  --door-filled-flap: #e4cca2;
  --door-filled-ink: #2b1d18;
  --door-opened-bg: #fffbf2;
  --door-opened-ink: #182722;
}

/* Theme 2: Sunlit Parchment & Oxblood */
body[data-theme="cranberry"] {
  --bg: #efe3ce;
  --bg-top: #f6ecdb;
  --candle-glow: rgba(154, 47, 42, 0.08);
  --ink: #261714;
  --ink-muted: #654b42;
  --brass: #a87119;
  --accent: #9a2f2a;
  --accent-hover: #7f231f;
  --accent-ink: #fffaf2;
  --crimson: #9a2f2a;
  --hairline: rgba(38, 23, 20, 0.14);
  --control-bg: rgba(38, 23, 20, 0.04);
  --control-border: rgba(38, 23, 20, 0.18);
  --input-bg: #fffaf1;
  --input-ink: #261714;
  --pill-active-bg: #261714;
  --pill-active-ink: #fffaf1;
  --compare-highlight: #8d2520;
  --header-scrolled: rgba(239, 227, 206, 0.94);
  --door-empty-bg: rgba(38, 23, 20, 0.04);
  --door-empty-border: rgba(168, 113, 25, 0.42);
  --door-filled-bg: #7a2326;
  --door-filled-flap: #61191c;
  --door-filled-ink: #fff6e8;
  --door-opened-bg: #fffcf6;
  --door-opened-ink: #261714;
}

/* Theme 3: Midnight Starlight */
body[data-theme="midnight"] {
  --bg: #081324;
  --bg-top: #101f38;
  --candle-glow: rgba(230, 185, 92, 0.15);
  --ink: #f1f4fa;
  --ink-muted: #b7c2d9;
  --brass: #b4c8e2;
  --accent: #ac293b;
  --accent-hover: #8f2032;
  --accent-ink: #ffffff;
  --crimson: #ac293b;
  --hairline: rgba(245, 241, 232, 0.14);
  --control-bg: rgba(245, 241, 232, 0.06);
  --control-border: rgba(245, 241, 232, 0.18);
  --input-bg: rgba(9, 15, 31, 0.72);
  --input-ink: #f1f4fa;
  --pill-active-bg: #f1f4fa;
  --pill-active-ink: #111c36;
  --compare-highlight: #bed2ef;
  --header-scrolled: rgba(12, 20, 38, 0.92);
  --door-empty-bg: rgba(245, 241, 232, 0.05);
  --door-empty-border: rgba(189, 207, 234, 0.44);
  --door-filled-bg: #e3eaf4;
  --door-filled-flap: #b7c5d8;
  --door-filled-ink: #18233e;
  --door-opened-bg: #f7f9fc;
  --door-opened-ink: #14203b;
}

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

::selection {
  background: var(--brass);
  color: #161108;
}

html {
  scroll-behavior: smooth;
  scrollbar-color: var(--control-border) var(--bg);
  scrollbar-width: thin;
}

h1, h2 {
  text-wrap: balance;
}

input, textarea {
  caret-color: var(--brass);
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: 1.55;
  color: var(--ink);
  background: radial-gradient(ellipse 90% 55% at 50% 0%, var(--bg-top) 0%, var(--bg) 68%);
  transition: background-color 220ms var(--ease), color 220ms var(--ease);
  overflow-x: clip;
}

a {
  color: inherit;
  text-underline-offset: 4px;
}

button, input, textarea {
  font-family: inherit;
}

.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;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 3px;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid transparent;
  transition: background-color 180ms var(--ease), border-color 180ms var(--ease);
}

.site-header.is-scrolled {
  background: var(--header-scrolled);
  border-bottom-color: var(--hairline);
  backdrop-filter: blur(10px);
}

.header-inner {
  width: min(1180px, 92%);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 1.32rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-decoration: none;
  white-space: nowrap;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: nowrap;
}

.site-nav a,
.nav-link-btn {
  background: none;
  border: 0;
  padding: 6px 2px;
  color: var(--ink-muted);
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: color 150ms var(--ease);
}

.site-nav a:hover,
.nav-link-btn:hover {
  color: var(--ink);
}

/* Main */
main {
  width: min(1180px, 92%);
  margin: 0 auto;
  padding-bottom: 56px;
}

/* Opening Hero + Frameless 3D Book Stage */
.hero-stage {
  padding-top: clamp(8px, 1.8vw, 18px);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.hero-copy {
  max-width: 780px;
}

.hero-copy h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 3.8vw, 3.25rem);
  font-weight: 700;
  line-height: 1.04;
  letter-spacing: -0.025em;
}

.hero-sub {
  margin: 8px auto 0;
  max-width: 58ch;
  font-size: var(--text-body);
  color: var(--ink-muted);
}

/* Translucent Inline Builder Strip (no clunky card box) */
.builder-strip {
  margin-top: 16px;
  width: min(860px, 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px;
  border-radius: var(--radius-md);
  background: var(--control-bg);
  border: 1px solid var(--control-border);
}

.builder-field {
  flex: 1 1 220px;
  min-width: 180px;
}

.builder-field input {
  width: 100%;
  min-height: 42px;
  padding: 8px 14px;
  border: 1px solid var(--control-border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--input-ink);
  font-size: var(--text-body);
}

.builder-field input::placeholder {
  color: var(--ink-muted);
  opacity: 0.78;
}

.theme-switcher {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.12);
  border: 1px solid var(--hairline);
}

.theme-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 11px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-muted);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background-color 150ms var(--ease), color 150ms var(--ease);
}

.theme-option.is-active {
  background: var(--pill-active-bg);
  color: var(--pill-active-ink);
}

.swatch {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  display: inline-block;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.swatch-evergreen { background: #1c4c3c; }
.swatch-cranberry { background: #8f2d2c; }
.swatch-midnight { background: #1e325c; }

.primary-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 9px 20px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: var(--text-body);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 160ms var(--ease), transform 160ms var(--ease);
}

.primary-cta:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.secondary-btn,
.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--control-border);
  border-radius: var(--radius-sm);
  background: var(--control-bg);
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease);
}

.secondary-btn:hover,
.secondary-link:hover {
  border-color: var(--brass);
}

.status-line {
  margin: 8px 0 0;
  min-height: 20px;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--brass);
}

.status-line:empty {
  display: none;
}

/* Frameless Atelier Stage (zero enclosing card box) */
.atelier-stage {
  width: 100%;
  margin-top: 14px;
  text-align: left;
}

.stage-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding-bottom: 6px;
}

.stage-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 2vw, 1.55rem);
  font-weight: 600;
  line-height: 1.15;
}

.stage-caption {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.book3d-stage {
  position: relative;
}

.book3d-canvas-wrap {
  position: relative;
  width: 100%;
  height: clamp(325px, 41vh, 410px);
  background: radial-gradient(ellipse 68% 62% at 50% 56%, var(--candle-glow), transparent 72%);
}

.book3d-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: pan-y;
}

.book3d-hint {
  margin: 2px 0 10px;
  font-size: var(--text-sm);
  color: var(--ink-muted);
  text-align: center;
}

/* Unified Slim Control Rail */
.atelier-rail {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 12px;
  border-top: 1px solid var(--hairline);
}

.spread-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.spread-tabs {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border-radius: var(--radius-sm);
  background: var(--control-bg);
  border: 1px solid var(--hairline);
  flex-wrap: wrap;
}

.spread-tab,
.view-mode-btn {
  min-height: 34px;
  padding: 5px 11px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-muted);
  font-size: var(--text-sm);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 150ms var(--ease), color 150ms var(--ease);
}

.spread-tab.is-active,
.view-mode-btn.is-active {
  background: var(--pill-active-bg);
  color: var(--pill-active-ink);
}

.rail-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.view-switcher {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border-radius: var(--radius-sm);
  background: var(--control-bg);
  border: 1px solid var(--hairline);
}

.rail-btn {
  min-height: 38px;
  padding: 6px 12px;
  border: 1px solid var(--control-border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 150ms var(--ease), background-color 150ms var(--ease);
}

.rail-btn:hover {
  border-color: var(--brass);
  background: var(--control-bg);
}

/* Frameless 24-Door Postal Grid */
.door-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: clamp(10px, 1.3vw, 14px);
  padding: 16px 0 18px;
}

.door-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  aspect-ratio: 1.08;
  min-height: 76px;
  padding: 10px 11px 9px;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  font-variant-numeric: tabular-nums;
  transition: transform 180ms var(--ease), box-shadow 180ms var(--ease), border-color 180ms var(--ease);
}

.door-card:hover {
  transform: translateY(-2px);
}

.door-card.is-empty {
  background: var(--door-empty-bg);
  border: 1.5px dashed var(--door-empty-border);
  color: var(--ink);
}

.door-card.is-filled,
.door-card.is-ready {
  background: var(--door-filled-bg);
  border: 1px solid rgba(0, 0, 0, 0.16);
  color: var(--door-filled-ink);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.22);
}

.door-card.is-filled::before,
.door-card.is-ready::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 44%;
  background: var(--door-filled-flap);
  clip-path: polygon(0 0, 100% 0, 50% 88%);
  border-top-left-radius: 9px;
  border-top-right-radius: 9px;
  pointer-events: none;
}

.door-card.is-ready {
  box-shadow: 0 0 0 2px var(--brass), 0 10px 22px rgba(0, 0, 0, 0.28);
}

.door-card.is-opened {
  background: var(--door-opened-bg);
  border: 1px solid var(--brass);
  color: var(--door-opened-ink);
}

.door-top {
  position: relative;
  z-index: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.door-num {
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 1.8vw, 1.45rem);
  font-weight: 700;
  line-height: 1;
}

.door-seal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.door-foot {
  position: relative;
  z-index: 1;
  width: 100%;
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@keyframes door-wiggle {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px) rotate(-1deg); }
  75% { transform: translateX(4px) rotate(1deg); }
}

.door-card.is-wiggling {
  animation: door-wiggle 260ms var(--ease);
}

/* Below-the-Fold Editorial Sections */
.editorial-section {
  margin-top: clamp(56px, 7vw, 88px);
}

.editorial-section h2 {
  margin: 0 0 26px;
  font-family: var(--font-display);
  font-size: var(--text-h2);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.02em;
}

.steps-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 28px;
}

.step-item {
  padding-top: 18px;
  border-top: 1px solid var(--brass);
}

.step-item h3 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: var(--text-body);
  font-weight: 700;
}

.step-item p {
  margin: 0;
  font-size: var(--text-body);
  color: var(--ink-muted);
  max-width: 58ch;
}

/* Frameless Comparison Ledger */
.table-wrap {
  overflow-x: auto;
}

.compare-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: var(--text-sm);
}

.compare-table th,
.compare-table td {
  padding: 15px 14px;
  border-bottom: 1px solid var(--hairline);
  vertical-align: top;
}

.compare-table th {
  font-weight: 700;
  color: var(--ink);
  border-top: 1px solid var(--brass);
}

.compare-table td {
  color: var(--ink-muted);
}

.compare-table td:first-child {
  color: var(--ink);
  font-weight: 600;
}

.compare-table td:nth-child(2),
.compare-table th:nth-child(2) {
  font-weight: 600;
  color: var(--compare-highlight);
}

/* Full-Bleed Cotton Paper Band for Note Ideas */
.paper-band {
  margin-top: clamp(56px, 7vw, 88px);
  margin-inline: calc(50% - 50vw);
  padding: clamp(44px, 6vw, 68px) calc(50vw - 50%);
  background: #f4ead8;
  color: #241714;
}

.paper-band .editorial-section {
  margin-top: 0;
}

.section-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.section-head-row h2 {
  margin: 0;
}

.segmented-tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius-sm);
  background: rgba(36, 23, 20, 0.06);
  border: 1px solid rgba(36, 23, 20, 0.14);
}

.tab-btn {
  min-height: 36px;
  padding: 6px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #4f3a33;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background-color 150ms var(--ease), color 150ms var(--ease);
}

.tab-btn.is-active {
  background: #8f2d2c;
  color: #fff9ef;
}

.ideas-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 32px;
}

.idea-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 0;
  border-top: 1px solid rgba(36, 23, 20, 0.16);
}

.idea-card p {
  margin: 0;
  font-size: var(--text-body);
  color: #241714;
}

.idea-copy-btn {
  min-height: 34px;
  padding: 5px 12px;
  border: 1px solid rgba(36, 23, 20, 0.24);
  border-radius: 6px;
  background: #fbf4e7;
  color: #241714;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Frameless Hairline FAQ */
.faq-list {
  border-top: 1px solid var(--hairline);
}

.faq-item {
  border-bottom: 1px solid var(--hairline);
  padding: 16px 0;
}

.faq-item summary {
  cursor: pointer;
  font-weight: 600;
  font-size: var(--text-body);
  color: var(--ink);
}

.faq-item p {
  margin: 10px 0 0;
  color: var(--ink-muted);
  font-size: var(--text-body);
  max-width: 65ch;
}

/* Room View */
.room-stage {
  padding-top: clamp(20px, 3.5vw, 36px);
}

.room-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}

.room-header h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3.1rem);
  font-weight: 700;
  line-height: 1.06;
  letter-spacing: -0.025em;
}

.room-sub {
  margin: 8px 0 0;
  color: var(--ink-muted);
  max-width: 58ch;
}

.room-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.room-stage .atelier-stage {
  margin-top: 22px;
}

.room-footer-tools {
  margin-top: 22px;
  display: flex;
  justify-content: flex-end;
}

.danger-link {
  background: none;
  border: 0;
  padding: 8px 4px;
  color: var(--ink-muted);
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

/* Privacy Policy */
.policy-page {
  max-width: 68ch;
  padding: 40px 0 56px;
}

.policy-page h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3rem);
  margin: 0 0 18px;
}

.policy-page h2 {
  font-family: var(--font-display);
  font-size: var(--text-h2);
  margin: 28px 0 10px;
}

.policy-page p {
  color: var(--ink-muted);
}

/* Footer */
.site-footer {
  width: min(1180px, 92%);
  margin: 16px auto 0;
  padding: 24px 0 40px;
  border-top: 1px solid var(--hairline);
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.footer-inner p {
  margin: 0;
}

.footer-links {
  display: flex;
  gap: 18px;
}

/* Dialogs */
.keepsake-dialog {
  width: min(92vw, 520px);
  padding: 0;
  max-height: 90dvh;
  overflow-y: auto;
  border: 1px solid rgba(255, 245, 224, 0.22);
  border-radius: var(--radius-lg);
  background: #e8edf5;
  color: #17283f;
  box-shadow: 0 28px 64px rgba(0, 0, 0, 0.45);
}

.keepsake-dialog::backdrop {
  background: rgba(7, 15, 14, 0.72);
  backdrop-filter: blur(5px);
}

.dialog-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 22px;
  border-bottom: 1px solid rgba(36, 23, 20, 0.12);
}

.dialog-top h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 700;
}

.dialog-close {
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid rgba(36, 23, 20, 0.2);
  border-radius: var(--radius-sm);
  background: #d6e1ef;
  color: #17283f;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
}

.envelope3d-wrap {
  width: 100%;
  height: 224px;
  background: #101e35;
}

.envelope3d-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.seal-svg {
  width: 1.15em;
  height: 1.15em;
  display: block;
}

.wax-seal-orb .seal-svg {
  width: 34px;
  height: 34px;
}

.door-seal .seal-svg,
.letter-seal .seal-svg,
.sticker-btn .seal-svg {
  width: 20px;
  height: 20px;
}

.letter-seal {
  display: inline-flex;
  align-items: center;
  color: #9e253a;
}

/* Hide redundant 2D orb when WebGL 3D envelope is active */
.keepsake-dialog.has-3d-envelope #unwrap-seal-icon {
  display: none;
}

.unwrap-stage,
.locked-stage,
.success-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 22px 24px 24px;
  gap: 14px;
}

.unwrap-stage .primary-cta,
.success-stage .primary-cta,
.write-form .primary-cta {
  background: #9e253a;
  color: #fffaf2;
}

.unwrap-stage .primary-cta:hover,
.success-stage .primary-cta:hover,
.write-form .primary-cta:hover {
  background: #7f231f;
}

.wax-seal-orb {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 35% 30%, #c6453e, #8d231e);
  color: #fff7e6;
}

.wax-seal-orb.is-locked {
  background: radial-gradient(circle at 35% 30%, #6b635a, #423c36);
}

.unwrap-hint,
.locked-message,
.success-msg {
  margin: 0;
  font-size: var(--text-body);
  color: #34475d;
  max-width: 36ch;
}

.unwrap-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-top: 4px;
}

.quiet-link {
  background: none;
  border: 0;
  padding: 6px 12px;
  color: #405269;
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

.letter-sheet {
  padding: 20px 24px 24px;
  background:
    repeating-linear-gradient(
      to bottom,
      #f5f8fc 0px,
      #f5f8fc 31px,
      rgba(73, 101, 142, 0.14) 31px,
      rgba(73, 101, 142, 0.14) 32px
    );
}

.letter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.letter-date {
  font-size: var(--text-sm);
  font-weight: 700;
  color: #912038;
}

.letter-body {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.24rem;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #17283f;
}

.letter-signature {
  margin: 16px 0 0;
  font-size: var(--text-body);
  font-weight: 700;
  color: #912038;
}

.letter-actions {
  margin-top: 18px;
  display: flex;
  justify-content: flex-end;
}

.letter-actions .secondary-btn,
.success-actions .secondary-btn {
  background: #d6e1ef;
  color: #17283f;
  border-color: rgba(36, 23, 20, 0.22);
}

.write-form {
  padding: 18px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 700;
  color: #233950;
  margin-bottom: 6px;
}

.label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.char-count {
  font-size: var(--text-sm);
  color: #465a73;
  font-variant-numeric: tabular-nums;
}

.sticker-picker {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 6px;
}

.sticker-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid rgba(36, 23, 20, 0.18);
  border-radius: 8px;
  background: #ffffff;
  color: #233950;
  cursor: pointer;
  transition: transform 140ms var(--ease), border-color 140ms var(--ease), background-color 140ms var(--ease);
}

.sticker-btn.is-selected {
  border-color: #9e253a;
  background: #fbeae6;
  color: #9e253a;
  transform: scale(1.06);
}

.write-form input[type="text"],
.write-form textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(36, 23, 20, 0.24);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: #17283f;
  font-size: var(--text-body);
}

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: var(--text-sm);
  color: #34475d;
  cursor: pointer;
}

.prompt-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

.full-width {
  width: 100%;
}

.success-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 6px;
}

.dialog-intro {
  margin: 14px 24px 0;
  font-size: var(--text-sm);
  color: #405269;
}

.my-cal-list {
  display: grid;
  gap: 10px;
  padding: 14px 24px 24px;
}

.my-cal-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(36, 23, 20, 0.16);
  background: #ffffff;
}

.my-cal-item .secondary-link {
  background: #d6e1ef;
  color: #17283f;
  border-color: rgba(36, 23, 20, 0.22);
}

.my-cal-meta {
  display: flex;
  flex-direction: column;
}

.my-cal-meta strong {
  font-size: var(--text-body);
}

.my-cal-meta span {
  font-size: var(--text-sm);
  color: #465a73;
}

/* Mobile Layout (<= 760px) */
@media (max-width: 760px) {
  .header-inner {
    padding: 12px 0;
    gap: 10px;
  }

  .brand {
    font-size: 1.12rem;
  }

  .site-nav {
    gap: 10px;
  }

  .site-nav a {
    display: none;
  }

  .builder-strip {
    flex-direction: column;
    align-items: stretch;
  }

  .builder-field {
    flex: 0 0 auto;
    width: 100%;
    min-width: 0;
  }

  .theme-switcher {
    justify-content: space-between;
  }

  .theme-option {
    flex: 1 1 0;
    justify-content: center;
    padding: 6px 6px;
  }

  .book3d-canvas-wrap {
    height: 300px;
  }

  .atelier-rail {
    flex-direction: column;
    align-items: stretch;
  }

  .spread-nav {
    justify-content: space-between;
  }

  .spread-tabs {
    order: -1;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
  }

  .spread-tab {
    padding: 7px 6px;
    font-size: 0.8125rem;
    text-align: center;
  }

  .rail-actions {
    width: 100%;
    margin-left: 0;
    justify-content: space-between;
  }

  .door-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
  }

  .door-card {
    aspect-ratio: 0.96;
    min-height: 68px;
    padding: 8px 7px;
  }

  .door-foot {
    font-size: 0.8125rem;
    letter-spacing: -0.015em;
  }

  .envelope3d-wrap {
    height: 190px;
  }

  .steps-grid,
  .ideas-grid {
    grid-template-columns: 1fr;
  }

  .sticker-picker {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* Winter-night paper theatre. Keep the canvas transparent so its folded pages
   and their actual shadows sit directly against the illustrated backdrop. */
body[data-theme="midnight"] {
  background: #081324;
  isolation: isolate;
}
body[data-theme="midnight"]::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  z-index: -1;
  height: max(96svh, 61vw);
  pointer-events: none;
  background: url("/art/night-theater.webp") center top / cover no-repeat;
  mask-image: linear-gradient(black 72%, transparent);
}
.header-inner { width: min(1530px, 93%); padding-block: 18px; }
.brand, .nav-link-btn { color: var(--ink); font: 500 1.3rem/1.3 var(--font-display); }
.hero-stage { padding-top: clamp(12px, 3vh, 40px); }
.hero-copy { max-width: 100%; }
.hero-copy h1 {
  font-size: clamp(2.75rem, 6.3vw, 6.6rem);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -.045em;
}
#start-calendar {
  margin-top: 14px;
  padding: 8px 25px;
  font: 600 clamp(1.05rem, 1.6vw, 1.45rem)/1.3 var(--font-display);
  background: #a7283b;
  color: #fff6f6;
  border: 1px solid #c34b59;
  border-radius: 10px;
}
#start-calendar:hover { background: #912236; }
.hero-stage .atelier-stage { margin-top: 0; }
.book3d-canvas-wrap { background: none; }
.hero-stage .book3d-canvas-wrap { height: clamp(370px, 64svh, 780px); }
.hero-stage .atelier-rail { justify-content: center; border: 0; padding: 0 0 34px; gap: 22px; }
.hero-stage .rail-actions { margin-left: 0; }
.hero-stage .spread-nav, .hero-stage .view-switcher {
  padding: 5px;
  border-radius: 12px;
  border: 1px solid var(--control-border);
  background: var(--control-bg);
}
.hero-stage .rail-btn { min-height: 34px; padding: 5px 12px; }
.spread-picker {
  min-height: 34px;
  padding: 0 8px;
  background: var(--bg);
  color: var(--ink);
  border: 0;
  font: 500 1rem var(--font-display);
  cursor: pointer;
}
.hero-stage .door-grid { margin-block: 28px; }
#create-dialog .builder-strip {
  display: grid;
  width: 100%;
  margin: 0;
  padding: 21px;
  border: 0;
  background: transparent;
  gap: 14px;
}
#create-dialog .builder-field input, #create-dialog .theme-switcher {
  color: #17283f;
  background: #fff;
  border-color: #9eacc0;
}
#create-dialog .builder-field input::placeholder { color: #596a80; }
#create-dialog .theme-option { color: #455875; }
#create-dialog .theme-option.is-active { background: #182c48; color: #fff; }
#create-dialog .status-line { color: #892336; margin: 0 22px 16px; }
#door-dialog .dialog-top { background: #132641; color: #f2f5fb; border: 0; }
#door-dialog .dialog-close { background: #203959; color: #e8eff8; border-color: #5b708d; }
.unwrap-stage, .locked-stage, .success-stage { background: #e8edf5; }
#door-dialog .envelope3d-wrap { height: clamp(180px, 30vh, 290px); }
.paper-band { background: #e7edf5; color: #182943; }
@media (max-width: 760px) {
  body[data-theme="midnight"]::before { height: 75svh; }
  .header-inner { padding-block: 15px; }
  .brand, .nav-link-btn { font-size: 1.05rem; }
  .hero-stage { padding-top: 30px; }
  .hero-copy h1 { font-size: clamp(2.35rem, 8.6vw, 4rem); }
  .hero-stage .book3d-canvas-wrap { height: clamp(235px, 77vw, 470px); }
  .hero-stage .atelier-rail, .hero-stage .rail-actions { width: auto; align-items: center; gap: 8px; }
  .hero-stage .spread-nav { flex-wrap: nowrap; }
}

.envelope3d-canvas { touch-action: none; }
.hero-stage .book3d-stage { margin-block: -1.8vh -1.2vh; }
#start-calendar { position: relative; z-index: 1; }

/* A single bound calendar sheet. The illustrated month header and seven
   weekday columns stay together when the screen narrows. */
.atelier-stage:has(.door-grid:not([hidden])) {
  display: flex;
  flex-direction: column;
}
.atelier-stage:has(.door-grid:not([hidden])) .atelier-rail {
  order: -1;
  align-self: center;
  border: 0;
  padding: 0;
  margin: 12px 0;
}
.atelier-stage:has(.door-grid:not([hidden])) .rail-actions { width: auto; }
.atelier-stage:has(.door-grid:not([hidden])) .stage-meta { padding-block: 0 8px; }
.hero-stage:has(.door-grid:not([hidden])) .hero-copy h1 { font-size: clamp(2.35rem, 4.4vw, 4.8rem); }
.hero-sub { margin-top: 6px; }
.door-grid, .hero-stage .door-grid {
  align-self: center;
  width: min(780px, 100%);
  isolation: isolate;
  overflow: hidden;
  margin: 0 auto;
  padding: 0 clamp(8px, 2vw, 28px) 14px;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0;
  color: #192e47;
  background: #f1f4f9;
  border: 1px solid #b2bfd1;
  border-radius: 8px;
  box-shadow: 0 4px 0 -1px #b9c7d8, 0 8px 0 -3px #8495ad, 0 18px 38px #0005;
}
.calendar-month {
  grid-column: 1 / -1;
  margin-inline: calc(-1 * clamp(8px, 2vw, 28px));
  padding: 12px 5%;
  display: flex;
  flex-direction: column-reverse;
  align-items: start;
  justify-content: center;
  min-height: clamp(92px, 13vh, 142px);
  color: #eef3fc;
  background: #172b48 url("/art/calendar-post-office.webp") right 3% bottom -2px / auto 97% no-repeat;
  border-bottom: 3px solid #a82e42;
}
.calendar-month h2 { font: 500 clamp(2rem, 4vw, 3.7rem)/.98 var(--font-display); margin: 2px 0; letter-spacing: -.05em; }
.calendar-month span { font-size: .82rem; letter-spacing: .2em; color: #c4d5eb; }
.weekday { padding: 8px 1px; color: #53677d; font: 600 .72rem/1 var(--font-sans); text-align: center; }
.door-grid .door-card, .calendar-rest, .calendar-blank {
  border: 0;
  border-top: 1px solid #cad3df;
  border-radius: 0;
}
.door-grid .door-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  aspect-ratio: auto;
  min-height: clamp(48px, 6.1vh, 66px);
  padding: 4px 2px;
  text-align: center;
  color: #1b304b;
  background: transparent;
  box-shadow: none;
}
.door-grid .door-card::before { content: none; }
.door-grid .door-top { justify-content: center; gap: 4px; }
.door-grid .door-num { font: 500 clamp(1.35rem, 2.3vw, 2rem)/1 var(--font-display); }
.door-grid .door-seal { color: #465f80; }
.door-grid .door-seal .seal-svg { width: 13px; height: 13px; }
.door-grid .door-foot { color: #4e6075; font: 500 .72rem/1.1 var(--font-sans); }
.door-grid .door-card.is-ready { background: #e5ecf5; }
.door-grid .door-card.is-ready .door-foot { color: #8c2639; font-weight: 700; }
.door-grid .door-card[aria-current="date"] { box-shadow: inset 0 -3px #a8273d; }
.door-grid .door-card:hover, .door-grid .door-card:focus-visible { background: #dae5f1; transform: none; }
.door-grid .door-card:focus-visible { outline: 2px solid #882a40; outline-offset: -2px; }
.calendar-rest { padding: 10px 2px; color: #7b899a; text-align: center; font: 500 1rem/1.2 var(--font-display); }
@media (max-width: 600px) {
  .hero-stage { padding-top: 14px; }
  .hero-stage:has(.door-grid:not([hidden])) .hero-copy h1 { font-size: clamp(2rem, 8.2vw, 2.8rem); }
  .hero-sub { font-size: .87rem; }
  .calendar-month { min-height: 84px; background-size: 49% auto; background-position: right 2% bottom; }
  .door-grid .door-card { min-height: 48px; }
  .door-grid .door-seal { display: none; }
  .door-grid .door-foot { font-size: .64rem; }
  .calendar-rest { padding-block: 6px; }
}

.book-loading { display: none; }
.book3d-stage[aria-busy="true"] .book-loading {
  display: block;
  position: absolute;
  inset: 40% 0 auto;
  text-align: center;
  color: var(--ink-muted);
}

.gift-copy { color: var(--ink-muted); font-size: .84rem; max-width: 52ch; margin: .45rem auto 0; }
.golden-room .door-grid { border: 3px double #bf9748; }
.golden-room .calendar-month { border-bottom-color: #e1b451; }
#edition { align-self: center; color: #ac7624; }
.door-card[data-wrap="gold"] .door-num { color: #886222; }
.door-card[data-wrap="aurora"] .door-num { color: #45639b; }
#letter-switcher, #wrap-field { font-size: .9rem; }
#wrap-choice, #letter-choice { padding: .4rem; max-width: 100%; }
#cowrite-hint { margin: 0; color: #364963; }

.collector-tools, #collector-pages article { padding: 1.25rem; }
#collector-pages article { color: #192d44; background: #faf8ef; border-top: 1px solid #c1a365; }
#collector-pages article p { white-space: pre-wrap; overflow-wrap: anywhere; }
@media print {
  body:has(#collector-dialog[open]) > :not(#collector-dialog) { display: none !important; }
  #collector-dialog[open] { display: block; position: static; width: auto; max-width: none; height: auto; max-height: none; overflow: visible; margin: 0; border: 0; box-shadow: none; }
  #collector-dialog::backdrop, #collector-dialog .dialog-top, #collector-dialog .collector-tools { display: none; }
  #collector-pages article { break-before: page; }
  #collector-pages article:first-child { break-before: auto; }
}

.footer-links { flex-wrap: wrap; }
.public-form {
  display: grid;
  justify-items: start;
  gap: .75rem;
  padding: 1.5rem 0;
}
.public-form input {
  box-sizing: border-box;
  width: min(100%, 24rem);
  padding: .8rem 1rem;
  border: 1px solid var(--hairline);
  border-radius: .5rem;
  font: inherit;
}
#invite-code, #room-code { letter-spacing: .09em; }
.public-form [role="status"] { margin: 0; }
.guide-table { width: 100%; border-collapse: collapse; }
.guide-table th, .guide-table td {
  text-align: start; vertical-align: top;
  border-bottom: 1px solid var(--hairline); padding: .65rem .3rem;
}
.note-collection ol { list-style: none; padding: 0; }
.note-collection li { padding: 1rem 0; border-bottom: 1px solid var(--hairline); }
.note-collection li p { margin: .4rem 0 .7rem; }
.site-nav .enter-code { display: inline-block; }

#copy-room-code { gap: .4em; }
#create-return-calendar { white-space: normal; overflow-wrap: anywhere; }
