:root {
  --ink: #1c2333;
  --ink-soft: #4a5268;
  --paper: #faf7f2;
  --card: #ffffff;
  --line: #e4ded3;
  --accent: #1f4e79;
  --accent-deep: #163a5b;
  --accent-warm: #b4622d;
  --ok: #2e7d54;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(28, 35, 51, 0.07);
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Public Sans", -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16.5px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
}

.container { max-width: 960px; margin: 0 auto; padding: 0 24px; }
.container.narrow { max-width: 720px; }

a { color: var(--accent); }

/* ---------- header ---------- */
.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  padding-bottom: 14px;
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand-mark { font-size: 1.5rem; color: var(--accent); }
.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: 0.01em;
}
.privacy-chip {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ok);
  background: #edf6f1;
  border: 1px solid #cfe6da;
  border-radius: 999px;
  padding: 5px 13px;
  white-space: nowrap;
}

/* ---------- views ---------- */
.view { display: none; padding: 56px 0 80px; }
.view.active { display: block; }

h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.9rem, 4.5vw, 2.75rem);
  line-height: 1.18;
  margin: 0 0 20px;
}
h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.45rem;
  margin: 0 0 6px;
}
h3 { font-family: var(--font-display); font-weight: 600; }

.lede { font-size: 1.13rem; color: var(--ink-soft); margin-bottom: 32px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 30px;
  margin-bottom: 32px;
}
.info-card h2 { font-size: 1.2rem; }
.info-card ul { margin: 14px 0 0; padding-left: 20px; }
.info-card li { margin-bottom: 12px; }
.info-card li:last-child { margin-bottom: 0; }

.time-note { color: var(--ink-soft); font-size: 0.9rem; margin-top: 12px; }

/* ---------- sources page ---------- */
.back-link { font-size: 0.92rem; margin: 0 0 18px; }
.info-card p { margin: 14px 0 0; }
.info-card p:first-of-type { margin-top: 10px; }

/* ---------- buttons ---------- */
.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1rem;
  border-radius: 10px;
  padding: 11px 22px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
}
.btn:active { transform: translateY(1px); }
a.btn { display: inline-block; text-decoration: none; }
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-deep); }
.btn-lg { font-size: 1.1rem; padding: 14px 30px; }
.btn-ghost {
  background: transparent;
  color: var(--accent);
  border-color: var(--line);
}
.btn-ghost:hover { background: #f1ede5; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

/* ---------- progress ---------- */
.progress { margin-bottom: 36px; }
.progress-bar {
  height: 6px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 25%;
  background: linear-gradient(90deg, var(--accent), var(--accent-warm));
  border-radius: 999px;
  transition: width 0.3s ease;
}
.progress-steps {
  display: flex;
  justify-content: space-between;
  list-style: none;
  padding: 10px 2px 0;
  margin: 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
}
.progress-steps li.current { color: var(--accent); font-weight: 700; }
.progress-steps li.done { color: var(--ok); }

/* ---------- form ---------- */
fieldset.step {
  display: none;
  border: none;
  padding: 0;
  margin: 0;
}
fieldset.step.active { display: block; animation: fadein 0.25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

legend { padding: 0; }
.step-hint { color: var(--ink-soft); margin: 4px 0 26px; }

form label {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 18px;
}
input[type="text"], input[type="email"], input[type="tel"], textarea, select {
  display: block;
  width: 100%;
  margin-top: 6px;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 13px;
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
textarea { resize: vertical; }
input.invalid, textarea.invalid { border-color: #c0392b; outline-color: #c0392b; }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 560px) { .row { grid-template-columns: 1fr; } }

.req {
  font-weight: 500;
  font-size: 0.78rem;
  color: var(--accent-warm);
  margin-left: 6px;
}
.opt {
  font-weight: 500;
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin-left: 6px;
}
.fine-print { font-size: 0.85rem; color: var(--ink-soft); }

.group { margin-bottom: 24px; }
.group-label { display: block; font-weight: 600; font-size: 0.95rem; margin-bottom: 10px; }

/* Conditional follow-up questions, revealed in step 3 by the checked bases/actions. */
.followups {
  margin: 4px 0 24px;
  padding: 18px 18px 2px;
  border-left: 3px solid var(--accent);
  background: #f7f4ee;
  border-radius: 0 8px 8px 0;
}
.followups-heading {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink-soft);
  margin: 0 0 16px;
}
.checks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 6px 14px;
}
.check {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 500;
  font-size: 0.94rem;
  margin-bottom: 0;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.check:hover { background: #f1ede5; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); margin: 0; flex-shrink: 0; }
.check.standalone { margin-bottom: 14px; }

.deadline-note {
  background: #fdf3e7;
  border: 1px solid #f0d9bc;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 0.92rem;
  margin: 0 0 22px;
}

.nav-buttons {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-top: 34px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.nav-buttons .btn-primary, .nav-buttons #submit-btn { margin-left: auto; }

/* ---------- review ---------- */
.review { margin-bottom: 24px; }
.review dl {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 8px 18px;
  margin: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 26px;
}
.review dt { font-weight: 700; font-size: 0.88rem; color: var(--ink-soft); }
.review dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 560px) { .review dl { grid-template-columns: 1fr; gap: 2px 0; } .review dd { margin-bottom: 12px; } }

.privacy-reminder {
  font-size: 0.93rem;
  padding: 16px 20px;
  margin-bottom: 0;
  background: #edf6f1;
  border-color: #cfe6da;
}

/* ---------- result ---------- */
.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 22px;
}
.result-head h2 { margin: 0; }
.result-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.result-actions[hidden] { display: none; }

.letter {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.02rem;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 48px 56px;
  min-height: 300px;
  margin: 0 0 30px;
}
@media (max-width: 640px) { .letter { padding: 28px 22px; } }

.letter.streaming::after {
  content: "▋";
  animation: blink 1s step-end infinite;
  color: var(--accent);
}
@keyframes blink { 50% { opacity: 0; } }

#retry-btn { margin-bottom: 30px; }

.next-steps ol { margin: 10px 0 0; padding-left: 22px; }
.next-steps li { margin-bottom: 10px; }

/* ---------- footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 28px 0 40px;
  font-size: 0.86rem;
  color: var(--ink-soft);
}
.footer-feedback { margin: 14px 0 0; }
.footer-feedback .btn { padding: 8px 16px; font-size: 0.9rem; }

/* ---------- feedback modal ---------- */
.feedback-dialog {
  width: min(92vw, 460px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(28, 35, 51, 0.22);
  background: var(--card);
  color: var(--ink);
  padding: 28px 30px;
}
.feedback-dialog::backdrop { background: rgba(28, 35, 51, 0.45); }
.feedback-dialog h2 { font-size: 1.3rem; margin-bottom: 4px; }
.feedback-intro { color: var(--ink-soft); margin: 0 0 16px; }
.feedback-privacy {
  font-size: 0.88rem;
  background: #fdf3e7;
  border: 1px solid #f0d9bc;
  border-radius: 8px;
  padding: 12px 14px;
  margin: 0 0 20px;
}
.feedback-status { font-size: 0.9rem; margin: 2px 0 14px; }
.feedback-status.error { color: #c0392b; }
.feedback-status.ok { color: var(--ok); }
.feedback-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 4px;
}

/* ---------- print: letter only ---------- */
@media print {
  .site-header, .site-footer, .result-head, .next-steps { display: none !important; }
  .view { display: none !important; padding: 0; }
  #result { display: block !important; }
  .letter { border: none; box-shadow: none; padding: 0; }
  body { background: #fff; }
}
