:root {
  --ink: #202a3f; --ink-soft: #3c4863; --blue: #1e3a63; --blue-2: #35588f; --gold: #ab7f2e; --gold-soft: #ecdfbb;
  --line: #e2dcc9; --soft: #efe8d6; --bg: #f7f4ee; --panel: #fff; --muted: #726c59; --danger: #a33a3a; --ok: #2d6a45;
  --note: #f2ecdb; --paper: #fffdf9; --on-accent: #fff;
  --sh-sm: 0 1px 2px rgba(32, 34, 46, .08); --sh-md: 0 6px 20px rgba(32, 40, 61, .1); --sh-lg: 0 14px 34px rgba(24, 32, 54, .16);
  color-scheme: light;
}
/* hidden גובר על display שמוגדר במחלקה (למשל .tabs), כדי שהלשוניות לא יופיעו לחבר קהילה */
[hidden] { display: none !important; }
/* מצב לילה – רק במסך; בהדפסה הלוח תמיד בצבעי יום */
@media screen {
  :root[data-theme="dark"] {
    --ink: #e9ecf5; --ink-soft: #c3cadf; --blue: #8fb0ec; --blue-2: #b6cdf5; --gold: #dfb564; --gold-soft: #3c3320;
    --line: #2a3252; --soft: #202a48; --bg: #0c1120; --panel: #161d30; --muted: #98a2c0; --danger: #f08c80; --ok: #6fd09c;
    --note: #1c2740; --paper: #161d30; --on-accent: #0c1120;
    --sh-sm: 0 1px 2px rgba(0, 0, 0, .3); --sh-md: 0 8px 24px rgba(0, 0, 0, .38); --sh-lg: 0 18px 40px rgba(0, 0, 0, .5);
  }
}
* { box-sizing: border-box; }
body { margin: 0; padding-bottom: env(safe-area-inset-bottom, 0px); background: var(--bg); color: var(--ink); font-family: "Assistant", Arial, sans-serif; font-size: 16px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
.wrap { max-width: 980px; margin: 0 auto; padding: 0 18px; }
main.wrap { padding-bottom: 48px; }
header.top { padding-top: 8px; padding-bottom: 4px; }
:root { --page-gutter: 18px; --page-width: 980px; }
h1 { font-family: "Frank Ruhl Libre", Georgia, serif; font-weight: 900; font-size: 1.85rem; margin: 6px 0 4px; letter-spacing: .2px; }
h2 { font-family: "Frank Ruhl Libre", Georgia, serif; font-size: 1.25rem; margin: 0 0 12px; color: var(--ink); }

.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tabs button { border: none; box-shadow: none; border-radius: 8px 8px 0 0; padding: 9px 20px; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--muted); background: transparent; transform: none; }
.tabs button:hover { color: var(--blue); background: color-mix(in srgb, var(--blue) 6%, transparent); transform: none; }
.tabs button[aria-selected="true"] { color: var(--blue); border-bottom-color: var(--gold); font-weight: 700; background: transparent; }
/* לשוניות בתוך ההגדרות: בטלפון גוללים אותן לצד ולא שוברים שורה */
.sub-tabs { overflow-x: auto; scrollbar-width: none; }
.sub-tabs button { flex: 0 0 auto; white-space: nowrap; }
/* חצי גלילה בצדי שורת לשוניות (js/tab-arrows.js) */
.tab-arrows-wrap { position: relative; }
.tab-arrow { position: absolute; top: 0; z-index: 2; width: 34px; padding: 0 0 4px; border: 0; border-radius: 0; box-shadow: none; transform: none; margin: 0; font-size: 1.7rem; line-height: 1; cursor: pointer; color: var(--blue, var(--tchelet)); }
.tab-arrow[hidden] { display: none; }
.tab-arrow-left { left: 0; background: linear-gradient(to right, var(--bg) 55%, transparent); text-align: left; padding-left: 6px; }
.tab-arrow-right { right: 0; background: linear-gradient(to left, var(--bg) 55%, transparent); text-align: right; padding-right: 6px; }
.tab-arrow:hover { background-color: transparent; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin-bottom: 16px; box-shadow: var(--sh-sm); transition: box-shadow .2s ease; }
.hint-panel { background: var(--note); border-color: transparent; }
.space-hint.hint-panel { padding: 8px 12px; border-radius: 10px; margin: 0 0 10px; }
.space-hint .chip { margin-inline-start: 6px; }
label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 4px; color: var(--ink-soft); }
input, select, textarea { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; width: 100%; transition: border-color .15s ease, box-shadow .15s ease; }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--blue) 45%, var(--line)); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.field { margin-bottom: 10px; }
button { font: inherit; cursor: pointer; border-radius: 9px; border: 1px solid var(--line); background: var(--panel); color: var(--blue); padding: 9px 16px; font-weight: 700; box-shadow: var(--sh-sm); transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease, background-color .12s ease; }
button:hover:not(:disabled) { border-color: var(--blue); box-shadow: var(--sh-md); transform: translateY(-1px); }
button:active:not(:disabled) { transform: translateY(0); box-shadow: var(--sh-sm); }
button:disabled { box-shadow: none; transform: none; opacity: .55; cursor: default; }
button.primary { background: linear-gradient(135deg, var(--blue), var(--blue-2)); color: var(--on-accent); border-color: transparent; box-shadow: 0 4px 14px color-mix(in srgb, var(--blue) 45%, transparent); }
button.primary:hover:not(:disabled) { box-shadow: 0 8px 20px color-mix(in srgb, var(--blue) 50%, transparent); }
button.danger { border-color: var(--danger); color: var(--danger); background: var(--panel); }
button.danger:hover:not(:disabled) { box-shadow: 0 6px 16px color-mix(in srgb, var(--danger) 30%, transparent); }
button.link { border: none; padding: 0 4px; text-decoration: underline; box-shadow: none; background: transparent; }
button.link:hover { transform: none; box-shadow: none; opacity: .8; }
button.link:active { transform: none; }
.btn-google { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn-google::before { content: ""; width: 18px; height: 18px; flex: 0 0 18px; border-radius: 3px; background: #fff url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'><path fill='%234285F4' d='M45.12 24.5c0-1.56-.14-3.06-.4-4.5H24v8.51h11.84c-.51 2.75-2.06 5.08-4.39 6.64v5.52h7.11c4.16-3.83 6.56-9.47 6.56-16.17z'/><path fill='%2334A853' d='M24 46c5.94 0 10.92-1.97 14.56-5.33l-7.11-5.52c-1.97 1.32-4.49 2.1-7.45 2.1-5.73 0-10.58-3.87-12.31-9.07H4.34v5.7C7.96 41.07 15.4 46 24 46z'/><path fill='%23FBBC05' d='M11.69 28.18C11.25 26.86 11 25.45 11 24s.25-2.86.69-4.18v-5.7H4.34A21.94 21.94 0 0 0 2 24c0 3.55.85 6.91 2.34 9.88l7.35-5.7z'/><path fill='%23EA4335' d='M24 10.75c3.23 0 6.13 1.11 8.41 3.29l6.31-6.31C34.91 4.18 29.93 2 24 2 15.4 2 7.96 6.93 4.34 14.12l7.35 5.7c1.73-5.2 6.58-9.07 12.31-9.07z'/></svg>") no-repeat center/12px; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.hint { font-size: .85rem; color: var(--muted); margin: 6px 0 0; }
#fontSample { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; color: var(--ink); }

.rule { border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; margin-bottom: 8px; background: var(--bg); }
.rule[open] { padding-bottom: 12px; }
.rule > summary { display: flex; align-items: baseline; gap: 10px; padding: 10px 0; cursor: pointer; list-style: none; }
.rule > summary::-webkit-details-marker { display: none; }
.rule > summary::after { content: "▾"; margin-inline-start: auto; color: var(--muted); transition: transform .15s ease; }
.rule[open] > summary::after { transform: rotate(180deg); }
.rule-name { flex: 0 0 auto; }
.rule-sum { font-size: .85rem; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rule[open] .rule-sum { visibility: hidden; }
.rule-top { display: flex; gap: 8px; margin-bottom: 8px; }
.rule-top input { font-weight: 700; background: var(--panel); }
.rule-top button { border-color: transparent; color: var(--danger); padding: 6px 8px; box-shadow: none; }
.rgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 600px) { .rgrid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.rgrid label { font-size: .76rem; color: var(--muted); font-weight: 600; }
.rgrid select, .rgrid input, .rgrid textarea { font-family: inherit; padding: 6px; font-size: .92rem; background: var(--panel); }
.offset-pair { display: flex; gap: 6px; }
.offset-pair input { width: 0; flex: 1 1 0; }
.offset-pair select { flex: 1.3 1 0; }

.mix-offer { border: 1px dashed var(--gold); border-radius: 10px; padding: 9px 12px; margin: 0 0 10px; background: var(--gold-soft); }

/* ייבוא מתבנית אחרת */
.imp { margin-top: 10px; }
.imp-form[hidden] { display: none; }
.imp-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 6px; }
.imp-form select { width: auto; flex: 1 1 180px; }
.imp-items { flex: 1 1 100%; border: 1px solid var(--line); border-radius: 10px; padding: 4px 10px; background: var(--bg); max-height: 280px; overflow-y: auto; }
.imp-items:empty { display: none; }
.imp-items .check { margin: 5px 0; font-weight: 400; align-items: flex-start; }
.imp-items .check input { margin-top: 4px; }
.imp-items small { display: block; color: var(--muted); font-size: .82rem; }
.imp-items .imp-all { margin: 4px 0 2px; font-size: .85rem; }
.sizes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
@media (min-width: 600px) { .sizes { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* תבניות בהגדרות */
.tpl-list { display: flex; flex-wrap: wrap; gap: 7px; margin: 10px 0; }
.chip { border-radius: 18px; padding: 6px 16px; border-color: var(--line); }
.chip.add { border-style: dashed; border-color: var(--gold); color: var(--gold); }
.tpl-new { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 10px; background: var(--bg); }
.tpl-info .field input { font-weight: 700; }
fieldset.moadim { border: 1px solid var(--line); border-radius: 10px; margin: 6px 0; padding: 4px 10px 6px; display: flex; flex-wrap: wrap; column-gap: 18px; }
fieldset.moadim legend { font-size: .82rem; color: var(--muted); font-weight: 600; padding: 0 4px; }
fieldset.moadim .check { margin: 4px 0; font-weight: 400; }

.nav-occ { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.nav-occ button { border-color: var(--line); }
.luach-tools { display: flex; justify-content: flex-end; margin-bottom: 6px; }
.luach-tools button { border-color: var(--line); font-size: .9rem; padding: 6px 12px; }
.luach.editing [data-e] { cursor: pointer; border-radius: 4px; outline: 1px dashed color-mix(in srgb, var(--blue) 45%, transparent); outline-offset: 2px; }
.luach.editing [data-e]:hover { background: color-mix(in srgb, var(--blue) 12%, transparent); }
.luach.editing [data-e].ed { outline-style: solid; outline-color: var(--gold); }
.luach.editing [data-e].fx { outline-style: solid; outline-color: var(--blue); }
@media print { .luach-tools { display: none !important; } .luach [data-e] { outline: none !important; background: none !important; cursor: auto !important; } }
.actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 16px 0; }
.actions.left { justify-content: flex-start; }

/* הלוח עצמו – נראה כמו דף מודפס, איכותי ומהודר */
.luach { font-family: var(--f-body, inherit); color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 22px 24px 26px; box-shadow: var(--sh-lg); position: relative; overflow: hidden; }
.luach .stripe { height: 4px; background: linear-gradient(90deg, var(--blue), var(--blue-2)); margin-bottom: 4px; border-radius: 2px; }
.luach .stripe.s { height: 2px; background: var(--gold); opacity: .8; }
.l-shul { text-align: center; font-size: 1rem; font-weight: 700; color: var(--blue); margin-top: calc(16px * var(--fit-gap, 1)); letter-spacing: .3px; }
.l-title { text-align: center; font-family: var(--f-title, "Frank Ruhl Libre", Georgia, serif); font-weight: 900; font-size: calc(2.1rem * var(--s-title, 1)); margin: calc(6px * var(--fit-gap, 1)) 0; line-height: 1.2; }
.l-dates { text-align: center; font-size: .92rem; color: var(--muted); margin-bottom: calc(8px * var(--fit-gap, 1)); position: relative; padding-bottom: calc(10px * var(--fit-gap, 1)); }
.l-dates::after { content: ""; position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); width: 46px; height: 2px; background: var(--gold); border-radius: 2px; }
.l-sec { width: 100%; border-collapse: collapse; margin-top: calc(20px * var(--fit-gap, 1)); }
.l-sec th, .l-sec td { padding: calc(8px * var(--fit-gap, 1)) 3px; border-bottom: 1px solid var(--soft); text-align: right; }
.l-sec th { font-size: 1.1rem; border-bottom: 2px solid var(--blue); font-family: var(--f-title, "Frank Ruhl Libre", Georgia, serif); }
.l-sec td { font-size: calc(1em * var(--s-name, 1)); }
.l-sec tr:last-child td { border-bottom: none; }
.l-sec tr:hover td { background: color-mix(in srgb, var(--blue) 4%, transparent); }
.l-sec th.d { text-align: left; white-space: nowrap; font-weight: 400; font-size: .85rem; color: var(--muted); }
.l-sec td.t { text-align: left; font-weight: 700; width: calc(80px * var(--s-time, 1)); font-size: calc(1em * var(--s-time, 1)); font-variant-numeric: tabular-nums; color: var(--blue); }
/* מודעת אירוע: הפרטים במרכז בגופן גדול, והמודעה בגובה של דף */
.l-poster { text-align: center; white-space: pre-line; font-size: calc(1.35rem * var(--s-name, 1)); line-height: 1.6; margin: calc(56px * var(--fit-gap, 1)) 12px calc(40px * var(--fit-gap, 1)); }
.luach.poster { min-height: min(120vw, 900px); }
.luach.poster .l-title { font-size: calc(3.1rem * var(--s-title, 1)); }
/* הודעת הקידוש: השורות כמו בלוח הקידושים, והכותרת מודגשת */
.l-sec td.k { text-align: center; white-space: pre-line; line-height: 1.45; }
.l-sec td.k::first-line { font-weight: 700; }
.l-sec td.z { font-size: calc(.8rem * var(--s-zman, 1)); color: var(--muted); border: none; }
.l-sec td.z > span { display: inline-block; margin-left: 14px; }
/* לוח ימי חול: עמודה לכל יום */
.l-grid-wrap { overflow-x: auto; margin-top: calc(20px * var(--fit-gap, 1)); }
.l-grid { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.l-grid th, .l-grid td { padding: calc(8px * var(--fit-gap, 1)) 4px; border-bottom: 1px solid var(--soft); text-align: center; }
.l-grid tbody th { text-align: right; font-weight: 400; font-size: calc(1em * var(--s-name, 1)); }
.l-grid thead th { border-bottom: 2px solid var(--blue); font-size: 1rem; vertical-align: top; font-family: var(--f-title, "Frank Ruhl Libre", Georgia, serif); }
.l-grid thead small { display: block; font-weight: 400; font-size: .78rem; color: var(--muted); }
.l-grid thead small.sp { color: var(--gold); font-weight: 700; }
.l-grid td { font-weight: 700; font-size: calc(1em * var(--s-time, 1)); color: var(--blue); }
.l-grid tr.z th, .l-grid tr.z td { font-size: calc(.8rem * var(--s-zman, 1)); color: var(--muted); border: none; padding: 2px 4px; font-weight: 400; }
.l-grid tr.z.first th, .l-grid tr.z.first td { padding-top: calc(12px * var(--fit-gap, 1)); }
/* לוח שבת/חג בעמודות (הגדרת התבנית): הקטעים זה לצד זה. בלוח צר (טלפון) – עמודה אחת */
.luach:has(.l-cols) { container-type: inline-size; }
.l-cols { display: flex; gap: 28px; align-items: flex-start; }
.l-col { flex: 1 1 0; min-width: 0; }
@container (max-width: 520px) { .l-cols { display: block; } }
.luach-empty { text-align: center; color: var(--muted); }

/* תבניות תצוגה (LAYOUTS ב-config.js). התבנית הקלאסית היא העיצוב שלמעלה; כל שינוי כאן צריך להתאים גם ל-image.js */
/* פס צבעוני */
.luach[data-layout="banner"] .stripe { display: none; }
.luach[data-layout="banner"] .l-head { background: var(--blue); color: var(--paper); border-radius: 12px; padding: calc(16px * var(--fit-gap, 1)) 16px calc(14px * var(--fit-gap, 1)); }
.luach[data-layout="banner"] .l-title { color: var(--paper); }
.luach[data-layout="banner"] .l-shul { color: var(--paper); opacity: .9; margin-top: 0; }
.luach[data-layout="banner"] .l-dates { color: var(--paper); opacity: .85; margin-bottom: 0; padding-bottom: 0; }
.luach[data-layout="banner"] .l-dates::after { display: none; }
.luach[data-layout="banner"] .l-sec th { background: var(--soft); border-bottom: none; padding-inline: 10px; }
.luach[data-layout="banner"] .l-sec th:first-child { border-radius: 0 8px 8px 0; }
.luach[data-layout="banner"] .l-sec th:last-child { border-radius: 8px 0 0 8px; }
.luach[data-layout="banner"] .l-sec td { border-bottom: none; padding-inline: 10px; }
.luach[data-layout="banner"] .l-sec tr:nth-child(odd):not(:first-child) td:not(.z) { background: var(--note); }
.luach[data-layout="banner"] .l-grid thead th { background: var(--soft); border-bottom: none; }
.luach[data-layout="banner"] .l-grid tbody tr:nth-child(even):not(.z) > * { background: var(--note); }
.luach[data-layout="banner"] .l-grid tbody > tr > * { border-bottom: none; }
/* מסגרת מעוטרת */
.luach[data-layout="framed"] { padding: 34px 36px 36px; }
.luach[data-layout="framed"]::before { content: ""; position: absolute; inset: 10px; border: 4px double var(--blue); border-radius: 8px; pointer-events: none; }
.luach[data-layout="framed"] .stripe { display: none; }
.luach[data-layout="framed"] .l-shul { margin-top: 0; }
.luach[data-layout="framed"] .l-dates { padding-bottom: calc(18px * var(--fit-gap, 1)); }
.luach[data-layout="framed"] .l-dates::before { content: ""; position: absolute; bottom: .35rem; left: 50%; transform: translateX(-50%); width: 120px; height: 1px; background: var(--blue); }
.luach[data-layout="framed"] .l-dates::after { content: "◆"; width: auto; height: auto; padding: 0 8px; background: var(--paper); color: var(--blue); font-size: .7rem; line-height: 1; border-radius: 0; }
.luach[data-layout="framed"] .l-sec th { text-align: center; border-bottom: 3px double var(--blue); }
.luach[data-layout="framed"] .l-sec th.d { text-align: left; }
.luach[data-layout="framed"] .l-sec td:not(.z) { border-bottom: 1px dotted var(--line); }
.luach[data-layout="framed"] .l-grid thead th { border-bottom: 3px double var(--blue); }
.luach[data-layout="framed"] .l-grid td, .luach[data-layout="framed"] .l-grid tbody th { border-bottom-style: dotted; border-bottom-color: var(--line); }
/* נקי ומודרני */
.luach[data-layout="minimal"] .stripe { display: none; }
.luach[data-layout="minimal"] .l-head { border-inline-start: 4px solid var(--blue); padding-inline-start: 14px; }
.luach[data-layout="minimal"] .l-shul, .luach[data-layout="minimal"] .l-title, .luach[data-layout="minimal"] .l-dates { text-align: right; }
.luach[data-layout="minimal"] .l-shul { margin-top: 0; font-size: .9rem; color: var(--muted); }
.luach[data-layout="minimal"] .l-title { margin-top: 2px; }
.luach[data-layout="minimal"] .l-dates { padding-bottom: 0; }
.luach[data-layout="minimal"] .l-dates::after { display: none; }
.luach[data-layout="minimal"] .l-sec th { font-family: var(--f-body); font-size: .95rem; color: var(--blue); border-bottom: 1px solid var(--line); }
.luach[data-layout="minimal"] .l-sec td { border-bottom-color: transparent; }
.luach[data-layout="minimal"] .l-sec td.t { color: var(--ink); }
.luach[data-layout="minimal"] .l-grid thead th { font-family: var(--f-body); border-bottom: 1px solid var(--line); }
.luach[data-layout="minimal"] .l-grid td { color: var(--ink); }
.luach[data-layout="minimal"] .l-grid td, .luach[data-layout="minimal"] .l-grid tbody th { border-bottom-color: transparent; }
/* כרטיסים */
.luach[data-layout="cards"] .stripe { display: none; }
.luach[data-layout="cards"] .l-shul { margin-top: 0; }
.luach[data-layout="cards"] .l-sec { border-collapse: separate; border-spacing: 0; background: var(--note); border-radius: 14px; padding: 4px 14px 10px; }
.luach[data-layout="cards"] .l-sec td:not(.z) { border-bottom-color: var(--paper); }
.luach[data-layout="cards"] .l-grid-wrap { background: var(--note); border-radius: 14px; padding: 4px 12px 10px; }
.luach[data-layout="cards"] .l-grid td, .luach[data-layout="cards"] .l-grid tbody th { border-bottom-color: var(--paper); }
/* כותרת כהה */
.luach[data-layout="dark"] .stripe { display: none; }
.luach[data-layout="dark"] .l-head { background: var(--ink); margin: -22px -24px 0; padding: calc(20px * var(--fit-gap, 1)) 24px calc(16px * var(--fit-gap, 1)); border-bottom: 5px solid var(--blue); }
.luach[data-layout="dark"] .l-shul { margin-top: 0; color: var(--paper); opacity: .85; }
.luach[data-layout="dark"] .l-title { color: var(--paper); }
.luach[data-layout="dark"] .l-dates { color: var(--line); margin-bottom: 0; padding-bottom: 0; }
.luach[data-layout="dark"] .l-dates::after { display: none; }
.luach[data-layout="dark"] .l-sec th { background: var(--blue); color: var(--paper); border-bottom: none; padding-inline: 10px; }
.luach[data-layout="dark"] .l-sec th.d { color: color-mix(in srgb, var(--paper) 85%, var(--blue)); }
.luach[data-layout="dark"] .l-sec th:first-child { border-radius: 0 8px 8px 0; }
.luach[data-layout="dark"] .l-sec th:last-child { border-radius: 8px 0 0 8px; }
.luach[data-layout="dark"] .l-sec td { padding-inline: 10px; }
.luach[data-layout="dark"] .l-grid thead th { background: var(--blue); color: var(--paper); border-bottom: none; }
.luach[data-layout="dark"] .l-grid thead small, .luach[data-layout="dark"] .l-grid thead small.sp { color: var(--paper); }
.luach[data-layout="dark"].fit-measure .l-head { margin: 0 0 4px; }
@media print { .luach[data-layout="dark"] .l-head { margin: 0 0 4px; } }
/* שעות מודגשות */
.luach[data-layout="pills"] .stripe { display: none; }
.luach[data-layout="pills"] .l-shul { margin-top: 0; }
.luach[data-layout="pills"] .l-dates { border-bottom: 1px solid var(--line); }
.luach[data-layout="pills"] .l-dates::after { display: none; }
.luach[data-layout="pills"] .l-sec th { color: var(--blue); border-bottom: none; }
.luach[data-layout="pills"] .l-sec td { border-bottom: none; }
.luach[data-layout="pills"] .l-sec td.t { width: calc(100px * var(--s-time, 1)); }
.luach[data-layout="pills"] .l-sec td.t > span,
.luach[data-layout="pills"] .l-grid tbody tr:not(.z) td > span:not(:empty) { display: inline-block; background: var(--soft); border-radius: 999px; padding: 1px 12px; }
.luach[data-layout="pills"] .l-grid thead th { color: var(--blue); border-bottom: none; }
.luach[data-layout="pills"] .l-grid td, .luach[data-layout="pills"] .l-grid tbody th { border-bottom: none; }
/* מסגרת מעוגלת */
.luach[data-layout="outline"] { padding: 34px 36px 36px; }
.luach[data-layout="outline"]::before { content: ""; position: absolute; inset: 12px; border: 3px solid var(--blue); border-radius: 22px; pointer-events: none; }
.luach[data-layout="outline"] .stripe { display: none; }
.luach[data-layout="outline"] .l-shul { margin-top: 0; }
.luach[data-layout="outline"] .l-sec th { border-bottom: 1px solid var(--line); }
.luach[data-layout="outline"] .l-sec th:first-child > span { display: inline-block; background: var(--soft); color: var(--blue); border-radius: 999px; padding: 2px 14px; }
.luach[data-layout="outline"] .l-grid thead th { border-bottom: 1px solid var(--line); }

/* בחירת תבנית תצוגה בהגדרות: דוגמה מוקטנת של כל תבנית */
.lay-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 8px 0 14px; }
.lay-card { display: flex; flex-direction: column; gap: 6px; padding: 8px; text-align: right; border: 2px solid var(--line); border-radius: 12px; background: var(--bg); color: inherit; cursor: pointer; }
.lay-card[aria-pressed="true"] { background: var(--bg); color: inherit; border-color: var(--blue); box-shadow: 0 0 0 2px color-mix(in srgb, var(--blue) 25%, transparent); }
.lay-card b { font-size: .95rem; }
.lay-card small { font-size: .78rem; opacity: .75; line-height: 1.35; }
.lay-thumb { height: 150px; overflow: hidden; border-radius: 8px; border: 1px solid var(--line); pointer-events: none; }
.lay-thumb .luach { width: 480px; zoom: .3; border: none; border-radius: 0; box-shadow: none; }
.lay-thumb img { display: block; width: 100%; height: auto; }
.lay-card[data-upload] { border-style: dashed; }
.lay-card[data-upload] .lay-thumb { display: grid; place-items: center; border-style: dashed; }
.lay-plus { font-size: 2.6rem; line-height: 1; color: var(--blue); }
.lay-more { display: block; margin: -6px 0 14px; }

.lp { position: relative; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(8px); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-size: .9rem; opacity: 0; pointer-events: none; box-shadow: var(--sh-lg); transition: opacity .2s ease, transform .2s ease; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); color: var(--on-accent); }
.credit { text-align: center; font-size: .8rem; color: var(--muted); padding-bottom: 28px; }

@media print {
  /* גודל הדף וכיוונו לפי התבנית (applyPage ב-app.js) */
  /* שוליים 0 – כך הדפדפן לא מוסיף כותרת עליונה ותחתונה (תאריך, כותרת, כתובת, מספר עמוד). את השוליים (14mm, כמו PRINT_MARGIN ב-app.js)
     יוצר main.wrap, ו-clone חוזר עליהם בכל עמוד */
  @page { margin: 0; }
  body { background: #fff; margin: 0; }
  header,.tpl-list, .mix-offer, .tpl-new, .nav-occ, .actions, #welcome, footer, .toast, #view-settings, .community-panel { display: none !important; }
  main.wrap { max-width: none; width: auto; margin: 0; padding: 14mm; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
  .luach { border: none; box-shadow: none; padding: 0; font-size: 18px; border-radius: 0; }
  .l-title { font-size: calc(2.4rem * var(--s-title, 1)); }
  /* לוח בשני עמודים נשבר בין השורות, ולא משאירים כותרת של קטע לבד בתחתית העמוד */
  .l-sec tr, .l-grid tr { break-inside: avoid; }
  .l-sec tr:first-child { break-after: avoid; }
  /* הלוח ברוחב הדף בלי השוליים. בדף גדול מ-A4 הוא מוגדל באותו יחס, ולוח שבעמוד האחרון שלו עד חצי עמוד
     מוקטן, יחד עם הרווחים, לעמוד אחד פחות (applyPage ו-fitPrint ב-app.js) */
  .luach:not(:has(.lp)) { zoom: var(--zoom, 1); width: calc(var(--page-w, 182mm) / var(--zoom, 1)); }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  /* טקסט שקוף למחצה (opacity) מודפס כתמונה ולא כטקסט, ולכן יוצא מטושטש על הנייר. בהדפסה הוא בצבע מלא, והגופנים לא מוחלקים */
  .luach[data-layout="banner"] .l-shul, .luach[data-layout="banner"] .l-dates, .luach[data-layout="dark"] .l-shul, .luach .stripe.s { opacity: 1; }
  body { -webkit-font-smoothing: auto; text-rendering: geometricPrecision; }
}

/* תבנית מלוח קיים */
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; margin: 8px 0; }
.check input { width: auto; transform: scale(1.2); }
.day-checks { display: flex; flex-wrap: wrap; gap: 0 16px; }
.day-checks .check { margin: 4px 0; font-weight: 400; }
.rule-opts { display: flex; flex-wrap: wrap; gap: 6px; }
.rule-opts .chip { padding: 5px 12px; font-weight: 400; }
.rule-opts small { opacity: .75; }
.wrap-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 44px; padding: 6px 8px; margin-bottom: 6px;
  border: 1px solid var(--line); border-radius: 8px; }
.wrap-line .chip { padding: 5px 12px; font-weight: 400; }
.wrap-edit { margin-inline-start: auto; min-width: 36px; min-height: 36px; padding: 4px 8px; font-size: 1.05rem; line-height: 1;
  background: transparent; color: inherit; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; opacity: .8; }
.wrap-edit:hover, .wrap-edit:focus-visible { opacity: 1; }
.line-ed { align-items: flex-start; }
.line-ed-body { flex: 1; display: grid; gap: 8px; min-width: 0; }
.line-ed-body input[data-line-text], .line-ed-body select { width: 100%; }
.line-ed-week { padding: 8px 10px; border-radius: 8px; background: var(--line); line-height: 1.6; }
.line-ed-week small { display: block; opacity: .75; }
.line-ed-scope, .line-ed-btns { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.linkish { background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; cursor: pointer; font: inherit; }
.look-btns { display: flex; gap: 6px; }
.look-btns .chip { min-width: 42px; padding: 5px 10px; font-family: Georgia, "Times New Roman", serif; }
.look-btns .look-bold { font-weight: 800; }
.look-btns .look-italic { font-style: italic; font-weight: 400; }
.wrap-no { font-size: .85rem; opacity: .7; margin-inline-end: 4px; }
.tpl-status { margin: 0 0 6px; font-weight: 600; color: var(--ok); }
.profiles { list-style: none; margin: 10px 0; padding: 0; }
.profiles li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; background: var(--bg); }
.profiles li.current { border-color: var(--ok); }
.prof-name { font-weight: 700; overflow-wrap: anywhere; }
.prof-meta { font-size: .8rem; color: var(--muted); }
.prof-text { flex: 1 1 180px; min-width: 0; }
.prof-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.prof-btns button { padding: 6px 12px; }
.tpl-occ { align-self: end; margin: 0 0 8px; }
.tpl-fontfill { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0 12px; }
.tpl-fontfill .hint { flex-basis: 100%; margin: 0; }
.luach-img { display: block; width: 100%; height: auto; border-radius: 10px; }
.luach:has(.luach-img) { padding: 10px; background: #fff; }
/* שבת/חג רב-יומי בעיצוב מקובץ: עמוד לכל יום */
.lp + .lp { margin-top: 16px; }
.tpl-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.tpl-help { margin: 4px 0 0; }
.tpl-help > summary { cursor: pointer; font-weight: 700; font-size: .9rem; color: var(--blue); width: fit-content; }
.tpl-tools { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 0 8px; background: var(--bg); }
.slot-ed { scroll-margin: 12px 0 80px; }
@media (min-width: 900px) {
  main.wrap:has(#view-template:not([hidden])) { max-width: 1200px; }
  .tpl-layout { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; }
  .tpl-stage { position: sticky; top: calc(8px + var(--sm-top, 0px)); }
}
/* טלפון (ובעיקר האפליקציה): הדף נשאר צמוד למעלה בגובה מוגבל, והרשימה נגללת מתחתיו */
@media (max-width: 899px) {
  #view-template .panel { padding: 14px; margin-bottom: 12px; }
  #view-template h2 { margin-bottom: 8px; }
  .tpl-head { grid-template-columns: 1fr; gap: 0; margin-bottom: 4px; }
  .tpl-occ { margin: 0 0 6px; }
  .tpl-layout { gap: 10px; }
  .tpl-tools button { flex: 1 1 0; padding: 8px 10px; }
  #view-template .actions.sticky { margin: 12px 0 0; padding: 8px 0 calc(8px + env(safe-area-inset-bottom, 0px)); gap: 8px; flex-wrap: nowrap; }
  .actions.sticky button { flex: 1 1 auto; min-width: 0; padding: 10px 8px; white-space: nowrap; font-size: .95rem; }
  .actions.sticky #tplCancel { flex: 0 1 auto; padding-inline: 14px; }
}
/* כשיש מספיק גובה (לא כשהמקלדת פתוחה) הדף צמוד למעלה ונגלל בתוכו */
@media (max-width: 899px) and (min-height: 560px) {
  .tpl-stage { position: sticky; top: var(--sm-top, calc(54px + env(safe-area-inset-top, 0px))); z-index: 5; max-height: 46dvh; overflow-y: auto; overscroll-behavior: contain;
    background: var(--bg); margin: 0 -4px; padding: 0 4px 6px; border-bottom: 1px solid var(--line); box-shadow: 0 8px 12px -10px rgba(0, 0, 0, .25); }
  .tpl-tools { position: sticky; top: 0; z-index: 3; padding-top: 6px; }
  .slot-ed { scroll-margin-top: calc(var(--sm-top, calc(54px + env(safe-area-inset-top, 0px))) + 46dvh + 12px); }
}
.tpl-page { position: relative; border: 1px solid var(--line); background: #fff; touch-action: pan-y; border-radius: 10px; overflow: hidden; }
.tpl-page img { display: block; width: 100%; height: auto; user-select: none; -webkit-user-drag: none; }
.tpl-page.drawing { cursor: crosshair; touch-action: none; }
.tb { position: absolute; padding: 0; border-radius: 2px; min-width: 6px; min-height: 6px; }
.tb.cand { border: 1px dashed #9aa7ba; background: rgba(154, 167, 186, .08); }
.tb.cand:hover { background: rgba(44, 74, 124, .15); }
.tb.slot { border: 2px solid var(--blue); background: rgba(44, 74, 124, .06); }
.tb.slot span { position: absolute; top: -9px; right: -9px; background: var(--blue); color: var(--on-accent); font-size: 11px; line-height: 16px; min-width: 16px; border-radius: 8px; padding: 0 3px; }
.tb.val { border: 1px dashed var(--blue); background: rgba(44, 74, 124, .14); pointer-events: none; }
.tb.drag { pointer-events: none; }
.tb.slot, .tb.cand { cursor: pointer; user-select: none; -webkit-user-select: none; }
.tb.slot.sel { box-shadow: 0 0 0 2px color-mix(in srgb, var(--blue) 30%, transparent); }
/* גרירת אזורים רק במצב "הזזת אזורים"; מחוץ לו, נגיעה באזור בטלפון גוללת את העמוד כרגיל */
.tpl-page.moving .tb.slot, .tpl-page.moving .tb.cand { cursor: grab; touch-action: none; outline: 2px dashed var(--blue); outline-offset: 1px; }
.tb.ghost { border: 2px dashed var(--blue); background: transparent; opacity: .6; }
.rh { position: absolute; width: 14px; height: 14px; margin: -7px -7px 0 0; border-radius: 50%; background: var(--blue); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--blue); touch-action: none; z-index: 2; }
.rh-l, .rh-r { cursor: ew-resize; }
.rh-t, .rh-b { cursor: ns-resize; }
.tpl-page.drawing .tb { pointer-events: none; }
.tpl-page.text-editing .tb.cand, .tpl-page.text-editing .tb.slot { outline: 2px solid var(--gold); outline-offset: 1px; }
.slot-ed.sel { border-color: var(--blue); box-shadow: 0 0 0 2px color-mix(in srgb, var(--blue) 25%, transparent); }
.slot-ed > summary { align-items: center; }
.slot-ed .num { background: var(--blue); color: var(--on-accent); border-radius: 10px; min-width: 22px; text-align: center; font-size: .85rem; }
.slot-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.slot-top select { width: auto; flex: 1 1 160px; font-weight: 700; }
.slot-top .del { border-color: transparent; color: var(--danger); padding: 4px 8px; margin-inline-start: auto; box-shadow: none; }
.slot-ed .rgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.slot-ed .rgrid .wide { grid-column: 1 / -1; }
.actions.sticky { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; border-top: 1px solid var(--line); }
button[aria-pressed="true"] { background: linear-gradient(135deg, var(--blue), var(--blue-2)); color: var(--on-accent); border-color: transparent; }

@media print {
  #view-template { display: none !important; }
  .luach:has(.luach-img) { padding: 0; }
  /* לוח מקובץ (תמונה) מודפס על כל הדף, בלי שוליים (printArea ב-app.js) */
  main.wrap:has(#luach .luach-img) { padding: 0; }
  .lp + .lp { margin-top: 0; break-before: page; }
  /* תמונה מקובץ שבעמוד האחרון שלה עד חצי עמוד מוקטנת כולה, באותו יחס, לעמוד אחד פחות (fitPrint ב-app.js) */
  .lp.fit { break-inside: avoid; }
  .lp.fit .luach-img { width: auto; max-width: 100%; max-height: var(--fit-h, 268mm); margin: 0 auto; border-radius: 0; }
}
/* מדידת הלוח ברוחב ובגודל של ההדפסה (הדף בלי השוליים), לפני ההדפסה */
.luach.fit-measure { zoom: var(--zoom, 1); width: calc(var(--page-w, 182mm) / var(--zoom, 1)); max-width: none; border: none; box-shadow: none; padding: 0; font-size: 18px; border-radius: 0; }
.luach.fit-measure .l-title { font-size: calc(2.4rem * var(--s-title, 1)); }
/* המסגרות צריכות ריווח גם בהדפסה */
.luach[data-layout="framed"].fit-measure, .luach[data-layout="outline"].fit-measure { padding: 30px 32px; }
@media print { .luach[data-layout="framed"], .luach[data-layout="outline"] { padding: 30px 32px; } }

/* קהילה */
.gate { text-align: center; padding: 32px 18px; }
.gate p { margin: 0 0 14px; }
.btn-link { display: inline-block; background: linear-gradient(135deg, var(--blue), var(--blue-2)); color: var(--on-accent); border-radius: 9px; padding: 9px 16px; font-weight: 700; text-decoration: none; box-shadow: 0 4px 14px color-mix(in srgb, var(--blue) 45%, transparent); transition: transform .12s ease, box-shadow .12s ease; }
.btn-link:hover { box-shadow: 0 8px 20px color-mix(in srgb, var(--blue) 50%, transparent); transform: translateY(-1px); }
.btn-link:active { transform: translateY(0); }
.community-title { margin: 6px 0 14px; }
.community-file { margin-top: 12px; }
.community-file h2, .community-file h3 { margin: 0; }
.community-file .luach-img { display: block; max-width: 100%; margin-top: 8px; border: 1px solid var(--line); border-radius: 8px; }
.community-panel details { margin-top: 12px; }
/* לשונית משולבת של שבת וחג בלוח אחד, עם סימן להפרדה */
.chip-join { display: inline-flex; align-items: stretch; }
.chip-join .chip { border-start-end-radius: 0; border-end-end-radius: 0; padding-inline-end: 10px; }
.chip-split { border-start-start-radius: 0; border-end-start-radius: 0; border-start-end-radius: 18px; border-end-end-radius: 18px; padding: 0 11px; margin-inline-start: 1px; background: var(--blue-2); color: var(--on-accent); border-color: transparent; font-weight: 400; }

/* קבצים ואחסון של הקהילה */
.storage-panel { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.storage-panel > summary { cursor: pointer; font-weight: 700; color: var(--blue); }
.storage-panel > summary .hint { font-weight: 400; }
.usage { margin: 10px 0; }
.usage-bar { height: 10px; border-radius: 999px; background: var(--soft); border: 1px solid var(--line); overflow: hidden; }
.usage-bar span { display: block; height: 100%; background: var(--ok); border-radius: inherit; }
.usage.high .usage-bar span { background: var(--gold); }
.usage.full .usage-bar span { background: var(--danger); }
.storage-warn { background: var(--note); color: var(--danger); border-radius: 10px; padding: 8px 12px; font-weight: 600; font-size: .9rem; }
.file-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.file-row .info { flex: 1 1 220px; min-width: 0; }
.file-row .info .n { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row .hint { margin: 0; }
.file-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.file-actions button { padding: 5px 10px; font-size: .85rem; }
.storage-panel .trash { margin-top: 12px; }
.storage-panel .trash > summary { cursor: pointer; font-weight: 700; }
.file-open { color: var(--blue); font-weight: 700; font-size: .85rem; padding: 5px 6px; }

/* אשף התחלה לגבאי חדש */
.wiz { border: 0; border-radius: 18px; padding: 0; width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 24px); background: var(--panel); color: inherit; box-shadow: 0 18px 40px rgba(24,32,54,.3); }
.wiz::backdrop { background: rgba(10,16,32,.5); }
.wiz-form { padding: 20px; }
.wiz h2 { margin: 6px 0 14px; }
.wiz-dots { display: flex; gap: 6px; }
.wiz-dots i { width: 28px; height: 5px; border-radius: 3px; background: var(--line); }
.wiz-dots i.on { background: var(--blue); }
.wiz-modes { display: flex; gap: 8px; margin-bottom: 12px; }
.wiz-modes button { flex: 1; }
.wiz-modes button[aria-pressed="true"] { border-color: var(--blue); box-shadow: 0 0 0 2px color-mix(in srgb, var(--blue) 25%, transparent); }
.wiz .lay-pick { max-height: 46vh; overflow: auto; padding: 2px; }
.wiz-sum { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 6px; }
.wiz-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 16px; }
.wiz-actions .link { margin-inline-start: auto; }
.fmt-bar { display: flex; gap: 6px; align-items: center; margin: 4px 0; flex-wrap: wrap; }
.fmt-bar .fmt { min-width: 34px; padding: 3px 8px; }
