/* Apricot.
   The ground and the ink stay the user's: every surface is a brand hue mixed into
   var(--bg), so the same card is a pale tint in light mode and a deep
   one in dark, and body text is always var(--tg-theme-text-color). Swapping palette
   is six hex values on :root -- nothing structural moves.

   Three hues, each with a job: amber lecture, sage practical, periwinkle seminar
   and language. Apricot carries the actions. */
:root {
  /* Never assign --tg-theme-* here: Telegram injects those itself, and whichever
     stylesheet loads last would win. Read them with a fallback instead, so the
     apricot values apply only when Telegram has not supplied a theme. */
  --bg: var(--tg-theme-bg-color, #fffdfa);
  --surface: var(--tg-theme-secondary-bg-color, #f6f0e8);
  --text: var(--tg-theme-text-color, #241f1b);
  --hint: var(--tg-theme-hint-color, #8a7f74);
  --brand: var(--tg-theme-button-color, #ef8642);
  --link: var(--tg-theme-link-color, #c25a1c);
  --danger: var(--tg-theme-destructive-text-color, #d1453f);

  --lec:  #e9a23b;  --lec-ink:  #7d5307;
  --prac: #3fa796;  --prac-ink: #1c5c52;
  --lang: #6c7be0;  --lang-ink: #38409b;
  --topic: #3fa796; --topic-ink: #1c5c52;

  /* Aliases the admin panel's stylesheet reads. */
  --accent: var(--brand);
  --on-accent: #ffffff;
  --muted: var(--hint);
  --radius: 16px;

  /* A tint has to work harder against a dark ground to read as colour at all. */
  --tint: 11%;
  --tint-strong: 26%;
  --gutter: 12px;
}

:root[data-theme='dark'] {
  --tint: 16%;
  --tint-strong: 30%;
  --lec-ink:  #f6c884;
  --prac-ink: #8fd9cc;
  --lang-ink: #b3bcf4;
  --topic-ink: #8fd9cc;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
        'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

.wrap { max-width: 560px; margin: 0 auto; padding-bottom: 32px; }
.pad { padding: 0 16px; }
.muted { color: var(--hint); }
.small { font-size: 13px; }
.center { text-align: center; }
[hidden] { display: none !important; }

/* The strip sits above the view and is never re-created, so its animation runs
   uninterrupted while the day changes underneath it. */
.view { position: relative; }
.in-next  { animation: slide-next 0.22s cubic-bezier(0.22, 0.61, 0.36, 1) both; }
.in-prev  { animation: slide-prev 0.22s cubic-bezier(0.22, 0.61, 0.36, 1) both; }
.in-fade  { animation: view-fade 0.18s ease both; }
@keyframes slide-next {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: none; }
}
@keyframes slide-prev {
  from { opacity: 0; transform: translateX(-16px); }
  to   { opacity: 1; transform: none; }
}
@keyframes view-fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .in-next, .in-prev, .in-fade { animation: none; }
}

/* channel marquee */
.marquee { overflow: hidden; padding: 8px 0 2px; }
.marquee-track { display: flex; gap: 10px; width: max-content;
  animation: marquee 26s linear infinite; }
.marquee a {
  font-size: 12px; font-weight: 600; white-space: nowrap; text-decoration: none;
  padding: 5px 12px; border-radius: 999px;
  background: color-mix(in srgb, var(--brand) 12%, var(--bg));
  color: var(--link);
}
@keyframes marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) {
  .marquee-track { animation: none; flex-wrap: wrap; width: auto; padding-left: 16px; }
}

/* header */
.topbar { display: flex; align-items: center; gap: 11px; padding: 12px 10px 10px 16px; }
.topbar .who { flex: 1; min-width: 0; }
.topbar .who b { display: block; font-size: 16.5px; font-weight: 700; line-height: 1.2;
  letter-spacing: -0.01em; overflow-wrap: break-word; }
.topbar .who span { display: block; font-size: 12.5px; line-height: 1.3; margin-top: 2px;
  color: var(--hint); }
.topbar-actions { display: flex; gap: 2px; flex: none; }

.icon-btn {
  width: 44px; height: 44px; flex: none; border-radius: 14px;
  display: grid; place-items: center; border: 0; background: transparent;
  color: var(--hint); cursor: pointer; text-decoration: none; font-size: 17px; padding: 0;
}
.icon-btn:active { background: color-mix(in srgb, var(--text) 6%, transparent); }

.avatar {
  width: 42px; height: 42px; flex: none; border-radius: 15px; overflow: hidden;
  display: grid; place-items: center; cursor: pointer; border: 0; padding: 0;
  font-size: 15px; font-weight: 700;
  background: color-mix(in srgb, var(--brand) 20%, var(--bg));
  color: var(--link);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.admin-tag { color: var(--brand); }

/* date navigation */
.datebar {
  margin: 4px var(--gutter) 0; padding: 6px; border-radius: 20px; background: var(--surface);
  display: grid; grid-template-columns: 44px 1fr 44px; align-items: center;
}
.datebar .label { min-width: 0; text-align: center; }
.datebar .label b { display: block; font-size: 16px; font-weight: 700; line-height: 1.2;
  letter-spacing: -0.01em; }
.datebar .label span { display: block; font-size: 12px; line-height: 1.3; margin-top: 1px;
  color: var(--hint); }

.weekstrip { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px;
  padding: 10px var(--gutter) 14px; }
.weekstrip button {
  height: 52px; border: 0; border-radius: 16px; cursor: pointer; padding: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  background: transparent; color: var(--text); font: inherit;
}
.weekstrip button span { font-size: 11px; font-weight: 600; color: var(--hint); }
.weekstrip button b { font-size: 15px; font-weight: 700; }
.weekstrip button.on {
  background: var(--brand); color: #fff;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--brand) 40%, transparent);
}
.weekstrip button.on span { color: #fff; opacity: 0.9; }

/* One explanation for the whole screen, so each card carries a short placeholder
   instead of repeating the same apology ten times. */
.banner {
  display: flex; gap: 10px; align-items: flex-start;
  margin: 0 var(--gutter) 12px; padding: 12px 14px; border-radius: 18px;
  background: color-mix(in srgb, var(--brand) 12%, var(--bg));
}
.banner .ico { flex: none; margin-top: 1px; color: var(--link); }
.banner b { display: block; font-size: 13.5px; font-weight: 700; line-height: 1.35; }
.banner span { display: block; font-size: 12.5px; line-height: 1.4; margin-top: 2px;
  color: var(--hint); }

.daynote { padding: 2px 16px 12px; font-size: 13.5px; line-height: 1.4; color: var(--hint); }
.daynote b { font-weight: 700; color: var(--text); }

/* lessons */
.lessons { display: flex; flex-direction: column; gap: 10px; padding: 0 var(--gutter); }

.lesson {
  border-radius: 20px; padding: 13px 14px 14px; display: flex; gap: 12px;
  background: color-mix(in srgb, var(--hue) var(--tint), var(--bg));
}
.lesson.maruza   { --hue: var(--lec);  --ink: var(--lec-ink); }
.lesson.amaliyot { --hue: var(--prac); --ink: var(--prac-ink); }
.lesson.seminar  { --hue: var(--lang); --ink: var(--lang-ink); }

.lesson .when { flex: none; width: 50px; }
.lesson .when b { display: block; font-size: 17px; font-weight: 700; line-height: 1.15;
  letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.lesson .when .to { font-size: 13px; line-height: 1.15; margin-top: 3px; color: var(--hint);
  font-variant-numeric: tabular-nums; }
.lesson .when .para { font-size: 11px; margin-top: 7px; color: var(--hint); }
.lesson .body { flex: 1; min-width: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 6px; }
.chip {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 999px;
  background: color-mix(in srgb, var(--hue) var(--tint-strong), var(--bg));
  color: var(--ink);
}
.chip.plain { background: color-mix(in srgb, var(--text) 7%, transparent); color: var(--hint); }

.lesson .subject { font-size: 16px; font-weight: 700; line-height: 1.3;
  letter-spacing: -0.01em; overflow-wrap: break-word; text-wrap: pretty; }

/* Rooms matter, so they get their own pill rather than a line of grey text. */
.room {
  display: inline-flex; align-items: center; gap: 5px; max-width: 100%;
  margin-top: 7px; padding: 4px 9px 4px 7px; border-radius: 999px;
  background: color-mix(in srgb, var(--text) 6%, transparent);
}
.room svg { flex: none; }
.room span { font-size: 12.5px; font-weight: 600; line-height: 1.3; min-width: 0;
  overflow-wrap: break-word; }
.room.unknown span { color: var(--hint); font-weight: 400; }

.lesson .meta { font-size: 12px; line-height: 1.35; margin-top: 5px; color: var(--hint); }

.topic {
  margin-top: 10px; border-radius: 15px; padding: 9px 12px 11px;
  background: color-mix(in srgb, var(--topic) 17%, var(--bg));
}
.topic .k { font-size: 10px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--topic-ink); }
.topic .v { font-size: 15.5px; font-weight: 700; line-height: 1.35; margin-top: 3px;
  letter-spacing: -0.01em; overflow-wrap: break-word; text-wrap: pretty; }
.topic.none { background: transparent; padding: 0; margin-top: 9px;
  display: flex; align-items: center; gap: 7px; }
.topic.none .dash { flex: none; width: 14px; border-top: 2px dashed var(--hint); opacity: 0.6; }
.topic.none .v { font-size: 12.5px; font-weight: 500; color: var(--hint); margin: 0;
  letter-spacing: 0; }

/* two lessons in one slot: one shell, one header */
.sametime {
  border-radius: 22px; padding: 10px; display: flex; flex-direction: column; gap: 8px;
  background: color-mix(in srgb, var(--text) 4%, transparent);
}
.sametime > .cap { font-size: 11px; font-weight: 600; color: var(--hint); padding: 2px 4px 0; }
.subgroup { font-size: 11px; font-weight: 600; color: var(--hint); margin-bottom: 3px; }

/* a day with nothing in it */
.restcard {
  margin: 4px var(--gutter) 0; border-radius: 22px; padding: 22px 16px 20px;
  background: color-mix(in srgb, var(--prac) 14%, var(--bg));
}
.restcard b { display: block; font-size: 17px; font-weight: 700; line-height: 1.25;
  letter-spacing: -0.01em; margin-top: 12px; }
.restcard span { display: block; font-size: 12.5px; line-height: 1.45; margin-top: 5px;
  color: var(--hint); }
.restcard button {
  width: 100%; margin-top: 14px; height: 46px; border: 0; border-radius: 15px;
  background: var(--brand); color: #fff; font: inherit; font-size: 14px; font-weight: 700;
  cursor: pointer;
}
.restcard.sunday { background: color-mix(in srgb, var(--lec) 16%, var(--bg)); }

/* welcome */
.welcome {
  position: fixed; inset: 0; z-index: 30;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 20px 18px 34px; color: var(--text);
  background:
    radial-gradient(120% 80% at 18% 8%,
      color-mix(in srgb, var(--lec) 34%, var(--bg)) 0%, var(--bg) 58%),
    radial-gradient(100% 70% at 92% 96%,
      color-mix(in srgb, var(--prac) 26%, var(--bg)) 0%, transparent 60%),
    var(--bg);
  animation: fade 0.4s ease both;
}
.welcome .badge { width: 42px; height: 42px; border-radius: 14px; background: var(--brand);
  display: grid; place-items: center; margin-bottom: 16px; }
.welcome .hi { font-size: 13px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--hint); }
.welcome .name { font-size: 30px; font-weight: 800; line-height: 1.08;
  letter-spacing: -0.03em; margin-top: 4px; overflow-wrap: break-word; }
.welcome .sub { font-size: 13px; line-height: 1.45; margin-top: 10px; color: var(--hint); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .welcome { animation: none; } }

/* forms */
h1 { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; margin: 0 0 6px; }
h2 { font-size: 15px; font-weight: 700; margin: 20px 0 8px; }
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--hint);
  margin: 16px 0 7px; }

input, textarea, select {
  width: 100%; padding: 13px 14px; border-radius: 15px;
  border: 1.5px solid color-mix(in srgb, var(--text) 10%, transparent);
  background: var(--bg); color: var(--text); font: inherit;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}
textarea { resize: vertical; }

button.primary {
  width: 100%; min-height: 50px; margin-top: 20px; padding: 14px;
  border: 0; border-radius: 16px; background: var(--brand); color: #fff;
  font: inherit; font-size: 15px; font-weight: 700; cursor: pointer;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--brand) 32%, transparent);
}
button.primary:disabled { opacity: 0.5; box-shadow: none; cursor: default; }

.choice { display: flex; flex-wrap: wrap; gap: 7px; }
.choice button {
  min-width: 50px; min-height: 46px; flex: 1 0 auto; padding: 11px 16px;
  border: 1.5px solid color-mix(in srgb, var(--text) 10%, transparent);
  border-radius: 14px; background: var(--bg); color: var(--text);
  font: inherit; font-size: 15px; font-weight: 700; cursor: pointer;
}
.choice button.on {
  background: var(--brand); border-color: var(--brand); color: #fff;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--brand) 30%, transparent);
}
.choice.lang button { font-weight: 600; font-size: 14px; }

.name-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.name-pair label { margin-top: 0; }

/* drill-down rows */
.row-btn {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  min-height: 60px; padding: 12px 14px; margin-top: 8px;
  border: 1.5px solid color-mix(in srgb, var(--text) 10%, transparent);
  border-radius: 16px; background: var(--bg); color: var(--text);
  font: inherit; cursor: pointer;
}
.row-btn .tick {
  flex: none; width: 26px; height: 26px; border-radius: 9px; display: grid;
  place-items: center; font-size: 13px;
  background: color-mix(in srgb, var(--text) 7%, transparent); color: var(--hint);
}
.row-btn.filled .tick { background: var(--brand); color: #fff; }
.row-btn .col { flex: 1; min-width: 0; }
.row-btn .k { display: block; font-size: 11.5px; font-weight: 600; color: var(--hint); }
.row-btn .v { display: block; font-size: 15px; font-weight: 700; margin-top: 1px;
  overflow-wrap: break-word; }
.row-btn .v.unset { font-weight: 500; color: var(--hint); }
.row-btn .arrow { flex: none; color: var(--hint); }

.picker-head { display: flex; align-items: center; gap: 6px; padding: 10px 10px 10px 6px; }
.picker-head b { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.picker-search { padding: 4px 16px 12px; }
.picker-list { padding: 0 var(--gutter) 20px; display: flex; flex-direction: column; gap: 6px; }
.picker-list button {
  width: 100%; min-height: 54px; padding: 15px 16px; text-align: left;
  border: 0; border-radius: 16px; background: var(--surface); color: var(--text);
  font: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
}
.picker-list button.on {
  background: var(--brand); color: #fff; font-weight: 700;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--brand) 30%, transparent);
}
.picker-empty { padding: 30px 16px; text-align: center; color: var(--hint); }

.notice {
  margin: 12px 0; padding: 11px 13px; border-radius: 14px; font-size: 13px; line-height: 1.4;
  background: color-mix(in srgb, var(--danger) 12%, var(--bg)); color: var(--danger);
}

/* ── channel gate ────────────────────────────────────
   Joined channels stay on the list as a sage tick and lose their button; only what
   is left to do is apricot. The counter turns four rows into one small task. */
.gate { padding: 22px 16px 24px; }
.gate .mark {
  width: 44px; height: 44px; border-radius: 15px; margin-bottom: 14px;
  display: grid; place-items: center; color: var(--link);
  background: color-mix(in srgb, var(--brand) 16%, var(--bg));
}
.gate h1 { font-size: 22px; font-weight: 800; line-height: 1.2; letter-spacing: -0.025em;
  text-wrap: pretty; margin: 0; }
.gate .lede { font-size: 13.5px; line-height: 1.45; margin-top: 7px; color: var(--hint); }

.gate-progress { display: flex; align-items: center; gap: 9px; margin-top: 18px; }
.gate-progress .bar {
  flex: 1; min-width: 0; height: 8px; border-radius: 999px; overflow: hidden;
  background: color-mix(in srgb, var(--text) 8%, transparent);
}
.gate-progress .bar i { display: block; height: 100%; border-radius: 999px;
  background: var(--prac); transition: width 0.3s ease; }
.gate-progress .count { flex: none; font-size: 12px; font-weight: 700; color: var(--hint); }

/* a pair of channels that belong together */
.partners {
  margin-top: 16px; border-radius: 22px; padding: 12px 12px 13px;
  background: color-mix(in srgb, var(--lang) 10%, var(--bg));
}
.partners .cap { display: flex; align-items: center; gap: 7px; padding: 0 3px 10px;
  color: var(--lang); }
.partners .cap span { font-size: 11px; font-weight: 800; letter-spacing: 0.09em;
  text-transform: uppercase; }
.partners .rows { display: flex; flex-direction: column; gap: 7px; }
.partners .foot { font-size: 11.5px; line-height: 1.4; padding: 9px 3px 0; color: var(--hint); }
.partners .chrow { background: var(--bg); border-radius: 17px; }
.partners .chrow .ava { background: color-mix(in srgb, var(--lang) 20%, var(--bg));
  color: var(--lang); }

.chlist { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.chrow {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 19px;
  background: var(--surface);
}
.chrow .ava {
  flex: none; width: 38px; height: 38px; border-radius: 13px; display: grid;
  place-items: center; font-size: 14px; font-weight: 800; overflow: hidden;
  background: color-mix(in srgb, var(--lec) 26%, var(--bg)); color: #7d5307;
}
.chrow .ava img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* A real photo brings its own colour, so the tinted placeholder gets out of its way. */
.chrow .ava.has-photo { background: color-mix(in srgb, var(--text) 6%, transparent); }
.chrow .col { flex: 1; min-width: 0; }
.chrow .col b { display: block; font-size: 14.5px; font-weight: 700; line-height: 1.3;
  overflow-wrap: break-word; }
.chrow .col span { display: block; font-size: 12px; line-height: 1.3; margin-top: 1px;
  color: var(--hint); }
.chrow a.join {
  flex: none; height: 44px; padding: 0 16px; border-radius: 14px; display: flex;
  align-items: center; background: var(--brand); color: #fff;
  font-size: 13.5px; font-weight: 700; text-decoration: none;
}
.chrow .done {
  flex: none; height: 44px; padding: 0 12px; border-radius: 14px;
  display: flex; align-items: center; gap: 5px;
  background: color-mix(in srgb, var(--prac) 16%, var(--bg)); color: var(--prac-ink);
  font-size: 12.5px; font-weight: 700;
}
/* the ones still missing after a check are outlined, so the eye lands on them */
.chrow.flagged { box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--danger) 40%, transparent) inset; }

.gate-error {
  margin-top: 14px; display: flex; gap: 9px; align-items: flex-start;
  padding: 11px 13px 12px; border-radius: 18px;
  background: color-mix(in srgb, var(--danger) 10%, var(--bg));
}
.gate-error .ico { flex: none; margin-top: 1px; color: var(--danger); }
.gate-error b { display: block; font-size: 13.5px; font-weight: 700; line-height: 1.35;
  color: var(--danger); }
.gate-error span { display: block; font-size: 12.5px; line-height: 1.45; margin-top: 2px; }

.gate .check {
  width: 100%; margin-top: 14px; height: 54px; border: 0; border-radius: 17px;
  background: var(--brand); color: #fff; font: inherit; font-size: 15.5px; font-weight: 700;
  cursor: pointer; box-shadow: 0 6px 16px color-mix(in srgb, var(--brand) 35%, transparent);
}
.gate .check:disabled { opacity: 0.55; box-shadow: none; }

/* comments */
.counter { display: flex; gap: 10px; padding: 4px var(--gutter) 12px; }
.counter div {
  flex: 1; border-radius: 18px; padding: 13px 14px;
  background: color-mix(in srgb, var(--prac) var(--tint), var(--bg));
}
.counter div + div { background: color-mix(in srgb, var(--lang) var(--tint), var(--bg)); }
.counter b { display: block; font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.counter span { font-size: 12px; color: var(--hint); }

.comment {
  margin: 0 var(--gutter) 10px; padding: 13px 14px; border-radius: 20px;
  background: var(--surface);
}
.comment .head { display: flex; align-items: center; gap: 9px; }
.comment .head b { font-size: 14px; font-weight: 700; }
.comment .head time { font-size: 11px; color: var(--hint); margin-left: auto; }
.comment .body { font-size: 14.5px; line-height: 1.45; margin-top: 8px;
  overflow-wrap: break-word; white-space: pre-wrap; }
.comment .acts { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.comment .acts button {
  min-height: 38px; padding: 7px 13px; border-radius: 999px; cursor: pointer;
  border: 0; background: color-mix(in srgb, var(--text) 6%, transparent);
  color: var(--text); font: inherit; font-size: 13px; font-weight: 600;
}
.comment .acts button.on {
  background: color-mix(in srgb, var(--brand) 22%, var(--bg)); color: var(--link);
}
.comment .acts .spacer { flex: 1; }
.comment .acts button.text-btn { background: transparent; color: var(--hint); padding: 7px 8px; }

.empty-day { padding: 34px 16px; text-align: center; color: var(--hint); }
