:root {
  --bg: #070a0f;
  --surface: #0d1117;
  --surface2: #111820;
  --text: #f0ece6;
  --text2: #a09890;
  --muted: #7a7570;
  --accent: #d70913;
  --accent-dim: rgba(215, 9, 19, 0.12);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.15);
  --radius: 12px;
}
html.light {
  --bg: #fdf9f3;
  --surface: #f0ece6;
  --surface2: #e8e4de;
  --text: #1c1c18;
  --text2: #625e59;
  --muted: #9a9490;
  --accent-dim: rgba(215, 9, 19, 0.07);
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.15);
}

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

body {
  font-family: "Cabin", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  transition: background 0.3s, color 0.3s;
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

.hidden { display: none !important; }

.screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 72px 1.25rem 48px;
}

/* ── Fixed Controls ── */
#backBtn {
  position: fixed; top: 16px; left: 16px; z-index: 200;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); display: flex; align-items: center; justify-content: center;
  text-decoration: none; transition: border-color 0.2s, color 0.2s;
}
#backBtn:hover { border-color: var(--accent); color: var(--accent); }

#themeToggle {
  position: fixed; top: 16px; right: 16px; z-index: 200;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: border-color 0.2s, color 0.2s;
}
#themeToggle:hover { border-color: var(--accent); color: var(--accent); }

/* ── Form Container ── */
.form-container { width: 100%; max-width: 480px; }
.form-container h2 {
  font-family: "Ubuntu", sans-serif;
  font-size: 26px; font-weight: 500; margin-bottom: 6px;
}
.hint { font-size: 14px; color: var(--text2); margin-bottom: 24px; line-height: 1.55; }
.hint strong { color: var(--text); }

.input-group { margin-bottom: 20px; }
.input-group label {
  display: block; font-size: 11px; font-weight: 700;
  letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--text2); margin-bottom: 8px;
}
.input-group input[type="text"] {
  width: 100%; padding: 13px 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  font-family: "Cabin", sans-serif; font-size: 15px;
  transition: border-color 0.2s; outline: none;
}
.input-group input[type="text"]:focus { border-color: var(--accent); }

/* ── Buttons ── */
.btn {
  display: block; width: 100%; padding: 15px;
  background: var(--accent); color: #fff;
  border: none; border-radius: var(--radius);
  font-family: "Cabin", sans-serif; font-size: 15px; font-weight: 700;
  cursor: pointer; transition: opacity 0.2s; margin-bottom: 12px;
  text-align: center; text-decoration: none; letter-spacing: 0.3px;
}
.btn:hover:not(:disabled) { opacity: 0.87; }
.btn:disabled { opacity: 0.35; cursor: default; }

.btn-secondary {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { border-color: var(--border-strong); opacity: 1; }

.btn-back {
  display: block; width: 100%; background: transparent; color: var(--text2);
  border: none; font-family: "Cabin", sans-serif; font-size: 14px; font-weight: 500;
  cursor: pointer; padding: 8px 0; text-align: center; margin-top: 4px;
}
.btn-back:hover { color: var(--text); }

/* ── Welcome ── */
.welcome-inner {
  display: flex; flex-direction: column; align-items: flex-start;
  text-align: left; max-width: 400px; width: 100%; padding-top: 20px;
}
.welcome-illustration { display: none; }
.create-illustration  { display: none; }

.welcome-eyebrow {
  font-size: 10px; font-weight: 700; letter-spacing: 4px;
  text-transform: uppercase; color: var(--accent); margin-bottom: 18px;
}
.welcome-title {
  font-family: "Ubuntu", sans-serif;
  font-size: clamp(30px, 8vw, 48px);
  font-weight: 700; font-style: normal; line-height: 1.15; margin-bottom: 16px;
}
.welcome-sub { font-size: 15px; color: var(--text2); margin-bottom: 36px; line-height: 1.65; }
.welcome-stats {
  display: flex; gap: 0; margin-bottom: 40px;
  padding: 16px 0; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); width: 100%;
}
.welcome-stat { display: flex; flex-direction: column; align-items: center; flex: 1; text-align: center; padding: 4px 8px; }
.welcome-stat-num {
  font-family: "Ubuntu", sans-serif; font-size: 26px;
  font-weight: 700; color: var(--text); line-height: 1; margin-bottom: 4px;
}
.welcome-stat-lbl { font-size: 11px; color: var(--text2); text-transform: uppercase; letter-spacing: 1px; }
.welcome-divider { width: 1px; background: var(--border); align-self: stretch; }
.welcome-btns { width: 100%; }

/* ── Share ── */
.share-field {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 4px 4px 4px 14px; margin-bottom: 8px;
}
.share-field input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font-family: "Cabin", sans-serif; font-size: 13px; min-width: 0;
}
.btn-copy {
  background: var(--accent); color: #fff; border: none;
  padding: 10px 14px; border-radius: 8px; font-size: 13px;
  font-weight: 700; cursor: pointer; flex-shrink: 0;
  font-family: "Cabin", sans-serif; transition: opacity 0.2s;
}
.btn-copy:hover { opacity: 0.85; }
.copy-ok { font-size: 12px; color: #2ecc71; margin-bottom: 10px; display: none; }
.code-details { margin-top: 12px; }
.code-details summary { font-size: 13px; color: var(--text2); cursor: pointer; margin-bottom: 8px; }
.code-details textarea {
  width: 100%; padding: 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text2); font-family: monospace; font-size: 11px;
  resize: none; outline: none;
}

/* ── Sections List ── */
.sections-list { display: flex; flex-direction: column; gap: 14px; margin-bottom: 24px; }

.section-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 18px 14px;
  transition: border-color 0.2s;
}
.section-card.has-answer { border-color: rgba(215, 9, 19, 0.35); }

.section-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
}
.section-num {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.section-label {
  font-size: 11px; font-weight: 700; letter-spacing: 1.2px;
  text-transform: uppercase; color: var(--text2);
}
.section-prompt {
  font-size: 14px; color: var(--text); line-height: 1.55; margin-bottom: 12px;
}
.section-input {
  width: 100%; padding: 10px 12px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text);
  font-family: "Cabin", sans-serif; font-size: 14px; line-height: 1.5;
  outline: none; transition: border-color 0.2s;
  resize: vertical; min-height: 72px;
}
.section-input:focus { border-color: var(--accent); }
.section-input::placeholder { color: var(--muted); }

/* ── Reveal Ready ── */
.reveal-ready-block {
  text-align: center; padding: 32px 20px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; margin-bottom: 24px;
}
.reveal-ready-icon {
  font-size: 28px; color: var(--accent); margin-bottom: 14px; line-height: 1;
}
.reveal-ready-block h2 {
  font-family: "Ubuntu", sans-serif; font-size: 24px; font-weight: 500; margin-bottom: 8px;
}
.reveal-ready-sub { font-size: 14px; color: var(--text2); line-height: 1.55; }
.reveal-ready-sub strong { color: var(--text); }

/* ── Reveal / Letter (Scroll) ── */
#revealScreen {
  justify-content: flex-start;
  align-items: center;
  padding-top: 60px;
  padding-bottom: 80px;
}

.letter-container {
  width: 100%; max-width: 540px;
}

.letter-paper {
  position: relative;
  overflow: visible;
  background:
    radial-gradient(ellipse at center, transparent 55%, rgba(140, 90, 15, 0.14) 100%),
    radial-gradient(ellipse at 28% 18%, rgba(255, 250, 220, 0.45) 0%, transparent 55%),
    linear-gradient(175deg, #f5e4b5 0%, #edd8a0 20%, #e5cb88 50%, #d9ba72 80%, #d2b266 100%);
  border: none;
  border-radius: 2px;
  padding: 44px 36px 52px;
  margin-bottom: 44px;
  box-shadow:
    0 10px 40px rgba(0, 0, 0, 0.6),
    0 2px 8px rgba(0, 0, 0, 0.35),
    inset 0 0 60px rgba(160, 105, 20, 0.1);
}

.letter-paper::before,
.letter-paper::after {
  content: '';
  position: absolute;
  left: 7%; right: 7%;
  height: 28px;
  border-radius: 50%;
}

.letter-paper::before {
  top: -14px;
  background: linear-gradient(to bottom, #b8820a, #e0c57a, #d9b96a, #b8820a);
  box-shadow: 0 7px 16px rgba(0, 0, 0, 0.5), 0 2px 5px rgba(0, 0, 0, 0.3);
}

.letter-paper::after {
  bottom: -14px;
  background: linear-gradient(to top, #b8820a, #e0c57a, #d9b96a, #b8820a);
  box-shadow: 0 -7px 16px rgba(0, 0, 0, 0.5), 0 -2px 5px rgba(0, 0, 0, 0.3);
}

.letter-from {
  font-size: 10px; font-weight: 700;
  letter-spacing: 2px; text-transform: uppercase;
  color: #7a5525; margin-bottom: 20px;
}

.letter-divider {
  height: 1px; background: rgba(120, 78, 22, 0.28); margin-bottom: 28px;
}

.letter-body { }

.letter-section { margin-bottom: 26px; }
.letter-section:last-child { margin-bottom: 0; }

.letter-label {
  font-size: 9px; font-weight: 700;
  letter-spacing: 1.8px; text-transform: uppercase;
  color: #9a6e28; margin-bottom: 6px; display: block;
}

.letter-text {
  font-family: "Lora", Georgia, serif;
  font-size: 17px; font-style: italic;
  color: #2c1a0c; line-height: 1.85;
}

.wax-seal {
  width: 50px; height: 50px;
  background: radial-gradient(circle at 38% 33%, #c92a2a, #8b0a0a);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 32px auto 0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.55), inset 0 1px 3px rgba(255, 150, 150, 0.15);
  color: rgba(255, 255, 255, 0.3);
  font-size: 18px;
}

/* ── Constellation animations ── */
@keyframes starFloat {
  0%, 100% { transform: translateY(0) scale(1); }
  50%       { transform: translateY(-14px) scale(1.35); }
}
@keyframes dashFlow { to { stroke-dashoffset: -8; } }
.clines { animation: dashFlow 2.4s linear infinite; }
.cnode  { transform-box: fill-box; transform-origin: center; }
.n1 { animation: starFloat 3.6s ease-in-out 0s    infinite; }
.n2 { animation: starFloat 3.6s ease-in-out 0.4s  infinite; }
.n3 { animation: starFloat 3.6s ease-in-out 0.8s  infinite; }
.n4 { animation: starFloat 3.6s ease-in-out 1.2s  infinite; }
.n5 { animation: starFloat 3.6s ease-in-out 1.6s  infinite; }
.n6 { animation: starFloat 3.6s ease-in-out 2.0s  infinite; }
.n7 { animation: starFloat 3.6s ease-in-out 2.4s  infinite; }
.n8 { animation: starFloat 3.6s ease-in-out 2.8s  infinite; }

/* ── Desktop split layout ── */
@media (min-width: 768px) {
  .screen {
    padding: 72px 1.25rem 48px;
  }

  #welcomeScreen,
  #setupScreen,
  #writeScreen,
  #draftShareScreen,
  #partnerWriteScreen,
  #revealShareScreen {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 5rem;
    padding: 2rem 8%;
  }

  #writeScreen,
  #partnerWriteScreen { align-items: flex-start; padding-top: 5rem; }

  .welcome-inner,
  .form-container {
    flex-shrink: 0; max-width: 460px; width: 100%;
  }

  #writeScreen .form-container,
  #partnerWriteScreen .form-container { max-width: 520px; }

  .welcome-illustration,
  .create-illustration {
    display: flex; flex-shrink: 0;
    align-items: center; justify-content: center;
  }
  .welcome-illustration svg,
  .create-illustration svg { height: min(76vh, 500px); width: auto; display: block; }

  #revealScreen {
    padding: 60px 8% 80px;
    justify-content: flex-start;
    align-items: center;
  }
}
