/* The classes screens: the timetable ("המערכת שלי"), the classes list, a class page and the settings
   (js/screens/{timetable,classes,class,settings}.js). Tokens and components come from app.css and motion.css:
   one curve (--ease), durations --t1/--t2/--t3, logical properties only (RTL). */

/* ---------- class colors: the six tokens --k0..--k5 of app.css, always next to the class name ----------
   Any screen can use them: data-kc="0..5" on an element sets --kc; .kdot is the small round mark. */
[data-kc="0"] { --kc: var(--k0); }
[data-kc="1"] { --kc: var(--k1); }
[data-kc="2"] { --kc: var(--k2); }
[data-kc="3"] { --kc: var(--k3); }
[data-kc="4"] { --kc: var(--k4); }
[data-kc="5"] { --kc: var(--k5); }
.kdot { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--kc, var(--faint)); box-shadow: 0 0 0 2px color-mix(in srgb, var(--kc, var(--faint)) 22%, transparent); }
.kdot.lg { width: 14px; height: 14px; }
.chip.cur { background: var(--board-soft); color: var(--board); }
.chip.cur .ic, .chip .ic { width: 15px; height: 15px; }
.chip.ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); }

/* ---------- forms shared by the class sheets ---------- */
.kform { display: grid; gap: 18px; margin-top: 14px; }
.kform .hint { color: var(--muted); font-size: 14px; }
.kform .err-line { color: var(--danger); font-size: 14px; font-weight: 600; min-height: 1em; }
.input[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 18%, transparent); }
.subj-rows { display: grid; gap: 8px; }
.subj-row { display: flex; align-items: center; gap: 8px; animation: rise var(--t3) var(--ease) both; }
.subj-row .input { flex: 1; min-width: 0; }
.subj-row .chip { flex: none; }
.subj-row .btn.ghost { min-width: 44px; padding: 0 10px; }
.suggest { display: flex; flex-wrap: wrap; gap: 6px; }
.suggest button { min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px dashed var(--line); background: transparent; color: var(--muted); cursor: pointer; font-weight: 600;
  transition: border-color var(--t2) var(--ease), color var(--t2) var(--ease), transform var(--t1) var(--ease); }
.suggest button:hover { border-color: var(--board); color: var(--board); }
.suggest button:active { transform: scale(.96); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatches button { width: 44px; height: 44px; border-radius: 50%; border: 2px solid transparent; background: transparent; cursor: pointer; display: grid; place-items: center;
  transition: border-color var(--t2) var(--ease), transform var(--t1) var(--ease); }
.swatches button::before { content: ""; width: 26px; height: 26px; border-radius: 50%; background: var(--kc); }
.swatches button[aria-pressed="true"] { border-color: var(--kc); }
.swatches button:active { transform: scale(.94); }

/* ---------- the timetable ("המערכת שלי") ---------- */
.tt-setup { max-width: 1060px; margin: 0 auto; padding: 8px 0 64px; }
.tt-setup .brand-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 28px; }
.tt-step { display: flex; align-items: baseline; gap: 10px; }
.tt-step .n { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--board-soft); color: var(--board); font-weight: 700; font-size: 15px; flex: none; }
.tt-note { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--r-m); background: var(--paper-2); color: var(--muted); font-size: 15px; margin-bottom: 20px; }

.bells { margin-bottom: 28px; }
.bells > summary { list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; padding: 6px 18px; cursor: pointer; }
.bells > summary::-webkit-details-marker { display: none; }
.bells > summary .chev { color: var(--muted); transition: transform var(--t2) var(--ease); }
.bells[open] > summary .chev { transform: rotate(-90deg); }
.bells .body { padding: 4px 18px 18px; }
.bell-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 8px 20px; }
.bell { display: flex; align-items: center; gap: 8px; min-height: 52px; }
.bell .lbl { min-width: 64px; font-weight: 600; color: var(--muted); font-size: 15px; }
.bell .input { min-height: 44px; padding: 6px 10px; width: 108px; font-variant-numeric: tabular-nums; }
.bell .to { color: var(--faint); }
.bell .btn.ghost { min-width: 44px; padding: 0 10px; color: var(--muted); }
.bell .btn.ghost:hover { color: var(--danger); }
.bells .actions { margin-top: 14px; }

.tt { position: relative; }
.tt-days { display: none; }
.tt-grid { display: grid; grid-template-columns: 96px repeat(6, minmax(0, 1fr)); gap: 6px; }
.tt-dh { text-align: center; font-weight: 700; padding: 4px 0 8px; position: relative; color: var(--muted); }
.tt-dh .d { display: block; color: var(--ink); font-size: 17px; }
.tt-dh.today .d { color: var(--ink); }
.tt-dh .line { position: absolute; inset-inline: 18%; bottom: 0; height: 10px; }
.tt-dh .line svg { width: 100%; height: 100%; display: block; overflow: visible; }
.tt-ph { display: flex; flex-direction: column; justify-content: center; padding-inline-end: 6px; min-height: 68px; }
.tt-ph .p { font-weight: 700; }
.tt-ph .tm { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; direction: ltr; text-align: end; }
.tt-break { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; color: var(--faint); font-size: 13px; height: 16px; }
.tt-break::before, .tt-break::after { content: ""; flex: 1; border-top: 1px dashed var(--line); }
.tt-cell {
  position: relative; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 0; min-height: 68px; width: 100%;
  padding: 8px 12px; border-radius: var(--r-m); border: 1px dashed var(--line); background: color-mix(in srgb, var(--surface) 55%, transparent);
  text-align: start; cursor: pointer; color: var(--faint); overflow: hidden;
  transition: background var(--t2) var(--ease), border-color var(--t2) var(--ease), transform var(--t1) var(--ease), box-shadow var(--t2) var(--ease);
}
.tt-cell:hover { border-color: var(--board); color: var(--board); }
.tt-cell:active { transform: scale(.97); }
.tt-cell .plus { align-self: center; opacity: .55; transition: opacity var(--t2) var(--ease); }
.tt-cell:hover .plus { opacity: 1; }
.tt-cell.filled {
  border: 1px solid color-mix(in srgb, var(--kc) 35%, var(--line)); border-inline-start: 4px solid var(--kc);
  background: color-mix(in srgb, var(--kc) 11%, var(--surface)); color: var(--ink); box-shadow: var(--shadow-1), var(--hi);
}
.tt-cell.filled:hover { border-color: var(--kc); }
.tt-cell .n { font-weight: 700; line-height: 1.3; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tt-cell .s { font-size: 14px; color: var(--muted); line-height: 1.3; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tt-cell .changed { position: absolute; top: 7px; inset-inline-end: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--board); }
.tt-cell.inked { animation: ink var(--t3) var(--ease); }
@keyframes ink { 0% { transform: scale(.94); opacity: .4; } 100% { transform: none; opacity: 1; } }
.tt-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--line); }
.tt-count { color: var(--muted); }
.tt-count strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.tt-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 16px; color: var(--muted); font-size: 15px; }
.tt-legend span { display: inline-flex; align-items: center; gap: 8px; }

/* the bar that holds unsaved timetable changes */
.tt-bar-box { position: sticky; bottom: 16px; z-index: 20; }
.tt-bar {
  margin-top: 28px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  padding: 12px 12px 12px 16px; border-radius: var(--r-l); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-2), var(--hi);
  animation: rise var(--t3) var(--ease) both;
}
.tt-bar .grow { flex: 1; min-width: 160px; font-weight: 600; }
.tt-bar .grow .muted { font-weight: 400; display: block; font-size: 14px; }
@media (max-width: 860px) { .tt-bar-box { bottom: calc(76px + env(safe-area-inset-bottom)); } }

/* the cell sheet: pick a class and a subject */
.pick-class { padding: 12px 0; }
.pick-class + .pick-class { border-top: 1px solid var(--line); }
.pick-class .k { display: flex; align-items: center; gap: 10px; font-weight: 700; margin-bottom: 8px; }
.pick-class .k .muted { font-weight: 400; font-size: 14px; }
.pick-class .picks { gap: 8px; }
.pick-class .pick[aria-pressed="true"] { background: var(--kc, var(--board)); border-color: var(--kc, var(--board)); color: #fff; }
:root[data-theme="dark"] .pick-class .pick[aria-pressed="true"] { color: #0f1a16; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pick-class .pick[aria-pressed="true"] { color: #0f1a16; } }
.sheet-foot { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.sheet-foot .spacer { flex: 1; }
.add-subj { display: flex; gap: 8px; margin-top: 8px; }
.add-subj .input { flex: 1; min-width: 0; min-height: 44px; }

@media (max-width: 700px) {
  .tt-days { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; padding: 4px; border-radius: 999px; background: var(--paper-2); margin-bottom: 14px; }
  .tt-days button {
    position: relative; min-height: 44px; border: 0; border-radius: 999px; background: transparent; cursor: pointer; font-weight: 700; color: var(--muted);
    transition: background var(--t2) var(--ease), color var(--t2) var(--ease), transform var(--t1) var(--ease);
  }
  .tt-days button:active { transform: scale(.95); }
  .tt-days button[aria-pressed="true"] { background: var(--surface-2); color: var(--ink); box-shadow: var(--shadow-1); }
  .tt-days button .c { position: absolute; bottom: 4px; inset-inline: 0; margin: 0 auto; width: 4px; height: 4px; border-radius: 50%; background: var(--board); }
  .tt-days button.today::after { content: ""; position: absolute; top: 5px; inset-inline-end: 9px; width: 6px; height: 6px; border-radius: 50%; background: var(--chalk); }
  .tt-grid { grid-template-columns: 76px 1fr; gap: 6px 8px; }
  .tt-dh, .tt-corner { display: none; }
  .tt[data-day="0"] .tt-cell:not([data-day="0"]), .tt[data-day="1"] .tt-cell:not([data-day="1"]),
  .tt[data-day="2"] .tt-cell:not([data-day="2"]), .tt[data-day="3"] .tt-cell:not([data-day="3"]),
  .tt[data-day="4"] .tt-cell:not([data-day="4"]), .tt[data-day="5"] .tt-cell:not([data-day="5"]) { display: none; }
  .tt-day-in .tt-cell { animation: rise var(--t3) var(--ease) both; }
  .tt-cell { min-height: 60px; }
  .bell-list { grid-template-columns: 1fr; }
  .bell .input { width: auto; flex: 1; min-width: 0; }
}

/* ---------- the classes list ---------- */
.kcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; list-style: none; margin: 0; padding: 0; }
.kcards > li { animation: rise var(--t3) var(--ease) both; }
.kcards > li:nth-child(2) { animation-delay: 40ms; } .kcards > li:nth-child(3) { animation-delay: 80ms; } .kcards > li:nth-child(n+4) { animation-delay: 120ms; }
.kcard {
  position: relative; display: flex; flex-direction: column; gap: 12px; height: 100%; padding: 20px 20px 16px; border-radius: var(--r-m);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1), var(--hi); text-decoration: none; overflow: hidden;
  transition: box-shadow var(--t2) var(--ease), transform var(--t1) var(--ease), border-color var(--t2) var(--ease);
}
.kcard::before { content: ""; position: absolute; inset-block-start: 0; inset-inline: 0; height: 4px; background: var(--kc); }
.kcard:hover { box-shadow: var(--shadow-2), var(--hi); border-color: color-mix(in srgb, var(--kc) 40%, var(--line)); }
.kcard:active { transform: scale(.99); }
.kcard .top { display: flex; align-items: center; gap: 10px; }
.kcard h2 { font-size: 24px; }
.kcard .meta { color: var(--muted); font-size: 15px; }
.kcard .subs { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.kcard .subs li { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.kcard .subs .nm { font-weight: 700; }
.kcard .subs .nx { color: var(--muted); font-size: 15px; min-width: 0; }
.kcard .subs .nx strong { color: var(--ink); font-weight: 600; }
.kcard .go { margin-top: auto; display: flex; align-items: center; justify-content: flex-end; color: var(--board); font-weight: 600; font-size: 15px; gap: 4px; }
.kcard.fresh { animation: fresh 900ms var(--ease); }
@keyframes fresh { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--board) 50%, transparent); } 100% { box-shadow: 0 0 0 14px transparent; } }
.k-sum { display: flex; flex-wrap: wrap; gap: 8px 28px; color: var(--muted); margin: -12px 0 24px; }
.k-sum strong { color: var(--ink); font-family: var(--display); font-size: 21px; font-variant-numeric: tabular-nums; }

/* ---------- a class page ---------- */
.k-title { display: flex; align-items: center; gap: 12px; }
.subj-tabs { display: flex; gap: 4px; overflow-x: auto; margin: -12px 0 28px; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.subj-tabs::-webkit-scrollbar { display: none; }
.subj-tabs a {
  position: relative; display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 16px; text-decoration: none; white-space: nowrap;
  color: var(--muted); font-weight: 700; border-radius: var(--r-s) var(--r-s) 0 0; transition: color var(--t2) var(--ease), background var(--t2) var(--ease);
}
.subj-tabs a:hover { color: var(--ink); background: var(--paper-2); }
.subj-tabs a[aria-current="page"] { color: var(--board); }
.subj-tabs a[aria-current="page"]::after { content: ""; position: absolute; inset-inline: 10px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--board); view-transition-name: subj-ind; }
.subj-tabs .ic { width: 16px; height: 16px; }
@media (hover: none) { .subj-tabs a:hover { background: transparent; } }

/* the board at the top of a subject: where it stands (pace, held, cancelled) */
.next.pace { grid-template-columns: 1fr; align-items: start; }
.next.pace .k { color: var(--chalk-dim); }
.next.pace h2 { margin-bottom: 4px; }
.pace .board-line { margin-top: 0; }
.pace .nums { display: flex; flex-wrap: wrap; gap: 12px 36px; margin-top: 18px; }
.pace .nums .v { font-family: var(--display); font-size: 30px; line-height: 1; font-variant-numeric: tabular-nums; color: var(--chalk-ink); }
.pace .nums .l { color: var(--chalk-dim); font-size: 14px; margin-top: 4px; }
.pace .why { background: rgba(255, 255, 255, .06); color: var(--chalk-dim); margin-top: 16px; padding: 10px 14px; font-size: 15px; display: block; }
.pace .why strong { color: var(--chalk-ink); }
.pace .progress { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .1); overflow: hidden; margin-top: 16px; max-width: 520px; }
.pace .progress i { display: block; height: 100%; border-radius: 3px; background: var(--chalk-ink); transform-origin: right; animation: grow 900ms var(--ease) both; animation-delay: 200ms; }
.pace .progress i.exp { position: relative; }

/* rows with a link and a side action (skip) */
.lrows > li { display: flex; align-items: center; gap: 4px; padding-inline-end: 8px; }
.lrows > li + li { border-top: 1px solid var(--line); }
.lrows > li > .row { flex: 1; min-width: 0; }
.lrows > li > .row + .row { border-top: 0; }
.lrows .when { flex: none; width: 54px; text-align: center; line-height: 1.2; }
.lrows .when .d { display: block; font-weight: 700; }
.lrows .when .m { display: block; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.lrows .side { flex: none; color: var(--muted); }
.lrows .row.static { cursor: default; }
.lrows .row.static:hover, .lrows .row.static:active { background: transparent; transform: none; }
.lrows .struck .t { text-decoration: line-through; color: var(--faint); }
.lrows .here { box-shadow: inset 3px 0 0 var(--chalk); }
.row .chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.row .t .math { font-weight: 600; }

/* the free subject's topic list */
.topics { counter-reset: tp; }
.topics > li { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 8px; min-height: 60px; }
.topics > li + li { border-top: 1px solid var(--line); }
.topics .num { min-width: 2em; text-align: center; color: var(--faint); font-variant-numeric: tabular-nums; }
.topics .grow { flex: 1; min-width: 0; }
.topics .t { font-weight: 600; overflow-wrap: anywhere; }
.topics .s { color: var(--muted); font-size: 14px; }
.topics .tools { display: flex; gap: 2px; flex: none; }
.topics .tools .btn { min-width: 44px; padding: 0 8px; color: var(--muted); }
.topics .tools .btn:hover { color: var(--board); }
.topics .tools .btn.del:hover { color: var(--danger); }
.topics .edit { display: flex; gap: 8px; flex: 1; min-width: 0; }
.topics .edit .input { flex: 1; min-width: 0; min-height: 44px; }
.topics li.moved { animation: ink var(--t3) var(--ease); }
.topic-add { display: flex; gap: 10px; padding: 14px 16px; border-top: 1px solid var(--line); }
.topic-add .input { flex: 1; min-width: 0; }
.taught-topics > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; min-height: 52px; padding: 0 16px; color: var(--muted); font-weight: 600; }
.taught-topics > summary::-webkit-details-marker { display: none; }
.taught-topics > summary .chev { transition: transform var(--t2) var(--ease); }
.taught-topics[open] > summary .chev { transform: rotate(-90deg); }
.taught-topics ol { margin: 0; padding: 0 16px 12px; list-style: none; color: var(--muted); }
.taught-topics li { padding: 6px 0; display: flex; gap: 10px; justify-content: space-between; }
.rotation { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.rotation .chip { font-size: 15px; padding: 5px 12px; }
.rotation .chip.weak { font-weight: 700; }

/* the year chart topic bars are buttons here (they open the topic's lessons) */
.chart button.tb { font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; text-align: start; }
.months button.row { width: 100%; border: 0; background: transparent; font: inherit; text-align: start; cursor: pointer; color: inherit; }
.chart .now .lbl { color: #1c2925; }

.k-split { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 860px) { .k-split { grid-template-columns: 1fr; } }
.k-part { margin-top: 64px; padding-top: 28px; border-top: 2px solid var(--line); }
.k-part > .kicker { color: var(--muted); font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.mini-empty { color: var(--muted); padding: 18px 20px; }
.mini-empty strong { color: var(--ink); display: block; margin-bottom: 2px; }
.mk-row .row { min-height: 64px; }
.mk-tools { display: flex; flex-wrap: wrap; gap: 6px; flex: none; }
@media (max-width: 560px) {
  .lrows > li { flex-wrap: wrap; padding-inline: 0 8px; }
  .mk-row { padding-bottom: 10px; }
  .mk-row .mk-tools { padding-inline-start: 16px; }
}
.danger-zone { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 20px; padding: 16px 20px; border-radius: var(--r-m); border: 1px dashed color-mix(in srgb, var(--danger) 40%, var(--line)); }
.danger-zone p { color: var(--muted); font-size: 15px; max-width: 52ch; }

/* ---------- settings ---------- */
.set-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 760px) { .set-grid { grid-template-columns: 1fr; } }
.set-grid .box { padding: 22px 22px 20px; box-shadow: var(--shadow-1), var(--hi); }
.set-grid .box.wide { grid-column: 1 / -1; }
.set-grid .box > p.muted { margin-bottom: 4px; }
.code-row { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.code-row .input { flex: 1; min-width: 180px; text-align: start; direction: ltr; letter-spacing: .04em; }
.code-state { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 14px; font-weight: 600; }
.code-state.on { color: var(--board); }
.code-state.off { color: var(--muted); }
.set-grid .box h3 { display: flex; align-items: center; gap: 10px; }
.set-grid .box h3 .ic { color: var(--board); }
.backup-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.about { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; margin-top: 36px; }
.ic.rot-up { transform: rotate(90deg); }
.ic.rot-down { transform: rotate(-90deg); }
.btn[disabled] .ic { opacity: .5; }
/* the hidden attribute wins over the display of these blocks */
.add-subj[hidden], .kform .field[hidden], .tt-note[hidden], .suggest button[hidden] { display: none; }

/* phones: lesson rows put their chips under the title, topic tools under the topic, the board's numbers in one row */
.k-page .sec-head { flex-wrap: wrap; row-gap: 2px; }
@media (max-width: 560px) {
  .lrows .row { flex-wrap: wrap; row-gap: 6px; padding-inline: 12px; }
  .lrows .row .grow { flex-basis: calc(100% - 68px); }
  .lrows .row .chips { order: 3; flex-basis: 100%; justify-content: flex-start; padding-inline-start: 68px; }
  .lrows .row .chips:empty { display: none; }
  .lrows > li > .btn.ghost.small { align-self: stretch; }
  .topics > li { flex-wrap: wrap; row-gap: 0; }
  .topics .grow { flex-basis: calc(100% - 3em); }
  .topics .tools { width: 100%; justify-content: flex-end; }
  .topics .edit { flex-wrap: wrap; }
  .pace .nums { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
  .pace .nums .v { font-size: 26px; }
  .pace .nums .l { font-size: 13px; line-height: 1.3; }
  .kcard { padding: 18px 16px 12px; }
}
