/* ─────────────────────────────────────────────────────────────
   Три темы. Меняются переменные — разметка одна.
   ───────────────────────────────────────────────────────────── */

:root {
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --radius-bubble: 20px;
  --radius-tail: 6px;
  --maxw: 620px;
}

/* ── СВЕТЛАЯ ── */
[data-theme='bubbles-light'] {
  --bg: linear-gradient(170deg, #f2f5fb 0%, #e9eef8 55%, #eef1f8 100%);
  --bg-solid: #eef1f8;
  --ink: #191d26;
  --ink-dim: #737e91;
  --ink-faint: #9aa3b2;
  --bubble-l: #ffffff;
  --bubble-l-ink: #1b2029;
  /* Пузырь в карточке ленты. Отдельно от --bubble-l: там пузырь лежит на
     фоне страницы, а в карточке — на самой карточке, и совпадение цветов
     превратило бы реплику в невидимый белый прямоугольник. */
  --card-bubble: #f2f5fa;
  --bubble-r: linear-gradient(135deg, #5b7cfa, #7c5cff);
  --bubble-r-ink: #ffffff;
  --shadow: 0 2px 12px rgba(28, 40, 74, .07);
  --hl-ring: rgba(124, 92, 255, .35);
  --hl-glow: 0 6px 26px rgba(124, 92, 255, .22);
  --line: rgba(20, 30, 60, .09);
  --chip: rgba(91, 124, 250, .1);
  --chip-ink: #4a63c8;
  --c0: #d1495b; --c1: #2a8c74; --c2: #5b62b8; --c3: #b8722a; --c4: #7a4fa3;
}

/* ── ТЁМНАЯ ── */
[data-theme='bubbles-dark'] {
  --bg: radial-gradient(1000px 600px at 80% -10%, rgba(124,92,255,.16), transparent 60%), #0a0b0f;
  --bg-solid: #0a0b0f;
  --ink: #e9ecf4;
  --ink-dim: #8790a2;
  --ink-faint: #5d6675;
  --bubble-l: #15171f;
  --bubble-l-ink: #dfe3ec;
  --card-bubble: #21242e;
  --bubble-r: linear-gradient(135deg, #6d4fff, #9a5cff);
  --bubble-r-ink: #ffffff;
  --shadow: 0 2px 14px rgba(0, 0, 0, .35);
  --hl-ring: rgba(157, 140, 255, .5);
  --hl-glow: 0 8px 30px rgba(124, 92, 255, .3);
  --line: rgba(255, 255, 255, .08);
  --chip: rgba(124, 92, 255, .15);
  --chip-ink: #b3a3ff;
  --c0: #ff7a85; --c1: #4fd6b0; --c2: #9d8cff; --c3: #ffb454; --c4: #ff8fd1;
}

/* ── КАРТОЧКА ── */
[data-theme='card'] {
  --bg: linear-gradient(155deg, #1b1f3a 0%, #2d1f45 50%, #3d2450 100%);
  --bg-solid: #2a2044;
  --ink: #f2effd;
  --ink-dim: #a79fc8;
  --ink-faint: #8078a0;
  --bubble-l: rgba(255, 255, 255, .07);
  --bubble-l-ink: #f0eefc;
  --card-bubble: rgba(255, 255, 255, .1);
  --bubble-r: linear-gradient(135deg, rgba(157,140,255,.9), rgba(255,143,209,.75));
  --bubble-r-ink: #16122b;
  --shadow: 0 4px 24px rgba(0, 0, 0, .25);
  --hl-ring: rgba(255, 255, 255, .45);
  --hl-glow: 0 10px 36px rgba(157, 140, 255, .35);
  --line: rgba(255, 255, 255, .12);
  --chip: rgba(255, 255, 255, .12);
  --chip-ink: #d6cdfa;
  --c0: #ff9aa8; --c1: #6fe3c0; --c2: #b8a8ff; --c3: #ffc978; --c4: #ffa6dd;
}

[data-theme='card'] .bubble {
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, .1);
}

/* ─── БАЗА ─── */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font);
  background: var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

.shell { max-width: var(--maxw); margin: 0 auto; padding: 24px 18px 60px; }

/* ─── ШАПКА ─── */
.top {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 26px; font-size: 13px;
}
.brand {
  color: var(--ink); text-decoration: none; font-weight: 700;
  letter-spacing: -.2px; opacity: .85;
}
.brand:hover { opacity: 1; }
.date { color: var(--ink-faint); }

.title {
  font-size: 26px; line-height: 1.24; font-weight: 800;
  letter-spacing: -.5px; margin-bottom: 26px;
}

/* ─── ПУЗЫРИ ─── */
.chat { display: flex; flex-direction: column; gap: 4px; padding: 4px 0 12px; }

.row { display: flex; margin-top: 8px; }
.row.right { justify-content: flex-end; }
.stack { max-width: 82%; min-width: 0; }
.row.right .stack { align-items: flex-end; display: flex; flex-direction: column; }

.who {
  font-size: 11.5px; font-weight: 700; letter-spacing: .02em;
  margin: 0 0 5px 14px; opacity: .95;
}
.row.right .who { margin: 0 14px 5px 0; }
.c0 { color: var(--c0); } .c1 { color: var(--c1); } .c2 { color: var(--c2); }
.c3 { color: var(--c3); } .c4 { color: var(--c4); }

.bubble {
  background: var(--bubble-l);
  color: var(--bubble-l-ink);
  border-radius: var(--radius-bubble);
  border-bottom-left-radius: var(--radius-tail);
  padding: 11px 15px;
  box-shadow: var(--shadow);
  font-size: 15.5px;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.row.right .bubble {
  background: var(--bubble-r);
  color: var(--bubble-r-ink);
  border-bottom-left-radius: var(--radius-bubble);
  border-bottom-right-radius: var(--radius-tail);
}

/* Подсвеченная реплика — панчлайн не теряется */
.bubble.is-highlight {
  font-size: 19px;
  font-weight: 600;
  padding: 15px 19px;
  box-shadow: var(--hl-glow);
  outline: 2px solid var(--hl-ring);
  outline-offset: 2px;
}

.bubble .photo { margin: -3px -5px 8px; }
.bubble .photo img { width: 100%; border-radius: 12px; display: block; }
.bubble .photo:last-child { margin-bottom: -3px; }

/* ─── РЕАКЦИИ ─── */
.reactions {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin: 18px 0 4px; padding-top: 16px; border-top: 1px solid var(--line);
}
.react {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border: 1px solid var(--line);
  border-radius: 20px; padding: 6px 12px; cursor: pointer;
  font-size: 15px; color: var(--ink-dim);
  transition: transform .16s, border-color .16s, background .16s;
}
.react:hover { border-color: var(--hl-ring); }
.react.mine { background: var(--chip); border-color: var(--hl-ring); }
.react b { font-size: 12.5px; font-weight: 700; color: var(--ink-dim); }
.react.pop { transform: scale(1.16); }

/* ─── ПОДВАЛ ─── */
.foot {
  margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-faint);
}
.meta { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.linky {
  background: none; border: none; padding: 0; cursor: pointer;
  font: inherit; color: var(--ink-dim); text-decoration: underline;
  text-underline-offset: 2px;
}
.linky:hover { color: var(--ink); }
.linky:disabled { opacity: .55; cursor: default; text-decoration: none; }

.cta {
  display: inline-block; text-decoration: none;
  background: var(--bubble-r); color: var(--bubble-r-ink);
  padding: 9px 16px; border-radius: 11px;
  font-size: 13.5px; font-weight: 600; white-space: nowrap;
  box-shadow: var(--shadow);
}
.cta:hover { filter: brightness(1.06); }
.cta.big { padding: 12px 22px; font-size: 15px; }

/* ─── ГЛАВНАЯ: ВИТРИНА ─────────────────────────────────────────
   Странице публикации хватает колонки в 620px, витрине — двух
   колонок карточек, поэтому ширина расширяется только здесь.
   Цвета берутся из переменных темы: захардкоженные значения из
   макета сделали бы главную единственной страницей, не умеющей
   в тёмное оформление.
   ───────────────────────────────────────────────────────────── */
.page-feed .shell { max-width: 900px; }

/* ── Шапка ── */
.brandbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 34px;
}
.logo {
  display: flex; align-items: center; gap: 9px;
  font-weight: 800; font-size: 15.5px; letter-spacing: -.2px;
}
.logo svg { display: block; flex: none; }
.nav-link { font-size: 13.5px; color: var(--ink-dim); text-decoration: none; }
.nav-link:hover { color: var(--ink); }

/* ── Герой ── */
.hero { margin-bottom: 28px; }
.live {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 600;
  color: #0f8f6c; background: rgba(52, 196, 150, .12);
  padding: 6px 13px; border-radius: 20px; margin-bottom: 16px;
}
.live i {
  width: 6px; height: 6px; border-radius: 50%;
  background: #22b98a; font-style: normal;
  box-shadow: 0 0 0 3px rgba(34, 185, 138, .22);
}
.hero h1 {
  font-size: 40px; font-weight: 800; letter-spacing: -1.3px;
  line-height: 1.08; margin-bottom: 12px;
}
.hero h1 span {
  background: linear-gradient(115deg, #5b7cfa, #7c5cff 55%, #c05cff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p {
  color: var(--ink-dim); font-size: 15.5px;
  max-width: 450px; margin-bottom: 22px; line-height: 1.6;
}
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none;
  background: var(--bubble-r); color: var(--bubble-r-ink);
  padding: 13px 24px; border-radius: 12px;
  font-size: 14.5px; font-weight: 600;
  box-shadow: 0 6px 22px rgba(91, 124, 250, .28);
}
.btn:hover { filter: brightness(1.06); }
.btn.ghost {
  background: var(--bubble-l); color: var(--ink);
  border: 1px solid var(--line); box-shadow: none;
}

/* ── Статистика ── */
.stats {
  display: flex; gap: 34px; flex-wrap: wrap; margin: 28px 0; padding: 18px 0;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.st b {
  display: block; font-size: 22px; font-weight: 800;
  letter-spacing: -.5px; color: var(--ink);
}
.st span { font-size: 12px; color: var(--ink-faint); }

/* ── Рубрики ── */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.tab {
  font-size: 13.5px; padding: 8px 16px; border-radius: 22px;
  text-decoration: none; background: var(--bubble-l);
  color: var(--ink-dim); border: 1px solid var(--line);
}
.tab:hover { color: var(--ink); }
.tab.on { background: var(--ink); color: var(--bg-solid); border-color: var(--ink); font-weight: 600; }
.tab .n { opacity: .5; margin-left: 5px; font-size: 12px; }

/* ── Карточки ── */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.card {
  display: block; text-decoration: none; color: inherit;
  background: var(--bubble-l); border-radius: 18px; padding: 18px;
  box-shadow: var(--shadow); border: 1px solid var(--line);
  transition: transform .18s ease, box-shadow .18s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 10px 30px rgba(28, 40, 74, .13); }
/* Подсветка полупрозрачным акцентом поверх фона карточки: сплошной цвет
   пришлось бы подбирать заново под каждую тему. */
.card.hot {
  border-color: var(--hl-ring);
  background-image: linear-gradient(165deg, var(--chip), transparent 55%);
}
.c-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 13px; }
.chip {
  font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  background: var(--chip); color: var(--chip-ink); padding: 4px 10px; border-radius: 11px;
}
.fire { font-size: 11.5px; font-weight: 600; color: #d97740; }

/* Мини-пузыри повторяют правило страницы публикации: первый заговоривший
   справа. Совпадение обязательно — иначе одна переписка выглядит в ленте
   и на странице как два разных диалога. */
.mini { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.b { max-width: 84%; padding: 9px 13px; font-size: 13.5px; line-height: 1.45; border-radius: 15px; }
.b.l {
  background: var(--card-bubble); color: var(--bubble-l-ink);
  align-self: flex-start; border-bottom-left-radius: var(--radius-tail);
}
.b.r {
  background: var(--bubble-r); color: var(--bubble-r-ink);
  align-self: flex-end; border-bottom-right-radius: var(--radius-tail);
}
.b.more {
  background: transparent; border: 0; color: var(--ink-faint);
  font-size: 12px; padding: 2px 4px; align-self: flex-start;
}
.c-foot {
  display: flex; align-items: center; gap: 13px; padding-top: 13px;
  border-top: 1px solid var(--line); font-size: 11.5px; color: var(--ink-faint);
}
.c-foot .react {
  margin-left: auto; display: flex; gap: 7px;
  background: none; border: 0; padding: 0;
}
.c-foot .react span { background: var(--chip); padding: 3px 8px; border-radius: 10px; }

/* ── Догрузка ── */
.more-btn {
  display: block; margin: 22px auto 0; cursor: pointer;
  background: var(--bubble-l); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 26px; font: inherit; font-size: 14px; color: var(--ink-dim);
}
.more-btn:hover { color: var(--ink); }
.more-btn:disabled { opacity: .6; cursor: default; }

/* ── Пустая лента ── */
.welcome { text-align: center; padding: 44px 20px 30px; color: var(--ink-dim); }
.welcome p { margin-bottom: 18px; font-size: 15.5px; }

/* ── «Как это работает» и подвал ── */
.how { margin-top: 44px; padding-top: 24px; border-top: 1px solid var(--line); }
.how h2 { font-size: 17px; font-weight: 700; margin-bottom: 12px; letter-spacing: -.3px; }
.how ol { color: var(--ink-dim); font-size: 14px; line-height: 1.7; padding-left: 20px; }
.foot-note {
  margin-top: 34px; padding-top: 22px; border-top: 1px solid var(--line);
  font-size: 12px; color: var(--ink-faint); text-align: center; line-height: 1.65;
}

.empty { text-align: center; padding: 60px 20px; color: var(--ink-dim); }
.empty .dim { color: var(--ink-faint); font-size: 14px; margin-top: 6px; }
.empty .cta { margin-top: 20px; }

/* ─── МОБИЛЬНЫЙ ─── */
/* 640px — брейкпоинт витрины: ниже него две колонки карточек не помещаются. */
@media (max-width: 640px) {
  .grid { grid-template-columns: 1fr; }
  .hero h1 { font-size: 31px; letter-spacing: -1px; }
  .stats { gap: 24px; }
  .st b { font-size: 19px; }
}

@media (max-width: 520px) {
  .shell { padding: 18px 14px 48px; }
  .title { font-size: 22px; }
  .stack { max-width: 88%; }
  .bubble { font-size: 15px; }
  .bubble.is-highlight { font-size: 17.5px; }
  .foot { flex-direction: column; align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ─── Переключатель оформления и похожие публикации ─── */

.top-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--line);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  color: var(--ink-dim);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  transition: color .15s, border-color .15s;
}

.theme-toggle:hover {
  color: var(--ink);
  border-color: var(--ink-faint);
}

.similar {
  margin-top: 42px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
}

.similar-head {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-dim);
  margin-bottom: 14px;
}

.similar-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink);
}

.similar-item:last-child { border-bottom: none; }
.similar-item:hover .similar-title { color: var(--chip-ink); }

.similar-title {
  font-size: 15px;
  transition: color .15s;
}

.similar-meta {
  font-size: 13px;
  color: var(--ink-faint);
  white-space: nowrap;
}

/* Навигация к соседним публикациям. Два слота по краям, счётчик в центре.
   Пустой слот держит место, чтобы одиночная стрелка на краю ленты осталась
   у своего края, а не съехала в центр. */
.postnav {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-top: 30px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.postnav-slot { flex: 1 1 0; }

.postnav-link {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 0;
  text-decoration: none;
  color: var(--ink);
}

/* «Следующая →» прижата к правому краю вместе со своей подсказкой. */
.postnav-next {
  align-items: flex-end;
  text-align: right;
}

.postnav-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-dim);
  transition: color .15s;
}

.postnav-link:hover .postnav-label { color: var(--chip-ink); }

.postnav-preview {
  max-width: 100%;
  font-size: 13px;
  color: var(--ink-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.postnav-count {
  flex: 0 0 auto;
  align-self: center;
  font-size: 13px;
  color: var(--ink-faint);
  white-space: nowrap;
}

/* Подсказка о превышении лимита и прочих отказах API. */
.notice {
  margin: 14px 0 0;
  padding: 11px 15px;
  border-radius: 12px;
  background: var(--chip);
  color: var(--chip-ink);
  font-size: 14px;
  line-height: 1.4;
}
