* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #f4f2ec;
  --card: #ffffff;
  --ink: #22283b;
  --dim: #6b7188;
  --gold: #b8912e;
  --navy: #1c2952;
  --line: #ddd8ca;
  --danger: #b03030;
}
body { font-family: "Heebo", "Segoe UI", Arial, sans-serif; background: var(--bg); color: var(--ink); }
.hidden { display: none !important; }
#tabs button.archived { display: none; }
/* photo-frame edition (body.edition-frame): the shul-only controls stay out of sight */
.edition-frame .shul-only { display: none !important; }
.edition-frame #lh-line1, .edition-frame #lh-line2i, .edition-frame #lh-line3i { direction: ltr; }
body:not(.edition-frame) .frame-only { display: none !important; } /* kept in the page for the panel dialogs' "upload a calendar" link */
.error { color: var(--danger); min-height: 1.2em; margin-top: 8px; }
.hint { color: var(--dim); font-weight: 400; font-size: 0.85em; }

/* login */
.center-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-box { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 40px; width: 340px; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,0.08); }
.login-box h1 { font-size: 1.3rem; color: var(--navy); margin-bottom: 20px; }
.login-box input { width: 100%; margin-bottom: 12px; }
.login-box .field-label { display: block; text-align: left; font-size: 0.8rem; color: var(--dim); margin: 0 0 4px 2px; }

/* topbar */
.topbar { background: var(--navy); color: #fff; display: flex; align-items: center; gap: 24px; padding: 10px 24px; flex-wrap: wrap; }
.topbar h1 { font-size: 1.05rem; color: #e8cf85; }
#tabs { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
#tabs button { background: transparent; color: #cdd3e8; border: none; padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 0.95rem; }
#tabs button.active { background: rgba(232, 207, 133, 0.18); color: #e8cf85; }
.topbar-right { display: flex; gap: 12px; align-items: center; }
.topbar-right a { color: #cdd3e8; text-decoration: none; font-size: 0.9rem; }
.topbar-right button { background: transparent; border: 1px solid #46507a; color: #cdd3e8; border-radius: 8px; padding: 6px 12px; cursor: pointer; }

/* main */
main { max-width: 980px; margin: 24px auto 80px; padding: 0 16px; }
.tab { display: none; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 24px; }
.tab.active { display: block; }
h2 { color: var(--navy); margin-bottom: 16px; font-size: 1.15rem; }
h3 { color: var(--navy); margin: 18px 0 10px; font-size: 1rem; }

input, textarea, select {
  font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: #fdfcf9; color: var(--ink); width: 100%;
}
label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; color: var(--dim); }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); }
label.check input { width: auto; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 8px; }
.checks { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 16px; }

button { font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--line); background: #fff; padding: 8px 16px; margin-top: 10px; }
button.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
button.danger { color: var(--danger); border-color: var(--danger); background: #fff; padding: 4px 10px; margin: 0; }

/* editors */
.item-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.simcha-builder { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.simcha-builder select { width: auto; }
.simcha-builder select.sb-size { width: auto; font-size: 0.8rem; padding: 4px 6px; color: var(--ink-dim, #666); margin-left: -4px; }
.simcha-builder input { flex: 1; min-width: 150px; }
.item-row input[type="checkbox"] { width: auto; }
.item-row .grow { flex: 1; min-width: 160px; }
.item-row .sm { width: 130px; }
.item-row .xs { width: 70px; }
.pd-item { border-bottom: 1px dashed var(--line); padding-bottom: 6px; margin-bottom: 8px; }
.sp-tag { font-weight: 700; font-size: 12px; color: #888; text-transform: uppercase; letter-spacing: 0.04em; }
/* sponsorship lines as tidy blocks; dates fold away behind the 📅 button */
.sp-row { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; background: #fff; }
.sp-row .item-row { margin-bottom: 6px; }
.sp-row .item-row:last-child, .sp-row .sp-dates { margin-bottom: 0; }
.sp-head-row { background: #f2f4f9; border-color: #c9d0e0; }
.sp-dates { border-top: 1px dashed var(--line); padding-top: 6px; margin-top: 2px; }
.sp-cal { padding: 4px 8px; }
.sp-cal.on { outline: 2px solid #d4af37; border-radius: 6px; }
/* drag-to-reorder handle (donors + sponsorship lines) */
.drag-h { cursor: grab; user-select: none; touch-action: none; color: #99a; font-size: 16px; padding: 0 2px; }
.drag-h:active { cursor: grabbing; }
.dragging { opacity: 0.55; outline: 2px dashed #8a94b8; }
/* donors: totals + Excel-update preview */
.don-totals { margin-left: auto; color: #556; font-size: 13px; }
.don-preview { list-style: none; max-height: 220px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; margin: 6px 0; }
.don-preview li { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border-bottom: 1px dashed var(--line); }
.don-preview li:last-child { border-bottom: 0; }
.don-preview li.dec { color: #b00020; }
/* per-line weekday picker in the ⚙ schedule row */
.pd-days { display: inline-flex; gap: 2px; align-items: center; border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; }
.pd-days label { display: inline-flex; align-items: center; gap: 1px; font-size: 12px; }
.pd-days input[type="checkbox"] { width: auto; margin: 0; }
/* donor rows carry 6 fields — keep each on one line */
.pd-donor { flex-wrap: nowrap; }
.pd-donor .sm { width: 90px; flex: 0 0 auto; }
.pd-donor .grow { min-width: 100px; }
.pd-sched { font-size: 0.85rem; color: var(--dim); background: #f4f1e8; border-radius: 8px; padding: 6px 8px; }
.pd-sched .sm { width: 140px; }
.pd-dr { display: inline-flex; align-items: center; gap: 4px; }
.pd-gear { padding: 4px 8px; margin: 0; }
.pd-gear.on { border-color: var(--gold); color: var(--gold); }
.sec-block { border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 14px; background: #faf9f4; }
.sec-head { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; align-items: center; }
.sec-head input { flex: 1; min-width: 140px; }
.sec-head select { width: auto; }

/* theme picker */
.theme-picker { display: flex; gap: 14px; flex-wrap: wrap; }
.theme-opt {
  width: 150px; border: 2px solid var(--line); border-radius: 12px; overflow: hidden;
  cursor: pointer; background: #fff; text-align: center; padding: 0; margin: 0;
}
.theme-opt.selected { border-color: var(--navy); box-shadow: 0 0 0 2px rgba(28,41,82,0.25); }
.theme-opt .swatch { height: 64px; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; }
.theme-opt .tname { padding: 8px; font-size: 0.9rem; color: var(--ink); }

/* layout editor (drag to resize the screen's sections) */
#layout-editor {
  position: relative; width: 100%; max-width: 880px; aspect-ratio: 16 / 8.5;
  display: flex; padding: 8px; box-sizing: border-box; margin-top: 8px;
  border: 1px solid var(--line); border-radius: 10px;
  background:
    repeating-linear-gradient(0deg, transparent 0 calc(5% - 1px), rgba(28, 41, 82, 0.06) calc(5% - 1px) 5%),
    repeating-linear-gradient(90deg, transparent 0 calc(5% - 1px), rgba(28, 41, 82, 0.06) calc(5% - 1px) 5%),
    #fdfcf9;
  touch-action: none; user-select: none;
}
.le-col { display: flex; flex-direction: column; min-width: 0; }
.le-block {
  position: relative; min-height: 0; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: rgba(28, 41, 82, 0.10); border: 1px solid rgba(28, 41, 82, 0.28);
  border-radius: 6px; font-size: 0.85rem; color: var(--navy); text-align: center;
}
.le-block .pct { position: absolute; bottom: 3px; left: 6px; font-size: 0.68rem; color: var(--dim); }
.le-block .hide-btn {
  position: absolute; top: 0; left: 2px; border: none; background: none;
  color: var(--danger); cursor: pointer; font-size: 0.8rem; padding: 2px 4px; margin: 0;
}
/* panel settings dialog */
#panel-dialog { position: fixed; inset: 0; z-index: 50; }
#panel-dialog.hidden { display: none; }
.pd-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.45); }
.pd-box {
  position: relative; margin: 5vh auto; width: min(760px, 94vw);
  max-height: 88vh; overflow: auto; background: #fff; border-radius: 12px;
  padding: 20px 22px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
.pd-actions { display: flex; gap: 8px; margin-top: 16px; align-items: center; }
/* the simchas/events editors live in hidden holders and are moved into the
   dialog when their panel is clicked — show them there, without the card look */
#panel-dialog .tab { display: block; background: transparent; border: 0; padding: 0; margin-top: 6px; }
#panel-dialog .tab h2 { display: none; }
.pd-spacer { flex: 1; }
.le-block { cursor: pointer; }
.le-bar { max-width: 880px; margin: 6px 0; padding: 6px 12px; border: 1px dashed var(--line); border-radius: 8px; background: #fff; cursor: pointer; font-size: 0.9rem; color: var(--ink); }
.le-bar:hover { border-color: var(--accent); }
.le-bar .hint { margin-left: 6px; }

.le-tools { position: absolute; top: 0; right: 2px; display: flex; }
.le-tools button {
  border: none; background: none; color: var(--navy); cursor: pointer;
  font-size: 0.7rem; padding: 2px 3px; margin: 0; opacity: 0.6;
}
.le-tools button:hover { opacity: 1; }
.le-tools .hide-btn { position: static; font-size: 0.8rem; }
.le-hdiv { height: 10px; flex: none; cursor: ns-resize; position: relative; }
.le-hdiv::after {
  content: ''; position: absolute; left: 12%; right: 12%; top: 4px; height: 2px;
  background: var(--gold); opacity: 0.55; border-radius: 2px;
}
.le-vdiv { width: 10px; flex: none; cursor: ew-resize; position: relative; }
.le-vdiv::after {
  content: ''; position: absolute; top: 12%; bottom: 12%; left: 4px; width: 2px;
  background: var(--gold); opacity: 0.55; border-radius: 2px;
}
#layout-hidden { margin-top: 8px; color: var(--dim); font-size: 0.9rem; }
#layout-hidden button { margin: 4px 4px 0 0; padding: 4px 10px; }

/* rich text editor */
.rt-toolbar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.rt-toolbar button { margin: 0; padding: 6px 12px; }
.rt-editor {
  min-height: 220px; border: 1px solid var(--line); border-radius: 8px;
  background: #fdfcf9; padding: 14px; font-size: 1.05rem; line-height: 1.5;
}
.rt-editor:focus { outline: 2px solid var(--navy); }
#f-web-opts, #f-file-opts, #f-rich-opts { margin-top: 12px; }

/* proposal */
.prop-group { margin: 14px 0; }
.prop-group h4 { color: var(--gold); margin-bottom: 6px; }
.prop-row { display: flex; gap: 8px; align-items: center; padding: 4px 0; }

/* toast */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 10px 22px; border-radius: 999px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.25); z-index: 10;
}
@media (max-width: 700px) { .grid2 { grid-template-columns: 1fr; } }

/* users & permissions */
.users-intro { margin-bottom: 4px; }
.users-mail { margin: 0 0 14px; padding: 8px 12px; background: #fbf8ef; border: 1px solid var(--line); border-radius: 8px; }
.user-card { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; background: var(--card); transition: box-shadow 0.15s; }
.user-card.open { box-shadow: 0 6px 22px rgba(28,41,82,0.10); border-color: #c9c2ad; }
.user-card.inactive .user-head { opacity: 0.6; }
.user-head { display: flex; align-items: center; gap: 14px; padding: 12px 14px; cursor: pointer; }
.user-head:hover { background: #faf8f2; border-radius: 12px; }
.avatar { flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--navy); color: #e8cf85; font-weight: 700; font-size: 1.1rem; display: flex; align-items: center; justify-content: center; }
.user-main { flex: 1; min-width: 0; }
.user-name { font-weight: 600; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.user-sub { color: var(--dim); font-size: 0.88rem; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; }
.user-sub .mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.85em; }
.user-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.chip { font-size: 0.78rem; padding: 2px 9px; border-radius: 999px; background: #eef1f8; color: var(--navy); }
.chip-gold { background: #f6ecd0; color: #7a5c10; font-weight: 600; }
.chip-dim { background: transparent; color: var(--dim); border: 1px dashed var(--line); }
.badge { font-size: 0.72rem; font-weight: 600; padding: 1px 7px; border-radius: 6px; letter-spacing: 0.01em; }
.badge-you { background: var(--navy); color: #fff; }
.badge-ok { background: #e3f3e6; color: #1e6b31; }
.badge-wait { background: #fdf1d6; color: #8a5a00; }
.badge-off { background: #eee; color: #666; }
.badge-new { background: #e7eefb; color: #24478f; }
.badge-google { background: #fff; color: #444; border: 1px solid var(--line); }
.user-edit { flex: none; font-size: 0.85rem; padding: 6px 14px; }
.user-body { display: none; padding: 4px 14px 14px; border-top: 1px solid var(--line); }
.user-card.open .user-body { display: block; }
.user-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin-top: 12px; }
.user-fields label { font-size: 0.85rem; font-weight: 600; color: var(--ink); }
.user-fields label .hint { font-weight: 400; }
.user-fields input { margin-top: 3px; }
.user-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.user-tools button { font-size: 0.85rem; }
.user-tools .grow { flex: 1; }
.perm-group { font-weight: 600; color: var(--dim); margin-top: 14px; font-size: 0.85rem; }
.perms { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px; margin-top: 6px; }
.perm-opt { display: flex; align-items: flex-start; gap: 8px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 0.88rem; cursor: pointer; background: #fff; }
.perm-opt:hover { background: #faf8f2; }
.perm-opt.on { background: #eef1f8; border-color: #b9c3e0; }
.perm-opt input { width: auto; margin-top: 3px; }
#activity-log .when { color: var(--dim); font-size: 0.85em; margin-right: 6px; }
#activity-log div { padding: 2px 0; border-bottom: 1px dashed var(--line); }
#whoami { color: #cdd3e8; font-size: 0.9rem; }
/* a login without the layout permission sees the panels but no arrange controls */
.no-layout .le-tools, .no-layout #layout-hidden, .no-layout #layout-add-section, .no-layout #save-display { display: none !important; }
.no-layout .le-note { display: block; }
.invite-row { margin-top: 6px; }
.invite-row button { font-size: 0.85rem; }
.google-btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; width: 100%; margin-top: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: #222; text-decoration: none; font-weight: 500; }
.google-btn:hover { background: #f5f5f5; }
.login-box .or { text-align: center; color: var(--dim); font-size: 0.85rem; margin: 10px 0 0; }
.login-links { margin: 14px 0 0; font-size: 0.9rem; }
.login-links a { color: var(--dim); text-decoration: underline; }

.linkish { background: none; border: 0; padding: 0; color: var(--navy); text-decoration: underline; cursor: pointer; font: inherit; }
.sm-btn { padding: 4px 10px; font-size: 0.85rem; vertical-align: middle; }

/* Settings → Shul screen (remote reload / reboot + mirror heartbeat) */
.screen-control { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 18px; background: #fbf8ef; }
.screen-control .sc-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.screen-control .sc-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.screen-control .sc-actions button { font-size: 0.9rem; }
.sc-online { color: #1e6b31; font-weight: 600; }
.sc-diag { margin-top: 4px; font-size: 0.88rem; }
.sc-diag .bad { color: var(--danger); font-weight: 600; }
.sc-diag .good { color: #1e6b31; font-weight: 600; }
.sc-diag pre { white-space: pre-wrap; font-size: 0.75rem; max-height: 180px; overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; margin: 6px 0 0; direction: ltr; text-align: left; }
.sc-shot { margin-top: 10px; }
.sc-shot img { width: 100%; border: 1px solid var(--line); border-radius: 8px; display: block; background: #000; }
.sc-offline { color: var(--danger); font-weight: 600; }

/* saved layouts / overrides / rotation */
.editing-banner { margin: 0 0 6px; padding: 6px 10px; background: #fbf8ef; border: 1px solid var(--line); border-radius: 8px; }
.lay-block { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
.lay-title { font-weight: 600; margin-bottom: 6px; }
.lay-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0; }
.lay-chip { display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: 0.9rem; }
.lay-chip.on { background: #eef1f8; border-color: #b9c3e0; }
.lay-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.lay-actions button { font-size: 0.88rem; }
label.inline { display: inline-flex; flex-direction: row; align-items: center; gap: 6px; font-size: 0.9rem; margin: 0; }
label.inline input, label.inline select { width: auto; }
.ov-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.ov-row input.grow { flex: 1 1 140px; }
.danger-link { color: var(--danger); }

/* slideshow rows in the panel dialog */
.pd-slide { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.pd-slide .slide-no { color: var(--dim); width: 1.4em; }
.slide-thumb-wrap { flex: none; width: 72px; height: 54px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: #fff; display: block; }
.slide-thumb { width: 100%; height: 100%; object-fit: cover; border: 0; pointer-events: none; display: block; }
.pd-slide .slide-fields { flex: 1; min-width: 120px; display: flex; flex-direction: column; gap: 2px; }
.pd-slide .slide-fields input { width: 100%; }
.pd-slide label.inline input.xs { width: 58px; }

/* special screens: library, show picker, cards */
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 6px; }
.lib-card { border: 1px solid var(--line); border-radius: 10px; padding: 8px; background: #fff; display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; }
.lib-card input { font-size: 0.9rem; padding: 4px 6px; }
.lib-thumb-wrap { display: block; height: 96px; border-radius: 6px; overflow: hidden; background: #111; }
.lib-thumb { width: 100%; height: 100%; object-fit: contain; border: 0; pointer-events: none; display: block; background: #fff; }
.lib-add { align-items: center; justify-content: center; cursor: pointer; border-style: dashed; color: var(--navy); min-height: 150px; text-align: center; }
.lib-add .plus { font-size: 2rem; line-height: 1; }
.lib-add:hover { background: #faf8f2; }
.ov-card { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 8px 0; background: #fff; }
.ov-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ov-head .ov-name { flex: 1 1 200px; font-weight: 600; }
.ov-when { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); }
.show-pick { margin-top: 8px; }
.show-kinds { display: flex; flex-wrap: wrap; gap: 6px; }
.kbtn { font-size: 0.85rem; padding: 5px 12px; border-radius: 999px; background: #fff; }
.kbtn.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.show-detail { margin-top: 8px; }
.file-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.file-chip { display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: 0.85rem; cursor: pointer; }
.file-chip.on { background: #eef1f8; border-color: #b9c3e0; }
.file-chip input { width: auto; margin-left: 6px; }
.chip-thumb { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; border: 0; pointer-events: none; background: #fff; }
.rot-item { display: flex; align-items: flex-start; gap: 8px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.rot-item .rot-no { color: var(--dim); padding-top: 6px; }
.rot-item .show-pick { flex: 1; margin-top: 0; }
.lay-adv summary { cursor: pointer; }
.lib-pick-box { border: 1px dashed var(--line); border-radius: 8px; padding: 8px 10px; margin: 6px 0; }
.sc-show { border-top: 1px dashed var(--line); padding-top: 8px; }
.sc-show select { width: auto; max-width: 260px; }

/* Admin in Hebrew / Yiddish (i18n.js sets html[dir=rtl] + .i18n-rtl): the page
   mirrors itself; keep machine-readable fields and code left-to-right. */
html.i18n-rtl #s-timezone, html.i18n-rtl #s-latitude, html.i18n-rtl #s-longitude,
html.i18n-rtl input[type="url"], html.i18n-rtl input[type="email"], html.i18n-rtl input[type="time"],
html.i18n-rtl input[type="date"], html.i18n-rtl input[type="datetime-local"], html.i18n-rtl input[type="number"],
html.i18n-rtl code, html.i18n-rtl pre, html.i18n-rtl .mono { direction: ltr; text-align: left; }

/* Searchable dropdowns (combo.js): input + ▾ + a filtered list with ✕ per entry */
.combo-wrap { position: relative; display: inline-flex; align-items: center; min-width: 0; }
.combo-wrap.grow { flex: 1; min-width: 150px; }
.combo-wrap > input { width: 100%; padding-inline-end: 28px; }
.combo-btn { position: absolute; inset-inline-end: 4px; top: 50%; transform: translateY(-50%); border: 0; background: none; padding: 2px 6px; color: #778; cursor: pointer; font-size: 0.9rem; box-shadow: none; }
.combo-pop { position: absolute; top: calc(100% + 2px); inset-inline-start: 0; min-width: 100%; max-width: min(520px, 90vw); max-height: 260px; overflow-y: auto; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.15); z-index: 30; padding: 4px; }
.combo-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 0.95rem; }
.combo-item:hover, .combo-item.active { background: #eef1fa; }
.combo-txt { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.combo-x { border: 0; background: none; color: #b55; padding: 0 4px; cursor: pointer; font-size: 0.85rem; opacity: 0.6; box-shadow: none; }
.combo-x:hover { opacity: 1; }
.combo-empty { padding: 6px 8px; color: var(--dim); font-size: 0.85rem; }
.simcha-builder .combo-wrap { flex: 1; min-width: 120px; }
label.inline.grow { flex: 1; }
label.inline.grow .combo-wrap { flex: 1; }

/* dragging a panel box to another place or column in the layout editor */
.le-block { touch-action: none; }
.le-block.le-dragging { opacity: 0.45; outline: 2px dashed #8a94b8; }
.le-drop { flex: 0 0 auto; height: 4px; margin: 2px 0; border-radius: 2px; background: var(--navy); }

/* ============================================================
   Modern UI layer (2026-10) — look and feel only, no markup or
   behaviour changes. Loaded last so it wins on equal specificity.
   Built for a phone and a computer from the same rules.
   ============================================================ */
:root {
  --bg: #f6f5f1;
  --card: #ffffff;
  --ink: #1b2236;
  --dim: #6a7184;
  --gold: #a8842a;
  --gold-soft: #e8cf85;
  --navy: #1b2a52;
  --navy-700: #24376a;
  --line: #e4e1d7;
  --line-soft: #efece3;
  --danger: #b4302f;
  --ok: #1f7a4d;
  --focus: #4d6ae0;
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 22px;
  --sh-1: 0 1px 2px rgba(16, 24, 40, 0.05);
  --sh-2: 0 4px 14px rgba(16, 24, 40, 0.07);
  --sh-3: 0 24px 60px rgba(16, 24, 40, 0.22);
  --tap: 44px; /* smallest comfortable touch target */
}
body {
  font-family: "Heebo", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: linear-gradient(180deg, var(--navy-700), var(--navy));
  gap: 10px 18px; padding: 10px 20px;
  box-shadow: var(--sh-2);
}
.topbar h1 { font-size: 1rem; font-weight: 700; letter-spacing: 0.01em; color: var(--gold-soft); white-space: nowrap; }
#tabs { gap: 2px; }
#tabs button {
  padding: 9px 14px; border-radius: 999px; font-size: 0.92rem; font-weight: 500;
  color: #c5cce6; transition: background 0.15s, color 0.15s; margin: 0; border: 0; background: transparent;
}
#tabs button:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
#tabs button.active { background: var(--gold-soft); color: var(--navy); font-weight: 700; }
.topbar-right { gap: 10px; }
.topbar-right a { color: #c5cce6; padding: 6px 4px; border-radius: var(--r-sm); }
.topbar-right a:hover { color: #fff; }
.topbar-right button {
  border-color: rgba(255, 255, 255, 0.25); background: rgba(255, 255, 255, 0.06);
  color: #e7ebf7; margin: 0; padding: 7px 14px; border-radius: 999px;
}
.topbar-right button:hover { background: rgba(255, 255, 255, 0.14); }

/* ---------- page + cards ---------- */
main { max-width: 1080px; margin: 22px auto 96px; padding: 0 18px; }
.tab { border-radius: var(--r-lg); border-color: var(--line); box-shadow: var(--sh-1); padding: 26px 28px; }
h2 { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.01em; margin-bottom: 18px; }
h3 {
  font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--dim); margin: 26px 0 12px; padding-bottom: 7px; border-bottom: 1px solid var(--line-soft);
}
h2 .hint, h3 .hint { text-transform: none; letter-spacing: 0; font-weight: 400; }

/* ---------- fields ---------- */
input, textarea, select {
  min-height: 40px; padding: 9px 12px; border-radius: var(--r-sm);
  border-color: var(--line); background: #fff; transition: border-color 0.15s, box-shadow 0.15s;
}
input:hover, textarea:hover, select:hover { border-color: #cfcabb; }
input:focus, textarea:focus, select:focus, .rt-editor:focus, [contenteditable]:focus {
  outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px rgba(77, 106, 224, 0.16);
}
input[type="checkbox"] { min-height: 0; width: 18px; height: 18px; accent-color: var(--navy); }
select {
  appearance: none; padding-inline-end: 32px; background-repeat: no-repeat;
  background-position: right 11px center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236a7184' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
}
html.i18n-rtl select { background-position: left 11px center; }
label { gap: 5px; font-size: 0.82rem; font-weight: 500; }
label.check { font-size: 0.92rem; font-weight: 400; }

/* ---------- buttons ---------- */
button {
  min-height: 38px; padding: 9px 16px; border-radius: var(--r-sm); font-weight: 500;
  background: #fff; border-color: var(--line); color: var(--ink);
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.05s;
}
button:hover { background: #fbfaf7; border-color: #cfcabb; }
button:active { transform: translateY(1px); }
button:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(77, 106, 224, 0.3); }
button.primary { background: var(--navy); border-color: var(--navy); color: #fff; box-shadow: var(--sh-1); }
button.primary:hover { background: var(--navy-700); border-color: var(--navy-700); }
button.danger { border-color: #e6c9c9; color: var(--danger); }
button.danger:hover { background: #fdf3f3; border-color: var(--danger); }

/* ---------- rows and blocks ---------- */
.item-row { gap: 9px; margin-bottom: 10px; }
.sec-block, .sp-row, .lib-card, .user-card { border-radius: var(--r-md); box-shadow: var(--sh-1); }
.pd-item { border-bottom-color: var(--line-soft); padding-bottom: 10px; margin-bottom: 12px; }
.pd-sched { background: #f7f5ee; border: 1px solid var(--line-soft); }
.drag-h { font-size: 18px; padding: 4px 2px; border-radius: 6px; }
.drag-h:hover { background: var(--line-soft); }

/* ---------- theme picker ---------- */
.theme-picker { gap: 12px; }
.theme-opt { width: 142px; border-radius: var(--r-md); border-width: 2px; box-shadow: var(--sh-1); transition: transform 0.12s, box-shadow 0.15s; }
.theme-opt:hover { transform: translateY(-2px); box-shadow: var(--sh-2); }
.theme-opt.selected { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(27, 42, 82, 0.18); }

/* ---------- layout editor ---------- */
#layout-editor { border-radius: var(--r-md); box-shadow: var(--sh-1) inset; }
.le-block { border-radius: var(--r-sm); transition: background 0.12s, box-shadow 0.12s; }
.le-block:hover { background: rgba(27, 42, 82, 0.16); box-shadow: 0 0 0 2px rgba(27, 42, 82, 0.2); }
.le-bar { border-radius: var(--r-sm); }

/* ---------- dialog ---------- */
.pd-backdrop { background: rgba(14, 20, 36, 0.5); backdrop-filter: blur(2px); }
.pd-box { border-radius: var(--r-xl); padding: 0 24px 20px; box-shadow: var(--sh-3); }
.pd-box > h3:first-child, #pd-heading {
  position: sticky; top: 0; z-index: 2; margin: 0 -24px 14px; padding: 18px 24px 13px;
  background: #fff; border-bottom: 1px solid var(--line-soft); border-radius: var(--r-xl) var(--r-xl) 0 0;
  font-size: 1.1rem; font-weight: 700; color: var(--navy); text-transform: none; letter-spacing: -0.01em;
}
.pd-actions {
  position: sticky; bottom: 0; z-index: 2; margin: 18px -24px -20px; padding: 14px 24px;
  background: #fff; border-top: 1px solid var(--line-soft); border-radius: 0 0 var(--r-xl) var(--r-xl);
}

/* ---------- toast ---------- */
#toast {
  border-radius: var(--r-md); padding: 12px 20px; box-shadow: var(--sh-3);
  font-weight: 500; max-width: min(520px, calc(100vw - 32px)); text-align: center;
  bottom: max(24px, env(safe-area-inset-bottom));
}

/* ============================================================
   Phone
   ============================================================ */
@media (max-width: 760px) {
  body { font-size: 16px; } /* iOS does not zoom a focused field at 16px */
  .topbar { padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px)); gap: 6px 10px; }
  .topbar h1 { font-size: 0.95rem; flex: 1; }
  .topbar-right { order: 2; gap: 8px; }
  .topbar-right .hint { display: none; } /* "signed in as…" is not worth the room */
  #tabs {
    order: 3; flex: 0 0 100%; flex-wrap: nowrap; overflow-x: auto; gap: 4px;
    padding-bottom: 2px; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  #tabs::-webkit-scrollbar { display: none; }
  #tabs button { flex: 0 0 auto; padding: 9px 13px; }
  main { margin: 12px auto 72px; padding: 0 10px; }
  .tab { padding: 18px 14px; border-radius: var(--r-md); }
  h2 { font-size: 1.1rem; margin-bottom: 14px; }
  .grid2 { grid-template-columns: 1fr; gap: 12px; }
  /* every tap target reaches 44px */
  button, input, select, textarea { min-height: var(--tap); }
  button.danger, .pd-gear, .sp-cal, .le-tools button, .combo-btn, .drag-h { min-height: 0; }
  .item-row { gap: 8px; }
  .item-row .grow { flex: 1 1 100%; min-width: 0; }
  .item-row .sm { flex: 1 1 42%; width: auto; min-width: 0; }
  .item-row .xs { flex: 0 0 72px; width: auto; }
  .pd-donor { flex-wrap: wrap; }
  .simcha-builder { gap: 8px; }
  .simcha-builder input, .simcha-builder .combo-wrap { flex: 1 1 100%; }
  .simcha-builder select.sb-size { flex: 0 0 auto; }
  .theme-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .theme-opt { width: auto; }
  /* the layout preview keeps the TV's own shape (16:8.5) on a phone too, so what
     you see is what the screen shows; the boxes are small, so tap targets stay readable */
  #layout-editor { max-width: none; }
  .le-block { font-size: 0.7rem; }
  .le-block .pct { display: none; }   /* no room beside the title in a phone-sized box */
  .le-tools button { font-size: 0.8rem; padding: 3px 5px; opacity: 0.85; }
  /* the boxes are small here: the move arrows would cover the titles, and a box
     can be dragged to another place or column anyway, so only ✕ stays */
  .le-tools button[data-mv] { display: none; }
  /* dialogs become full-height sheets */
  .pd-box {
    margin: 0; width: 100vw; max-height: 100vh; height: 100dvh; border-radius: 0;
    padding: 0 14px calc(14px + env(safe-area-inset-bottom, 0px));
  }
  .pd-box > h3:first-child, #pd-heading { margin: 0 -14px 12px; padding: 14px; border-radius: 0; }
  .pd-actions {
    margin: 16px -14px calc(-14px - env(safe-area-inset-bottom, 0px));
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px));
    border-radius: 0; flex-wrap: wrap;
  }
  .pd-actions button { flex: 1 1 auto; }
  .pd-spacer { display: none; }
  .login-box { width: min(380px, calc(100vw - 28px)); padding: 28px 22px; }
}

/* ============================================================
   Dark mode — follows the phone or computer's own setting
   ============================================================ */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11141c;
    --card: #191d27;
    --ink: #e7eaf2;
    --dim: #99a1b5;
    --gold: #d8b45e;
    --gold-soft: #e8cf85;
    --navy: #2b3c70;
    --navy-700: #35498a;
    --line: #2d3344;
    --line-soft: #242a37;
    --danger: #e4807e;
    --sh-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --sh-2: 0 4px 14px rgba(0, 0, 0, 0.45);
    --sh-3: 0 24px 60px rgba(0, 0, 0, 0.6);
  }
  body { background: var(--bg); color: var(--ink); }
  .topbar { background: linear-gradient(180deg, #1d2432, #161b25); }
  .tab, .login-box, .pd-box, .sec-block, .sp-row, .lib-card, .user-card, .combo-pop {
    background: var(--card); border-color: var(--line); color: var(--ink);
  }
  .sec-block, .pd-sched { background: #1d2230; }
  .sp-head-row { background: #232a3c; border-color: #39415a; }
  input, textarea, select, button, .rt-editor { background: #141823; color: var(--ink); border-color: var(--line); }
  input:hover, textarea:hover, select:hover, button:hover { border-color: #3c4458; }
  button:hover { background: #1c2130; }
  button.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
  button.primary:hover { background: var(--navy-700); }
  button.danger { background: #141823; border-color: #5a3334; color: var(--danger); }
  button.danger:hover { background: #241a1c; border-color: var(--danger); }
  select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2399a1b5' d='M1 1l5 5 5-5'/%3E%3C/svg%3E"); }
  h2, h3 { color: var(--ink); }
  .pd-box > h3:first-child, #pd-heading, .pd-actions { background: var(--card); border-color: var(--line-soft); color: var(--ink); }
  .pd-backdrop { background: rgba(0, 0, 0, 0.65); }
  #layout-editor {
    background:
      repeating-linear-gradient(0deg, transparent 0 calc(5% - 1px), rgba(255, 255, 255, 0.05) calc(5% - 1px) 5%),
      repeating-linear-gradient(90deg, transparent 0 calc(5% - 1px), rgba(255, 255, 255, 0.05) calc(5% - 1px) 5%),
      #141823;
    border-color: var(--line);
  }
  .le-block { background: rgba(120, 150, 230, 0.16); border-color: rgba(140, 170, 240, 0.35); color: #dbe3fa; }
  .le-block:hover { background: rgba(120, 150, 230, 0.26); }
  .le-tools button { color: #dbe3fa; }
  .le-bar { background: #1a1f2b; color: var(--ink); }
  .combo-item:hover, .combo-item.active { background: #242b3c; }
  .don-preview { border-color: var(--line); }
  #toast { background: #2b3c70; }
  .theme-opt { background: #141823; }
  .theme-opt .tname { color: var(--ink); }
}

/* ---------- grouped settings + a save bar that follows you ---------- */
.group {
  border: 1px solid var(--line-soft); border-radius: var(--r-md);
  padding: 16px 18px 18px; margin-bottom: 16px; background: #fcfbf8;
}
.group > h3:first-child { margin-top: 0; }
.group .grid2 { margin-bottom: 0; }
.group .checks { margin: 14px 0 0; }
.group .item-row:last-child { margin-bottom: 0; }
/* the Save button stays reachable at the bottom of a long tab */
.save-bar {
  position: sticky; bottom: 0; z-index: 5;
  margin: 20px -28px -26px; padding: 14px 28px calc(14px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), var(--card) 36%);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  display: flex; gap: 10px; align-items: center;
}
.save-bar button { margin-top: 0; }
@media (max-width: 760px) {
  .group { padding: 14px; }
  .save-bar { margin: 16px -14px -18px; padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px)); }
  .save-bar button { flex: 1; }
}
@media (prefers-color-scheme: dark) {
  .group { background: #1d2230; border-color: var(--line); }
  .save-bar { background: linear-gradient(180deg, rgba(25, 29, 39, 0), var(--card) 36%); }
}

/* ---------- panel dialog: the panel's own settings fold away ---------- */
.pd-basics {
  border: 1px solid var(--line-soft); border-radius: var(--r-md);
  background: #fcfbf8; margin-bottom: 14px;
}
.pd-basics > summary {
  list-style: none; cursor: pointer; padding: 11px 14px;
  display: flex; align-items: center; gap: 10px; border-radius: var(--r-md);
  font-size: 0.92rem;
}
.pd-basics > summary::-webkit-details-marker { display: none; }
.pd-basics > summary::after {
  content: '▾'; margin-inline-start: auto; color: var(--dim); font-size: 0.85rem;
  transition: transform 0.15s;
}
.pd-basics[open] > summary::after { transform: rotate(180deg); }
.pd-basics > summary:hover { background: var(--line-soft); }
.pd-sum-k { font-weight: 700; color: var(--navy); white-space: nowrap; flex: 0 0 auto; }
.pd-sum-v { color: var(--dim); flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pd-basics[open] > summary { border-bottom: 1px solid var(--line-soft); border-radius: var(--r-md) var(--r-md) 0 0; }
.pd-basics .grid2 { padding: 14px; margin: 0; }
/* the type editors breathe a little more */
#pd-type-body > .hint:first-child { margin-bottom: 12px; }
#pd-type-body fieldset {
  border: 1px solid var(--line-soft); border-radius: var(--r-md);
  padding: 12px 14px; margin-bottom: 14px;
}
#pd-type-body fieldset > legend {
  padding: 0 8px; font-size: 0.74rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--dim);
}
@media (prefers-color-scheme: dark) {
  .pd-basics { background: #1d2230; border-color: var(--line); }
  .pd-basics > summary:hover { background: #242b3c; }
  .pd-sum-k { color: #dbe3fa; }
  #pd-type-body fieldset { border-color: var(--line); }
}

/* ---------- Display tab: special screens and rotation fold away ---------- */
details.lay-block > summary.lay-title {
  list-style: none; cursor: pointer; display: flex; align-items: baseline;
  gap: 8px; flex-wrap: wrap; padding: 4px 0; border-radius: var(--r-sm);
}
details.lay-block > summary::-webkit-details-marker { display: none; }
details.lay-block > summary.lay-title::after {
  content: '▾'; margin-inline-start: auto; color: var(--dim);
  font-size: 0.8rem; transition: transform 0.15s;
}
details.lay-block[open] > summary.lay-title::after { transform: rotate(180deg); }
details.lay-block > summary.lay-title:hover { color: var(--navy); }

/* zmanim dialog: one line per zman — name (en + he), weekday toggles, custom label */
.zman-rows { display: flex; flex-direction: column; gap: 4px; }
.zman-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 6px 8px; border-radius: var(--r-sm, 8px); background: rgba(27, 42, 82, 0.04); }
.zman-row.off { opacity: 0.6; }
.zman-row .check { flex: 1 1 240px; margin: 0; }
.zman-row .zen { font-weight: 600; }
.zman-row .zhe { color: var(--dim); margin-inline-start: 6px; font-family: "Frank Ruhl Libre", "David Libre", serif; }
.zdays { display: inline-flex; gap: 2px; direction: rtl; }
.zday { position: relative; display: inline-block; }
.zday input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.zday span { display: inline-block; min-width: 26px; padding: 3px 0; text-align: center; border: 1px solid var(--line); border-radius: 6px; font-size: 0.85rem; color: var(--dim); background: #fff; }
.zday input:checked + span { background: var(--navy); color: #fff; border-color: var(--navy); }
.zman-row .zlabel { flex: 0 1 180px; min-width: 120px; }
@media (max-width: 760px) {
  .zman-row .check { flex-basis: 100%; }
  .zman-row .zlabel { flex: 1 1 140px; }
}
@media (prefers-color-scheme: dark) {
  .zman-row { background: rgba(120, 150, 230, 0.08); }
  .zday span { background: #1d2540; color: #c7d0ea; border-color: #3a4566; }
  .zday input:checked + span { background: #dbe3fa; color: #141a2e; border-color: #dbe3fa; }
}

/* sponsorship lines the AI just read: marked until the owner saves */
.sp-row.sp-ai-new { background: #fff7d6; border-radius: 6px; box-shadow: inset 3px 0 0 #e0b400; }

/* sponsorship line: several sponsors (title · name · suffix) and several dedications */
.sp-people, .sp-deds { margin: 4px 0 2px; padding-inline-start: 22px; }
.sp-person input.sp-p-title, .sp-person input.sp-p-suffix { width: 90px; }
.sp-row .link-btn { background: none; border: 0; color: #2b5fb3; padding: 2px 0; cursor: pointer; font-size: 13px; }
.sp-row button.sp-x { padding: 2px 8px; }
.sp-person > button, .sp-ded-row > button { flex: 0 0 auto; width: auto; min-width: 0; }

/* simcha builder: more simchas for the same person ("+ ו") */
#sb-type-more { display: contents; }
.sb-more { display: inline-flex; gap: 4px; align-items: center; }
.sb-more input { width: 140px; }
#sb-type-add { padding: 4px 10px; }

/* header: when the server last updated (red = this page is older, reload) */
.server-updated { font-size: 11px; opacity: 0.75; margin-inline-start: 10px; white-space: nowrap; }
.server-updated.stale { color: #ffb4b4; opacity: 1; font-weight: 600; }
.file-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; } /* not display:none: some tablet browsers will not open a hidden file picker */

/* past simchas archive themselves into a closed box at the end of the list */
.sim-archive { margin-top: 12px; border: 1px dashed var(--line, #ccc); border-radius: 8px; padding: 6px 10px; opacity: 0.85; }
.sim-archive > summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.sim-archive .item-row { opacity: 0.8; }

/* limudim calendar: an upload whose days are all in the past */
.lim-past { color: #b42318; font-weight: 600; margin-inline-start: 8px; }
.lim-preview { list-style: none; padding: 0; }
.lim-preview li { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; padding: 2px 0; }
