/* המחברת — design direction C, "לוח קוביות" (spec §11). */

@font-face { font-family: "Rubik"; font-weight: 400; font-display: swap;
  src: url(/fonts/rubik-hebrew-400-normal.woff2) format("woff2");
  unicode-range: U+0307-0308, U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F; }
@font-face { font-family: "Rubik"; font-weight: 400; font-display: swap;
  src: url(/fonts/rubik-latin-400-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Rubik"; font-weight: 500; font-display: swap;
  src: url(/fonts/rubik-hebrew-500-normal.woff2) format("woff2");
  unicode-range: U+0307-0308, U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F; }
@font-face { font-family: "Rubik"; font-weight: 500; font-display: swap;
  src: url(/fonts/rubik-latin-500-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Fredoka"; font-weight: 500; font-display: swap;
  src: url(/fonts/fredoka-hebrew-500-normal.woff2) format("woff2");
  unicode-range: U+0307-0308, U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F; }
@font-face { font-family: "Fredoka"; font-weight: 500; font-display: swap;
  src: url(/fonts/fredoka-latin-500-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Fredoka"; font-weight: 600; font-display: swap;
  src: url(/fonts/fredoka-hebrew-600-normal.woff2) format("woff2");
  unicode-range: U+0307-0308, U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F; }
@font-face { font-family: "Fredoka"; font-weight: 600; font-display: swap;
  src: url(/fonts/fredoka-latin-600-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* ---------- theme tokens (spec §11.2) ---------- */

:root {
  --bg: #f4f2f7; --surface: #ffffff; --surface-2: #ebe8f1; --line: #e3e0ea;
  --ink: #1d1b24; --muted: #66637a; --nav-active-bg: #1d1b24; --nav-active-fg: #ffffff;
  --good: #2f7d4f; --warn: #a96c12; --crit: #c2412d;
  color-scheme: light;

  /* course tiles: same pastel in both themes, dark ink on top */
  --peach:  #f6c3a5; --peach-ink:  #2a1a12;
  --sky:    #b9d6ee; --sky-ink:    #13222f;
  --lilac:  #d3c4f0; --lilac-ink:  #221a33;
  --mint:   #b8e3cf; --mint-ink:   #13271d;
  --butter: #f1e3a0; --butter-ink: #2b250c;
  --rose:   #f5c1d0; --rose-ink:   #2e131c;
  --periwinkle: #bcc6f2; --periwinkle-ink: #171b33;
  --teal:   #a9dedd; --teal-ink:   #0f2828;
  --lime:   #d5e8a6; --lime-ink:   #20280d;
  --sand:   #e2d3bc; --sand-ink:   #27200f;

  --r-tile: 22px; --r-pill: 999px; --r-input: 10px;
  --gap: 12px;
  --font-body: "Rubik", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Fredoka", "Rubik", system-ui, sans-serif;
  --nav-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #18171d; --surface: #24232b; --surface-2: #34333c; --line: #34333c;
    --ink: #f1eff5; --muted: #a19fae; --nav-active-bg: #f1eff5; --nav-active-fg: #18171d;
    --good: #8fd3ad; --warn: #f0c56a; --crit: #f0806b; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #18171d; --surface: #24232b; --surface-2: #34333c; --line: #34333c;
  --ink: #f1eff5; --muted: #a19fae; --nav-active-bg: #f1eff5; --nav-active-fg: #18171d;
  --good: #8fd3ad; --warn: #f0c56a; --crit: #f0806b; color-scheme: dark;
}

/* course color on any element: its tile, chip or row reads these */
[data-color="peach"] { --tile-bg: var(--peach); --tile-ink: var(--peach-ink); }
[data-color="sky"] { --tile-bg: var(--sky); --tile-ink: var(--sky-ink); }
[data-color="lilac"] { --tile-bg: var(--lilac); --tile-ink: var(--lilac-ink); }
[data-color="mint"] { --tile-bg: var(--mint); --tile-ink: var(--mint-ink); }
[data-color="butter"] { --tile-bg: var(--butter); --tile-ink: var(--butter-ink); }
[data-color="rose"] { --tile-bg: var(--rose); --tile-ink: var(--rose-ink); }
[data-color="periwinkle"] { --tile-bg: var(--periwinkle); --tile-ink: var(--periwinkle-ink); }
[data-color="teal"] { --tile-bg: var(--teal); --tile-ink: var(--teal-ink); }
[data-color="lime"] { --tile-bg: var(--lime); --tile-ink: var(--lime-ink); }
[data-color="sand"] { --tile-bg: var(--sand); --tile-ink: var(--sand-ink); }

/* ---------- base ---------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; height: 100%; overflow: hidden; }
/* The page itself never scrolls, only #scroller does. On iPhone a position: fixed bottom bar can come
   loose and scroll with the page after a time picker or the keyboard closes. */
body {
  margin: 0; height: 100dvh; overflow: hidden;
  display: flex; flex-direction: column;
  background: var(--bg); color: var(--ink);
  font: 400 16px/1.5 var(--font-body);
  font-variant-numeric: tabular-nums;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; margin: 0; line-height: 1.2; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.muted { color: var(--muted); }
/* a time reads left to right even in the RTL page: Firefox otherwise shows 08:30 as 30:08 */
input[type="time"] { direction: ltr; unicode-bidi: isolate; text-align: start; }

/* math stays left-to-right inside the RTL page (spec §4.5) */
.katex, .katex-display, .math, .math-block { direction: ltr; unicode-bidi: isolate; }
.md .math-block { text-align: left; overflow-x: auto; overflow-y: hidden; max-width: 100%; padding: 2px 0; }
.md .katex-display { text-align: left; margin: .4em 0; }
.md .katex-display > .katex { text-align: left; }

/* ---------- layout ---------- */

.topbar {
  flex: none; width: 100%; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: var(--bg);
}
.scroller { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.topbar-title { font-size: 22px; flex: 1; min-width: 0; }
.gear {
  display: grid; place-items: center; width: 44px; height: 44px;
  border-radius: var(--r-pill); color: var(--ink); background: var(--surface);
}
.gear svg { width: 22px; height: 22px; }
.gear[aria-current="page"] { background: var(--nav-active-bg); color: var(--nav-active-fg); }

.view {
  max-width: 1200px; margin: 0 auto;
  padding: 8px 16px 24px;
  outline: none;
}

/* phone: bottom nav */
.tabs {
  flex: none; z-index: 10;
  display: grid; grid-template-columns: repeat(6, 1fr);
  padding: 6px 2px calc(env(safe-area-inset-bottom) + 6px);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 52px; border-radius: 16px;
  color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 500;
}
.tabs a svg { width: 24px; height: 24px; }
.tabs a[aria-current="page"] { color: var(--ink); }
.tabs a[aria-current="page"] svg { background: var(--surface-2); border-radius: var(--r-pill); padding: 2px 10px; width: 46px; box-sizing: content-box; }

/* desktop: pill nav in the header (RTL: it sits on the left) */
.pills { display: none; }
@media (min-width: 900px) {
  .tabs { display: none !important; }
  .gear { display: none; }
  .pills { display: flex; gap: 6px; background: var(--surface); padding: 5px; border-radius: var(--r-pill); }
  .pills a {
    padding: 8px 16px; border-radius: var(--r-pill); min-height: 40px; display: flex; align-items: center;
    color: var(--ink); text-decoration: none; font-weight: 500; font-size: 15px;
  }
  .pills a[aria-current="page"] { background: var(--nav-active-bg); color: var(--nav-active-fg); }
  .topbar { max-width: 1232px; margin: 0 auto; padding-top: 18px; }
  .topbar-title { font-size: 26px; }
  .view { padding-bottom: 48px; }
}

/* ---------- bento tiles ---------- */

.greeting { padding: 4px 2px 14px; }
.greeting h2 { font-size: 30px; }
.greeting .date { color: var(--muted); margin-top: 2px; }

.bento { display: grid; gap: var(--gap); grid-template-columns: 1fr; }
@media (min-width: 640px) { .bento { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .bento { grid-template-columns: repeat(4, 1fr); } }
.bento .wide { grid-column: 1 / -1; }
@media (min-width: 900px) { .bento .half { grid-column: span 2; } }

.tile {
  background: var(--surface); border-radius: var(--r-tile);
  padding: 18px; min-height: 110px;
  display: flex; flex-direction: column; gap: 8px;
}
.tile h2 { font-size: 17px; font-weight: 500; }
.tile.course { color: var(--tile-ink); background: var(--tile-bg); }
.tile .empty { color: var(--muted); font-size: 15px; }
.tile.course .empty { color: inherit; opacity: .75; }

.empty-page {
  background: var(--surface); border-radius: var(--r-tile); padding: 28px 20px;
  color: var(--muted); text-align: center;
}

/* ---------- settings ---------- */

.section { display: flex; flex-direction: column; gap: 10px; margin-bottom: 22px; }
.section h2 { font-size: 18px; font-weight: 500; }
.card { background: var(--surface); border-radius: var(--r-tile); padding: 16px; display: flex; flex-direction: column; gap: 12px; }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: var(--r-pill); }
.segmented button {
  border: 0; background: transparent; min-height: 44px; border-radius: var(--r-pill); font-weight: 500;
}
.segmented button[aria-pressed="true"] { background: var(--nav-active-bg); color: var(--nav-active-fg); }

.btn {
  border: 0; min-height: 48px; padding: 0 22px; border-radius: var(--r-pill);
  background: var(--nav-active-bg); color: var(--nav-active-fg); font-weight: 500;
}
.btn.secondary { background: var(--surface-2); color: var(--ink); }
.btn.danger { background: transparent; color: var(--crit); padding: 0 4px; align-self: flex-start; }
.btn:disabled { opacity: .55; cursor: default; }

/* ---------- login ---------- */

.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--surface); border-radius: 28px; padding: 28px 22px;
  display: flex; flex-direction: column; gap: 14px;
}
.login-mark { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; width: 52px; height: 52px; }
.login-mark span { border-radius: 9px; }
.login-mark span:nth-child(1) { background: var(--peach); }
.login-mark span:nth-child(2) { background: var(--sky); }
.login-mark span:nth-child(3) { background: var(--mint); }
.login-mark span:nth-child(4) { background: var(--lilac); }
.login h1 { font-size: 30px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field input {
  min-height: 48px; padding: 0 14px; border-radius: var(--r-input);
  border: 1px solid var(--line); background: var(--bg); font-size: 16px;
}
.error { color: var(--crit); font-size: 15px; min-height: 1.5em; }

/* ---------- toast / offline ---------- */

.toast {
  position: fixed; inset-inline: 16px; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 14px);
  margin: 0 auto; max-width: 420px; z-index: 20;
  background: var(--nav-active-bg); color: var(--nav-active-fg);
  padding: 12px 16px; border-radius: 16px; text-align: center;
  opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: none; }
.offline {
  max-width: 1200px; margin: 0 auto 8px; padding: 8px 14px;
  background: var(--surface-2); color: var(--muted); border-radius: var(--r-pill); text-align: center; font-size: 14px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- weekly files: sync + upload ---------- */

.row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn.small { min-height: 44px; padding: 0 16px; align-self: flex-start; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; unicode-bidi: isolate; }
pre.mono { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; text-align: left; background: var(--surface-2); padding: 10px 12px; border-radius: var(--r-input); }
.small { font-size: 13px; }
.sync-line { font-size: 15px; }
.sync-warn { color: var(--warn); font-size: 15px; }
.sync-tile { min-height: 0; gap: 10px; }
.sync-tile .btn { align-self: flex-start; }
.quote { font-size: 17px; line-height: 1.55; }
.panel { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: 16px; background: var(--surface-2); }
.error-panel p:first-child { color: var(--crit); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 0; min-height: 44px; padding: 0 16px; border-radius: var(--r-pill); font-weight: 500;
  background: var(--tile-bg, var(--surface)); color: var(--tile-ink, var(--ink));
}
.file-errors { display: flex; flex-direction: column; gap: 8px; }
.file-error summary { cursor: pointer; min-height: 32px; color: var(--crit); }
.file-error pre { margin-top: 6px; }

/* ---------- homework (spec §11.3) ---------- */

.hw-head { justify-content: flex-start; margin-bottom: 12px; }
.task-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.task {
  display: grid; grid-template-columns: 32px 1fr auto; align-items: center; gap: 10px;
  background: var(--surface); border-radius: 18px; padding: 12px 12px 12px 10px;
  border-inline-start: 6px solid var(--tile-bg, var(--line));
}
.rank { font-family: var(--font-display); font-weight: 600; font-size: 20px; text-align: center; color: var(--muted); }
.task-main { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.task-title { font-weight: 500; overflow-wrap: anywhere; }
.task-when { font-size: 13px; }
.task.is-done .task-title { text-decoration: line-through; color: var(--muted); }
.task-actions { display: flex; align-items: center; gap: 4px; }
.icon-btn {
  border: 0; background: var(--surface-2); color: var(--ink); border-radius: var(--r-pill);
  min-width: 44px; min-height: 44px; display: inline-grid; place-items: center; font-size: 16px; padding: 0 10px;
}
.icon-btn:disabled { opacity: .5; cursor: default; }
.done-box { width: 28px; height: 28px; margin: 8px; accent-color: var(--good); cursor: pointer; }

.chips-s { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-s {
  display: inline-flex; align-items: center; min-height: 26px; padding: 0 10px; border-radius: var(--r-pill);
  font-size: 13px; font-weight: 500; background: var(--surface-2); color: var(--ink); white-space: nowrap;
}
.course-chip { background: var(--tile-bg); color: var(--tile-ink); }
.due-crit { background: color-mix(in srgb, var(--crit) 12%, transparent); color: color-mix(in srgb, var(--crit) 75%, var(--ink)); }
.due-warn { background: color-mix(in srgb, var(--warn) 20%, transparent); color: color-mix(in srgb, var(--warn) 75%, var(--ink)); }
.due-ok { background: color-mix(in srgb, var(--good) 16%, transparent); color: color-mix(in srgb, var(--good) 75%, var(--ink)); }
.tile.course .chip-s { background: color-mix(in srgb, var(--tile-ink) 12%, transparent); color: var(--tile-ink); }

.fold > summary { list-style: none; cursor: pointer; min-height: 44px; display: flex; align-items: center; gap: 8px; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::before { content: "‹"; font-size: 20px; transition: transform .15s; display: inline-block; }
.fold[open] > summary::before { transform: rotate(-90deg); }
.fold > .task-list { margin-top: 8px; }
.calibration { list-style: none; padding: 0; margin: 14px 2px 0; font-size: 14px; display: flex; flex-direction: column; gap: 2px; }
.section + .section, .task-list + .section, .calibration + .section { margin-top: 20px; }
.ranked + .section { margin-top: 20px; }

/* Home: top task + next tiles */
.top-task .top-title { font-family: var(--font-display); font-weight: 600; font-size: 22px; line-height: 1.25; }
.top-task .row { margin-top: auto; padding-top: 4px; }
.tile.course .btn { background: var(--tile-ink); color: var(--tile-bg); }
.tile.course .btn.secondary { background: color-mix(in srgb, var(--tile-ink) 12%, transparent); color: var(--tile-ink); }
.next-task { text-decoration: none; min-height: 0; gap: 6px; }
.next-course { font-size: 13px; font-weight: 500; opacity: .8; }
.next-title { font-weight: 500; }
.next-task .chip-s { align-self: flex-start; }

/* add/edit task: native modal dialog as a bottom sheet on phones */
dialog.sheet {
  border: 0; padding: 20px 18px calc(18px + env(safe-area-inset-bottom)); border-radius: 24px 24px 0 0;
  background: var(--surface); color: var(--ink); width: 100%; max-width: 520px;
  margin: auto auto 0; max-height: 92dvh; overflow-y: auto;
}
@media (min-width: 640px) { dialog.sheet { margin: auto; border-radius: 24px; } }
dialog.sheet h2 { font-size: 20px; margin-bottom: 14px; }
dialog:modal { overscroll-behavior: contain; }
dialog::backdrop { background: rgb(0 0 0 / .4); overflow: hidden; overscroll-behavior: contain; }
.task-form { display: flex; flex-direction: column; gap: 14px; }
.task-form .field input, .task-form .field select {
  min-height: 48px; padding: 0 12px; border-radius: var(--r-input); border: 1px solid var(--line);
  background: var(--bg); font-size: 16px; width: 100%;
}
.field-row { display: grid; grid-template-columns: 1.4fr 1fr; gap: 10px; }
.label { font-size: 15px; }
.form-actions .btn.danger { margin-inline-start: auto; align-self: center; }

/* ---------- exams (spec §4.5, §11.3) ---------- */

.exam-grid { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); align-items: start; }
.exam-tile { gap: 10px; }
.exam-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.exam-head h2 { min-width: 0; }
.exam-count { display: flex; align-items: baseline; gap: 8px; font-family: var(--font-display); font-weight: 500; }
.exam-big { font-size: 52px; font-weight: 600; line-height: 1; }
.exam-dates { list-style: none; margin: 0; padding: 0; font-size: 14px; display: flex; flex-wrap: wrap; gap: 2px 14px; }
.exam-dates li { opacity: .75; }
.exam-dates .current { opacity: 1; font-weight: 500; }
.ready { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0 8px; }
.ready label { font-weight: 500; }
.ready-value { font-weight: 500; }
.ready-slider { grid-column: 1 / -1; width: 100%; height: 44px; margin: 0; accent-color: var(--tile-ink); cursor: pointer; }
.ready-slider:disabled { opacity: .5; cursor: default; }
.next-block { opacity: .75; }
.view > .md { margin-bottom: 12px; padding-inline: 2px; }
.tile.course :focus-visible { outline-color: var(--tile-ink); }
.folder-link { display: inline-flex; align-items: center; justify-content: center; align-self: flex-start; text-decoration: none; min-height: 44px; }

/* the same four colors in both themes: chips sit on the pastel course tiles */
.topics, .topic-legend { display: flex; flex-wrap: wrap; gap: 6px; }
.topic-legend { margin-bottom: 12px; }
.topic {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 4px 12px; border-radius: var(--r-pill);
  border: 1px solid rgb(0 0 0 / .28); font-size: 14px; font-weight: 500; text-align: start;
  background: var(--topic-bg); color: #1d1b24;
}
.topic.static { min-height: 30px; font-size: 13px; }
.topic:disabled { opacity: .6; cursor: default; }
.topic-mark { font-weight: 600; }
.topic[data-status="todo"]    { --topic-bg: #f7b5a7; }
.topic[data-status="partial"] { --topic-bg: #fbe27e; }
.topic[data-status="unclear"] { --topic-bg: #dcdae2; }
.topic[data-status="done"]    { --topic-bg: #9fe0ad; }

.other-folders { margin-top: 20px; }
.chips a.chip { display: inline-flex; align-items: center; text-decoration: none; }
a.home-exam { text-decoration: none; }
.home-exam .exam-big { font-size: 40px; }
.home-exam .exam-name { font-weight: 500; }
.home-exam .small { opacity: .8; }

/* folder */
.back-link { display: inline-flex; align-items: center; min-height: 44px; color: var(--ink); text-decoration: none; font-weight: 500; }
.folder-head { min-height: 0; margin-bottom: 12px; }
.folder-head h2 { font-size: 22px; }
.folder-tabs { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: none; }
.folder-tabs button {
  flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px;
  border: 0; border-radius: var(--r-pill); background: var(--surface); font-weight: 500; font-size: 15px;
}
.folder-tabs button[aria-selected="true"] { background: var(--nav-active-bg); color: var(--nav-active-fg); }
.tab-count { font-size: 12px; opacity: .75; }
.md { overflow-wrap: anywhere; min-width: 0; line-height: 1.65; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol, .md pre, .md table, .md blockquote { margin: 0 0 .75em; }
.md ul, .md ol { padding-inline-start: 1.4em; }
.md li + li { margin-top: .35em; }
.md h3, .md h4 { font-size: 17px; margin: 1em 0 .4em; }
.md a { color: inherit; }
.md blockquote { border-inline-start: 3px solid var(--line); padding-inline-start: 12px; color: var(--muted); }
.md code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .9em; background: var(--surface-2); padding: 1px 5px; border-radius: 6px; unicode-bidi: isolate; direction: ltr; }
.md pre { direction: ltr; text-align: left; overflow-x: auto; background: var(--surface-2); padding: 10px 12px; border-radius: var(--r-input); }
.md pre code { background: none; padding: 0; }
.md table { display: block; overflow-x: auto; border-collapse: collapse; }
.md th, .md td { border: 1px solid var(--line); padding: 6px 10px; text-align: start; }
.md img { max-width: 100%; height: auto; }
.md .katex { overflow-wrap: normal; }

/* ---------- course colors ---------- */

.color-list { gap: 16px; }
.color-course { font-weight: 500; margin-bottom: 6px; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch {
  width: 44px; height: 44px; border-radius: var(--r-pill); border: 1px solid rgb(0 0 0 / .12); padding: 0;
  background: var(--tile-bg); color: var(--tile-ink); font-weight: 600;
}
.swatch[aria-pressed="true"] { outline: 2px solid var(--ink); outline-offset: 2px; }
.swatch:disabled { opacity: .5; cursor: default; }

/* ---------- labs ---------- */

.lab-grid { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); align-items: start; }
.lab { background: var(--surface); border-radius: var(--r-tile); overflow: hidden; }
.lab-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 14px 18px; background: var(--tile-bg); color: var(--tile-ink); }
.lab-head h2 { font-size: 18px; }
.lab-progress { font-size: 14px; font-weight: 500; white-space: nowrap; }
.parts { list-style: none; margin: 0; padding: 8px 14px 10px; }
.part {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 0; padding-inline-start: 22px;
}
.part::before { content: ""; position: absolute; inset-inline-start: 4px; top: 18px; width: 10px; height: 10px; border-radius: 50%; background: var(--tile-bg); border: 1px solid var(--muted); }
.part:not(:last-child)::after { content: ""; position: absolute; inset-inline-start: 8.5px; top: 30px; bottom: -16px; width: 1px; background: var(--line); }
.part.is-done::before { background: var(--good); border-color: var(--good); }
.part.is-done .part-title { text-decoration: line-through; color: var(--muted); }
.part-main { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.part-title { font-weight: 500; overflow-wrap: anywhere; }
.part-when { font-size: 13px; display: flex; align-items: center; gap: 4px; }
.part-clock { display: inline-flex; }
.part-clock svg { width: 16px; height: 16px; }
.fold > .lab-grid { margin-top: 8px; }
.lab-grid + .section { margin-top: 20px; }

/* ---------- גוף ונפש ---------- */

.body-top { margin-bottom: 22px; align-items: start; }
.body-day { display: flex; flex-direction: column; gap: 14px; }
.body-day .section { margin-bottom: 0; }
.ring-row { display: flex; align-items: center; gap: 12px; }
.ring {
  --ring-ink: var(--tile-ink, var(--ink));
  flex: none; display: grid; place-items: center; width: 68px; height: 68px; border-radius: 50%;
  background: conic-gradient(var(--ring-ink) var(--p), color-mix(in srgb, var(--ring-ink) 15%, transparent) 0);
  font-family: var(--font-display); font-weight: 600; font-size: 18px;
}
.ring span { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: var(--tile-bg, var(--surface)); }
.home-link { text-decoration: none; color: inherit; }
.tile .btn { align-self: flex-start; }
.workout-list { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.workout-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tile.course .icon-btn { background: color-mix(in srgb, var(--tile-ink) 12%, transparent); color: var(--tile-ink); }
.tile.course .muted { color: inherit; opacity: .8; }
.chip.pick { background: var(--surface-2); color: var(--ink); }
.chip.pick[aria-pressed="true"] { background: var(--nav-active-bg); color: var(--nav-active-fg); }
.habit-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.habit { display: flex; align-items: center; gap: 4px; min-height: 44px; cursor: pointer; }
.habit-name { flex: 1; min-width: 0; }
.screen-line { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.stepper { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; }
.stepper-value { text-align: center; font-family: var(--font-display); font-weight: 600; font-size: 22px; }
.stepper-value.over { color: var(--warn); }
.habit-grid { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 3px; }
.habit-grid.head { font-size: 11px; color: var(--muted); text-align: center; }
.habit-grid-row { display: flex; flex-direction: column; gap: 4px; }
.cell { aspect-ratio: 1; border-radius: 5px; background: var(--surface-2); }
.cell.on { background: var(--good); }
.cell.today { outline: 1.5px solid var(--ink); outline-offset: 1px; }
.habit-grid-fold .card { margin-top: 8px; }

/* ---------- notifications ---------- */

.card-title { font-size: 16px; font-weight: 500; }
.btn.align-start { align-self: flex-start; }
.notif-fields { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.notif-fields .field input, .per-day-row input[type="time"] {
  min-height: 44px; padding: 0 10px; border-radius: var(--r-input); border: 1px solid var(--line);
  background: var(--bg); font-size: 16px; width: 100%; min-width: 0;
}
.per-day > summary { min-height: 44px; font-weight: 500; font-size: 15px; }
.per-day-rows { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.per-day-row { display: grid; grid-template-columns: 32px 1fr auto; align-items: center; gap: 8px; }
.per-day-name { font-weight: 500; }
.per-day-off { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; font-size: 14px; }
.per-day-off input { width: 22px; height: 22px; accent-color: var(--good); }
.card > .segmented button { font-size: 14px; padding: 0 6px; }

/* ---------- timer and תקועה ---------- */

.timer-screen {
  position: fixed; inset: 0; z-index: 30; overflow-y: auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center;
  padding: calc(env(safe-area-inset-top) + 64px) 20px calc(env(safe-area-inset-bottom) + 28px);
  background: var(--tile-bg); color: var(--tile-ink);
}
.timer-min {
  position: absolute; top: calc(env(safe-area-inset-top) + 10px); inset-inline-end: 12px; min-height: 44px; padding: 0 16px;
  border: 0; border-radius: var(--r-pill); font-weight: 500; color: inherit; background: color-mix(in srgb, var(--tile-ink) 12%, transparent);
}
.timer-course { font-weight: 500; opacity: .8; }
.timer-title { font-size: 24px; max-width: 560px; overflow-wrap: anywhere; }
.timer-phase { font-family: var(--font-display); font-weight: 500; font-size: 18px; margin-top: 12px; }
.timer-clock { font-family: var(--font-display); font-weight: 600; font-size: clamp(72px, 26vw, 140px); line-height: 1; }
.timer-question { font-family: var(--font-display); font-weight: 600; font-size: 30px; margin-top: 16px; }
.timer-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 18px; max-width: 420px; }
.timer-screen .btn { background: var(--tile-ink); color: var(--tile-bg); }
.timer-screen .btn.secondary { background: color-mix(in srgb, var(--tile-ink) 12%, transparent); color: var(--tile-ink); }
.timer-screen :focus-visible { outline-color: var(--tile-ink); }
.timer-pill {
  position: fixed; z-index: 15; inset-inline-start: 16px; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 14px);
  min-height: 48px; padding: 0 20px; border: 1px solid rgb(0 0 0 / .15); border-radius: var(--r-pill);
  background: var(--tile-bg); color: var(--tile-ink); font-family: var(--font-display); font-weight: 600; font-size: 20px;
  box-shadow: 0 2px 10px rgb(0 0 0 / .2);
}
@media (min-width: 900px) { .timer-pill { bottom: 24px; } }
.stuck-intro { margin-top: 10px; }
.stuck-text { font-family: var(--font-display); font-weight: 500; font-size: 20px; line-height: 1.35; margin: 4px 0 18px; }
.part .task-actions { flex: none; }

/* ---------- the plan ---------- */

.warn-tile { min-height: 0; background: color-mix(in srgb, var(--warn) 16%, var(--surface)); }
.warn-tile ul { margin: 0; padding-inline-start: 18px; display: flex; flex-direction: column; gap: 6px; }
.today-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.today-list li {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding-inline-start: 10px;
  border-inline-start: 5px solid var(--tile-bg); border-radius: 3px;
}
.today-time { font-size: 13px; color: var(--muted); white-space: nowrap; flex: none; }
.today-label { flex: 1; min-width: 0; overflow-wrap: anywhere; font-weight: 500; }
.today-list .is-class .today-label { font-weight: 400; color: var(--muted); }
.today-list .is-class { border-inline-start-color: var(--line); }
.today-list .is-past .today-label { text-decoration: line-through; }
.window-row { display: grid; grid-template-columns: 26px 1fr 1fr auto; align-items: center; gap: 6px; }
.window-row input[type="time"] {
  min-height: 44px; padding: 0 6px; border-radius: var(--r-input); border: 1px solid var(--line);
  background: var(--bg); font-size: 16px; width: 100%; min-width: 0;
}
.window-row input[type="time"]:disabled { opacity: .45; }

/* ---------- reading and diary ---------- */

.field-row.even { grid-template-columns: 1fr 1fr; }
.reading-now { flex-direction: row; align-items: center; justify-content: space-between; min-height: 0; }
.reading-clock { font-family: var(--font-display); font-weight: 600; font-size: 24px; }
.book-list { list-style: none; margin: 8px 0 0; display: flex; flex-direction: column; gap: 10px; }
.book-session { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.fold > .card-title { margin-top: 12px; }
.diary-input {
  width: 100%; min-height: 110px; padding: 10px 12px; border-radius: var(--r-input); border: 1px solid var(--line);
  background: var(--bg); font-size: 16px; line-height: 1.5; resize: vertical;
}
.diary-text { white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- calendar tab ---------- */

.tabs a { font-size: 11px; min-width: 0; white-space: nowrap; }
.tabs a[aria-current="page"] svg { padding: 2px 6px; width: 38px; }
.link-btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.cal-note { margin-bottom: 12px; display: block; }
.card.cal-note { display: flex; }
.cal-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.cal-nav { align-items: center; }
.cal-mode { min-width: 150px; }
.cal-mode button { min-height: 44px; font-size: 14px; }
.cal-grid { background: var(--surface); border-radius: 16px; --cal-gutter: 42px; }
.cal-head, .cal-allday, .cal-body { display: grid; grid-template-columns: var(--cal-gutter) repeat(var(--cal-days), minmax(0, 1fr)); }
.cal-head { position: sticky; top: 0; z-index: 3; background: var(--surface); border-radius: 16px 16px 0 0; border-bottom: 1px solid var(--line); }
.cal-day-head { display: flex; flex-direction: column; align-items: center; padding: 6px 0; font-size: 12px; color: var(--muted); }
.cal-day-head strong { font-size: 13px; color: var(--ink); font-weight: 500; }
.cal-day-head.is-today strong { background: var(--nav-active-bg); color: var(--nav-active-fg); border-radius: var(--r-pill); padding: 0 7px; }
.cal-allday { border-bottom: 1px solid var(--line); }
.cal-allday-day { display: flex; flex-direction: column; gap: 2px; padding: 2px 1px; min-width: 0; }
.cal-allday-item { border: 0; border-radius: 5px; padding: 2px 4px; font-size: 11px; font-weight: 500; text-align: start; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-height: 22px; }
.cal-hours { position: relative; }
.cal-hours span { position: absolute; inset-inline: 0; text-align: center; font-size: 11px; color: var(--muted); transform: translateY(1px); }
.cal-day {
  position: relative; min-width: 0; border-inline-start: 1px solid var(--line);
  background-image: repeating-linear-gradient(to bottom, var(--line) 0 1px, transparent 1px var(--hour));
}
.cal-day.is-today { background-color: color-mix(in srgb, var(--surface-2) 45%, transparent); }
.cal-item {
  position: absolute; display: flex; flex-direction: column; align-items: stretch; gap: 0; padding: 1px 3px; overflow: hidden;
  border: 0; border-radius: 5px; font-size: 11px; line-height: 1.25; text-align: start;
  background: var(--tile-bg, var(--surface-2)); color: var(--tile-ink, var(--ink)); box-shadow: 0 0 0 1px var(--surface);
}
.cal-item-time { font-size: 10px; text-align: start; unicode-bidi: isolate; }
.cal-item-label { font-weight: 500; overflow: hidden; overflow-wrap: anywhere; }
.cal-item.is-class { background: var(--surface-2); color: var(--muted); border-inline-start: 3px solid var(--tile-bg, var(--line)); }
.cal-item.is-class .cal-item-label { font-weight: 400; }
.cal-item.is-busy { background: var(--surface-2); color: var(--muted); }
.cal-item.is-lab { outline: 1.5px solid var(--tile-ink); outline-offset: -1.5px; }
.cal-item.is-prep { background-image: repeating-linear-gradient(135deg, transparent 0 6px, rgb(0 0 0 / .07) 6px 12px); }
.cal-item.is-past { opacity: .8; }
.cal-now { position: absolute; inset-inline: 0; height: 2px; background: var(--crit); z-index: 2; pointer-events: none; }
.cal-foot { align-items: center; justify-content: space-between; margin-top: 10px; }
.cal-facts { display: flex; flex-direction: column; gap: 4px; margin-bottom: 16px; }

/* ---------- polish ---------- */

.cal-heavy { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: var(--warn); color: var(--surface); font-size: 11px; font-weight: 600; }
.view:focus { outline: none; }
