:root {
  --bg: #f6f2ea;
  --surface: #fffdf9;
  --surface-2: #f0ebe1;
  --ink: #2b2722;
  --ink-soft: #6b6359;
  --line: #e4ddd0;
  --gold: #9a7b3f;
  --accent: #9a7b3f;
  --danger: #a4443a;
  --radius: 16px;
  --serif: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --shadow: 0 1px 2px rgba(43, 39, 34, .04), 0 8px 30px rgba(43, 39, 34, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171512;
    --surface: #1f1c18;
    --surface-2: #26221d;
    --ink: #ece6dc;
    --ink-soft: #a39a8d;
    --line: #34302a;
    --shadow: 0 1px 2px rgba(0,0,0,.2), 0 8px 30px rgba(0,0,0,.3);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(8px);
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 26px; height: 26px; color: var(--gold); }
.brand-name { font-family: var(--serif); font-size: 26px; font-weight: 500; letter-spacing: .3px; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.ghost-btn {
  background: transparent; border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 12px; font-size: 13px; color: var(--ink-soft);
}
.ghost-btn:hover { color: var(--ink); border-color: var(--ink-soft); }
.timer, .sub-badge {
  font-size: 13px; padding: 6px 12px; border-radius: 999px;
  background: var(--surface-2); color: var(--ink-soft); font-variant-numeric: tabular-nums;
}
.timer.low { color: var(--danger); }
.sub-badge { color: var(--gold); }

/* ---------- layout ---------- */
.layout {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: 1fr 320px;
}
.chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.paths {
  border-left: 1px solid var(--line);
  background: var(--surface);
  padding: 24px 18px;
  overflow-y: auto;
}
.paths-title {
  font-family: var(--serif); font-weight: 500; font-size: 22px;
  margin: 0 6px 14px;
}
.religion-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.religion-btn {
  width: 100%; display: flex; align-items: center; gap: 14px;
  padding: 12px; border-radius: 14px;
  background: transparent; border: 1px solid transparent; text-align: left;
  transition: background .2s, border-color .2s;
}
.religion-btn:hover { background: var(--surface-2); }
.religion-btn.active { background: var(--surface-2); border-color: color-mix(in srgb, var(--c) 40%, var(--line)); }
.religion-icon {
  width: 42px; height: 42px; flex-shrink: 0; padding: 9px;
  border-radius: 50%;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 10%, transparent);
}
.religion-text { display: flex; flex-direction: column; min-width: 0; }
.religion-name { font-weight: 500; font-size: 15px; }
.religion-tag { font-size: 12.5px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- thread ---------- */
.thread {
  flex: 1; overflow-y: auto;
  padding: 32px max(24px, calc((100% - 760px) / 2));
  display: flex; flex-direction: column; gap: 22px;
  scroll-behavior: smooth;
}
.empty {
  margin: auto; text-align: center; max-width: 420px; color: var(--ink-soft);
}
.empty-icon { width: 54px; height: 54px; margin: 0 auto 18px; color: var(--gold); opacity: .8; }
.empty h1 { font-family: var(--serif); font-weight: 500; font-size: 34px; line-height: 1.15; color: var(--ink); margin: 0 0 10px; }
.empty p { margin: 0; }

.msg { display: flex; gap: 12px; max-width: 100%; animation: rise .35s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg-avatar {
  width: 34px; height: 34px; flex-shrink: 0; padding: 7px; border-radius: 50%;
  color: var(--c); background: color-mix(in srgb, var(--c) 10%, transparent);
  margin-top: 2px;
}
.msg-body { min-width: 0; }
.msg.ai .msg-body { font-family: var(--serif); font-size: 19px; line-height: 1.55; }
.msg.ai .msg-body p { margin: 0 0 10px; }
.msg.ai .msg-body p:last-child { margin-bottom: 0; }
.msg.ai blockquote {
  margin: 12px 0; padding: 4px 0 4px 16px;
  border-left: 2px solid var(--c);
  font-style: italic; color: var(--ink);
}
.msg.user { justify-content: flex-end; }
.msg.user .msg-body {
  background: var(--surface); border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 18px 18px 4px 18px;
  max-width: 78%; white-space: pre-wrap; word-wrap: break-word;
  box-shadow: var(--shadow);
}
.typing { display: inline-flex; gap: 4px; padding-top: 10px; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-soft); opacity: .4; animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 50% { opacity: 1; } }

/* ---------- composer ---------- */
.composer {
  padding: 12px max(24px, calc((100% - 760px) / 2)) 14px;
  border-top: 1px solid var(--line);
  background: var(--bg);
  flex-shrink: 0;
}
.current-path { font-size: 12.5px; color: var(--ink-soft); margin: 0 4px 8px; }
.current-path b { color: var(--c); font-weight: 500; }
.composer-row {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 22px; padding: 6px 6px 6px 18px;
  box-shadow: var(--shadow);
}
.composer-row:focus-within { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
textarea {
  flex: 1; border: 0; outline: 0; resize: none; background: transparent; color: var(--ink);
  font: inherit; font-size: 15px; padding: 9px 0; max-height: 160px;
}
textarea::placeholder { color: var(--ink-soft); }
.send-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 0; padding: 10px; flex-shrink: 0;
  background: var(--accent); color: #fff; transition: opacity .2s;
}
.send-btn:disabled { opacity: .35; cursor: default; }
.disclaimer { font-size: 11.5px; color: var(--ink-soft); text-align: center; margin: 8px 0 0; }

/* ---------- modals ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  backdrop-filter: blur(6px);
}
.modal-card {
  width: 100%; max-width: 420px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 22px; padding: 32px 28px 24px;
  box-shadow: 0 20px 60px rgba(43,39,34,.15);
  display: flex; flex-direction: column; gap: 14px;
  text-align: center;
  animation: rise .3s ease;
}
.modal-card h2 { font-family: var(--serif); font-weight: 500; font-size: 30px; line-height: 1.15; margin: 0; }
.modal-icon { width: 44px; height: 44px; margin: 0 auto; color: var(--gold); }
.muted { color: var(--ink-soft); margin: 0; }
.tiny { font-size: 12px; }
.modal-card input[type=email], .code-input {
  width: 100%; padding: 13px 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  font: inherit; outline: 0; text-align: center;
}
.modal-card input:focus { border-color: var(--gold); }
.code-input { font-size: 26px; letter-spacing: 10px; }
.check { display: flex; gap: 10px; text-align: left; font-size: 13px; color: var(--ink-soft); align-items: flex-start; }
.check input { margin-top: 3px; accent-color: var(--gold); }
.primary-btn {
  width: 100%; padding: 13px; border: 0; border-radius: 12px;
  background: var(--ink); color: var(--bg); font-weight: 500;
  transition: transform .1s, opacity .2s;
}
.primary-btn:hover { opacity: .9; }
.primary-btn:active { transform: scale(.99); }
.primary-btn:disabled { opacity: .5; }
.error { color: var(--danger); font-size: 13px; margin: 0; }
.row-links { display: flex; justify-content: center; gap: 18px; flex-wrap: wrap; }
.link-btn { background: none; border: 0; color: var(--ink-soft); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }
.price { font-family: var(--serif); font-size: 44px; font-weight: 500; line-height: 1; }
.price small { font-family: var(--sans); font-size: 14px; color: var(--ink-soft); margin-left: 4px; }
.benefits { list-style: none; padding: 0; margin: 0; text-align: left; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.benefits li::before { content: '✦'; color: var(--gold); margin-right: 10px; }

/* ---------- mobile ---------- */
@media (max-width: 860px) {
  .topbar { padding: 10px 16px; }
  .brand-name { font-size: 22px; }
  .layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .paths {
    order: -1; border-left: 0; border-bottom: 1px solid var(--line);
    padding: 10px 0; overflow-x: auto; overflow-y: hidden;
  }
  .paths-title { display: none; }
  .religion-list { flex-direction: row; gap: 4px; padding: 0 12px; }
  .religion-btn { flex-direction: column; gap: 6px; width: 84px; padding: 8px 4px; text-align: center; }
  .religion-icon { width: 38px; height: 38px; padding: 8px; }
  .religion-name { font-size: 12px; line-height: 1.2; }
  .religion-tag { display: none; }
  .thread, .composer { padding-left: 16px; padding-right: 16px; }
  .thread { padding-top: 20px; }
  .msg.ai .msg-body { font-size: 18px; }
  .msg.user .msg-body { max-width: 88%; }
  .empty h1 { font-size: 28px; }
}
