:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #1d4ed8;
  --primary-soft: #dbeafe;
  --free: #ecfdf5;
  --free-text: #047857;
  --danger: #b91c1c;
  --warn-soft: #fef3c7;
  --warn: #92400e;
  font-family: system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a; --surface: #1e293b; --text: #f1f5f9; --muted: #94a3b8; --border: #334155;
    --primary: #60a5fa; --primary-soft: #1e3a8a; --free: #064e3b; --free-text: #6ee7b7;
    --danger: #f87171; --warn-soft: #78350f; --warn: #fde68a;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 16px; }
.hidden { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
}
label { display: block; margin-bottom: 12px; color: var(--muted); font-size: 14px; }
label input, label select, label textarea { margin-top: 4px; color: var(--text); font-size: 16px; }
label.check { display: flex; gap: 8px; align-items: center; color: var(--text); font-size: 16px; }
label.check input { width: auto; margin: 0; }
button { cursor: pointer; border: 1px solid var(--border); background: var(--surface); padding: 10px 14px; border-radius: 10px; }
button.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
button.danger { color: var(--danger); }
button.small { padding: 6px 10px; font-size: 14px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.muted { color: var(--muted); font-size: 14px; }
.error { color: var(--danger); min-height: 1.2em; }

.screen { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.login-card { width: 100%; max-width: 360px; }
.login-card h1 { margin-top: 0; font-size: 22px; }
.login-card button { width: 100%; }

.topbar { position: sticky; top: 0; z-index: 2; background: var(--primary); color: #fff; padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); }
.topbar h1 { margin: 0; font-size: 19px; }
main { padding: 12px 16px 96px; max-width: 760px; margin: 0 auto; }

.tabs {
  position: fixed; bottom: 0; inset-inline: 0; display: flex; background: var(--surface);
  border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); z-index: 3;
}
.tabs button { flex: 1; border: 0; border-radius: 0; background: none; padding: 8px 2px; font-size: 12px; color: var(--muted); position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tabs button span { font-size: 20px; }
.tabs button.active { color: var(--primary); font-weight: 600; }
.badge { position: absolute; top: 4px; inset-inline-start: 50%; margin-inline-start: 8px; background: var(--danger); color: #fff; border-radius: 99px; font-size: 11px; padding: 1px 6px; }

.week-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.day { margin-bottom: 16px; }
.day h2 { font-size: 16px; margin: 0 0 6px; }
.day.today h2 { color: var(--primary); }
.slot { display: flex; align-items: center; gap: 10px; width: 100%; text-align: start; margin-bottom: 6px; }
.slot .time { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 48px; }
.slot.free { background: var(--free); color: var(--free-text); border-color: transparent; }
.slot.booked { background: var(--primary-soft); border-color: transparent; }
.slot.closed { color: var(--muted); border-style: dashed; background: transparent; }
.slot.past { opacity: .55; }
.week-nav button:disabled { opacity: .4; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--warn-soft); color: var(--warn); margin-inline-start: auto; }
.tag.ok { background: var(--free); color: var(--free-text); }

.student-row { display: flex; justify-content: space-between; align-items: center; width: 100%; text-align: start; margin-bottom: 8px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.stat { background: var(--bg); border-radius: 10px; padding: 8px; text-align: center; }
.stat b { display: block; font-size: 22px; }
.list-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
a.link-row { color: inherit; text-decoration: none; }
a.link-row b { color: var(--primary); }
h3 { font-size: 16px; margin: 16px 0 8px; }

dialog { border: 0; border-radius: 16px; padding: 16px; width: min(480px, calc(100vw - 32px)); background: var(--surface); color: var(--text); }
dialog::backdrop { background: rgb(0 0 0 / .4); }
dialog h2 { margin-top: 0; font-size: 18px; }
.toast { position: fixed; bottom: 84px; inset-inline: 16px; margin: auto; max-width: 420px; background: #111827; color: #fff; padding: 12px 16px; border-radius: 12px; text-align: center; z-index: 5; }

.hours-grid .list-item select { width: auto; padding: 8px 6px; }
.hours-grid .row { flex-wrap: nowrap; gap: 4px; }

/* יומן: בחירת תצוגה, חודש בקוביות ושבוע בעמודות */
.seg { display: flex; background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 3px; margin-bottom: 12px; }
.seg button { flex: 1; border: 0; background: none; padding: 8px; border-radius: 9px; color: var(--muted); }
.seg button.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; margin-bottom: 8px; }
.month-grid .dow { text-align: center; font-size: 12px; color: var(--muted); padding: 4px 0; }
.cube { aspect-ratio: 1 / 1.15; padding: 4px; display: flex; flex-direction: column; align-items: center; gap: 2px; border-radius: 10px; min-width: 0; }
.cube .num { font-weight: 600; font-variant-numeric: tabular-nums; }
.cube.out { opacity: .35; }
.cube.past { opacity: .5; }
.cube.today { border: 2px solid var(--primary); }
.chip { font-size: 11px; line-height: 1.4; padding: 0 6px; border-radius: 99px; font-variant-numeric: tabular-nums; }
.chip.booked { background: var(--primary-soft); color: var(--text); }
.chip.free { background: var(--free); color: var(--free-text); }
.week-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; margin-bottom: 8px; align-items: start; }
.wcol { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.wcol.past { opacity: .6; }
.whead { padding: 6px 2px; display: flex; flex-direction: column; align-items: center; font-size: 12px; border-radius: 10px; }
.wcol.today .whead { background: var(--primary); color: #fff; border-color: var(--primary); }
.wslot { padding: 4px 2px; display: flex; flex-direction: column; align-items: center; font-size: 11px; border-radius: 8px; min-width: 0; border-color: transparent; }
.wslot .time { font-weight: 600; font-variant-numeric: tabular-nums; }
.wslot .who { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wslot.free { background: var(--free); color: var(--free-text); }
.wslot.booked { background: var(--primary-soft); }
.wslot.past { opacity: .55; }
@media (min-width: 700px) { .wslot, .whead { font-size: 13px; } .cube { aspect-ratio: 1 / .8; } }
.heb { font-size: 12px; color: var(--muted); font-weight: 400; }
.week-nav b { text-align: center; line-height: 1.3; }
.wcol.today .whead .heb { color: inherit; opacity: .85; }
.topbar .who { font-size: 13px; opacity: .85; margin-inline-start: 8px; }
.topbar { display: flex; align-items: baseline; }
.chat { display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow: auto; padding: 4px 0; }
.bubble { max-width: 85%; padding: 8px 12px; border-radius: 14px; white-space: pre-line; }
.bubble.bot { background: var(--bg); align-self: flex-start; }
.bubble.me { background: var(--free); color: var(--free-text); align-self: flex-end; }
.copy-box { font-size: 12px; direction: ltr; text-align: left; word-break: break-all; background: var(--bg); padding: 8px; border-radius: 8px; }
.note { background: var(--warn-soft); color: var(--text); border-radius: 8px; padding: 6px 10px; margin: 6px 0 0; font-size: 14px; white-space: pre-line; }
.tag.bad, b.bad, .bad { color: var(--danger); }
.tag.bad { background: #fee2e2; }
a.button { display: inline-block; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--border); text-decoration: none; color: inherit; }
a.button.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
/* כרטיס התקדמות */
.progress { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; margin: 8px 0; }
.progress span { display: block; height: 100%; background: var(--free-text); }
details summary { cursor: pointer; color: var(--primary); margin: 4px 0; }
.skill { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.skill .levels { display: flex; gap: 2px; flex-shrink: 0; }
.skill .levels button { padding: 4px 6px; font-size: 12px; }
.skill .levels button.on.lv0 { background: var(--bg); font-weight: 600; }
.skill .levels button.on.lv1 { background: var(--warn-soft); color: var(--warn); border-color: transparent; font-weight: 600; }
.skill .levels button.on.lv2 { background: var(--free); color: var(--free-text); border-color: transparent; font-weight: 600; }
/* טסט מדומה */
.mt-head { display: flex; justify-content: space-between; align-items: center; }
.mt-head #mt-timer { font-size: 28px; font-variant-numeric: tabular-nums; }
.mt-list { max-height: 55vh; overflow: auto; margin: 8px 0; }
.mt-list h4 { margin: 12px 0 4px; color: var(--muted); font-size: 13px; }
.mt-item { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 6px 4px; border-bottom: 1px solid var(--border); font-size: 15px; }
.mt-item.minor { background: var(--warn-soft); }
.mt-item.severe { background: #fee2e2; color: #111827; }
.mt-foot button:disabled { opacity: .4; }
/* טסט עם מסלול: כל המסך, מפה בחצי העליון והליקויים בחצי התחתון (כמו הטאבלט של הבוחן). */
dialog.mt-full { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; padding: 8px; }
dialog.mt-full #dialog-body { display: flex; flex-direction: column; height: 100%; }
dialog.mt-full .mt-list { flex: 1 1 auto; min-height: 0; max-height: none; }
.mt-map { flex: 0 0 42dvh; border-radius: 10px; margin-top: 6px; background: var(--border); position: relative; overflow: hidden; }
.mt-map-inner { position: absolute; transition: transform .6s linear; }
.mt-map-inner .mt-pin span { display: inline-block; transform: rotate(var(--rot, 0deg)); transition: transform .6s linear; }
.mt-map-btns { position: absolute; top: 8px; inset-inline-start: 8px; display: flex; flex-direction: column; gap: 6px; z-index: 1000; }
.mt-map-btns button { padding: 6px 10px; font-size: 15px; background: var(--surface); box-shadow: 0 1px 4px rgb(0 0 0 / .3); }
.mt-map-credit { position: absolute; bottom: 0; right: 0; z-index: 1000; font-size: 11px; padding: 1px 5px; background: rgb(255 255 255 / .8); color: #333; }
.mt-me { display: flex; align-items: center; justify-content: center; }
.mt-me span { display: block; color: #16a34a; font-size: 26px; line-height: 1; text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff; transition: transform .6s linear; }
.mt-nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 8px 2px; font-size: 16px; border-bottom: 1px solid var(--border); }
.mt-off { width: 100%; background: #dc2626; color: #fff; font-weight: 700; text-align: center; padding: 6px; border-radius: 8px; }
.mt-pin { background: var(--primary); color: #fff; border: 2px solid #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; font: 700 13px system-ui, sans-serif; box-shadow: 0 1px 4px rgb(0 0 0 / .4); }
.mt-pin.start { background: #111827; }
@media (prefers-color-scheme: dark) { .tag.bad, .mt-item.severe { background: #7f1d1d; color: #fff; } }

/* כספים */
.segmented { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 4px; margin-bottom: 12px; }
.segmented button { flex: 1; border: 0; padding: 8px 4px; font-size: 14px; background: none; }
.segmented button.on { background: var(--primary); color: #fff; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chips button.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); font-weight: 600; }
.bad { color: var(--danger); }
.card.expense { display: flex; gap: 12px; align-items: flex-start; }
.exp-photo { width: 72px; height: 72px; flex: none; border-radius: 10px; overflow: hidden; background: var(--bg); display: grid; place-items: center; font-size: 12px; color: var(--muted); text-align: center; }
.exp-photo img { width: 100%; height: 100%; object-fit: cover; }
.preview { max-width: 100%; max-height: 200px; border-radius: 10px; margin: -4px 0 12px; display: block; }
.warn-box { background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: 8px 10px; margin: 8px 0; }
.link-box { background: var(--bg); border-radius: 10px; padding: 8px 10px; word-break: break-all; font-size: 13px; }
button.link { border: 0; background: none; padding: 0; color: var(--primary); text-decoration: underline; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.thumb { display: flex; flex-direction: column; gap: 4px; align-items: center; font-size: 13px; text-align: center; }
.thumb a { width: 96px; height: 96px; border-radius: 10px; overflow: hidden; background: var(--bg); display: grid; place-items: center; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .pdf { font-weight: 700; color: var(--muted); }
a.button.small { padding: 6px 10px; font-size: 14px; }

/* בקשות לשיעור */
.request-bar { display: block; width: 100%; border: 0; text-align: center; font-weight: 600; margin: 0 0 12px; cursor: pointer; }
.wslot.request, .slot.request { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); border-style: dashed; }
.banner { background: var(--warn-soft); color: var(--warn); padding: 10px 16px; font-size: 14px; }
.legal-links { text-align: center; margin-bottom: 0; }
.legal h2 { font-size: 18px; margin: 20px 0 6px; }
.legal p, .legal li { line-height: 1.6; }
.features label.check { margin: 4px 0; }
table.simple { width: 100%; border-collapse: collapse; font-size: 14px; }
table.simple th, table.simple td { text-align: right; padding: 6px; border-bottom: 1px solid var(--border); white-space: nowrap; }

/* מסך היום */
.today-date { margin: 0 0 10px; }
.today-lesson.next { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.today-lesson.done { opacity: .7; }
button.plain { background: none; border: 0; padding: 8px 0; color: inherit; font: inherit; }

/* חתימה באצבע */
.sign-box { position: relative; margin: 8px 0 12px; }
canvas.sign { display: block; width: 100%; height: 160px; background: #fff; border: 1px dashed var(--muted); border-radius: 10px; touch-action: none; }
.sign-box button { position: absolute; top: 4px; left: 8px; color: #555; }
.sign-text { white-space: pre-wrap; max-height: 40vh; overflow: auto; background: var(--bg); border-radius: 10px; padding: 10px; margin-bottom: 12px; font-size: 15px; }
details.sig summary { display: flex; gap: 10px; align-items: center; cursor: pointer; list-style: none; }
details.sig img { width: 96px; height: 48px; object-fit: contain; background: #fff; border-radius: 6px; border: 1px solid var(--border); }
.pub-photo { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; display: block; margin-bottom: 8px; }
.prices { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin-bottom: 8px; }
.price-card { border: 1px solid var(--border); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 2px; text-align: center; }
.price-card .amount { font-size: 1.3em; font-weight: 700; }
.assistant-btn { margin-inline-start: auto; background: rgba(255, 255, 255, .15); border: 0; color: #fff; font-size: 18px; padding: 4px 10px; border-radius: 99px; align-self: center; }
.assistant-mic { width: 100%; font-size: 18px; padding: 14px; }
.list-item.clash { background: var(--warn-soft, #fef3c7); border-radius: 8px; padding-inline: 8px; color: var(--danger); }
