:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --ink: #1f2430;
  --muted: #6b7080;
  --line: #dcdde2;
  --silver: #8a93a6;
  --silver-light: #e8eaef;
  --accent: #2f3a55;
  --accent-ink: #ffffff;
  --success: #2e7d4f;
  --error: #b3261e;
  --radius: 14px;
  --serif: "Cormorant Garamond", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161c;
    --surface: #1d2029;
    --ink: #e9eaee;
    --muted: #9ba1b0;
    --line: #2e323d;
    --silver: #aab2c4;
    --silver-light: #262a35;
    --accent: #c9cfdc;
    --accent-ink: #14161c;
    --success: #6fcf97;
    --error: #f28b82;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

[hidden] { display: none !important; }

/* Header */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
}
.brand-mark { color: var(--silver); }
.nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.nav-link {
  background: none;
  border: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.95rem;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.nav-link:hover, .nav-link.active { color: var(--ink); background: var(--silver-light); }

/* Buttons */
.btn {
  background: var(--accent);
  color: var(--accent-ink);
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 10px 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.1); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-small { padding: 6px 12px; font-size: 0.9rem; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-full { width: 100%; margin-top: 10px; }
.btn-provider { background: var(--surface); color: var(--ink); border-color: var(--line); }
.link-button {
  background: none;
  border: none;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  padding: 4px 0;
}
.link-button:hover { color: var(--ink); }

/* Home */
.hero {
  text-align: center;
  padding: 24px 8px 8px;
}
.hero-verse {
  font-family: var(--serif);
  font-size: 1.45rem;
  font-style: italic;
  line-height: 1.4;
  margin: 0 auto;
  max-width: 600px;
}
.hero-ref { color: var(--muted); font-size: 0.9rem; margin-top: 8px; }

.section-title {
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 600;
  margin: 28px 0 16px;
}

.levels { display: grid; gap: 12px; }
.level-card {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.15s, transform 0.15s;
}
.level-card:hover { border-color: var(--silver); transform: translateY(-1px); }
.level-name { font-family: var(--serif); font-size: 1.5rem; font-weight: 700; }
.level-desc { color: var(--muted); }

/* Question */
.question-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.level-pill {
  background: var(--silver-light);
  color: var(--ink);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.85rem;
  font-weight: 600;
}
.question-card, .answer-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 16px;
}
.question-text {
  font-family: var(--serif);
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1.3;
  margin: 0 0 18px;
}
.helps { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 620px) { .helps { grid-template-columns: 1fr 1fr; } }
.help-block h3, .tradition-block h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 6px;
}
.verse-list, .reading-list { margin: 0; padding-left: 18px; }
.verse-list a { color: var(--ink); }
.reading-list .work { font-style: italic; }
.tradition-block { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 14px; }
.tradition-block h3 .muted { text-transform: none; letter-spacing: 0; }

.answer-label { display: block; font-weight: 600; margin-bottom: 8px; }
textarea, input, select {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
}
textarea { resize: vertical; min-height: 180px; }
textarea:focus, input:focus, select:focus { outline: 2px solid var(--silver); outline-offset: 1px; }
.answer-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.answer-actions .status { flex: 1 1 100%; text-align: left; }
.answer-actions .status:empty { display: none; }
@media (max-width: 480px) {
  .answer-actions .btn { flex: 1 1 0; padding: 10px 8px; }
}

.status { font-size: 0.9rem; color: var(--muted); }
.status.ok { color: var(--success); }
.status.err { color: var(--error); }
.muted { color: var(--muted); }

/* Answers list */
.answers-list { display: grid; gap: 12px; }
.saved-answer {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.saved-answer h3 { font-family: var(--serif); font-size: 1.2rem; margin: 6px 0 8px; line-height: 1.3; }
.saved-answer .meta { font-size: 0.8rem; color: var(--muted); }
.saved-answer .body { white-space: pre-wrap; margin: 0 0 10px; }
.saved-answer .row { display: flex; gap: 14px; }

/* Settings */
.settings-form { display: grid; gap: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.settings-form label { display: grid; gap: 6px; font-weight: 600; }

/* Dialog */
.dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 20px 22px 24px;
  width: min(420px, calc(100vw - 32px));
}
.dialog::backdrop { background: rgba(10, 12, 18, 0.5); }
.dialog h2 { font-family: var(--serif); font-size: 1.8rem; margin: 0; }
.dialog-close-row { display: flex; justify-content: flex-end; margin: -8px -6px 0 0; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 0.85rem; margin: 18px 0 4px; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.email-form { display: grid; gap: 4px; margin-top: 8px; }

/* Footer */
.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 20px 16px 28px;
  border-top: 1px solid var(--line);
}
.site-footer p { margin: 4px 0; }

/* Sign-in code boxes */
.otp { display: flex; gap: 8px; justify-content: center; margin: 12px 0 4px; }
.otp-box {
  width: 44px;
  height: 54px;
  padding: 0;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.otp-box:disabled { opacity: 0.6; }
@media (max-width: 380px) { .otp { gap: 5px; } .otp-box { width: 38px; height: 48px; } }

/* Google's own button (rendered by Google into this box) */
.google-btn { display: flex; justify-content: center; margin-top: 14px; min-height: 44px; }
