/* Лента нарезок — Reels/TikTok-паттерн, адаптив под мобильный Telegram WebView */
:root {
  --bg: #0d0d12;
  --fg: #f2f2f5;
  --muted: #9a9aa8;
  --accent: #2ea043;
  --danger: #d64550;
  --glass: rgba(18, 18, 26, 0.72);
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}

/* ---- Лента ---- */
#feed {
  height: 100vh;
  height: 100dvh;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
}
#feed::-webkit-scrollbar { display: none; }

.card {
  position: relative;
  height: 100vh;
  height: 100dvh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  overflow: hidden;
}
.card video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}
.card .video-error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 15px;
  text-align: center;
  padding: 24px;
}
.card .card-caption {
  position: absolute;
  left: 0; right: 0;
  bottom: calc(96px + var(--safe-bottom));
  padding: 14px 16px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.72));
  font-size: 14px;
  line-height: 1.4;
  max-height: 30vh;
  overflow: hidden;
  pointer-events: none;
}
.card .card-caption .title { font-weight: 600; margin-bottom: 4px; }
.card .card-caption .text {
  color: #e6e6ee;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---- Верхний бар ---- */
#topbar {
  position: fixed;
  top: calc(10px + var(--safe-top));
  left: 0; right: 0;
  display: flex;
  justify-content: center;
  gap: 8px;
  z-index: 20;
  pointer-events: none;
}
.chip {
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
}
.chip-ghost { color: var(--muted); font-weight: 500; }

/* ---- Нижняя панель ---- */
#controls {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(14px + var(--safe-bottom));
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  z-index: 20;
}
.btn {
  border: 0;
  border-radius: var(--radius);
  padding: 15px 18px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease;
  user-select: none;
  -webkit-user-select: none;
}
.btn:active { transform: scale(0.95); opacity: 0.9; }
.btn-approve { flex: 1; background: var(--accent); }
.btn-reject { flex: 1; background: var(--danger); }
.btn-ghost {
  flex: 0 0 auto;
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--fg);
  font-size: 19px;
  padding: 14px 16px;
}
.btn-dark { background: #26262e; width: 100%; margin-top: 10px; }

/* ---- Шторки ---- */
.sheet {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: flex-end;
  z-index: 40;
}
.sheet-card {
  width: 100%;
  background: #17171f;
  border-radius: 18px 18px 0 0;
  padding: 18px 18px calc(18px + var(--safe-bottom));
  max-height: 70vh;
  overflow-y: auto;
}
.sheet-card h3 { margin: 0 0 10px; font-size: 17px; }
.sheet-card p { margin: 0 0 12px; font-size: 14px; line-height: 1.5; color: #dddde6; white-space: pre-wrap; }
.sheet-card dl { margin: 0 0 12px; font-size: 13px; color: var(--muted); }
.sheet-card dl div { display: flex; gap: 8px; padding: 3px 0; }
.sheet-card dt { min-width: 110px; }
.sheet-card dd { margin: 0; color: var(--fg); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip-btn {
  border: 1px solid #33333d;
  background: #22222b;
  color: var(--fg);
  font-size: 14px;
  padding: 10px 15px;
  cursor: pointer;
}
.chip-btn:active { background: #2e2e39; }

/* ---- Финал / заглушки ---- */
.done {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  text-align: center;
}
.done-inner { padding: 24px; max-width: 420px; }
.done-emoji { font-size: 64px; margin-bottom: 8px; }
.done h2 { margin: 0 0 12px; font-size: 24px; }
.done-summary { font-size: 16px; margin: 0 0 10px; }
.done-thanks { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 0 0 22px; }

/* ---- Тост ---- */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-bottom));
  transform: translateX(-50%);
  background: var(--glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--fg);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 14px;
  z-index: 60;
  max-width: 86vw;
  text-align: center;
}

/* Анимация ухода карточки после решения */
.card.leaving { transition: transform 0.28s ease, opacity 0.28s ease; transform: translateY(-40%); opacity: 0; }

@media (min-width: 700px) {
  .btn { padding: 16px 26px; }
  #controls { max-width: 560px; left: 50%; transform: translateX(-50%); }
}
