/* Корефаны: ночной неон. Тёмный фон, розовое и голубое свечение, плавные анимации */
:root {
  --bg: #0b0912;
  --panel: #15111f;
  --panel-2: #211a31;
  --fg: #f4efff;
  --muted: #9e93b8;
  --line: #2c2340;
  --accent: #ff4fd8;          /* неоновый розовый */
  --accent-2: #3ee6ff;        /* неоновый голубой */
  --accent-ink: #1a0717;
  --glow: 0 0 18px rgba(255, 79, 216, .55);
  --glow-2: 0 0 18px rgba(62, 230, 255, .5);
  --ok: #5ef0a0;
  --danger: #ff7a8a;
  --font-logo: "Rubik Mono One", "Arial Black", sans-serif;
  --font-body: "Manrope", "Segoe UI", Arial, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
/* iPhone: не увеличивать текст самому и не вылезать вбок за экран */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { overflow-x: hidden; }
/* Убираем «айфоновский» вид полей (свои тени, скругления и внутренние отступы), чтобы везде было одинаково */
input, textarea, button { -webkit-appearance: none; appearance: none; }
input[type=checkbox] { -webkit-appearance: auto; appearance: auto; }
body { background: var(--bg); color: var(--fg); font-family: var(--font-body); font-size: 15px; line-height: 1.5; min-height: 100vh; }
/* Размытые неоновые пятна на фоне */
body::before {
  content: ""; position: fixed; inset: -15%; z-index: -1; pointer-events: none;
  background:
    radial-gradient(40vmax 40vmax at 10% 10%, rgba(255, 79, 216, .16), transparent 60%),
    radial-gradient(45vmax 45vmax at 90% 90%, rgba(62, 230, 255, .12), transparent 60%),
    radial-gradient(25vmax 25vmax at 80% 15%, rgba(140, 90, 255, .10), transparent 60%);
  animation: drift 36s ease-in-out infinite alternate;
}
/* Пятна света медленно плывут */
@keyframes drift {
  50% { transform: translate3d(5%, -4%, 0) scale(1.08); }
  100% { transform: translate3d(-4%, 5%, 0) scale(1.02); }
}
a { color: inherit; }
button, input, textarea { font: inherit; color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

/* iPhone приближает страницу, если шрифт в поле меньше 16px, и края экрана уезжают.
   На телефонах во всех полях ввода ставим 16px, чтобы такого не было */
@media (max-width: 700px) {
  input, textarea, select { font-size: 16px; }
}

/* Тонкие тёмные полосы прокрутки вместо стандартных серых со стрелками — везде на сайте */
* { scrollbar-width: thin; scrollbar-color: #3a2f52 transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #3a2f52; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }
::-webkit-scrollbar-button { display: none; }

.loading { padding: 40px 16px; text-align: center; color: var(--muted); }

/* Заготовки, пока грузится: мерцают, как тусклый неон */
.skeleton { padding: 0; text-align: left; }
.sk-top { height: 58px; border-bottom: 1px solid var(--line); background: rgba(11, 9, 18, .8); }
.sk-body { max-width: 1100px; margin: 0 auto; padding: 28px 16px; display: grid; gap: 28px; }
.sk {
  border-radius: 12px; background: linear-gradient(100deg, var(--panel) 30%, #2a1f3d 50%, var(--panel) 70%);
  background-size: 250% 100%; animation: shimmer 1.4s linear infinite;
}
.sk-cover { height: clamp(230px, 38vw, 400px); border-radius: 20px; box-shadow: 0 0 30px rgba(255, 79, 216, .12); }
.sk-grid { column-width: 210px; column-gap: 10px; }
.sk-grid .sk { margin-bottom: 10px; break-inside: avoid; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -150% 0; } }

/* Полоса прогресса при загрузке файлов */
.progress { height: 8px; border-radius: 999px; background: var(--panel-2); overflow: hidden; }
.progress i {
  display: block; height: 100%; width: 0; border-radius: inherit; transition: width .4s ease;
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent)); background-size: 200% 100%;
  box-shadow: 0 0 12px rgba(255, 79, 216, .8); animation: shimmer 1.2s linear infinite;
}
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

/* Шапка */
.top { position: sticky; top: 0; z-index: 20; padding-top: env(safe-area-inset-top, 0px); background: rgba(11, 9, 18, .8); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; align-items: center; gap: 8px 20px; flex-wrap: wrap; padding-block: 12px; }
.logo { font-family: var(--font-logo); font-size: 18px; letter-spacing: .02em; text-decoration: none; margin-right: auto; text-shadow: 0 0 8px rgba(255, 79, 216, .8), 0 0 22px rgba(255, 79, 216, .45); animation: flicker 9s 3s infinite; }
/* Иногда логотип мигает, как старая вывеска */
@keyframes flicker { 0%, 94%, 100% { opacity: 1; } 94.5% { opacity: .35; } 95.2% { opacity: 1; } 96% { opacity: .5; } 96.6% { opacity: 1; } }
.logo span { color: var(--accent-2); text-shadow: var(--glow-2); }
.nav { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.nav a { text-decoration: none; padding: 6px 12px; border-radius: 999px; color: var(--muted); font-weight: 600; transition: color .2s, background .2s, box-shadow .2s; }
.nav a:hover { color: var(--fg); }
.nav a.on { color: var(--fg); background: var(--panel-2); box-shadow: inset 0 0 0 1px rgba(255, 79, 216, .35); }
.nav a.cta { background: var(--accent); color: var(--accent-ink); box-shadow: var(--glow); }
.nav a.cta:hover { box-shadow: 0 0 26px rgba(255, 79, 216, .8); }
.nav a.me { padding: 0; }
.me-m { display: none; text-decoration: none; }

/* Аватар: фото или первая буква имени */
.ava { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; font-weight: 700; color: #15121c; flex: none; overflow: hidden; }
.ava img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ava.big { width: 76px; height: 76px; font-size: 30px; box-shadow: 0 0 0 2px var(--accent), var(--glow); }

main.wrap { padding-block: 28px 64px; display: grid; gap: 28px; animation: fade .35s ease both; }
h1 {
  font-family: var(--font-logo); font-weight: 400; font-size: clamp(22px, 4vw, 32px); margin: 0; line-height: 1.15;
  background: linear-gradient(90deg, var(--fg) 30%, var(--accent) 75%, var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent;
}
h2 { font-size: 13px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 0 0 12px; font-weight: 700; }
.sub { color: var(--muted); margin: 6px 0 0; }
.sub a { color: var(--accent-2); }

/* Сетка фото и видео: каждое фото в своих пропорциях, без обрезки */
.grid { column-width: 210px; column-gap: 10px; }
.tile {
  display: block; width: 100%; margin: 0 0 10px; break-inside: avoid;
  position: relative; border: 0; padding: 0; border-radius: 10px; overflow: hidden; background: var(--panel); cursor: pointer;
  animation: rise .5s ease both; animation-delay: calc(var(--i, 0) * 45ms);
  transition: transform .2s, box-shadow .2s;
}
.tile:hover { transform: translateY(-3px); box-shadow: 0 0 0 1px rgba(255, 79, 216, .5), 0 8px 30px rgba(255, 79, 216, .25); }
.tile img { width: 100%; height: auto; display: block; }
.tile .play { position: absolute; right: 8px; top: 8px; background: rgba(0, 0, 0, .6); border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 700; color: var(--accent-2); }
.tile .noimg { display: grid; place-items: center; aspect-ratio: 4 / 3; color: var(--muted); font-size: 28px; }
.tile .rc { position: absolute; left: 8px; bottom: 8px; background: rgba(0, 0, 0, .6); border-radius: 999px; padding: 2px 8px; font-size: 12px; font-weight: 700; }
/* Обложка ленты */
.cover {
  position: relative; display: grid; align-items: end; overflow: hidden;
  min-height: clamp(230px, 38vw, 400px); border-radius: 20px; border: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(255, 79, 216, .35), rgba(62, 230, 255, .18)), var(--panel);
  box-shadow: var(--glow); animation: rise .5s ease both;
}
.cover > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: saturate(1.15) contrast(1.05); }
.cover::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(11, 9, 18, .96) 8%, rgba(11, 9, 18, .35) 55%, rgba(255, 79, 216, .18)); }
.cover-in { position: relative; z-index: 1; padding: clamp(18px, 4vw, 34px); display: grid; gap: 10px; }
.cover-kicker { margin: 0; font-size: 12px; letter-spacing: .3em; text-transform: uppercase; color: var(--accent-2); text-shadow: var(--glow-2); }
.cover-title { font-size: clamp(30px, 6vw, 54px); color: #ffe6fb; background: none; text-shadow: 0 0 10px var(--accent), 0 0 30px rgba(255, 79, 216, .6); }
.stats { display: flex; flex-wrap: wrap; gap: 10px 28px; }
.stats b { display: block; font-family: var(--font-logo); font-weight: 400; font-size: 22px; line-height: 1.2; text-shadow: 0 0 12px rgba(62, 230, 255, .5); }
.stats span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

.month { display: grid; gap: 10px; }
.month + .month { margin-top: 18px; }
.empty { color: var(--muted); background: var(--panel); border: 1px dashed var(--line); border-radius: 12px; padding: 28px 20px; text-align: center; }
.empty a { color: var(--accent); font-weight: 600; }

/* Корефаны-постеры */
.posters { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.poster {
  position: relative; display: grid; align-items: end; aspect-ratio: 3 / 4; max-width: 100%; overflow: hidden;
  border-radius: 16px; text-decoration: none; border: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(255, 79, 216, .35), rgba(62, 230, 255, .2)), var(--panel);
  animation: rise .5s ease both; animation-delay: calc(var(--i, 0) * 60ms);
  transition: transform .25s, box-shadow .25s, border-color .25s;
}
.poster > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform .5s; }
.poster::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(11, 9, 18, .95) 12%, rgba(11, 9, 18, .2) 60%, rgba(255, 79, 216, .12)); }
.poster:hover { transform: translateY(-4px); border-color: var(--accent); box-shadow: var(--glow); }
.poster:hover > img { transform: scale(1.06); }
.poster-in { position: relative; z-index: 1; display: grid; gap: 4px; padding: 16px; }
.poster-in .ava { box-shadow: 0 0 0 2px var(--accent); margin-bottom: 6px; }
.poster-in b { font-family: var(--font-logo); font-weight: 400; font-size: 18px; line-height: 1.2; color: #ffe6fb; text-shadow: 0 0 10px rgba(255, 79, 216, .8); overflow-wrap: anywhere; }
.poster-in span { font-size: 13px; color: var(--muted); }
@media (max-width: 700px) { .posters { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; } .poster-in { padding: 12px; } .poster-in b { font-size: 15px; } }

/* Список корефанов */
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.person { display: flex; gap: 12px; align-items: center; padding: 14px; background: var(--panel); border-radius: 12px; text-decoration: none; border: 1px solid var(--line); transition: border-color .2s, box-shadow .2s, transform .2s; animation: rise .45s ease both; }
.person:hover { border-color: var(--accent); box-shadow: var(--glow); transform: translateY(-2px); }
.person b { display: block; }
.person span { color: var(--muted); font-size: 13px; }
.head { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }

/* Профиль корефана */
.profile { display: flex; gap: clamp(16px, 4vw, 36px); align-items: center; flex-wrap: wrap; padding: clamp(16px, 3vw, 28px); background: var(--panel); border: 1px solid var(--line); border-radius: 20px; animation: rise .45s ease both; }
.profile .ava.big { width: clamp(86px, 18vw, 128px); height: clamp(86px, 18vw, 128px); font-size: clamp(34px, 7vw, 52px); box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--accent), 0 0 30px rgba(255, 79, 216, .6); }
.pinfo { display: grid; gap: 8px; min-width: 0; flex: 1 1 260px; }
.pinfo .sub { margin: 0; }
.pinfo .stats { margin-top: 6px; }
.badges { display: flex; flex-wrap: wrap; gap: 8px; }
.badge { display: inline-grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center; padding: 8px 14px 8px 10px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); font-weight: 700; font-size: 14px; animation: rise .45s ease both; }
.badge i { grid-row: span 2; font-style: normal; font-size: 22px; }
.badge small { font-weight: 500; font-size: 12px; color: var(--muted); }
.badge.gold { border-color: var(--accent); box-shadow: 0 0 16px rgba(255, 79, 216, .35); }

/* Формы */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; display: grid; gap: 14px; max-width: 640px; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
input[type=text], input[type=email], input[type=password], input[type=date], textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); transition: border-color .2s, box-shadow .2s;
}
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 79, 216, .15); outline: none; }
/* Поля для текста сами растут под текст (autoGrow в app.js), полоса прокрутки появляется только на максимуме */
textarea { min-height: 70px; max-height: 300px; resize: none; overflow-y: hidden; }
.btn { border: 1px solid var(--line); background: var(--panel-2); border-radius: 10px; padding: 10px 16px; cursor: pointer; font-weight: 600; transition: box-shadow .2s, transform .1s, border-color .2s; }
.btn:hover { border-color: var(--accent-2); box-shadow: var(--glow-2); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: var(--glow); }
.btn.primary:hover { box-shadow: 0 0 28px rgba(255, 79, 216, .85); }
.btn.danger { color: var(--danger); border-color: currentColor; background: transparent; }
.btn.danger:hover { box-shadow: 0 0 16px rgba(255, 122, 138, .45); }
.btn:disabled { opacity: .5; cursor: default; box-shadow: none; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.msg { font-size: 14px; color: var(--muted); margin: 0; }
.msg.err { color: var(--danger); }
.msg.ok { color: var(--ok); }

.drop { border: 2px dashed var(--line); border-radius: 12px; padding: 26px 16px; text-align: center; color: var(--muted); cursor: pointer; transition: border-color .2s, box-shadow .2s, color .2s; }
.drop:hover, .drop.over { border-color: var(--accent); color: var(--fg); box-shadow: inset 0 0 30px rgba(255, 79, 216, .15); }
.picked { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 6px; }
.picked div { aspect-ratio: 1; border-radius: 8px; background: var(--panel-2) center / cover; display: grid; place-items: center; font-size: 12px; color: var(--muted); animation: rise .3s ease both; }

/* Отметки людей */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; gap: 6px; align-items: center; padding: 4px 12px 4px 4px; border-radius: 999px; background: var(--panel-2); border: 1px solid transparent; cursor: pointer; text-decoration: none; font-size: 14px; transition: border-color .2s, box-shadow .2s; }
.chip .ava { width: 24px; height: 24px; font-size: 12px; }
.chip:hover { border-color: var(--line); }
.chip[aria-pressed="true"] { border-color: var(--accent); background: rgba(255, 79, 216, .15); box-shadow: 0 0 12px rgba(255, 79, 216, .35); }

/* Цитаты и шутки */
.tab { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 6px 14px; cursor: pointer; font-weight: 600; color: var(--muted); transition: all .2s; }
.tab[aria-pressed="true"] { background: var(--panel-2); color: var(--fg); border-color: var(--accent); box-shadow: 0 0 12px rgba(255, 79, 216, .3); }
.quotes { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; align-items: start; }
.quote { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; display: grid; gap: 12px; border-top: 3px solid var(--accent); box-shadow: 0 -6px 20px -10px rgba(255, 79, 216, .6); animation: rise .45s ease both; }
.quote.joke { border-top-color: var(--accent-2); box-shadow: 0 -6px 20px -10px rgba(62, 230, 255, .6); }
.quote .kind { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.quote .qtext { margin: 0; font-size: 19px; line-height: 1.35; font-weight: 600; white-space: pre-wrap; overflow-wrap: anywhere; }
.quote .qmeta { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.link-btn { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0; font-size: 12px; text-decoration: underline; }
.link-btn:hover { color: var(--danger); }

/* Реакции */
.reacts { display: flex; gap: 6px; flex-wrap: wrap; }
.react { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 4px 10px; cursor: pointer; font-size: 16px; line-height: 1.2; transition: border-color .2s, box-shadow .2s, transform .1s; }
.react:active { transform: scale(.9); }
.react span { font-size: 13px; font-weight: 700; color: var(--muted); }
.react[aria-pressed="true"] { border-color: var(--accent); background: rgba(255, 79, 216, .15); box-shadow: 0 0 14px rgba(255, 79, 216, .45); }
.react[aria-pressed="true"] span { color: var(--fg); }
.react.pop { animation: pop .35s ease; }

/* Комментарии */
.comments { display: grid; gap: 12px; border-top: 1px solid var(--line); padding-top: 14px; }
.comments h2 { margin: 0; display: flex; align-items: center; gap: 8px; }
.c-count:not(:empty) { color: var(--accent); background: rgba(255, 79, 216, .15); border-radius: 999px; padding: 0 8px; font-size: 12px; letter-spacing: 0; box-shadow: 0 0 10px rgba(255, 79, 216, .35); }
.c-list { display: grid; gap: 10px; }
.c-empty { margin: 0; font-size: 14px; color: var(--muted); }
.c-item { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px; align-items: start; animation: rise .35s ease both; animation-delay: calc(var(--i, 0) * 40ms); }
.c-item > a { text-decoration: none; }
.c-item .ava { width: 30px; height: 30px; font-size: 13px; }
.c-bubble { background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px 16px 16px 16px; padding: 8px 12px; min-width: 0; }
.c-item.mine .c-bubble { border-color: rgba(255, 79, 216, .45); background: linear-gradient(135deg, rgba(255, 79, 216, .16), var(--panel-2) 70%); }
.c-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; font-size: 12px; }
.c-head span { color: var(--muted); }
.c-head .link-btn { margin-left: auto; }
.c-text { margin: 2px 0 0; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.c-item.new { animation: pop-in .45s cubic-bezier(.2, 1.4, .4, 1) both; }
.c-item.new .c-bubble { animation: glow-pulse 1.4s ease; }
.c-item.bye { animation: bye .28s ease forwards; }

.c-form { position: sticky; bottom: -20px; display: flex; gap: 8px; align-items: flex-end; padding: 10px 0 20px; background: var(--panel); }
.c-form .pill textarea { max-height: 120px; }
.c-form .c-send { width: 44px; height: 44px; }
.c-send {
  flex: none; display: grid; place-items: center; width: 42px; height: 42px; border: 0; border-radius: 50%; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); box-shadow: var(--glow); transition: transform .15s, box-shadow .2s, opacity .2s;
}
.c-send svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.c-send:hover:not(:disabled) { transform: scale(1.08); box-shadow: 0 0 26px rgba(255, 79, 216, .9); }
.c-send:disabled { opacity: .35; box-shadow: none; cursor: default; }
.c-send.flying svg { animation: fly .6s ease-in-out infinite; }

@keyframes pop-in { from { opacity: 0; transform: translateY(14px) scale(.9); } }
@keyframes glow-pulse { 0% { box-shadow: 0 0 0 rgba(255, 79, 216, 0); } 30% { box-shadow: 0 0 24px rgba(255, 79, 216, .75); } 100% { box-shadow: 0 0 0 rgba(255, 79, 216, 0); } }
@keyframes bye { to { opacity: 0; transform: translateX(30px) scale(.95); } }
@keyframes fly { 45% { transform: translate(8px, -8px) scale(.7); opacity: 0; } 55% { transform: translate(-8px, 8px) scale(.7); opacity: 0; } 100% { transform: none; opacity: 1; } }

/* Плашка «новое на сайте» */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); z-index: 60; transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px; max-width: calc(100vw - 32px);
  padding: 10px 10px 10px 18px; border-radius: 999px; background: rgba(21, 17, 31, .95); backdrop-filter: blur(10px);
  border: 1px solid var(--accent); box-shadow: var(--glow); font-weight: 600; font-size: 14px;
  animation: toast-in .4s cubic-bezier(.2, 1.4, .4, 1) both;
}
.toast span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast button { flex: none; border: 0; border-radius: 999px; padding: 6px 14px; background: var(--accent); color: var(--accent-ink); font-weight: 700; cursor: pointer; }
.toast.out { animation: toast-out .3s ease forwards; }
@media (max-width: 700px) { .toast { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 30px) scale(.9); } }
@keyframes toast-out { to { opacity: 0; transform: translate(-50%, 20px); } }

/* ---------- Мессенджер ---------- */

/* Счётчик непрочитанных в меню */
.nav-badge {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 6px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); font-size: 11px; font-style: normal; font-weight: 800; vertical-align: 1px;
  box-shadow: 0 0 10px rgba(255, 79, 216, .8); animation: pop .4s ease;
}
.bn-ico { position: relative; display: block; }
.bn-ico .nav-badge { position: absolute; top: -6px; right: -12px; margin: 0; }
.top-m { color: var(--muted); }
.top-m svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Аватарки общих чатов и групп */
.chat-ava { color: var(--accent-ink); font-weight: 800; font-size: 14px; }
.chat-ava.general { background: radial-gradient(circle at 30% 30%, #ff8ae6, var(--accent)); font-family: var(--font-logo); font-weight: 400; box-shadow: 0 0 12px rgba(255, 79, 216, .6); }
.chat-ava.group { background: linear-gradient(135deg, var(--accent-2), #8c5aff); }

/* Список чатов */
.chat-panel { animation: rise .3s ease both; }
.chat-list { display: grid; gap: 6px; }
.chat-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 12px 14px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); text-decoration: none;
  animation: rise .4s ease both; animation-delay: calc(var(--i, 0) * 40ms); transition: border-color .2s, box-shadow .2s, transform .2s;
}
.chat-row:hover { border-color: var(--accent); box-shadow: var(--glow); transform: translateX(3px); }
.chat-row .ava { width: 46px; height: 46px; font-size: 18px; }
.cr-main { display: grid; min-width: 0; }
.cr-main b { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cr-main span { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-row.unread .cr-main span { color: var(--fg); }
.cr-side { display: grid; justify-items: end; gap: 4px; }
.cr-side time { font-size: 12px; color: var(--muted); }
.cr-badge { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-style: normal; font-weight: 800; box-shadow: 0 0 12px rgba(255, 79, 216, .8); }

/* Переписка на весь экран */
body.in-chat main.wrap { padding-block: 0; gap: 0; animation: none; }
body.in-chat .bnav { display: none; }
body.in-chat { padding-bottom: 0; }
.chat { display: flex; flex-direction: column; height: calc(100dvh - 59px - env(safe-area-inset-top, 0px)); }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.chat-head .back { padding: 8px 12px; }
.ch-who { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; text-decoration: none; }
.ch-who > div { display: grid; min-width: 0; }
.ch-who b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-who span { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.add-ppl { padding: 10px 0; display: grid; gap: 8px; border-bottom: 1px solid var(--line); animation: rise .25s ease both; }

.msgs { flex: 1; overflow-y: auto; padding: 16px 2px; display: flex; flex-direction: column; gap: 4px; overscroll-behavior: contain; }
.msgs-empty { margin: auto; color: var(--muted); }
.day-sep { display: flex; justify-content: center; margin: 14px 0 8px; }
.day-sep span { font-size: 12px; font-weight: 700; color: var(--muted); background: var(--panel); border: 1px solid var(--line); padding: 3px 12px; border-radius: 999px; }

.msg { display: flex; gap: 8px; align-items: flex-end; max-width: min(78%, 560px); }
.msg:not(.run) { margin-top: 8px; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.m-ava { width: 30px; flex: none; text-decoration: none; }
.m-ava .ava { width: 30px; height: 30px; font-size: 13px; }
.m-body { display: grid; gap: 3px; min-width: 0; position: relative; }
.msg.mine .m-body { justify-items: end; }
.m-name { font-size: 12px; font-weight: 700; color: var(--accent-2); padding-left: 12px; }
.bubble {
  position: relative; background: var(--panel-2); border: 1px solid var(--line); border-radius: 18px 18px 18px 6px;
  padding: 8px 12px 6px; cursor: pointer; min-width: 0; max-width: 100%; transition: box-shadow .2s;
}
.msg.run .bubble { border-radius: 6px 18px 18px 6px; }
.msg.mine .bubble {
  border-radius: 18px 18px 6px 18px; border-color: transparent; color: #fff;
  background: linear-gradient(135deg, #d63ab4, #8a3cff); box-shadow: 0 0 16px rgba(255, 79, 216, .25);
}
.msg.mine.run .bubble { border-radius: 18px 6px 6px 18px; }
.msg.active .bubble { box-shadow: 0 0 0 2px var(--accent-2), var(--glow-2); }
.m-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.4; }
.m-text a { color: var(--accent-2); }
.msg.mine .m-text a { color: #dffbff; }
.bubble time { display: block; text-align: right; font-size: 11px; opacity: .6; margin-top: 2px; }
.m-img { display: block; max-width: min(100%, 320px); max-height: 360px; border-radius: 12px; margin: 2px 0 4px; cursor: zoom-in; object-fit: cover; }
.m-img-pending { padding: 30px 20px; font-size: 14px; }
.m-reply {
  display: grid; text-align: left; width: 100%; margin-bottom: 6px; padding: 4px 10px; border: 0; border-left: 3px solid var(--accent-2);
  border-radius: 6px; background: rgba(0, 0, 0, .25); cursor: pointer; font-size: 13px; color: inherit;
}
.m-reply b { color: var(--accent-2); font-size: 12px; }
.m-reply span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .85; }
.msg.mine .m-reply { border-left-color: #fff; } .msg.mine .m-reply b { color: #fff; }

.m-reacts { display: flex; gap: 4px; flex-wrap: wrap; }
.m-reacts:empty { display: none; }
.m-react { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 1px 8px; font-size: 13px; cursor: pointer; }
.m-react[aria-pressed="true"] { border-color: var(--accent); background: rgba(255, 79, 216, .18); box-shadow: 0 0 10px rgba(255, 79, 216, .4); }
.m-react.pop { animation: pop .35s ease; }

/* Меню действий над сообщением */
.m-actions {
  display: none; position: absolute; bottom: calc(100% + 6px); left: 0; z-index: 5;
  gap: 2px; padding: 4px; border-radius: 999px; background: rgba(21, 17, 31, .97); border: 1px solid var(--accent); box-shadow: var(--glow);
  white-space: nowrap;
}
.msg.mine .m-actions { left: auto; right: 0; }
.msg.active .m-actions { display: flex; animation: pop-in .25s cubic-bezier(.2, 1.4, .4, 1) both; }
.m-actions button { border: 0; background: none; border-radius: 999px; padding: 4px 8px; cursor: pointer; font-size: 18px; }
.m-actions button[data-mact="reply"], .m-actions button[data-mact="del"] { font-size: 13px; font-weight: 700; }
.m-actions button:hover { background: var(--panel-2); }
.m-actions .danger { color: var(--danger); }

/* Анимации сообщений */
.msg.new { animation: msg-in .4s cubic-bezier(.2, 1.3, .4, 1) both; }
.msg.mine.new .bubble { animation: glow-pulse 1.2s ease; }
.msg.pending { opacity: .55; }
.msg.pending .bubble { background: linear-gradient(100deg, #8a3cff 30%, #d63ab4 50%, #8a3cff 70%); background-size: 250% 100%; animation: shimmer 1.2s linear infinite; }
.msg.failed .bubble { background: var(--panel-2); border: 1px solid var(--danger); }
.m-fail { display: block; font-size: 12px; color: var(--danger); }
.msg.bye { animation: bye .28s ease forwards; }
.msg.flash .bubble { animation: flash 1.2s ease; }
@keyframes msg-in { from { opacity: 0; transform: translateY(16px) scale(.92); } }
@keyframes flash { 0%, 100% { box-shadow: none; } 30% { box-shadow: 0 0 0 3px var(--accent-2), 0 0 26px rgba(62, 230, 255, .7); } }

/* Поле ввода */
.composer { border-top: 1px solid var(--line); padding: 10px 0 calc(10px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 8px; }
.reply-bar { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-left: 3px solid var(--accent-2); background: var(--panel); border-radius: 8px; animation: rise .2s ease both; }
.reply-bar div { display: grid; min-width: 0; flex: 1; font-size: 13px; }
.reply-bar b { color: var(--accent-2); font-size: 12px; }
.reply-bar span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.comp-row { display: flex; align-items: flex-end; gap: 8px; width: 100%; }
/* Поле и обе кнопки ровно 44px.
   Рамку рисует обёртка .pill, а само поле внутри прозрачное и без рамки:
   так Safari на iPhone не может сделать поле выше или ниже кнопок своими настройками */
.pill {
  flex: 1 1 auto; min-width: 0; display: flex; align-items: center;
  min-height: 44px; padding: 0 16px; border: 1px solid var(--line); border-radius: 22px; background: var(--bg);
  transition: border-color .2s, box-shadow .2s;
}
.pill:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 79, 216, .15); }
.pill textarea, .pill textarea:focus {
  flex: 1 1 auto; width: 100%; min-width: 0; margin: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; outline: none;
  height: 42px; min-height: 42px; padding: 11px 0; line-height: 20px;
}
.comp-row .pill textarea { max-height: 140px; }
.comp-row .c-send { width: 44px; height: 44px; }
.attach { flex: none; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--line); background: var(--panel-2); color: var(--accent-2); cursor: pointer; transition: box-shadow .2s, border-color .2s; }
.attach:hover { border-color: var(--accent-2); box-shadow: var(--glow-2); }
.attach svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }

/* Фото на весь экран */
.lightbox { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 16px; background: rgba(6, 4, 10, .95); cursor: zoom-out; animation: fade .2s ease both; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; animation: zoom .25s ease both; box-shadow: 0 0 60px rgba(255, 79, 216, .25); }
.lightbox.out { animation: toast-out .2s ease forwards; }

@media (max-width: 700px) {
  .chat { height: calc(100dvh - 59px - env(safe-area-inset-top, 0px)); }
  .msg { max-width: 86%; }
  .top-m { margin-right: 4px; }
}

/* Плашка Netlify в правом нижнем углу (около 190×55): пока она есть, поднимаем свои кнопки над ней */
body.has-nl-badge .composer { padding-bottom: calc(62px + env(safe-area-inset-bottom, 0px)); }
body.has-nl-badge .c-form { padding-bottom: 76px; }
body.has-nl-badge .toast { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
@media (max-width: 700px) {
  body.has-nl-badge { padding-bottom: calc(124px + env(safe-area-inset-bottom, 0px)); }
  body.has-nl-badge .bnav { padding-bottom: calc(68px + env(safe-area-inset-bottom, 0px)); }
  body.has-nl-badge .toast { bottom: calc(140px + env(safe-area-inset-bottom, 0px)); }
  body.in-chat.has-nl-badge { padding-bottom: 0; }
}

.push-on { font-weight: 700; color: var(--ok); text-shadow: 0 0 10px rgba(94, 240, 160, .5); }

/* Топ месяца */
.noms { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.nom { display: flex; gap: 12px; align-items: center; padding: 16px; background: var(--panel); border-radius: 14px; text-decoration: none; border: 1px solid var(--line); transition: border-color .2s, box-shadow .2s; animation: rise .45s ease both; }
.nom:hover { border-color: var(--accent-2); box-shadow: var(--glow-2); }
.nom .t { display: block; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.nom b { display: block; font-size: 17px; }
.nom span:not(.t):not(.ava) { color: var(--muted); font-size: 13px; }
.nom.main { grid-column: 1 / -1; border-color: var(--accent); background: linear-gradient(120deg, rgba(255, 79, 216, .22), rgba(62, 230, 255, .08) 60%, var(--panel)); box-shadow: var(--glow); }
.nom.main .t { color: var(--accent); }
.nom.main b { font-family: var(--font-logo); font-weight: 400; font-size: 22px; text-shadow: 0 0 14px rgba(255, 79, 216, .6); }

/* Аватарка в профиле */
.ava-edit { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }

/* Вход: неоновая вывеска */
.login { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 10px; padding: 24px 16px; }
.login .card { width: 100%; max-width: 380px; margin-top: 18px; box-shadow: 0 0 60px rgba(255, 79, 216, .15); animation: rise .6s 1.2s ease both; }
.sign {
  margin: 0; text-align: center; font-family: var(--font-logo); font-weight: 400; letter-spacing: .04em;
  font-size: clamp(34px, 10vw, 68px); line-height: 1; color: #ffe6fb;
  text-shadow: 0 0 4px #fff, 0 0 12px var(--accent), 0 0 28px var(--accent), 0 0 60px rgba(255, 79, 216, .6);
  animation: ignite 1.4s linear both;
}
.sign .broken { animation: broken 5s 2s infinite; }
.tagline {
  margin: 0; font-size: 13px; letter-spacing: .45em; text-transform: uppercase; color: #dffbff;
  text-shadow: 0 0 6px var(--accent-2), 0 0 18px var(--accent-2);
  animation: ignite 1.4s .5s linear both;
}
@keyframes ignite {
  0% { opacity: 0; } 8% { opacity: 1; } 12% { opacity: .15; } 20% { opacity: 1; }
  24% { opacity: .3; } 34% { opacity: 1; } 38% { opacity: .6; } 46%, 100% { opacity: 1; }
}
@keyframes broken { 0%, 90%, 100% { opacity: 1; } 91% { opacity: .2; } 93% { opacity: 1; } 95% { opacity: .35; } 96% { opacity: 1; } }

/* Просмотр одного фото или видео */
.viewer { position: fixed; inset: 0; z-index: 50; overflow: hidden; background: rgba(6, 4, 10, .95); backdrop-filter: blur(6px); display: grid; grid-template-columns: minmax(0, 1fr) 320px; animation: fade .2s ease both; }
.viewer-bg { position: absolute; inset: -10%; background: center / cover no-repeat; filter: blur(40px) brightness(.45) saturate(1.5); transform: scale(1.1); pointer-events: none; }
.viewer .media { position: relative; display: grid; place-items: center; padding: 16px; min-height: 0; touch-action: pan-y; }
.viewer .media.from-right > * { animation: from-right .28s ease both; }
.viewer .media.from-left > * { animation: from-left .28s ease both; }
.viewer .info { position: relative; }
@keyframes from-right { from { opacity: 0; transform: translateX(40px); } }
@keyframes from-left { from { opacity: 0; transform: translateX(-40px); } }
.viewer .media img, .viewer .media video { max-width: 100%; max-height: calc(100vh - 32px); border-radius: 8px; box-shadow: 0 0 60px rgba(255, 79, 216, .25); animation: zoom .3s ease both; }
.viewer .info { background: var(--panel); border-left: 1px solid var(--line); padding: 20px; overflow-y: auto; display: grid; gap: 14px; align-content: start; }
.viewer .close { position: absolute; left: 16px; top: 16px; z-index: 2; }
.viewer .nav-btn { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; }
.viewer .prev { left: 16px; } .viewer .next { right: 336px; }
.viewer .caption { font-size: 17px; margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Нижнее меню на телефоне */
.bnav { display: none; }
@media (max-width: 700px) {
  .top .nav { display: none; }
  .me-m { display: inline-flex; }
  body { padding-bottom: calc(68px + env(safe-area-inset-bottom, 0px)); }
  .bnav {
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    padding: 6px max(6px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(6px, env(safe-area-inset-left, 0px));
    background: rgba(11, 9, 18, .9); backdrop-filter: blur(14px); border-top: 1px solid var(--line);
  }
  .bnav a { display: grid; justify-items: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 600; padding: 4px 0; transition: color .2s; }
  .bnav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .bnav a.on { color: var(--accent); }
  .bnav a.on svg { filter: drop-shadow(0 0 6px rgba(255, 79, 216, .9)); }
  .bnav a.plus { color: var(--accent-ink); }
  .bnav a.plus span { display: grid; place-items: center; width: 48px; height: 48px; margin-top: -18px; border-radius: 50%; background: var(--accent); box-shadow: var(--glow); }
  .bnav a.plus svg { stroke-width: 2.4; }
  .viewer { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .viewer .media img, .viewer .media video { max-height: 52vh; }
  .viewer .info { max-height: 48vh; border-left: 0; border-top: 1px solid var(--line); }
  .viewer .next { right: 16px; }
  .grid { column-width: 150px; column-gap: 8px; }
  .tile { margin-bottom: 8px; }
}

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.98); } }
@keyframes zoom { from { opacity: 0; transform: scale(.94); } }
@keyframes pop { 40% { transform: scale(1.25); } }

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