/* Тёмная читалка-лента. Вертикальный скролл со снапом меняет пост,
   горизонтальный внутри поста — страницу. overscroll-behavior: none по обеим
   осям, иначе браузер перехватывает свайп и уводит «назад» по истории. */

:root {
  --bg: #0d0f14;
  --card: #141821;
  --card-2: #1b2130;
  --ink: #e8e3d9;
  --ink-dim: #9aa3b2;
  --accent: #d8a657;
  --like: #e4636f;
  --bar-h: 58px;
  --gutter: 20px;
}

* { box-sizing: border-box; }

/* Атрибут hidden даёт display: none, но любое своё правило display его
   перебивает — и скрытая шторка продолжает ловить тапы поверх ленты.
   Поэтому hidden объявлен сильнее всех. */
[hidden] { display: none !important; }

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

body { overflow: hidden; }

/* ---------- лента ---------- */

.feed {
  height: 100%;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  overscroll-behavior-y: contain;
  scrollbar-width: none;
}
.feed::-webkit-scrollbar { display: none; }

.post {
  height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex; flex-direction: column;
  padding-bottom: var(--bar-h);
}

/* горизонтальная дорожка страниц одного поста */
.pages {
  flex: 1; min-height: 0;
  display: flex;
  overflow-x: scroll; overflow-y: hidden;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;   /* без этого свайп вправо = «назад» */
  scrollbar-width: none;
}
.pages::-webkit-scrollbar { display: none; }

.page {
  flex: 0 0 100%;
  height: 100%;
  overflow-y: auto;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  padding: calc(env(safe-area-inset-top) + 18px) var(--gutter) 24px;
  overscroll-behavior: contain;
}

.page img {
  width: 100%; border-radius: 14px; margin: 0 0 16px;
  display: block; background: var(--card-2);
}

.page .body {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 19px; line-height: 1.62;
  white-space: pre-wrap;
  hyphens: auto;
}

.page video { width: 100%; border-radius: 14px; background: #000; }

/* шапка поста */
.head {
  padding: calc(env(safe-area-inset-top) + 10px) var(--gutter) 8px;
  display: flex; align-items: baseline; gap: 8px;
  font-size: 13px; color: var(--ink-dim);
}
.head .kind {
  color: var(--accent); text-transform: uppercase;
  letter-spacing: .08em; font-size: 11px; font-weight: 700;
}
.head .src { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* точки страниц + кнопки действий */
.foot {
  display: flex; align-items: center; gap: 6px;
  padding: 8px var(--gutter) 10px;
}
.dots { display: flex; gap: 6px; flex: 1; }
.dot {
  width: 22px; height: 3px; border-radius: 2px;
  background: #333b4d; transition: background .2s;
}
.dot.on { background: var(--accent); }

.act {
  background: none; border: 0; color: var(--ink-dim);
  font-size: 21px; line-height: 1; padding: 6px 8px; cursor: pointer;
}
.act.on { color: var(--accent); }
.act.like.on { color: var(--like); }
.act .n { font-size: 12px; margin-left: 3px; vertical-align: 2px; }

/* полоса перемотки озвучки */
.seek { padding: 0 var(--gutter) 6px; display: none; }
.seek.on { display: block; }
.seek input { width: 100%; accent-color: var(--accent); }

.empty {
  height: 100%; display: grid; place-content: center;
  text-align: center; color: var(--ink-dim); padding: 40px;
  line-height: 1.6;
}

/* ---------- нижняя панель ---------- */

.bar {
  position: fixed; left: 0; right: 0; bottom: 0; height: var(--bar-h);
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: #10141ce8; backdrop-filter: blur(12px);
  border-top: 1px solid #222a38;
}
.bar button {
  flex: 1; background: none; border: 0; color: var(--ink-dim);
  font-size: 20px; cursor: pointer;
}
.bar button.on { color: var(--accent); }

/* ---------- вход и меню ---------- */

.gate, .sheet {
  position: fixed; inset: 0; z-index: 10;
  display: grid; place-items: center;
  background: #080a0ee0; padding: var(--gutter);
}
.gate-card, .sheet-card {
  width: 100%; max-width: 360px;
  background: var(--card); border: 1px solid #232b3a;
  border-radius: 18px; padding: 24px;
}
.gate-card h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: -.02em; }
.sheet-card h2 { margin: 0 0 12px; font-size: 18px; }
.muted { color: var(--ink-dim); font-size: 14px; margin: 0 0 18px; }

.tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.tabs button {
  flex: 1; padding: 9px; border-radius: 10px; cursor: pointer;
  background: var(--card-2); border: 1px solid #2a3344; color: var(--ink-dim);
  font-size: 14px;
}
.tabs button.on { color: var(--bg); background: var(--accent); border-color: var(--accent); }

form input, .sheet select {
  width: 100%; margin-bottom: 10px; padding: 12px;
  border-radius: 10px; border: 1px solid #2a3344;
  background: var(--card-2); color: var(--ink); font-size: 15px;
}
form button[type=submit], .wide {
  width: 100%; padding: 12px; border: 0; border-radius: 10px;
  background: var(--accent); color: #14161c; font-weight: 700;
  font-size: 15px; cursor: pointer; margin-top: 4px;
}
.wide.ghost { background: var(--card-2); color: var(--ink-dim); font-weight: 500; }
.err { color: var(--like); font-size: 13px; min-height: 18px; margin: 8px 0 0; }

.row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; font-size: 14px; color: var(--ink-dim); margin: 14px 0;
}
.row select { width: auto; margin: 0; }
.stats {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
  font-size: 13px; color: var(--ink-dim); margin-bottom: 6px;
}
.stats b { color: var(--ink); font-size: 16px; display: block; }
.invite-out {
  font-size: 12px; word-break: break-all; color: var(--accent);
  margin: 8px 0 2px; line-height: 1.5;
}

.toast {
  position: fixed; left: 50%; bottom: calc(var(--bar-h) + 18px);
  transform: translateX(-50%); z-index: 20;
  background: #222a38f2; color: var(--ink); font-size: 13px;
  padding: 10px 16px; border-radius: 20px; pointer-events: none;
  opacity: 0; transition: opacity .2s;
}
.toast.on { opacity: 1; }
