/* ============================================================
   app.css — тёмная тема в стиле Crypto Bot (Telegram Mini App)
   Все цвета — через CSS-переменные с fallback (их подхватывает JS
   из Telegram.WebApp.themeParams для тёмной темы).
   ============================================================ */

:root {
  /* Базовая палитра (fallback) */
  --bg: #0E1013;
  --card: #1A1D21;
  --card2: #17191D;
  --border: rgba(255, 255, 255, 0.06);
  --text: #FFFFFF;
  --text2: rgba(255, 255, 255, 0.55);
  --text3: rgba(255, 255, 255, 0.32);
  --accent: #3390EC;
  --accent-soft: rgba(51, 144, 236, 0.16);
  --btn-text: #FFFFFF;
  --green: #4FD166;
  --red: #F0616D;
  --orange: #FFA84C;
  --purple: #A678F0;

  --radius: 16px;
  --radius-lg: 20px;
  --topbar-h: 56px;
  --tabbar-h: 62px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* Нативные контролы (date/time picker) — тёмные */
  color-scheme: dark;

  font-size: 16px;
}

/* ============================================================
   Светлая тема (переключатель в Профиле)
   ============================================================ */
[data-theme="light"] {
  --bg: #F1F2F6;
  --card: #FFFFFF;
  --card2: #E9EBEF;
  --border: rgba(0, 0, 0, 0.08);
  --text: #17212B;
  --text2: rgba(23, 33, 43, 0.55);
  --text3: rgba(23, 33, 43, 0.35);
  --accent: #3390EC;
  --accent-soft: rgba(51, 144, 236, 0.12);
  --btn-text: #FFFFFF;
  --green: #2EAF4D;
  --red: #E04854;
  --orange: #E08A28;
  --purple: #8B5CF6;
  color-scheme: light;
}

/* Светлая тема: карточки с мягкой тенью вместо светлой рамки */
[data-theme="light"] .card,
[data-theme="light"] .status-card {
  box-shadow: 0 1px 3px rgba(23, 33, 43, 0.08);
}

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

/* Атрибут hidden должен побеждать любые display-правила классов */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body { min-height: 100vh; }

button, input, textarea, select {
  font-family: inherit;
  color: inherit;
}

button { cursor: pointer; }

#shell {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
}

/* ============================================================
   Верхняя панель
   ============================================================ */
#topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  background: rgba(14, 16, 19, 0.92); /* fallback без color-mix */
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding-top: var(--safe-top);
}

.topbar-inner {
  max-width: 560px;
  margin: 0 auto;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 10px 0 14px;
}

#topbar-title {
  flex: 1;
  margin: 0;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#topbar-actions { display: flex; align-items: center; gap: 2px; }

/* Кнопки-иконки ≥44px */
.icon-btn {
  min-width: 44px;
  height: 44px;
  padding: 0 10px;
  display: inline-grid;
  place-items: center;
  font-size: 20px;
  line-height: 1;
  background: transparent;
  border: none;
  border-radius: 12px;
  color: var(--accent);
}
.icon-btn:active { background: var(--accent-soft); }
.icon-btn.muted { color: var(--text2); }

/* Бейдж «офлайн» в шапке */
.offline-badge {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  color: var(--orange);
  background: rgba(255, 168, 76, 0.14);
  border: 1px solid rgba(255, 168, 76, 0.35);
  border-radius: 999px;
  padding: 3px 9px;
  margin-right: 6px;
  white-space: nowrap;
}

/* ============================================================
   Основная область и экраны
   ============================================================ */
#main {
  padding-top: calc(var(--topbar-h) + var(--safe-top) + 12px);
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 24px);
  min-height: 100vh;
}

.screen { display: none; }
.screen.active { display: block; }

.screen-body {
  padding: 0 14px;
  animation: fadeIn 0.18s ease;
}

.screen-subtitle {
  font-size: 17px;
  font-weight: 700;
  color: var(--text2);
  margin: 2px 2px 12px;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* ============================================================
   Карточки и списки
   ============================================================ */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  margin: 0 0 10px;
  text-transform: none;
}

.section-title {
  font-size: 18px;
  font-weight: 700;
  margin: 20px 2px 10px;
}

.list { display: flex; flex-direction: column; }

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--border);
  min-height: 52px;
}
.row:last-child { border-bottom: none; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-size: 15px; font-weight: 600; }
.row-sub { font-size: 13px; color: var(--text2); margin-top: 2px; }

/* Строка-раздел (списки «Админ» / «Супер» / дни) */
.list-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 58px;
  padding: 8px 4px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  color: inherit;
  text-align: left;
}
.list-btn:last-child { border-bottom: none; }
.list-btn:active { background: rgba(255, 255, 255, 0.03); }

/* Небольшая цветная иконка в списке */
.mini-ico {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 19px;
  flex-shrink: 0;
}

.muted { color: var(--text2); }
.small { font-size: 13px; }
.green { color: var(--green); }
.red { color: var(--red); }
.orange { color: var(--orange); }
.blue { color: var(--accent); }

/* Бейджи */
.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--card2);
  border: 1px solid var(--border);
  color: var(--text2);
  white-space: nowrap;
}
.badge.blue { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge.green { background: rgba(79, 209, 102, 0.14); color: var(--green); border-color: transparent; }
.badge.red { background: rgba(240, 97, 109, 0.14); color: var(--red); border-color: transparent; }
.badge.orange { background: rgba(255, 168, 76, 0.14); color: var(--orange); border-color: transparent; }
.badge.purple { background: rgba(166, 120, 240, 0.16); color: var(--purple); border-color: transparent; }

/* Номер пары — квадратный бейдж */
.num-badge {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 700;
  background: var(--accent-soft);
  color: var(--accent);
}
.num-badge.grey { background: rgba(255,255,255,0.07); color: var(--text2); }
.num-badge.red { background: rgba(240, 97, 109, 0.16); color: var(--red); }

/* ============================================================
   Кнопки
   ============================================================ */
.btn {
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card2);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn:active { opacity: 0.75; }
.btn:disabled { opacity: 0.45; pointer-events: none; }

.btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--btn-text);
}

.btn-danger { color: var(--red); }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-block { width: 100%; margin-bottom: 12px; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 13px; border-radius: 10px; }

.btn-row { display: flex; gap: 8px; margin-bottom: 10px; }
.btn-row .btn { flex: 1; }

/* ============================================================
   Чипы (переключатели)
   ============================================================ */
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 12px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  min-height: 38px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text2);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.chip.active {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}

/* ============================================================
   Статус-карточка (Главная)
   ============================================================ */
.status-card {
  position: relative;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 18px 16px;
  margin-bottom: 12px;
}
.status-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 90px;
  background: linear-gradient(180deg, rgba(255,255,255,0.05), transparent);
  pointer-events: none;
}
.status-card.st-lesson::before { background: linear-gradient(180deg, rgba(51,144,236,0.28), transparent); }
.status-card.st-cancel::before { background: linear-gradient(180deg, rgba(240,97,109,0.28), transparent); }
.status-card.st-break::before { background: linear-gradient(180deg, rgba(255,255,255,0.07), transparent); }
.status-card.st-weekend::before,
.status-card.st-finished::before { background: linear-gradient(180deg, rgba(255,255,255,0.05), transparent); }

.status-top { display: flex; align-items: center; gap: 12px; position: relative; }
.status-ico { font-size: 34px; line-height: 1; }
.status-big {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.05;
}
.status-sub { font-size: 15px; color: var(--text2); margin-top: 4px; }
.status-meta { font-size: 14px; color: var(--text3); margin-top: 2px; }
.status-next {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 14px;
  color: var(--text2);
}
.status-timer {
  margin-top: 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
}
.status-card.st-cancel .status-timer { color: var(--red); }
.status-card.st-break .status-timer { color: var(--text2); }
.status-card.st-weekend .status-timer,
.status-card.st-finished .status-timer { color: var(--text2); }

/* ============================================================
   Пары (расписание)
   ============================================================ */
.lesson {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.lesson:last-child { border-bottom: none; }
.lesson-main { flex: 1; min-width: 0; }
.lesson-subject { font-size: 15px; font-weight: 600; }
.lesson-time { font-size: 13px; color: var(--text2); margin-top: 2px; }
.lesson.cancelled .lesson-subject { text-decoration: line-through; color: var(--text3); }
.lesson-room {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 10px;
}
.lesson-cancel-note {
  font-size: 13px;
  color: var(--red);
  background: rgba(240, 97, 109, 0.12);
  border-radius: 8px;
  padding: 4px 8px;
  margin-top: 6px;
}

/* ============================================================
   ДЗ
   ============================================================ */
.hw-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--border);
}
.hw-item:last-child { border-bottom: none; }
.hw-check {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  font-size: 20px;
  background: transparent;
  border: none;
  border-radius: 12px;
}
.hw-main { flex: 1; min-width: 0; }
.hw-subject { font-size: 12px; font-weight: 600; color: var(--text2); }
.hw-task { font-size: 15px; margin-top: 2px; word-break: break-word; }
.hw-due { font-size: 13px; color: var(--text2); margin-top: 4px; }
.hw-item.done .hw-task { text-decoration: line-through; color: var(--text3); }

/* ============================================================
   Напоминания
   ============================================================ */
.rem-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 2px;
  border-bottom: 1px solid var(--border);
}
.rem-item:last-child { border-bottom: none; }
.rem-time { font-size: 24px; font-weight: 700; letter-spacing: -0.4px; min-width: 62px; }
.rem-date { font-size: 12px; color: var(--text2); font-weight: 500; }
.rem-main { flex: 1; min-width: 0; }
.rem-text { font-size: 15px; word-break: break-word; }
.rem-status { font-size: 12px; color: var(--text2); margin-top: 3px; }

.abs-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--border);
}
.abs-item:last-child { border-bottom: none; }

/* ============================================================
   Плитки «Ещё» (как в Crypto Bot)
   ============================================================ */
.tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px 6px;
  padding: 6px 0 4px;
}

.tile {
  background: transparent;
  border: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text);
}
.tile:active { opacity: 0.7; }
.tile-ico {
  width: 54px;
  height: 54px;
  border-radius: 17px;
  display: grid;
  place-items: center;
  font-size: 26px;
  line-height: 1;
}
.tile-label { font-size: 12px; font-weight: 500; text-align: center; line-height: 1.2; }

.ico-green { background: linear-gradient(160deg, #66E38A, #2FA85A); }
.ico-orange { background: linear-gradient(160deg, #FFC061, #F08A2E); }
.ico-blue { background: linear-gradient(160deg, #57ADF2, #2C72D6); }
.ico-purple { background: linear-gradient(160deg, #B98CF5, #7C4DD6); }
.ico-red { background: linear-gradient(160deg, #FF8A95, #D64453); }

/* ============================================================
   Переключатели (тумблеры)
   ============================================================ */
.switch {
  flex-shrink: 0;
  width: 52px;
  height: 44px;
  display: grid;
  place-items: center;
  background: transparent;
  border: none;
}
.switch-track {
  width: 44px;
  height: 27px;
  border-radius: 999px;
  background: rgba(255,255,255,0.14);
  position: relative;
  transition: background 0.18s ease;
  display: block;
}
.switch-thumb {
  position: absolute;
  top: 3px; left: 3px;
  width: 21px; height: 21px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.18s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.35);
}
.switch.on .switch-track { background: var(--green); }
.switch.on .switch-thumb { transform: translateX(17px); }

/* ============================================================
   Формы
   ============================================================ */
.field { margin-bottom: 12px; }
.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  margin: 0 2px 6px;
}

.input, .textarea, .select {
  width: 100%;
  min-height: 46px;
  padding: 11px 14px;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 15px;
  outline: none;
}
.input::placeholder, .textarea::placeholder { color: var(--text3); }
.input:focus, .textarea:focus { border-color: var(--accent); }
.textarea { min-height: 90px; resize: vertical; }
.select { min-height: 46px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-size: 14px;
  color: var(--text2);
}
.check-row input { width: 20px; height: 20px; accent-color: var(--accent); }

/* ============================================================
   ИИ-чат
   ============================================================ */
.chat-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 0;
  min-height: 200px;
}
.bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}
.bubble.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 6px; }
.bubble.bot { align-self: flex-start; background: var(--card2); border: 1px solid var(--border); border-bottom-left-radius: 6px; }
.bubble.typing { color: var(--text2); font-style: italic; }

.chat-inputbar {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  margin-top: 12px;
  position: sticky;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 8px);
}
.chat-inputbar .textarea { min-height: 46px; max-height: 120px; flex: 1; }
.chat-send {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 18px;
  display: grid;
  place-items: center;
}

/* ============================================================
   Статистика (админ)
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.stat-tile {
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 10px;
  text-align: center;
}
.stat-num { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; }
.stat-label { font-size: 12px; color: var(--text2); margin-top: 4px; line-height: 1.25; }

/* ============================================================
   Пустые состояния и скелетоны
   ============================================================ */
.empty {
  text-align: center;
  padding: 34px 16px;
  color: var(--text2);
}
.empty-ico { font-size: 40px; margin-bottom: 10px; }
.empty-text { font-size: 14px; }

.skeleton {
  border-radius: 12px;
  background: linear-gradient(90deg, rgba(255,255,255,0.04), rgba(255,255,255,0.09), rgba(255,255,255,0.04));
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite linear;
}
.sk-card { height: 120px; margin-bottom: 12px; border-radius: var(--radius); }
.sk-row { height: 44px; margin-bottom: 8px; }

@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* ============================================================
   Экран «Нет доступа»
   ============================================================ */
.access-body {
  min-height: 70vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  padding: 24px;
}
.access-ico { font-size: 56px; }
.access-body h2 { margin: 0; font-size: 24px; font-weight: 700; }
.access-body p { margin: 0 0 14px; color: var(--text2); font-size: 14px; max-width: 320px; }

/* ============================================================
   Калькулятор среднего балла
   ============================================================ */
.gpa-big {
  font-size: 46px;
  font-weight: 800;
  letter-spacing: -1px;
  text-align: center;
  padding: 6px 0 4px;
  color: var(--text);
}
.gpa-big.green { color: var(--green); }
.gpa-big.orange { color: var(--orange); }
.gpa-big.red { color: var(--red); }
.gpa-meta {
  text-align: center;
  font-size: 13px;
  color: var(--text2);
}
.gpa-add-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.gpa-add-row .input { flex: 1; }
.gpa-add-row .btn { min-width: 52px; }
.gpa-exp-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.gpa-exp-row .input { flex: 1; max-width: 140px; }
.gpa-chip { border-color: rgba(255, 255, 255, 0.14); }
#gpa-exp-hint { margin-top: 8px; }

/* --- 📈 Динамика оценок --- */
.gd-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.gd-label {
  width: 90px;
  font-size: 12px;
  color: var(--text2);
  flex-shrink: 0;
}
.gd-barwrap {
  flex: 1;
  height: 16px;
  background: var(--card2);
  border-radius: 8px;
  overflow: hidden;
}
.gd-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 8px;
  min-width: 4px;
  transition: width 0.3s ease;
}
.gd-num {
  width: 40px;
  text-align: right;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

/* ============================================================
   Нижняя навигация
   ============================================================ */
#tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 50;
  background: rgba(23, 25, 29, 0.94); /* fallback без color-mix */
  background: color-mix(in srgb, var(--card2) 92%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
}

.tabbar-inner {
  position: relative;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  height: var(--tabbar-h);
}

/* Скользящая пилюля активного таба (стиль Crypto Bot) */
.tab-pill {
  position: absolute;
  top: 5px;
  bottom: 5px;
  left: 0;
  border-radius: 14px;
  background: var(--accent-soft);
  border: 1px solid rgba(51, 144, 236, 0.28);
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.3, 1),
              width 0.28s cubic-bezier(0.2, 0.8, 0.3, 1),
              opacity 0.2s ease;
  pointer-events: none;
}

.tab {
  position: relative;
  z-index: 1;
  flex: 1;
  min-width: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: transparent;
  border: none;
  color: var(--text2);
  padding: 6px 2px;
  transition: color 0.2s ease;
}
.tab-ico {
  font-size: 20px;
  line-height: 1;
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.3, 1);
}
.tab-label { font-size: 10.5px; font-weight: 600; }
.tab.active { color: var(--accent); }
.tab.active .tab-ico { transform: scale(1.12); }

/* ============================================================
   Модальные окна (bottom sheet)
   ============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeInBg 0.18s ease;
}
@keyframes fadeInBg { from { opacity: 0; } to { opacity: 1; } }

.modal-sheet {
  width: 100%;
  max-width: 560px;
  max-height: 86vh;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 22px 22px 0 0;
  padding: 18px 16px calc(18px + var(--safe-bottom));
  animation: slideUp 0.22s cubic-bezier(0.2, 0.8, 0.3, 1);
}
@keyframes slideUp { from { transform: translateY(60px); opacity: 0.4; } to { transform: none; opacity: 1; } }

.modal-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.modal-title { flex: 1; font-size: 19px; font-weight: 700; }

/* Крупное превью времени в модалке напоминания */
.time-preview {
  text-align: center;
  padding: 12px 0 4px;
}
.time-preview-main { font-size: 30px; font-weight: 700; letter-spacing: -0.4px; }
.time-preview-sub { font-size: 14px; color: var(--text2); margin-top: 4px; }

/* ============================================================
   Тосты
   ============================================================ */
#toast-root {
  position: fixed;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 14px);
  left: 0; right: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  max-width: 480px;
  width: calc(100% - 28px);
  background: #262A2F;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 14px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.45);
  animation: toastIn 0.2s ease;
}
.toast.error { color: var(--red); }
.toast.success { color: var(--green); }
@keyframes toastIn { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Текст заявления */
.statement-text {
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}

/* Просмотрщик изображений внутри приложения */
.img-view {
  display: flex;
  justify-content: center;
  align-items: center;
}
.img-view img {
  max-width: 100%;
  max-height: 64vh;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--card2);
}

pre.code-result {
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  font-size: 12.5px;
  line-height: 1.45;
  max-height: 400px;
  overflow: auto;
  color: var(--text2);
}

/* ============================================================
   Адаптивность
   ============================================================ */
@media (max-width: 360px) {
  .tile-ico { width: 48px; height: 48px; font-size: 23px; border-radius: 15px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .status-big { font-size: 32px; }
}
