/* תהילים עולמי — עיצוב: לילה כחול עמוק וזהב (נרות שבת), משטחים לבנים נקיים. מובייל קודם, תחושת אפליקציה. */
:root {
  --navy: #0f1b3d;
  --navy-2: #1c2c63;
  --navy-3: #2a3d80;
  --gold: #c39a3e;
  --gold-2: #e8c873;
  --gold-soft: #f6edd6;
  --bg: #f3f4f8;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --ink: #141c36;
  --muted: #5d6784;
  --line: #e2e5ee;
  --ok: #23845a;
  --ok-soft: #e3f4ec;
  --danger: #c0392b;
  --danger-soft: #fbe9e7;
  --shadow: 0 1px 2px rgba(15, 27, 61, .06), 0 8px 24px rgba(15, 27, 61, .06);
  --radius: 18px;
  --display: "Frank Ruhl Libre", "David Libre", "Times New Roman", serif;
  --body: "Heebo", "Assistant", "Segoe UI", Arial, sans-serif;
  --tab-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a1022; --surface: #131b35; --surface-2: #18213f; --ink: #edf0f8; --muted: #9ba5c2; --line: #253055;
    --gold-soft: #2c2716; --ok-soft: #12301f; --danger-soft: #3a1714; --navy-3: #3b52a3;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 16px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 8px; }

/* ───── מעטפת ───── */
.app { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
  background: color-mix(in srgb, var(--navy) 94%, transparent); color: #fff; backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark { width: 38px; height: 38px; border-radius: 10px; display: block; object-fit: cover; box-shadow: 0 0 0 1px rgba(232, 200, 115, .45); }
.brand-name { font-family: var(--display); font-weight: 900; font-size: 1.3rem; letter-spacing: .01em; }
.topbar-cta { text-decoration: none; font-weight: 700; font-size: .92rem; padding: 7px 14px; border-radius: 99px; background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .22); }
.topbar-cta:hover { background: rgba(255, 255, 255, .2); }
.view { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 18px max(16px, env(safe-area-inset-right, 0px)) calc(var(--tab-h) + 28px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); outline: none; }
.view.wide { max-width: 1180px; }
.boot { min-height: 50vh; display: grid; place-items: center; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--gold); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 30; display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-inline: max(8px, env(safe-area-inset-left, 0px)) max(8px, env(safe-area-inset-right, 0px));
  background: color-mix(in srgb, var(--surface) 96%, transparent); border-top: 1px solid var(--line); backdrop-filter: blur(12px);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: .74rem; font-weight: 600; }
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.on { color: var(--navy-3); }
.tabbar a.on svg { stroke-width: 2.2; }
@media (prefers-color-scheme: dark) { .tabbar a.on { color: var(--gold-2); } }
body.admin-mode .tabbar { display: none; }
body.admin-mode .view { padding-bottom: 40px; }

/* ───── טיפוגרפיה ───── */
h1, h2, h3 { margin: 0; line-height: 1.2; text-wrap: balance; }
.h-display { font-family: var(--display); font-weight: 900; }
.section-title { font-family: var(--display); font-weight: 700; font-size: 1.45rem; margin: 30px 0 12px; }
.lead { color: var(--muted); margin: 6px 0 0; }
.eyebrow { font-size: .78rem; font-weight: 700; letter-spacing: .06em; color: var(--gold); }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.num { font-variant-numeric: tabular-nums; }

/* ───── הירו ───── */
.hero {
  position: relative; overflow: hidden; border-radius: 26px; padding: 26px 22px 22px; color: #fff;
  background: radial-gradient(120% 90% at 85% 0%, #2d4290 0%, transparent 60%), linear-gradient(160deg, var(--navy-2), var(--navy) 70%);
  box-shadow: 0 18px 40px rgba(15, 27, 61, .28);
}
.hero::after {
  content: ""; position: absolute; inset: auto -40px -60px auto; width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle, rgba(232, 200, 115, .35), transparent 65%); pointer-events: none;
}
.hero .eyebrow { color: var(--gold-2); }
.hero-logo { float: inline-end; width: 96px; height: 96px; border-radius: 22px; margin: -4px 0 8px 12px; box-shadow: 0 10px 26px rgba(0, 0, 0, .35), 0 0 0 1px rgba(232, 200, 115, .35); position: relative; z-index: 1; }
@media (min-width: 560px) { .hero-logo { width: 128px; height: 128px; border-radius: 28px; } }
.hero-count { display: flex; align-items: baseline; gap: 12px; margin-top: 10px; }
.hero-count b { font-family: var(--display); font-size: clamp(3.4rem, 15vw, 5rem); font-weight: 900; line-height: 1; color: var(--gold-2); font-variant-numeric: tabular-nums; }
.hero-count span { font-size: 1.15rem; font-weight: 600; line-height: 1.3; }
.hero p { margin: 12px 0 0; color: rgba(255, 255, 255, .82); max-width: 34em; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; position: relative; z-index: 1; }

.book { margin-top: 20px; padding: 14px 14px 12px; border-radius: 16px; background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .12); position: relative; z-index: 1; }
.book-row { display: flex; justify-content: space-between; gap: 10px; font-size: .9rem; }
.book-row b { font-variant-numeric: tabular-nums; }
.bar { height: 10px; border-radius: 99px; background: rgba(255, 255, 255, .14); overflow: hidden; margin-top: 8px; }
.bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--gold), var(--gold-2)); transition: width .8s cubic-bezier(.2, .8, .2, 1); }

/* ───── כרטיסים ───── */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
@media (min-width: 620px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; }
.stat b { display: block; font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat span { font-size: .84rem; color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 12px; }
.card h3 { font-size: 1.1rem; }

.steps { display: grid; gap: 10px; counter-reset: step; }
.step { display: grid; grid-template-columns: 40px 1fr; gap: 12px; align-items: start; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; }
.step::before { counter-increment: step; content: counter(step); width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; background: var(--gold-soft); color: var(--gold); font-family: var(--display); font-size: 1.2rem; }
.step b { display: block; }
.step p { margin: 2px 0 0; color: var(--muted); font-size: .92rem; }

/* ───── כפתורים וטפסים ───── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px; border-radius: 14px; border: 0;
  font-weight: 700; font-size: 1rem; text-decoration: none; cursor: pointer; transition: transform .12s ease, filter .12s ease, background .12s;
}
.btn:active { transform: scale(.98); }
.btn-gold { background: linear-gradient(145deg, var(--gold-2), var(--gold)); color: var(--navy); box-shadow: 0 6px 18px rgba(195, 154, 62, .35); }
.btn-gold:hover { filter: brightness(1.05); }
.btn-ghost { background: rgba(255, 255, 255, .1); color: #fff; border: 1px solid rgba(255, 255, 255, .25); }
.btn-primary { background: var(--navy-2); color: #fff; }
.btn-primary:hover { background: var(--navy-3); }
.btn-wa { background: #1f9d55; color: #fff; }
.btn-wa:hover { filter: brightness(1.06); }
.btn-soft { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: .88rem; border-radius: 10px; }
.btn-block { width: 100%; }
.btn[disabled] { background: var(--line); color: var(--muted); box-shadow: none; cursor: default; }
.btn svg { width: 20px; height: 20px; }

.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field label, .field .label { font-weight: 600; font-size: .92rem; }
.field .hint { font-size: .82rem; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; min-height: 50px; padding: 12px 14px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface-2);
  transition: border-color .15s, box-shadow .15s; font-size: 1rem;
}
.textarea { min-height: 120px; resize: vertical; line-height: 1.55; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--navy-3); box-shadow: 0 0 0 4px color-mix(in srgb, var(--navy-3) 16%, transparent); background: var(--surface); }
.input[dir="ltr"] { text-align: right; }
.err { color: var(--danger); font-size: .86rem; font-weight: 600; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; padding: 5px; background: var(--surface-2); border: 1.5px solid var(--line); border-radius: 14px; }
.seg button { min-height: 42px; border: 0; border-radius: 10px; background: transparent; font-weight: 600; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(15, 27, 61, .14); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 14px; border-radius: 99px; border: 1.5px solid var(--line); background: var(--surface); font-weight: 600; font-size: .9rem; cursor: pointer; white-space: nowrap; }
.chip.on { background: var(--navy-2); border-color: var(--navy-2); color: #fff; }
.chip .count { font-size: .78rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ───── שמות ───── */
.kind-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 22px 0 10px; }
.kind-head h3 { font-family: var(--display); font-size: 1.25rem; }
.name-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); gap: 8px; }
.name-item { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-weight: 600; }
.name-item small { display: block; font-weight: 400; color: var(--muted); font-size: .8rem; }
.empty { text-align: center; padding: 26px 16px; color: var(--muted); background: var(--surface); border: 1.5px dashed var(--line); border-radius: 16px; }

/* ───── קריאה ───── */
.reader-bar { position: sticky; top: calc(56px + env(safe-area-inset-top, 0px)); z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: -6px -4px 10px; padding: 8px 4px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); }
.reader-bar .title { font-weight: 700; }
.size-ctl { display: flex; gap: 6px; }
.chapter { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 18px 12px; margin-bottom: 14px; }
.chapter h2 { font-family: var(--display); font-size: 1.5rem; color: var(--gold); margin-bottom: 8px; }
.verses { font-family: var(--display); font-size: var(--read-size, 1.35rem); line-height: 2.05; margin: 0; }
.verses .v { margin-inline-end: 4px; }
.verses sup { font-family: var(--body); font-size: .62em; color: var(--muted); font-weight: 700; margin-inline-end: 3px; vertical-align: .35em; }
.picker { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
@media (min-width: 560px) { .picker { grid-template-columns: repeat(10, minmax(0, 1fr)); } }
.picker a { aspect-ratio: 1; display: grid; place-items: center; text-decoration: none; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; font-family: var(--display); font-weight: 700; font-size: 1.02rem; }
.picker a:hover { border-color: var(--gold); color: var(--gold); }
.done-card { text-align: center; padding: 26px 18px; }
.done-card .big { font-size: 2.6rem; }

/* ───── הודעות ───── */
.toast { position: fixed; z-index: 60; inset-inline: 0; bottom: calc(var(--tab-h) + 16px + env(safe-area-inset-bottom, 0px)); margin: 0 auto; width: max-content; max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 14px; background: var(--ink); color: var(--bg); font-weight: 600; box-shadow: var(--shadow); text-align: center; }
.success { text-align: center; padding: 26px 18px; }
.success .icon { width: 64px; height: 64px; margin: 0 auto 10px; border-radius: 50%; display: grid; place-items: center; background: var(--ok-soft); color: var(--ok); }
.success .icon svg { width: 34px; height: 34px; }
.note { padding: 12px 14px; border-radius: 14px; background: var(--gold-soft); font-size: .92rem; }

.footer { margin-top: 34px; text-align: center; color: var(--muted); font-size: .84rem; }

/* ───── אדמין ───── */
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.admin-head h1 { font-family: var(--display); font-size: 1.7rem; }
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow-x: auto; scrollbar-width: none; margin-bottom: 16px; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; min-height: 40px; padding: 0 14px; border: 0; border-radius: 10px; background: none; font-weight: 600; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.tabs button.on { background: var(--navy-2); color: #fff; }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--danger); color: #fff; font-size: .72rem; font-weight: 700; display: inline-grid; place-items: center; }
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 760px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; }
.kpi b { display: block; font-size: 1.75rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi span { font-size: .84rem; color: var(--muted); }
.kpi.gold { background: linear-gradient(160deg, var(--navy-2), var(--navy)); color: #fff; border: 0; }
.kpi.gold b { color: var(--gold-2); }
.kpi.gold span { color: rgba(255, 255, 255, .75); }
.grid-2 { display: grid; gap: 12px; margin-top: 12px; }
@media (min-width: 900px) { .grid-2 { grid-template-columns: 1.3fr 1fr; } }
.chart { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding-top: 18px; }
.chart .col { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 100%; }
.chart .col i { display: block; width: 100%; max-width: 34px; border-radius: 8px 8px 3px 3px; background: linear-gradient(180deg, var(--gold-2), var(--gold)); min-height: 3px; }
.chart .col em { font-style: normal; font-size: .72rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.chart .col small { font-size: .66rem; color: var(--muted); white-space: nowrap; }
.table-wrap { overflow-x: auto; }
.list { display: grid; gap: 8px; }
.row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; text-align: start; width: 100%; cursor: pointer; }
.row:hover { border-color: color-mix(in srgb, var(--navy-3) 40%, var(--line)); }
.row .who { min-width: 0; }
.row .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .who span { font-size: .82rem; color: var(--muted); }
.row .end { text-align: left; font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.avatar { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; background: var(--surface-2); color: var(--muted); }
.avatar.m { background: #e3ebfb; color: #2a4fa8; }
.avatar.f { background: #fbe6ef; color: #b23a6e; }
@media (prefers-color-scheme: dark) { .avatar.m { background: #1d2b52; color: #9db6f2; } .avatar.f { background: #3a1d2b; color: #f0a3c4; } }
.pill { display: inline-flex; align-items: center; min-height: 24px; padding: 0 9px; border-radius: 99px; font-size: .76rem; font-weight: 700; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--gold-soft); color: var(--gold); border-color: transparent; }
.pill.off { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar .input { flex: 1 1 220px; min-height: 44px; }
.name-row { display: flex; align-items: center; gap: 10px; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.name-row .who { flex: 1; min-width: 0; }
.name-row .who b { display: block; }
.name-row .who span { font-size: .8rem; color: var(--muted); }
.name-row .acts { display: flex; gap: 6px; flex: none; }
.check { width: 22px; height: 22px; accent-color: var(--navy-3); flex: none; }

.sheet-back { position: fixed; inset: 0; z-index: 50; background: rgba(8, 12, 28, .5); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease; }
.sheet { width: 100%; max-width: 640px; max-height: 92dvh; overflow-y: auto; background: var(--bg); border-radius: 24px 24px 0 0; padding: 10px 18px calc(22px + env(safe-area-inset-bottom, 0px)); animation: up .22s cubic-bezier(.2, .8, .2, 1); }
@media (min-width: 700px) { .sheet-back { align-items: center; } .sheet { border-radius: 24px; } }
.sheet-grip { width: 42px; height: 5px; border-radius: 99px; background: var(--line); margin: 0 auto 12px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.sheet-head h2 { font-size: 1.25rem; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; cursor: pointer; }
.icon-btn svg { width: 20px; height: 20px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: .92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }
.bubble { max-width: 85%; padding: 8px 12px; border-radius: 14px; font-size: .9rem; white-space: pre-wrap; margin-bottom: 6px; }
.bubble.user { background: var(--surface); border: 1px solid var(--line); margin-inline-end: auto; }
.bubble.bot { background: #dcf5e4; color: #0f2d1c; margin-inline-start: auto; }
@media (prefers-color-scheme: dark) { .bubble.bot { background: #18402a; color: #e3f6ea; } }
.login { max-width: 420px; margin: 8vh auto 0; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
