:root {
  --bg: #f6f2ea;
  --surface: #fffdf8;
  --ink: #2b2620;
  --muted: #7a7064;
  --line: #e4dccd;
  --accent: #6b4f3a;
  --accent-ink: #fffdf8;
  --soft: #efe7da;
  --danger: #a33b2b;
  --ok-bg: #e8efe2;
  --ok-ink: #3c5a2e;
  --serif: "Cormorant Garamond", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, sans-serif;
  --radius: 14px;
  color-scheme: light;
}
/* Light is the default. Dark is opt-in via the header toggle (static/theme.js sets data-theme). */
:root[data-theme="dark"] {
  --bg: #17140f;
  --surface: #211d17;
  --ink: #ece4d6;
  --muted: #a39887;
  --line: #3a332a;
  --accent: #d8b48f;
  --accent-ink: #1b1712;
  --soft: #2b261f;
  --danger: #e0806f;
  --ok-bg: #26301f;
  --ok-ink: #b9d3a6;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 var(--sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; padding-block: 2.5rem 4rem; }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.15; margin: 0 0 .5rem; }
h1 { font-size: clamp(2.2rem, 5vw, 3.2rem); }
h2 { font-size: 1.8rem; }
h3 { font-size: 1.35rem; }
p { margin: 0 0 1rem; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; }
code { background: var(--soft); padding: .1em .35em; border-radius: 4px; word-break: break-all; }

.wrap { width: 100%; max-width: 1040px; margin: 0 auto; padding-inline: 16px; }
.narrow { max-width: 480px; margin: 0 auto; }
.narrow.wide { max-width: 720px; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.tiny { font-size: .78rem; margin: .5rem 0 0; }
.block { display: block; }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: .75rem; color: var(--muted); margin-bottom: .75rem; }
.lede { font-size: 1.15rem; color: var(--muted); max-width: 60ch; }

/* header */
.site-header { border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(6px); position: sticky; top: 0; z-index: 5; }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-block: .9rem; flex-wrap: wrap; }
.brand { font-family: var(--serif); font-size: 1.5rem; font-weight: 600; color: var(--ink); text-decoration: none; }
.brand-mark { color: var(--accent); }
.brand-mark.big { font-size: 3rem; margin: 0; }
nav { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; font-size: .93rem; }
nav a { color: var(--muted); text-decoration: none; }
nav a:hover, nav a[aria-current="page"] { color: var(--ink); }
nav .btn { color: var(--accent-ink); }
.inline { display: inline; margin: 0; }

.site-footer { border-top: 1px solid var(--line); padding-block: 1.5rem; font-family: var(--serif); font-size: 1.1rem; }

/* buttons */
.btn {
  display: inline-block; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  padding: .7rem 1.3rem; border-radius: 999px; font: 500 .95rem var(--sans); text-decoration: none; cursor: pointer;
  transition: transform .1s ease, opacity .15s ease;
}
.btn:hover { opacity: .9; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: progress; }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-small { padding: .4rem .9rem; font-size: .85rem; }
button.link { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; cursor: pointer; }
button.link:hover { color: var(--ink); }
.danger { color: var(--danger) !important; }
.actions { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }

/* forms */
.stack { display: flex; flex-direction: column; gap: 1.1rem; margin-block: 1.5rem; }
label { display: flex; flex-direction: column; gap: .35rem; font-weight: 500; font-size: .95rem; }
label small, .question small { font-weight: 400; color: var(--muted); font-size: .82rem; }
input, textarea {
  font: 400 1rem/1.5 var(--sans); color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: .65rem .8rem; width: 100%;
}
textarea { resize: vertical; }
input:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; border-color: var(--accent); }
.input-inline { width: 6.5rem; display: inline-block; padding: .35rem .5rem; margin-inline: .3rem; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem 1.1rem; margin: 0; display: flex; flex-direction: column; gap: .7rem; background: var(--surface); }
legend { font-family: var(--serif); font-size: 1.25rem; font-weight: 600; padding: 0 .35rem; }
label.choice { flex-direction: row; align-items: flex-start; gap: .65rem; font-weight: 400; cursor: pointer; }
label.choice input { width: auto; margin-top: .3rem; accent-color: var(--accent); }
label.choice .muted { display: block; font-size: .88rem; }
.when-extra { font-weight: 400; }
.when-extra[hidden] { display: none; }

.error { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); color: var(--danger); border-radius: 10px; padding: .8rem 1rem; margin-block: 1rem; }
.error ul { margin: 0; padding-left: 1.1rem; }
.flash { background: var(--ok-bg); color: var(--ok-ink); border-radius: 10px; padding: .7rem 1rem; margin-bottom: 1.5rem; }
.notice { background: var(--soft); border-radius: 10px; padding: .7rem 1rem; font-size: .92rem; }
.danger-zone { margin-top: 2rem; border-top: 1px solid var(--line); padding-top: 1rem; }

/* hero / landing */
.hero { padding-block: 3rem 3.5rem; }
.hero h1 { font-size: clamp(2.6rem, 7vw, 4.4rem); margin-bottom: 1.2rem; }
.hero .actions { margin-top: 2rem; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.5rem; padding-block: 2rem 3rem; border-top: 1px solid var(--line); }
.features p { color: var(--muted); font-size: .95rem; }
.section-title { margin-top: 2.5rem; margin-bottom: 1rem; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem 1.4rem; }
.card h3 { margin-bottom: .35rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.card-link { text-decoration: none; color: inherit; transition: border-color .15s, transform .15s; }
.card-link:hover { border-color: var(--accent); transform: translateY(-2px); }
.card-link p { margin: 0; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-head p { margin: 0; }
.status-grid, .persona-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.empty { text-align: center; padding: 3rem 1rem; border: 1px dashed var(--line); border-radius: var(--radius); }
.empty p:first-child { font-family: var(--serif); font-size: 1.5rem; margin-bottom: .25rem; }

.message-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .75rem; }
.message-row { display: flex; justify-content: space-between; gap: 1rem; align-items: center; }
.message-row p { margin: 0; }
.tag { display: inline-block; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; padding: .1rem .5rem; border-radius: 999px; background: var(--soft); color: var(--muted); margin-right: .25rem; }
.tag-public { background: color-mix(in srgb, var(--accent) 16%, var(--surface)); color: var(--accent); }
.tag-released { background: var(--ok-bg); color: var(--ok-ink); }

progress.progress { width: 100%; height: 8px; border: 0; border-radius: 999px; overflow: hidden; background: var(--soft); appearance: none; margin-block: .5rem; }
progress.progress::-webkit-progress-bar { background: var(--soft); border-radius: 999px; }
progress.progress::-webkit-progress-value { background: var(--accent); border-radius: 999px; }
progress.progress::-moz-progress-bar { background: var(--accent); border-radius: 999px; }

/* letter */
.letter { max-width: 680px; margin: 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(1.5rem, 5vw, 3.5rem); }
.letter-body { font-family: var(--serif); font-size: 1.3rem; line-height: 1.65; margin-top: 2rem; overflow-wrap: anywhere; }

/* quiz */
.quiz-section { margin-top: 2.5rem; }
.quiz-section h2 { display: flex; align-items: center; gap: .6rem; }
.step { font-family: var(--sans); font-size: .85rem; width: 1.8rem; height: 1.8rem; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: inline-grid; place-items: center; flex: none; }
.question { margin-block: 1.25rem; }
.question fieldset { background: transparent; border: 0; padding: 0; }
.question legend { font: 500 .95rem var(--sans); padding: 0; margin-bottom: .5rem; }
.pills { display: flex; flex-wrap: wrap; gap: .5rem; }
.pill { flex-direction: row; cursor: pointer; }
.pill input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pill span { display: inline-block; padding: .4rem .85rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-weight: 400; font-size: .9rem; }
.pill input:checked + span { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.pill input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.sticky-save { position: sticky; bottom: 0; padding: 1rem 0; background: linear-gradient(transparent, var(--bg) 35%); margin-top: 2rem; }

/* persona */
.prompt { white-space: pre-wrap; background: var(--soft); border-radius: 10px; padding: 1rem; max-height: 420px; overflow: auto; font-size: .8rem; line-height: 1.5; }
.chat { display: flex; flex-direction: column; gap: .75rem; }
.chat-log { min-height: 260px; max-height: 460px; overflow-y: auto; display: flex; flex-direction: column; gap: .6rem; padding: .75rem; background: var(--soft); border-radius: 12px; }
.chat-empty { margin: auto; }
.bubble { max-width: 85%; padding: .6rem .9rem; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; }
.bubble.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; }
.bubble.assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; font-family: var(--serif); font-size: 1.1rem; }
.bubble.pending { color: var(--muted); font-style: italic; }
.bubble.err { align-self: center; background: transparent; color: var(--danger); font-size: .88rem; }
.chat-form { display: flex; gap: .5rem; }
.chat-form input { flex: 1; }

@media (max-width: 560px) {
  nav { gap: .8rem; font-size: .88rem; }
  .message-row { flex-direction: column; align-items: flex-start; }
}

/* social login */
.social { display: flex; flex-direction: column; gap: .6rem; margin-top: 1.5rem; }
.btn-social { display: flex; align-items: center; justify-content: center; gap: .6rem; background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-social:hover { border-color: var(--accent); opacity: 1; }
.social-icon { font-weight: 700; width: 1.2rem; text-align: center; }
.btn-google .social-icon { color: #4285f4; }
.btn-facebook .social-icon { color: #1877f2; font-family: Georgia, serif; }
.btn-microsoft .social-icon { color: #00a4ef; }
.divider { display: flex; align-items: center; gap: .75rem; color: var(--muted); font-size: .85rem; margin-top: 1.25rem; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.identity-list { list-style: none; padding: 0; margin: .5rem 0 0; }
.identity-list li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .6rem 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.identity-list li:first-child { border-top: 0; }
.identity-list form { display: flex; gap: .75rem; align-items: center; }

/* theme toggle */
.theme-toggle { background: none; border: 1px solid var(--line); color: var(--muted); width: 2.1rem; height: 2.1rem; border-radius: 50%; display: inline-grid; place-items: center; cursor: pointer; padding: 0; transition: color .15s, border-color .15s; }
.theme-toggle:hover { color: var(--ink); border-color: var(--accent); }
.theme-toggle svg { width: 1rem; height: 1rem; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
body { transition: background-color .2s ease, color .2s ease; }

/* footer + donate */
.footer-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.btn-donate { display: inline-flex; align-items: center; gap: .45rem; font-family: var(--sans); }
.btn-donate svg { width: .95rem; height: .95rem; color: var(--danger); }

.donate-wrap { display: inline-flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.donate-note { font-family: var(--sans); font-size: .85rem; color: var(--muted); }
.free-note { border-top: 1px solid var(--line); padding-block: 2rem 2.5rem; }
.free-note p { color: var(--muted); max-width: 42rem; }
.free-note .btn-donate { margin-top: .5rem; }
