/* ============================================================
   ReadIn52 — modern design system
   ============================================================ */
:root {
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-serif: 'Fraunces', Georgia, 'Times New Roman', serif;

  /* "Illuminated" — lapis indigo ink + antique gold leaf on cool paper */
  --accent: #34459b;
  --accent-2: #4a5cc4;
  --accent-ink: #283680;
  --grad: #34459b;
  --accent-soft: color-mix(in srgb, var(--accent) 9%, var(--surface));
  --gold: #a2802f;
  --gold-2: #bf9a3d;
  --gold-soft: color-mix(in srgb, var(--gold) 14%, var(--surface));

  --bg: #eceef4;
  --bg-2: #e3e6ef;
  --surface: #ffffff;
  --surface-2: #f3f4f9;
  --text: #191d2c;
  --muted: #656b81;
  --border: #dfe2ec;
  --shadow: 0 1px 2px rgba(20,24,45,.05);
  --shadow-lg: 0 14px 38px rgba(20,24,45,.16);
  --radius: 10px;
  --radius-sm: 8px;
  --ok: #2e8b57; --err: #c0392b; --info: #2f6fb0;
  --hl-yellow: #ffe9a8; --hl-green: #c9ecc9; --hl-blue: #c7e0f7; --hl-red: #f7cccc; --hl-purple: #e2d0f2;
}
:root[data-theme="dark"] {
  /* "Midnight" — luminous indigo + warm gold on deep night paper */
  --accent: #97a6f2;
  --accent-2: #b0bcf7;
  --accent-ink: #b0bcf7;
  --grad: #5568d8;
  --gold: #d9b45f;
  --gold-2: #e7c877;
  --gold-soft: color-mix(in srgb, var(--gold) 16%, var(--surface));
  --accent-soft: color-mix(in srgb, var(--accent) 14%, var(--surface));
  --bg: #0e1220;
  --bg-2: #131829;
  --surface: #161c2e;
  --surface-2: #1d2439;
  --text: #e7e9f3;
  --muted: #9298b4;
  --border: #29304a;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
  --shadow-lg: 0 16px 44px rgba(0,0,0,.6);
  --hl-yellow: #6b5a1f; --hl-green: #2c5230; --hl-blue: #274a66; --hl-red: #6a2e2e; --hl-purple: #4a3564;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex; flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3 { font-family: var(--font-serif); font-weight: 600; line-height: 1.2; color: var(--text); }
h1 { font-size: clamp(1.6rem, 3vw, 2.3rem); }
img { max-width: 100%; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.accent { color: var(--accent); }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: .82rem; }

.container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.app-main { padding-top: 1.75rem; padding-bottom: 4rem; flex: 1; }
.app-main.narrow { max-width: 720px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font: inherit; font-weight: 600; cursor: pointer;
  padding: .62rem 1.1rem; border-radius: var(--radius-sm);
  border: 1px solid transparent; transition: transform .08s, box-shadow .2s, background .2s, border-color .2s;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--grad); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: transparent; color: var(--err); border-color: color-mix(in srgb, var(--err) 40%, transparent); }
.btn-danger:hover { background: color-mix(in srgb, var(--err) 12%, transparent); }
.btn-sm { padding: .4rem .75rem; font-size: .85rem; }
.btn-lg { padding: .85rem 1.6rem; font-size: 1.05rem; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-flex; align-items: center; gap: .35rem; justify-content: center;
  background: transparent; border: 1px solid transparent; color: var(--text);
  border-radius: 10px; padding: .45rem .6rem; cursor: pointer; font: inherit; font-size: .9rem;
  transition: background .15s, border-color .15s;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border); }

/* ---------- Icons ---------- */
.ico { width: 1.15em; height: 1.15em; display: inline-block; vertical-align: -.15em; flex-shrink: 0; }
.icon-chip { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); flex-shrink: 0; }
.icon-chip .ico { width: 22px; height: 22px; }
.icon-chip.sm { width: 38px; height: 38px; border-radius: 10px; }
.icon-chip.sm .ico { width: 19px; height: 19px; }
.icon-chip.lg { width: 64px; height: 64px; border-radius: 18px; }
.icon-chip.lg .ico { width: 30px; height: 30px; }

/* ---------- Header ---------- */
.site-header { position: sticky; top: 0; z-index: 40; background: color-mix(in srgb, var(--bg) 80%, transparent); backdrop-filter: saturate(180%) blur(12px); border-bottom: 1px solid var(--border); }
.header-inner { max-width: 1200px; margin: 0 auto; padding: .6rem 20px; display: flex; align-items: center; gap: 1rem; }
.brand { display: flex; align-items: center; gap: .55rem; font-family: var(--font-serif); font-weight: 700; font-size: 1.15rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { border-radius: 8px; }
.main-nav { display: flex; gap: .3rem; margin-left: .5rem; }
.main-nav a { position: relative; padding: .45rem .35rem; color: var(--muted); font-weight: 600; font-size: .92rem; }
.main-nav a:hover { color: var(--text); text-decoration: none; }
.main-nav a.active { color: var(--text); }
.main-nav a.active::after { content: ''; position: absolute; left: .35rem; right: .35rem; bottom: -.55rem; height: 2px; background: var(--gold); border-radius: 2px; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: .35rem; }
.ico-moon { display: none; }
:root[data-theme="dark"] .ico-sun { display: none; }
:root[data-theme="dark"] .ico-moon { display: inline; }

.avatar-btn { background: none; border: none; cursor: pointer; padding: 0; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--grad); color: #fff; font-weight: 700; }
.menu { position: relative; }
.menu-panel { position: absolute; right: 0; top: calc(100% + 8px); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); min-width: 220px; padding: .4rem; display: none; z-index: 50; }
.menu.open .menu-panel { display: block; }
.menu-panel a { display: block; padding: .55rem .7rem; border-radius: 8px; color: var(--text); font-size: .92rem; }
.menu-panel a:hover { background: var(--surface-2); text-decoration: none; }
.menu-panel a.danger { color: var(--err); }
.menu-head { padding: .5rem .7rem; border-bottom: 1px solid var(--border); margin-bottom: .3rem; display: flex; flex-direction: column; }
.menu-head span { font-size: .8rem; color: var(--muted); }
.nav-toggle { display: none; }

/* ---------- Flash / alerts / toasts ---------- */
.flash { max-width: 1080px; margin: .75rem auto 0; padding: .7rem 1rem; border-radius: 10px; display: flex; justify-content: space-between; align-items: center; font-weight: 500; }
.flash-success { background: color-mix(in srgb, var(--ok) 15%, var(--surface)); color: var(--ok); }
.flash-error { background: color-mix(in srgb, var(--err) 15%, var(--surface)); color: var(--err); }
.flash-close { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: inherit; }
.alert { padding: .7rem .9rem; border-radius: 10px; margin-bottom: 1rem; font-size: .92rem; }
.alert-error { background: color-mix(in srgb, var(--err) 12%, var(--surface)); color: var(--err); }
.alert-success { background: color-mix(in srgb, var(--ok) 12%, var(--surface)); color: var(--ok); }
.alert-info { background: color-mix(in srgb, var(--info) 12%, var(--surface)); color: var(--info); }
.toast-stack { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: .5rem; z-index: 100; }
.toast { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 10px; padding: .7rem 1rem; box-shadow: var(--shadow-lg); max-width: 320px; animation: toastIn .25s ease; }
.toast.badge { border-left-color: #d4a017; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.35rem; margin-bottom: 1.5rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.card-head h2 { font-size: 1.25rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.section-title { font-size: 1.15rem; margin: 1.75rem 0 .9rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: .72rem; font-weight: 700; color: var(--gold); }

/* ---------- Forms ---------- */
.stack { display: flex; flex-direction: column; gap: .9rem; }
label { display: flex; flex-direction: column; gap: .35rem; font-weight: 600; font-size: .9rem; }
input, select, textarea {
  font: inherit; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); color: var(--text); width: 100%; font-weight: 400;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
textarea { resize: vertical; }
.select-sm { width: auto; padding: .4rem .6rem; font-size: .85rem; border-radius: 8px; }
.checkbox { flex-direction: row; align-items: center; gap: .5rem; font-weight: 400; }
.checkbox input { width: auto; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
hr { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }
.inline-form { display: flex; gap: 1rem; align-items: flex-end; margin-bottom: 1rem; }
.inline-form label { flex-direction: row; align-items: center; gap: .5rem; }

/* ---------- Auth ---------- */
.auth-wrap { flex: 1; display: grid; place-items: center; padding: 2.5rem 20px; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow-lg); padding: 2.2rem; width: 100%; max-width: 420px; }
.auth-card h1 { font-size: 1.6rem; margin-bottom: .3rem; }
.auth-card .muted { margin-bottom: 1.3rem; }
.auth-links { display: flex; justify-content: space-between; margin-top: 1.2rem; font-size: .9rem; flex-wrap: wrap; gap: .5rem; }

/* ---------- Landing ---------- */
.landing { flex: 1; }
.hero { position: relative; overflow: hidden; padding: clamp(2.5rem, 7vw, 5rem) 20px 2.5rem; text-align: center; }
.hero-glow { display: none; }
.hero-inner { position: relative; z-index: 1; max-width: 760px; margin: 0 auto; }
.hero-title { font-size: clamp(2.2rem, 6vw, 4rem); margin: 1rem 0; letter-spacing: -.02em; }
.hero-sub { font-size: clamp(1rem, 2vw, 1.2rem); color: var(--muted); max-width: 640px; margin: 0 auto 1.8rem; }
.hero-cta { display: flex; gap: .8rem; justify-content: center; flex-wrap: wrap; }
.hero-verse { margin-top: 2.5rem; font-family: var(--font-serif); font-style: italic; color: var(--muted); }
.features { padding: 2rem 20px; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.1rem; }
.feature-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.4rem; transition: border-color .18s; }
.feature-card:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.feature-ico { margin-bottom: .85rem; }
.feature-card h3 { font-size: 1.1rem; margin-bottom: .35rem; }
.feature-card p { color: var(--muted); font-size: .93rem; }
.tracks { padding: 1rem 20px 4rem; text-align: center; }
.track-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .7rem; margin-bottom: 2.5rem; }
.track { display: flex; align-items: center; gap: .6rem; padding: 1rem 1.1rem; border-radius: var(--radius); font-weight: 600; text-align: left; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--c); color: var(--text); }
.track::before { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.cta-band { background: var(--surface); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius); padding: 2.5rem 2rem; text-align: center; }
.cta-band h2 { margin-bottom: 1.2rem; }

/* ---------- Dashboard ---------- */
.dash-hero { display: grid; grid-template-columns: 1.7fr 1fr; gap: 1.5rem; margin-bottom: 1.5rem; }
.hero-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.hero-head h1 { font-size: 1.8rem; margin: .2rem 0; }
.ring { position: relative; width: 92px; height: 92px; flex-shrink: 0; }
.ring svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.ring circle { fill: none; stroke-width: 10; }
.ring-bg { stroke: var(--border); }
.ring-fg { stroke: url(#g); stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 327; stroke-dashoffset: calc(327 - 327 * var(--pct) / 100); transition: stroke-dashoffset .8s ease; }
.ring-label { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; font-size: 1.1rem; }
.current-readings { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin: 1.3rem 0; }
.reading-pill { display: flex; align-items: center; gap: .6rem; padding: .6rem .8rem; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }
.reading-pill:hover { border-color: var(--c); text-decoration: none; }
.reading-pill .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex-shrink: 0; }
.rp-body { display: flex; flex-direction: column; line-height: 1.25; }
.rp-body small { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }
.daily-verse { display: flex; flex-direction: column; }
.daily-verse blockquote { font-family: var(--font-serif); font-size: 1.15rem; line-height: 1.5; margin: .6rem 0; flex: 1; }
.daily-verse cite { color: var(--muted); font-style: normal; font-weight: 600; }
.verse-loading { color: var(--muted); }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat { display: flex; align-items: center; gap: .8rem; margin-bottom: 0; padding: 1.1rem; }
.stat strong { display: block; font-size: 1.5rem; font-family: var(--font-serif); line-height: 1; }
.stat small { color: var(--muted); font-size: .82rem; }
.stat.big strong { font-size: 1.9rem; }

.legend { display: flex; gap: .9rem; flex-wrap: wrap; font-size: .8rem; color: var(--muted); }
.legend .lg { display: inline-flex; align-items: center; gap: .35rem; }
.legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

.weeks-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: .55rem; }
.week-cell { position: relative; aspect-ratio: 1; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); cursor: pointer; padding: .35rem; display: flex; flex-direction: column; justify-content: space-between; transition: transform .1s, border-color .15s, box-shadow .15s; }
.week-cell:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow); }
.week-cell.is-current { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent); }
.week-cell.full { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); }
.wc-num { font-size: .75rem; font-weight: 700; color: var(--muted); text-align: left; }
.week-cell.full .wc-num { color: var(--accent-ink); }
.wc-bars { display: flex; gap: 2px; }
.wc-bar { flex: 1; height: 5px; border-radius: 3px; background: var(--border); }
.wc-bar[data-on="1"] { background: var(--c); }

.week-detail-body { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.wd-cat { border: 1px solid var(--border); border-radius: 12px; padding: 1rem; border-top: 3px solid var(--c); }
.wd-cat h3 { font-size: 1rem; display: flex; justify-content: space-between; align-items: center; }
.wd-cat .wd-ref { color: var(--muted); font-size: .85rem; margin: .2rem 0 .7rem; }
.wd-chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .7rem; }
.ch-chip { display: inline-flex; align-items: center; gap: .3rem; padding: .3rem .55rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; font-size: .82rem; font-weight: 600; }
.ch-chip.done { background: color-mix(in srgb, var(--c) 20%, var(--surface)); border-color: var(--c); color: var(--text); }
.ch-chip:hover { border-color: var(--c); }
.wd-cat .btn { width: 100%; }

/* ---------- Stats ---------- */
.cat-bars { display: flex; flex-direction: column; gap: .8rem; }
.cat-bar-row { display: grid; grid-template-columns: 140px 1fr 52px; align-items: center; gap: .8rem; }
.cbl { font-weight: 600; font-size: .9rem; display: flex; align-items: center; gap: .4rem; }
.cbl::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.cbar { height: 12px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.cbar i { display: block; height: 100%; border-radius: 8px; background: var(--accent); transition: width .6s; }
.cbv { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-size: .85rem; }
.heatmap { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 5px; }
.hm-cell { aspect-ratio: 1; border-radius: 7px; display: grid; place-items: center; font-size: .68rem; font-weight: 600; color: color-mix(in srgb, var(--text) 60%, transparent); background: color-mix(in srgb, var(--accent) calc(var(--i) * 85%), var(--surface-2)); border: 1px solid var(--border); }
.hm-cell[style*="1.00"], .hm-cell[style*="0.9"] { color: #fff; }
.activity-heatmap { display: flex; gap: 3px; overflow-x: auto; padding-bottom: .3rem; }
.ah-week { display: flex; flex-direction: column; gap: 3px; }
.ah-day { width: 13px; height: 13px; border-radius: 3px; background: var(--surface-2); border: 1px solid var(--border); }
.ah-day.on { background: var(--accent); border-color: var(--accent); }
.book-progress-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: .5rem 1.5rem; }
.bp-row { display: grid; grid-template-columns: 120px 1fr 52px; align-items: center; gap: .6rem; font-size: .85rem; }
.bp-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bp-row.done .bp-name { color: var(--ok); }
.bp-bar { height: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.bp-bar i { display: block; height: 100%; background: var(--accent); }
.bp-val { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- Books ---------- */
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .8rem; margin-bottom: 1.5rem; }
.book-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 1rem; box-shadow: var(--shadow); color: var(--text); transition: transform .12s, border-color .15s; display: flex; flex-direction: column; gap: .4rem; }
.book-card:hover { transform: translateY(-3px); border-color: var(--accent); text-decoration: none; }
.book-card.done { border-color: color-mix(in srgb, var(--ok) 50%, var(--border)); }
.bc-top { display: flex; justify-content: space-between; align-items: center; }
.bc-name { font-family: var(--font-serif); font-weight: 600; }
.bc-check { color: var(--ok); font-weight: 700; }
.bc-meta { font-size: .78rem; color: var(--muted); }
.bc-bar { height: 6px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bc-bar i { display: block; height: 100%; background: var(--grad); }

/* ---------- Achievements ---------- */
.ach-progress { height: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-bottom: 1rem; }
.ach-progress i { display: block; height: 100%; background: var(--grad); transition: width .8s; }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.badge-card { text-align: center; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 1.3rem 1rem; box-shadow: var(--shadow); }
.badge-card.locked { opacity: .8; }
.badge-card.locked .badge-ico { filter: grayscale(1); opacity: .45; }
.badge-card.earned { border-color: color-mix(in srgb, #d4a017 55%, var(--border)); background: color-mix(in srgb, #d4a017 8%, var(--surface)); }
.badge-ico { font-size: 2.5rem; margin-bottom: .5rem; }
.badge-name { font-family: var(--font-serif); font-weight: 600; }
.badge-desc { font-size: .8rem; color: var(--muted); margin: .3rem 0 .6rem; min-height: 2.4em; }
.badge-status { font-size: .78rem; font-weight: 600; color: var(--muted); }
.badge-status.earned { color: #b8860b; }
.badge-mini-bar { height: 6px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin-bottom: .3rem; }
.badge-mini-bar i { display: block; height: 100%; background: var(--accent); }

/* ---------- Notes ---------- */
.seg { display: inline-flex; gap: .25rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: .2rem; }
.seg-btn { border: none; background: none; cursor: pointer; padding: .35rem .6rem; border-radius: 7px; font: inherit; font-size: .85rem; font-weight: 600; color: var(--muted); }
.seg-btn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.color-dot { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border); cursor: pointer; padding: 0; }
.color-dot.sel { border-color: var(--text); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 40%, transparent); }
.c-default { background: var(--surface); } .c-yellow { background: var(--hl-yellow); } .c-green { background: var(--hl-green); }
.c-blue { background: var(--hl-blue); } .c-red { background: var(--hl-red); } .c-purple { background: var(--hl-purple); }
.notes-masonry { columns: 3 260px; column-gap: 1rem; }
.note-card { break-inside: avoid; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 1rem; margin-bottom: 1rem; box-shadow: var(--shadow); border-left: 5px solid var(--border); }
.note-card.c-yellow { border-left-color: #e6b800; } .note-card.c-green { border-left-color: #3aa856; }
.note-card.c-blue { border-left-color: #3b82c4; } .note-card.c-red { border-left-color: #cc4b4b; } .note-card.c-purple { border-left-color: #8b5cb8; }
.note-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; }
.note-head h3 { font-size: 1.05rem; }
.note-tools { display: flex; gap: .1rem; opacity: 0; transition: opacity .15s; }
.note-card:hover .note-tools { opacity: 1; }
.note-ref { font-size: .75rem; color: var(--accent-ink); font-weight: 600; margin: .2rem 0; }
.note-body { font-size: .92rem; white-space: pre-wrap; margin: .4rem 0; }
.note-date { font-size: .72rem; color: var(--muted); }
.empty { text-align: center; padding: 3rem 1rem; }
.empty-ico { font-size: 3rem; margin-bottom: .5rem; }
.empty h3 { margin-bottom: .3rem; }
.empty p { margin-bottom: 1rem; }

/* ---------- Modal / palette ---------- */
.modal-backdrop, .picker-backdrop, .palette-backdrop { position: fixed; inset: 0; background: rgba(20,14,8,.5); backdrop-filter: blur(3px); z-index: 90; display: grid; place-items: start center; padding: 8vh 20px 20px; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-lg); width: 100%; max-width: 520px; padding: 1.5rem; animation: pop .18s ease; }
.modal-head, .picker-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.modal-head h2 { font-size: 1.3rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .5rem; }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(8px); } }

.palette { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; overflow: hidden; animation: pop .18s ease; }
.palette input { border: none; border-radius: 0; border-bottom: 1px solid var(--border); padding: 1rem 1.2rem; font-size: 1.1rem; background: var(--surface); }
.palette input:focus { box-shadow: none; }
.palette-results { list-style: none; max-height: 320px; overflow-y: auto; }
.palette-results li { padding: .7rem 1.2rem; cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.palette-results li.active, .palette-results li:hover { background: var(--surface-2); }
.palette-results .pr-ref { color: var(--muted); font-size: .85rem; }
.palette-hint { padding: .6rem 1.2rem; border-top: 1px solid var(--border); font-size: .78rem; color: var(--muted); }
kbd { background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 0 .35rem; font-size: .72rem; font-family: var(--font-ui); }

/* ---------- Reader ---------- */
.reader-body { background: var(--bg); }
.reader { flex: 1; display: flex; flex-direction: column; }
.reader-toolbar { position: sticky; top: 52px; z-index: 30; display: flex; align-items: center; gap: .5rem; padding: .6rem 20px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.rt-left { font-weight: 600; }
.rt-center { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.rt-right { margin-left: auto; display: flex; gap: .3rem; align-items: center; }
.type-controls { display: flex; gap: .1rem; border: 1px solid var(--border); border-radius: 9px; }
.reader-scroll { flex: 1; }
.reader-page { max-width: 760px; margin: 0 auto; padding: 2rem 20px; }
.reader-page.dual { max-width: 1100px; }
.reader-loading { text-align: center; color: var(--muted); padding: 3rem; }
.chapter-title { font-family: var(--font-serif); font-size: 2rem; margin-bottom: 1.4rem; text-align: center; }
.verses { font-family: var(--reader-font, var(--font-serif)); font-size: var(--reader-size, 18px); line-height: 1.85; }
.verses.sans { --reader-font: var(--font-ui); }
.verse { cursor: pointer; border-radius: 4px; padding: 0 .1em; transition: background .15s; }
.verse:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.verse .vn { font-size: .68em; font-weight: 700; color: var(--gold); vertical-align: super; margin-right: .25em; user-select: none; }
.verse.hl-yellow { background: var(--hl-yellow); } .verse.hl-green { background: var(--hl-green); }
.verse.hl-blue { background: var(--hl-blue); } .verse.hl-red { background: var(--hl-red); } .verse.hl-purple { background: var(--hl-purple); }
.dual-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }
.dual-cols .col h4 { font-family: var(--font-ui); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: .8rem; }
.chapter-nav { max-width: 760px; margin: 0 auto; padding: 1.5rem 20px 4rem; display: flex; justify-content: space-between; align-items: center; }
#rProgressMark { font-size: .85rem; color: var(--muted); }

.reader.focus .site-header, .reader.focus .rt-center, .reader.focus .rt-left .icon-btn { }
body.focus-mode .site-header { display: none; }
body.focus-mode .reader-toolbar { top: 0; }

.picker { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; max-height: 76vh; display: flex; flex-direction: column; overflow: hidden; }
.picker-head { padding: 1rem; margin: 0; border-bottom: 1px solid var(--border); gap: .5rem; }
.picker-head input { flex: 1; }
.picker-body { overflow-y: auto; padding: 1rem; }
.picker-book { margin-bottom: .8rem; }
.picker-book .pb-name { font-weight: 700; font-family: var(--font-serif); margin-bottom: .4rem; }
.picker-chaps { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 4px; }
.picker-chaps a { display: grid; place-items: center; aspect-ratio: 1; border: 1px solid var(--border); border-radius: 7px; font-size: .8rem; color: var(--text); background: var(--surface-2); }
.picker-chaps a:hover { border-color: var(--accent); text-decoration: none; }

.notes-drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 380px; max-width: 92vw; background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg); z-index: 60; display: flex; flex-direction: column; animation: slideIn .25s ease; }
@keyframes slideIn { from { transform: translateX(100%); } }
.nd-head { display: flex; justify-content: space-between; align-items: center; padding: 1rem; border-bottom: 1px solid var(--border); }
.nd-head h3 { font-size: 1.1rem; }
.nd-list { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .7rem; }
.nd-note { border: 1px solid var(--border); border-radius: 10px; padding: .7rem; border-left: 4px solid var(--border); }
.nd-note h4 { font-size: .95rem; margin-bottom: .2rem; }
.nd-note p { font-size: .85rem; white-space: pre-wrap; }
.nd-note .nd-note-tools { display: flex; gap: .3rem; margin-top: .4rem; }
.nd-form { border-top: 1px solid var(--border); padding: 1rem; display: flex; flex-direction: column; gap: .6rem; }
.nd-colors { display: flex; gap: .5rem; }
.nd-actions { display: flex; gap: .5rem; }

.hl-popover { position: absolute; z-index: 70; display: flex; gap: .3rem; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: .4rem; }
.hl-swatch { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--border); cursor: pointer; }
.hl-swatch.c-yellow { background: var(--hl-yellow); } .hl-swatch.c-green { background: var(--hl-green); }
.hl-swatch.c-blue { background: var(--hl-blue); } .hl-swatch.c-red { background: var(--hl-red); } .hl-swatch.c-purple { background: var(--hl-purple); }
.hl-clear { background: var(--surface-2); display: grid; place-items: center; font-size: .8rem; }

/* ---------- Study reader ---------- */
.reader-layout { flex: 1; display: block; }
.reader-scroll { min-height: 60vh; transition: padding-right .2s; }
.reader-page { max-width: 720px; margin: 0 auto; padding: 1.5rem 20px 2rem; }
.reader-page.sans .verses { --reader-font: var(--font-ui); }
.chapter-block { margin-bottom: 1.5rem; }
.chapter-block .chapter-title { font-family: var(--font-serif); font-size: 1.9rem; font-weight: 600; text-align: center; margin: 1.6rem 0 1.5rem; color: var(--text); }
.chapter-block .chapter-title::after { content: ''; display: block; width: 42px; height: 2px; background: var(--gold); margin: .7rem auto 0; opacity: .8; }
.verses { font-family: var(--reader-font, var(--font-serif)); font-size: var(--reader-size, 19px); line-height: 1.9; }
.dropcap { float: left; font-family: var(--font-serif); font-weight: 600; font-size: 3.1em; line-height: .78; margin: .06em .1em -.04em 0; color: var(--gold); }
.verse.first .vn { display: none; }
.verse { cursor: pointer; border-radius: 5px; padding: 0 .12em; transition: background .12s; scroll-margin-top: 120px; }
.verse:hover { background: color-mix(in srgb, var(--accent) 9%, transparent); }
.verse.active { background: color-mix(in srgb, var(--accent) 16%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent); }
.verse .vn { font-size: .66em; font-weight: 700; color: var(--gold); vertical-align: super; margin-right: .28em; user-select: none; }
.verse.has-ref .vn { border-bottom: 1.5px dotted color-mix(in srgb, var(--gold) 70%, transparent); }

/* Verse-by-verse layout: each verse on its own line, numbers in a gold gutter */
#rLayoutBtn .ico-para { display: none; }
body.verse-mode #rLayoutBtn .ico-verse { display: none; }
body.verse-mode #rLayoutBtn .ico-para { display: inline-block; }
body.verse-mode .verses { display: block; }
body.verse-mode .verse {
  display: block; position: relative;
  padding: .32rem .5rem .32rem 2.9rem;
  margin: .12rem 0; border-radius: 8px;
  scroll-margin-top: 120px;
}
body.verse-mode .verse .vn {
  position: absolute; left: 0; top: .32rem;
  width: 2.2rem; text-align: right;
  font-size: .82em; vertical-align: baseline; margin: 0;
  border-bottom: none;
}
body.verse-mode .verse.first .vn { display: block; }
body.verse-mode .verse.has-ref { }
body.verse-mode .verse.has-ref::before {
  content: ''; position: absolute; left: 2.5rem; top: .7rem;
  width: 4px; height: 4px; border-radius: 50%; background: var(--gold);
}
body.verse-mode .dropcap { float: none; font-size: 1em; line-height: inherit; margin: 0; font-weight: 700; }
body.verse-mode .verse:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
body.verse-mode .verse.active { background: color-mix(in srgb, var(--accent) 13%, transparent); box-shadow: inset 3px 0 0 var(--gold); }
.verse.hl-yellow { background: var(--hl-yellow); } .verse.hl-green { background: var(--hl-green); }
.verse.hl-blue { background: var(--hl-blue); } .verse.hl-red { background: var(--hl-red); } .verse.hl-purple { background: var(--hl-purple); }
.load-sentinel { height: 1px; }
.reader-end { text-align: center; color: var(--muted); padding: 2rem 20px 4rem; }

/* Study panel */
.study-panel { position: fixed; z-index: 55; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; }
.sp-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 1rem 1.1rem .7rem; border-bottom: 1px solid var(--border); }
.sp-eyebrow { display: block; font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); font-weight: 700; }
.sp-head strong { font-family: var(--font-serif); font-size: 1.2rem; }
.sp-verse { padding: .9rem 1.1rem; font-family: var(--font-serif); font-size: 1.05rem; line-height: 1.6; color: var(--text); background: var(--surface-2); }
.sp-actions { padding: .8rem 1.1rem; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: .7rem; }
.sp-hl { display: flex; gap: .45rem; align-items: center; }
.sp-hl .hl-swatch { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--border); cursor: pointer; }
.sp-hl .hl-swatch.sel { box-shadow: 0 0 0 2px var(--accent); }
.hl-swatch.c-yellow { background: var(--hl-yellow); } .hl-swatch.c-green { background: var(--hl-green); }
.hl-swatch.c-blue { background: var(--hl-blue); } .hl-swatch.c-red { background: var(--hl-red); } .hl-swatch.c-purple { background: var(--hl-purple); }
.hl-swatch.hl-clear { background: var(--surface-2); display: grid; place-items: center; font-size: .75rem; color: var(--muted); }
.sp-btns { display: flex; gap: .5rem; }
.chip-btn { flex: 1; border: 1px solid var(--border); background: var(--surface-2); border-radius: 9px; padding: .5rem; cursor: pointer; font: inherit; font-size: .88rem; font-weight: 600; color: var(--text); }
.chip-btn:hover { border-color: var(--accent); }
.sp-noteform { padding: .8rem 1.1rem; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: .5rem; }
.sp-noteactions { display: flex; gap: .5rem; }
.sp-section { padding: 1rem 1.1rem; flex: 1; overflow-y: auto; }
.sp-title { font-family: var(--font-ui); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: .7rem; display: flex; align-items: baseline; gap: .5rem; }
.sp-hint { text-transform: none; letter-spacing: 0; font-weight: 400; font-size: .72rem; }
.sp-refs { display: flex; flex-direction: column; gap: .7rem; }
.xref { border-left: 3px solid color-mix(in srgb, var(--accent) 40%, var(--border)); padding: .2rem 0 .2rem .7rem; }
.xref-ref { font-weight: 700; font-size: .9rem; color: var(--accent-ink); }
.xref-text { font-family: var(--font-serif); font-size: .92rem; line-height: 1.5; margin-top: .2rem; }
.sp-title select { margin-left: auto; font-size: .75rem; padding: .2rem .35rem; }
.sp-commentary { border-top: 1px solid var(--border); }
.sp-commentary-body { max-height: 280px; overflow-y: auto; }
.cm-text { font-family: var(--font-serif); font-size: .95rem; line-height: 1.65; color: var(--text); white-space: pre-wrap; }
.cm-scope { display: inline-block; font-size: .72rem; color: var(--muted); margin-bottom: .3rem; }
.sp-btns { flex-wrap: wrap; }
.sp-notes { padding: 0 1.1rem 1.1rem; }
.sp-note { border: 1px solid var(--border); border-left: 4px solid var(--border); border-radius: 8px; padding: .6rem; margin-bottom: .5rem; }
.sp-note.c-yellow { border-left-color: #e6b800; } .sp-note.c-green { border-left-color: #3aa856; }
.sp-note.c-blue { border-left-color: #3b82c4; } .sp-note.c-red { border-left-color: #cc4b4b; } .sp-note.c-purple { border-left-color: #8b5cb8; }
.sp-note strong { font-size: .92rem; } .sp-note p { font-size: .85rem; white-space: pre-wrap; margin: .2rem 0; }
.study-fab { position: fixed; bottom: 20px; right: 20px; z-index: 45; width: 52px; height: 52px; border-radius: 50%; border: none; background: var(--grad); color: #fff; font-size: 1.3rem; cursor: pointer; box-shadow: var(--shadow-lg); }

.rt-title { font-weight: 700; font-size: 1rem; }

/* Desktop: right drawer */
@media (min-width: 1100px) {
  .study-panel { top: 0; right: 0; bottom: 0; width: 400px; }
  body.study-open .reader-scroll { padding-right: 400px; }
}
/* Mobile/tablet: bottom sheet */
@media (max-width: 1099px) {
  .study-panel { left: 0; right: 0; bottom: 0; max-height: 76vh; border-radius: 18px 18px 0 0; animation: slideUp .22s ease; }
  @keyframes slideUp { from { transform: translateY(100%); } }
}

/* ---------- Tables / admin ---------- */
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; padding: .6rem .7rem; border-bottom: 2px solid var(--border); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.table td { padding: .7rem; border-bottom: 1px solid var(--border); }
.pill { font-size: .72rem; font-weight: 700; padding: .15rem .5rem; border-radius: 20px; background: var(--surface-2); border: 1px solid var(--border); text-transform: uppercase; }
.pill.admin { background: color-mix(in srgb, var(--accent) 18%, var(--surface)); color: var(--accent-ink); border-color: transparent; }
.admin-nav { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: 1.5rem; border-bottom: 1px solid var(--border); }
.admin-nav a { padding: .6rem .9rem; color: var(--muted); font-weight: 600; font-size: .9rem; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.admin-nav a:hover { color: var(--text); text-decoration: none; }
.admin-nav a.active { color: var(--accent-ink); border-bottom-color: var(--accent); }
.rp-cat { border: 1px solid var(--border); border-radius: 12px; padding: 1rem; border-left: 4px solid var(--c); }
.rp-cat legend { font-weight: 700; padding: 0 .4rem; }
.danger-zone { border-color: color-mix(in srgb, var(--err) 25%, var(--border)); }
.danger-zone h2 { color: var(--err); }
.dz-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .9rem 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.dz-row:last-child { border-bottom: none; }
.dz-row form { display: flex; gap: .5rem; align-items: center; }
.dz-row input { width: auto; }

/* ---------- Prose ---------- */
.prose h2 { margin: 1.5rem 0 .6rem; font-size: 1.3rem; }
.prose p, .prose li { color: var(--text); }
.prose ul { padding-left: 1.3rem; margin: .5rem 0; }
.prose li { margin: .3rem 0; }

/* ---------- AI study companion ---------- */
.sp-ai-ask { display: flex; gap: .4rem; margin-top: .5rem; }
.sp-ai-ask input { font-size: .88rem; }
.sp-ai-ask .chip-btn { flex: 0 0 auto; }
.sp-ai-body { margin-top: .6rem; font-family: var(--font-serif); font-size: .95rem; line-height: 1.6; white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--border); border-left: 3px solid var(--gold); border-radius: 8px; padding: .7rem .8rem; }
.sp-ai-note { font-size: .7rem; color: var(--muted); margin-top: .45rem; }

/* ---------- Search ---------- */
.search-bar { display: flex; align-items: center; gap: .6rem; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .5rem .5rem .5rem .85rem; margin-bottom: 1.4rem; }
.search-bar .ico { width: 20px; height: 20px; color: var(--muted); }
.search-bar input { border: none; background: transparent; padding: .45rem .2rem; font-size: 1.05rem; }
.search-bar input:focus { outline: none; box-shadow: none; }
.search-count { margin: 0 0 1rem; }
.search-results { list-style: none; display: flex; flex-direction: column; gap: .1rem; }
.search-result { padding: .8rem .9rem; border-radius: 10px; border-bottom: 1px solid var(--border); }
.search-result:hover { background: var(--surface-2); }
.sr-ref { display: inline-block; font-weight: 700; color: var(--accent-ink); font-size: .88rem; margin-bottom: .15rem; }
.sr-text { font-family: var(--font-serif); font-size: 1.02rem; line-height: 1.55; color: var(--text); }
mark { background: var(--gold-soft); color: inherit; border-radius: 3px; padding: 0 .12em; }
.search-examples { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip-link { display: inline-block; padding: .35rem .7rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); color: var(--text); font-size: .88rem; }
.chip-link:hover { border-color: var(--accent); text-decoration: none; }

/* Read-aloud (audio) */
#rListenBtn .ico-stop { display: none; }
body.audio-playing #rListenBtn .ico-listen { display: none; }
body.audio-playing #rListenBtn .ico-stop { display: inline-block; color: var(--accent); }
.verse.speaking { background: var(--gold-soft); box-shadow: inset 3px 0 0 var(--gold); border-radius: 6px; }

/* Deep-linked verse flash (from search results) */
@keyframes verseFlash { 0%,55% { background: var(--gold-soft); box-shadow: inset 3px 0 0 var(--gold); } 100% { background: transparent; box-shadow: none; } }
.verse.flash { animation: verseFlash 2.4s ease; border-radius: 6px; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); margin-top: auto; }
.footer-inner { max-width: 1080px; margin: 0 auto; padding: 1.5rem 20px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; }
.footer-inner strong { font-family: var(--font-serif); }
.footer-inner .muted { margin-left: .5rem; font-size: .85rem; }
.footer-links { display: flex; gap: 1rem; }
.footer-links a { color: var(--muted); font-size: .9rem; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .dash-hero { grid-template-columns: 1fr; }
  .main-nav { display: none; position: absolute; top: 100%; left: 0; right: 0; flex-direction: column; background: var(--surface); border-bottom: 1px solid var(--border); padding: .5rem; box-shadow: var(--shadow-lg); }
  .main-nav.open { display: flex; }
  .nav-toggle { display: inline-flex; }
  .dual-cols { grid-template-columns: 1fr; gap: 1rem; }
  .field-row { grid-template-columns: 1fr; }
  .cat-bar-row { grid-template-columns: 100px 1fr 46px; }
  .notes-masonry { columns: 1; }
}
@media (max-width: 560px) {
  .current-readings { grid-template-columns: 1fr; }
  .footer-inner { flex-direction: column; align-items: flex-start; }
  .reader-toolbar { top: 0; position: sticky; }
}
