/* Дневник МАИ — стили Mini App.
   Тёмная тема по умолчанию, светлая через html[data-theme="light"].
   Все цвета только через переменные ниже. */

:root,
html[data-theme="dark"] {
  --bg: #0f1722;
  --bg-elevated: #131d2b;
  --surface: #182334;
  --surface-2: #1f2c40;
  --surface-hover: #24334a;
  --border: rgba(160, 190, 230, 0.10);
  --border-strong: rgba(160, 190, 230, 0.18);
  --scroll-thumb: rgba(160, 190, 230, 0.22);
  --scroll-thumb-hover: rgba(160, 190, 230, 0.38);
  --text: #edf2fa;
  --text-2: #b6c3d6;
  --muted: #7f90a8;
  --accent: #3d82f6;          /* фирменный синий МАИ */
  --accent-strong: #2a6fe4;
  --accent-text: #6aa5ff;     /* синий для текста на тёмном (преподаватели, ссылки) */
  --accent-soft: rgba(61, 130, 246, 0.16);
  --on-accent: #ffffff;
  --today: #f5a524;           /* «Сегодня» */
  --today-soft: rgba(245, 165, 36, 0.14);
  --success: #2fbf71;
  --success-soft: rgba(47, 191, 113, 0.15);
  --warning: #f5a524;
  --warning-soft: rgba(245, 165, 36, 0.15);
  --danger: #ef5b5b;
  --danger-soft: rgba(239, 91, 91, 0.14);
  --overlay: rgba(4, 9, 16, 0.66);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --nav-bg: rgba(24, 35, 52, 0.86);
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #f2f5fa;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --surface-2: #eef3fb;
  --surface-hover: #e6eef9;
  --border: #e1e8f2;
  --border-strong: #cfd9e8;
  --scroll-thumb: rgba(47, 76, 120, 0.22);
  --scroll-thumb-hover: rgba(47, 76, 120, 0.4);
  --text: #121b29;
  --text-2: #3a4759;
  --muted: #6b7a90;
  --accent: #2f6fec;
  --accent-strong: #1f5ad1;
  --accent-text: #2a64d6;
  --accent-soft: rgba(47, 111, 236, 0.10);
  --on-accent: #ffffff;
  --today: #d9820b;
  --today-soft: rgba(217, 130, 11, 0.12);
  --success: #1e9e5a;
  --success-soft: rgba(30, 158, 90, 0.12);
  --warning: #c77a06;
  --warning-soft: rgba(199, 122, 6, 0.12);
  --danger: #d93f3f;
  --danger-soft: rgba(217, 63, 63, 0.10);
  --overlay: rgba(17, 27, 41, 0.45);
  --shadow: 0 10px 30px rgba(24, 45, 80, 0.12);
  --nav-bg: rgba(255, 255, 255, 0.9);
  color-scheme: light;
}

:root {
  --radius: 18px;
  --radius-sm: 12px;
  --gutter: 16px;
  --nav-h: 64px;
  --font: "Golos Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ===== База ===== */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.45 var(--font);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
button:disabled { opacity: 0.55; cursor: default; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Полосы прокрутки: тонкие, в цвет темы, без стрелок (список групп, модалки, шторка, страница).
   Chrome 121+ при заданных scrollbar-width/scrollbar-color игнорирует ::-webkit-scrollbar и рисует
   системную полосу со стрелками, поэтому стандартные свойства только там, где webkit-стилей нет (Firefox). */
@supports not selector(::-webkit-scrollbar) {
  * {
    scrollbar-width: thin;
    scrollbar-color: var(--scroll-thumb) transparent;
  }
}
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-hover); }
::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
::-webkit-scrollbar-corner { background: transparent; }
body.sheet-open, body.modal-open { overflow: hidden; }

.app {
  max-width: 680px;
  margin: 0 auto;
  padding: 4px var(--gutter) calc(var(--nav-h) + 40px + env(safe-area-inset-bottom, 0px));
}

/* ===== Шапка ===== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 680px;
  margin: 0 auto;
  padding: calc(10px + env(safe-area-inset-top, 0px)) var(--gutter) 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(145deg, #4a8dff, #1f5ad1);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 14px rgba(47, 111, 236, 0.35);
}
.brand-text { min-width: 0; }
.brand-title { font-weight: 700; font-size: 17px; line-height: 1.2; }
.brand-sub {
  display: block;
  max-width: 100%;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0;
}
.icon-btn {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  transition: background 0.15s ease, transform 0.1s ease;
}
.icon-btn:active { transform: scale(0.94); }
.icon-btn:hover { background: var(--surface-hover); }
.icon-btn-sm { width: 34px; height: 34px; font-size: 13px; }
html[data-theme="dark"] .icon-sun,
html[data-theme="light"] .icon-moon { display: none; }

/* ===== Экраны ===== */
.screen { display: none; }
.screen.active { display: block; animation: fadeIn 0.2s ease-out; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}
.screen-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 6px 0 14px;
}
.screen-title { font-size: 24px; font-weight: 700; letter-spacing: -0.2px; }
.section-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  margin: 22px 0 10px;
}

/* ===== Кнопки и поля ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 14px;
  font-weight: 600;
  font-size: 15px;
  transition: background 0.15s ease, transform 0.1s ease, opacity 0.15s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-sm { min-height: 38px; padding: 7px 14px; font-size: 14px; border-radius: 12px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-strong); }
.btn-ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface-hover); }
.link-btn { color: var(--accent-text); font-weight: 600; font-size: 13px; padding: 4px 0; }

/* Кнопки в карточках (используются в JS) */
.btn-control {
  flex: 1 1 130px;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.25;
  transition: transform 0.1s ease, background 0.15s;
}
.btn-control:active { transform: scale(0.97); }
.btn-resolve { background: var(--accent); color: var(--on-accent); }
.btn-success { background: var(--success); color: #fff; }
.btn-cancel { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.btn-reopen { background: var(--warning-soft); color: var(--warning); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-chat { background: var(--accent-soft); color: var(--accent-text); }

.field {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 11px 14px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
  -webkit-appearance: none;
  appearance: none;
}
select.field {
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237f90a8' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px;
  text-overflow: ellipsis;
}
select.field option { background: var(--surface); color: var(--text); }
.field:focus { border-color: var(--accent); background: var(--surface); }
.field::placeholder { color: var(--muted); }
.field-sm { min-height: 40px; padding: 8px 12px; font-size: 14px; border-radius: 12px; }
.field-area { min-height: 110px; resize: vertical; line-height: 1.45; }
.date-field { text-align: left; color: var(--muted); }
.date-field.has-value { color: var(--text); }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin: 14px 0 6px; }
.form-label:first-child { margin-top: 0; }
.form-note { font-weight: 400; opacity: 0.85; }

/* ===== Карточки ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.card-title { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.card-hint { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.status-box {
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 26px 18px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
.status-box .btn { margin-top: 12px; }

/* ===== Расписание ===== */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 14px;
}
.pill {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-weight: 600;
  font-size: 14.5px;
  white-space: nowrap;
  transition: background 0.15s;
}
.pill:hover { background: var(--surface-hover); }
.pill-group { min-width: 0; overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; }
.week-switch {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
}
.week-switch .pill { padding: 0 12px; }
.week-arrow {
  width: 34px;
  height: 44px;
  border-radius: 12px;
  font-size: 24px;
  line-height: 1;
  color: var(--accent-text);
}
.week-arrow:hover { background: var(--surface-hover); }

.day-block { margin-bottom: 18px; scroll-margin-top: 80px; }
.day-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: baseline;
  padding: 0 4px 8px;
}
.day-name { font-weight: 700; font-size: 15px; text-transform: uppercase; letter-spacing: 0.4px; }
.day-today { color: var(--today); font-weight: 600; font-size: 15px; text-align: center; }
.day-date { color: var(--muted); font-size: 14px; text-align: right; }
.day-block.is-today .day-name { color: var(--today); }
.day-block.is-target .lesson-card { border-color: var(--border-strong); }
.day-empty {
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 14px;
}

.lesson-card {
  position: relative;
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 4px 12px;
  padding: 14px 14px 12px;
  margin-bottom: 8px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: background 0.15s ease, transform 0.1s ease, border-color 0.15s;
}
.lesson-card.is-tappable { cursor: pointer; }
.lesson-card.is-tappable:hover { background: var(--surface-hover); }
.lesson-card.is-tappable:active { transform: scale(0.99); }
.lesson-card.is-now { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.lesson-card.is-past { opacity: 0.6; }
.lesson-num {
  grid-row: span 3;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  font-weight: 700;
  font-size: 14px;
  color: var(--text-2);
}
.lesson-card.is-now .lesson-num { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.lesson-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; min-width: 0; }
.lesson-title { font-size: 17px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.lesson-teacher { font-size: 14px; color: var(--accent-text); overflow-wrap: anywhere; }
.lesson-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
  margin-top: 8px;
  font-size: 13.5px;
  color: var(--muted);
}
.lesson-meta .lesson-room { color: var(--text-2); }
.lesson-hw-badge {
  flex-shrink: 0;
  padding: 3px 8px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

/* ===== Дедлайны ===== */
.deadline-list { display: flex; flex-direction: column; gap: 10px; }
.deadline-card {
  position: relative;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
}
.deadline-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--accent);
}
.deadline-card.soon::before { background: var(--warning); }
.deadline-card.overdue::before { background: var(--danger); }
.deadline-card.done { opacity: 0.6; }
.deadline-card.done::before { background: var(--muted); }
.deadline-card.done .deadline-text { text-decoration: line-through; }
.deadline-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 6px 10px; margin-bottom: 8px; }
.deadline-subject { font-size: 16px; font-weight: 600; line-height: 1.3; min-width: 0; overflow-wrap: anywhere; }
.deadline-badge {
  flex-shrink: 0;
  padding: 4px 9px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent-text);
}
.deadline-badge.badge-soon { background: var(--warning-soft); color: var(--warning); }
.deadline-badge.badge-overdue { background: var(--danger-soft); color: var(--danger); }
.deadline-text { font-size: 14.5px; color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; margin-bottom: 12px; }
.deadline-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.done-toggle { color: var(--muted); font-size: 14px; font-weight: 600; padding: 8px 2px; text-align: left; }
.deadline-empty {
  text-align: center;
  padding: 36px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  color: var(--muted);
  font-size: 14px;
}
.deadline-empty .empty-icon { font-size: 34px; margin-bottom: 8px; }
.deadline-empty .empty-title { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  margin-bottom: 12px;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-text);
  border: 1px solid var(--accent);
  font-weight: 600;
  font-size: 13.5px;
  text-align: left;
  overflow-wrap: anywhere;
}

/* ===== Файлы ===== */
.hw-files { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.hw-file { display: flex; align-items: center; gap: 6px; }
.hw-file-open {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 13.5px;
  text-align: left;
}
.hw-file-open:hover { background: var(--surface-hover); }
.hw-file-thumb { width: 42px; height: 42px; border-radius: 8px; object-fit: cover; flex-shrink: 0; background: var(--surface); }
.hw-file-icon {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  flex-shrink: 0;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 11px; font-weight: 700; text-transform: uppercase;
}
.hw-file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hw-file-size { flex-shrink: 0; color: var(--muted); font-size: 12px; }
.hw-file-remove {
  flex-shrink: 0;
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
}
.hw-file-remove:hover { color: var(--danger); }
.pending-files { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.pending-file {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 4px 4px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 13.5px;
}

/* ===== Взаимопомощь ===== */
.filter-row { display: flex; gap: 8px; margin-bottom: 12px; }
.filter-row .field { flex: 1; }
.request-card {
  padding: 14px 16px;
  margin-bottom: 10px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: background 0.15s, transform 0.1s;
}
.request-card.is-clickable { cursor: pointer; }
.request-card.is-clickable:hover { background: var(--surface-hover); }
.request-card.is-clickable:active { transform: scale(0.99); }
.request-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.badge-course, .badge-subj, .status-pill, .role-pill {
  padding: 3px 9px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.badge-course { background: var(--surface-2); color: var(--text-2); }
.badge-subj { background: var(--accent-soft); color: var(--accent-text); }
.request-topic { font-size: 16px; font-weight: 600; margin-bottom: 4px; overflow-wrap: anywhere; }
.request-desc {
  font-size: 14px;
  color: var(--text-2);
  margin-bottom: 10px;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.request-desc-full { display: block; -webkit-line-clamp: unset; line-clamp: unset; white-space: pre-wrap; }
.request-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
}
.request-footer > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.help-action-hint { color: var(--accent-text); font-weight: 600; white-space: nowrap; }
.request-card.is-mine .help-action-hint { color: var(--muted); }
.my-request-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px; margin-bottom: 8px; }
.status-open { background: var(--accent-soft); color: var(--accent-text); }
.status-in_progress { background: var(--warning-soft); color: var(--warning); }
.status-closed { background: var(--success-soft); color: var(--success); }
.status-muted { background: var(--surface-2); color: var(--muted); }
.my-request-controls { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.helper-box {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--accent-soft);
  font-size: 14px;
}
.helper-box .helper-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.helper-box b { color: var(--text); }

/* Рейтинг */
.rating-card { padding: 14px 16px; }
.rating-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.rating-title { font-weight: 700; font-size: 15px; }
.rating-list { display: flex; flex-direction: column; gap: 6px; }
.rating-row { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.rating-place {
  flex-shrink: 0;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--surface-2);
  font-size: 12px; font-weight: 700;
  color: var(--text-2);
}
.rating-row:nth-child(1) .rating-place { background: #f5c542; color: #3a2a00; }
.rating-row:nth-child(2) .rating-place { background: #c9d3e0; color: #26303d; }
.rating-row:nth-child(3) .rating-place { background: #d8955a; color: #3a1d05; }
.rating-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rating-row.is-me .rating-name { color: var(--accent-text); font-weight: 600; }
.rating-score { font-weight: 700; color: var(--text-2); }
.rating-me { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 13.5px; color: var(--muted); }
.rating-me b { color: var(--text); }

/* ===== Профиль ===== */
.profile-card { display: flex; align-items: center; gap: 14px; }
.avatar {
  flex-shrink: 0;
  display: grid; place-items: center;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: linear-gradient(145deg, #4a8dff, #1f5ad1);
  color: #fff;
  font-size: 22px;
  font-weight: 700;
}
.profile-main { flex: 1; min-width: 0; }
.profile-name { font-size: 18px; font-weight: 700; overflow-wrap: anywhere; }
.profile-id { font-size: 13px; color: var(--muted); padding: 2px 0; }
.profile-id:hover { color: var(--accent-text); }
.role-pill { background: var(--accent-soft); color: var(--accent-text); flex-shrink: 0; }
.settings-card { padding: 4px 16px; }
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 60px;
  padding: 10px 0;
}
.setting-row + .setting-row { border-top: 1px solid var(--border); }
.setting-row > div:first-child { min-width: 0; }
.setting-label { font-size: 13px; color: var(--muted); }
.setting-value { font-size: 15.5px; font-weight: 600; overflow-wrap: anywhere; }
.segmented { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.segmented button { padding: 7px 12px; border-radius: 9px; font-size: 13.5px; font-weight: 600; color: var(--muted); }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15); }
html[data-theme="dark"] .segmented button.active { background: var(--accent); color: #fff; }
.role-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; }
.members-list { display: flex; flex-direction: column; margin-top: 12px; }
.member-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 2px;
  border-top: 1px solid var(--border);
  font-size: 14px;
  text-align: left;
  width: 100%;
}
.member-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.member-name small { display: block; color: var(--muted); font-size: 12px; }
.member-row .role-pill.is-student { background: var(--surface-2); color: var(--muted); }

/* ===== Нижняя навигация ===== */
.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  gap: 4px;
  width: calc(100% - 24px);
  max-width: 520px;
  height: var(--nav-h);
  padding: 6px;
  border-radius: 32px;
  background: var(--nav-bg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.nav-item {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 26px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.nav-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.nav-item.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }

/* ===== Модалки ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 14px;
  background: var(--overlay);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal-overlay.active { display: flex; animation: fadeIn 0.15s ease-out; }
.modal {
  width: 100%;
  max-width: 440px;
  padding: 20px;
  border-radius: 22px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.modal-scroll { max-height: calc(100vh - 28px); overflow-y: auto; overscroll-behavior: contain; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 4px; }
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 10px; }
.modal-head .modal-title { margin-bottom: 0; }
.modal-text { font-size: 15px; color: var(--text-2); margin-bottom: 8px; }
.modal-hint { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .btn { flex: 1; }
.group-list {
  max-height: min(46vh, 360px);
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px -6px 12px 0;   /* полоса прокрутки уходит в отступ модалки, а не на кнопки */
  padding-right: 6px;
  scrollbar-gutter: stable;
}
.group-item-btn {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  text-align: left;
  font-weight: 600;
}
.group-item-btn:hover { border-color: var(--accent); }
.group-item-btn.selected { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
.group-list-empty { text-align: center; color: var(--muted); padding: 14px 6px; font-size: 14px; }
.group-list-empty p { margin-bottom: 12px; }

/* Календарь */
.calendar-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-weight: 700; font-size: 16px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.cal-head { font-size: 12px; color: var(--muted); padding-bottom: 6px; font-weight: 600; }
.cal-cell { padding: 9px 0; font-size: 14px; border-radius: 10px; cursor: pointer; }
.cal-cell:hover { background: var(--surface-hover); }
.cal-cell.today { box-shadow: 0 0 0 1.5px var(--today) inset; color: var(--today); font-weight: 600; }
.cal-cell.selected, .cal-cell.selected:hover { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.cal-cell.empty { cursor: default; background: transparent; }

/* ===== Шторка ===== */
.sheet-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 150;
  align-items: flex-end;
  justify-content: center;
  background: var(--overlay);
}
.sheet-overlay.active { display: flex; animation: fadeIn 0.15s ease-out; }
.bottom-sheet {
  width: 100%;
  max-width: 680px;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 24px 24px 0 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  transition: transform 0.2s ease;
  animation: sheetUp 0.22s ease-out;
}
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.sheet-drag-area { padding: 8px 16px 10px; touch-action: none; }
.sheet-handle { width: 40px; height: 4px; border-radius: 2px; background: var(--border-strong); margin: 0 auto 10px; }
.sheet-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.sheet-kicker { font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); }
.sheet-title { font-size: 18px; line-height: 1.3; overflow-wrap: anywhere; }
.sheet-body { flex: 1; overflow-y: auto; padding: 4px 16px 12px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; }
.sheet-subtitle { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 6px; }
.sheet-footer { display: flex; gap: 10px; padding: 12px 16px 16px; border-top: 1px solid var(--border); }
.sheet-footer > .btn { flex: 1; }

/* ===== Уведомление ===== */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 26px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 20px);
  z-index: 300;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 14px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ===== Адаптивность ===== */
@media (max-width: 380px) {
  :root { --gutter: 12px; }
  .brand-mark { width: 36px; height: 36px; font-size: 12px; }
  .pill { padding: 0 12px; font-size: 13.5px; }
  .week-switch .pill { padding: 0 8px; }
  .week-arrow { width: 28px; }
  .lesson-card { grid-template-columns: 28px 1fr; gap: 4px 10px; padding: 12px; }
  .lesson-num { width: 28px; height: 28px; font-size: 13px; }
  .lesson-title { font-size: 16px; }
  .role-form { grid-template-columns: 1fr 1fr; }
  .role-form .btn { grid-column: 1 / -1; }
  .screen-title { font-size: 21px; }
}
@media (max-width: 340px) {
  .toolbar { flex-wrap: wrap; }
  .week-switch { margin-left: 0; }
}
@media (min-width: 720px) {
  .app { padding-top: 10px; }
  .lesson-card { padding: 16px 18px 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ===== Учёба: переключатель «Задания / Методички» ===== */
.segmented-wide { display: flex; width: 100%; margin-bottom: 14px; }
.segmented-wide button { flex: 1; padding: 9px 12px; }
#studyMaterials > .field { margin-bottom: 12px; }
.material-title { font-size: 16px; font-weight: 600; margin-bottom: 6px; overflow-wrap: anywhere; }
.material-card::before { background: var(--accent); }

/* ===== Сессия ===== */
.session-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--today-soft), var(--accent-soft));
  border: 1px solid var(--today);
  text-align: left;
}
.session-icon { font-size: 26px; flex-shrink: 0; }
.session-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.session-title { font-weight: 700; font-size: 15px; overflow-wrap: anywhere; }
.session-sub { font-size: 13px; color: var(--text-2); }
.session-arrow { font-size: 24px; color: var(--today); }
.lesson-card.is-session { border-color: var(--today); background: linear-gradient(135deg, var(--today-soft), var(--surface) 60%); }
.lesson-card.is-session .lesson-num { border-color: var(--today); color: var(--today); }
.lesson-card.is-session .lesson-type { color: var(--today); font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; }
.lesson-card.is-consult { border-style: dashed; background: var(--surface); }

/* ===== Мои запросы: кнопка «убрать» ===== */
.my-request-tools { display: inline-flex; align-items: center; gap: 8px; margin-left: auto; }
.icon-btn-xs { width: 28px; height: 28px; font-size: 12px; color: var(--muted); }
.icon-btn-xs:hover { color: var(--danger); }

/* ===== Профиль: продуктивность ===== */
.stats-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.stats-ring {
  --p: 0;
  --ring: var(--accent);
  flex-shrink: 0;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--ring) calc(var(--p) * 1%), var(--surface-2) 0);
}
.stats-ring span {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--surface);
  font-weight: 700;
  font-size: 17px;
}
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px;
  border-radius: 12px;
  background: var(--surface-2);
  min-width: 0;
}
.stat b { font-size: 19px; line-height: 1.2; }
.stat b.ok { color: var(--success); }
.stat b.bad { color: var(--danger); }
.stat span { font-size: 12px; color: var(--muted); line-height: 1.25; }
.stats-exam {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--today-soft);
  text-align: left;
  font-size: 14px;
}
.stats-exam small { color: var(--text-2); }
@media (max-width: 380px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
