/* ============================================================
   Кинотека — компоненты и раскладка.
   Токены — в tokens.css. Стекла и размытия нет: всё построено на
   фоне, поверхностях и hairline-линиях, как в референсе.
   ============================================================ */

@import url("https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500&family=Unbounded:wght@300;400;500;600;700;800&display=swap");

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* hidden должен побеждать display из компонентов */
[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Иконки: контур 1.8, заливка — только у отмеченных в спрайте ---------- */
.icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon--sm {
  width: 16px;
  height: 16px;
}

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 15px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--raised);
  color: var(--text);
  font: 600 14px/1 var(--sans);
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--d-fast), border-color var(--d-fast), color var(--d-fast), opacity var(--d-fast), transform .18s var(--ease-spring);
}

.btn:hover {
  background: var(--surface-2);
}

.btn:active {
  transform: scale(.95);
}

.btn:disabled {
  opacity: .35;
  pointer-events: none;
}

/* Инвертированная кнопка — главное действие */
.btn--primary {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}

.btn--primary:hover {
  background: var(--text);
  opacity: .86;
}

.btn--ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-2);
}

.btn--ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn--icon {
  width: 38px;
  padding: 0;
}

.btn--sm {
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
}

.btn--danger {
  color: var(--text-2);
}

/* Круглая кнопка воспроизведения */
.btn--play {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}

.btn--play:hover {
  background: var(--text);
  opacity: .86;
}

/* ---------- Поля ввода ---------- */
.field {
  min-width: 0;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-lg);
  background: var(--raised);
  color: var(--text);
  font: 400 15px/1.4 var(--sans);
  transition: border-color var(--t);
}

.field::placeholder {
  color: var(--muted);
}

.field:focus {
  outline: none;
  border-color: var(--text-2);
}

/* ---------- Шапка ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: var(--header-h);
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  margin: 0;
  font: 800 17px/1 var(--sans);
  letter-spacing: -.01em;
  white-space: nowrap;
}

.brand__mark {
  display: grid;
  place-items: center;
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--text);
  color: var(--bg);
}

.brand__mark .icon {
  width: 17px;
  height: 17px;
}

.top__actions {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.members {
  display: flex;
  align-items: center;
  gap: 10px;
}

.members__stack {
  display: flex;
}

.members__stack .avatar + .avatar {
  margin-left: -8px;
}

.members__count {
  color: var(--muted);
  font: 300 14px/1 var(--sans);
  white-space: nowrap;
}

#btnProfile {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 50%;
}

/* ---------- Аватары: монограмма на нейтральной поверхности ---------- */
.avatar {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--surface-2);
  color: var(--text-2);
  box-shadow: 0 0 0 2px var(--bg);
  font: 600 13px/1 var(--sans);
  user-select: none;
}

.avatar--sm {
  width: 28px;
  height: 28px;
  font-size: 12px;
}

.avatar--lg {
  width: 72px;
  height: 72px;
  font-size: 26px;
}

.avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ---------- Раскладка: видео слева, панель справа; на узком экране — столбцом ---------- */
/* На телефоне кадр сверху, а переписка занимает весь остаток экрана */
/* Отступы под вырез и домашний индикатор: на iPhone при установке
   на домашний экран страница заходит под строку состояния (viewport-fit=cover) */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.layout {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.stage {
  display: flex;
  flex: 0 1 auto;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  min-height: 0;
  padding: 16px 16px 24px;
  overflow-y: auto;
}

/* Блоки сцены не сжимаются: при низком окне сцена прокручивается, а строка управления не режется */
.stage > * {
  flex-shrink: 0;
}

.now {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font: 300 13px/1.4 var(--sans);
}

.now__title {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font: 800 20px/1.25 var(--sans);
  letter-spacing: -.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.now__meta {
  margin: 2px 0 0;
  overflow: hidden;
  color: var(--muted);
  font: 300 14px/1.4 var(--sans);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 200px;
  min-width: 0;
  border-top: 1px solid var(--line);
}

/* ---------- Плеер: кадр 16:9 и строка управления под ним одним блоком ---------- */
.player {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--raised);
}

.player__screen {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
}

.player__media {
  position: absolute;
  inset: 0;
}

.player__frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* Постер при паузе: закрывает чужой оверлей плеера (название, логотип, большая кнопка) */
.player__poster {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--d-base) var(--ease-out);
}

.player.is-paused .player__poster {
  opacity: 1;
}

.player__poster img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: .72;
}

.player__big-play {
  position: relative;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .94);
  color: #0b0b0c;
}

.player__big-play .icon {
  width: 26px;
  height: 26px;
  margin-left: 3px;
  fill: currentColor;
  stroke: none;
}

/* Прозрачный щит: перехватывает клики раньше плеера и его оверлеев */
.player__shield {
  position: absolute;
  inset: 0;
  z-index: 2;
  cursor: pointer;
}

.player__empty {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  background: var(--raised);
  text-align: center;
}

.player__empty h2 {
  margin: 12px 0 0;
  color: var(--text);
  font: 800 24px/1.15 var(--sans);
  letter-spacing: -.02em;
}

.player__empty p {
  max-width: 420px;
  margin: 0;
  color: var(--muted);
  font-weight: 300;
  font-size: 15px;
  line-height: 1.5;
}

.player__empty-glyph {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  color: var(--text-2);
}

/* Пустой плеер: карточка с формой тянется по содержимому, а не режется 16:9-рамкой */
.player__screen:has(> .player__empty:not([hidden])) {
  aspect-ratio: auto;
}

.player__empty:not([hidden]) {
  position: relative;
  min-height: 280px;
}

/* Строка «ссылка + кнопка» — тот же приём, что у emoji.wivvi.net */
.prompt {
  display: flex;
  align-items: center;
  gap: 6px;
  width: min(460px, 100%);
  margin-top: 16px;
  padding: 5px 5px 5px 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-lg);
  background: var(--bg);
}

.prompt:focus-within {
  border-color: var(--text-2);
}

.prompt__input {
  flex: 1;
  min-width: 0;
  height: 36px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  font: 400 15px/1 var(--sans);
}

.prompt__input::placeholder {
  color: var(--muted);
}

.prompt__input:focus {
  outline: none;
}

/* Строка управления: на широком экране — в одну линию, на узком — переносится */
.player__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  padding: 8px 10px;
  border-top: 1px solid var(--line);
  background: var(--raised);
}

/* Без ролика строка управления видна, но не работает */
.player.is-empty .player__bar > :not(.sync-badge) {
  opacity: .35;
  pointer-events: none;
}

.time {
  min-width: 44px;
  color: var(--muted);
  font: 500 13px/1 var(--mono);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.player__sound {
  color: var(--text);
}

.sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 6px;
  color: var(--muted);
  font: 400 13px/1 var(--sans);
  white-space: nowrap;
}

.sync-badge__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text);
}

.sync-badge.is-syncing .sync-badge__dot {
  animation: pulse 1s var(--ease) infinite;
}

/* Полоса позиции: заливка и бегунок двигаются трансформациями */
.scrubber {
  position: relative;
  flex: 1;
  min-width: 80px;
  height: 28px;
  cursor: pointer;
  touch-action: none;
}

.scrubber__track {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 4px;
  margin-top: -2px;
  overflow: hidden;
  border-radius: 4px;
  background: var(--surface-2);
}

.scrubber__fill {
  position: absolute;
  inset: 0;
  background: var(--text);
  transform-origin: left center;
  transform: scaleX(var(--p, 0));
  transition: transform .3s var(--ease-out);
}

.scrubber.is-dragging .scrubber__fill {
  transition: none;
}

.scrubber__knob {
  position: absolute;
  top: 50%;
  left: 0;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: var(--text);
  transform: translateX(calc(var(--p, 0) * var(--track-w, 0px)));
  transition: transform .3s var(--ease-out);
}

.scrubber.is-dragging .scrubber__knob {
  transition: none;
}

/* Бегунок виден на наведении и фокусе; на тач-экране — всегда */
.scrubber:hover .scrubber__knob,
.scrubber:focus-visible .scrubber__knob,
.scrubber.is-dragging .scrubber__knob {
  transform: translateX(calc(var(--p, 0) * var(--track-w, 0px))) scale(1.15);
}

@media (hover: none) {
  .scrubber__knob {
    transform: translateX(calc(var(--p, 0) * var(--track-w, 0px))) scale(1.15);
  }
}

/* Кнопка-заглушка «Вернуть на место», пока кадр в отдельном окне */
.stage__away {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  aspect-ratio: 16 / 9;
  padding: 24px;
  border: 1px dashed var(--line-2);
  border-radius: var(--radius-xl);
  text-align: center;
}

.stage__away h2 {
  margin: 12px 0 0;
  font: 800 22px/1.2 var(--sans);
  letter-spacing: -.02em;
}

.stage__away p {
  max-width: 380px;
  margin: 0 0 12px;
  color: var(--muted);
  font-weight: 300;
  font-size: 15px;
}

/* ---------- Боковая панель: вкладки «Чат» и «Плейлист» ---------- */
.side__tabs {
  position: relative;
  display: flex;
  gap: 4px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
}

.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 46px;
  padding: 0 12px;
  border: 0;
  background: none;
  color: var(--muted);
  font: 600 15px/1 var(--sans);
  cursor: pointer;
  transition: color var(--d-fast), transform .25s var(--ease-spring);
}

.tab:hover {
  color: var(--text);
}

.tab[aria-selected="true"] {
  color: var(--text);
}


.tab__count {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  font: 600 12px/20px var(--sans);
  text-align: center;
}

.pane {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.pane__empty {
  margin: auto;
  color: var(--muted);
  font-weight: 300;
  font-size: 14px;
  text-align: center;
}

/* ---------- Чат ---------- */
.chat {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  padding: 16px 14px 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  contain: layout paint;
}

.msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-top: 2px;
}

.msg.is-tail {
  margin-top: 10px;
}

.msg__avatar-slot {
  flex: 0 0 28px;
  width: 28px;
}

.msg__col {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  max-width: 78%;
}

.msg__author {
  margin: 0 0 4px 2px;
  color: var(--muted);
  font: 500 13px/1.2 var(--sans);
}

.msg__bubble {
  padding: 8px 13px;
  border-radius: 16px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  user-select: text;
}

.msg:not(.is-tail) .msg__bubble {
  border-bottom-left-radius: 6px;
}

.msg__time {
  margin: 3px 4px 0;
  color: var(--muted);
  font: 300 11px/1.2 var(--sans);
}

.msg__reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.msg__react-btn {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--muted);
  opacity: 0;
  cursor: pointer;
  transition: opacity var(--t), background var(--t);
}

.msg:hover .msg__react-btn,
.msg__react-btn:focus-visible {
  opacity: 1;
}

.msg__react-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

@media (hover: none) {
  .msg__react-btn {
    opacity: .7;
  }
}

/* Свои сообщения — справа и инвертированы */
.msg--own {
  justify-content: flex-end;
}

.msg--own .msg__avatar-slot {
  display: none;
}

.msg--own .msg__col {
  align-items: flex-end;
}

.msg--own .msg__bubble {
  background: var(--text);
  color: var(--bg);
}

.msg--own:not(.is-tail) .msg__bubble {
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 6px;
}

.msg--own .msg__react-btn {
  order: -1;
}

.msg--system {
  justify-content: center;
}

.msg--system .msg__bubble {
  padding: 2px 8px;
  background: none;
  color: var(--muted);
  font-weight: 300;
  font-size: 13px;
  text-align: center;
}

.reaction {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 9px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--raised);
  color: var(--text);
  font: 500 12px/1 var(--sans);
  cursor: pointer;
}

.reaction:hover {
  background: var(--surface-2);
}

.reaction.is-mine {
  border-color: var(--text);
}

.msg__reactions.is-new .reaction.is-new {
  animation: pop .3s var(--ease);
}

.reaction-picker {
  position: fixed;
  z-index: 25;
  display: flex;
  gap: 2px;
  padding: 6px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--raised);
  box-shadow: var(--shadow);
}

.reaction-picker button {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: none;
  font-size: 20px;
  cursor: pointer;
}

.reaction-picker button:hover {
  background: var(--surface-2);
}


/* «Печатает…» */
.typing {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  color: var(--muted);
  font: 500 13px/1.4 var(--sans);
}

.typing:empty {
  display: none;
}

.typing:not(:empty) {
  padding-top: 6px;
}

.typing__dots {
  display: inline-flex;
  gap: 3px;
}

.typing__dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--muted);
  animation: bounce 1.2s var(--ease) infinite;
  animation-delay: calc(var(--i) * .15s);
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.composer__input {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  padding: 9px 14px;
  overflow-y: hidden;
  resize: none;
  line-height: 1.4;
}

.composer__send {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-lg);
}

.composer__send:not(:disabled):hover {
  opacity: .86;
}

/* ---------- Плейлист ---------- */
.playlist {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  padding: 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.track {
  display: flex;
  align-items: center;
  gap: 4px;
  border-radius: var(--radius);
  transition: background var(--d-fast), transform .3s var(--ease-out);
}

.track:hover,
.track:focus-within {
  background: var(--surface);
}

.track.is-current {
  background: var(--surface-2);
}

.track.is-new {
  animation: rise .42s var(--ease-spring);
}

.track__open {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 6px;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.track__thumb {
  display: grid;
  place-items: center;
  flex: 0 0 64px;
  width: 64px;
  height: 36px;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
}

.track__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.track__body {
  flex: 1;
  min-width: 0;
}

.track__title {
  overflow: hidden;
  color: var(--text);
  font: 600 14px/1.3 var(--sans);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track.is-current .track__title::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 7px;
  vertical-align: middle;
  border-radius: 50%;
  background: var(--text);
}

.track__meta {
  overflow: hidden;
  color: var(--muted);
  font: 300 12.5px/1.4 var(--sans);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track__remove {
  opacity: 0;
  transition: opacity var(--t);
}

.track:hover .track__remove,
.track:focus-within .track__remove,
.track__remove:focus-visible {
  opacity: 1;
}

@media (hover: none) {
  .track__remove {
    opacity: .7;
  }
}

.playlist__add {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.playlist__add .field {
  flex: 1;
}

/* ---------- Листы: профиль и приглашение ---------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 16px;
  background: var(--scrim);
  animation: fade-in .2s var(--ease);
}

.sheet-backdrop.is-closing {
  animation: fade-out .2s var(--ease) forwards;
}

.sheet {
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: min(440px, 100%);
  max-height: calc(100dvh - 32px);
  padding: 24px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--raised);
  box-shadow: var(--shadow);
  animation: sheet-in .5s var(--ease-spring);
}

.sheet__title {
  margin: 0;
  font: 800 22px/1.2 var(--sans);
  letter-spacing: -.02em;
}

.sheet__subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-weight: 300;
  font-size: 14px;
  line-height: 1.5;
}

.sheet__section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sheet__label {
  color: var(--muted);
  font: 500 13px/1.2 var(--sans);
}

.sheet__section .field {
  width: 100%;
}

.sheet__divider {
  height: 1px;
  background: var(--line);
}

/* Переключатель темы: три варианта в одной строке, выбранный — приподнят */
.segmented {
  display: flex;
  gap: 4px;
  position: relative;
  padding: 4px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-lg);
  background: var(--bg);
}

.segmented__item {
  flex: 1;
  height: 34px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font: 500 13px/1 var(--sans);
  cursor: pointer;
  position: relative;
  z-index: 1;
  transition: color var(--d-fast);
}

.segmented__item:hover {
  color: var(--text);
}

.segmented__item[aria-checked="true"] {
  color: var(--text);
}

.sheet__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.sheet__actions .btn {
  flex: 1 1 auto;
}

.profile-preview {
  display: flex;
  justify-content: center;
}

.invite__row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 5px 5px 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-lg);
  background: var(--bg);
}

.invite__link {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font: 500 14px/1 var(--mono);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Уведомления ---------- */
.toasts {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: calc(100% - 32px);
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  max-width: 100%;
  padding: 11px 18px;
  overflow-wrap: anywhere;
  border-radius: 12px;
  background: var(--text);
  color: var(--bg);
  font: 500 14px/1.4 var(--sans);
  box-shadow: var(--shadow);
  animation: rise .42s var(--ease-spring);
}

.toast.is-leaving {
  animation: fade-out .3s var(--ease) forwards;
}

/* ---------- Адаптив ---------- */

/* Планшет и широкий телефон: видео слева, панель справа */
@media (min-width: 720px) {
  .app {
    height: 100dvh;
    min-height: 0;
  }

  .layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--side-w);
    min-height: 0;
  }

  .stage {
    min-height: 0;
    overflow-y: auto;
    padding: 24px 24px 32px;
  }

  .side {
    min-height: 0;
    border-top: 0;
    border-left: 1px solid var(--line);
  }
}

@media (min-width: 1100px) {
  :root {
    --side-w: 340px;
  }
}

/* На невысоком окне кадр уменьшается по высоте, чтобы строка управления
   оставалась в окне без прокрутки: 320px — шапка, название и отступы сцены */
@media (min-width: 720px) {
  .player {
    width: min(100%, calc((100dvh - 320px) * 16 / 9));
    align-self: flex-start;
  }
}

/* Узкий телефон: плеер и управление плотнее, полоса позиции — отдельной строкой */
@media (max-width: 479px) {
  .top {
    padding: 0 14px;
  }

  .members__count {
    display: none;
  }

  .stage {
    gap: 12px;
    padding: 12px 12px 16px;
  }

  .player {
    border-radius: var(--radius-lg);
  }

  .player__empty {
    padding: 16px;
  }

  .player__empty h2 {
    font-size: 21px;
  }

  .player__empty p {
    font-size: 14px;
  }

  .player__bar {
    justify-content: center;
    padding: 6px 8px 8px;
  }

  .scrubber {
    order: -1;
    flex: 1 0 100%;
    min-width: 0;
  }

  #syncText {
    display: none;
  }

  /* В узкой шапке приглашение остаётся значком: слово «Пригласить» не влезает */
  #btnInvite {
    width: 38px;
    padding: 0;
  }

  #btnInvite span {
    display: none;
  }

  .time {
    min-width: 40px;
  }

  .sync-badge {
    padding: 0 2px;
  }
}

/* Телефон лёжа: кадр широкий, лишнее прячем */
@media (max-height: 500px) and (orientation: landscape) {
  :root {
    --header-h: 52px;
  }

  .stage {
    padding: 0 0 8px;
  }

  .now {
    display: none;
  }

  .player {
    border: 0;
    border-radius: 0;
  }
}

/* ---------- Анимации ---------- */
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px) scale(.96);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes fade-out {
  to {
    opacity: 0;
  }
}

@keyframes pop {
  0% {
    transform: scale(.7);
  }

  60% {
    transform: scale(1.1);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: .5;
  }

  30% {
    transform: translateY(-3px);
    opacity: 1;
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: .3;
  }
}

/* ---------- Появления и переходы ---------- */

/* Страница собирается сверху вниз, а не появляется разом */
.top {
  animation: page-in .5s var(--ease-out) both;
}

.stage {
  animation: page-in .6s var(--ease-out) .08s both;
}

.side {
  animation: page-in .6s var(--ease-out) .16s both;
}

@keyframes page-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

/* Пустой плеер и карточка «в отдельном окне» появляются, а не встают сразу */
.player__empty:not([hidden]),
.stage__away:not([hidden]) {
  animation: rise .5s var(--ease-out) both;
}

/* Большая кнопка на паузе вспыхивает */
.player.is-paused .player__big-play {
  animation: pop .5s var(--ease-spring) both;
}

/* Иконка play/pause перекручивается при смене */
.icon.is-swap {
  animation: icon-swap .36s var(--ease-spring);
}

@keyframes icon-swap {
  from {
    opacity: 0;
    transform: scale(.5) rotate(-35deg);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

/* Сообщения влетают со своей стороны: свои — справа, чужие — слева */
.msg--own.is-new .msg__bubble {
  animation: msg-in-own .45s var(--ease-spring);
}

.msg:not(.msg--own).is-new .msg__bubble {
  animation: msg-in-other .45s var(--ease-spring);
}

@keyframes msg-in-own {
  from {
    opacity: 0;
    transform: translate(14px, 6px) scale(.94);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes msg-in-other {
  from {
    opacity: 0;
    transform: translate(-14px, 6px) scale(.94);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

/* Реакции: нажатие сжимает чип, появление — пружинкой */
.reaction {
  transition: transform .25s var(--ease-spring), background var(--d-fast), border-color var(--d-fast);
}

.reaction:active {
  transform: scale(.88);
}

/* Удаление ролика: строка сжимается и уходит, и только потом уходит команда серверу */
.track.is-leaving {
  animation: track-out .22s var(--ease-in) forwards;
  pointer-events: none;
}

@keyframes track-out {
  to {
    opacity: 0;
    transform: translateX(-14px) scale(.96);
  }
}

/* Новый участник в стопке появляется с пружинкой */
.members__stack .avatar.is-new {
  animation: pop .5s var(--ease-spring);
}

/* Листы: появление с пружиной, уход с затуханием */
@keyframes sheet-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(.94);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.sheet-backdrop.is-closing .sheet {
  animation: sheet-out .22s var(--ease-in) forwards;
}

@keyframes sheet-out {
  to {
    opacity: 0;
    transform: translateY(10px) scale(.97);
  }
}

/* Вкладки: индикатор скользит к выбранной вкладке */
.tabs__indicator {
  position: absolute;
  bottom: -1px;
  left: 0;
  height: 2px;
  width: var(--w, 0px);
  border-radius: 2px;
  background: var(--text);
  transform: translateX(var(--x, 0px));
  transition: transform .42s var(--ease-out), width .42s var(--ease-out);
}

/* Переключатель темы: плашка скользит под выбранным вариантом */
.segmented__thumb {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 0;
  width: var(--w, 0px);
  border-radius: var(--radius);
  background: var(--raised);
  box-shadow: var(--shadow);
  transform: translateX(var(--x, 0px));
  transition: transform .42s var(--ease-out), width .42s var(--ease-out);
}

/* Смена темы: цвета плавно перетекают, а не переключаются разом */
.theme-switching,
.theme-switching *,
.theme-switching *::before,
.theme-switching *::after {
  transition: background-color .35s var(--ease-out), border-color .35s var(--ease-out), color .35s var(--ease-out) !important;
}

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