/* ============================================================
   БАЗОВЫЕ СТИЛИ
   Переменные, сбросы, темы оформления, вход
   ============================================================ */

/* === ТЕМА ПО УМОЛЧАНИЮ: ТЁМНАЯ === */
:root,
[data-theme="dark"] {
  --bg: #1e1e2e;
  --bg-secondary: #2a2a3c;
  --bg-tertiary: #3a3a52;
  --text: #eee;
  --text-muted: #888;
  --accent: #4a7cff;
  --accent-hover: #3a6cef;
  --border: #3a3a52;
  --own-msg: #4a7cff;
  --other-msg: #2a2a3c;
  --warn: #f5a623;
  --ok: #3a9d5d;
  --danger: #e04a4a;
  --star: #f5c542;

  --app-height: 100dvh;
}

/* === СВЕТЛАЯ === */
[data-theme="light"] {
  --bg: #f5f5f7;
  --bg-secondary: #ffffff;
  --bg-tertiary: #e8e8ed;
  --text: #1a1a1a;
  --text-muted: #666;
  --accent: #4a7cff;
  --accent-hover: #3a6cef;
  --border: #d0d0d8;
  --own-msg: #4a7cff;
  --other-msg: #e8e8ed;
  --warn: #f5a623;
  --ok: #3a9d5d;
  --danger: #e04a4a;
  --star: #f5c542;
}

/* === ГЛУБОКИЙ СИНИЙ === */
[data-theme="navy"] {
  --bg: #0d1b2a;
  --bg-secondary: #1b263b;
  --bg-tertiary: #2a3a52;
  --text: #e0e0e0;
  --text-muted: #8a9bb0;
  --accent: #4a9eff;
  --accent-hover: #3a8eef;
  --border: #2a3a52;
  --own-msg: #4a9eff;
  --other-msg: #1b263b;
  --warn: #f5a623;
  --ok: #3a9d5d;
  --danger: #e04a4a;
  --star: #f5c542;
}

/* === ЛЕСНАЯ === */
[data-theme="forest"] {
  --bg: #1a2e1f;
  --bg-secondary: #2d4a32;
  --bg-tertiary: #3a5c40;
  --text: #e0e8e0;
  --text-muted: #8aa890;
  --accent: #3a9d5d;
  --accent-hover: #2a8d4d;
  --border: #3a5c40;
  --own-msg: #3a9d5d;
  --other-msg: #2d4a32;
  --warn: #f5a623;
  --ok: #3a9d5d;
  --danger: #e04a4a;
  --star: #f5c542;
}

/* === ЗАКАТ === */
[data-theme="sunset"] {
  --bg: #2d1b3d;
  --bg-secondary: #3d2a4d;
  --bg-tertiary: #4d3a5d;
  --text: #f0e0f0;
  --text-muted: #b090b0;
  --accent: #ff6b35;
  --accent-hover: #ef5b25;
  --border: #4d3a5d;
  --own-msg: #ff6b35;
  --other-msg: #3d2a4d;
  --warn: #f5a623;
  --ok: #3a9d5d;
  --danger: #e04a4a;
  --star: #f5c542;
}

/* === АМЕТИСТ === */
[data-theme="amethyst"] {
  --bg: #1f1235;
  --bg-secondary: #2d1b4e;
  --bg-tertiary: #3d2a5e;
  --text: #e8e0f0;
  --text-muted: #a890c0;
  --accent: #a67cff;
  --accent-hover: #966cef;
  --border: #3d2a5e;
  --own-msg: #a67cff;
  --other-msg: #2d1b4e;
  --warn: #f5a623;
  --ok: #3a9d5d;
  --danger: #e04a4a;
  --star: #f5c542;
}

/* === ЧИСТО-ЧЁРНАЯ === */
[data-theme="black"] {
  --bg: #000000;
  --bg-secondary: #0a0a0a;
  --bg-tertiary: #1a1a1a;
  --text: #ffffff;
  --text-muted: #888888;
  --accent: #4a7cff;
  --accent-hover: #3a6cef;
  --border: #2a2a2a;
  --own-msg: #4a7cff;
  --other-msg: #1a1a1a;
  --warn: #f5a623;
  --ok: #3a9d5d;
  --danger: #e04a4a;
  --star: #f5c542;
}

/* === РЖД (КОРПОРАТИВНАЯ) === */
[data-theme="rzd"] {
  --bg: #1a1a1a;
  --bg-secondary: #2a2a2a;
  --bg-tertiary: #3a3a3a;
  --text: #ffffff;
  --text-muted: #a0a0a0;
  --accent: #cd202c;
  --accent-hover: #bd101c;
  --border: #3a3a3a;
  --own-msg: #cd202c;
  --other-msg: #2a2a2a;
  --warn: #f5a623;
  --ok: #3a9d5d;
  --danger: #e04a4a;
  --star: #f5c542;
}

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

html {
  height: 100%;
  overscroll-behavior-x: none;
}

body {
  font-family: -apple-system, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  height: var(--app-height);
  overscroll-behavior: none;
  overscroll-behavior-x: none;
  transition: background 0.2s, color 0.2s;
}

/* Загрузка */
#loading {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--bg);
  color: var(--text-muted);
  z-index: 200;
}
#loading.hide { display: none; }

/* Экран входа */
#login {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 20px;
  gap: 12px;
  z-index: 100;
  overflow-y: auto;
}
#login input {
  width: 100%;
  max-width: 320px;
  padding: 14px 16px;
  font-size: 16px;
  border: none;
  border-radius: 12px;
  background: var(--bg-secondary);
  color: var(--text);
  outline: none;
}
#authBtn {
  width: 100%;
  max-width: 320px;
  padding: 16px;
  font-size: 16px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: white;
  font-weight: bold;
  cursor: pointer;
}
.tab-btn {
  background: var(--bg-secondary);
  color: var(--text);
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.tab-btn.active { background: var(--accent); color: #fff; }
.row { display: flex; gap: 8px; width: 100%; max-width: 320px; }
.row input { flex: 1; }

/* Утилиты */
.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

.section-title {
  padding: 16px 16px 6px;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.round-btn { display: none; }

/* ============================================================
   СЕТКА ТЕМ (для модалки выбора)
   ============================================================ */

.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 4px 0;
}
.theme-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-radius: 12px;
  background: var(--bg-tertiary);
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.1s;
}
.theme-card:active { transform: scale(0.97); }
.theme-card.active { border-color: var(--accent); }
.theme-preview {
  height: 60px;
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.1);
}
.theme-preview-accent {
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
}
.theme-name {
  font-size: 12px;
  color: var(--text);
  text-align: center;
  font-weight: 500;
}