:root {
  color-scheme: dark;
  --bg: #080a0f;
  --surface: #10131a;
  --surface-2: #151a23;
  --surface-3: #1b2230;
  --text: #f3f3ef;
  --muted: #8b93a1;
  --soft: #b9bfca;
  --line: #242b36;
  --line-strong: #384252;
  --primary: #18e889;
  --primary-text: #06110b;
  --green: #18e889;
  --green-soft: rgba(24, 232, 137, .12);
  --danger: #ff6878;
  --danger-soft: rgba(255, 104, 120, .13);
  --shadow: 0 18px 44px rgba(0, 0, 0, .26);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, sans-serif;
  font-weight: 400;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
  font-weight: 400;
}

strong,
b {
  font-weight: 400;
}

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

button:disabled {
  cursor: wait;
  opacity: .58;
}

.app-shell {
  width: min(1180px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 10px clamp(12px, 3vw, 28px) 34px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 6px 0 18px;
}

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

.brand-copy {
  min-width: 0;
}

.user-meta {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 6px;
  margin-top: 4px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 38px;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #000;
  line-height: 1;
}

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

.top-actions,
.search-actions,
.controls,
.external-actions {
  display: flex;
  gap: 8px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  overflow: hidden;
  font-size: clamp(24px, 4vw, 34px);
  font-weight: 400;
  line-height: 1.04;
  text-overflow: ellipsis;
  white-space: nowrap;
}

h2 {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

h3 {
  font-weight: 400;
}

#userLabel {
  overflow: hidden;
  max-width: 220px;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-badge {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  color: var(--green);
}

.admin-badge .lucide {
  width: 16px;
  height: 16px;
  stroke-width: 1.8;
}

.view {
  display: block;
  min-width: 0;
}

.hidden {
  display: none !important;
}

.search-row {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 4px 0 14px;
  background: rgba(8, 10, 15, .94);
  backdrop-filter: blur(14px);
}

.search-box {
  display: flex;
  align-items: center;
  min-width: 0;
  height: 52px;
  gap: 12px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--muted);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .03);
}

.search-box:focus-within {
  border-color: var(--line-strong);
  background: var(--surface-2);
}

.search-box input,
.message-form input,
.source-box input,
.source-box textarea {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
}

.search-box input::placeholder,
.message-form input::placeholder,
.source-box input::placeholder,
.source-box textarea::placeholder {
  color: #666e7b;
}

.nav-button,
.icon-button,
.ghost-button,
.primary-button,
.source-open-button,
.watch-link,
.room-link-button,
.leave-room-button,
.close-room-button,
.text-button {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  text-decoration: none;
  transition: transform .14s ease, border-color .18s ease, background-color .18s ease, color .18s ease, opacity .18s ease;
  will-change: transform;
}

.nav-button {
  min-width: 0;
  padding: 0 13px;
  white-space: nowrap;
}

.icon-button {
  width: 52px;
  height: 52px;
}

.ghost-button,
.primary-button,
.source-open-button,
.watch-link,
.room-link-button,
.leave-room-button,
.close-room-button {
  padding: 0 14px;
}

.primary-button,
.source-open-button,
.accent-icon-button {
  border-color: rgba(24, 232, 137, .38);
  background: rgba(24, 232, 137, .14);
  color: #d9ffe9;
}

.ghost-button:hover,
.icon-button:hover,
.nav-button:hover,
.movie-card:hover,
.source-open-button:hover,
.watch-link:hover,
.room-link-button:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
}

.primary-button:hover,
.source-open-button:hover,
.accent-icon-button:hover {
  border-color: rgba(24, 232, 137, .7);
  background: rgba(24, 232, 137, .2);
  color: #effff6;
}

.icon-button .lucide,
.nav-button .lucide,
.ghost-button .lucide,
.primary-button .lucide,
.source-open-button .lucide,
.watch-link .lucide,
.room-link-button .lucide,
.leave-room-button .lucide,
.close-room-button .lucide {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

button:active,
.movie-card:active,
.source-open-button:active,
.watch-link:active {
  transform: scale(.975);
}

button:focus-visible,
.movie-card:focus-visible,
.source-open-button:focus-visible,
.watch-link:focus-visible {
  outline: 2px solid rgba(245, 245, 242, .7);
  outline-offset: 3px;
}

.tap-animate::after {
  position: absolute;
  inset: 50%;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .2);
  content: "";
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(1);
  animation: tap-pulse .38s ease-out forwards;
}

@keyframes tap-pulse {
  from {
    opacity: .48;
    transform: translate(-50%, -50%) scale(1);
  }

  to {
    opacity: 0;
    transform: translate(-50%, -50%) scale(15);
  }
}

.library-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 14px;
}

.library-head h2 {
  margin: 0;
  color: var(--text);
  font-size: 16px;
}

.library-head span,
.movie-meta,
.provider-heading,
.source-help,
.source-note,
.detail-meta,
.provider-row,
.account-muted {
  color: var(--muted);
}

.active-rooms-head {
  margin-top: 18px;
}

.available-rooms {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 10px;
  margin-bottom: 22px;
}

.available-room {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 64px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0d0f13;
  color: var(--text);
  text-align: left;
}

.available-room:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
}

.available-room img {
  width: 76px;
  aspect-ratio: 16 / 10;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-2);
}

.available-room-info {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.available-room-info strong,
.available-room-info small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.available-room-info strong {
  font-size: 14px;
}

.available-room-info small,
.available-rooms-empty {
  color: var(--muted);
  font-size: 12px;
}

.available-rooms-empty {
  margin: 0 0 22px;
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 12px;
}

.movie-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(236px, 1fr));
  gap: 18px;
}

.movie-card {
  position: relative;
  display: grid;
  grid-template-rows: auto auto auto;
  min-width: 0;
  gap: 9px;
  padding: 0 0 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #0d0f13;
  color: var(--text);
  text-align: left;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .02);
}

.movie-card:hover {
  transform: translateY(-2px);
}

.movie-card img {
  width: 100%;
  aspect-ratio: 16 / 10;
  border-bottom: 1px solid var(--line);
  border-radius: 13px 13px 0 0;
  object-fit: cover;
  background: var(--surface-2);
}

.movie-title {
  min-height: 38px;
  padding: 0 12px;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 16px;
  line-height: 1.22;
}

.movie-meta {
  padding: 0 12px;
  font-size: 13px;
}

.delete-file-button {
  position: absolute;
  top: 10px;
  right: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 104, 120, .42);
  border-radius: 10px;
  background: rgba(16, 18, 22, .82);
  color: #ffd7dc;
  box-shadow: var(--shadow);
}

.delete-file-button:hover,
.leave-room-button:hover {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.delete-file-button .lucide,
.file-picker-button .lucide {
  width: 17px;
  height: 17px;
}

.upload-status,
.library-empty,
.account-card,
.profile-cover-card,
.account-section,
.vk-card,
.create-panel,
.members-list,
.messages-list {
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.upload-status {
  display: grid;
  gap: 9px;
  margin: -4px 0 16px;
  padding: 12px 14px;
  color: var(--muted);
  font-size: 13px;
}

.upload-status.is-loading {
  border-color: rgba(245, 245, 242, .32);
}

.upload-status.is-success {
  border-color: rgba(18, 216, 121, .5);
  color: #bdf4d6;
}

.upload-status.is-error {
  border-color: rgba(255, 104, 120, .64);
  color: #ffcbd1;
}

.upload-status-head {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 8px;
  color: var(--text);
}

.upload-status-head strong,
.upload-status-detail {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-spinner {
  width: 15px;
  height: 15px;
  flex: 0 0 15px;
  border: 2px solid rgba(255, 255, 255, .14);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: upload-spin .8s linear infinite;
}

.upload-status.is-success .upload-spinner,
.upload-status.is-error .upload-spinner {
  animation: none;
  border-color: currentColor;
}

.upload-progress {
  overflow: hidden;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .08);
}

.upload-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width .24s ease;
}

.upload-status.is-success .upload-progress span {
  background: var(--green);
}

.upload-status.is-error .upload-progress span {
  background: var(--danger);
}

@keyframes upload-spin {
  to {
    transform: rotate(360deg);
  }
}

.library-empty {
  display: grid;
  justify-items: center;
  gap: 10px;
  grid-column: 1 / -1;
  min-height: 240px;
  padding: 34px 20px;
  color: var(--muted);
  text-align: center;
}

.library-empty .lucide,
.external-fallback-content > .lucide {
  width: 42px;
  height: 42px;
  color: var(--green);
}

.library-empty h2 {
  color: var(--text);
  font-size: 19px;
}

.library-empty p {
  max-width: 520px;
  line-height: 1.45;
}

.account-panel,
.friends-panel,
.vk-panel {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.account-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  padding: 14px;
}

.profile-cover-card {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  min-height: 132px;
  padding: 16px;
}

.profile-cover-glow {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 14% 18%, rgba(24, 232, 137, .16), transparent 32%),
    radial-gradient(circle at 92% 0%, rgba(98, 126, 255, .12), transparent 30%);
  pointer-events: none;
}

.profile-cover-card > :not(.profile-cover-glow) {
  position: relative;
  z-index: 1;
}

.friends-hero,
.friends-section,
.friends-empty {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.friends-hero {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 14px;
}

.friends-hero h2 {
  margin: 0 0 4px;
  color: var(--text);
  font-size: 22px;
}

.friends-hero p,
.friends-room-hint {
  color: var(--muted);
  font-size: 13px;
}

.friends-room-hint {
  line-height: 1.4;
}

.friends-room-hint span {
  color: var(--green);
}

.friend-add-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.friend-add-form .search-box {
  position: static;
  height: 48px;
  padding: 0 14px;
}

.friends-section {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.friends-section .account-section-head {
  padding: 0 2px;
}

.friends-section .account-section-head h2 {
  margin: 0;
  color: var(--text);
  font-size: 15px;
}

.friends-section .account-section-head span {
  color: var(--muted);
  font-size: 13px;
}

.friends-list {
  display: grid;
  gap: 8px;
}

.friend-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #0b0e14;
}

.friend-avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 25%, #283242, #111721);
  color: var(--text);
  font-size: 13px;
}

.friend-main {
  min-width: 0;
}

.friend-main strong,
.friend-main span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.friend-main strong {
  color: var(--text);
  font-size: 14px;
}

.friend-main span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.friend-row .friend-avatar.is-online::after,
.direct-head .friend-avatar.is-online::after {
  position: absolute;
  right: 0;
  bottom: 1px;
  width: 9px;
  height: 9px;
  border: 2px solid #0b0e14;
  border-radius: 50%;
  background: var(--green);
  content: "";
}

.friend-actions {
  display: flex;
  gap: 6px;
}

.friend-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--soft);
  cursor: pointer;
}

.friend-action.accept {
  border-color: rgba(24, 232, 137, .38);
  color: #d9ffe9;
}

.friend-action.message {
  border-color: rgba(120, 148, 255, .36);
  color: #dce3ff;
}

.friend-action.danger {
  border-color: rgba(255, 104, 120, .34);
  color: #ffd7dc;
}

.friend-action .lucide {
  width: 17px;
  height: 17px;
}

.friends-empty {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 32px 18px;
  color: var(--muted);
  text-align: center;
}

.friends-empty .lucide {
  width: 42px;
  height: 42px;
  color: var(--green);
}

.friends-empty h2 {
  margin: 0;
  color: var(--text);
  font-size: 19px;
}

.direct-chat {
  display: grid;
  grid-template-rows: auto minmax(260px, 1fr) auto;
  min-height: min(640px, calc(100vh - 120px));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.direct-head {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 14, 20, .72);
}

.direct-messages {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  padding: 12px;
  overflow-y: auto;
}

.direct-message {
  display: grid;
  justify-items: start;
  align-self: flex-start;
  max-width: min(76%, 520px);
  gap: 4px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 14px 14px 14px 5px;
  background: #0b0e14;
  color: var(--text);
  overflow-wrap: anywhere;
}

.direct-message.from-me {
  justify-items: end;
  align-self: flex-end;
  border-color: rgba(24, 232, 137, .28);
  border-radius: 14px 14px 5px 14px;
  background: rgba(24, 232, 137, .12);
}

.direct-message span {
  line-height: 1.35;
}

.direct-message small {
  color: var(--muted);
  font-size: 11px;
}

.direct-empty {
  margin: auto;
  max-width: 240px;
  color: var(--muted);
  text-align: center;
  line-height: 1.4;
}

.direct-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--line);
  background: rgba(11, 14, 20, .72);
}

.direct-form input {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 14px;
  outline: none;
  background: #0b0e14;
  color: var(--text);
}

.account-avatar {
  display: grid;
  place-items: center;
  width: 74px;
  height: 74px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text);
  font-size: 18px;
}

.account-avatar img,
.friend-avatar img,
.profile-avatar-small img {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}

.account-main,
.detail-panel,
.history-room div {
  min-width: 0;
}

.account-main h2 {
  overflow: hidden;
  margin: 4px 0 2px;
  color: var(--text);
  font-size: 22px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-main p,
.account-muted {
  font-size: 13px;
}

.profile-bio {
  margin-top: 9px;
  color: var(--soft);
  line-height: 1.4;
  white-space: normal;
}

.profile-avatar-picker {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #0b0e14;
  cursor: pointer;
}

.profile-avatar-small {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
}

.profile-avatar-picker strong,
.profile-avatar-picker small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-avatar-picker strong {
  color: var(--text);
  font-size: 14px;
}

.profile-avatar-picker small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.profile-avatar-picker > .lucide {
  width: 18px;
  height: 18px;
  color: var(--green);
}

.account-label,
.region-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid rgba(18, 216, 121, .28);
  border-radius: 999px;
  color: var(--green);
  font-size: 12px;
}

.account-section,
.vk-card {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.account-section h2,
.vk-head h2 {
  margin: 0;
  color: var(--text);
}

.account-wide-button {
  width: 100%;
}

.account-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.account-stats div {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0f1116;
}

.account-stats strong {
  overflow: hidden;
  color: var(--text);
  font-size: 17px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-stats span {
  color: var(--muted);
  font-size: 12px;
}

.account-section-head,
.vk-head,
.availability-head,
.room-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.text-button {
  min-height: 0;
  padding: 0;
  border: 0;
  color: var(--muted);
  background: transparent;
}

.room-history {
  display: grid;
  gap: 9px;
}

.history-room {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) 38px 38px;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0f1116;
}

.history-room img {
  width: 74px;
  height: 46px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-2);
}

.history-room strong,
.history-room span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-room strong {
  color: var(--text);
  font-size: 14px;
}

.history-room span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.history-room .icon-button {
  width: 38px;
  height: 38px;
}

.account-loading {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--muted);
}

.vk-search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.vk-room-dock {
  position: relative;
  margin-top: 14px;
  background: var(--surface);
}

.vk-room-actions {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  align-items: end;
  gap: 10px;
}

.compact-source-box {
  gap: 6px;
}

.vk-manual-panel {
  display: grid;
  gap: 10px;
}

.vk-room-privacy .source-box {
  margin-top: 2px;
}

.vk-results {
  display: grid;
  gap: 10px;
}

.vk-empty {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #0c0f15;
  color: var(--soft);
  line-height: 1.45;
}

.vk-result-card {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 84px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #0c0f15;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.vk-result-card:hover {
  border-color: rgba(24, 232, 137, .38);
  background: #11161f;
}

.vk-result-card img {
  width: 112px;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  object-fit: cover;
  background: #050608;
}

.vk-result-info {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.vk-result-info strong,
.vk-result-info small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vk-result-info small {
  color: var(--muted);
  font-size: 12px;
}

.vk-result-action {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(24, 232, 137, .36);
  border-radius: 12px;
  color: var(--green);
  background: var(--green-soft);
}

.vk-browser {
  overflow: auto;
  width: 100%;
  height: min(68vh, 680px);
  min-height: 460px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #07080b;
}

.vk-browser iframe,
.vk-embed-preview iframe {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 760px;
  border: 0;
  background: #07080b;
}

.vk-embed-preview iframe {
  min-width: 0;
}

.vk-embed-preview {
  overflow: hidden;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #050608;
}

.movie-detail {
  display: grid;
  grid-template-columns: minmax(220px, 420px) minmax(0, 1fr);
  gap: 20px;
  margin-top: 18px;
}

.detail-poster img {
  width: 100%;
  aspect-ratio: 16 / 10;
  border: 1px solid var(--line);
  border-radius: 14px;
  object-fit: cover;
  background: var(--surface-2);
}

.detail-panel h2 {
  margin: 2px 0 8px;
  color: var(--text);
  font-size: clamp(26px, 4vw, 44px);
  line-height: 1.02;
}

.source-note,
.source-help,
.overview {
  line-height: 1.45;
}

.overview {
  margin: 16px 0;
  color: var(--soft);
}

.availability {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

.availability h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
}

.provider-group,
.source-box,
.create-panel {
  display: grid;
  gap: 10px;
}

.create-panel {
  min-width: 0;
  margin: 16px 0;
  padding: 14px;
}

.create-panel h3 {
  color: var(--text);
  font-size: 16px;
}

.detail-panel > .source-box {
  margin: 16px 0;
}

.source-box input,
.source-box textarea,
.message-form input {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 14px;
  background: #0f1116;
}

.source-box textarea {
  padding: 12px 14px;
  resize: vertical;
}

.room-access-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.room-access-options label {
  position: relative;
  display: grid;
  min-width: 0;
  cursor: pointer;
}

.room-access-options input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.room-access-options span {
  display: grid;
  gap: 3px;
  min-height: 68px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0f1116;
}

.room-access-options strong,
.room-access-options small {
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-access-options strong {
  color: var(--text);
  font-size: 13px;
}

.room-access-options small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.room-access-options input:checked + span {
  border-color: rgba(24, 232, 137, .58);
  background: rgba(24, 232, 137, .1);
}

.ready-source {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  margin: 16px 0;
  padding: 12px 14px;
  border: 1px solid rgba(18, 216, 121, .28);
  border-radius: 14px;
  background: var(--green-soft);
}

.ready-source > .lucide {
  width: 18px;
  height: 18px;
  color: var(--green);
}

.ready-source strong,
.ready-source span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ready-source strong {
  color: var(--text);
  font-size: 14px;
}

.ready-source span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.source-divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.source-divider::before,
.source-divider::after {
  height: 1px;
  background: var(--line);
  content: "";
}

.file-picker {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 46px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0f1116;
}

.file-picker-input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-picker-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 11px;
  border-radius: 10px;
  background: var(--surface-3);
  color: var(--text);
  white-space: nowrap;
}

.file-picker-name {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.provider-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 4px;
}

.provider {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}

.provider img {
  width: 22px;
  height: 22px;
  border-radius: 6px;
}

.room-header {
  margin-bottom: 14px;
}

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

.room-title-block img {
  width: 86px;
  height: 54px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  object-fit: cover;
  background: var(--surface-2);
}

.room-title-block h1 {
  max-width: min(620px, 70vw);
  font-size: clamp(22px, 3.2vw, 34px);
  overflow-wrap: anywhere;
  white-space: normal;
}

.room-code {
  color: var(--green);
}

.room-access-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  margin-left: 7px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--soft);
  background: var(--surface);
  font-size: 12px;
}

.room-closed-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  margin-left: 7px;
  padding: 0 8px;
  border: 1px solid rgba(255, 104, 120, .38);
  border-radius: 999px;
  color: #ffd7dc;
  background: var(--danger-soft);
  font-size: 12px;
}

.leave-room-button,
.close-room-button {
  margin-left: 8px;
  border-color: rgba(255, 104, 120, .42);
  color: #ffd7dc;
}

.close-room-button:hover {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.player-mount {
  overflow: hidden;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #050608;
  box-shadow: var(--shadow);
}

.player-mount video,
.player-mount iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
}

.external-player {
  display: grid;
  grid-template-rows: auto 1fr;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.external-player-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
}

.external-player-bar .source-open-button {
  flex: 0 0 auto;
  min-height: 34px;
  margin-top: 0;
  white-space: nowrap;
}

.external-player-fallback,
.empty-player {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.external-fallback-content {
  display: grid;
  justify-items: center;
  gap: 12px;
  width: min(520px, 100%);
}

.external-fallback-content h2 {
  color: var(--text);
  font-size: 22px;
  line-height: 1.2;
}

.external-url {
  max-width: 100%;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 12px;
}

.controls {
  margin: 12px 0 16px;
}

.room-grid {
  display: grid;
  grid-template-columns: minmax(180px, 300px) 1fr;
  gap: 14px;
}

#roomView.external-room {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  align-items: start;
  gap: 16px;
}

#roomView.external-room .room-header {
  grid-column: 1 / -1;
  margin-bottom: 0;
}

#roomView.external-room .player-mount {
  min-height: 560px;
  height: calc(100vh - 160px);
  aspect-ratio: auto;
}

#roomView.external-room .room-grid {
  grid-template-columns: 1fr;
  align-content: start;
}

#roomView.external-room .messages-list {
  max-height: calc(100vh - 380px);
  min-height: 300px;
  overflow-y: auto;
}

.member,
.message {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.member:last-child,
.message:last-child {
  border-bottom: 0;
}

.message strong {
  display: block;
  margin-bottom: 3px;
  color: var(--soft);
}

.message-form {
  display: grid;
  grid-template-columns: 1fr 50px;
  gap: 8px;
  margin-top: 8px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 20;
  max-width: min(440px, calc(100vw - 28px));
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 14px;
  background: var(--primary);
  color: var(--primary-text);
  box-shadow: var(--shadow);
  transform: translateX(-50%);
}

@media (min-width: 900px) {
  .app-shell {
    display: grid;
    grid-template-columns: 270px minmax(0, 1fr);
    column-gap: 34px;
    max-width: none;
    padding: 8px 34px 40px 8px;
  }

  .topbar {
    position: sticky;
    top: 8px;
    grid-row: 1 / span 5;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    min-height: calc(100vh - 16px);
    padding: 8px;
  }

  .brand-lockup {
    min-height: 70px;
    margin-bottom: 34px;
  }

  .top-actions {
    flex-direction: column;
  }

  .nav-button {
    justify-content: flex-start;
    width: 100%;
    height: 42px;
  }

  #searchView,
  #detailView,
  #accountView,
  #friendsView,
  #vkView,
  #roomView {
    grid-column: 2;
    padding-top: 8px;
  }
}

@media (max-width: 899px) {
  .nav-button span {
    display: none;
  }

  .nav-button {
    width: 46px;
    height: 46px;
    padding: 0;
  }
}

@media (max-width: 760px) {
  .movie-detail,
  .room-grid,
  #roomView.external-room {
    grid-template-columns: 1fr;
  }

  .search-row,
  .vk-search-form {
    grid-template-columns: 1fr;
  }

  .search-actions {
    display: flex;
    justify-content: flex-start;
  }

  .search-actions .icon-button {
    width: 52px;
    flex: 0 0 52px;
  }

  .detail-poster img {
    max-width: 100%;
  }

  .room-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .room-title-block {
    align-items: flex-start;
  }

  .room-title-block h1 {
    max-width: 100%;
  }

  #roomView.external-room .player-mount {
    min-height: 430px;
    height: 62vh;
  }

  #roomView.external-room .messages-list {
    max-height: none;
  }

  .external-player-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .vk-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .vk-head .ghost-button,
  .vk-head .icon-button {
    width: 100%;
  }

  .vk-room-actions {
    grid-template-columns: 1fr;
  }

  .vk-room-actions .primary-button,
  .vk-room-actions .ghost-button {
    width: 100%;
  }

  .vk-browser {
    height: min(64vh, 560px);
    min-height: 420px;
  }

  .vk-result-card {
    grid-template-columns: 96px minmax(0, 1fr) 38px;
  }

  .vk-result-card img {
    width: 96px;
  }
}

@media (max-width: 520px) {
  .app-shell {
    padding: 10px 10px 30px;
  }

  .brand-mark {
    width: 44px;
    height: 32px;
  }

  .topbar {
    gap: 10px;
  }

  h1 {
    font-size: 25px;
  }

  .top-actions {
    gap: 6px;
  }

  .nav-button {
    width: 42px;
    height: 42px;
  }

  .search-box {
    height: 54px;
    border-radius: 15px;
  }

  .vk-browser {
    min-height: 380px;
  }

  .vk-browser iframe {
    min-width: 700px;
  }

  .vk-result-card {
    grid-template-columns: 82px minmax(0, 1fr);
  }

  .vk-result-card img {
    width: 82px;
  }

  .vk-result-action {
    display: none;
  }

  .movie-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .movie-card img {
    aspect-ratio: 16 / 9;
  }

  .account-stats,
  .friend-add-form,
  .file-picker,
  .room-access-options {
    grid-template-columns: 1fr;
  }

  .friend-add-form .primary-button {
    width: 100%;
  }

  .friend-row {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .friend-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }

  .direct-chat {
    min-height: calc(100vh - 96px);
  }

  .direct-head {
    grid-template-columns: auto auto minmax(0, 1fr);
  }

  .direct-head > .friend-action.accept {
    grid-column: 1 / -1;
    justify-self: end;
  }

  .direct-message {
    max-width: 86%;
  }

  .file-picker-button {
    justify-content: flex-start;
  }

  .history-room {
    grid-template-columns: 64px minmax(0, 1fr) 36px 36px;
  }

  .history-room img {
    width: 64px;
    height: 42px;
  }

  .room-title-block img {
    width: 72px;
    height: 46px;
  }

  .room-link-button,
  .leave-room-button,
  .close-room-button {
    width: 100%;
    justify-content: center;
    margin-left: 0;
  }
}
