:root {
  --night-bg: #090d14;
  --night-panel: #111925;
  --night-panel-raised: #172233;
  --night-panel-soft: #0d1420;
  --night-border: #27364a;
  --night-text: #e8eff8;
  --night-muted: #a2b1c4;
  --night-blue: #7db7ff;
  --night-cyan: #69e0ed;
}

.site-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0 0 14px;
}

.site-toolbar .top-nav { display: flex; align-items: center; gap: 10px; margin: 0; }
.top-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #fff;
  color: #1a3a6c;
  font: inherit;
  font-size: .9rem;
  font-weight: 700;
  text-decoration: none;
  transition: border-color .2s, background .2s, color .2s, transform .2s;
}
.top-nav a:hover { transform: translateY(-1px); border-color: #7ba8e0; }
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #fff;
  color: #1a3a6c;
  font: inherit;
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color .2s, background .2s, color .2s, transform .2s;
}
.theme-toggle:hover { transform: translateY(-1px); border-color: #7ba8e0; }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-icon-sun { display: none; }
:root[data-theme="dark"] .theme-icon-moon { display: none; }
:root[data-theme="dark"] .theme-icon-sun { display: block; }
:focus-visible { outline: 3px solid #69e0ed !important; outline-offset: 2px; }

:root[data-theme="dark"] { color-scheme: dark; }
:root[data-theme="dark"] body {
  background: radial-gradient(ellipse at 50% -20%, #17263a 0, var(--night-bg) 56%);
  color: var(--night-text);
}
:root[data-theme="dark"] .page-title { color: #f1f6ff; text-shadow: 0 0 26px rgba(105, 224, 237, .15); }
:root[data-theme="dark"] .top-nav a {
  border-color: #34465e;
  background: rgba(17, 25, 37, .9);
  color: #d9e8fa;
  box-shadow: 0 5px 20px rgba(0, 0, 0, .2);
}
:root[data-theme="dark"] .top-nav a:hover { border-color: var(--night-cyan); background: #172438; }
:root[data-theme="dark"] .theme-toggle {
  border-color: #34465e; background: rgba(17, 25, 37, .9); color: #d9e8fa;
  box-shadow: 0 5px 20px rgba(0, 0, 0, .2);
}
:root[data-theme="dark"] .theme-toggle:hover { border-color: var(--night-cyan); background: #172438; }
:root[data-theme="dark"] .loading { color: var(--night-muted); }
:root[data-theme="dark"] .error { color: #ffb4b4; background: #351c26; border: 1px solid #713344; }

:root[data-theme="dark"] .faculty-tabs,
:root[data-theme="dark"] .teacher-panel,
:root[data-theme="dark"] .teacher-results,
:root[data-theme="dark"] .teacher-results-toolbar,
:root[data-theme="dark"] .calendar-empty,
:root[data-theme="dark"] .semester-matrix-wrap {
  background: var(--night-panel); color: var(--night-text);
  border: 1px solid var(--night-border);
  box-shadow: 0 14px 36px rgba(0, 0, 0, .23);
}
:root[data-theme="dark"] .faculty-tabs-header,
:root[data-theme="dark"] .study-form-tabs-header,
:root[data-theme="dark"] .education-level-tabs-header,
:root[data-theme="dark"] .teacher-view-switch { background: #0c1420; border-color: var(--night-border); }
:root[data-theme="dark"] .faculty-tab-button,
:root[data-theme="dark"] .study-form-tab-button,
:root[data-theme="dark"] .education-level-tab-button { color: #aebbd0; }
:root[data-theme="dark"] .faculty-tab-button:hover,
:root[data-theme="dark"] .study-form-tab-button:hover,
:root[data-theme="dark"] .education-level-tab-button:hover { background: #1a293d; color: #fff; }
:root[data-theme="dark"] .faculty-tab-button.active { background: var(--night-panel); color: #a9d1ff; }
:root[data-theme="dark"] .faculty-tab-button.active::after { background: linear-gradient(90deg, #4b8fff, var(--night-cyan)); }
:root[data-theme="dark"] .study-form-tab-button.active,
:root[data-theme="dark"] .education-level-tab-button.active { background: #244f83; color: #fff; }
:root[data-theme="dark"] .faculty-full-name,
:root[data-theme="dark"] .course-title { color: #b7d8ff; border-color: var(--night-border); }
:root[data-theme="dark"] .course-column { background: var(--night-panel-soft); border: 1px solid #202e41; }
:root[data-theme="dark"] .group-item { background: #172235; color: #e4edf8; border-left-color: #4d9dff; }
:root[data-theme="dark"] .group-item:hover { background: #203550; }

:root[data-theme="dark"] .modal { background: rgba(2, 6, 12, .78); backdrop-filter: blur(6px); }
:root[data-theme="dark"] .modal-content { background: var(--night-panel); color: var(--night-text); border: 1px solid #34465e; box-shadow: 0 24px 80px rgba(0,0,0,.55); }
:root[data-theme="dark"] .modal-header { background: linear-gradient(110deg, #173253, #14243a); color: #eef6ff; border-color: #2a405b; }
:root[data-theme="dark"] .modal-title { color: #eef6ff; }
:root[data-theme="dark"] .close-btn { color: #cfdeef; }
:root[data-theme="dark"] .week-selector,
:root[data-theme="dark"] .week-selector label { color: var(--night-muted); }
:root[data-theme="dark"] .week-selector {
  background: #111b29;
  border: 1px solid #2d4056;
  border-left: 4px solid #4d91d8;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .22);
}
:root[data-theme="dark"] .week-selector label { color: #c1d4e8; }
:root[data-theme="dark"] select,
:root[data-theme="dark"] input,
:root[data-theme="dark"] .week-selector select,
:root[data-theme="dark"] .teacher-controls input,
:root[data-theme="dark"] .teacher-controls select {
  color: var(--night-text); background: #0c1420; border-color: #35465d;
}
:root[data-theme="dark"] input::placeholder { color: #8191a6; }
:root[data-theme="dark"] option { background: #111925; color: var(--night-text); }

:root[data-theme="dark"] .schedule-day,
:root[data-theme="dark"] .calendar-day { background: var(--night-panel); border-color: var(--night-border); }
:root[data-theme="dark"] .day-title,
:root[data-theme="dark"] .calendar-day-head { background: #17263a; color: #b8d8ff; border-color: var(--night-border); }
:root[data-theme="dark"] .day-note { color: #b5c3d5; }
:root[data-theme="dark"] .day-title .day-note {
  background: #213248;
  border: 1px solid #354b64;
  color: #c6dcf4;
}
:root[data-theme="dark"] .week-nav button {
  border-color: #3d6289;
  background: #1b3858;
  color: #e5f2ff;
}
:root[data-theme="dark"] .week-nav button:hover:not(:disabled) { background: #254b72; border-color: #5d96d1; }
:root[data-theme="dark"] .week-nav button:disabled { background: #293746; border-color: #384b5e; color: #8b9db0; }
:root[data-theme="dark"] .schedule-table { color: var(--night-text); }
:root[data-theme="dark"] .schedule-table th { background: #101a28; color: #bddaff; border-color: #34445a; }
:root[data-theme="dark"] .schedule-table td { background: #121c2a; border-color: #2a394d; }
:root[data-theme="dark"] .schedule-table tr:nth-child(even) td { background: #152132; }
:root[data-theme="dark"] .schedule-table tr:hover td { background: #1c3047; }
:root[data-theme="dark"] .schedule-table .time-column,
:root[data-theme="dark"] .schedule-table .room-column { color: #b8c7da; }
:root[data-theme="dark"] .lesson-note-row td,
:root[data-theme="dark"] .lesson-note { background: #382e1c !important; color: #f6dda4; border-color: #66532c; }
:root[data-theme="dark"] .no-lessons-row td { background: #121c2a !important; color: #8e9db1; }
:root[data-theme="dark"] .lesson-type-lecture { background: #263d5b; color: #b7d8ff; }
:root[data-theme="dark"] .lesson-type-seminar { background: #174438; color: #a5f0ce; }
:root[data-theme="dark"] .lesson-type-practice { background: #4a3420; color: #ffcf91; }
:root[data-theme="dark"] .lesson-type-language { background: #442b52; color: #e2b8ff; }
:root[data-theme="dark"] .lesson-type-lab { background: #4a2935; color: #ffb5c4; }
:root[data-theme="dark"] .lesson-subgroup { background: #392747; color: #e2b8ff; }
:root[data-theme="dark"] .lesson-elective { background: #49391d; color: #ffe09b; }
:root[data-theme="dark"] .no-lessons { color: #9baabd; }

:root[data-theme="dark"] .teacher-controls label,
:root[data-theme="dark"] .teacher-summary,
:root[data-theme="dark"] .calendar-meta,
:root[data-theme="dark"] .calendar-free,
:root[data-theme="dark"] .calendar-empty,
:root[data-theme="dark"] .teacher-note { color: var(--night-muted); }
:root[data-theme="dark"] .teacher-semester { background: var(--night-panel); border-color: var(--night-border); }
:root[data-theme="dark"] .teacher-badge { background: #1e3450; color: #c0ddff; }
:root[data-theme="dark"] .teacher-controls button { background: linear-gradient(135deg, #2877c8, #256cae); }
:root[data-theme="dark"] .teacher-view-switch button { color: #a9b9ce; }
:root[data-theme="dark"] .teacher-view-switch button.is-active { background: #1b2b40; color: #c4e1ff; box-shadow: 0 1px 4px #050a11; }
:root[data-theme="dark"] .teacher-week-navigation button { border-color: #46658a; background: #111d2b; color: #bddaff; }
:root[data-theme="dark"] .teacher-week-navigation button:hover:not(:disabled) { background: #1b3048; }
:root[data-theme="dark"] .teacher-active-week span { color: #8ea1b8; }
:root[data-theme="dark"] .teacher-active-week strong,
:root[data-theme="dark"] .calendar-title,
:root[data-theme="dark"] .calendar-lesson time { color: #b8d8ff; }
:root[data-theme="dark"] .calendar-lesson { background: #121d2b; border-color: #438bdb; color: var(--night-text); }
:root[data-theme="dark"] .teacher-table th { background: #111b29; color: #bddaff; border-color: #34445a; }
:root[data-theme="dark"] .teacher-table td { border-color: #2a394d; }
:root[data-theme="dark"] .teacher-table tr:nth-child(even) td { background: #121c2a; }
:root[data-theme="dark"] .teacher-table tr:hover td { background: #1b2c40; }
:root[data-theme="dark"] .semester-matrix { color: var(--night-text); }
:root[data-theme="dark"] .semester-matrix-heading strong { color: #b8d8ff; }
:root[data-theme="dark"] .semester-matrix-heading span,
:root[data-theme="dark"] .semester-matrix-heading p,
:root[data-theme="dark"] .semester-legend-item { color: var(--night-muted); }
:root[data-theme="dark"] .semester-matrix-scroll { border-color: var(--night-border); }
:root[data-theme="dark"] .semester-matrix th,
:root[data-theme="dark"] .semester-matrix td { background: #111b29; border-color: #2b3a4e; }
:root[data-theme="dark"] .semester-matrix th { color: #bddaff; }
:root[data-theme="dark"] .semester-matrix thead th:first-child { background: #17263a; }
:root[data-theme="dark"] .semester-matrix thead th:nth-child(2) { background: #17263a; }
:root[data-theme="dark"] .semester-matrix tbody .semester-day-cell,
:root[data-theme="dark"] .semester-matrix tbody .semester-time-cell { background: #152132; color: #c4d2e4; }
:root[data-theme="dark"] .semester-matrix thead th small { color: #9aabc0; }
:root[data-theme="dark"] .semester-matrix tr:nth-child(even) td { background: #152132; }
:root[data-theme="dark"] .semester-matrix tbody tr.semester-day-end > td,
:root[data-theme="dark"] .semester-matrix tbody tr.semester-day-end > .semester-time-cell,
:root[data-theme="dark"] .semester-matrix tbody .semester-day-cell { border-bottom-color: #57708c; }
:root[data-theme="dark"] .semester-group-chip { background: color-mix(in srgb, var(--group-color) 32%, #111925); color: #f1f6ff; }
:root[data-theme="dark"] .semester-empty { color: var(--night-muted); }
:root[data-theme="dark"] .teacher-group { color: #23344a; }
:root[data-theme="dark"] .teacher-type-lecture { background: #263d5b; color: #b7d8ff; }
:root[data-theme="dark"] .teacher-type-seminar { background: #174438; color: #a5f0ce; }
:root[data-theme="dark"] .teacher-type-practice { background: #4a3420; color: #ffcf91; }
:root[data-theme="dark"] .teacher-type-lab { background: #4a2935; color: #ffb5c4; }

@media (max-width: 640px) {
  .site-toolbar { align-items: center; flex-wrap: wrap; }
  .theme-toggle { min-height: 38px; padding: 7px 11px; font-size: .82rem; }
  .top-nav a { min-height: 38px; padding: 7px 11px; font-size: .82rem; }
}

:root[data-theme="dark"] .teacher-panel,
:root[data-theme="dark"] .teacher-results,
:root[data-theme="dark"] .teacher-results-toolbar,
:root[data-theme="dark"] .teacher-semester {
  background: linear-gradient(145deg, #131e2c, #101722);
  border: 1px solid #2b3d52;
  color: #e8eff8;
}
:root[data-theme="dark"] .teacher-group {
  background: #24364b;
  color: #dcecff;
  border: 1px solid #3c5875;
}
:root[data-theme="dark"] .teacher-table td::before { color: #a9bdd2; }
:root[data-theme="dark"] .teacher-table tbody tr { background: #121c2a; }
:root[data-theme="dark"] .teacher-table tbody tr:nth-child(even) { background: #152132; }
:root[data-theme="dark"] .calendar-day { background: #111925; }
:root[data-theme="dark"] .calendar-lessons { background: #111925; }
:root[data-theme="dark"] .calendar-subject { color: #e8eff8; }
:root[data-theme="dark"] .calendar-groups .teacher-group { background: #24364b; color: #dcecff; }
:root[data-theme="dark"] .teacher-badge { border: 1px solid #385677; }
:root[data-theme="dark"] .semester-legend-item { border-color: color-mix(in srgb, var(--group-color) 65%, #27364a); }
:root[data-theme="dark"] .semester-group-chip { color: #f1f6ff; }
:root[data-theme="dark"] .teacher-week-navigation button:disabled { color: #8393a6; background: #202c39; border-color: #344355; }

