/* Citirea Bibliei — mobile-first, portrait phone. Adapted from VerseLearning app.css. */
:root {
  --bg: #0f172a;
  --bg2: #1e293b;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --accent: #4f46e5;
  --accent2: #7c3aed;
  --ok: #16a34a;
  --bad: #dc2626;
  --gold: #f59e0b;
  --radius: 16px;
  --tap: 48px;
  --pad: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: linear-gradient(160deg, var(--bg), var(--bg2));
  color: #e2e8f0;
  font: 16px/1.45 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior: none;
}
#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  padding: 0 var(--pad);
  padding-top: var(--safe-top);
  padding-bottom: calc(var(--safe-bottom) + 72px);
}

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 2px; position: sticky; top: 0; z-index: 5;
  background: linear-gradient(160deg, var(--bg), transparent);
}
.topbar .brand { font-weight: 700; font-size: 18px; }
.topbar .me-wrap { display: flex; align-items: center; gap: 8px; }
.topbar .me { font-size: 13px; color: var(--muted); }
.topbar .me b { color: var(--gold); }
.topbar .logout-btn {
  width: 34px; height: 34px; margin: 0; padding: 0; border-radius: 8px;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.15);
  color: #e2e8f0; font-size: 16px; line-height: 1; cursor: pointer;
}
.topbar .logout-btn:active { transform: scale(.95); }

main { flex: 1; padding-bottom: 8px; }

/* cards / inputs */
.card {
  background: var(--card); color: var(--ink);
  border-radius: var(--radius); padding: 22px 18px; margin: 8px 0;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
label { display: block; font-size: 13px; font-weight: 600; color: var(--ink); margin: 12px 0 6px; }
input, select, textarea {
  width: 100%; border: 2px solid #e2e8f0; border-radius: 12px;
  padding: 10px 14px; font-size: 16px; background: #f8fafc; color: var(--ink); font-family: inherit;
}
input { height: var(--tap); }
textarea { resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }

button {
  width: 100%; height: var(--tap); border: none; border-radius: 12px;
  font-size: 16px; font-weight: 700; cursor: pointer; margin-top: 16px;
}
button.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; }
button.ghost { background: transparent; color: var(--accent); border: 2px solid var(--accent); }
button.danger { color: var(--bad); border-color: var(--bad); }
button.small { height: 38px; font-size: 13px; margin-top: 10px; border-radius: 10px; }
button:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: default; }

h1 { margin: 0 0 8px; font-size: 24px; }
h2 { margin: 8px 0; font-size: 18px; }
h3.sec-h { margin: 18px 0 8px; font-size: 14px; color: var(--ink); }
.muted { color: var(--muted); font-size: 13px; }
.hint-info { color: var(--muted); font-size: 12px; text-align: center; margin-top: 14px; }

.auth .switch { text-align: center; margin-top: 14px; font-size: 14px; color: var(--muted); }
.auth .switch a { color: var(--accent); font-weight: 700; text-decoration: none; }
.auth .links { text-align: center; margin-top: 8px; font-size: 13px; }
.auth .links a { color: var(--accent); text-decoration: none; }
.err { color: var(--bad); text-align: center; margin-top: 8px; font-size: 14px; }
.ok-box { background: #dcfce7; color: #166534; border-radius: 12px; padding: 12px; margin-top: 12px; font-size: 14px; word-break: break-all; }
.ok-box a { color: var(--accent); font-weight: 700; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 6px; }
.stat { background: #f1f5f9; border-radius: 12px; padding: 12px; text-align: center; }
.stat .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.stat .v { font-size: 22px; font-weight: 800; color: var(--ink); }
.stat .v.gold { color: var(--gold); }
.stat .v.flame { color: var(--bad); }
.stat .v.flame.alive { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.12)} }

/* tabbar */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 9;
  max-width: 480px; margin: 0 auto; display: flex;
  background: rgba(15,23,42,.96); padding: 6px 6px calc(6px + var(--safe-bottom));
  border-top: 1px solid rgba(255,255,255,.08);
}
.tabbar button {
  flex: 1; height: 44px; margin: 0 4px; background: transparent;
  color: #94a3b8; font-weight: 700; font-size: 12px; border-radius: 10px;
}
.tabbar button.active { background: var(--accent); color: #fff; }

/* continue card */
.continue-card { text-align: center; }
.continue-card .ct-title { font-size: 15px; color: var(--muted); margin-bottom: 6px; }
.continue-card .ct-ref { font-size: 22px; font-weight: 800; color: var(--ink); }
.continue-card .ct-btn { margin-top: 12px; }

/* quote card */
.quote-card .q-text { font-size: 17px; line-height: 1.5; color: var(--ink); font-style: italic; }
.quote-card .q-ref { text-align: right; color: var(--accent); font-weight: 700; margin-top: 8px; }

/* bible grid (66 dots) — 6 columns of finger-friendly tiles, filled by progress */
.bible-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.bible-grid .dot {
  position: relative; overflow: hidden;
  aspect-ratio: 1; min-height: 44px; border-radius: 8px; background: #e2e8f0; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 3px; font-size: 11px; color: #334155;
  font-weight: 800; border: 1px solid #cbd5e1;
}
.bible-grid .dot.ot { background: #dbeafe; }
.bible-grid .dot.nt { background: #fce7f3; }
/* Fill bar = a full-height layer scaled down from the bottom by --fill (0..1).
   Using transform (not a % height) is robust against aspect-ratio's non-definite height. */
.bible-grid .dot::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; bottom: 0; z-index: 1;
  transform: scaleY(var(--fill, 0)); transform-origin: bottom;
  background: linear-gradient(to top, var(--accent), var(--accent2));
  transition: transform .45s ease;
}
.bible-grid .dot span { position: relative; z-index: 2; }
.bible-grid .dot.partial {
  color: #0f172a;
  text-shadow: 0 1px 3px rgba(255,255,255,.95), 0 0 7px rgba(255,255,255,.7);
}
/* fully read: green, glowing, with a moving shimmer + a check beside the name */
.bible-grid .dot.done {
  background: #16a34a; border-color: #15803d; color: #fff;
  box-shadow: 0 0 10px rgba(34,197,94,.55), inset 0 0 8px rgba(255,255,255,.25);
  animation: dot-glow 2.2s ease-in-out infinite;
}
.bible-grid .dot.done::before {
  transform: scaleY(1);
  background: linear-gradient(135deg, #16a34a, #4ade80, #22c55e, #16a34a);
  background-size: 220% 220%;
  animation: dot-shimmer 3s linear infinite;
}
.bible-grid .dot.done span,
.bible-grid .dot .done-tick { position: relative; z-index: 2; }
.bible-grid .dot .done-tick {
  font-style: normal; font-weight: 900; font-size: 12px; color: #fff;
  margin-left: 2px; text-shadow: 0 1px 2px rgba(0,0,0,.35);
}
@keyframes dot-shimmer { 0% { background-position: 0% 50%; } 100% { background-position: 220% 50%; } }
@keyframes dot-glow { 0%,100% { box-shadow: 0 0 8px rgba(34,197,94,.45), inset 0 0 8px rgba(255,255,255,.25); } 50% { box-shadow: 0 0 14px rgba(34,197,94,.75), inset 0 0 8px rgba(255,255,255,.25); } }

/* library */
.lib-tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.lib-tab {
  flex: 1; height: 40px; margin: 0; border-radius: 10px; font-size: 13px; font-weight: 700;
  background: #f1f5f9; color: var(--muted); border: 2px solid transparent; cursor: pointer;
}
.lib-tab.active { background: #eef2ff; color: var(--accent); border-color: var(--accent); }
.lib-list { display: grid; gap: 8px; }
.lib-item {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px;
  background: #f1f5f9; border-radius: 12px; padding: 12px 14px; cursor: pointer;
}
.lib-item .li-name { font-weight: 700; color: var(--ink); }
.lib-item .li-meta { font-size: 12px; color: var(--muted); }
.lib-item .li-pct { font-weight: 800; color: var(--accent); font-size: 13px; }
.lib-item .li-bar { grid-column: 1 / -1; height: 6px; background: #e2e8f0; border-radius: 6px; overflow: hidden; }
.lib-item .li-bar > div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); }

/* reflections feed */
.refl-list { display: grid; gap: 8px; }
.refl-item {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 8px;
  background: #f1f5f9; border-radius: 12px; padding: 12px 14px; cursor: pointer;
}
.refl-item .ri-ref { font-weight: 700; color: var(--ink); }
.refl-item .ri-meta { font-size: 12px; color: var(--muted); grid-column: 1; }
.refl-item .ri-count { font-weight: 800; color: var(--accent); font-size: 13px; white-space: nowrap; }

/* chapters grid */
.ch-progress { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.ch-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.ch-grid .ch {
  aspect-ratio: 1; border-radius: 10px; background: #f1f5f9; border: 2px solid #e2e8f0;
  display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--ink);
  cursor: pointer; font-size: 14px;
}
.ch-grid .ch.read { background: #dcfce7; border-color: var(--ok); color: var(--ok); }
.ch-grid .ch:active { transform: scale(.95); }

/* reader */
.reader { padding: 16px; }
.reader-back { display: flex; gap: 8px; margin-bottom: 8px; }
.reader-back button { width: auto; flex: 1; margin: 0; }
.reader-foot {
  display: flex; gap: 8px; margin-top: 18px;
  position: sticky; bottom: 8px; z-index: 4;
  background: linear-gradient(to top, var(--card) 70%, rgba(255,255,255,.85));
  padding: 8px 0 4px; border-radius: 12px;
  box-shadow: 0 -6px 14px rgba(15,23,42,.10);
}
.reader-foot button { width: auto; flex: 1; margin: 0; }
.reader-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.reader-head .nav-arrow { width: 44px; height: 44px; margin: 0; padding: 0; font-size: 20px; }
.reader-ref { font-size: 18px; font-weight: 700; color: var(--ink); text-align: center; flex: 1; }
.reader-ref b { color: var(--accent); }
.audio-bar { background: #f1f5f9; border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; }
.audio-bar .ab-row { display: flex; align-items: center; gap: 10px; }
.audio-bar .ab-play {
  width: 44px; height: 44px; margin: 0; border-radius: 50%; flex: 0 0 44px;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; font-size: 18px;
}
.audio-bar .ab-info { flex: 1; font-size: 12px; color: var(--muted); }
.audio-bar .ab-time { font-weight: 700; color: var(--ink); }
.audio-bar audio { width: 100%; margin-top: 8px; }
.audio-bar .ab-no { font-size: 13px; color: var(--muted); }
.chapter-text { font-size: var(--reader-font, 17px); line-height: 1.7; color: var(--ink); }
.chapter-text .vrow { margin-bottom: 6px; }
.chapter-text sup { color: var(--accent); font-weight: 800; font-size: 12px; margin-right: 4px; user-select: none; }
.chapter-text .vrow.speaking { background: #eef2ff; border-radius: 6px; box-shadow: -3px 0 0 var(--accent); }
.reflect-box { margin-top: 14px; padding: 14px; background: #f8fafc; border-radius: 12px; }
.reflect-box textarea { margin-top: 6px; }

/* comments */
.comments-list { display: grid; gap: 10px; margin: 12px 0; }
.comment-card { background: #f1f5f9; border-radius: 12px; padding: 12px 14px; }
.comment-card.reply { margin-left: 18px; border-left: 3px solid var(--accent); }
.comment-card .cc-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.comment-card .cc-handle { font-weight: 800; font-size: 13px; color: var(--accent); }
.comment-card .cc-time { font-size: 11px; color: var(--muted); }
.comment-card .cc-body { font-size: 14px; line-height: 1.5; color: var(--ink); white-space: pre-wrap; word-break: break-word; }
.comment-card .cc-actions { margin-top: 6px; }
.comment-card .cc-actions button { width: auto; height: 30px; margin: 0 6px 0 0; padding: 0 12px; font-size: 12px; border-radius: 8px; }
.c-compose { margin-top: 14px; padding: 14px; background: #f8fafc; border-radius: 12px; }
.c-compose textarea { margin-top: 6px; }

/* achievements grid */
.badges-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.ach { background: #f1f5f9; border-radius: 14px; padding: 14px; text-align: center; }
.ach .emoji { font-size: 30px; display: block; filter: grayscale(1); opacity: .4; }
.ach.earned { background: #ecfccb; }
.ach.earned .emoji { filter: none; opacity: 1; }
.ach .name { font-weight: 800; font-size: 13px; margin-top: 4px; }
.ach .desc { font-size: 11px; color: var(--muted); }

/* progress bars */
.book-bars { display: grid; gap: 8px; }
.book-bar { display: grid; grid-template-columns: 92px 1fr 46px; align-items: center; gap: 8px; font-size: 12px; }
.book-bar .bb-name { color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book-bar .bb-track { height: 10px; background: #e2e8f0; border-radius: 6px; overflow: hidden; }
.book-bar .bb-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); }
.book-bar .bb-pct { color: var(--muted); font-weight: 700; text-align: right; }

/* heatmap */
.heatmap { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); gap: 3px; overflow-x: auto; padding-bottom: 6px; }
.heatmap .cell { width: 12px; height: 12px; border-radius: 3px; background: #e2e8f0; }
.heatmap .cell.l1 { background: #c7d2fe; }
.heatmap .cell.l2 { background: #818cf8; }
.heatmap .cell.l3 { background: var(--accent); }
.heatmap .cell.l4 { background: var(--accent2); }

/* profile */
#profile-info { font-size: 15px; color: var(--ink); margin-bottom: 8px; }
#profile-info .pi-row { padding: 6px 0; border-bottom: 1px solid #f1f5f9; }
#profile-info .pi-k { color: var(--muted); font-size: 12px; }

/* text-size control */
.textsize-row { display: flex; align-items: center; gap: 12px; }
.textsize-row input[type="range"] { flex: 1; height: 28px; padding: 0; }
.textsize-val { font-weight: 800; color: var(--accent); min-width: 56px; text-align: right; }
.textsize-sample {
  margin-top: 10px; padding: 12px 14px; background: #f8fafc; border-radius: 10px;
  color: var(--ink); line-height: 1.55; border: 1px solid #e2e8f0;
  font-size: var(--reader-font, 17px);
}

/* toast */
.toast {
  position: fixed; left: 50%; bottom: calc(88px + var(--safe-bottom)); transform: translateX(-50%);
  background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 12px;
  font-size: 14px; z-index: 50; max-width: 90%; text-align: center;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}

/* confetti / milestone overlay */
.confetti {
  position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center;
  background: rgba(15,23,42,.78); padding: 24px;
}
.confetti .cc-card {
  background: var(--card); border-radius: 20px; padding: 28px 22px; text-align: center; max-width: 340px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.confetti .cc-emoji { font-size: 56px; }
.confetti .cc-title { font-size: 22px; font-weight: 900; color: var(--ink); margin: 8px 0; }
.confetti .cc-quote { font-size: 14px; color: var(--muted); font-style: italic; margin: 8px 0 16px; }
.confetti .cc-quote b { color: var(--accent); font-style: normal; }
.confetti button { margin-top: 6px; }

/* whole-Bible celebration: bigger, golden, with rotating rays */
.confetti.big .cc-card { max-width: 380px; background: linear-gradient(160deg, #fffbeb, #fef3c7); border: 2px solid #f59e0b; overflow: hidden; }
.confetti .cc-crown .cc-emoji { font-size: 72px; animation: crown-bounce 1.4s ease-in-out infinite; }
.confetti .cc-crown .cc-title { font-size: 26px; background: linear-gradient(135deg, #b45309, #f59e0b, #fde68a); -webkit-background-clip: text; background-clip: text; color: transparent; }
.confetti .cc-rays {
  position: absolute; inset: -40%; z-index: 0; pointer-events: none;
  background: conic-gradient(from 0deg, transparent 0 18deg, rgba(245,158,11,.18) 18deg 22deg, transparent 22deg 40deg,
    rgba(245,158,11,.18) 40deg 44deg, transparent 44deg 62deg, rgba(245,158,11,.18) 62deg 66deg, transparent 66deg 84deg,
    rgba(245,158,11,.18) 84deg 88deg, transparent 88deg);
  animation: spin 8s linear infinite;
}
.confetti .cc-crown > * { position: relative; z-index: 1; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes crown-bounce { 0%,100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-6px) scale(1.08); } }

@media (min-width: 600px) { #app { box-shadow: 0 0 60px rgba(0,0,0,.4); min-height: 100vh; border-radius: 0; } }