/* ─────────────────────────────────────────────────────────────
   фидоня.дети — дизайн-система
   Тёмное «стекло» в духе Apple + фиолетовая палитра Twitch.
   ───────────────────────────────────────────────────────────── */

:root {
  --accent: #a970ff;
  --accent-2: #ff5fa2;
  --live: #ff3b5c;
  --mint: #35e0a1;
  --amber: #ffc44d;

  --ink: #08080d;
  --ink-2: #0d0d16;
  --surface: rgba(255, 255, 255, 0.055);
  --surface-2: rgba(255, 255, 255, 0.085);
  --line: rgba(255, 255, 255, 0.10);
  --line-strong: rgba(255, 255, 255, 0.18);
  --text: #f4f4f7;
  --muted: #9a9aa6;

  --radius: 26px;
  --radius-sm: 16px;
  --blur: saturate(180%) blur(26px);
  --shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.75);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  --font-display: "Unbounded", "Manrope", system-ui, sans-serif;
  --font-sans: "Manrope", -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
}

html[data-theme="light"] {
  --ink: #f2f2f6;
  --ink-2: #ffffff;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-2: rgba(255, 255, 255, 0.92);
  --line: rgba(9, 9, 20, 0.09);
  --line-strong: rgba(9, 9, 20, 0.16);
  --text: #12121a;
  --muted: #63636e;
  --shadow: 0 20px 50px -24px rgba(20, 20, 40, 0.35);
}

* { -webkit-tap-highlight-color: transparent; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--ink);
  color: var(--text);
  font-family: var(--font-sans);
  font-feature-settings: "ss01", "cv01";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.font-display { font-family: var(--font-display); letter-spacing: -0.02em; }
.font-mono, .tabular { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

::selection { background: color-mix(in srgb, var(--accent) 45%, transparent); color: #fff; }

/* ── Фон ─────────────────────────────────────────────────── */
.bg-stage { position: fixed; inset: 0; z-index: -2; overflow: hidden; background: var(--ink); }
.bg-stage::after {
  content: "";
  position: absolute; inset: -50%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.32'/%3E%3C/svg%3E");
  opacity: 0.14; mix-blend-mode: overlay; pointer-events: none;
}
.blob { position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.55; will-change: transform; }
.blob-1 { width: 46vmax; height: 46vmax; top: -14vmax; left: -10vmax; background: var(--accent); animation: drift-a 26s var(--ease) infinite alternate; }
.blob-2 { width: 38vmax; height: 38vmax; bottom: -14vmax; right: -8vmax; background: var(--accent-2); opacity: 0.4; animation: drift-b 32s var(--ease) infinite alternate; }
.blob-3 { width: 26vmax; height: 26vmax; top: 40%; left: 55%; background: #2b6cff; opacity: 0.28; animation: drift-c 38s var(--ease) infinite alternate; }
html[data-bg="grid"] .blob { opacity: 0.18; }
html[data-bg="grid"] .bg-stage { background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px); background-size: 46px 46px; }
html[data-bg="mesh"] .blob { filter: blur(50px); opacity: 0.7; }
html[data-bg="plain"] .blob { display: none; }
body[data-live="true"] .blob-2 { background: var(--live); opacity: 0.5; }

@keyframes drift-a { to { transform: translate3d(12vmax, 8vmax, 0) scale(1.15); } }
@keyframes drift-b { to { transform: translate3d(-14vmax, -6vmax, 0) scale(1.2); } }
@keyframes drift-c { to { transform: translate3d(-8vmax, 10vmax, 0) scale(0.85); } }

/* ── Стекло ──────────────────────────────────────────────── */
.glass {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--shadow);
}
.glass-sm { border-radius: var(--radius-sm); }
.glass-hover { transition: transform 0.45s var(--ease), border-color 0.3s, background 0.3s; }
.glass-hover:hover { transform: translateY(-3px); border-color: var(--line-strong); background: var(--surface-2); }

.sheen { position: relative; overflow: hidden; }
.sheen::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, 0.14) 46%, transparent 62%);
  transform: translateX(-120%); transition: transform 0.9s var(--ease); pointer-events: none;
}
.sheen:hover::before { transform: translateX(120%); }

/* ── Типографика ─────────────────────────────────────────── */
.title-xl { font-family: var(--font-display); font-weight: 700; font-size: clamp(1.7rem, 6vw, 2.35rem); line-height: 1.05; letter-spacing: -0.03em; }
.eyebrow { font-size: 0.68rem; letter-spacing: 0.22em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.muted { color: var(--muted); }
.grad-text { background: linear-gradient(100deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ── Аватар и пасхалка ───────────────────────────────────── */
.avatar-wrap { position: relative; width: 128px; height: 128px; cursor: pointer; user-select: none; touch-action: manipulation; }
.avatar-ring { position: absolute; inset: -6px; border-radius: 50%; background: conic-gradient(from 0deg, var(--accent), var(--accent-2), #2b6cff, var(--accent)); animation: spin 9s linear infinite; opacity: 0.9; }
.avatar-ring::after { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: var(--ink); }
body[data-live="true"] .avatar-ring { background: conic-gradient(from 0deg, var(--live), #ff8a5c, var(--live)); }
.avatar-img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; z-index: 2; transition: transform 0.5s var(--ease), filter 0.4s; }
.avatar-wrap:active .avatar-img { transform: scale(0.94); }
.avatar-wrap[data-egg="hot"] .avatar-img { filter: saturate(1.35) contrast(1.06); }
.egg-progress { position: absolute; inset: -12px; z-index: 3; pointer-events: none; transform: rotate(-90deg); }
.egg-progress circle { fill: none; stroke-width: 3; stroke-linecap: round; }
.egg-track { stroke: transparent; }
.egg-bar { stroke: var(--accent-2); transition: stroke-dashoffset 0.35s var(--ease); filter: drop-shadow(0 0 6px var(--accent-2)); }
@keyframes spin { to { transform: rotate(360deg); } }
.egg-burst { animation: burst 0.7s var(--ease); }
@keyframes burst { 0% { transform: scale(1); } 40% { transform: scale(1.12); } 100% { transform: scale(1); } }

.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--live); box-shadow: 0 0 0 0 color-mix(in srgb, var(--live) 70%, transparent); animation: pulse 1.9s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 12px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* ── Ссылки-строки ───────────────────────────────────────── */
.link-row {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 16px; border-radius: 18px;
  background: var(--surface); border: 1px solid var(--line);
  transition: transform 0.35s var(--ease), background 0.3s, border-color 0.3s;
  text-decoration: none; color: inherit;
}
.link-row:hover { transform: translateX(4px); background: var(--surface-2); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.link-row:active { transform: scale(0.985); }
.link-ico { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; font-size: 18px; background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); flex: none; }
.chev { margin-left: auto; opacity: 0.35; transition: transform 0.35s var(--ease), opacity 0.3s; }
.link-row:hover .chev { transform: translateX(3px); opacity: 0.9; }

/* ── Чипы и кнопки ───────────────────────────────────────── */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; font-size: 0.74rem; font-weight: 700; border: 1px solid var(--line); background: var(--surface); }
.chip[data-tone="accent"] { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.chip[data-tone="live"] { color: var(--live); border-color: color-mix(in srgb, var(--live) 40%, transparent); background: color-mix(in srgb, var(--live) 14%, transparent); }
.chip[data-tone="mint"] { color: var(--mint); border-color: color-mix(in srgb, var(--mint) 40%, transparent); background: color-mix(in srgb, var(--mint) 14%, transparent); }
.chip[data-tone="amber"] { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 40%, transparent); background: color-mix(in srgb, var(--amber) 14%, transparent); }

.btn-x {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: 14px; font-weight: 700; font-size: 0.9rem;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  cursor: pointer; transition: transform 0.25s var(--ease), background 0.25s, border-color 0.25s, box-shadow 0.25s;
}
.btn-x:hover { background: var(--surface-2); border-color: var(--line-strong); }
.btn-x:active { transform: scale(0.97); }
.btn-x[data-variant="primary"] { background: linear-gradient(100deg, var(--accent), var(--accent-2)); border: none; color: #fff; box-shadow: 0 12px 30px -12px var(--accent); }
.btn-x[data-variant="primary"]:hover { filter: brightness(1.07); }
.btn-x[data-variant="danger"] { color: var(--live); border-color: color-mix(in srgb, var(--live) 40%, transparent); }
.btn-x[data-variant="ghost"] { background: transparent; }
.btn-icon { width: 38px; height: 38px; padding: 0; border-radius: 12px; }

/* ── Поля формы ──────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 7px; }
.field > label { font-size: 0.76rem; font-weight: 700; color: var(--muted); letter-spacing: 0.01em; }
.input-x, textarea.input-x, select.input-x {
  width: 100%; padding: 11px 14px; border-radius: 14px; font: inherit; font-size: 0.92rem;
  background: rgba(255, 255, 255, 0.04); color: var(--text);
  border: 1px solid var(--line); outline: none;
  transition: border-color 0.25s, box-shadow 0.25s, background 0.25s;
}
html[data-theme="light"] .input-x { background: rgba(255, 255, 255, 0.85); }
.input-x:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
.input-x::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
textarea.input-x { resize: vertical; min-height: 92px; line-height: 1.55; }
.input-x[type="color"] { padding: 4px; height: 44px; cursor: pointer; }

.switch { position: relative; width: 48px; height: 28px; border-radius: 999px; background: var(--line); border: 1px solid var(--line-strong); cursor: pointer; transition: background 0.3s; flex: none; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform 0.32s var(--ease); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35); }
.switch[data-on="true"] { background: linear-gradient(100deg, var(--accent), var(--accent-2)); border-color: transparent; }
.switch[data-on="true"]::after { transform: translateX(20px); }

/* ── Навигация админки ───────────────────────────────────── */
.nav-item { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 14px; color: var(--muted); font-weight: 600; font-size: 0.9rem; text-decoration: none; transition: background 0.25s, color 0.25s, transform 0.25s var(--ease); }
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item[data-active="true"] { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--text); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent); }
.tabbar { position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 40; display: flex; gap: 4px; padding: 7px; border-radius: 22px; }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 4px; border-radius: 16px; font-size: 0.62rem; font-weight: 700; color: var(--muted); text-decoration: none; transition: background 0.25s, color 0.25s; }
.tabbar a[data-active="true"] { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--text); }

/* ── Тепловая карта ──────────────────────────────────────── */
.heat { display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 3px; }
.hm-cell { aspect-ratio: 1; border-radius: 4px; background: rgba(255, 255, 255, 0.05); transition: transform 0.2s var(--ease); }
.hm-cell:hover { transform: scale(1.35); z-index: 2; }
.hm-cell[data-level="1"] { background: color-mix(in srgb, var(--accent) 28%, transparent); }
.hm-cell[data-level="2"] { background: color-mix(in srgb, var(--accent) 52%, transparent); }
.hm-cell[data-level="3"] { background: color-mix(in srgb, var(--accent) 76%, transparent); }
.hm-cell[data-level="4"] { background: linear-gradient(140deg, var(--accent), var(--accent-2)); box-shadow: 0 0 10px -2px var(--accent-2); }

/* ── Галерея ─────────────────────────────────────────────── */
.masonry { column-gap: 14px; column-count: 1; }
@media (min-width: 640px) { .masonry { column-count: 2; } }
@media (min-width: 1024px) { .masonry { column-count: 3; } }
@media (min-width: 1536px) { .masonry { column-count: 4; } }
.masonry > * { break-inside: avoid; margin-bottom: 14px; }
.tile { position: relative; overflow: hidden; border-radius: 20px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; display: block; }
.tile img, .tile video { width: 100%; display: block; transition: transform 0.6s var(--ease); }
.tile:hover img, .tile:hover video { transform: scale(1.06); }
.tile-veil { position: absolute; inset: 0; background: linear-gradient(to top, rgba(0, 0, 0, 0.82) 0%, rgba(0, 0, 0, 0.1) 45%, transparent 70%); opacity: 0; transition: opacity 0.4s; display: flex; flex-direction: column; justify-content: flex-end; padding: 14px; gap: 4px; }
.tile:hover .tile-veil, .tile:focus-visible .tile-veil { opacity: 1; }
@media (hover: none) { .tile-veil { opacity: 1; background: linear-gradient(to top, rgba(0, 0, 0, 0.78) 0%, transparent 55%); } }
.tile-kind { position: absolute; top: 10px; left: 10px; display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border-radius: 999px; font-size: 0.68rem; font-weight: 800; background: rgba(0, 0, 0, 0.55); color: #fff; backdrop-filter: blur(8px); }
.play-badge { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.play-badge span { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 50%; background: rgba(0, 0, 0, 0.45); backdrop-filter: blur(10px); border: 1px solid rgba(255, 255, 255, 0.25); font-size: 22px; color: #fff; }

/* ── Лайтбокс ────────────────────────────────────────────── */
.lightbox { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 16px; }
.lb-backdrop { position: absolute; inset: 0; background: rgba(4, 4, 8, 0.92); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
.lightbox-inner { position: relative; z-index: 2; max-width: min(1100px, 100%); max-height: 88dvh; width: 100%; overflow-y: auto; overscroll-behavior: contain; }
.lightbox img, .lightbox video { max-height: 70dvh; width: auto; max-width: 100%; margin: 0 auto; display: block; border-radius: 18px; }
.lightbox iframe { width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: 18px; }
.lb-close, .lb-nav {
  position: absolute; z-index: 5; display: grid; place-items: center;
  border-radius: 50%; background: rgba(255, 255, 255, 0.12); border: 1px solid var(--line-strong);
  color: #fff; cursor: pointer; backdrop-filter: blur(10px); transition: background 0.25s, transform 0.25s var(--ease);
}
.lb-close:hover, .lb-nav:hover { background: rgba(255, 255, 255, 0.24); }
.lb-close:active, .lb-nav:active { transform: scale(0.92); }
.lb-close { top: calc(14px + env(safe-area-inset-top)); right: 14px; width: 48px; height: 48px; font-size: 20px; z-index: 6; }
.lb-nav { top: 50%; transform: translateY(-50%); width: 46px; height: 46px; font-size: 20px; }
.lb-nav:active { transform: translateY(-50%) scale(0.92); }
.lb-prev { left: 12px; }
.lb-next { right: 12px; }
@media (min-width: 640px) { .lb-prev { left: 24px; } .lb-next { right: 24px; } }

/* ── Загрузка файлов ─────────────────────────────────────── */
.dropzone { border: 2px dashed var(--line-strong); border-radius: var(--radius); padding: 34px 20px; text-align: center; transition: border-color 0.3s, background 0.3s, transform 0.3s var(--ease); }
.dropzone[data-over="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); transform: scale(1.01); }
.progress-track { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress-bar { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.25s var(--ease); }

/* ── Тосты ───────────────────────────────────────────────── */
.toasts { position: fixed; z-index: 120; left: 50%; transform: translateX(-50%); bottom: calc(20px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; padding: 11px 16px; border-radius: 16px; font-size: 0.86rem; font-weight: 600; background: rgba(20, 20, 30, 0.86); color: #fff; border: 1px solid var(--line-strong); backdrop-filter: blur(18px); box-shadow: var(--shadow); animation: toast-in 0.4s var(--ease); }
.toast[data-kind="error"] { border-color: color-mix(in srgb, var(--live) 55%, transparent); }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(0.96); } }

/* ── Появление ───────────────────────────────────────────── */
.reveal { animation: reveal 0.75s var(--ease) both; }
.reveal-1 { animation-delay: 0.05s; }
.reveal-2 { animation-delay: 0.12s; }
.reveal-3 { animation-delay: 0.19s; }
.reveal-4 { animation-delay: 0.26s; }
@keyframes reveal { from { opacity: 0; transform: translateY(16px); filter: blur(6px); } }

.htmx-request .htmx-hide { opacity: 0.5; }
.saved-flash { animation: saved 1.1s var(--ease); }
@keyframes saved { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--mint) 60%, transparent); } 100% { box-shadow: 0 0 0 10px transparent; } }

/* ── Скроллбар ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: content-box; }

.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* ── Доступность ─────────────────────────────────────────── */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
[x-cloak] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* ── Иконки lucide ───────────────────────────────────────── */
svg.lucide { width: 1em; height: 1em; flex: none; stroke-width: 2; }
i[data-lucide] { display: inline-block; width: 1em; height: 1em; }
.text-accent { color: var(--accent); }
.text-live { color: var(--live); }
.text-mint { color: var(--mint); }
.bg-accent-soft { background: color-mix(in srgb, var(--accent) 16%, transparent); }

/* Полоса доли в топ-списках (ширина берётся из data-share) */
.progress-bar[data-share] { width: 0; }
.chip[data-active="true"] { color: var(--text); border-color: color-mix(in srgb, var(--accent) 60%, transparent); background: color-mix(in srgb, var(--accent) 22%, transparent); }

/* ── Телефоны ────────────────────────────────────────────── */
@media (max-width: 640px) {
  :root { --radius: 22px; --radius-sm: 14px; }

  .glass { backdrop-filter: saturate(160%) blur(18px); -webkit-backdrop-filter: saturate(160%) blur(18px); }

  /* лайтбокс: стрелки уводим вниз, чтобы не лежали на картинке */
  .lb-nav { top: auto; bottom: calc(18px + env(safe-area-inset-bottom)); transform: none; width: 52px; height: 52px; }
  .lb-nav:active { transform: scale(0.92); }
  .lb-prev { left: 18px; }
  .lb-next { right: 18px; }
  .lightbox-inner { padding-bottom: 84px; }
  .lightbox img, .lightbox video { max-height: 62dvh; }

  /* сетка галереи плотнее */
  .masonry { column-gap: 10px; }
  .masonry > * { margin-bottom: 10px; }
  .tile { border-radius: 16px; }

  /* тепловая карта прокручивается вбок, а не ломает вёрстку */
  .heat { gap: 2px; min-width: 460px; }
  .heat-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* нижняя панель админки: пять пунктов помещаются */
  .tabbar { gap: 2px; padding: 6px; border-radius: 20px; }
  .tabbar a { font-size: 0.58rem; padding: 7px 2px; }

  /* поля и кнопки крупнее пальца, без зума iOS */
  .input-x, textarea.input-x, select.input-x { font-size: 16px; padding: 12px 14px; }
  .btn-x { padding: 12px 16px; }
  .btn-icon { width: 44px; height: 44px; }
  .switch { width: 52px; height: 30px; }
  .switch::after { width: 24px; height: 24px; }
  .switch[data-on="true"]::after { transform: translateX(22px); }

  /* карточка профиля */
  .avatar-wrap { width: 112px; height: 112px; }
  .link-row { padding: 12px 14px; }
  .link-row:hover { transform: none; }

  /* строки медиа не расползаются */
  .media-row { padding: 10px; }
}

@media (max-width: 380px) {
  .tabbar a span { font-size: 0.54rem; }
  .chip { padding: 4px 9px; font-size: 0.7rem; }
}

/* ═══════════════════════════════════════════════════════════
   Анимации и эффекты
   ═══════════════════════════════════════════════════════════ */

/* ── Появление при скролле ───────────────────────────────── */
html.js [data-reveal] { opacity: 0; transform: translateY(20px) scale(0.985); }
html.js [data-reveal].is-in {
  opacity: 1; transform: none;
  transition: opacity 0.7s var(--ease) var(--d, 0ms), transform 0.7s var(--ease) var(--d, 0ms);
}

/* ── Наклон карточки за курсором ─────────────────────────── */
[data-tilt] {
  transform: perspective(1000px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform 0.6s var(--ease), box-shadow 0.6s var(--ease);
  transform-style: preserve-3d;
}
[data-tilt].tilting { transition: transform 0.12s linear; }
[data-tilt]::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(420px circle at var(--gx, 50%) var(--gy, 0%), rgba(255, 255, 255, 0.10), transparent 45%);
  opacity: 0; transition: opacity 0.4s;
}
[data-tilt].tilting::after { opacity: 1; }

/* ── Живая рамка карточки профиля ────────────────────────── */
.card-aurora { position: relative; }
.card-aurora::before {
  content: ""; position: absolute; inset: -1px; border-radius: inherit; padding: 1px;
  background: conic-gradient(from 0deg, transparent 15%, var(--accent), var(--accent-2), transparent 60%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  opacity: 0.55; animation: aurora-spin 8s linear infinite; pointer-events: none;
}
body[data-live="true"] .card-aurora::before { opacity: 0.9; animation-duration: 4s; }
@keyframes aurora-spin { to { transform: rotate(360deg); } }

/* ── Волна нажатия ───────────────────────────────────────── */
.btn-x, .link-row, .chip, .nav-item, .tile { position: relative; overflow: hidden; }
.wave {
  position: absolute; width: 12px; height: 12px; border-radius: 50%;
  background: currentColor; opacity: 0.28; pointer-events: none;
  transform: translate(-50%, -50%) scale(0);
  animation: wave 0.6s var(--ease) forwards;
}
@keyframes wave { to { transform: translate(-50%, -50%) scale(26); opacity: 0; } }

/* ── Полоса загрузки ─────────────────────────────────────── */
.hx-bar {
  position: fixed; top: 0; left: 0; height: 2px; width: 0; z-index: 200;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 12px var(--accent); opacity: 0;
  transition: width 0.5s var(--ease), opacity 0.25s;
}
.hx-bar[data-on="true"] { width: 82%; opacity: 1; }
.hx-bar[data-on="false"] { width: 100%; opacity: 0; }

/* ── Ссылки появляются каскадом ──────────────────────────── */
.link-row { animation: slide-in 0.6s var(--ease) both; }
.link-row:nth-child(1) { animation-delay: 0.06s; }
.link-row:nth-child(2) { animation-delay: 0.12s; }
.link-row:nth-child(3) { animation-delay: 0.18s; }
.link-row:nth-child(4) { animation-delay: 0.24s; }
.link-row:nth-child(5) { animation-delay: 0.30s; }
.link-row:nth-child(n + 6) { animation-delay: 0.36s; }
@keyframes slide-in { from { opacity: 0; transform: translateX(-14px); } }

.link-row .link-ico { transition: transform 0.45s var(--ease), background 0.3s; }
.link-row:hover .link-ico { transform: scale(1.1) rotate(-6deg); background: color-mix(in srgb, var(--accent) 32%, transparent); }

/* ── Аватар: дыхание и отклик ────────────────────────────── */
.avatar-wrap { transition: transform 0.5s var(--ease); }
.avatar-wrap:hover { transform: scale(1.03); }
.avatar-img { box-shadow: 0 12px 40px -12px rgba(0, 0, 0, 0.9); }
body[data-live="true"] .avatar-ring { animation: spin 4s linear infinite, breathe 2.6s ease-in-out infinite; }
@keyframes breathe { 50% { filter: drop-shadow(0 0 16px var(--live)); } }
.avatar-wrap[data-egg="hot"] .avatar-ring { animation-duration: 1.6s; }

/* ── Чипы и кнопки ───────────────────────────────────────── */
.chip { transition: transform 0.3s var(--ease), background 0.3s, border-color 0.3s, color 0.3s; }
.chip:hover { transform: translateY(-1px); }
.btn-x[data-variant="primary"]::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(115deg, transparent 35%, rgba(255, 255, 255, 0.35) 50%, transparent 65%);
  transform: translateX(-140%); transition: transform 0.8s var(--ease);
}
.btn-x[data-variant="primary"]:hover::after { transform: translateX(140%); }

/* ── Плитки галереи ──────────────────────────────────────── */
.tile { transition: transform 0.5s var(--ease), box-shadow 0.5s var(--ease), border-color 0.4s; }
.tile:hover { transform: translateY(-4px); box-shadow: 0 22px 48px -22px rgba(0, 0, 0, 0.9); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.tile .tile-kind { transform: translateY(-6px); opacity: 0; transition: transform 0.35s var(--ease), opacity 0.35s; }
.tile:hover .tile-kind, .tile:focus-visible .tile-kind { transform: none; opacity: 1; }
@media (hover: none) { .tile .tile-kind { transform: none; opacity: 1; } }
.play-badge span { transition: transform 0.45s var(--ease), background 0.3s; }
.tile:hover .play-badge span { transform: scale(1.14); background: color-mix(in srgb, var(--accent) 65%, rgba(0, 0, 0, 0.4)); }

/* ── Лайтбокс: мягкое появление ──────────────────────────── */
.lightbox-inner { animation: lb-pop 0.45s var(--ease); }
@keyframes lb-pop { from { opacity: 0; transform: scale(0.94) translateY(12px); filter: blur(8px); } }
.lb-close, .lb-nav { animation: fade-in 0.5s var(--ease) 0.1s both; }
@keyframes fade-in { from { opacity: 0; } }

/* ── Шапки густеют при прокрутке ─────────────────────────── */
html[data-scrolled="true"] header.sticky { box-shadow: 0 10px 30px -18px rgba(0, 0, 0, 0.9); }

/* ── Карточки статистики ─────────────────────────────────── */
.glass-hover:hover .link-ico { transform: scale(1.08); }
.progress-bar { transition: width 0.9s var(--ease); }
.hm-cell { transition: transform 0.25s var(--ease), filter 0.25s; }
.hm-cell:hover { filter: brightness(1.35); }

/* ── Переключатель ───────────────────────────────────────── */
.switch::after { transition: transform 0.34s var(--ease), width 0.2s; }
.switch:active::after { width: 28px; }

/* ── Мягкая смена содержимого по SSE ─────────────────────── */
[sse-swap] > * { animation: soft-in 0.45s var(--ease); }
@keyframes soft-in { from { opacity: 0.35; transform: translateY(6px); } }

@media (prefers-reduced-motion: reduce) {
  html.js [data-reveal] { opacity: 1; transform: none; }
  .link-row, .lightbox-inner, [sse-swap] > * { animation: none; }
  .card-aurora::before { animation: none; }
}
