:root {
  --bg: #ffffff;
  --card: rgba(255,255,255,.86);
  --text: #111111;
  --muted: #777777;
  --line: #e8e8e8;
  --hover: #f1f1f1;
  --accent: #e60023;
  --glass: rgba(255,255,255,.55);
  --border: #000;
}
body.night {
  --card: rgba(20,20,24,.55);
  --text: #f4f4f4;
  --muted: #b5b5b5;
  --line: rgba(255,255,255,.15);
  --hover: rgba(255,255,255,.1);
  --border: rgba(255,255,255,.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Noto Sans Display", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px 16px;
  overflow-x: hidden;
  transition: color .3s;
}

/* ---------- фон ---------- */
.card { position: relative; z-index: 1; }
.theme { z-index: 5; }
.bg { position: fixed; inset: 0; z-index: 0; overflow: hidden; }
.bg video, .bg img, .bg svg {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block;
  object-position: var(--focus, center) center;
}

/* карточка слева на широких экранах — чтобы справа был виден фон */
@media (min-width: 1000px) {
  body.card-left { justify-items: start; padding-left: 4vw; }
  body.card-left .card { width: min(880px, 50vw); }
}
.bg .dim {
  position: absolute; inset: 0; background: #000;
  opacity: 0; transition: opacity .6s ease;
}
body.night .bg .dim { opacity: var(--dim, .5); }
.bg .night-layer { opacity: 0; transition: opacity .8s ease; }
body.night .bg .night-layer { opacity: 1; }
.bg.default {
  background:
    radial-gradient(ellipse at 50% 120%, #2f7a2a 0 35%, transparent 36%),
    linear-gradient(#5b8fc7 0%, #a7c7e7 55%, #3f8d33 56%, #2a6a22 100%);
}

/* ---------- карточка ---------- */
.card {
  width: min(960px, 100%);
  height: min(560px, calc(100vh - 48px));
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  border: 2px solid var(--border);
  border-radius: 48px;
  overflow: hidden;
  background: var(--card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.media { background: #000; position: relative; overflow: hidden; }
.media > img, .media > video {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  user-select: none; -webkit-user-drag: none; pointer-events: none;
}
.media.clickable { cursor: pointer; -webkit-tap-highlight-color: transparent; outline: none; }
.media.clickable:focus-visible { box-shadow: inset 0 0 0 3px var(--accent); }

/* смена фото по нажатию: новое раскрывается кругом из точки нажатия,
   проявляясь из размытия; старое уходит вглубь */
.media > .photo-in, .media > .photo-out { transform-origin: var(--x, 50%) var(--y, 50%); }
.media > .photo-in  { z-index: 1; animation: photo-in .9s cubic-bezier(.65, 0, .35, 1) both; }
.media > .photo-out { animation: photo-out .9s cubic-bezier(.65, 0, .35, 1) both; }
@keyframes photo-in {
  from { clip-path: circle(0% at var(--x, 50%) var(--y, 50%)); filter: blur(16px); transform: scale(1.15); }
  to   { clip-path: circle(150% at var(--x, 50%) var(--y, 50%)); filter: blur(0); transform: scale(1); }
}
@keyframes photo-out {
  to { filter: blur(8px) brightness(.85); transform: scale(1.06); }
}
.media.masked > img, .media.masked > video {
  inset: 8%; width: 84%; height: 84%;
  -webkit-mask: var(--mask) center / contain no-repeat;
          mask: var(--mask) center / contain no-repeat;
}

.panel {
  display: flex; flex-direction: column;
  padding: 24px 18px 0 18px;
  min-height: 0;
  position: relative;
}

.top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.like {
  display: flex; align-items: center; gap: 8px;
  background: none; border: 0; color: var(--text);
  font-family: inherit; font-weight: 600; font-size: 18px; cursor: pointer;
}
.like svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; transition: transform .15s; }
.like.on svg { fill: var(--accent); stroke: var(--accent); }
.like:active svg { transform: scale(.85); }
.like.pop svg { animation: like-pop .45s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes like-pop { 0% { transform: scale(.7); } 60% { transform: scale(1.25); } 100% { transform: scale(1); } }
#likeCount { display: inline-block; font-variant-numeric: tabular-nums; }
#likeCount.bump { animation: count-bump .35s ease; }
@keyframes count-bump { 0% { transform: translateY(-6px); opacity: 0; } 100% { transform: none; opacity: 1; } }

.save {
  background: var(--accent); color: #fff; text-decoration: none;
  font-weight: 700; font-size: 14px;
  padding: 10px 16px; border-radius: 999px;
}
.save:hover { filter: brightness(.92); }

.author { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.author img { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; }
.author b { font-size: 16px; }

.status-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.status { font-size: 15px; min-height: 1.3em; white-space: pre-wrap; min-width: 0; }
.views {
  flex: none; display: inline-flex; align-items: center; gap: 4px;
  color: var(--muted); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.views[hidden] { display: none; }
.views svg { width: 14px; height: 14px; fill: currentColor; }
.status__caret {
  display: inline-block; width: 2px; height: 1.1em; margin-left: 2px; border-radius: 1px;
  background: currentColor; vertical-align: -0.18em;
  animation: caret-blink 1s steps(1) infinite;
}
.status.is-typing .status__caret { animation: none; }
@keyframes caret-blink { 50% { opacity: 0; } }

.buttons { display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.buttons a {
  flex: 1 1 0; min-width: 64px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  color: #fff; text-decoration: none; font-weight: 700; font-size: 13px;
  padding: 8px 12px; border-radius: 999px;
  background: var(--c, #555);
  transition: transform .15s, filter .15s;
}
.buttons a:hover { transform: translateY(-1px); filter: brightness(1.08); }
.buttons svg { width: 16px; height: 16px; fill: currentColor; flex: none; }

h2 { font-size: 15px; font-weight: 700; margin: 14px 0 8px; }

.tracks {
  list-style: none; overflow-y: auto; flex: 1; min-height: 0;
  padding-bottom: 70px; margin-right: -8px; padding-right: 8px;
}
.tracks::-webkit-scrollbar { width: 4px; }
.tracks::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
.tracks li {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 6px; border-radius: 10px; cursor: pointer; font-size: 12.5px;
}
.tracks li:hover, .tracks li.active { background: var(--hover); }
.tracks .cover {
  width: 32px; height: 32px; border-radius: 4px; flex: none;
  background: var(--line) center / cover;
}
.tracks .t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tracks .d { color: var(--muted); font-size: 11px; }
.tracks .dl {
  width: 18px; height: 18px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 4px; color: var(--muted);
}
.tracks .dl svg { width: 10px; height: 10px; fill: currentColor; }
.tracks .empty { color: var(--muted); cursor: default; }

.player {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px 14px;
  background: var(--glass);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.player[hidden] { display: none; }
body.night .player { background: rgba(20,20,24,.6); }
.pp {
  width: 26px; height: 26px; border-radius: 50%; border: 0; flex: none;
  background: #000; color: #fff; cursor: pointer; display: grid; place-items: center;
}
body.night .pp { background: #fff; color: #000; }
.pp svg { width: 10px; height: 10px; fill: currentColor; }
.pinfo { flex: 1; min-width: 0; }
.ptitle { font-size: 11.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ptime { font-size: 10px; color: var(--muted); }
.bar { height: 3px; background: var(--line); border-radius: 3px; margin-top: 3px; cursor: pointer; }
.bar i { display: block; height: 100%; width: 0; background: var(--text); border-radius: 3px; }
.vol { width: 60px; accent-color: var(--text); }

/* ---------- появление сайта ---------- */
.bg { animation: bg-in 1.2s ease both; }
@keyframes bg-in { from { opacity: 0; } }
/* backwards: после окончания анимации у карточки не остаётся filter/transform —
   иначе на телефоне «прилипает» плеер, прижатый к низу экрана */
.card { animation: card-in 1s cubic-bezier(.2, .8, .2, 1) .15s backwards; }
@keyframes card-in {
  from { opacity: 0; transform: translateY(28px) scale(.97); filter: blur(14px); }
  to   { opacity: 1; transform: none; filter: none; }
}
/* содержимое справа выезжает по очереди */
.panel > :not(.player) { animation: item-in .7s cubic-bezier(.2, .8, .2, 1) backwards; }
.panel > :nth-child(1) { animation-delay: .45s; }
.panel > :nth-child(2) { animation-delay: .55s; }
.panel > :nth-child(3) { animation-delay: .65s; }
.panel > :nth-child(4) { animation-delay: .75s; }
.panel > :nth-child(5) { animation-delay: .85s; }
.panel > :nth-child(6) { animation-delay: .95s; }
@keyframes item-in { from { opacity: 0; transform: translateY(10px); } }
.theme { animation: item-in .7s ease 1.1s backwards; }

/* ---------- подсказка «нажми на фото» ---------- */
.tap-hint {
  position: absolute; left: 50%; bottom: 18px; z-index: 5;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  padding: 7px 14px 7px 10px; border-radius: 999px;
  background: rgba(0, 0, 0, .45); color: #fff;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  font-size: 13px; font-weight: 600; white-space: nowrap; pointer-events: none;
  animation: hint-in .6s ease 1.6s both;
  transition: opacity .4s ease, transform .4s ease;
}
.tap-hint i {
  position: relative; width: 10px; height: 10px; border-radius: 50%; background: #fff; flex: none;
}
.tap-hint i::after {
  content: ""; position: absolute; inset: -5px; border-radius: 50%;
  border: 2px solid #fff; animation: hint-pulse 1.4s ease-out infinite;
}
.tap-hint.hide { opacity: 0; transform: translateX(-50%) translateY(6px); }
@keyframes hint-in { from { opacity: 0; transform: translateX(-50%) translateY(8px); } }
@keyframes hint-pulse { from { transform: scale(.6); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }

/* ---------- плавная смена темы ---------- */
html.theme-fade *, html.theme-fade *::before, html.theme-fade *::after {
  transition: background-color .6s ease, color .6s ease, border-color .6s ease,
              fill .6s ease, stroke .6s ease, box-shadow .6s ease, opacity .8s ease, left .25s ease !important;
}

/* ---------- комментарии ---------- */
.bubbles { position: fixed; inset: 0; z-index: 3; pointer-events: none; overflow: hidden; }
/* Пузырёк: внешний слой равномерно плывёт вверх (без рывков),
   внутренний — проявляется и исчезает с «motion blur»: размытие +
   лёгкое вертикальное растяжение, как у движущегося объекта.
   Без backdrop-filter — он на движущихся элементах даёт подтормаживания. */
.bubble {
  position: absolute; max-width: min(260px, 70vw);
  will-change: transform;
  animation: bubble-drift var(--life, 9s) linear both;
}
.bubble > div {
  padding: 7px 12px; border-radius: 14px;
  background: rgba(255, 255, 255, .62); color: #111;
  border: 1px solid rgba(255, 255, 255, .55);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .10);
  font-size: 13px; line-height: 1.3; overflow-wrap: anywhere;
  transform-origin: 50% 100%;
  will-change: opacity, filter, transform;
  animation: bubble-blur var(--life, 9s) both;
}
.bubble b { display: block; font-size: 11px; font-weight: 700; opacity: .65; margin-bottom: 1px; }
.bubble.mine > div { border-color: rgba(230, 0, 35, .55); }
body.night .bubble > div { background: rgba(20, 20, 24, .58); color: #f2f2f2; border-color: rgba(255, 255, 255, .14); }
@keyframes bubble-drift {
  from { transform: translate3d(0, 28px, 0); }
  to   { transform: translate3d(0, -64px, 0); }
}
@keyframes bubble-blur {
  0%   { opacity: 0; filter: blur(10px); transform: scale(.94, 1.12); animation-timing-function: cubic-bezier(.2, .7, .3, 1); }
  14%  { opacity: 1; filter: blur(0);    transform: scale(1, 1); }
  80%  { opacity: 1; filter: blur(0);    transform: scale(1, 1);  animation-timing-function: cubic-bezier(.6, 0, .8, .4); }
  100% { opacity: 0; filter: blur(8px);  transform: scale(.96, 1.1); }
}

.cbtn {
  position: fixed; right: 92px; bottom: 24px; z-index: 5;
  height: 30px; padding: 0 12px 0 10px; border: 0; border-radius: 999px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  background: #f3f3f3; color: #222; font: 600 13px "Noto Sans Display", system-ui, sans-serif;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .15);
  animation: item-in .7s ease 1.2s backwards;
}
.cbtn[hidden] { display: none; }
.cbtn svg { width: 15px; height: 15px; fill: currentColor; }
body.night .cbtn { background: #222; color: #eee; }

.cform {
  position: fixed; right: 24px; bottom: 66px; z-index: 6;
  width: min(320px, calc(100vw - 32px));
  display: grid; gap: 8px; padding: 12px; border-radius: 18px;
  background: var(--glass); color: var(--text);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
  animation: item-in .25s ease both;
}
body.night .cform { background: rgba(20, 20, 24, .7); }
.cform[hidden] { display: none; }
.cform input, .cform textarea {
  width: 100%; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, .6); color: var(--text); font: 14px "Noto Sans Display", system-ui, sans-serif; resize: none;
}
body.night .cform input, body.night .cform textarea { background: rgba(0, 0, 0, .35); }
.cform .hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.crow { display: flex; align-items: center; gap: 8px; }
.crow small { flex: 1; color: var(--muted); font-size: 12px; }
.crow small.err { color: var(--accent); }
.cclose, .csend { border: 0; border-radius: 999px; padding: 7px 12px; cursor: pointer; font: 600 13px "Noto Sans Display", system-ui, sans-serif; }
.cclose { background: transparent; color: var(--muted); }
.csend { background: var(--accent); color: #fff; }
.csend:disabled { opacity: .6; cursor: default; }

@media (max-width: 720px) {
  .cbtn { right: auto; left: 16px; top: 16px; bottom: auto; }
  .cform { right: 16px; left: 16px; width: auto; top: 56px; bottom: auto; }
}

/* ---------- переключатель день/ночь ---------- */
.theme {
  position: fixed; right: 24px; bottom: 24px;
  width: 58px; height: 30px; border-radius: 999px; border: 0; cursor: pointer;
  background: #f3f3f3; box-shadow: 0 4px 14px rgba(0,0,0,.15);
}
.theme i {
  position: absolute; top: 4px; left: 5px; width: 22px; height: 22px; border-radius: 50%;
  background: #222; transition: left .25s;
}
body.night .theme { background: #222; }
body.night .theme i { left: 31px; background: #fff; }

/* ---------- телефон ---------- */
@media (max-width: 720px) {
  body { display: block; padding: 0; }
  .card {
    grid-template-columns: minmax(0, 1fr); height: auto; border-radius: 0; border: 0;
  }
  .media { aspect-ratio: 1; border-radius: 0 0 32px 32px; }
  .panel { padding: 16px 16px 0; }
  .tracks { max-height: none; overflow: visible; padding-bottom: 80px; }
  .player { position: fixed; padding: 10px 16px 14px; }
  .theme { top: 16px; right: 16px; bottom: auto; }
}
