/* === Theme variables === */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg-2: var(--tg-theme-secondary-bg-color, #f3f4f6);
  /* Глубже bg-2 — для треков прогресса, «утопленных» зон, дорожек.
     Раньше токен не был определён → var(--bg-3,#444) светил серым на свету. */
  --bg-3: color-mix(in oklab, var(--bg-2) 92%, var(--text));
  --surface: var(--tg-theme-bg-color, #ffffff);
  --surface-2: var(--tg-theme-secondary-bg-color, #f3f4f6);
  --text: var(--tg-theme-text-color, #14161a);
  --hint: var(--tg-theme-hint-color, #8a8f98);
  --link: var(--tg-theme-link-color, #2481cc);
  --accent: var(--tg-theme-button-color, #2481cc);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  /* Мягкая подложка акцента (чипы/secondary/hover) — читаема в обеих темах. */
  --accent-soft: color-mix(in oklab, var(--accent) 12%, transparent);
  /* Вторичный бренд-цвет и фирменный градиент (раньше #6c5ce7 был раскидан). */
  --brand-2: #6c5ce7;
  --brand-grad: linear-gradient(135deg, var(--accent), var(--brand-2));
  --separator: color-mix(in oklab, var(--text) 12%, transparent);
  /* Hairline-граница карточек: тоньше separator, даёт глубину без тяжёлых теней. */
  --card-border: color-mix(in oklab, var(--text) 7%, transparent);

  /* Единый ритм отступов 4 / 8 / 12 / 16 / 20 / 24. */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px;

  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  /* Шкала теней — мягкие, многослойные. --shadow оставлен (его юзают компоненты). */
  --shadow-sm: 0 1px 2px rgba(16,18,24,.05), 0 1px 3px rgba(16,18,24,.05);
  --shadow: 0 2px 6px rgba(16,18,24,.05), 0 4px 16px rgba(16,18,24,.06);
  --shadow-md: 0 4px 10px rgba(16,18,24,.06), 0 12px 28px rgba(16,18,24,.10);
  --shadow-lg: 0 8px 18px rgba(16,18,24,.10), 0 24px 56px rgba(16,18,24,.16);
  /* Плавное кольцо фокуса для полей/кнопок. */
  --ring: 0 0 0 3.5px color-mix(in oklab, var(--accent) 22%, transparent);
}

[data-color-scheme="dark"] {
  --bg-3: color-mix(in oklab, var(--bg-2) 80%, #ffffff);
  --separator: rgba(255, 255, 255, 0.11);
  --card-border: rgba(255, 255, 255, 0.06);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --shadow: 0 2px 8px rgba(0,0,0,.28), 0 6px 20px rgba(0,0,0,.32);
  --shadow-md: 0 6px 18px rgba(0,0,0,.40), 0 14px 32px rgba(0,0,0,.40);
  --shadow-lg: 0 12px 30px rgba(0,0,0,.50), 0 28px 60px rgba(0,0,0,.55);
}

/* Принудительная тёмная тема (админка) — не зависит от темы Telegram. */
[data-theme="dark"] {
  --bg: #0b0c10;
  --bg-2: #161922;
  --bg-3: #1f232e;
  --surface: #14161d;
  --surface-2: #1b1e28;
  --text: #e9ebf1;
  --hint: #969cab;
  --link: #5aa9ee;
  --accent: #3d97ec;
  --accent-text: #ffffff;
  --accent-soft: color-mix(in oklab, var(--accent) 18%, transparent);
  --brand-2: #7b6cf0;
  --separator: rgba(255, 255, 255, 0.08);
  --card-border: rgba(255, 255, 255, 0.07);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow: 0 2px 8px rgba(0,0,0,.40), 0 8px 24px rgba(0,0,0,.45);
  --shadow-md: 0 8px 20px rgba(0,0,0,.50), 0 16px 40px rgba(0,0,0,.50);
  --shadow-lg: 0 14px 34px rgba(0,0,0,.60), 0 30px 64px rgba(0,0,0,.60);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  min-height: 100vh;
  overscroll-behavior: none;
}

button { font-family: inherit; }
input, textarea {
  font-family: inherit;
  font-size: inherit;
  color: var(--text);
}

a { color: var(--link); text-decoration: none; }

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 14px 24px;
}
.container-admin { padding-bottom: 92px; /* место под нижнюю навигацию */ }
.container-user { padding-bottom: 96px; }

/* === Glass surfaces === */
.glass {
  background: color-mix(in oklab, var(--bg-2) 76%, transparent);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border: 1px solid color-mix(in oklab, var(--separator) 70%, transparent);
}
.glass-hero {
  position: relative;
  overflow: hidden;
}
.glass-hero::after {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(120% 80% at 0% 0%, rgba(255,255,255,0.20), transparent 60%),
    radial-gradient(120% 80% at 100% 100%, rgba(255,255,255,0.10), transparent 60%);
  pointer-events: none;
}
.glass-nav {
  background: color-mix(in oklab, var(--bg) 70%, transparent) !important;
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}

h1, h2, h3 { line-height: 1.25; font-weight: 700; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

.muted { color: var(--hint); font-size: 13px; }
.center { text-align: center; }

.page-title { margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.page-title h2 { margin: 0; }
.title-badge {
  display: inline-flex; align-items: center; justify-content: center;
  background: #ff3b30; color: #fff; font-size: 12px; font-weight: 700;
  padding: 0 8px; min-width: 22px; height: 22px; border-radius: 11px;
}

/* === Loading / Spinner === */
.loading {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 14px; padding: 80px 0;
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--separator);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: var(--hint); font-size: 14px; }

/* === Hero on user home === */
.hero {
  text-align: center;
  padding: 28px 16px 22px;
  background: linear-gradient(160deg, var(--accent) 0%, color-mix(in oklab, var(--accent) 70%, var(--brand-2)) 100%);
  color: #fff;
  border-radius: var(--radius-lg);
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.hero-emoji { font-size: 44px; line-height: 1; margin-bottom: 6px; }
.hero-title { font-size: 22px; font-weight: 800; letter-spacing: 0.2px; }
.hero-sub { opacity: 0.92; margin-top: 4px; }

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  border: none;
  border-radius: var(--radius);
  padding: 13px 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 8px;
  text-align: center;
  text-decoration: none;
  transition: transform 0.05s ease, opacity 0.15s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.98); opacity: 0.9; }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-secondary {
  background: color-mix(in oklab, var(--accent) 14%, var(--bg));
  color: var(--accent);
}
.btn-ghost {
  background: var(--bg-2);
  color: var(--text);
}
.btn-danger { background: #ff3b30; color: #fff; }

.actions { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > .btn { flex: 1; }

.back-btn {
  background: var(--bg-2);
  border: none;
  width: 36px; height: 36px;
  border-radius: 50%;
  font-size: 22px; line-height: 1;
  color: var(--text);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}

/* === Cards === */
.card {
  background: var(--bg-2);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card-title { font-weight: 700; margin-bottom: 6px; }
.alt-score { display: inline-block; min-width: 44px; text-align: center; padding: 1px 7px; border-radius: 8px; font-weight: 700; margin-right: 6px; color: #fff; }
.alt-high { background: #e0395e; }
.alt-mid { background: #e08a2f; }
.alt-low { background: #6c7a89; }
.card-body { color: var(--text); white-space: pre-wrap; margin-bottom: 8px; }
/* Описания-параграфы свёрстаны многострочным HTML с отступами. При pre-wrap
   эти отступы и переносы из исходника сохранялись — текст «ломался» лесенкой
   (баг в разделе партнёрки и в карточке капчи). Здесь возвращаем обычный
   перенос; .card-body с реальными \n (например причина бана) не трогаем. */
#page-partner .card-body,
#captcha-card .card-body { white-space: normal; }
.card-meta { font-size: 12px; color: var(--hint); margin-bottom: 4px; }
.card-warn {
  background: color-mix(in oklab, #ff3b30 12%, var(--bg));
  border: 1px solid color-mix(in oklab, #ff3b30 30%, transparent);
}

/* === Page header === */
.page-header {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px;
}
.page-header h3 { margin: 0; }
.page-back {
  background: transparent;
  border: none;
  color: var(--accent);
  font-size: 22px;
  line-height: 1;
  padding: 2px 6px;
  cursor: pointer;
}

/* === Quote blocks (внутри карточек заявок) === */
.quote {
  background: var(--bg);
  border-left: 3px solid var(--separator);
  padding: 8px 12px;
  border-radius: 8px;
  margin: 8px 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  white-space: pre-wrap;
}
.quote-accent { border-left-color: var(--accent); }

/* === Lists === */
.list { display: flex; flex-direction: column; gap: 10px; }
.list-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-2);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.list-item:active { background: color-mix(in oklab, var(--accent) 8%, var(--bg-2)); }
.list-item-body { flex: 1; min-width: 0; }
.list-item-title {
  font-weight: 600; display: flex; align-items: center; gap: 6px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.list-item-sub {
  font-size: 13px; color: var(--hint); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.list-item-meta { font-size: 12px; color: var(--hint); }

.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--brand-2));
  color: #fff;
  font-weight: 700;
  flex-shrink: 0;
}

/* === Chips / badges === */
.chip {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 6px;
}
.chip-red { background: #ff3b30; color: #fff; }
.chip-orange { background: #ff9500; color: #fff; }
.chip-green { background: #34c759; color: #fff; }
.chip-blue { background: #2481cc; color: #fff; }
/* «Возможно, публичный ПК» и подобные предупреждения-подсказки: это не
   тревога (ТЗ 5.2 просит именно НЕ бить тревогу), поэтому мягкая заливка,
   а не заливной красный. */
.chip-warn {
  background: color-mix(in oklab, #ff9500 18%, transparent);
  color: #b26a00;
  border: 1px solid color-mix(in oklab, #ff9500 40%, transparent);
}
[data-theme="dark"] .chip-warn { color: #ffb340; }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ff3b30;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px; height: 18px;
  padding: 0 6px;
  border-radius: 9px;
  margin-left: auto;
}

/* === Stats === */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.stats-grid-large { gap: 14px; }
.stat-card {
  background: var(--bg-2);
  border-radius: var(--radius-lg);
  padding: 22px 16px;
  text-align: center;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.stat-card::before {
  content: '';
  position: absolute; left: 0; top: 0; right: 0; height: 4px;
  background: var(--accent);
}
.stat-blue::before { background: #2481cc; }
.stat-orange::before { background: #ff9500; }
.stat-violet::before { background: var(--brand-2); }
.stat-red::before { background: #ff3b30; }
.stat-ico { font-size: 26px; line-height: 1; opacity: 0.92; }
.stat-value { font-size: 2.4rem; font-weight: 800; line-height: 1.1; }
.stat-label { font-size: 12px; color: var(--hint); text-transform: uppercase; letter-spacing: 0.6px; }

/* === Activity chart === */
.chart-card { padding: 16px 14px 10px; }
.chart-title { font-weight: 700; margin-bottom: 6px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 11px; color: var(--hint); margin-bottom: 8px; }
.chart-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.chart-wrap { width: 100%; }
.chart-svg { width: 100%; height: auto; display: block; }

/* === Filters === */
.filter-bar { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.filter-btn {
  border: 1px solid var(--separator);
  background: var(--bg-2);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.filter-btn.active {
  background: var(--accent);
  color: var(--accent-text);
  border-color: transparent;
}

/* === Search === */
.search-bar { display: flex; gap: 8px; margin-bottom: 12px; align-items: stretch; }
/* Усиленная специфичность — иначе .admin-section input побеждает и
   тянет ширину 100% + лишний margin-bottom внутри flex-контейнера. */
.search-bar input,
.search-bar input[type="text"] {
  flex: 1;
  width: auto;
  border: 1px solid var(--separator);
  border-radius: var(--radius);
  padding: 11px 14px;
  background: var(--bg);
  color: var(--text);
  margin-bottom: 0;
  font-size: 15px;
}
.search-bar input:focus,
.search-bar input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
}
.search-bar select {
  border: 1px solid var(--separator);
  border-radius: var(--radius);
  padding: 11px 14px;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
}
/* Фильтры списка пользователей */
.user-filters {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 12px;
}
.user-filters select,
.user-filters input[type="number"] {
  border: 1px solid var(--separator); border-radius: 8px; padding: 6px 8px;
  background: var(--bg); color: var(--text); font-size: 13px;
}
.user-filters input[type="number"] { width: 72px; }
.uf-check {
  display: inline-flex; align-items: center; gap: 4px; font-size: 13px;
  padding: 5px 8px; border: 1px solid var(--separator); border-radius: 8px;
  color: var(--text); cursor: pointer;
}
.search-bar button {
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: var(--radius);
  padding: 0 16px;
  cursor: pointer;
}

/* === User detail key/value === */
.kv {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--separator);
  font-size: 14px;
}
.kv:last-of-type { border-bottom: none; }
.kv > span:first-child { color: var(--hint); }
.points-log { margin-top: 8px; max-height: 220px; overflow-y: auto; }
.points-log .kv { font-size: 13px; }
.pts-plus { color: #2ecc71; font-weight: 700; }
.pts-minus { color: #e74c3c; font-weight: 700; }

/* Школьная БД */
.school-subtabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.school-subtab {
  padding: 6px 12px; border-radius: 8px; border: 1px solid var(--separator);
  background: var(--surface); color: var(--text); cursor: pointer; font-size: 13px;
}
.school-subtab.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.chip-checks { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.chip-check {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 8px;
  border: 1px solid var(--separator); border-radius: 8px; font-size: 13px;
}
.form-label { display: block; font-size: 12px; color: var(--hint); margin: 6px 0 2px; }
.tch-photos { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.tch-photo { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; }

/* Задания (геймификация) */
.task-card { cursor: pointer; }
.task-reward {
  background: var(--accent); color: var(--accent-text); border-radius: 999px;
  padding: 3px 10px; font-size: 12px; font-weight: 700; white-space: nowrap; align-self: center;
}
.task-reward-big { margin-top: 8px; font-weight: 700; color: var(--accent); }
.task-badge { font-size: 11px; padding: 1px 6px; border-radius: 6px; margin-left: 4px; }
.tb-pending { background: #ff9500; color: #fff; }
.tb-done { background: #2ecc71; color: #fff; }
.tb-rej { background: #ff3b30; color: #fff; }

/* Единая лента заявок */
.app-type-bar { flex-wrap: wrap; }
.app-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; font-size: 12px; }
.app-actions { flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.app-card .audit-msg { background: rgba(127,127,127,0.12); border-radius: 8px; padding: 6px 8px; margin-top: 4px; font-size: 13px; white-space: pre-wrap; }

/* Фото профиля как аватарка в списке пользователей */
.avatar-img { object-fit: cover; padding: 0; }
.psw-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--separator);
}
.psw-row:last-of-type { border-bottom: none; }
.psw-label { font-weight: 600; }
.psw-row input[type="checkbox"] { width: 22px; height: 22px; flex-shrink: 0; }
.form-row {
  display: flex; flex-direction: column; gap: 6px; margin: 12px 0;
}
.form-row label { font-size: 12px; color: var(--hint); }
.form-row input {
  border: 1px solid var(--separator);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--bg);
}

/* === Chat === */
.chat-messages {
  height: 60vh;
  overflow-y: auto;
  padding: 14px;
  background: var(--bg-2);
  border-radius: var(--radius);
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-msg {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
  position: relative;
  box-shadow: var(--shadow);
  margin-top: 4px;
}
.chat-msg-text { white-space: pre-wrap; }
.chat-msg.outgoing {
  background: var(--accent);
  color: var(--accent-text);
  align-self: flex-end;
  border-bottom-right-radius: 6px;
}
.chat-msg.incoming {
  background: var(--surface);
  color: var(--text);
  align-self: flex-start;
  border-bottom-left-radius: 6px;
  border: 1px solid var(--separator);
}
.chat-msg .msg-time {
  font-size: 10px;
  opacity: 0.7;
  margin-top: 3px;
  text-align: right;
}
.chat-msg.incoming .msg-time { color: var(--hint); }

/* Вложения в чате с админом */
.chat-media-img,
.chat-media-vid {
  display: block;
  max-width: 240px;
  max-height: 320px;
  width: auto;
  border-radius: 10px;
  cursor: pointer;
}
.chat-media-note {
  display: block;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  object-fit: cover;
}
.chat-media-audio {
  display: block;
  max-width: 240px;
  width: 240px;
}
.chat-media-sticker {
  display: block;
  max-width: 140px;
  max-height: 140px;
}
.chat-media-file {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(127, 127, 127, 0.12);
  color: inherit;
  text-decoration: none;
  word-break: break-word;
}
.chat-msg .chat-media-img + .chat-msg-text,
.chat-msg .chat-media-vid + .chat-msg-text,
.chat-msg .chat-media-note + .chat-msg-text,
.chat-msg .chat-media-audio + .chat-msg-text,
.chat-msg .chat-media-file + .chat-msg-text { margin-top: 6px; }

.chat-input {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 6px 0;
}
.chat-input input {
  flex: 1;
  border: 1px solid var(--separator);
  border-radius: 999px;
  padding: 11px 16px;
  background: var(--bg-2);
}
.chat-input input:focus { outline: none; border-color: var(--accent); }
.chat-input button {
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: 50%;
  width: 44px; height: 44px;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
}
.chat-input button.chat-attach-btn {
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--separator);
  font-size: 20px;
}

/* Панель прикреплённых вложений над полем ввода чата */
.chat-attach-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 6px 2px;
}
.chat-attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-2);
  border: 1px solid var(--separator);
  border-radius: 999px;
  padding: 4px 6px 4px 10px;
  font-size: 13px;
}
.chat-attach-chip button {
  background: none;
  border: none;
  color: var(--hint);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 0 2px;
}
.chat-attach-hint { font-size: 12px; }
.chat-attach-refresh {
  margin-left: auto;
  background: var(--bg-2);
  border: 1px solid var(--separator);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 14px;
  cursor: pointer;
  color: var(--text);
}

/* === Rules === */
.rules-content {
  line-height: 1.6;
  white-space: pre-wrap;
  background: var(--bg-2);
  border-radius: var(--radius);
  padding: 16px;
}

#rules-editor {
  width: 100%;
  border: 1px solid var(--separator);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--bg-2);
  color: var(--text);
  margin-bottom: 10px;
  resize: vertical;
}

/* === Tracker create form === */
#create-tracker-form input {
  width: 100%;
  border: 1px solid var(--separator);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
  background: var(--bg);
  color: var(--text);
}
.link-line { font-size: 12px; color: var(--link); word-break: break-all; margin: 4px 0; }

/* === Tree === */
ul.tree { list-style: none; padding-left: 0; }
ul.tree ul { list-style: none; padding-left: 18px; border-left: 1px dashed var(--separator); margin-left: 8px; }
.tree-node { padding: 4px 0; }
.tree-label {
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 2px 6px;
  border-radius: 6px;
}
.tree-label:active { background: var(--bg-2); }
.tree-label small { color: var(--hint); }
.tree-tracker {
  font-size: 11px;
  color: var(--hint);
  background: var(--bg-2);
  padding: 1px 6px;
  border-radius: 999px;
}
.tree-node.tree-hit > .tree-label {
  background: rgba(255, 149, 0, 0.18);
  font-weight: 600;
}
.tree-self-card {
  border: 2px solid var(--accent);
}
.ancestor-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--separator);
  cursor: pointer;
  font-size: 13px;
}
.ancestor-row:last-child { border-bottom: none; }
.ancestor-arrow {
  color: var(--hint);
  font-family: ui-monospace, monospace;
  flex-shrink: 0;
}

/* === Bottom nav === */
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  background: var(--bg);
  border-top: 1px solid var(--separator);
  padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0));
  z-index: 50;
  box-shadow: 0 -1px 6px rgba(0, 0, 0, 0.06);
}
.bottom-nav::-webkit-scrollbar { display: none; }
.nav-btn {
  flex: 1 1 0;
  min-width: 0;
  border: none;
  background: transparent;
  padding: 6px 2px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--hint);
  cursor: pointer;
  position: relative;
  border-radius: 8px;
  transition: color 0.15s ease;
}
.nav-btn .nav-ico { font-size: 18px; line-height: 1; }
.nav-btn .nav-lbl {
  font-size: 10px; font-weight: 500;
  max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Пользовательское меню — все кнопки помещаются без прокрутки (мельче подпись). */
#user-nav .nav-btn .nav-lbl { font-size: 9px; }

/* Админское меню на телефоне: кнопок много — листаем по горизонтали. */
@media (max-width: 899px) {
  #admin-nav.bottom-nav {
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  #admin-nav .nav-btn { flex: 0 0 auto; min-width: 60px; }
}
.nav-btn.active { color: var(--accent); }
.nav-badge {
  position: absolute;
  top: 2px;
  right: calc(50% - 18px);
  background: #ff3b30;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px; height: 16px;
  border-radius: 8px;
  padding: 0 4px;
  display: inline-flex; align-items: center; justify-content: center;
}

/* === Posts (user home feed) === */
.post-card {
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.post-header {
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px; margin-bottom: 8px;
}
.post-status {
  font-size: 12px; font-weight: 700;
  padding: 4px 10px; border-radius: 999px;
}
.post-status.st-green { background: color-mix(in oklab, #34c759 22%, transparent); color: #1f9a40; }
.post-status.st-orange { background: color-mix(in oklab, #ff9500 22%, transparent); color: #c97000; }
.post-status.st-red { background: color-mix(in oklab, #ff3b30 22%, transparent); color: #c62820; }
.post-status.st-gray { background: var(--separator); color: var(--hint); }
[data-color-scheme="dark"] .post-status.st-green { color: #4cd964; }
[data-color-scheme="dark"] .post-status.st-orange { color: #ffb155; }
[data-color-scheme="dark"] .post-status.st-red { color: #ff6961; }
.post-mode { font-size: 12px; color: var(--hint); }
.post-body {
  white-space: pre-wrap;
  font-size: 14px; line-height: 1.5;
  margin-bottom: 6px;
  word-wrap: break-word;
}
.post-reason {
  background: color-mix(in oklab, #ff3b30 14%, transparent);
  border-left: 3px solid #ff3b30;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text);
  margin-bottom: 6px;
}
.post-meta { font-size: 11px; color: var(--hint); }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  border-radius: var(--radius);
  font-size: 16px;
  color: var(--text);
}

/* === Profile === */
.profile-card {
  text-align: center;
  padding: 22px 14px;
}
.profile-avatar {
  width: 72px; height: 72px;
  margin: 0 auto 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--brand-2));
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 30px; font-weight: 700;
}
.profile-name { font-size: 18px; font-weight: 700; }
.profile-uname { color: var(--hint); font-size: 13px; margin-bottom: 8px; }
.profile-status { margin-top: 8px; }

/* === Fixed chat layout === */
.page-chat-fixed.page-chat-active {
  display: flex !important;
  flex-direction: column;
  position: fixed;
  left: 0; right: 0;
  top: 0;
  bottom: calc(60px + env(safe-area-inset-bottom, 0));
  padding: 12px 14px 0;
  max-width: 640px;
  margin: 0 auto;
  z-index: 10;
}
.chat-messages-fill {
  flex: 1;
  height: auto !important;
  margin-bottom: 8px;
}
.chat-input-bottom {
  padding-bottom: 8px;
}
.chat-empty { padding: 20px 0; }

/* === FAB === */
.fab {
  position: fixed;
  bottom: calc(70px + env(safe-area-inset-bottom, 0));
  right: 18px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(36, 129, 204, 0.35);
  display: flex; align-items: center; justify-content: center;
  z-index: 40;
  transition: transform 0.1s ease;
}
.fab:active { transform: scale(0.92); }

/* === Modal === */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 100;
  padding: 0;
}
.modal {
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border-top-left-radius: 22px;
  border-top-right-radius: 22px;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0));
  box-shadow: 0 -8px 30px rgba(0,0,0,0.18);
  animation: modalSlide 0.22s ease-out;
}
@keyframes modalSlide { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.modal-header h3 { margin: 0; }
.modal-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--bg-2);
  color: var(--text);
  font-size: 16px; cursor: pointer;
}
/* Все поля внутри модалок и админских форм должны использовать тему,
   иначе на iOS/некоторых клиентах текст становится белым на белом. */
.modal textarea,
.modal input[type="text"],
.modal input[type="number"],
.modal input[type="datetime-local"],
.modal input:not([type]),
.modal select,
.admin-section input[type="text"],
.admin-section input[type="number"],
.admin-section input[type="datetime-local"],
.admin-section input:not([type]),
.admin-section textarea,
#news-form input[type="text"],
#news-form textarea,
#poll-block input[type="text"] {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--separator);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--bg);
  color: var(--text);
  resize: vertical;
  font-size: 15px;
  line-height: 1.45;
  margin-bottom: 12px;
}
.modal textarea:focus,
.modal input:focus,
.admin-section input:focus,
.admin-section textarea:focus,
#news-form input:focus,
#news-form textarea:focus,
#poll-block input:focus {
  outline: none;
  border-color: var(--accent);
}
.modal input::placeholder,
.admin-section input::placeholder,
.admin-section textarea::placeholder,
#news-form input::placeholder,
#news-form textarea::placeholder,
#poll-block input::placeholder { color: var(--hint); opacity: 1; }
.mode-toggle {
  display: flex; gap: 8px; margin-bottom: 10px;
}
.mode-opt {
  flex: 1; cursor: pointer;
  padding: 10px;
  border-radius: var(--radius);
  background: var(--bg-2);
  text-align: center;
  font-size: 13px; font-weight: 600;
  border: 2px solid transparent;
  transition: border-color 0.15s ease;
}
.mode-opt input { display: none; }
.mode-opt input:checked + span { color: var(--accent); }
.mode-opt:has(input:checked) { border-color: var(--accent); }
.compose-hint { font-size: 12px; margin-bottom: 10px; }

/* === Swipe-to-delete (admin posts) === */
.swipe-row {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  margin-bottom: 10px;
  background: #ff3b30;
}
.swipe-content {
  position: relative;
  background: var(--bg-2);
  transition: transform 0.22s cubic-bezier(0.2, 0.7, 0.2, 1);
  will-change: transform;
  touch-action: pan-y;
  cursor: pointer;
}
.swipe-content.swiped { transform: translateX(-92px); }
.swipe-content.swiping { transition: none; }
.swipe-actions {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 92px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ff3b30;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  gap: 4px;
  flex-direction: column;
}
.swipe-actions .swipe-ico { font-size: 22px; }

/* Карточка поста (внутри swipe-content) */
.admin-post {
  padding: 14px;
}
.admin-post-header {
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px; margin-bottom: 6px;
}
.admin-post-author {
  font-weight: 700; font-size: 14px;
}
.admin-post-author small { color: var(--hint); font-weight: 500; font-size: 12px; margin-left: 4px; }
.admin-post-meta { font-size: 11px; color: var(--hint); }
.admin-post-body {
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  margin-bottom: 4px;
}

/* Полноэкранный detail-overlay (пост или юзер) */
.detail-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 80;
  overflow-y: auto;
  padding: 12px 14px calc(80px + env(safe-area-inset-bottom, 0));
  animation: detailSlide 0.2s ease-out;
}
@keyframes detailSlide { from { transform: translateX(20%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* === Глобальный поиск (только админ) === */
.global-search {
  display: flex;
  gap: 6px;
  align-items: center;
  margin: -4px 0 12px;
  position: sticky;
  top: 0;
  z-index: 30;
  padding: 6px 0;
  background: var(--bg);
}
.global-search input {
  flex: 1;
  border: 1px solid var(--separator);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: var(--bg-2);
  font-size: 14px;
}
.global-search input:focus { outline: none; border-color: var(--accent); }
.global-search-clear {
  background: var(--bg-2);
  border: 1px solid var(--separator);
  border-radius: var(--radius);
  width: 38px;
  height: 38px;
  cursor: pointer;
  color: var(--hint);
  font-size: 14px;
}

.search-post {
  border-top: 1px solid var(--separator);
  padding: 8px 0;
}
.search-post:first-of-type { border-top: none; padding-top: 0; }
.search-post-body {
  white-space: pre-wrap;
  word-wrap: break-word;
  margin: 4px 0;
}

/* === IP-адреса === */
.avatar-ip {
  background: linear-gradient(135deg, var(--accent), var(--brand-2));
  color: #fff;
}
.ip-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  word-break: break-all;
}
.list-item-ip {
  margin-top: 2px;
  font-size: 12px;
}
.list-item-ip code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--bg-2);
  padding: 1px 6px;
  border-radius: 6px;
}
.ip-list-compact {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ip-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
  border-radius: 8px;
  background: var(--bg-2);
  cursor: pointer;
  gap: 8px;
  flex-wrap: wrap;
}
.ip-row:active { opacity: 0.7; }
.ip-row-main { display: flex; align-items: center; gap: 6px; }
.ip-row-meta { font-size: 12px; }

.ip-flag {
  font-size: 22px;
  margin-left: auto;
  line-height: 1;
  flex-shrink: 0;
}

/* === User detail overlay === */
.user-detail-head {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}
.avatar-lg {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--brand-2));
  color: #fff;
  font-size: 26px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.user-detail-name {
  font-size: 18px;
  font-weight: 700;
}
.user-detail-chips {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.section-card {
  cursor: pointer;
  transition: transform 0.1s ease;
}
.section-card:active { transform: scale(0.99); }
.section-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.section-card-arrow {
  font-size: 24px;
  color: var(--hint);
  line-height: 1;
}

.btn-block { width: 100%; margin-top: 8px; }

/* === Post mini cards (внутри user-detail) === */
.post-mini {
  padding: 8px 10px;
  background: var(--bg-2);
  border-radius: 10px;
  margin-bottom: 6px;
  cursor: pointer;
}
.post-mini:active { opacity: 0.7; }
.post-mini-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--hint);
  margin-bottom: 4px;
}
.post-mini-body {
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: 14px;
  max-height: 4.5em;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  margin-bottom: 4px;
}

/* === Ranks === */
.profile-rank-block { margin-top: 12px; }
.rank-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px;
}
.rank-badge {
  font-weight: 700;
  font-size: 14px;
}
.rank-progress-bar {
  height: 8px; background: var(--bg-2); border-radius: 4px;
  overflow: hidden; margin: 6px 0;
}
.rank-progress-fill {
  height: 100%;
  background: var(--brand-grad);
  transition: width 0.4s ease;
}
.rank-next { font-size: 12px; }

/* === News (changelog) === */
.st-blue { background: rgba(36, 129, 204, 0.18); color: #2481cc; }
.news-new { border: 2px solid #ff9500; }
.news-title { margin-top: 6px; font-size: 14px; }

/* === Suspect JR === */
.jr-suspect {
  border-left: 4px solid #ff3b30;
}

/* === Schedule presets === */
.schedule-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}
.schedule-presets .preset-btn {
  padding: 8px 12px;
  font-size: 13px;
  flex: 0 0 auto;
}
.schedule-presets .preset-btn.preset-active {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

/* === Tracker card === */
.tracker-card { cursor: pointer; }
.tracker-card:active { opacity: 0.85; }
.user-row { cursor: pointer; }
.user-row:active { opacity: 0.85; }
.user-row-main { display: flex; gap: 10px; align-items: center; }

/* === Audit log === */
.audit-row { font-size: 13px; }
.audit-clickable { cursor: pointer; }
.audit-clickable:active { opacity: 0.85; }
.audit-user {
  color: var(--accent);
  cursor: pointer;
  font-weight: 600;
}
.audit-msg {
  margin-top: 6px;
  padding: 8px 10px;
  background: var(--bg-2);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  font-size: 13px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 110px;
  overflow: hidden;
}
.audit-msg-full {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--bg-2);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  font-size: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.audit-detail-section h4 { margin: 4px 0 8px; font-size: 15px; }
.audit-json {
  background: var(--bg-2);
  border-radius: 8px;
  padding: 10px;
  font-size: 12px;
  white-space: pre-wrap;
  overflow-x: auto;
}
.audit-data-pretty {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  font-size: 13px;
}
.audit-data-pair {
  background: var(--bg-2);
  padding: 2px 8px;
  border-radius: 6px;
}

/* === Ban history === */
.ban-summary {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  text-align: center;
}
.ban-summary-num {
  font-size: 20px;
  font-weight: 700;
}
.ban-row {
  border-left: 3px solid var(--bg-3, #444);
}
.ban-row-ban   { border-left-color: #ff3b30; }
.ban-row-unban { border-left-color: #34c759; }
.ban-row-mod   { border-left-color: #af52de; }
.ban-row-mute  { border-left-color: #ff9500; }
.ban-row-unmute{ border-left-color: #34c759; }
.ban-row-auto  { border-left-color: #ff9500; }
.ban-row-warn  { border-left-color: #ffcc00; }
.ban-row-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.ban-row-icon { font-size: 16px; }
.ban-row-time {
  margin-left: auto;
  font-size: 12px;
}
.ban-row-meta {
  margin-top: 6px;
  font-size: 13px;
}
.chip-red-bg {
  background: rgba(255, 59, 48, 0.15);
  border: 1px solid rgba(255, 59, 48, 0.4);
}
.chat-msg-row .chat-msg-text {
  margin-top: 6px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(127, 127, 127, 0.15);
  cursor: pointer;
}
.settings-row:last-child { border-bottom: none; }
.settings-row input[type="checkbox"] {
  width: 22px;
  height: 22px;
  cursor: pointer;
}

/* === Restriction banner === */
.restriction-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: rgba(255, 59, 48, 0.18);
  border: 1px solid rgba(255, 59, 48, 0.5);
  color: #ff3b30;
  border-radius: 12px;
  padding: 10px 14px;
  margin: 8px 0 12px;
  font-weight: 600;
  cursor: pointer;
}
.restriction-banner:active { opacity: 0.85; }
.rb-text { flex: 1; font-size: 14px; }
.rb-arrow { font-size: 20px; line-height: 1; }
.restriction-info {
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.5;
  margin: 8px 0 12px;
}

/* === Knowledge base === */
.kb-content { display: flex; flex-direction: column; gap: 8px; }
.kb-section {
  border-radius: 14px;
  padding: 0;
  overflow: hidden;
}
.kb-section summary {
  list-style: none;
  padding: 14px 16px;
  cursor: pointer;
  font-size: 15px;
}
.kb-section summary::-webkit-details-marker { display: none; }
.kb-section summary::after {
  content: "›";
  float: right;
  color: var(--hint);
  transition: transform 0.2s;
}
.kb-section[open] summary::after { transform: rotate(90deg); }
.kb-ico { margin-right: 8px; }
.kb-body {
  padding: 0 16px 14px;
  font-size: 14px;
  line-height: 1.5;
}
.kb-body p { margin: 6px 0; }
.kb-body code {
  background: var(--bg-2);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* === Poll toggle button active state === */
.poll-toggle-btn { transition: all 0.15s; }
.poll-toggle-active {
  border: 2px solid #2481cc !important;
  background: rgba(36, 129, 204, 0.12) !important;
  color: #2481cc !important;
  font-weight: 600;
}

/* === Schedule block in compose === */
.schedule-block {
  margin: 8px 0;
  padding: 10px 12px;
  background: var(--bg-2);
  border-radius: 10px;
}
.schedule-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
}
.schedule-block input[type="datetime-local"] {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--separator);
  background: var(--bg);
  font-size: 14px;
}
.schedule-hint {
  margin-top: 6px;
  font-size: 12px;
}

/* === Similar post warning === */
.similar-warn {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 59, 48, 0.12);
  border: 1px solid rgba(255, 59, 48, 0.45);
}
.similar-warn-title { font-weight: 700; color: #ff3b30; margin-bottom: 6px; }
.similar-warn-quote {
  background: var(--bg-2);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 13px;
  margin: 6px 0;
  white-space: pre-wrap;
  max-height: 100px;
  overflow: auto;
}

/* === Heatmap === */
.heatmap-wrap { overflow-x: auto; padding-top: 4px; }
.heatmap {
  display: grid;
  grid-template-columns: 32px repeat(24, 1fr);
  gap: 1px;
  min-width: 100%;
  font-size: 9px;
}
.hm-cell {
  text-align: center;
  padding: 4px 2px;
  background: var(--bg-2);
  border-radius: 3px;
  color: var(--text);
  min-width: 14px;
}
.hm-head, .hm-day { color: var(--hint); background: transparent; }

/* ============================================================= */
/* === Веб-вход (пароль + 2FA) === */
/* ============================================================= */
.web-login {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
  background:
    radial-gradient(120% 90% at 10% 0%, color-mix(in oklab, var(--accent) 22%, transparent), transparent 55%),
    radial-gradient(120% 90% at 100% 100%, rgba(108,92,231,0.20), transparent 55%),
    var(--bg);
  z-index: 200;
  animation: fadeIn 0.4s ease;
}
.web-login-card {
  width: 100%;
  max-width: 380px;
  border-radius: var(--radius-lg);
  padding: 34px 26px 28px;
  text-align: center;
  box-shadow: 0 18px 60px rgba(0,0,0,0.18);
  animation: fadeInUp 0.5s cubic-bezier(0.16,1,0.3,1);
}
.web-login-logo {
  font-size: 46px;
  line-height: 1;
  margin-bottom: 6px;
  filter: drop-shadow(0 6px 14px rgba(0,0,0,0.18));
  animation: floaty 3.2s ease-in-out infinite;
}
.web-login-title { font-size: 1.6rem; font-weight: 800; letter-spacing: 0.3px; }
.web-login-sub { color: var(--hint); margin-bottom: 22px; }
.web-login-field { margin-bottom: 12px; }
.web-login-field input {
  width: 100%;
  border: 1.5px solid var(--separator);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: var(--bg);
  font-size: 16px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.web-login-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--accent) 18%, transparent);
}
.web-login-btn { margin-top: 4px; padding: 14px; font-size: 16px; }
.web-login-error {
  color: #ff3b30;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
}
.web-login-hint { color: var(--hint); font-size: 12.5px; margin-top: 14px; line-height: 1.4; }
.web-login-footer { margin-top: 4px; font-size: 12px; opacity: 0.8; }

/* Шаг 2FA */
.web-login-2fa-anim {
  position: relative;
  width: 96px; height: 96px;
  margin: 6px auto 18px;
  display: flex; align-items: center; justify-content: center;
}
.web-login-2fa-anim .pulse-core {
  font-size: 38px;
  z-index: 1;
}
.web-login-2fa-anim .pulse-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--accent);
  animation: pulseRing 1.8s ease-out infinite;
}
.web-login-2fa-text { font-size: 1.05rem; font-weight: 700; margin-bottom: 16px; }
.web-login-code-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--hint); }
.web-login-code {
  font-family: ui-monospace, 'SF Mono', monospace;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 8px;
  padding: 8px 0 4px;
  color: var(--accent);
}

/* Кнопка в состоянии загрузки */
.btn.loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.loading::after {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  top: calc(50% - 9px); left: calc(50% - 9px);
  border: 2px solid rgba(255,255,255,0.5);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ============================================================= */
/* === Анимации === */
/* ============================================================= */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes floaty {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}
@keyframes pulseRing {
  0% { transform: scale(0.7); opacity: 0.9; }
  100% { transform: scale(1.35); opacity: 0; }
}
@keyframes shakeX {
  0%,100% { transform: translateX(0); }
  20%,60% { transform: translateX(-8px); }
  40%,80% { transform: translateX(8px); }
}
.shake { animation: shakeX 0.45s ease; }

/* Плавное появление секций при переключении */
.admin-section { animation: fadeInUp 0.32s cubic-bezier(0.16,1,0.3,1); }

/* Лёгкий «подъём» карточек и кнопок при наведении (десктоп) */
@media (hover: hover) {
  .card, .stat-card, .list-item {
    transition: transform 0.18s ease, box-shadow 0.18s ease;
  }
  .stat-card:hover, .list-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 26px rgba(0,0,0,0.12);
  }
  .nav-btn { transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease; }
  .btn { transition: transform 0.1s ease, filter 0.15s ease, box-shadow 0.15s ease; }
  .btn:hover { filter: brightness(1.05); }
}
.btn:active { transform: scale(0.97); }

/* ============================================================= */
/* === Десктопная раскладка: боковое меню вместо нижнего === */
/* ============================================================= */
.sidebar-only { display: none; }

@media (min-width: 900px) {
  .container-admin {
    max-width: 1180px;
    margin-left: 248px;
    margin-right: auto;
    padding: 28px 32px 40px;
  }

  /* Нижняя навигация → вертикальный сайдбар слева */
  #admin-nav.bottom-nav {
    flex-direction: column;
    left: 0; top: 0; right: auto; bottom: 0;
    width: 248px;
    padding: 18px 14px;
    gap: 4px;
    align-items: stretch;
    border-top: none;
    border-right: 1px solid var(--separator);
    box-shadow: 2px 0 18px rgba(0,0,0,0.05);
    overflow-y: auto;
  }
  #admin-nav .nav-btn {
    flex: 0 0 auto;
    flex-direction: row;
    justify-content: flex-start;
    gap: 14px;
    padding: 12px 16px;
    border-radius: var(--radius);
    text-align: left;
  }
  #admin-nav .nav-btn .nav-ico { font-size: 21px; width: 24px; text-align: center; }
  #admin-nav .nav-btn .nav-lbl { font-size: 15px; font-weight: 600; }
  #admin-nav .nav-btn.active {
    background: color-mix(in oklab, var(--accent) 14%, transparent);
  }
  #admin-nav .nav-btn.active::before {
    content: '';
    position: absolute;
    left: 0; top: 18%; bottom: 18%;
    width: 4px; border-radius: 0 4px 4px 0;
    background: var(--accent);
  }
  #admin-nav .nav-badge {
    position: static;
    margin-left: auto;
  }

  .sidebar-only { display: flex; }
  .sidebar-brand {
    align-items: center;
    gap: 10px;
    padding: 6px 16px 18px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--separator);
  }
  .sidebar-brand-logo { font-size: 26px; }
  .sidebar-brand-text { font-size: 1.15rem; font-weight: 800; letter-spacing: 0.2px; }
  .nav-btn-logout { margin-top: auto; color: #ff3b30 !important; }

  /* Больше воздуха и колонок на широком экране */
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .stat-value { font-size: 2.8rem; }
  .web-login-card { max-width: 420px; }
  h2 { font-size: 1.5rem; }
}

/* Очень широкие экраны — ограничиваем длину строк списков */
@media (min-width: 1500px) {
  .container-admin { max-width: 1320px; }
}

/* === Партнёрка === */
.partner-steps { margin: 8px 0 14px; padding-left: 20px; }
.partner-steps li { margin-bottom: 8px; line-height: 1.45; }
.partner-status {
  display: inline-flex; align-items: center;
  font-size: 12px; font-weight: 700;
  padding: 3px 10px; border-radius: 999px;
  background: var(--bg-2);
}
.partner-status.ps-active { background: rgba(52,199,89,0.18); color: #34c759; }
.partner-status.ps-pending { background: rgba(255,149,0,0.18); color: #ff9500; }
.partner-status.ps-rejected { background: rgba(255,59,48,0.18); color: #ff3b30; }
.partner-status.ps-disabled { background: var(--bg-2); color: var(--hint); }

/* Статистика партнёров */
.pstats-grid { display: flex; flex-wrap: wrap; gap: 6px; justify-content: space-around; text-align: center; }
.pstat { flex: 1 1 60px; }
.pstat-num { font-size: 1.6rem; font-weight: 800; color: var(--accent); }

/* Лента сообщений группового чата (админ) */
.stream-msg {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  margin-bottom: 6px;
}
.stream-msg-head { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.stream-msg-time { font-size: 11px; color: var(--hint); font-weight: 400; margin-left: 6px; }
.stream-msg-text { font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.pmod-ban {
  float: right; border: none; background: transparent; cursor: pointer;
  font-size: 15px; padding: 0 4px; opacity: 0.7; transition: opacity .15s, transform .1s;
}
.pmod-ban:hover { opacity: 1; transform: scale(1.15); }
.hm-day { text-align: left; }

/* ===================================================================== */
/* Доработки (третья волна): поля под дизайн, дашборд, учителя, заявки    */
/* ===================================================================== */

/* ТЗ 7: поля в пользовательских страницах должны быть в теме (не белые). */
.container-user select,
.container-user input[type="text"],
.container-user input[type="number"],
.container-user input[type="search"],
.container-user input[type="tel"],
.container-user input:not([type]),
.container-user textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--separator);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--bg);
  color: var(--text);
  resize: vertical;
  font-size: 15px;
  line-height: 1.45;
  margin-bottom: 10px;
  -webkit-appearance: none;
  appearance: none;
}
.container-user select {
  /* стрелка для select без нативного вида */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238e8e93' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 30px;
}
.container-user select:focus,
.container-user input:focus,
.container-user textarea:focus { outline: none; border-color: var(--accent); }
.container-user input::placeholder,
.container-user textarea::placeholder { color: var(--hint); opacity: 1; }

/* ТЗ 1–3: прогресс-строки и bar-chart на дашборде. */
.ss-row { margin: 10px 0; }
.ss-row-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.ss-bar { height: 10px; border-radius: 6px; background: var(--bg-2); overflow: hidden; }
.ss-bar-fill { height: 100%; border-radius: 6px; transition: width .4s ease; min-width: 2px; }

/* ТЗ 15/7: chip-выбор здания. */
.building-grid { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 14px; }
.building-opt {
  flex: 1 1 calc(50% - 8px);
  padding: 14px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--separator);
  background: var(--bg-2);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  text-align: center;
  transition: all .15s ease;
}
.building-opt.active {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
  font-weight: 600;
}

/* ТЗ 13: фильтр-чипы и список учителей в задании. */
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.fchip {
  padding: 6px 10px;
  border-radius: 14px;
  border: 1px solid var(--separator);
  background: var(--bg-2);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}
.fchip.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.ti-results { max-height: 260px; overflow-y: auto; margin-bottom: 8px; }
.ti-opt {
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--separator);
  margin-bottom: 6px;
  cursor: pointer;
  background: var(--bg);
}
.ti-opt.active { border-color: var(--accent); background: color-mix(in oklab, var(--accent) 10%, var(--bg)); }
.ti-opt-name { font-weight: 600; font-size: 14px; }
.ti-opt-sub { font-size: 12px; }
.ti-selected { margin: 4px 0 10px; }

/* ТЗ 12: прикрепление фото. */
.attach-field { margin-bottom: 10px; }
.attach-previews { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.attach-thumb { position: relative; width: 72px; height: 72px; }
.attach-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; border: 1px solid var(--separator); }
.attach-thumb button {
  position: absolute; top: -6px; right: -6px;
  width: 22px; height: 22px; border-radius: 50%;
  border: none; background: #ff3b30; color: #fff; cursor: pointer; font-size: 12px;
}

/* ТЗ 14: подсказки админу. */
.task-hints { margin-top: 8px; border-top: 1px dashed var(--separator); padding-top: 8px; }
.hint-block { margin-bottom: 8px; font-size: 13px; }
.app-task-subbar { margin-top: 8px; }

/* ТЗ 5: списочные блоки журнала. */
.audit-data-list { margin-top: 4px; font-size: 13px; }
.tch-photos { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.tch-photo { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; }

/* ===== Доработки (четвёртая волна): фильтры заданий, разбор, чат-вью ===== */
/* Сворачиваемые фильтры выбора учителя (ТЗ 3) */
.ti-filter-bar { display: flex; gap: 8px; margin: 6px 0; }
.fbtn {
  flex: 1; padding: 10px; border-radius: var(--radius);
  border: 1px solid var(--separator); background: var(--bg-2);
  color: var(--text); font-size: 13px; cursor: pointer;
}
.fbtn span { color: var(--accent); font-weight: 600; }

/* Миниатюры фото в карточках/подсказках (ТЗ 7) */
.att-thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.att-thumb-sm { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; border: 1px solid var(--separator); }

/* Разбор задания по пунктам (ТЗ 7) */
.tr-field { margin-bottom: 10px; }
.tr-field-lbl { font-size: 12px; color: var(--hint); margin-bottom: 4px; }
.tr-opt {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px;
  border: 1px solid var(--separator); border-radius: 8px; margin-bottom: 4px;
}
.tr-opt input[type="checkbox"] { width: 20px; height: 20px; }

/* Подсветка нарушителя в просмотре чата (ТЗ 20) */
.stream-msg-flag { background: color-mix(in oklab, #ff9500 22%, var(--bg-2)); border-radius: 8px; }
.hint-same { color: var(--accent) !important; font-weight: 600; }

/* === Чёрный список проекта (ЧС) === */
.bl-card { display: flex; gap: 12px; align-items: center; cursor: pointer; }
.bl-photo {
  width: 56px; height: 56px; border-radius: 12px; object-fit: cover;
  flex-shrink: 0; border: 1px solid var(--separator);
}
.bl-photo-ph {
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; background: var(--bg-2);
}
.bl-card-body { flex: 1; min-width: 0; }
.bl-card-title { font-weight: 600; margin-bottom: 2px; }
.bl-card-reason {
  font-size: 13px; margin-bottom: 6px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.bl-oval {
  display: inline-block; padding: 3px 12px; border-radius: 999px;
  background: color-mix(in oklab, #ff3b30 18%, var(--bg-2));
  color: var(--text); font-size: 12px; font-weight: 600;
}
.bl-detail-photo {
  width: 100%; max-height: 260px; object-fit: contain;
  border-radius: 12px; margin-bottom: 10px; background: var(--bg-2);
}
.bl-detail-title { font-size: 18px; font-weight: 700; margin-bottom: 10px; text-align: center; }

/* ===================================================================== */
/* === Premium-native polish (2026-06-01) ===                            */
/* Надстройка над базой: глубина, единый ритм, типографика и микро-       */
/* взаимодействия. Только токены и СУЩЕСТВУЮЩИЕ классы — DOM и JS не       */
/* трогаются. Блок идёт последним: при равной специфичности аккуратно     */
/* усиливает уже описанные компоненты. Тема (свет/тьма Telegram, forced-  */
/* dark админки) полностью наследуется через переменные.                  */
/* ===================================================================== */

/* — Сглаживание шрифтов + приятное выделение текста — */
html, body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
::selection { background: color-mix(in oklab, var(--accent) 26%, transparent); }

/* — Цифры таблично-моноширинные: статы/счётчики не «прыгают» по ширине — */
.stat-value, .ban-summary-num, .pstat-num, .hm-cell { font-variant-numeric: tabular-nums; }
.stat-value, .pstat-num { letter-spacing: -0.02em; }

/* — Hairline-границы: глубина без тяжёлых теней (особенно в тёмной теме).
     Стекло (.glass) и предупреждающие карточки (.card-warn) не трогаем —
     у них своя рамка. — */
.card:not(.glass):not(.card-warn),
.stat-card:not(.glass),
.post-card:not(.glass),
.profile-card:not(.glass),
.list-item,
.web-login-card:not(.glass) {
  border: 1px solid var(--card-border);
}

/* — Кнопки: мягкая «цветная» тень у основной, ровный радиус, focus-ring — */
.btn { border-radius: var(--radius); }
.btn-primary {
  box-shadow: 0 1px 2px rgba(0,0,0,.06),
              0 6px 16px color-mix(in oklab, var(--accent) 28%, transparent);
}
.btn-primary:active {
  box-shadow: 0 1px 4px color-mix(in oklab, var(--accent) 24%, transparent);
}
.btn-secondary { background: var(--accent-soft); }
.btn:focus-visible,
.filter-btn:focus-visible,
.nav-btn:focus-visible,
.list-item:focus-visible { outline: none; box-shadow: var(--ring); }
/* У основной кнопки фокус-кольцо НЕ должен затирать её тень-возвышение
   (box-shadow не суммируется между правилами) — задаём оба слоя вместе. */
.btn-primary:focus-visible {
  box-shadow: var(--ring),
              0 6px 16px color-mix(in oklab, var(--accent) 28%, transparent);
}

/* — Hero: фирменный градиент + глубина + чуть больше «воздуха» — */
.hero {
  background: var(--brand-grad);
  border-radius: var(--radius-xl);
  padding: 30px 18px 26px;
  box-shadow: 0 10px 30px color-mix(in oklab, var(--accent) 26%, transparent);
}
.hero-title { font-size: 23px; }

/* — Карточки статистики: тоньше верхняя полоса, мягкая тень, ровный радиус — */
.stat-card { border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.stat-card::before { height: 3px; opacity: .92; }
.stat-label { letter-spacing: 0.7px; }

/* — Поля ввода: единый плавный focus-ring во всех контекстах — */
.search-bar input:focus, .search-bar input[type="text"]:focus,
.global-search input:focus,
.container-user input:focus, .container-user textarea:focus, .container-user select:focus,
.modal input:focus, .modal textarea:focus, .modal select:focus,
.admin-section input:focus, .admin-section textarea:focus,
.chat-input input:focus, #rules-editor:focus, #create-tracker-form input:focus {
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.search-bar input, .global-search input,
.container-user input, .container-user textarea, .container-user select,
.modal input, .modal textarea, .chat-input input {
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

/* — Нижняя навигация: анимированный индикатор активного раздела.
     Через ::after (top-bar) — layout-safe даже при 9 пунктах юзер-меню;
     десктопный сайдбар админки использует ::before, конфликта нет. — */
@media (max-width: 899px) {
  .bottom-nav .nav-btn { transition: color .18s ease; }
  .bottom-nav .nav-btn::after {
    content: '';
    position: absolute; top: 0; left: 50%;
    width: 20px; height: 3px; border-radius: 0 0 3px 3px;
    background: var(--accent);
    transform: translateX(-50%) scaleX(0);
    transition: transform .22s cubic-bezier(.2,.7,.2,1);
  }
  .bottom-nav .nav-btn.active::after { transform: translateX(-50%) scaleX(1); }
  .bottom-nav .nav-btn.active .nav-ico { transform: translateY(-1px); }
  .bottom-nav .nav-btn .nav-ico { transition: transform .15s ease; }
}

/* — Модалка: нативная «ручка» сверху + глубокая тень — */
.modal { box-shadow: var(--shadow-lg); }
.modal::before {
  content: '';
  display: block; width: 38px; height: 4px;
  border-radius: 999px; background: var(--separator);
  margin: -4px auto 12px;
}

/* — FAB: тень в цвет акцента — */
.fab { box-shadow: 0 8px 22px color-mix(in oklab, var(--accent) 40%, transparent); }
@media (hover: hover) { .fab:hover { filter: brightness(1.06); } }

/* — Чипы/фильтры: ровные пропорции и плавность — */
.chip { padding: 3px 9px; }
.filter-btn { transition: background .15s ease, color .15s ease, border-color .15s ease; }

/* — Прогресс-бары (ранги, школьная статистика) — фирменный градиент — */
.rank-progress-fill { background: var(--brand-grad); }

/* — Пустые состояния: спокойный приглушённый тон — */
.empty-state { color: var(--hint); font-size: 15px; line-height: 1.5; }

/* — Списки: чуть выразительнее тап — */
.list-item { transition: background .15s ease, transform .1s ease, box-shadow .18s ease; }
.list-item:active { transform: scale(.99); }

/* — Аккуратные тонкие скроллбары на десктопе (админка) — */
@media (min-width: 900px) {
  * { scrollbar-width: thin; scrollbar-color: var(--separator) transparent; }
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-thumb {
    background: var(--separator); border-radius: 999px;
    border: 2px solid transparent; background-clip: content-box;
  }
  ::-webkit-scrollbar-thumb:hover { background: var(--hint); background-clip: content-box; }
}

/* ===================================================================== */
/* === Движение / анимации (расширенный слой, 2026-06-01) ===            */
/* Живые входы, стаггер-каскады, тактильный отклик и тонкие «дышащие»     */
/* акценты. Только transform/opacity (GPU). Чат-пузыри и fixed-экран чата */
/* не анимируем (перерисовка по поллингу). Ниже prefers-reduced-motion —  */
/* он глушит всё это для тех, кому нужно.                                 */
/* ===================================================================== */

/* — Вход страницы при переключении (кроме fixed-чата) — */
.page:not(.page-chat-fixed) { animation: pageEnter .34s cubic-bezier(.16,1,.3,1) both; }
@keyframes pageEnter { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* — Каскадный вход списков, карточек и плиток статистики.
     fill-mode: backwards — прячем элемент до старта (без вспышки), но НЕ
     удерживаем финальный transform, чтобы :active/:hover после входа работали. — */
.list > *, .stats-grid > *, .page > .card {
  animation: riseIn .42s cubic-bezier(.16,1,.3,1) backwards;
}
@keyframes riseIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.stats-grid > * { animation-name: popIn; }
@keyframes popIn { 0% { opacity: 0; transform: scale(.92) translateY(10px); } 60% { opacity: 1; } 100% { opacity: 1; transform: none; } }
/* стаггер первых элементов (дальше — без задержки, чтобы длинные списки не тормозили) */
.list > *:nth-child(1), .stats-grid > *:nth-child(1) { animation-delay: .02s; }
.list > *:nth-child(2), .stats-grid > *:nth-child(2) { animation-delay: .06s; }
.list > *:nth-child(3), .stats-grid > *:nth-child(3) { animation-delay: .10s; }
.list > *:nth-child(4), .stats-grid > *:nth-child(4) { animation-delay: .14s; }
.list > *:nth-child(5) { animation-delay: .18s; }
.list > *:nth-child(6) { animation-delay: .22s; }
.list > *:nth-child(7) { animation-delay: .26s; }
.list > *:nth-child(8) { animation-delay: .30s; }
/* Списки с live-поиском перерисовываются на каждый ввод — каскад на них
   «дёргал» бы результаты заново при каждом нажатии. Отключаем у них вход
   (плавный fade самой страницы остаётся). */
#users-list > *, #bl-list > * { animation: none; }

/* — Hero: живой переливающийся градиент + парящий смайл — */
.hero {
  background: linear-gradient(120deg, var(--accent), var(--brand-2), var(--accent));
  background-size: 220% 220%;
  animation: heroGlow 11s ease-in-out infinite alternate;
}
@keyframes heroGlow { 0% { background-position: 0% 50%; } 100% { background-position: 100% 50%; } }
.hero-emoji { animation: bob 3.4s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }

/* — Нижняя навигация: въезд снизу + «прыжок» иконки активного пункта.
     navBarIn — ТОЛЬКО на мобильной раскладке: на десктопе #admin-nav — это
     ЛЕВЫЙ сайдбар, и въезд снизу (translateY 100%) выглядел бы неверно. — */
@keyframes navBarIn { from { transform: translateY(100%); } to { transform: none; } }
@media (max-width: 899px) {
  .bottom-nav { animation: navBarIn .42s cubic-bezier(.16,1,.3,1) both; }
  .bottom-nav .nav-btn.active .nav-ico { animation: navPop .34s cubic-bezier(.2,.8,.2,1.4); }
}
@keyframes navPop {
  0% { transform: translateY(-1px) scale(.8); }
  60% { transform: translateY(-1px) scale(1.18); }
  100% { transform: translateY(-1px) scale(1); }
}

/* — Бейджи непрочитанного/нового: мягкая пульсация привлекает взгляд — */
.nav-badge, .badge { animation: badgePulse 2.4s ease-in-out infinite; transform-origin: center; }
@keyframes badgePulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }

/* — FAB: эффектный въезд — */
.fab { animation: fabIn .5s cubic-bezier(.2,.8,.2,1.4) both; }
@keyframes fabIn {
  0% { opacity: 0; transform: scale(.3) rotate(-25deg); }
  70% { transform: scale(1.1) rotate(4deg); }
  100% { opacity: 1; transform: none; }
}

/* — Первичная кнопка: блик при наведении (десктоп). ::after у .loading занят
     спиннером — поэтому строго :not(.loading), чтобы не сломать загрузку. — */
.btn-primary:not(.loading) { position: relative; overflow: hidden; }
.btn-primary:not(.loading)::after {
  content: ''; position: absolute; top: 0; bottom: 0; left: 0; width: 45%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.38), transparent);
  transform: translateX(-160%) skewX(-18deg);
  pointer-events: none;
}
@media (hover: hover) {
  .btn-primary:not(.loading):hover::after { animation: sheen .7s ease; }
}
@keyframes sheen { to { transform: translateX(260%) skewX(-18deg); } }

/* — Прогресс-бары (ранг, школьная статистика): бегущий блик поверх заливки — */
.rank-progress-fill, .ss-bar-fill { position: relative; overflow: hidden; }
.rank-progress-fill::after, .ss-bar-fill::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.45), transparent);
  transform: translateX(-100%);
  animation: barShimmer 2.2s ease-in-out infinite;
}
@keyframes barShimmer { 0% { transform: translateX(-100%); } 60%, 100% { transform: translateX(260%); } }

/* — Баннер ограничения: мягкий «зов внимания» — */
.restriction-banner { animation: attn 2.6s ease-in-out infinite; }
@keyframes attn {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,59,48,0); }
  50% { box-shadow: 0 0 0 4px rgba(255,59,48,.16); }
}

/* — Модалка: фон проявляется плавно — */
.modal-backdrop { animation: fadeIn .22s ease; }

/* — Карточки на десктопе: ощутимее «подъём» при наведении — */
@media (hover: hover) {
  .card, .post-card, .bl-card, .task-card, .tracker-card, .section-card {
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  }
  /* Подъём — только у кликабельных карточек, не у статичных инфо-блоков. */
  .section-card:hover, .task-card:hover, .bl-card:hover, .tracker-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
  }
  .filter-btn:hover, .school-subtab:hover, .fchip:hover { transform: translateY(-1px); }
}

/* — Тактильный отклик на тап (мобильный) — */
.btn:active { transform: scale(.96); }
.filter-btn:active, .nav-btn:active, .chip:active, .building-opt:active { transform: scale(.94); }

/* — Бодрее активные контролы: фирменный градиент вместо плоского акцента — */
.filter-btn.active, .school-subtab.active, .fchip.active {
  background: var(--brand-grad); border-color: transparent; color: #fff;
}
.mode-opt:has(input:checked) { background: var(--accent-soft); }
.building-opt.active { background: var(--brand-grad); border-color: transparent; }

/* — Пауза всех анимаций, когда мини-апп скрыт (фон/свёрнут): экономия батареи
     и CPU. Класс .anim-paused вешает app.js по visibilitychange. — */
html.anim-paused *,
html.anim-paused *::before,
html.anim-paused *::after { animation-play-state: paused !important; }

/* ===================================================================== */
/* === Уточнение дизайна (2026-07-11) ===                                */
/* Ещё один слой премиум-полировки: объём аватаров, «дорогие» поверхности */
/* в тёмных темах, единый вторичный бренд-цвет (--brand-2) во всех темах  */
/* вместо раскиданного #6c5ce7. Только токены и СУЩЕСТВУЮЩИЕ классы —      */
/* DOM/JS не трогаются; блок статичный (без анимаций).                    */
/* ===================================================================== */

/* — Аватары/инициалы: мягкий объём (верхний внутренний блик + тень) и    */
/*    читаемая инициал/иконка поверх градиента. —                         */
.avatar, .avatar-lg, .avatar-ip, .profile-avatar {
  box-shadow: inset 0 1px 1.5px rgba(255,255,255,.30), 0 2px 8px rgba(0,0,0,.16);
  text-shadow: 0 1px 2px rgba(0,0,0,.20);
}

/* — Тёмные темы (Telegram-dark и forced-dark админки): тонкий верхний     */
/*    блик на карточках/статах/постах — глубина «стекла» без тяжёлых теней */
/*    и без потери контраста текста. Стекло и warning-карточки не трогаем. */
[data-color-scheme="dark"] .card:not(.glass):not(.card-warn),
[data-color-scheme="dark"] .stat-card:not(.glass),
[data-color-scheme="dark"] .post-card:not(.glass),
[data-color-scheme="dark"] .list-item,
[data-theme="dark"] .card:not(.glass):not(.card-warn),
[data-theme="dark"] .stat-card:not(.glass),
[data-theme="dark"] .post-card:not(.glass),
[data-theme="dark"] .list-item {
  background-image: linear-gradient(180deg, rgba(255,255,255,.035), transparent 42%);
}

/* — Верхняя полоса карточек-статов по умолчанию — фирменный градиент      */
/*    (семантические .stat-blue/orange/violet/red сохраняют свой цвет). —  */
.stat-card:not(.stat-blue):not(.stat-orange):not(.stat-violet):not(.stat-red)::before {
  background: var(--brand-grad);
}

/* — Вторичная кнопка: чуть насыщеннее при наведении (десктоп). —          */
@media (hover: hover) {
  .btn-secondary:hover { background: color-mix(in oklab, var(--accent) 22%, var(--bg)); }
}

/* — Пустые состояния: больше воздуха, спокойнее тон. —                    */
.empty-state { padding: 48px 22px; }

/* — Уважение к системной настройке «меньше движения» — */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* === Диалоги Mini App (замена prompt/confirm, ТЗ 6.2) === */
/* Пока диалог открыт — фон не скроллим: на iOS прокрутка «пробивала» модалку
   и уводила страницу, из-за чего казалось, что интерфейс живёт своей жизнью. */
html.uidlg-open, html.uidlg-open body { overflow: hidden; }

.uidlg { background: var(--surface); color: var(--text); }
.uidlg-text {
  color: var(--hint);
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 12px;
  white-space: pre-line;
}
.uidlg-hint { font-size: 12px; margin: -6px 0 12px; }
.uidlg .form-label {
  display: block;
  font-size: 12px;
  color: var(--hint);
  margin-bottom: 6px;
}
.uidlg-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin: -6px 0 12px;
}
.uidlg-chip {
  border: 1px solid var(--separator);
  background: var(--bg-2);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.uidlg-chip:hover { border-color: var(--accent); }
.uidlg-chip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  font-weight: 600;
}
.uidlg-check {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px;
  cursor: pointer;
}
.uidlg-check input { width: 22px; height: 22px; flex-shrink: 0; }
.uidlg-error {
  background: color-mix(in oklab, #ff3b30 12%, transparent);
  border: 1px solid color-mix(in oklab, #ff3b30 40%, transparent);
  color: #ff6b60;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 10px;
}
.uidlg-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 4px;
}
.uidlg-actions .btn { flex: 1; margin: 0; }

/* === Тосты === */
#toast-host {
  position: fixed;
  left: 50%;
  bottom: calc(76px + env(safe-area-inset-bottom, 0));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 120;
  pointer-events: none;
  width: min(92vw, 520px);
}
.toast {
  background: color-mix(in oklab, var(--text) 88%, transparent);
  color: var(--bg);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 14px;
  text-align: center;
  box-shadow: var(--shadow-md);
  animation: toastIn .2s ease-out, toastOut .3s ease-in 2.6s forwards;
}
.toast-error { background: #ff3b30; color: #fff; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px); } }

/* ═══════════════════════════════════════════════════════════════════════
   Чат Mini App (ТЗ 6.1) — визуально повторяет нативный Telegram.
   Префикс cx- изолирует компонент: он переиспользуется и для чата с
   админом, и в будущем для P2P-переписок (см. chat-ui.js).
   ═══════════════════════════════════════════════════════════════════════ */
.cx {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  background: var(--bg-2);
  border-radius: var(--radius);
  overflow: hidden;
}

/* --- Шапка: аватар, имя, статус --- */
.cx-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--separator);
  flex-shrink: 0;
}
.cx-back, .cx-profile {
  border: none; background: transparent; color: var(--accent);
  font-size: 22px; line-height: 1; cursor: pointer;
  width: 32px; height: 32px; flex-shrink: 0;
}
.cx-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--brand-grad); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; flex-shrink: 0;
}
.cx-headinfo { flex: 1; min-width: 0; }
.cx-title {
  font-weight: 600; font-size: 15px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cx-status {
  font-size: 12px; color: var(--hint);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: color .2s ease;
}
.cx-status.cx-online { color: var(--accent); }

/* --- Лента --- */
.cx-scroll {
  flex: 1; min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 10px 4px;
  overscroll-behavior: contain;
}
.cx-list { display: flex; flex-direction: column; }
.cx-empty { color: var(--hint); text-align: center; padding: 32px 12px; font-size: 14px; }

/* Разделитель дня — «плашка» поверх фона, как в Telegram. */
.cx-day { display: flex; justify-content: center; margin: 12px 0 8px; }
.cx-day span {
  background: color-mix(in oklab, var(--text) 10%, transparent);
  color: var(--text);
  font-size: 12px; font-weight: 600;
  padding: 3px 12px; border-radius: 999px;
  backdrop-filter: blur(6px);
}

.cx-row { display: flex; margin-top: 2px; }
.cx-out-row { justify-content: flex-end; }
.cx-in-row { justify-content: flex-start; }
/* Между сериями от разных сторон — воздух побольше. */
.cx-out-row + .cx-in-row, .cx-in-row + .cx-out-row { margin-top: 10px; }

.cx-bubble {
  position: relative;
  max-width: min(78%, 460px);
  padding: 7px 11px 6px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.38;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  box-shadow: 0 1px 1px rgba(16,18,24,.06);
}
.cx-in { background: var(--surface); color: var(--text); border-bottom-left-radius: 16px; }
.cx-out { background: var(--accent); color: var(--accent-text); border-bottom-right-radius: 16px; }

/* Хвостик — только у последнего сообщения серии (ставит chat-ui.js). */
.cx-in.cx-tail { border-bottom-left-radius: 5px; }
.cx-out.cx-tail { border-bottom-right-radius: 5px; }
.cx-tail::after {
  content: '';
  position: absolute; bottom: 0;
  width: 12px; height: 14px;
}
.cx-in.cx-tail::after {
  left: -6px;
  background: radial-gradient(circle at 100% 0, transparent 12px, var(--surface) 12px);
}
.cx-out.cx-tail::after {
  right: -6px;
  background: radial-gradient(circle at 0 0, transparent 12px, var(--accent) 12px);
}

.cx-text { white-space: pre-wrap; }
.cx-text a { color: inherit; text-decoration: underline; }
.cx-out .cx-text a { color: #fff; }

/* Время и галочки — «вплывают» в правый нижний угол баббла. */
.cx-meta {
  float: right;
  margin: 6px -3px -2px 8px;
  font-size: 11px;
  opacity: .65;
  white-space: nowrap;
  user-select: none;
}
.cx-ticks { margin-left: 3px; letter-spacing: -2px; }
.cx-ticks.cx-read { opacity: 1; }

/* Появление нового сообщения. Короткое и без «прыжка» — на длинной ленте
   любая заметная анимация читается как лаг. */
.cx-new { animation: cxIn .18s ease-out; }
@keyframes cxIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* --- «печатает…» --- */
.cx-typing { display: flex; padding: 2px 0 6px; }
.cx-typing-bubble { display: inline-flex; gap: 4px; align-items: center; padding: 11px 14px; }
.cx-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--hint);
  animation: cxDot 1.2s infinite ease-in-out;
}
.cx-dot:nth-child(2) { animation-delay: .18s; }
.cx-dot:nth-child(3) { animation-delay: .36s; }
@keyframes cxDot {
  0%, 60%, 100% { opacity: .3; transform: translateY(0); }
  30%           { opacity: 1;  transform: translateY(-3px); }
}

/* --- Вложения --- */
.cx-img, .cx-vid { display: block; max-width: 260px; max-height: 320px; border-radius: 12px; cursor: pointer; }
.cx-note { display: block; width: 190px; height: 190px; border-radius: 50%; object-fit: cover; }
.cx-audio { display: block; width: 240px; max-width: 100%; }
.cx-sticker { display: block; max-width: 140px; max-height: 140px; }
.cx-file {
  display: inline-block; padding: 6px 10px; border-radius: 10px;
  background: rgba(127,127,127,.14); color: inherit; text-decoration: none;
  word-break: break-word;
}
.cx-img + .cx-text, .cx-vid + .cx-text, .cx-note + .cx-text,
.cx-audio + .cx-text, .cx-file + .cx-text { margin-top: 6px; }

/* --- Поле ввода --- */
.cx-extra:empty { display: none; }
.cx-extra {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 8px 12px 0;
  background: var(--surface);
}
.cx-compose {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0));
  background: var(--surface);
  border-top: 1px solid var(--separator);
  flex-shrink: 0;
}
.cx-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--separator);
  border-radius: 20px;
  padding: 10px 14px;
  background: var(--bg-2);
  color: var(--text);
  font-size: 15px;
  line-height: 1.35;
  max-height: 140px;
  font-family: inherit;
}
.cx-input:focus { outline: none; border-color: var(--accent); }
.cx-send, .cx-attach {
  width: 40px; height: 40px; flex-shrink: 0;
  border: none; border-radius: 50%;
  font-size: 18px; cursor: pointer;
  transition: transform .12s ease, opacity .12s ease;
}
.cx-send { background: var(--accent); color: var(--accent-text); }
.cx-send:active { transform: scale(.92); }
.cx-send:disabled { opacity: .5; cursor: default; }
.cx-attach { background: var(--bg-2); color: var(--text); border: 1px solid var(--separator); font-size: 19px; }

/* Высота контейнера чата: на весь экран минус нижняя навигация. */
.cx-host {
  height: calc(100dvh - 150px);
  min-height: 320px;
}

/* Чат у пользователя занимает страницу целиком (нижняя навигация остаётся). */
.cx-host-full { height: calc(100dvh - 64px); border-radius: 0; }
.page-chat-fixed { padding: 0; }

/* Цитаты в карточках заявок (комментарий, «было/стало» у правки). */
.app-quote {
  margin: 6px 0;
  padding: 8px 12px;
  border-left: 3px solid var(--accent);
  background: var(--bg-2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  white-space: pre-wrap;
  font-size: 14px;
}
.app-quote-old { border-left-color: var(--hint); color: var(--hint); }

/* Анонимные комментарии в карточке поста (админка). */
.post-comment {
  padding: 8px 0;
  border-bottom: 1px solid var(--separator);
}
.post-comment:last-child { border-bottom: none; }
.post-comment-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.post-comment-text { white-space: pre-wrap; margin-bottom: 4px; }

/* === Пост целиком в Mini App (кнопка «Открыть полностью») === */
.post-body-full { white-space: pre-wrap; font-size: 15px; line-height: 1.55; }
#post-view-media { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.post-media-img, .post-media-vid {
  display: block; width: 100%; max-height: 70vh;
  object-fit: contain; border-radius: var(--radius);
  background: var(--bg-2); cursor: pointer;
}
.post-media-note {
  display: block; width: 220px; height: 220px;
  border-radius: 50%; object-fit: cover; align-self: center;
}
.post-media-audio { display: block; width: 100%; }
.post-media-sticker { display: block; max-width: 160px; align-self: center; }
.post-media-file {
  display: block; padding: 12px 14px;
  border-radius: var(--radius); background: var(--bg-2);
  color: var(--text); text-decoration: none; word-break: break-word;
}
