/* ===== לוח — עיצוב ===== */
:root {
  --bg: #f4f2ec;
  --surface: #ffffff;
  --surface-2: #faf9f5;
  --ink: #1f1e1d;
  --ink-2: #6e6c66;
  --muted: #a5a39b;
  --line: #e6e3d9;
  --line-soft: #efece3;
  --accent: #c96442;
  --accent-soft: #faede7;
  --cell: #fefefd;
  --shabbat: #eae7dc;
  --holiday: #6e6c66;
  --fast: #c96442;
  --on-accent: #ffffff;
  --radius: 16px;
  --radius-sm: 11px;
  --tap: rgba(31, 30, 29, .05);
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #1c1b19;
  --surface: #232220;
  --surface-2: #2b2926;
  --ink: #f5f3ee;
  --ink-2: #a8a59d;
  --muted: #6e6b64;
  --line: #34322d;
  --line-soft: #2a2825;
  --accent: #e08a6b;
  --accent-soft: #33241e;
  --cell: #26251f;
  --shabbat: #141312;
  --holiday: #a8a59d;
  --fast: #e08a6b;
  --on-accent: #1a120e;
  --tap: rgba(255, 255, 255, .06);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; overscroll-behavior: none; }
body {
  font-family: "Heebo", -apple-system, BlinkMacSystemFont, "SF Hebrew", "Segoe UI",
    "Noto Sans Hebrew", "Arial Hebrew", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; padding: 0; }
.hidden { display: none !important; }
svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ===== מבנה: מסך אחד, ללא גלילה בלוח ===== */
#app {
  height: 100dvh; display: flex; flex-direction: column; overflow: hidden;
  max-width: 560px; margin: 0 auto; background: var(--bg);
}
main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.view { display: none; }
.view.active { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.view.scroll.active {
  display: block; flex: 1; min-height: 0;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}

/* ===== סרגל עליון ===== */
.topbar {
  flex: none; padding-top: env(safe-area-inset-top);
  background: var(--bg); border-bottom: 1px solid var(--line-soft);
}
.topbar-inner { height: 50px; display: flex; align-items: center; gap: 8px; padding: 0 12px; }
.topbar h1 {
  font-size: 16px; font-weight: 600; margin: 0; flex: 1 1 auto; min-width: 0;
  text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  letter-spacing: -.2px;
}
.icon-btn { flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: var(--ink-2); }
.icon-btn:active { background: var(--tap); }
.icon-btn svg { width: 19px; height: 19px; }
.loc-btn {
  flex: none; display: flex; align-items: center; gap: 4px; height: 30px; padding: 0 10px 0 8px;
  border-radius: 999px; background: var(--surface); color: var(--ink-2);
  font-size: 12.5px; font-weight: 500; max-width: 44%; border: 1px solid var(--line);
}
.loc-btn:active { background: var(--tap); }
.loc-btn svg { width: 13px; height: 13px; stroke: var(--accent); flex: none; }
.loc-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill {
  flex: none; font-size: 12.5px; font-weight: 500; padding: 6px 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-2);
}
.pill:active { background: var(--tap); }

/* ===== ניווט תחתון ===== */
.tabbar {
  flex: none; background: var(--bg); border-top: 1px solid var(--line-soft);
  display: grid; grid-template-columns: repeat(4, 1fr); padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  height: 52px; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px; color: var(--muted); font-size: 10.5px; font-weight: 500;
}
.tabbar button svg { width: 21px; height: 21px; }
.tabbar button.active { color: var(--accent); }

/* ===== לוח חודשי ===== */
.month-nav { flex: none; display: flex; align-items: center; padding: 6px 6px 4px; }
.month-nav button { width: 40px; height: 38px; display: grid; place-items: center; color: var(--ink-2); border-radius: 10px; }
.month-nav button:active { background: var(--tap); }
.month-nav svg { width: 18px; height: 18px; stroke-width: 2; }
.month-title { flex: 1; text-align: center; border-radius: 10px; padding: 3px 0; }
.month-title:active { background: var(--tap); }
.month-title .heb { font-size: 16.5px; font-weight: 600; letter-spacing: -.3px; }
.month-title .greg { font-size: 11.5px; color: var(--muted); margin-top: -1px; }

.weekdays {
  flex: none; display: grid; grid-template-columns: repeat(7, 1fr);
  font-size: 11px; font-weight: 500; text-align: center; color: var(--muted);
  padding: 4px 0 6px; letter-spacing: .2px;
}
.weekdays div:last-child { color: var(--ink-2); }

.grid {
  flex: none; display: grid; grid-template-columns: repeat(7, 1fr);
  /* גובה השורה נקבע ב־JS לפי רוחב העמודה, ולכן אחיד בכל הימים */
  grid-auto-rows: var(--row-h, 64px); border-top: 1px solid var(--line-soft);
}
.cell {
  min-height: 0; padding: 5px 3px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; position: relative; overflow: hidden;
  border-bottom: 1px solid var(--line-soft);
  border-inline-end: 1px solid var(--line-soft);
}
.cell:nth-child(7n) { border-inline-end: 0; }
.cell { background: var(--cell); }
.cell.shabbat { background: var(--shabbat); }
.cell.sel { background: var(--accent-soft); }
.cell.today { background: var(--accent); }
.cell.today .h, .cell.today .g, .cell.today .lbl { color: var(--on-accent); }
.cell.today .g { opacity: .75; }
.cell.out .g, .cell.out .h, .cell.out .lbl { opacity: .38; }
.cell:active { background: var(--tap); }
.cell .g { font-size: 9.5px; color: var(--muted); font-variant-numeric: tabular-nums; line-height: 1; }
.cell .h {
  font-size: 17px; font-weight: 600; line-height: 1; letter-spacing: -.4px;
  margin-top: 4px; flex: none;
}
.cell .lbl {
  font-size: 9.5px; line-height: 1.32; margin-top: 1px; text-align: center;
  color: var(--holiday); font-weight: 500; max-width: 100%; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow-wrap: normal; word-break: keep-all;
}
.cell .lbl.fast { color: var(--fast); }
.cell .lbl.par { color: var(--muted); font-weight: 400; }
.cell .lbl.long { font-size: 8.4px; letter-spacing: -.2px; }

/* יום עם שתי תוויות: מצמצמים את שאר התא כדי שלשתי השורות יהיה מקום
   מלא, כולל הגרשיים שחורגים מעל האות והרגליים שחורגות מתחתיה. */
.cell.multi { padding: 3px 3px; }
.cell.multi .h { font-size: 15.5px; margin-top: 2px; }
.cell.multi .lbl {
  font-size: 8.4px; letter-spacing: -.2px; line-height: 1.3;
  -webkit-line-clamp: 1; margin-top: 0;
}

/* ===== כרטיס היום ===== */
.daycard {
  flex: 0 1 auto; min-height: 0; margin-top: auto; background: var(--surface);
  border-top: 1px solid var(--line); padding: 12px 16px 14px;
  display: flex; flex-direction: column;
}
.dc-body { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.dc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.dc-when { min-width: 0; }
.dc-meta {
  display: flex; flex-direction: column; align-items: flex-end; gap: 1px;
  max-width: 48%; text-align: end; padding-top: 2px; flex: none;
}
.dc-holiday { font-size: 12.5px; font-weight: 600; color: var(--ink-2); line-height: 1.3; }
.dc-holiday.yomtov { color: var(--accent); }
.dc-holiday.fast { color: var(--fast); }
.dc-date { font-size: 19px; font-weight: 600; letter-spacing: -.4px; }
.dc-greg { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.dc-par { font-size: 12.5px; font-weight: 600; color: var(--accent); line-height: 1.3; }
.dc-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.tag {
  font-size: 11.5px; padding: 3px 9px; border-radius: 999px; font-weight: 500;
  background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line-soft);
}
.tag.yomtov { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.tag.fast { color: var(--fast); }
.dc-omer {
  margin-top: 7px; padding: 6px 10px; border-radius: var(--radius-sm);
  background: var(--accent-soft); color: var(--accent);
  font-size: 12px; font-weight: 500; text-align: center; line-height: 1.28;
}
.dc-omer .ev {
  margin-top: 4px; padding-top: 4px; font-weight: 400;
  border-top: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
}
.dc-omer .ev span { font-weight: 600; }
.dc-omer .now + .ev { opacity: .9; }
.dc-times {
  flex: none; display: flex; align-items: center; gap: 4px; width: 100%; margin-top: 8px;
  padding: 8px 4px 0; border-top: 1px solid var(--line-soft); color: inherit;
}
.dc-times .t { flex: 1; text-align: center; }
.dc-times .k { font-size: 10.5px; color: var(--muted); }
.dc-times .v { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.3px; }
.dc-times .chev { width: 16px; height: 16px; color: var(--muted); flex: none; }
.dc-times:active { opacity: .55; }

/* ===== כרטיסים ורשימות ===== */
.card { background: var(--surface); border-radius: var(--radius); margin: 10px 12px; overflow: hidden; border: 1px solid var(--line-soft); }
.section-title { font-size: 12px; font-weight: 600; color: var(--muted); margin: 16px 20px 5px; }
.list { background: var(--surface); }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 15px; border-bottom: 1px solid var(--line-soft); }
.item:last-child { border-bottom: 0; }
.item:active { background: var(--tap); }
.item .txt { flex: 1; min-width: 0; }
.item .t { font-size: 14.5px; font-weight: 500; }
.item .s { font-size: 12px; color: var(--muted); margin-top: 1px; }
.item .val { font-size: 16.5px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.3px; }
.item.next { background: var(--accent-soft); }
.item.next .val, .item.next .t { color: var(--accent); }

/* ===== זמני היום ===== */
.hero { flex: none; background: var(--surface); border-bottom: 1px solid var(--line); padding: 12px 14px 14px; }
.hero .date-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hero .date-nav button { color: var(--ink-2); width: 38px; height: 34px; border-radius: 10px; display: grid; place-items: center; }
.hero .date-nav button:active { background: var(--tap); }
.hero .date-nav svg { width: 18px; height: 18px; stroke-width: 2; }
.hero .dt { text-align: center; flex: 1; min-width: 0; }
.hero .dt .a { font-size: 17px; font-weight: 600; letter-spacing: -.3px; }
.hero .dt .b { font-size: 12px; color: var(--muted); }
.hero .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.hero .box { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px; text-align: center; }
.hero .box .k { font-size: 11px; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 4px; }
.hero .box .k svg { width: 13px; height: 13px; stroke: var(--accent); }
.hero .box .v { font-size: 21px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.5px; margin-top: 1px; }
.countdown {
  margin: 10px 12px; background: var(--accent-soft); border-radius: var(--radius);
  padding: 11px 15px; display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.countdown .k { font-size: 11.5px; color: var(--ink-2); }
.countdown .t { font-size: 14.5px; font-weight: 600; }
.countdown .v { font-size: 19px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.loc-chip {
  display: flex; align-items: center; gap: 7px; margin: 10px 12px; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: 999px; font-size: 13px;
}
.loc-chip svg { width: 16px; height: 16px; stroke: var(--accent); }
.loc-chip .name { flex: 1; font-weight: 500; text-align: start; }
.loc-chip .act { font-size: 12.5px; color: var(--accent); font-weight: 600; }

/* ===== ממיר והגדרות ===== */
.field { padding: 11px 15px; border-bottom: 1px solid var(--line-soft); }
.field:last-child { border-bottom: 0; }
.field label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 6px; }
.field .controls { display: flex; gap: 8px; }
.field .controls select { flex: 1; min-width: 0; }
input[type="date"], input[type="text"], select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2); font-size: 15px;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
.result { padding: 16px; text-align: center; }
.result .big { font-size: 24px; font-weight: 600; letter-spacing: -.5px; }
.result .sub { font-size: 13px; color: var(--ink-2); margin-top: 3px; }
.setting { display: flex; align-items: center; gap: 12px; padding: 11px 15px; border-bottom: 1px solid var(--line-soft); width: 100%; text-align: start; }
.setting:last-child { border-bottom: 0; }
.setting .txt { flex: 1; }
.setting .t { font-size: 14.5px; display: flex; align-items: center; gap: 6px; }
.setting .info {
  width: 17px; height: 17px; border-radius: 50%; flex: none;
  background: var(--accent-soft); color: var(--accent);
  font-size: 11px; font-weight: 700; line-height: 17px; text-align: center;
}
.setting .info:active { background: var(--accent); color: var(--on-accent); }
.setting .s { max-width: 100%; }
.setting .s { font-size: 12px; color: var(--muted); }
.setting select { width: auto; min-width: 145px; max-width: 58%; }
.switch { width: 44px; height: 26px; border-radius: 999px; background: var(--line); position: relative; transition: background .2s; flex: none; }
.switch.on { background: var(--accent); }
.switch::after {
  content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 2px rgba(0, 0, 0, .2);
}
.switch.on::after { transform: translateX(-18px); }
.seg { display: flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { padding: 6px 13px; border-radius: 8px; font-size: 13px; color: var(--ink-2); }
.seg button.active { background: var(--surface); color: var(--ink); font-weight: 600; }

/* ===== חלון קופץ ===== */
.sheet-wrap { position: fixed; inset: 0; z-index: 100; display: none; }
.sheet-wrap.open { display: block; }
.sheet-bg { position: absolute; inset: 0; background: rgba(31, 30, 29, .35); }
.sheet {
  position: absolute; inset-inline: 0; bottom: 0; background: var(--bg);
  border-radius: 20px 20px 0 0; max-height: 86vh; display: flex; flex-direction: column;
  animation: up .26s cubic-bezier(.2, .9, .3, 1); padding-bottom: env(safe-area-inset-bottom);
  max-width: 560px; margin: 0 auto;
}
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px 10px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { font-size: 15.5px; font-weight: 600; margin: 0; flex: 1; }
.sheet-head .close { font-size: 14px; color: var(--accent); font-weight: 600; }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.grabber { width: 36px; height: 4px; border-radius: 999px; background: var(--line); margin: 8px auto 0; }
.search-box { padding: 10px 16px; position: sticky; top: 0; background: var(--bg); z-index: 2; }
.group-head { font-size: 11.5px; font-weight: 600; color: var(--muted); padding: 12px 16px 4px; }

.empty { text-align: center; color: var(--muted); font-size: 13px; padding: 26px 16px; }
.foot { text-align: center; color: var(--muted); font-size: 11.5px; padding: 14px 16px 20px; line-height: 1.6; }

/* ===== תצוגת הדפסה ===== */
#print-area { display: none; }
@media print {
  @page { size: A4 landscape; margin: 9mm; }
  html, body { background: #fff !important; height: auto; }
  #app, .tabbar, .sheet-wrap { display: none !important; }
  #print-area { display: block; color: #000; font-size: 10pt; }
  .pr-head {
    display: flex; align-items: flex-end; justify-content: space-between;
    border-bottom: 1.4pt solid #000; padding-bottom: 3mm; margin-bottom: 4mm;
  }
  .pr-head .a { font-size: 20pt; font-weight: 700; letter-spacing: -.3pt; }
  .pr-head .b { font-size: 11pt; color: #444; }
  .pr-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
  .pr-table th {
    font-size: 9pt; font-weight: 600; text-align: center; padding: 1.5mm 0;
    border-bottom: .8pt solid #000; letter-spacing: .3pt; width: 14.28%;
  }
  .pr-table td { border: .4pt solid #c8c8c8; vertical-align: top; padding: 1.5mm 1.8mm; height: 28mm; width: 14.28%; }
  .pr-table td.sh { background: #f4f4f2; }
  .pr-table td.out, .pr-table td.out .pr-h,
  .pr-table td.out .pr-g, .pr-table td.out .pr-l { color: #bcbcbc; }
  .pr-top { display: flex; justify-content: space-between; align-items: baseline; }
  .pr-h { font-size: 15pt; font-weight: 700; line-height: 1; }
  .pr-g { font-size: 8.5pt; color: #666; }
  .pr-l { font-size: 8pt; line-height: 1.3; margin-top: 1.4mm; }
  .pr-l.par { color: #444; }
  .pr-foot { margin-top: 3mm; font-size: 8pt; color: #666; display: flex; justify-content: space-between; }
}

/* מסכים נמוכים — צמצום גובה השורות */
@media (max-height: 720px) {
  .cell { padding: 3px 3px; }
  .cell .lbl { -webkit-line-clamp: 1; font-size: 8.6px; }
  .cell.multi .lbl { font-size: 7.9px; line-height: 1.3; }
  .cell .h { font-size: 15.5px; margin-top: 3px; }
  .daycard { padding: 10px 16px 12px; }
  .dc-omer { font-size: 11.4px; line-height: 1.25; padding: 5px 9px; }
  .dc-greg { font-size: 12px; }
  .dc-date { font-size: 17.5px; }
  .dc-omer {
  margin-top: 7px; padding: 6px 10px; border-radius: var(--radius-sm);
  background: var(--accent-soft); color: var(--accent);
  font-size: 12px; font-weight: 500; text-align: center; line-height: 1.28;
}
.dc-omer .ev {
  margin-top: 4px; padding-top: 4px; font-weight: 400;
  border-top: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
}
.dc-omer .ev span { font-weight: 600; }
.dc-omer .now + .ev { opacity: .9; }
.dc-times { margin-top: 8px; padding-top: 8px; }
}
