/* ==========================================================
   app.css — дополнения мини-приложения к стилям прототипа.
   Подключается последним.
   Здесь: «утилиты» вместо style="..." (политика безопасности CSP
   запрещает атрибут style), состояния загрузки и ошибок, метки
   «демо», экран «вне Telegram», отступы под безопасные зоны.
   ========================================================== */

/* ---------- Безопасные зоны Telegram (вырезы, полноэкранный режим) ---------- */
#app {
  padding-top: calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
}

.nav {
  padding-bottom: calc(10px + max(env(safe-area-inset-bottom), var(--tg-safe-area-inset-bottom, 0px)));
}

/* ---------- Утилиты отступов и текста ---------- */
.mt-0 { margin-top: 0; }
.mt-6 { margin-top: 6px; }
.mt-8 { margin-top: 8px; }
.mt-10 { margin-top: 10px; }
.mt-12 { margin-top: 12px; }
.mt-14 { margin-top: 14px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-10 { margin-bottom: 10px; }
.mb-14 { margin-bottom: 14px; }
.m--4-0-12 { margin: -4px 0 12px; }
.m-4-0-8 { margin: 4px 0 8px; }
.m-4-0-14 { margin: 4px 0 14px; }
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-good { color: var(--good); }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }
.fs-17 { font-size: 17px; }
.flex-1 { flex: 1; }
.row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ---------- Загрузка и ошибки ---------- */
.state-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px 20px;
  text-align: center;
}

.state-box.error {
  color: var(--bad);
}

.state-box.error .btn {
  color: var(--accent-text);
}

.spinner {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid var(--surface-2);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.toast.error {
  background: var(--bad);
  color: #fff;
}

/* ---------- Метки «Скоро · демо» ---------- */
.badge.demo {
  vertical-align: middle;
  background: var(--warn);
  color: #1a1400;
  font-size: 11px;
  white-space: nowrap;
}

.demo-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px dashed var(--warn);
  font-size: 12.5px;
  color: var(--text-muted);
}

.tile {
  position: relative;
}

.tile-tag {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 1px 6px;
  border-radius: 99px;
  background: var(--warn);
  color: #1a1400;
  font-size: 10px;
  font-weight: 800;
}

/* ---------- Тесты и карточки ---------- */
.xp-line {
  margin-top: 8px;
  font-weight: 800;
  color: var(--good);
}

.flash-face {
  overflow-y: auto;
}

.flash-actions .btn:disabled {
  opacity: 0.45;
}

/* ---------- Чат ---------- */
.bubble.error {
  border-color: var(--bad);
  color: var(--bad);
}

.chat-disclaimer {
  margin-top: 14px;
  font-size: 11.5px;
  text-align: center;
  color: var(--text-muted);
}

.chat-input input:disabled {
  opacity: 0.6;
}

.chat-head .btn {
  margin-left: auto;
}

/* ---------- Экран «Откройте через бота» / «Сессия устарела» ---------- */
.gate {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 28px 24px;
  text-align: center;
}

.gate img {
  width: 150px;
  height: 150px;
  object-fit: cover;
  border-radius: 50%;
  border: 1px solid var(--border);
}

.gate h1 {
  font-size: 21px;
  line-height: 1.25;
}

.gate a.btn {
  text-decoration: none;
  color: var(--accent-text);
}

/* Подписи на цветной карточке «задание дня» должны читаться */
.today-card .muted {
  color: inherit;
  opacity: 0.85;
}
