/* Розклад ФБ-з61мп — стилі */
:root {
  /* Лавандово-рожева гама */
  --bg: #f7f3fb;
  --surface: #fffdfe;
  --surface-2: #f9f5fc;
  --line: #e9dff3;
  --line-soft: #f1eaf7;
  --text: #3a2e4a;
  --text-2: #7a6b8f;
  --text-3: #a698b8;
  --accent: #a78bfa;
  --accent-soft: #efe7fd;
  --today: #f472b6;
  --hour: 58px;               /* висота однієї години в сітці */
  --radius: 12px;
  --shadow: 0 1px 2px rgba(120, 90, 160, .06), 0 6px 20px -8px rgba(120, 90, 160, .16);
  --btn-hover-border: #d8c9ea;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
/* Тема задається атрибутом data-theme на <html> (див. js/theme.js) */
html[data-theme="dark"] {
  --bg: #29233a;
  --surface: #322b45;
  --surface-2: #3a3250;
  --line: #4a4162;
  --line-soft: #413957;
  --text: #f6f1fb;
  --text-2: #c9bedb;
  --text-3: #9d91b3;
  --accent: #c4b5fd;
  --accent-soft: #4a3f66;
  --today: #f9a8d4;
  --shadow: 0 1px 2px rgba(0,0,0,.25), 0 8px 24px -10px rgba(0,0,0,.4);
  --btn-hover-border: #5e5379;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
html { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }
body {
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }

.page { width: 100%; padding: 20px 24px 40px; }

/* ---------- Шапка ---------- */
.top {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin-bottom: 18px;
}
.top h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -.01em; }
.top .sub { margin: 4px 0 0; color: var(--text-2); font-size: 14px; }
.top .sub b { color: var(--text); font-weight: 600; }

.nav { display: flex; align-items: center; gap: 10px; }
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  height: 36px; padding: 0 14px; border-radius: 10px; font: inherit; font-size: 14px; font-weight: 500;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--btn-hover-border); }
.btn.icon { width: 36px; padding: 0; justify-content: center; font-size: 18px; }
.btn.theme svg { width: 17px; height: 17px; }
.btn.theme .sun { display: none; }
html[data-theme="dark"] .btn.theme .sun { display: block; }
html[data-theme="dark"] .btn.theme .moon { display: none; }
.week-title { font-size: 18px; font-weight: 600; min-width: 220px; text-align: center; }
.week-title small { display: block; font-size: 12px; font-weight: 500; color: var(--text-3); }

/* ---------- Попередження ---------- */
.notice {
  display: flex; gap: 10px; align-items: flex-start;
  background: #fdeef5; border: 1px solid #f9cfe3; color: #8a3a63;
  border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px; font-size: 14px;
}
html[data-theme="dark"] .notice { background: #4a2f48; border-color: #6d4a6a; color: #fbc9e6; }
.notice svg { flex: none; margin-top: 2px; }

/* ---------- Сітка тижня ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.grid-wrap { overflow-x: auto; }
.grid {
  display: grid;
  grid-template-columns: 56px repeat(var(--days), minmax(150px, 1fr));
  grid-template-rows: 56px;                          /* шапка днів */
  grid-auto-rows: calc(var(--hour) / 12);          /* 1 рядок = 5 хвилин */
  position: relative;
  min-width: 960px;
}
.grid .corner, .grid .day-head {
  grid-row: 1; position: sticky; top: 0; z-index: 5;
  background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; flex-direction: column; justify-content: center; align-items: center;
}
.grid .corner { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; line-height: 1.2; text-align: center; }
.day-head .dow { font-size: 12px; color: var(--text-2); text-transform: capitalize; }
.day-head .dom { font-size: 18px; font-weight: 600; margin-top: 1px; }
.day-head.today .dom {
  background: var(--today); color: #fff; border-radius: 999px; width: 32px; height: 32px;
  display: grid; place-items: center; font-size: 15px;
}
.day-head.today .dow { color: var(--today); font-weight: 600; }

.hour-label {
  grid-column: 1; font-size: 11px; color: var(--text-3); text-align: right; padding-right: 8px;
  transform: translateY(-7px); position: relative; z-index: 2;
}
.cell { border-top: 1px solid var(--line-soft); border-left: 1px solid var(--line-soft); }
.cell.half { border-top: 1px dashed var(--line-soft); }
.cell.today-col { background: color-mix(in srgb, var(--today) 4%, transparent); }

/* ---------- Картка заняття ---------- */
.lesson {
  position: relative; z-index: 3; margin: 2px 4px 2px 3px;
  border-radius: 10px; padding: 8px 10px 8px 12px;
  background: var(--c-bg); color: var(--c-fg);
  border: 1px solid color-mix(in srgb, var(--c) 35%, transparent);
  display: flex; flex-direction: column; gap: 4px; overflow: hidden; min-height: 0;
  transition: transform .12s, box-shadow .12s;
}
.lesson::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c);
}
.lesson:hover { transform: translateY(-1px); box-shadow: 0 8px 22px -10px color-mix(in srgb, var(--c) 60%, transparent); z-index: 4; }
.lesson .time { font-size: 11.5px; font-variant-numeric: tabular-nums; color: var(--c-fg); opacity: .8; display: flex; justify-content: space-between; gap: 6px; }
.lesson .time .pairs { opacity: .8; }
.lesson .title { font-size: 13.5px; font-weight: 600; line-height: 1.25; }
.lesson .meta { font-size: 12px; opacity: .85; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.badge {
  display: inline-block; font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  padding: 1px 6px; border-radius: 6px; background: color-mix(in srgb, var(--c) 18%, transparent);
}
.lesson .links { margin-top: auto; display: flex; gap: 6px; flex-wrap: wrap; padding-top: 4px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; text-decoration: none;
  padding: 4px 9px; border-radius: 8px; background: var(--surface); color: var(--text);
  border: 1px solid color-mix(in srgb, var(--c) 30%, transparent); transition: background .12s, border-color .12s;
  white-space: nowrap;
}
.chip:hover { border-color: var(--c); background: color-mix(in srgb, var(--c) 10%, var(--surface)); }
.chip.empty { color: var(--text-3); border-style: dashed; cursor: default; }
.chip.empty:hover { background: var(--surface); border-color: color-mix(in srgb, var(--c) 30%, transparent); }
.chip svg { width: 13px; height: 13px; flex: none; }
.lesson .note { font-size: 12px; font-weight: 600; color: #c2185b; }
html[data-theme="dark"] .lesson .note { color: #ff8a80; }
.lesson.compact .links, .lesson.compact .module { display: none; }
.hour-label.first { transform: none; padding-top: 3px; }
.lesson.compact .title { font-size: 13px; }
.lesson.compact .meta { font-size: 11.5px; }

.now-line { position: absolute; left: 56px; right: 0; height: 2px; background: var(--today); z-index: 4; pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--today); }

.empty-week { grid-column: 1 / -1; padding: 48px 20px; text-align: center; color: var(--text-3); font-size: 15px; }

/* ---------- Клікабельність карток ---------- */
.lesson, .subject { cursor: pointer; }
.lesson:focus-visible, .subject:focus-visible { outline: 2px solid var(--c); outline-offset: 2px; }
.subject:hover { border-color: color-mix(in srgb, var(--c) 45%, var(--line)); }

/* ---------- Модалка деталей ---------- */
.dialog {
  border: none; padding: 0; background: var(--surface); color: var(--text);
  border-radius: 16px; width: min(520px, calc(100vw - 32px));
  box-shadow: 0 24px 80px -20px rgba(0,0,0,.45);
}
.dialog::backdrop { background: rgba(10, 12, 20, .55); backdrop-filter: blur(3px); }
.dialog-close {
  position: absolute; top: 10px; right: 10px; width: 32px; height: 32px; border-radius: 50%;
  border: none; background: rgba(0,0,0,.12); color: inherit; font-size: 20px; line-height: 1; cursor: pointer; z-index: 1;
}
.dialog-close:hover { background: rgba(0,0,0,.22); }
.d-head { padding: 22px 52px 18px 22px; background: var(--c-bg); color: var(--c-fg); border-bottom: 4px solid var(--c); }
.d-head h3 { margin: 8px 0 0; font-size: 19px; line-height: 1.3; }
.d-head .d-module { margin: 4px 0 0; font-size: 14px; opacity: .85; }
.d-info { display: grid; grid-template-columns: 96px 1fr; gap: 8px 12px; margin: 0; padding: 18px 22px 6px; font-size: 14px; }
.d-info dt { color: var(--text-3); }
.d-info dd { margin: 0; }
.d-info .muted { color: var(--text-3); }
.d-info .note { color: #b3261e; font-weight: 600; }
html[data-theme="dark"] .d-info .note { color: #ff8a80; }
.d-info .desc { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-2); line-height: 1.45; }
.d-links { display: flex; flex-direction: column; gap: 8px; padding: 14px 22px 22px; }
.link-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 12px; text-decoration: none;
  border: 1px solid var(--line); background: var(--surface-2); transition: border-color .12s, background .12s;
}
.link-row:hover { border-color: var(--c); background: color-mix(in srgb, var(--c) 8%, var(--surface)); }
.link-row.empty { border-style: dashed; color: var(--text-3); cursor: default; }
.link-row .ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: color-mix(in srgb, var(--c) 16%, transparent); color: var(--c); }
.link-row.empty .ico { background: var(--line-soft); color: var(--text-3); }
.link-row .ico svg { width: 18px; height: 18px; }
.link-row .txt { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.link-row .txt b { font-size: 14px; font-weight: 600; }
.link-row .txt small { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-row .arrow { color: var(--text-3); font-size: 16px; }

/* ---------- Додати в календар (js/calendar.js) ---------- */
.d-cal {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 12px 22px 20px; margin-top: -10px; border-top: 1px solid var(--line-soft);
}
.d-links + .d-cal { padding-top: 14px; }
.d-cal-label { font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.d-cal-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.d-cal-btns .btn { text-decoration: none; }
.d-cal-btns .btn svg, .d-cal-copy .btn svg { width: 15px; height: 15px; flex: none; }
.d-cal-copy { display: flex; gap: 6px; padding: 0 22px; }
.d-cal-copy input {
  flex: 1; min-width: 0; font: inherit; font-size: 13px; color: var(--text-2); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 9px; padding: 0 10px; height: 34px; font-variant-numeric: tabular-nums;
}
.d-cal-copy .btn { height: 34px; }
.d-cal-hint { margin: 10px 22px 20px; }
#cal-form .d-links { padding-top: 10px; padding-bottom: 12px; }
#cal-form .ed-fields { padding-bottom: 0; }

/* ---------- Меню кнопки PDF ---------- */
.btn .chev { width: 14px; height: 14px; margin: 0 -4px 0 -2px; color: var(--text-3); }
.cs-menu.menu { width: 300px; max-width: calc(100vw - 16px); }
.menu .cs-opt { width: 100%; border: 0; background: transparent; font: inherit; text-align: left; color: var(--text); }
.menu .cs-opt:hover, .menu .cs-opt:focus-visible { background: var(--accent-soft); outline: none; }
.menu .cs-opt svg { width: 18px; height: 18px; flex: none; color: var(--text-2); }

/* ---------- Імпорт із PDF (js/import.js) ---------- */
.dialog.wide { width: min(760px, calc(100vw - 32px)); }
.drop {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; cursor: pointer;
  padding: 28px 20px; border: 2px dashed var(--line); border-radius: 14px; background: var(--surface-2); color: var(--text-2);
  transition: border-color .15s, background .15s;
}
.drop:hover, .drop:focus-visible, .drop.over { border-color: var(--accent); background: var(--accent-soft); outline: none; }
.drop svg { width: 36px; height: 36px; color: var(--accent); margin-bottom: 4px; }
.drop b { color: var(--text); font-size: 15px; }
.drop small { font-size: 12.5px; color: var(--text-3); }
.imp-error { margin: 0; font-size: 13.5px; color: #c2185b; font-weight: 500; }
html[data-theme="dark"] .imp-error { color: #ff8a80; }
.imp-busy { display: flex; align-items: center; gap: 12px; padding: 36px 22px; color: var(--text-2); font-size: 14px; }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.imp-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); gap: 6px; margin: 0; }
.imp-summary > div { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 7px 9px; min-width: 0; }
.imp-summary dt { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); font-weight: 600; }
.imp-summary dd { margin: 2px 0 0; font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.imp-summary dd .muted { color: var(--text-3); font-weight: 500; }
.imp-summary dd.warn { color: #c2185b; }
html[data-theme="dark"] .imp-summary dd.warn { color: #ff8a80; }
.imp-warnings {
  margin: 0; padding: 10px 14px 10px 30px; font-size: 13px; border-radius: 10px;
  background: #fdeef5; border: 1px solid #f9cfe3; color: #8a3a63;
}
html[data-theme="dark"] .imp-warnings { background: #4a2f48; border-color: #6d4a6a; color: #fbc9e6; }
.imp-warnings li + li { margin-top: 3px; }
.imp-subjects { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.imp-subjects li { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.imp-subjects small, .imp-row small { color: var(--text-3); font-size: 12px; }
.imp-subjects small { margin-left: auto; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; box-shadow: 0 0 0 1px rgba(0,0,0,.08); }

.imp-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.imp-mode {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center; cursor: pointer;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); font-size: 14px;
}
.imp-mode:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.imp-mode:has(input:disabled) { opacity: .55; cursor: default; }
.imp-mode input { grid-row: 1 / span 2; accent-color: var(--accent); margin: 0; width: 16px; height: 16px; }
.imp-mode b { font-weight: 600; }
.imp-mode small { grid-column: 2; font-size: 12px; color: var(--text-3); line-height: 1.35; }

.imp-list { max-height: min(38vh, 380px); overflow: auto; border: 1px solid var(--line); border-radius: 10px; scrollbar-width: thin; }
.imp-day h4 { margin: 0; padding: 7px 12px; font-size: 12px; font-weight: 600; color: var(--text-2); background: var(--surface-2); position: sticky; top: 0; z-index: 1; border-bottom: 1px solid var(--line-soft); }
.imp-day h4::first-letter { text-transform: uppercase; }
.imp-day + .imp-day h4 { border-top: 1px solid var(--line); }
.imp-row {
  display: grid; grid-template-columns: 38px 10px minmax(0, 1fr) auto minmax(0, 120px) 64px; gap: 10px; align-items: center;
  padding: 7px 12px; font-size: 13px; border-top: 1px solid var(--line-soft);
}
.imp-row .pairs { font-variant-numeric: tabular-nums; color: var(--text-2); }
.imp-row .what { display: flex; flex-direction: column; min-width: 0; }
.imp-row .what b, .imp-row .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.imp-row .what b { font-weight: 600; }
.imp-row .type { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); }
.imp-row .who { color: var(--text-2); font-size: 12.5px; }
.imp-row .st { font-size: 11px; font-weight: 600; text-align: right; color: var(--accent); }
.imp-row.st-exists .st { color: var(--text-3); }
.imp-row.st-changed .st { color: #b26a00; }
html[data-theme="dark"] .imp-row.st-changed .st { color: #ffb74d; }
.imp-row.st-conflict .st { color: #c2185b; }
html[data-theme="dark"] .imp-row.st-conflict .st { color: #ff8a80; }
.imp-list.merge .imp-row.st-exists, .imp-list.merge .imp-row.st-changed { opacity: .5; }
.imp-list.merge .imp-row.st-exists .what b, .imp-list.merge .imp-row.st-changed .what b { text-decoration: line-through; text-decoration-color: var(--text-3); }
@media (max-width: 640px) {
  .imp-modes { grid-template-columns: 1fr; }
  .imp-row { grid-template-columns: 34px 10px minmax(0, 1fr) 56px; }
  .imp-row .type, .imp-row .who { display: none; }
}

/* ---------- Кнопки ---------- */
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; transition: none; }
.btn.primary:hover { filter: brightness(1.05); background: var(--accent); }
.btn.danger { color: #c2185b; border-color: color-mix(in srgb, #c2185b 40%, var(--line)); }
.btn.danger:hover { background: color-mix(in srgb, #c2185b 8%, var(--surface)); }
.btn.small { height: 30px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn.ghost { border-color: transparent; color: var(--text-2); }
.btn:disabled { opacity: .55; cursor: default; }

/* ---------- Режим редагування ---------- */
.edit-tools {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--accent-soft); border: 1px dashed var(--accent); border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 16px;
}
.edit-hint { font-size: 13px; color: var(--text-2); }
.edit-buttons { display: flex; gap: 6px; flex-wrap: wrap; }
body.editing .cell[data-date] { cursor: cell; }
body.editing .cell[data-date]:hover { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
body.editing .lesson { cursor: pointer; }
/* олівець у куті картки: SVG-маска, зафарбована кольором предмета */
body.editing .lesson::after, body.editing .subject::after {
  content: ""; position: absolute; top: 9px; right: 10px; width: 14px; height: 14px; z-index: 1;
  background: var(--c); opacity: .85;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 20h9'/%3E%3Cpath d='M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 20h9'/%3E%3Cpath d='M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.subject .name { padding-right: 24px; }
body.editing .lesson .time { padding-right: 22px; }

/* ---------- Форми ---------- */
.ed-form .d-head { padding: 18px 52px 16px 22px; }
.ed-form .d-head h3 { margin: 0; font-size: 17px; }
.ed-fields { padding: 16px 22px 4px; display: flex; flex-direction: column; gap: 12px; }
.f, .f-group { display: flex; flex-direction: column; gap: 5px; }
.f-label { font-size: 12px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.f-hint { font-size: 12px; color: var(--text-3); }
.ed-fields input:not([type=color]), .ed-fields select, .ed-fields textarea, .ed-fields .static {
  width: 100%; font: inherit; font-size: 14px; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; min-height: 38px;
}
.ed-fields textarea { resize: vertical; }
.ed-fields input:focus, .ed-fields select:focus, .ed-fields textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.ed-fields .row { display: flex; gap: 6px; align-items: stretch; }
.ed-fields .row select, .ed-fields .row .cs { flex: 1; min-width: 0; }
.ed-fields .row .btn.small {
  height: 38px; width: 38px; min-width: 38px; padding: 0; border-radius: 9px; display: grid; place-items: center;
  background: var(--surface-2); border-color: var(--line); color: var(--text-2); align-self: stretch;
}
.ed-fields .row .btn.small svg { width: 18px; height: 18px; display: block; }
.ed-fields .row .btn.small:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row-3 { display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 10px; }
.row-2 > *, .row-3 > *, .ed-fields .row > *, .cs, .f { min-width: 0; }   /* елементи сітки мають стискатись, а не вилазити */
.f-group input + input { margin-top: 0; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.swatch {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; background: var(--sw); cursor: pointer; padding: 0;
  box-shadow: 0 0 0 1px var(--line); transition: transform .1s;
}
.swatch:hover { transform: scale(1.1); }
.swatch.on { border-color: var(--surface); box-shadow: 0 0 0 2px var(--text-2); }
.swatch.custom { background: conic-gradient(#f07da0, #f4b183, #8fd3c7, #86a6f2, #b08cf0, #f07da0); position: relative; overflow: hidden; }
.swatch.custom input { position: absolute; inset: -8px; width: 200%; height: 200%; opacity: 0; cursor: pointer; }
.ed-actions { display: flex; gap: 8px; align-items: center; padding: 14px 22px 20px; }
.ed-actions .spacer { flex: 1; }
@media (max-width: 520px) { .row-2, .row-3 { grid-template-columns: 1fr; } }

/* ---------- Кастомні select / date (js/ui.js) ---------- */
.cs { position: relative; width: 100%; }
.cs-native { position: absolute !important; opacity: 0; pointer-events: none; width: 1px; height: 1px; min-height: 0 !important; padding: 0 !important; border: 0 !important; }
.cs-btn {
  width: 100%; min-height: 38px; display: flex; align-items: center; gap: 8px; text-align: left;
  font: inherit; font-size: 14px; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; cursor: pointer;
  transition: border-color .12s, background .12s;
}
.cs-btn:hover { border-color: var(--btn-hover-border); }
.cs-btn:focus-visible, .cs-btn[aria-expanded="true"] { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.cs-btn:disabled { opacity: .55; cursor: default; }
.cs-label { flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-label.placeholder { color: var(--text-3); }
.cs-hint { color: var(--text-3); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1 1 0; min-width: 0; text-align: right; }
.cs-chev { width: 16px; height: 16px; flex: none; margin-left: auto; color: var(--text-3); transition: transform .15s; }
.cs-btn[aria-expanded="true"] .cs-chev { transform: rotate(180deg); }
.cs-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; box-shadow: 0 0 0 1px rgba(0,0,0,.08); }
.cs-menu {
  position: fixed; z-index: 1000; max-height: 300px; max-width: calc(100vw - 16px); overflow: auto; padding: 5px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 16px 48px -12px rgba(20, 10, 40, .35), 0 2px 6px rgba(0,0,0,.08); outline: none;
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}
.cs-opt {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 8px; cursor: pointer;
  font-size: 14px; color: var(--text); line-height: 1.3;
}
.cs-opt.active { background: var(--accent-soft); }
.cs-opt .cs-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.cs-opt .cs-text small { color: var(--text-3); font-size: 12px; }
.cs-opt .cs-check { width: 16px; height: 16px; color: var(--accent); visibility: hidden; flex: none; }
.cs-opt .cs-check svg { width: 16px; height: 16px; display: block; }
.cs-opt.on { font-weight: 600; }
.cs-opt.on .cs-check { visibility: visible; }

/* календар */
.dp { padding: 10px; width: 272px; max-height: none; overflow: visible; }
.dp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.dp-title { font-weight: 600; font-size: 14px; }
.dp-nav {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--text-2);
  font: inherit; font-size: 18px; line-height: 1; cursor: pointer;
}
.dp-nav:hover { background: var(--accent-soft); color: var(--text); }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-dow { font-size: 11px; color: var(--text-3); text-align: center; padding: 4px 0 6px; text-transform: lowercase; }
.dp-day {
  height: 32px; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--text);
  font: inherit; font-size: 13px; cursor: pointer; font-variant-numeric: tabular-nums;
}
.dp-day:hover { background: var(--accent-soft); }
.dp-day.out { color: var(--text-3); opacity: .55; }
.dp-day.wknd:not(.on) { color: var(--text-2); }
.dp-day.today { border-color: var(--today); }
.dp-day.on { background: var(--accent); color: #fff; font-weight: 600; }
.dp-foot { display: flex; justify-content: flex-end; margin-top: 6px; }
.dp-today { border: none; background: transparent; color: var(--accent); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.dp-today:hover { background: var(--accent-soft); }

/* ---------- Тост ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 500;
  box-shadow: 0 10px 30px -10px rgba(0,0,0,.4); transition: opacity .2s, transform .2s; z-index: 50; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: #c2185b; color: #fff; }

/* ---------- Предмети ---------- */
h2 { font-size: 17px; font-weight: 600; margin: 32px 0 12px; }
.subjects { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.subject {
  padding: 14px 16px 14px 18px; position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 6px;
}
.subject::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--c); }
.subject .name { font-weight: 600; font-size: 14.5px; line-height: 1.3; }
.subject .teacher { color: var(--text-2); font-size: 13px; }
.subject .desc { color: var(--text-3); font-size: 12.5px; line-height: 1.4; white-space: pre-line; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.subject .links { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.subject .chip { background: var(--surface-2); }

.foot { margin-top: 28px; color: var(--text-3); font-size: 12.5px; display: flex; gap: 14px; flex-wrap: wrap; }
.foot .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; vertical-align: middle; }

/* ---------- Мобільний вигляд (список) ---------- */
.agenda { display: none; }
@media (max-width: 760px) {
  .page { padding: 16px 12px 40px; }
  .grid-wrap { display: none; }
  .agenda { display: flex; flex-direction: column; gap: 14px; }
  .agenda .day { padding: 12px 12px 6px; }
  .agenda .day h3 { margin: 0 0 8px; font-size: 14px; color: var(--text-2); font-weight: 600; text-transform: capitalize; display: flex; justify-content: space-between; }
  .agenda .day h3.today { color: var(--today); }
  .agenda .lesson { margin: 0 0 8px; }
  .top h1 { font-size: 22px; }
  .top { align-items: stretch; }
  .nav { flex-wrap: wrap; justify-content: center; width: 100%; }
  .week-title { min-width: 0; font-size: 16px; flex: 1 1 auto; }
  .nav .btn.icon { flex: none; }
}

@media print {
  body { background: #fff; }
  .nav, .foot, .notice svg { display: none; }
  .card { box-shadow: none; }
  .lesson:hover { transform: none; }
}
