/* ---------- Tokens ---------- */
:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #efede6;
  --text: #17191c;
  --muted: #5a606a;
  --border: #dfdcd2;
  --accent: #0b6b5c;
  --accent-hover: #095548;
  --accent-ink: #ffffff;
  --accent-soft: #e2f0ec;
  --danger: #b3261e;
  --danger-soft: #fbeceb;
  --shadow-sm: 0 1px 2px rgba(23, 25, 28, 0.05);
  --shadow-md: 0 8px 24px -10px rgba(23, 25, 28, 0.18);
  --radius: 16px;
  --radius-sm: 10px;
  --header-h: 64px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0f1113;
  --surface: #171a1d;
  --surface-2: #1f2327;
  --text: #eef0f2;
  --muted: #a2a9b3;
  --border: #2b3036;
  --accent: #4fd1b5;
  --accent-hover: #74dcc5;
  --accent-ink: #06211b;
  --accent-soft: #132f29;
  --danger: #ff9086;
  --danger-soft: #371917;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 10px 28px -12px rgba(0, 0, 0, 0.7);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s var(--ease), color 0.3s var(--ease);
}
main { flex: 1; outline: none; }
[hidden] { display: none !important; }
h1, h2 { font-family: var(--serif); font-weight: 600; line-height: 1.15; letter-spacing: -0.01em; margin: 0; }
h1 { font-size: clamp(2rem, 6vw, 3.25rem); outline: none; }
p { margin: 0; }
a { color: inherit; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  padding: 10px 16px; border-radius: var(--radius-sm);
  background: var(--accent); color: var(--accent-ink); font-weight: 600; text-decoration: none;
  transition: top 0.15s var(--ease);
}
.skip-link:focus { top: 12px; }

.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.wrap.narrow { max-width: 860px; }
.eyebrow {
  font-size: 0.8rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 14px;
}
.lead { font-size: clamp(1.05rem, 2.4vw, 1.2rem); color: var(--muted); margin-top: 16px; max-width: 60ch; }
.lead strong { color: var(--text); }
.hint { font-size: 0.875rem; color: var(--muted); }
.link { color: var(--accent); font-weight: 600; text-underline-offset: 3px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner { height: var(--header-h); display: flex; align-items: center; gap: 16px; }
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--serif); font-size: 1.3rem; font-weight: 600; text-decoration: none;
}
.brand-mark { position: relative; width: 30px; height: 20px; flex: none; }
.brand-mark::before, .brand-mark::after {
  content: ""; position: absolute; top: 0; width: 20px; height: 20px;
  border: 2.5px solid var(--accent); border-radius: 50%;
}
.brand-mark::before { left: 0; }
.brand-mark::after { right: 0; }

.site-nav { display: flex; gap: 4px; margin-left: auto; }
.site-nav a {
  padding: 8px 12px; border-radius: 999px; text-decoration: none;
  font-size: 0.95rem; color: var(--muted);
  transition: color 0.2s var(--ease), background-color 0.2s var(--ease);
}
.site-nav a:hover { color: var(--text); background: var(--surface-2); }
.site-nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); font-weight: 600; }
.header-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px;
  border: 1px solid transparent; border-radius: 50%; background: none; cursor: pointer;
  transition: background-color 0.2s var(--ease), transform 0.3s var(--ease);
}
.icon-btn:hover { background: var(--surface-2); }
#theme-btn:active { transform: rotate(180deg); }
.menu-btn { display: none; }
.menu-icon { display: grid; gap: 5px; width: 20px; }
.menu-icon span { height: 2px; border-radius: 2px; background: currentColor; transition: transform 0.25s var(--ease), opacity 0.2s; }
.menu-btn[aria-expanded="true"] .menu-icon span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-btn[aria-expanded="true"] .menu-icon span:nth-child(2) { opacity: 0; }
.menu-btn[aria-expanded="true"] .menu-icon span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 820px) {
  .menu-btn { display: inline-grid; }
  .header-actions { margin-left: auto; }
  .site-nav {
    position: absolute; left: 0; right: 0; top: var(--header-h);
    flex-direction: column; gap: 2px; margin: 0; padding: 10px 20px 16px;
    background: var(--bg); border-bottom: 1px solid var(--border); box-shadow: var(--shadow-md);
    display: none;
  }
  .site-nav.is-open { display: flex; animation: drop 0.22s var(--ease); }
  .site-nav a { padding: 13px 14px; border-radius: var(--radius-sm); font-size: 1.05rem; }
}

/* ---------- Pages ---------- */
.page { padding: clamp(40px, 8vw, 88px) 0 clamp(56px, 9vw, 104px); animation: rise 0.45s var(--ease); }
.hero { text-align: left; }
.hero h1 { font-size: clamp(2.4rem, 8vw, 4.5rem); max-width: 14ch; }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }
.btn-row.center { justify-content: center; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 12px 22px; border-radius: 999px;
  border: 1px solid transparent; font-weight: 600; text-decoration: none; cursor: pointer;
  transition: background-color 0.2s var(--ease), border-color 0.2s var(--ease), transform 0.15s var(--ease), box-shadow 0.2s var(--ease), opacity 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--accent-hover); box-shadow: var(--shadow-md); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-small { min-height: 44px; padding: 8px 13px; font-size: 0.85rem; white-space: nowrap; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; transform: none; }

.steps {
  list-style: none; margin: clamp(48px, 8vw, 88px) 0 0; padding: 0;
  display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}
.steps li, .panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow-sm);
}
.steps h2, .panel-title { font-size: 1.25rem; margin-bottom: 8px; }
.steps p, .panel p { color: var(--muted); }
.panel p + p { margin-top: 8px; }
.step-num {
  display: inline-grid; place-items: center; width: 34px; height: 34px; margin-bottom: 16px;
  border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700;
}
.prose > p:not(.eyebrow):not(.lead) { margin-top: 20px; max-width: 65ch; }
.feature-grid { display: grid; gap: 16px; margin-top: 40px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* ---------- Selection form ---------- */
#selection-form { margin-top: 28px; }
.status-bar {
  position: sticky; top: calc(var(--header-h) + 10px); z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px;
  padding: 8px 8px 8px 14px; margin-bottom: 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  transition: border-color 0.25s var(--ease);
}
.status-bar.is-full { border-color: var(--accent); }
.status-bar.nudge { animation: nudge 0.4s var(--ease); }
.status-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.counter { font-weight: 600; font-variant-numeric: tabular-nums; }
.dots { display: flex; gap: 6px; }
.dot {
  width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--border);
  transition: background-color 0.25s var(--ease), border-color 0.25s var(--ease), transform 0.25s var(--ease);
}
.dot.is-on { background: var(--accent); border-color: var(--accent); transform: scale(1.15); }
.limit-msg {
  flex-basis: 100%; padding: 0 8px 4px 0; font-size: 0.9rem; font-weight: 600; color: var(--accent);
  animation: rise 0.3s var(--ease);
}

.options { border: 0; margin: 0; padding: 0; min-width: 0; }
.card-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 600px) { .card-grid { grid-template-columns: 1fr 1fr; } }

.card {
  position: relative; display: flex; align-items: flex-start; gap: 14px;
  min-height: 96px; padding: 18px;
  background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent;
  transition: border-color 0.2s var(--ease), background-color 0.2s var(--ease), box-shadow 0.2s var(--ease), transform 0.2s var(--ease), opacity 0.25s var(--ease);
}
.card input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.card:hover { border-color: var(--muted); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.card:active { transform: scale(0.985); }
.card:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 3px; }
.card-num { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.08em; color: var(--muted); padding-top: 4px; font-variant-numeric: tabular-nums; }
.card-body { flex: 1; min-width: 0; }
.card-title { display: block; font-family: var(--serif); font-size: 1.2rem; font-weight: 600; line-height: 1.25; }
.card-desc { display: block; margin-top: 4px; font-size: 0.925rem; color: var(--muted); }
.card-check {
  position: relative; flex: none; width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--border);
  transition: background-color 0.2s var(--ease), border-color 0.2s var(--ease), transform 0.25s var(--ease);
}
.card-check::after {
  content: ""; position: absolute; left: 8px; top: 4px; width: 6px; height: 11px;
  border: solid var(--accent-ink); border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg) scale(0); transition: transform 0.2s var(--ease);
}
.card.is-selected { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent), var(--shadow-sm); }
.card.is-selected .card-num { color: var(--accent); }
.card.is-selected .card-check { background: var(--accent); border-color: var(--accent); animation: pop 0.3s var(--ease); }
.card.is-selected .card-check::after { transform: rotate(45deg) scale(1); }
.card.is-disabled { opacity: 0.42; cursor: not-allowed; box-shadow: none; transform: none; border-style: dashed; }
.card.is-disabled:hover { border-color: var(--border); }

.section-title { font-size: 1.5rem; margin: 44px 0 16px; }
.field-grid { display: grid; gap: 18px; grid-template-columns: 1fr; }
@media (min-width: 600px) { .field-grid { grid-template-columns: 1fr 1fr; } .field-wide { grid-column: 1 / -1; } }
.field label { display: block; font-weight: 600; margin-bottom: 6px; }
.req { color: var(--danger); }
.optional { font-weight: 400; color: var(--muted); }
.field input, .field textarea {
  width: 100%; min-height: 48px; padding: 12px 14px;
  background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 1rem; /* 16px keeps iOS from zooming on focus */
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.field textarea { resize: vertical; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field [aria-invalid="true"] { border-color: var(--danger); }
.field .hint { margin-top: 6px; text-align: right; }
.field-error { margin-top: 6px; font-size: 0.9rem; font-weight: 600; color: var(--danger); animation: rise 0.25s var(--ease); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.form-actions { justify-content: flex-end; }

.alert { margin-top: 24px; padding: 16px 18px; border-radius: var(--radius-sm); border: 1px solid; animation: rise 0.25s var(--ease); }
.alert-error { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.alert-title { font-weight: 700; }
.alert ul { margin: 6px 0 0; padding-left: 20px; }
.alert a { color: inherit; font-weight: 600; }

#step-review, #step-done, #step-edit { animation: rise 0.4s var(--ease); }
#step-review .panel { margin-top: 28px; }
.summary-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.summary-list li {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--radius-sm);
  font-weight: 600; text-align: left;
}
.summary-list li::before {
  content: ""; flex: none; width: 7px; height: 12px; margin: 0 4px 3px 4px;
  border: solid var(--accent); border-width: 0 2.5px 2.5px 0; transform: rotate(45deg);
}
.summary-dl { margin: 20px 0 0; display: grid; gap: 12px; }
.summary-dl div { display: grid; gap: 2px; }
.summary-dl dt { font-size: 0.8rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.summary-dl dd { margin: 0; white-space: pre-wrap; }

.success { text-align: center; max-width: 520px; margin: 0 auto; }
.success .lead { margin-left: auto; margin-right: auto; }
.success .summary-list { margin: 28px 0 16px; }
.success-mark {
  position: relative; display: inline-block; width: 72px; height: 72px; margin-bottom: 24px;
  border-radius: 50%; background: var(--accent); animation: pop 0.5s var(--ease);
}
.success-mark::after {
  content: ""; position: absolute; left: 26px; top: 15px; width: 17px; height: 32px;
  border: solid var(--accent-ink); border-width: 0 5px 5px 0; transform: rotate(45deg);
}

/* ---------- FAQ ---------- */
.faq { margin-top: 36px; display: grid; gap: 10px; }
.faq details { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); }
.faq summary {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  min-height: 56px; padding: 14px 18px; font-weight: 600; cursor: pointer; list-style: none; border-radius: var(--radius-sm);
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; flex: none; font-size: 1.4rem; line-height: 1; color: var(--accent); transition: transform 0.25s var(--ease); }
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p { padding: 0 18px 18px; color: var(--muted); animation: rise 0.25s var(--ease); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); padding: 36px 0 24px; }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 24px; }
.footer-inner .hint { margin-top: 8px; }
.footer-nav { display: flex; flex-wrap: wrap; gap: 4px 6px; align-content: flex-start; }
.footer-nav a { padding: 10px 12px; border-radius: 999px; text-decoration: none; color: var(--muted); font-size: 0.95rem; }
.footer-nav a:hover { color: var(--text); background: var(--surface-2); }
.footer-base { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }
.noscript { margin: 0; padding: 16px 20px; text-align: center; background: var(--danger-soft); color: var(--danger); font-weight: 600; }

@media (max-width: 440px) {
  .status-bar .dots { display: none; }
  .status-bar { flex-wrap: wrap; }
  .counter { font-size: 0.95rem; }
}
@media (max-width: 599px) {
  .form-actions .btn, .hero .btn { flex: 1 1 100%; }
  .footer-nav { margin-left: -12px; }
}

/* ---------- Motion ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes drop { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(0.6); } 60% { transform: scale(1.15); } 100% { transform: scale(1); } }
@keyframes nudge { 0%, 100% { transform: none; } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

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