:root {
  --bg: #f7f1e6;            /* אבן ירושלמית בהירה */
  --bg-2: #efe5d3;
  --card: #fffdf8;
  --ink: #2a2118;
  --muted: #7a6a58;
  --line: #e6dac5;
  --gold: #a97c2f;
  --gold-soft: #f3e6c8;
  --brand: #22355a;         /* תכלת-לילה עמוקה */
  --brand-ink: #fffaf0;
  --shiur: #55703f;
  --shiur-bg: #e9efdc;
  --warn-bg: #fbf0d6;
  --warn-ink: #6b4b0f;
  --danger: #a3352b;
  --radius: 16px;
  --serif: "Frank Ruhl Libre", "David Libre", "Times New Roman", serif;
  --sans: "Assistant", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --shadow: 0 1px 2px rgba(80, 55, 20, .06), 0 4px 14px rgba(80, 55, 20, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121722; --bg-2: #0d111a; --card: #1a2030; --ink: #f2ead9; --muted: #b3a68f; --line: #2c3446;
    --gold: #e2bb6c; --gold-soft: #3a321f; --brand: #e2bb6c; --brand-ink: #161b26;
    --shiur: #b5d29a; --shiur-bg: #223022; --warn-bg: #3a3020; --warn-ink: #f3dca6; --danger: #ff8e80;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0 auto; max-width: 640px; color: var(--ink);
  background:
    radial-gradient(120% 60% at 50% -10%, var(--gold-soft) 0%, transparent 60%),
    var(--bg);
  background-repeat: no-repeat;
  font: 17px/1.5 var(--sans);
  padding: 0 16px calc(100px + env(safe-area-inset-bottom, 0px));
}
button { font: inherit; }

/* ---------- כותרת ---------- */
.top { position: relative; text-align: center; padding-top: calc(14px + env(safe-area-inset-top, 0px)); padding-bottom: 4px; }
.bsd { position: absolute; top: calc(10px + env(safe-area-inset-top, 0px)); inset-inline-start: 0; font-family: var(--serif); font-size: .85rem; color: var(--muted); }
.arch { display: block; width: 64px; height: 40px; margin: 10px auto 2px; color: var(--gold); }
.top h1 { margin: 0; font-family: var(--serif); font-weight: 700; font-size: 2rem; line-height: 1.15; letter-spacing: .01em; }
.top h1 span { display: block; color: var(--gold); font-size: 1.15em; }
.hdate { margin: 6px 0 0; font-family: var(--serif); font-size: 1.05rem; color: var(--ink); }
.verse { margin: 8px auto 0; max-width: 30ch; font-family: var(--serif); font-size: .95rem; color: var(--muted); line-height: 1.5; }
.verse cite { font-style: normal; font-size: .8rem; display: block; }
.rule { display: flex; align-items: center; gap: 10px; margin: 14px 0 4px; color: var(--gold); }
.rule::before, .rule::after { content: ""; flex: 1; height: 1px; background: linear-gradient(to left, transparent, var(--gold) 50%, transparent); opacity: .55; }
.rule svg { width: 14px; height: 14px; }
.updated { margin: 0; text-align: center; color: var(--muted); font-size: .85rem; }
.draft { background: var(--warn-bg); color: var(--warn-ink); border-radius: 12px; padding: 8px 12px; font-size: .88rem; margin: 10px 0 0; text-align: center; }

/* ---------- סינון ---------- */
.filters { display: flex; gap: 8px; overflow-x: auto; padding: 14px 0 4px; scrollbar-width: none; justify-content: center; flex-wrap: wrap; }
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); cursor: pointer; transition: background .15s, color .15s;
}
.chip[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }

/* ---------- רשימה ---------- */
.day { margin: 22px 0 8px; font-size: .95rem; color: var(--muted); font-weight: 600; display: flex; align-items: baseline; gap: 8px; }
.day b { font-family: var(--serif); font-size: 1.3rem; color: var(--ink); }
.item {
  display: grid; grid-template-columns: auto 1fr; gap: 2px 16px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 10px; box-shadow: var(--shadow);
}
.time { grid-row: span 2; font-family: var(--serif); font-size: 1.75rem; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 4.2ch; text-align: center; direction: ltr; color: var(--brand); }
.what { font-weight: 700; font-size: 1.1rem; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.where { color: var(--muted); font-size: .95rem; display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: center; }

/* התפילה הקרובה */
.item.next {
  background: linear-gradient(160deg, var(--brand) 0%, color-mix(in srgb, var(--brand) 82%, #000) 100%);
  border-color: transparent; color: var(--brand-ink); padding: 18px 18px 16px;
  box-shadow: 0 8px 26px color-mix(in srgb, var(--brand) 35%, transparent);
}
.item.next .next-label { grid-column: 1 / -1; font-size: .8rem; letter-spacing: .04em; color: color-mix(in srgb, var(--brand-ink) 75%, transparent); margin-bottom: 4px; }
.item.next .time { color: var(--brand-ink); font-size: 2.3rem; }
.item.next .what { font-size: 1.25rem; font-family: var(--serif); }
.item.next .where, .item.next .meta, .item.next .unconf { color: color-mix(in srgb, var(--brand-ink) 80%, transparent); }
.item.next .link { color: var(--brand-ink); text-decoration: underline; text-underline-offset: 3px; }
.item.next .badge.soon { background: var(--brand-ink); color: var(--brand); }
@media (prefers-color-scheme: dark) { .item.next { background: linear-gradient(160deg, #e7c47c, #c99a45); } }

.badge { font-family: var(--sans); font-size: .76rem; font-weight: 700; padding: 2px 9px; border-radius: 999px; }
.badge.shiur { background: var(--shiur-bg); color: var(--shiur); }
.badge.temp { background: var(--warn-bg); color: var(--warn-ink); }
.badge.soon { background: var(--gold-soft); color: var(--gold); }
.badge.live { background: var(--gold); color: #fffaf0; }
.badge.cancel { background: var(--danger); color: #fff; }
.item.shiur .time { color: var(--shiur); }
.item.is-live:not(.next) { border-inline-start: 4px solid var(--gold); }
.item.cancelled { box-shadow: none; background: transparent; }
.item.cancelled .time, .item.cancelled .what { text-decoration: line-through; opacity: .55; }
.item .note, .item .meta { grid-column: 2; font-size: .86rem; color: var(--muted); }
.item .note { color: inherit; font-style: italic; }

.link { color: var(--brand); font-weight: 700; text-decoration: none; background: none; border: 0; padding: 6px 0; cursor: pointer; }
.link:hover { text-decoration: underline; }
.link.quiet { color: var(--muted); font-weight: 500; }
.unconf { font-size: .8rem; color: var(--muted); }
.empty {
  background: color-mix(in srgb, var(--card) 70%, transparent); border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 18px; color: var(--muted); text-align: center; font-family: var(--serif); font-size: 1.02rem;
}

/* ---------- בתי הכנסת ---------- */
.places h2 { font-family: var(--serif); font-size: 1.35rem; margin: 34px 0 10px; text-align: center; }
.map { height: 240px; border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; z-index: 0; box-shadow: var(--shadow); }
#places { list-style: none; padding: 0; margin: 10px 0 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
#places li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 16px; }
#places li + li { border-top: 1px solid var(--line); }
#places .nm { font-family: var(--serif); font-weight: 700; font-size: 1.1rem; }
#places .sub { color: var(--muted); font-size: .82rem; display: block; font-weight: 400; font-family: var(--sans); }

.foot { color: var(--muted); font-size: .85rem; margin-top: 30px; text-align: center; line-height: 1.6; }
.foot .bless { display: block; font-family: var(--serif); font-size: 1rem; color: var(--gold); margin-bottom: 4px; }

/* ---------- כפתורים ---------- */
.btn {
  min-height: 46px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); cursor: pointer; font-weight: 700;
}
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn:disabled { opacity: .45; cursor: default; }
.fab {
  position: fixed; inset-inline: 16px; bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  max-width: 608px; margin-inline: auto; min-height: 56px; border-radius: 18px; border: 0;
  background: linear-gradient(180deg, #c5994a, #a97c2f); color: #fffaf0; font-weight: 700; font-size: 1.05rem; cursor: pointer;
  box-shadow: 0 8px 24px rgba(120, 80, 20, .3); z-index: 10;
}
@media (prefers-color-scheme: dark) { .fab { color: #1a1408; background: linear-gradient(180deg, #ecc97f, #d0a14d); } }
.toast {
  position: fixed; inset-inline: 16px; bottom: calc(82px + env(safe-area-inset-bottom, 0px)); max-width: 608px; margin-inline: auto;
  background: var(--ink); color: var(--bg); padding: 12px 14px; border-radius: 12px; z-index: 11; text-align: center;
}

/* ---------- חלונות ---------- */
dialog { border: 0; padding: 0; width: min(560px, 100vw - 24px); max-height: calc(100dvh - 24px); border-radius: 20px; background: var(--card); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(30, 22, 10, .45); }
#add-dialog { overflow-y: auto; }
.sheet { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.sheet header { display: flex; justify-content: space-between; align-items: center; }
.sheet h2 { margin: 0; font-family: var(--serif); font-size: 1.35rem; }
.x { border: 0; background: none; font-size: 1.3rem; min-width: 44px; min-height: 44px; color: var(--muted); cursor: pointer; }
.hint { margin: 0; color: var(--muted); font-size: .95rem; }
.map.pick { height: 300px; }
.status { margin: 0; min-height: 1.4em; font-size: .95rem; }
.status.err { color: var(--danger); }
.row { display: flex; gap: 10px; }
.row .btn { flex: 1; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.seg button { flex: 1; min-height: 44px; border: 0; background: var(--card); color: var(--ink); cursor: pointer; font-weight: 700; }
.seg button + button { border-inline-start: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); }
.fld { display: flex; flex-direction: column; gap: 6px; font-weight: 700; font-size: .95rem; }
.fld[hidden] { display: none; }
.fld input, .fld select {
  font: inherit; font-weight: 400; min-height: 46px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink); width: 100%;
}
.fld input[type="time"] { direction: ltr; text-align: right; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.leaflet-container { font: inherit; }
