@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ── TOKENS ─────────────────────────────────────────── */
:root {
  --blue: #2563EB;
  --blue-dark: #1D4ED8;
  --blue-deeper: #1E3A8A;
  --blue-light: #DBEAFE;
  --blue-xlight: #EFF6FF;
  --gold: #F59E0B;
  --gold-light: #FEF3C7;
  --success: #10B981;
  --success-light: #D1FAE5;
  --danger: #EF4444;
  --danger-light: #FEE2E2;
  --text: #1E293B;
  --text-muted: #64748B;
  --text-light: #94A3B8;
  --border: #E2E8F0;
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --nav-h: 64px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --text: #F1F5F9;
    --text-muted: #94A3B8;
    --text-light: #64748B;
    --border: #334155;
    --bg: #0F172A;
    --surface: #1E293B;
    --blue-xlight: #1E3A5F;
    --blue-light: #1E40AF;
    --gold-light: #451A03;
    --success-light: #022C22;
    --danger-light: #450A0A;
    --shadow: 0 1px 3px rgba(0,0,0,.3);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,.4);
  }
}

:root[data-theme="dark"] {
  --text: #F1F5F9;
  --text-muted: #94A3B8;
  --text-light: #64748B;
  --border: #334155;
  --bg: #0F172A;
  --surface: #1E293B;
  --blue-xlight: #1E3A5F;
  --blue-light: #1E40AF;
  --gold-light: #451A03;
  --success-light: #022C22;
  --danger-light: #450A0A;
  --shadow: 0 1px 3px rgba(0,0,0,.3);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.4);
}

/* ── RESET ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}
img { max-width: 100%; }
a { color: var(--blue); text-decoration: none; }
button { cursor: pointer; font-family: inherit; border: none; }

/* ── LAYOUT ─────────────────────────────────────────── */
.page { min-height: 100vh; display: flex; flex-direction: column; }
.page-with-nav { padding-bottom: calc(var(--nav-h) + 16px); }
.container { max-width: 480px; margin: 0 auto; padding: 0 16px; width: 100%; }
.container-wide { max-width: 900px; margin: 0 auto; padding: 0 16px; width: 100%; }

/* ── HEADER ─────────────────────────────────────────── */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.header-wide { max-width: 900px; }
.header-back {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
}
.header-back svg { flex-shrink: 0; }

/* ── WORDMARK ───────────────────────────────────────── */
.wordmark {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--blue);
}
.wordmark-sm { font-size: 18px; }

/* ── BOTTOM NAV ─────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 1;
  padding: 8px 4px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  background: none;
  border: none;
  text-decoration: none;
}
.nav-item.active { color: var(--blue); }
.nav-item svg { width: 22px; height: 22px; }

/* ── CARDS ──────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.card-sm { padding: 14px 16px; }
.card-flush { padding: 0; overflow: hidden; }

/* ── BUTTONS ────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 20px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  transition: all 0.15s;
  border: none;
  cursor: pointer;
  width: 100%;
}
.btn-primary {
  background: var(--blue);
  color: #fff;
}
.btn-primary:hover { background: var(--blue-dark); }
.btn-primary:active { transform: scale(0.98); }
.btn-secondary {
  background: var(--blue-xlight);
  color: var(--blue);
  border: 1px solid var(--blue-light);
}
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-danger {
  background: var(--danger-light);
  color: var(--danger);
}
.btn-sm {
  padding: 8px 14px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  width: auto;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ── FORM ───────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.form-input {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s;
  width: 100%;
}
.form-input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.form-input::placeholder { color: var(--text-light); }
textarea.form-input { resize: vertical; min-height: 120px; line-height: 1.6; }

/* ── BADGES / PILLS ─────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
}
.badge-blue { background: var(--blue-light); color: var(--blue-dark); }
.badge-gold { background: var(--gold-light); color: #92400E; }
.badge-green { background: var(--success-light); color: #065F46; }
.badge-muted { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }

/* ── STEP INDICATOR ─────────────────────────────────── */
.steps {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 24px;
}
.step-item {
  display: flex;
  align-items: center;
  flex: 1;
}
.step-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: all 0.2s;
}
.step-dot.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.step-dot.done { background: var(--success); border-color: var(--success); color: #fff; }
.step-line { flex: 1; height: 2px; background: var(--border); }
.step-line.done { background: var(--success); }

/* ── QUIZ ───────────────────────────────────────────── */
.quiz-option {
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1.4;
}
.quiz-option:hover { border-color: var(--blue); background: var(--blue-xlight); }
.quiz-option.selected { border-color: var(--blue); background: var(--blue-xlight); color: var(--blue); }
.quiz-option.correct { border-color: var(--success); background: var(--success-light); color: #065F46; }
.quiz-option.wrong { border-color: var(--danger); background: var(--danger-light); color: var(--danger); }
.quiz-option:disabled { cursor: default; }

/* ── SCRIPTURE CARD ─────────────────────────────────── */
.scripture-card {
  background: var(--blue-xlight);
  border: 1px solid var(--blue-light);
  border-left: 4px solid var(--blue);
  border-radius: var(--radius-sm);
  padding: 16px;
}
.scripture-ref {
  font-size: 12px;
  font-weight: 700;
  color: var(--blue);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
.scripture-text {
  font-size: 14px;
  color: var(--text);
  line-height: 1.7;
  font-style: italic;
}
.scripture-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--blue);
  margin-top: 10px;
}

/* ── CHAPTER CARD ───────────────────────────────────── */
.chapter-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
  width: 100%;
}
.chapter-card:hover { border-color: var(--blue); box-shadow: var(--shadow-md); }
.chapter-card.current { border-color: var(--blue); background: var(--blue-xlight); }
.chapter-card.locked { opacity: 0.45; cursor: not-allowed; }
.chapter-num {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--blue-light);
  color: var(--blue-dark);
  font-size: 15px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chapter-card.current .chapter-num { background: var(--blue); color: #fff; }
.chapter-card.completed .chapter-num { background: var(--success-light); color: var(--success); }
.chapter-info { flex: 1; min-width: 0; }
.chapter-title { font-size: 14px; font-weight: 600; color: var(--text); line-height: 1.3; }
.chapter-meta { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

/* ── PROGRESS BARS ──────────────────────────────────── */
.progress-track {
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--blue);
  border-radius: 99px;
  transition: width 0.5s ease;
}
.progress-fill.green { background: var(--success); }
.progress-fill.gold { background: var(--gold); }

/* ── STAT TILES ─────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 12px;
  text-align: center;
}
.stat-value { font-size: 24px; font-weight: 800; color: var(--blue); }
.stat-label { font-size: 11px; color: var(--text-muted); font-weight: 500; margin-top: 2px; }

/* ── TABLES ─────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  padding: 12px 14px;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: left;
  white-space: nowrap;
}
td {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
tr:hover td { background: var(--bg); }

/* ── CHECK DOTS ─────────────────────────────────────── */
.check-dot {
  width: 20px; height: 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}
.check-dot.done { background: var(--success-light); color: var(--success); }
.check-dot.pending { background: var(--border); color: var(--text-light); }

/* ── TOAST ──────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: #fff;
  padding: 10px 20px;
  border-radius: 99px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  transition: all 0.3s;
  z-index: 999;
  white-space: nowrap;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.success { background: var(--success); }
#toast.error { background: var(--danger); }

/* ── ERROR / EMPTY STATES ───────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.empty-state p { font-size: 14px; margin-top: 8px; }
.error-msg {
  background: var(--danger-light);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
}

/* ── COMPLETION SCREEN ──────────────────────────────── */
.complete-screen {
  text-align: center;
  padding: 40px 20px;
}
.complete-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--success-light);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  font-size: 36px;
}
.complete-screen h2 { font-size: 22px; font-weight: 800; margin-bottom: 8px; }
.complete-screen p { color: var(--text-muted); font-size: 15px; }

/* ── SPLASH (login page) ────────────────────────────── */
.splash {
  background: var(--blue);
  padding: 48px 24px 40px;
  text-align: center;
  color: #fff;
}
.splash .wordmark { color: #fff; font-size: 36px; letter-spacing: -1px; }
.splash-tagline { font-size: 14px; opacity: 0.8; margin-top: 6px; font-weight: 500; }

/* ── TABS (login/signup) ────────────────────────────── */
.tab-bar {
  display: flex;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 4px;
  gap: 4px;
}
.tab-btn {
  flex: 1;
  padding: 10px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
}
.tab-btn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ── UTILITY ─────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-20 { gap: 20px; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }
.text-sm { font-size: 13px; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.hidden { display: none !important; }
.w-full { width: 100%; }
h1 { font-size: 22px; font-weight: 800; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }

/* ── SECTION HEADING ────────────────────────────────── */
.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* ── CURRENT CHAPTER HERO ───────────────────────────── */
.chapter-hero {
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-deeper) 100%);
  border-radius: var(--radius-lg);
  padding: 24px;
  color: #fff;
  position: relative;
  overflow: hidden;
}
.chapter-hero::after {
  content: '';
  position: absolute;
  right: -20px;
  top: -20px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
}
.chapter-hero-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; opacity: 0.75; }
.chapter-hero-num { font-size: 40px; font-weight: 800; line-height: 1; margin: 4px 0; }
.chapter-hero-title { font-size: 15px; font-weight: 600; opacity: 0.9; line-height: 1.3; }
.chapter-hero-progress { margin-top: 20px; }
.chapter-hero-progress-label { font-size: 12px; opacity: 0.7; margin-bottom: 8px; display: flex; justify-content: space-between; }
.chapter-hero-bar { height: 6px; background: rgba(255,255,255,0.2); border-radius: 99px; overflow: hidden; }
.chapter-hero-fill { height: 100%; background: #fff; border-radius: 99px; transition: width 0.5s ease; }

/* ── LESSON TEXT ────────────────────────────────────── */
.lesson-body { font-size: 15px; line-height: 1.8; color: var(--text); }
.lesson-body p { margin-bottom: 16px; }
.lesson-body p:last-child { margin-bottom: 0; }

/* ── HERO WITH ARTWORK ──────────────────────────────── */
.chapter-hero-art {
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
  min-height: 220px;
  display: flex;
  align-items: flex-end;
  margin-bottom: 16px;
}
.chapter-hero-art-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
}
.chapter-hero-art-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top,
    rgba(10,30,80,.92) 0%,
    rgba(10,30,80,.55) 55%,
    rgba(0,0,0,.15) 100%);
}
.chapter-hero-art-body {
  position: relative;
  z-index: 1;
  padding: 20px;
  color: #fff;
  width: 100%;
}

/* ── STREAK BADGE ───────────────────────────────────── */
.streak-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 16px;
}
.streak-flame { font-size: 22px; line-height: 1; }
.streak-num { font-size: 22px; font-weight: 800; color: var(--blue); line-height: 1; }
.streak-label { font-size: 13px; color: var(--text-muted); flex: 1; }
.streak-zero .streak-num { color: var(--text-light); }

/* ── WEEKLY QUOTE ───────────────────────────────────── */
.quote-card {
  background: var(--blue-xlight);
  border: 1px solid var(--blue-light);
  border-left: 3px solid var(--blue);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 20px;
}
.quote-card-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--blue);
  margin-bottom: 7px;
}
.quote-card-text {
  font-size: 14px;
  line-height: 1.65;
  font-style: italic;
  color: var(--text);
  margin-bottom: 6px;
}
.quote-card-attr { font-size: 11px; color: var(--text-muted); }

/* ── WARD SOCIAL STAT ───────────────────────────────── */
.ward-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--success-light);
  color: #065F46;
  border-radius: 99px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  margin-top: 10px;
}

/* ── CHAPTER ARTWORK THUMBNAIL ──────────────────────── */
.ch-thumb {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  object-fit: cover;
  object-position: center top;
  flex-shrink: 0;
  background: var(--blue-light);
}
.ch-thumb-lock {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

/* ── ACHIEVEMENT BADGES ─────────────────────────────── */
.achievement-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 24px;
}
.achievement-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 10px;
  text-align: center;
}
.achievement-card.unlocked {
  border-color: var(--gold);
  background: var(--gold-light);
}
.achievement-icon {
  font-size: 26px;
  line-height: 1;
  margin-bottom: 7px;
  filter: grayscale(1) opacity(.25);
}
.achievement-card.unlocked .achievement-icon { filter: none; }
.achievement-name {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  line-height: 1.3;
}
.achievement-card.unlocked .achievement-name { color: #92400E; }
.achievement-desc {
  font-size: 9px;
  color: var(--text-light);
  margin-top: 3px;
  line-height: 1.3;
}
.achievement-card.unlocked .achievement-desc { color: #B45309; }
