:root {
  color-scheme: dark;
  --bg: #090b10;
  --panel: #141821;
  --panel-soft: #191f2b;
  --line: rgba(255, 255, 255, 0.1);
  --text: #f5f7fb;
  --muted: #9ba7b7;
  --accent: #e50914;
  --accent-2: #2dd4bf;
  --warn: #f6c85f;
  --danger: #ff6b6b;
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: scroll;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: visible;
  background: var(--bg);
  color: var(--text);
}

html::-webkit-scrollbar {
  width: 10px;
}

html::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

label[role="button"] {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: visible;
}

.topbar {
  height: 72px;
  flex: 0 0 72px;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(9, 11, 16, 0.92);
  backdrop-filter: blur(20px);
  position: sticky;
  top: 0;
  z-index: 10;
}

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

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 17px;
  line-height: 1.15;
  letter-spacing: 0;
}

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

.status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-badge {
  min-height: 30px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  white-space: nowrap;
  font-size: 13px;
}

button.status-badge {
  cursor: pointer;
}

.mic-toggle {
  color: var(--text);
}

.mic-toggle.is-off {
  color: var(--warn);
}

.noise-toggle.is-off {
  color: var(--muted);
}

.mic-toggle:disabled {
  cursor: wait;
  opacity: 0.72;
}

.top-volume-control {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.top-volume-control input {
  width: 92px;
  accent-color: var(--accent-2);
}

.status-ok {
  color: #8fffdc;
  border-color: rgba(45, 212, 191, 0.38);
}

.status-warn {
  color: var(--warn);
  border-color: rgba(246, 200, 95, 0.35);
}

.status-danger {
  color: var(--danger);
  border-color: rgba(255, 107, 107, 0.38);
}

.system-message {
  padding: 9px 11px;
  border: 1px solid rgba(125, 211, 252, 0.28);
  border-radius: 8px;
  background: rgba(56, 189, 248, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.system-message .message-meta {
  color: #93c5fd;
}

.cinema-layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 320px);
  grid-template-rows: minmax(420px, 1fr) minmax(220px, 32vh);
  grid-template-areas:
    "stage chat"
    "members chat";
  min-height: calc(100vh - 72px);
  min-height: calc(100dvh - 72px);
  height: auto;
  overflow: visible;
}

.stage {
  grid-area: stage;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: #050608;
}

.video-frame {
  flex: 1 1 auto;
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: var(--video-aspect, 16 / 9);
  min-height: 0;
  max-height: calc(100vh - 72px - 44px);
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.07), transparent 35%),
    #050608;
  overflow: hidden;
  user-select: none;
}

.video-frame[data-aspect="16-9"] {
  aspect-ratio: 16 / 9;
}

.video-frame[data-aspect="4-3"] {
  aspect-ratio: 4 / 3;
}

.video-frame[data-aspect="auto"] {
  aspect-ratio: var(--video-aspect, 16 / 9);
}

video {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  background: black;
}

video[data-fit="contain"] {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

video[data-fit="ratio-16-9"] {
  width: 100%;
  height: 100%;
  aspect-ratio: 16 / 9;
  object-fit: contain;
}

video[data-fit="ratio-4-3"] {
  width: 100%;
  height: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
}

video[data-fit="fill"] {
  width: 100%;
  height: 100%;
  object-fit: fill;
}

.empty-state {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 16px;
  padding: 28px;
  text-align: center;
  background: linear-gradient(180deg, rgba(9, 11, 16, 0.56), rgba(9, 11, 16, 0.9));
}

.empty-state.hidden,
.hidden {
  display: none !important;
}

.empty-state p {
  max-width: 560px;
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.primary-button,
.icon-button,
select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--panel-soft);
}

.primary-button {
  padding: 0 16px;
  border: 0;
  background: var(--accent);
  font-weight: 700;
}

.file-button {
  display: inline-grid;
  place-items: center;
}

.file-picker {
  position: fixed;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.icon-button {
  padding: 0 14px;
}

.file-action {
  display: inline-grid;
  place-items: center;
}

.controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  min-height: 86px;
  padding: 10px 16px 12px;
  display: grid;
  grid-template-columns: auto auto auto auto minmax(96px, 140px) minmax(96px, 140px) auto;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 10px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(180deg, transparent, rgba(7, 9, 13, 0.94) 26%, rgba(7, 9, 13, 0.98));
  transition: opacity 160ms ease, transform 160ms ease;
}

.controls .progress-wrap {
  grid-column: 1 / -1;
  grid-row: 1;
}

.controls #playButton,
.controls #chooseVideoButton,
.controls #rateSelect,
.controls #fitSelect,
.controls .video-volume-control,
.controls .voice-volume-control,
.controls #fullscreenButton {
  grid-row: 2;
}

.stage.controls-hidden .controls {
  opacity: 0;
  pointer-events: none;
  transform: translateY(18px);
}

.stage.controls-hidden .video-frame {
  cursor: none;
}

.source-button {
  margin-top: 8px;
}

.source-action {
  min-width: 56px;
}

.source-card {
  width: min(980px, calc(100vw - 24px));
  max-height: min(82vh, 760px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  background: rgba(18, 24, 34, 0.92);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(24px);
}

.source-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.source-head h2,
.source-section h3 {
  margin: 0;
}

.source-head p {
  margin: 6px 0 0;
  color: rgba(255, 255, 255, 0.68);
  font-size: 13px;
}

.source-grid {
  display: grid;
  grid-template-columns: 1.05fr 1fr 1fr;
  gap: 14px;
  padding: 16px;
  min-height: 0;
  overflow: auto;
}

.source-section {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.source-import-form,
.source-search-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.source-search-form {
  flex-direction: row;
}

.source-import-form textarea,
.source-search-form input {
  width: 100%;
  min-width: 0;
  color: #f8fbff;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
}

.source-list,
.source-results,
.source-chapters {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
  min-height: 120px;
}

.source-list-item,
.source-result-item,
.source-chapter-item {
  text-align: left;
  color: #f8fbff;
  background: rgba(255, 255, 255, 0.075);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
}

.source-list-item.active,
.source-list-item:hover,
.source-result-item:hover,
.source-chapter-item:hover {
  background: rgba(125, 190, 255, 0.18);
  border-color: rgba(125, 190, 255, 0.42);
}

.source-list-item span,
.source-list-item small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-list-item small {
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.58);
}

@media (max-width: 860px) {
  .source-card {
    max-height: calc(100dvh - 20px);
  }

  .source-grid {
    grid-template-columns: 1fr;
  }

  .source-search-form {
    flex-direction: column;
  }
}

.progress-wrap {
  position: relative;
  min-width: 0;
}

.progress-wrap input[type="range"] {
  display: block;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.volume-control {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(58px, 1fr);
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.volume-control input {
  min-width: 0;
}

.time-row {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}

.seek-preview {
  position: absolute;
  left: 0;
  bottom: calc(100% + 10px);
  min-width: 58px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(11, 14, 20, 0.92);
  color: var(--text);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: center;
  transform: translateX(-50%);
  pointer-events: none;
}

.seek-feedback {
  position: absolute;
  z-index: 7;
  top: 50%;
  left: 50%;
  min-width: 108px;
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  background: rgba(8, 10, 15, 0.78);
  color: var(--text);
  font-weight: 800;
  text-align: center;
  transform: translate(-50%, -50%);
  backdrop-filter: blur(16px);
  pointer-events: none;
}

.sync-overlay {
  position: absolute;
  z-index: 7;
  top: 18px;
  left: 50%;
  max-width: min(86%, 360px);
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  background: rgba(8, 10, 15, 0.78);
  color: var(--text);
  font-size: 13px;
  text-align: center;
  transform: translateX(-50%);
  backdrop-filter: blur(16px);
  pointer-events: none;
}

select {
  padding: 0 10px;
}

select option,
select optgroup {
  color: #f7f8fb;
  background: #171a22;
}

select option:checked,
select option:hover {
  color: #ffffff;
  background: #2563eb;
}

.side-panel {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
}

.members-panel {
  grid-area: members;
  border-top: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

.chat-panel {
  grid-area: chat;
  border-left: 1px solid var(--line);
  max-height: calc(100vh - 72px);
  max-height: calc(100dvh - 72px);
  overflow: hidden;
}

.panel-toggle {
  width: 100%;
  min-height: 48px;
  padding: 0 16px;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  background: transparent;
  text-align: left;
  font-weight: 800;
}

.panel-content {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.members {
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  overflow: auto;
}

.member {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  grid-template-rows: auto auto;
  grid-template-areas:
    "avatar name"
    "avatar state";
  align-items: start;
  column-gap: 10px;
  row-gap: 4px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.04);
}

.avatar {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  grid-area: avatar;
  border-radius: var(--radius);
  background: #243044;
  font-weight: 800;
}

.member.speaking .avatar {
  outline: 2px solid var(--accent-2);
}

.member-name {
  grid-area: name;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  overflow-wrap: normal;
  word-break: keep-all;
  white-space: nowrap;
  line-height: 1.25;
}

.self-name-button {
  appearance: none;
  border: 0;
  padding: 0;
  color: inherit;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.self-name-button:hover {
  color: #bfdbfe;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.self-name-button:focus-visible {
  outline: 2px solid rgba(125, 211, 252, 0.8);
  outline-offset: 3px;
  border-radius: 6px;
}

.source-owner-badge {
  display: inline-flex;
  align-items: center;
  height: 18px;
  margin-left: 7px;
  padding: 0 7px;
  border-radius: 999px;
  border: 1px solid rgba(125, 211, 252, 0.35);
  background: rgba(56, 189, 248, 0.14);
  color: #bae6fd;
  font-size: 11px;
  font-weight: 700;
  vertical-align: 1px;
}

.member-state {
  grid-area: state;
  color: var(--accent-2);
  font-size: 12px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.25;
}

.messages {
  flex: 1 1 0;
  min-height: 0;
  height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
}

.messages::-webkit-scrollbar {
  width: 8px;
}

.messages::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
}

.message {
  display: grid;
  gap: 4px;
}

.message-meta {
  color: var(--muted);
  font-size: 12px;
}

.message-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.55;
}

.chat-form {
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  border-top: 1px solid var(--line);
}

.chat-form input,
.name-card input {
  min-height: 42px;
  width: 100%;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  outline: 0;
}

.transfer-panel {
  position: static;
  min-height: 44px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(100px, 220px) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
}

progress {
  width: 100%;
  accent-color: var(--accent-2);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(18px);
}

.modal.hidden {
  display: none;
}

.name-card {
  width: min(420px, 100%);
  padding: 24px;
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.45);
}

.confirm-card {
  width: min(460px, 100%);
  padding: 22px;
  display: grid;
  gap: 14px;
  border: 1px solid rgba(125, 211, 252, 0.22);
  border-radius: 12px;
  background: rgba(20, 28, 40, 0.96);
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.48);
}

.confirm-card h2,
.confirm-card p {
  margin: 0;
}

.confirm-card h2 {
  font-size: 18px;
}

.confirm-card p {
  color: var(--muted);
  line-height: 1.6;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

#confirmMessage {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.secondary-button {
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
}

.name-card h1,
.name-card p {
  margin: 0;
}

.name-card p {
  color: var(--muted);
}

@media (max-width: 860px) {
  html,
  body {
    height: auto;
    min-height: 100%;
    overflow: auto;
  }

  .modal {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .confirm-card,
  .name-card {
    width: min(100%, 460px);
    max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    padding: 18px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  #confirmTitle {
    flex: 0 0 auto;
  }

  #confirmMessage {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
  }

  .confirm-actions {
    flex: 0 0 auto;
    position: sticky;
    bottom: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding-top: 12px;
    margin-top: 0;
    background: linear-gradient(180deg, rgba(20, 28, 40, 0), rgba(20, 28, 40, 0.96) 24%);
  }

  .confirm-actions .primary-button,
  .confirm-actions .secondary-button {
    width: 100%;
    min-width: 0;
    padding-inline: 10px;
  }

  .app-shell {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  .topbar {
    height: auto;
    flex: 0 0 auto;
    align-items: flex-start;
    flex-direction: column;
  }

  .cinema-layout {
    display: flex;
    flex-direction: column;
    height: auto;
    overflow: visible;
  }

  .stage,
  .members-panel,
  .chat-panel {
    border-right: 0;
    border-left: 0;
  }

  .video-frame {
    display: flex;
    flex-direction: column;
    place-items: stretch;
    aspect-ratio: auto;
    min-height: 0;
    max-height: none;
    overflow: visible;
  }

  .video-frame[data-aspect="16-9"],
  .video-frame[data-aspect="4-3"],
  .video-frame[data-aspect="auto"] {
    aspect-ratio: auto;
  }

  .video-frame > video {
    flex: 0 0 auto;
    width: 100%;
    height: auto;
    max-height: 62vh;
    aspect-ratio: var(--video-aspect, 16 / 9);
    object-fit: contain;
  }

  .video-frame[data-aspect="4-3"] > video {
    aspect-ratio: 4 / 3;
  }

  .video-frame[data-aspect="auto"] > video {
    aspect-ratio: var(--video-aspect, 16 / 9);
  }

  .controls {
    position: static;
    display: grid;
    grid-template-columns: minmax(54px, 1fr) minmax(70px, 1.15fr) minmax(64px, 0.9fr) minmax(72px, 1fr) minmax(58px, 1fr);
    grid-template-areas:
      "progress progress progress progress progress"
      "play choose rate fit fullscreen"
      "video-volume video-volume video-volume voice-volume voice-volume";
    align-items: center;
    align-content: center;
    justify-items: stretch;
    gap: 7px;
    min-height: 104px;
    padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(7, 9, 13, 0.98);
    overflow: visible;
  }

  .controls .icon-button,
  .controls select,
  .controls .file-action {
    min-height: 34px;
    height: 34px;
    padding: 0 10px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1;
  }

  #playButton {
    grid-area: play;
    min-width: 54px;
  }

  #chooseVideoButton {
    grid-area: choose;
    min-width: 68px;
  }

  .progress-wrap {
    grid-area: progress;
    min-width: 0;
  }

  .controls .progress-wrap {
    grid-area: progress;
  }

  #rateSelect {
    grid-area: rate;
    width: 72px;
    min-width: 0;
  }

  #fitSelect {
    grid-area: fit;
    width: 78px;
    min-width: 0;
  }

  .video-volume-control,
  .voice-volume-control {
    display: grid;
    min-width: 0;
    height: 30px;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 6px;
    font-size: 11px;
  }

  .video-volume-control {
    grid-area: video-volume;
  }

  .voice-volume-control {
    grid-area: voice-volume;
  }

  #videoVolume,
  #voiceVolume {
    min-width: 0;
  }

  #fullscreenButton {
    grid-area: fullscreen;
    min-width: 54px;
  }

  .controls #playButton {
    grid-area: play;
  }

  .controls #chooseVideoButton {
    grid-area: choose;
  }

  .controls #rateSelect {
    grid-area: rate;
  }

  .controls #fitSelect {
    grid-area: fit;
  }

  .controls .video-volume-control {
    grid-area: video-volume;
  }

  .controls .voice-volume-control {
    grid-area: voice-volume;
  }

  .controls #fullscreenButton {
    grid-area: fullscreen;
  }

  .time-row {
    margin-top: -2px;
    font-size: 11px;
  }

  .seek-preview {
    bottom: calc(100% + 6px);
  }

  .side-panel {
    min-height: auto;
  }

  .panel-content {
    max-height: min(68vh, 560px);
  }

  .chat-panel .panel-content {
    height: min(68vh, 560px);
    min-height: 420px;
  }

  .side-panel.collapsed .panel-content {
    display: none;
  }

  .members {
    grid-template-columns: 1fr;
  }

  .transfer-panel {
    grid-template-columns: minmax(0, 1fr) minmax(92px, 180px) auto;
    gap: 8px;
    align-items: center;
    padding-top: 10px;
  }

  #transferTitle {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (max-width: 520px) {
  .topbar {
    padding: 10px 12px;
  }

  
.brand strong {
    font-size: 16px;
  }

  .status-badge {
    font-size: 12px;
    padding: 5px 8px;
  }

  .controls {
    grid-template-columns: minmax(52px, 1fr) minmax(64px, 1.15fr) minmax(58px, 0.9fr) minmax(66px, 1fr) minmax(52px, 1fr);
    grid-template-areas:
      "progress progress progress progress progress"
      "play choose rate fit fullscreen"
      "video-volume video-volume video-volume voice-volume voice-volume";
    gap: 6px;
    min-height: 104px;
    padding: 8px 8px calc(10px + env(safe-area-inset-bottom));
  }

  .controls .icon-button,
  .controls select,
  .controls .file-action {
    min-height: 32px;
    height: 32px;
    padding: 0 8px;
    font-size: 13px;
  }

  #playButton {
    min-width: 52px;
  }

  #chooseVideoButton {
    min-width: 64px;
  }

  #rateSelect {
    width: 64px;
  }

  #fitSelect {
    width: 70px;
  }

  #fullscreenButton {
    min-width: 52px;
  }

  .transfer-panel {
    grid-template-columns: 1fr auto;
  }

  .transfer-panel progress {
    grid-column: 1 / -1;
  }

  .chat-panel .panel-content {
    height: min(72vh, 520px);
    min-height: 360px;
  }
}

/* Apple-inspired Vue3/Element Plus visual layer. Added after 1.0 as an additive theme. */
:root {
  --bg: #07090d;
  --panel: rgba(22, 25, 32, 0.78);
  --panel-soft: rgba(30, 34, 43, 0.78);
  --line: rgba(255, 255, 255, 0.12);
  --text: #f7f8fb;
  --muted: #a7b0bf;
  --accent: #ff2d55;
  --accent-2: #64d2ff;
  --warn: #ffd166;
  --danger: #ff6b7a;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-soft: 0 18px 48px rgba(0, 0, 0, 0.28);
  --shadow-control: 0 1px 0 rgba(255, 255, 255, 0.08) inset, 0 10px 24px rgba(0, 0, 0, 0.18);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", system-ui, sans-serif;
}

body {
  background:
    linear-gradient(180deg, #10131a 0%, #07090d 36%, #050609 100%);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.vue-shell-sentinel {
  display: none;
}

.topbar {
  height: 78px;
  flex-basis: 78px;
  padding: 14px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(13, 15, 21, 0.78);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 12px 32px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(28px) saturate(1.25);
}

.brand {
  gap: 12px;
}

.brand strong {
  font-size: 18px;
  font-weight: 760;
}

.brand span {
  color: rgba(235, 240, 250, 0.58);
  font-size: 12px;
}

.status-line {
  gap: 9px;
}

.status-badge,
.top-volume-control,
.primary-button,
.icon-button,
select,
.secondary-button {
  border-radius: 12px;
  border-color: rgba(255, 255, 255, 0.12);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.105), rgba(255, 255, 255, 0.045)),
    rgba(22, 25, 33, 0.78);
  box-shadow: var(--shadow-control);
  backdrop-filter: blur(18px) saturate(1.18);
}

.primary-button {
  color: white;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.02)),
    linear-gradient(135deg, #0a84ff, #64d2ff);
}

.status-ok {
  color: #8ffff0;
  border-color: rgba(100, 210, 255, 0.36);
  background: rgba(32, 106, 114, 0.22);
}

.status-warn {
  color: #ffe08a;
  border-color: rgba(255, 209, 102, 0.34);
  background: rgba(120, 92, 24, 0.2);
}

.status-danger {
  color: #ff9aa6;
  border-color: rgba(255, 107, 122, 0.36);
  background: rgba(120, 36, 48, 0.22);
}

input[type="range"] {
  accent-color: var(--accent);
}

.top-volume-control input,
.voice-volume-control input {
  accent-color: var(--accent-2);
}

.cinema-layout {
  min-height: calc(100vh - 78px);
  min-height: calc(100dvh - 78px);
  background: rgba(255, 255, 255, 0.015);
}

.stage {
  background: #030406;
  border-right-color: rgba(255, 255, 255, 0.08);
}

.video-frame {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 18%),
    #030406;
}

video {
  background: #030406;
}

.controls {
  min-height: 92px;
  padding: 11px 18px 14px;
  gap: 11px 12px;
  border-top-color: rgba(255, 255, 255, 0.12);
  background:
    linear-gradient(180deg, rgba(3, 4, 6, 0), rgba(8, 10, 14, 0.9) 20%, rgba(8, 10, 14, 0.96));
  backdrop-filter: blur(24px) saturate(1.18);
}

.progress-wrap input[type="range"] {
  height: 18px;
}

.time-row {
  color: rgba(238, 242, 250, 0.72);
}

.transfer-panel,
.side-panel,
.messages,
.member,
.message,
.system-message,
.name-card,
.confirm-card {
  border-color: rgba(255, 255, 255, 0.1);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.065), rgba(255, 255, 255, 0.025)),
    rgba(19, 22, 30, 0.78);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset;
}

.transfer-panel {
  min-height: 54px;
  padding: 12px 16px;
  backdrop-filter: blur(18px) saturate(1.14);
}

.transfer-panel progress {
  height: 7px;
  border-radius: 999px;
}

.transfer-panel progress::-webkit-progress-bar {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
}

.transfer-panel progress::-webkit-progress-value {
  border-radius: 999px;
  background: linear-gradient(90deg, #64d2ff, #5eecdf);
}

.side-panel {
  background: rgba(11, 13, 18, 0.72);
  backdrop-filter: blur(16px) saturate(1.12);
}

.panel-toggle {
  color: rgba(247, 248, 251, 0.96);
  background: transparent;
}

.member,
.message {
  border-radius: 14px;
}

.member {
  padding: 11px;
}

.avatar {
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.035)),
    rgba(35, 45, 63, 0.88);
  color: #f7fbff;
}

.member.speaking .avatar {
  outline-color: #64d2ff;
  box-shadow: 0 0 0 5px rgba(100, 210, 255, 0.12);
}

.member-state,
.source-owner-badge {
  color: #64f4e6;
}

.source-owner-badge {
  border-color: rgba(100, 210, 255, 0.34);
  background: rgba(100, 210, 255, 0.13);
}

.chat-form {
  background: rgba(11, 13, 18, 0.82);
  backdrop-filter: blur(16px);
}

.chat-form input {
  min-height: 42px;
  border-color: rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.07);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset;
}

.chat-form input:focus,
select:focus,
button:focus-visible,
input[type="range"]:focus-visible {
  outline: 2px solid rgba(100, 210, 255, 0.58);
  outline-offset: 2px;
}

.modal {
  background: rgba(3, 5, 9, 0.68);
  backdrop-filter: blur(22px) saturate(1.16);
}

.name-card,
.confirm-card {
  border-radius: 22px;
  box-shadow: var(--shadow-soft);
}

.empty-state {
  background:
    linear-gradient(180deg, rgba(4, 6, 10, 0.2), rgba(4, 6, 10, 0.86));
}

.el-popper,
.el-select__popper {
  border-radius: 14px !important;
  overflow: hidden;
}

@media (max-width: 860px) {
  .topbar {
    padding: 12px 14px;
  }

  .cinema-layout {
    min-height: auto;
  }

  .controls {
    min-height: 108px;
    padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
    background: rgba(9, 11, 16, 0.96);
  }

  .video-frame > video {
    max-height: 60vh;
  }

  .transfer-panel {
    padding: 12px;
  }
}

@media (max-width: 520px) {
  .confirm-actions {
    grid-template-columns: 1fr;
  }

  .brand strong {
    font-size: 17px;
  }

  .controls {
    min-height: 108px;
  }

  .controls .icon-button,
  .controls select,
  .controls .file-action {
    border-radius: 11px;
  }
}

/* 1.0+ mobile polish: keep the status controls out of the video and make fullscreen a player icon. */
.fullscreen-toggle {
  display: inline-grid;
  place-items: center;
  min-width: 42px;
  padding-inline: 10px;
}

.fullscreen-icon {
  position: relative;
  width: 20px;
  height: 20px;
  display: inline-block;
}

.fullscreen-icon::before,
.fullscreen-icon::after {
  content: "";
  position: absolute;
  inset: 1px;
  background:
    linear-gradient(currentColor, currentColor) left top / 7px 2px no-repeat,
    linear-gradient(currentColor, currentColor) left top / 2px 7px no-repeat,
    linear-gradient(currentColor, currentColor) right top / 7px 2px no-repeat,
    linear-gradient(currentColor, currentColor) right top / 2px 7px no-repeat,
    linear-gradient(currentColor, currentColor) left bottom / 7px 2px no-repeat,
    linear-gradient(currentColor, currentColor) left bottom / 2px 7px no-repeat,
    linear-gradient(currentColor, currentColor) right bottom / 7px 2px no-repeat,
    linear-gradient(currentColor, currentColor) right bottom / 2px 7px no-repeat;
}

.fullscreen-toggle.is-fullscreen .fullscreen-icon {
  transform: rotate(180deg);
}

.video-frame:fullscreen {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  background: #000;
}

.video-frame:fullscreen > video {
  width: 100%;
  height: 100%;
  max-height: none;
}

.video-frame:fullscreen .controls {
  position: relative;
}

@media (max-width: 860px) {
  .topbar {
    height: auto;
    flex: 0 0 auto;
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
    padding: 9px 12px 10px;
    background: rgba(7, 9, 13, 0.985);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.055) inset, 0 8px 20px rgba(0, 0, 0, 0.22);
    backdrop-filter: blur(18px) saturate(1.08);
    z-index: 20;
  }

  .brand {
    gap: 9px;
  }

  

.brand strong {
    font-size: 16px;
    line-height: 1.05;
  }

  .brand span {
    margin-top: 2px;
    font-size: 11px;
  }

  .status-line {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-areas:
      "conn voice mic count"
      "noise micvol micvol micvol";
    gap: 6px;
    justify-content: stretch;
  }

  #connectionBadge {
    grid-area: conn;
  }

  #voiceBadge {
    grid-area: voice;
  }

  #micToggleButton {
    grid-area: mic;
  }

  #noiseToggleButton {
    grid-area: noise;
  }

  #memberCount {
    grid-area: count;
  }

  .status-badge,
  .top-volume-control {
    min-width: 0;
    min-height: 27px;
    padding: 0 8px;
    justify-content: center;
    overflow: hidden;
    text-overflow: ellipsis;
    border-radius: 9px;
    font-size: 11px;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.025)),
      rgba(23, 27, 35, 0.78);
    backdrop-filter: blur(12px) saturate(1.08);
  }

  .top-volume-control {
    grid-area: micvol;
    gap: 7px;
  }

  .top-volume-control input {
    width: 100%;
    min-width: 0;
  }

  .cinema-layout {
    min-height: auto;
  }

  .fullscreen-toggle {
    min-width: 46px;
    padding-inline: 8px;
  }
}

@media (max-width: 520px) {
  .status-line {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-areas:
      "conn voice mic count"
      "noise micvol micvol micvol";
  }

  .status-badge,
  .top-volume-control {
    min-height: 26px;
    padding-inline: 6px;
    font-size: 11px;
  }

  .top-volume-control span {
    flex: 0 0 auto;
  }

  .top-volume-control input {
    height: 16px;
  }
}

/* 1.0+ Vue shadcn-style layer: restrained dark surfaces, smaller controls, cleaner hierarchy. */
:root {
  --pc-bg: #08090d;
  --pc-surface: rgba(17, 19, 25, 0.86);
  --pc-surface-2: rgba(23, 26, 34, 0.78);
  --pc-surface-3: rgba(255, 255, 255, 0.055);
  --pc-border: rgba(255, 255, 255, 0.095);
  --pc-border-strong: rgba(255, 255, 255, 0.16);
  --pc-text: #f5f7fb;
  --pc-muted: rgba(235, 240, 250, 0.62);
  --pc-faint: rgba(235, 240, 250, 0.42);
  --pc-blue: #67d7ff;
  --pc-green: #7af4d7;
  --pc-red: #ff2d55;
  --pc-yellow: #ffd166;
  --pc-radius: 10px;
  --pc-shadow: 0 18px 54px rgba(0, 0, 0, 0.28);
  --pc-ring: 0 0 0 2px rgba(103, 215, 255, 0.36);
}

body {
  background:
    radial-gradient(circle at 18% -8%, rgba(103, 215, 255, 0.1), transparent 28%),
    radial-gradient(circle at 96% 10%, rgba(255, 45, 85, 0.08), transparent 26%),
    linear-gradient(180deg, #101218 0%, var(--pc-bg) 42%, #050609 100%);
}

.topbar {
  border-bottom-color: var(--pc-border);
  background: rgba(8, 9, 13, 0.88);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.045) inset, 0 18px 50px rgba(0, 0, 0, 0.18);
}

.brand strong {
  font-weight: 720;
}

.brand span {
  color: var(--pc-faint);
}

.status-badge,
.top-volume-control,
.icon-button,
select,
.secondary-button,
.chat-form input,
.name-card input {
  border-color: var(--pc-border);
  background: var(--pc-surface-3);
  color: var(--pc-text);
  box-shadow: none;
}

.status-badge,
.top-volume-control {
  border-radius: 999px;
}

.status-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.74;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

#memberCount::before {
  display: none;
}

.status-ok {
  color: var(--pc-green);
  border-color: rgba(122, 244, 215, 0.22);
  background: rgba(122, 244, 215, 0.08);
}

.status-warn {
  color: var(--pc-yellow);
  border-color: rgba(255, 209, 102, 0.22);
  background: rgba(255, 209, 102, 0.08);
}

.status-danger {
  color: #ff8ea1;
  border-color: rgba(255, 45, 85, 0.24);
  background: rgba(255, 45, 85, 0.09);
}

.noise-toggle.is-off,
.mic-toggle.is-off {
  color: var(--pc-muted);
}

.primary-button {
  border: 1px solid rgba(103, 215, 255, 0.2);
  background: linear-gradient(180deg, rgba(103, 215, 255, 0.24), rgba(103, 215, 255, 0.14));
  color: #f7fcff;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.12) inset;
}

.cinema-layout {
  gap: 0;
  background: transparent;
}

.stage {
  background: rgba(3, 4, 6, 0.84);
  border-right-color: var(--pc-border);
}

.video-frame {
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.04), transparent 38%),
    #020305;
}

.controls {
  border-top-color: var(--pc-border);
  background:
    linear-gradient(180deg, transparent, rgba(4, 5, 8, 0.82) 20%, rgba(7, 8, 12, 0.96));
}

.controls .icon-button,
.controls select,
.controls .file-action {
  min-height: 36px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.07);
}

.controls .icon-button:hover,
.controls select:hover,
.controls .file-action:hover,
.primary-button:hover {
  border-color: var(--pc-border-strong);
  background-color: rgba(255, 255, 255, 0.095);
}

input[type="range"] {
  accent-color: var(--pc-red);
}

.top-volume-control input,
.voice-volume-control input,
.transfer-panel progress {
  accent-color: var(--pc-blue);
}

.side-panel {
  border-color: var(--pc-border);
  background: rgba(9, 10, 14, 0.72);
}

.panel-toggle {
  min-height: 44px;
  color: var(--pc-text);
  border-bottom-color: var(--pc-border);
  font-size: 15px;
  letter-spacing: 0;
}

.member,
.message,
.system-message,
.transfer-panel,
.name-card,
.confirm-card {
  border-color: var(--pc-border);
  background: var(--pc-surface);
  box-shadow: none;
}

.member {
  border-radius: 12px;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.member:hover {
  border-color: rgba(103, 215, 255, 0.16);
  background: rgba(24, 28, 37, 0.86);
}

.avatar {
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.025)),
    rgba(38, 45, 60, 0.9);
}

.member.speaking {
  border-color: rgba(103, 215, 255, 0.32);
  background: rgba(103, 215, 255, 0.075);
}

.member.speaking .avatar {
  outline-color: rgba(103, 215, 255, 0.78);
  box-shadow: 0 0 0 4px rgba(103, 215, 255, 0.12);
}

.member-state,
.source-owner-badge {
  color: var(--pc-green);
}

.source-owner-badge {
  border-color: rgba(103, 215, 255, 0.26);
  background: rgba(103, 215, 255, 0.11);
  color: #b7f0ff;
}

.messages {
  gap: 10px;
}

.message {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
}

.message-meta {
  color: var(--pc-faint);
}

.system-message {
  border-color: rgba(103, 215, 255, 0.2);
  background: rgba(103, 215, 255, 0.09);
}

.system-message .message-meta {
  color: #aeefff;
}

.chat-form {
  background: rgba(8, 9, 13, 0.86);
}

.chat-form input {
  min-height: 40px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.055);
}

.transfer-panel {
  color: var(--pc-muted);
  background: rgba(10, 11, 16, 0.88);
}

.modal {
  background: rgba(2, 3, 5, 0.72);
}

.name-card,
.confirm-card {
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.065), rgba(255, 255, 255, 0.025)),
    rgba(16, 18, 24, 0.96);
  box-shadow: var(--pc-shadow);
}

.chat-form input:focus,
.name-card input:focus,
select:focus,
button:focus-visible,
input[type="range"]:focus-visible {
  outline: none;
  box-shadow: var(--pc-ring);
}

@media (max-width: 860px) {
  .topbar {
    background: rgba(7, 8, 12, 0.985);
  }

  .status-badge,
  .top-volume-control {
    min-height: 25px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.055);
  }

  .status-badge::before {
    width: 5px;
    height: 5px;
  }

  .controls .icon-button,
  .controls select,
  .controls .file-action {
    min-height: 32px;
    border-radius: 9px;
  }
}

/* 1.0+ Cinema OS redesign: cleaner desktop composition, lighter chrome, stronger video focus. */
@media (min-width: 861px) {
  body {
    background:
      radial-gradient(circle at 14% -12%, rgba(98, 216, 255, 0.13), transparent 28%),
      radial-gradient(circle at 88% 0%, rgba(255, 45, 85, 0.09), transparent 26%),
      linear-gradient(145deg, #0d1017 0%, #07080d 45%, #040507 100%);
  }

  .app-shell {
    min-height: 100dvh;
    padding: 12px;
    gap: 12px;
  }

  .topbar {
    position: sticky;
    top: 12px;
    height: 64px;
    flex: 0 0 64px;
    padding: 10px 14px;
    border: 1px solid var(--pc-border);
    border-radius: 18px;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.018)),
      rgba(9, 10, 15, 0.78);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28), 0 1px 0 rgba(255, 255, 255, 0.06) inset;
  }

  
.brand strong {
    font-size: 17px;
  }

  .status-line {
    gap: 7px;
  }

  .status-badge,
  .top-volume-control {
    min-height: 28px;
    padding: 0 10px;
    font-size: 12px;
    background: rgba(255, 255, 255, 0.052);
  }

  .top-volume-control input {
    width: 82px;
  }

  .cinema-layout {
    flex: 1;
    min-height: calc(100dvh - 100px);
    height: auto;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
    grid-template-rows: minmax(420px, 1fr) minmax(170px, 25vh);
    gap: 12px;
    grid-template-areas:
      "stage chat"
      "members chat";
  }

  .stage,
  .side-panel {
    border: 1px solid var(--pc-border);
    border-radius: 20px;
    overflow: hidden;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.012)),
      rgba(8, 9, 13, 0.72);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.22);
  }

  .video-frame {
    border-radius: 20px 20px 0 0;
    max-height: calc(100dvh - 164px);
  }

  .controls {
    min-height: 78px;
    padding: 9px 14px 12px;
  }

  .transfer-panel {
    min-height: 42px;
    border-top-color: var(--pc-border);
  }

  .members-panel,
  .chat-panel {
    border: 1px solid var(--pc-border);
  }

  .chat-panel {
    max-height: calc(100dvh - 100px);
  }

  .panel-toggle {
    min-height: 42px;
    padding-inline: 14px;
    color: rgba(248, 250, 255, 0.92);
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0)),
      rgba(255, 255, 255, 0.012);
  }

  .members {
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    padding: 12px;
  }

  .member {
    min-height: 72px;
    padding: 12px;
    border-radius: 16px;
  }

  .messages {
    padding: 12px;
  }

  .message {
    border-radius: 14px;
  }

  .chat-form {
    padding: 12px;
  }

  .chat-form input {
    border-radius: 999px;
    padding-inline: 14px;
  }

  .chat-form .primary-button {
    border-radius: 999px;
    padding-inline: 18px;
  }
}

@media (max-width: 860px) {
  .app-shell {
    background: #050609;
  }

  .stage {
    border-top: 1px solid var(--pc-border);
  }

  .message,
  .member {
    border-radius: 14px;
  }
}

/* 1.0+ Studio UI refresh: quieter Apple-like chrome with video-first layout. */
:root {
  --studio-bg: #07080b;
  --studio-surface: rgba(18, 20, 26, 0.78);
  --studio-surface-soft: rgba(255, 255, 255, 0.055);
  --studio-border: rgba(255, 255, 255, 0.11);
  --studio-border-soft: rgba(255, 255, 255, 0.075);
  --studio-text: #f7f8fb;
  --studio-muted: rgba(235, 239, 247, 0.62);
  --studio-blue: #6bd6ff;
  --studio-green: #7ef0d2;
  --studio-red: #ff375f;
  --studio-yellow: #ffd166;
  --studio-shadow: 0 20px 70px rgba(0, 0, 0, 0.28);
}

html {
  background: var(--studio-bg);
}

body {
  background: linear-gradient(180deg, #101218 0%, #07080b 42%, #050609 100%);
  color: var(--studio-text);
}

.topbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  align-items: center;
  gap: 14px;
}

.topbar-main {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand strong {
  letter-spacing: 0;
}

.room-summary,
.voice-control-cluster {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

#voiceBadge,
#micToggleButton,
#noiseToggleButton,
.voice-control-cluster .top-volume-control {
  grid-area: auto !important;
}

.status-line {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
}

.status-badge,
.top-volume-control {
  min-height: 30px;
  border: 1px solid var(--studio-border-soft);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--studio-muted);
  box-shadow: none;
}

.status-badge {
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  line-height: 1;
}

.status-badge::before {
  width: 6px;
  height: 6px;
}

.voice-pill {
  max-width: min(30vw, 280px);
  overflow: hidden;
  text-overflow: ellipsis;
}

.member-count {
  color: var(--studio-blue);
}

.member-count::before {
  display: none;
}

.top-volume-control {
  padding: 0 10px;
}

.top-volume-control input {
  width: 86px;
}

.status-ok {
  color: var(--studio-green);
  border-color: rgba(126, 240, 210, 0.22);
  background: rgba(126, 240, 210, 0.075);
}

.status-warn {
  color: var(--studio-yellow);
  border-color: rgba(255, 209, 102, 0.2);
  background: rgba(255, 209, 102, 0.075);
}

.status-danger {
  color: #ff9bad;
  border-color: rgba(255, 55, 95, 0.24);
  background: rgba(255, 55, 95, 0.08);
}

.cinema-layout {
  grid-template-columns: minmax(0, 1fr) minmax(318px, 360px);
}

.stage,
.side-panel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.032), rgba(255, 255, 255, 0.012)),
    rgba(9, 10, 14, 0.78);
  border-color: var(--studio-border-soft);
  box-shadow: var(--studio-shadow);
}

.video-frame {
  background: #030406;
}

.empty-state {
  padding: 22px;
  background: linear-gradient(180deg, rgba(5, 6, 9, 0.2), rgba(5, 6, 9, 0.88));
}

.empty-card {
  width: min(460px, 92%);
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  background: rgba(10, 12, 18, 0.68);
  backdrop-filter: blur(18px) saturate(1.12);
}

.controls {
  min-height: 82px;
  grid-template-columns: auto auto minmax(0, 1fr) auto auto minmax(96px, 130px) minmax(96px, 130px) auto;
  gap: 9px 10px;
  padding: 9px 14px 12px;
  background:
    linear-gradient(180deg, rgba(3, 4, 6, 0), rgba(5, 6, 9, 0.8) 20%, rgba(5, 6, 9, 0.96));
}

.controls .progress-wrap {
  grid-column: 1 / -1;
}

.controls .icon-button,
.controls select,
.controls .file-action {
  min-height: 34px;
  border-radius: 10px;
  border-color: var(--studio-border-soft);
  background: rgba(255, 255, 255, 0.075);
}

.play-toggle {
  min-width: 58px;
}

.progress-wrap input[type="range"] {
  height: 18px;
}

.volume-control {
  min-width: 96px;
}

.panel-toggle {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  font-weight: 760;
  border-bottom-color: var(--studio-border-soft);
}

.panel-toggle small {
  min-width: 0;
  color: var(--studio-muted);
  font-size: 12px;
  font-weight: 520;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.members {
  gap: 8px;
}

.member {
  min-height: 66px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.045);
}

.message {
  border: 0;
  background: rgba(255, 255, 255, 0.04);
}

.system-message {
  border: 1px solid rgba(107, 214, 255, 0.2);
  background: rgba(107, 214, 255, 0.1);
}

.chat-empty {
  margin: auto;
  color: rgba(235, 239, 247, 0.38);
  font-size: 13px;
}

.chat-form {
  grid-template-columns: minmax(0, 1fr) 72px;
}

.chat-form .primary-button {
  min-width: 72px;
}

@media (min-width: 861px) {
  .app-shell {
    padding: 14px;
    gap: 14px;
  }

  .topbar {
    top: 14px;
    height: 60px;
    flex-basis: 60px;
    padding: 9px 12px;
    border-radius: 18px;
  }

  .cinema-layout {
    min-height: calc(100dvh - 102px);
    grid-template-rows: minmax(420px, 1fr) minmax(150px, 23vh);
    gap: 14px;
  }

  .video-frame {
    max-height: calc(100dvh - 160px);
  }
}

@media (max-width: 1120px) and (min-width: 861px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr);
  }

  .status-line {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}

@media (max-width: 860px) {
  body {
    background: #050609;
  }

  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    padding: 8px 10px;
    border-radius: 0;
  }

  .topbar-main {
    gap: 10px;
  }

  
.brand strong {
    font-size: 15px;
  }

  .brand span {
    display: none;
  }

  .room-summary {
    flex: 0 0 auto;
  }

  .status-line {
    display: grid;
    grid-template-columns: minmax(96px, 0.82fr) minmax(0, 2.18fr) !important;
    grid-template-areas: none !important;
    gap: 6px;
  }

  .voice-control-cluster {
    display: grid;
    grid-template-columns: minmax(72px, 0.8fr) minmax(70px, 0.76fr) minmax(0, 1.6fr);
    gap: 6px;
  }

  #voiceBadge {
    justify-self: stretch;
  }

  .voice-pill {
    max-width: none;
  }

  .status-badge,
  .top-volume-control {
    min-height: 26px;
    padding-inline: 8px;
    justify-content: center;
    font-size: 11px;
  }

  .top-volume-control input {
    width: 100%;
    min-width: 0;
  }

  .cinema-layout {
    gap: 0;
  }

  .stage,
  .side-panel {
    border-radius: 0;
    box-shadow: none;
  }

  .video-frame {
    min-height: auto;
  }

  .empty-state {
    position: relative;
    inset: auto;
    min-height: 260px;
    width: 100%;
  }

  .video-frame > video {
    max-height: 56vh;
  }

  .controls {
    min-height: 106px;
    grid-template-columns: 56px minmax(62px, 1fr) 66px minmax(72px, 1fr) 48px;
    grid-template-areas:
      "progress progress progress progress progress"
      "play choose rate fit fullscreen"
      "video-volume video-volume video-volume voice-volume voice-volume";
    gap: 6px;
    padding: 7px 8px calc(9px + env(safe-area-inset-bottom));
  }

  .controls .icon-button,
  .controls select,
  .controls .file-action {
    min-height: 32px;
    height: 32px;
    padding-inline: 7px;
    font-size: 12px;
  }

  .volume-control {
    min-width: 0;
  }

  .panel-toggle {
    min-height: 42px;
    padding-inline: 12px;
  }

  .chat-panel .panel-content {
    min-height: 48vh;
    height: 56vh;
  }

  .messages {
    min-height: 0;
  }
}

@media (max-width: 430px) {
  .room-summary .status-badge {
    max-width: 76px;
  }

  .member-count {
    max-width: 64px;
  }

  .voice-control-cluster {
    grid-template-columns: minmax(64px, 0.74fr) minmax(64px, 0.72fr) minmax(0, 1.5fr);
  }

  .top-volume-control span {
    display: none;
  }
}

/* 1.0+ fullscreen fix: mobile page rules must not shrink the fullscreen video. */
.video-frame:fullscreen,
.video-frame:-webkit-full-screen {
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  max-height: 100dvh !important;
  min-height: 100vh !important;
  min-height: 100dvh !important;
  aspect-ratio: auto !important;
  display: grid !important;
  grid-template: 1fr / 1fr !important;
  place-items: center !important;
  overflow: hidden !important;
  border-radius: 0 !important;
  background: #000 !important;
}

.video-frame:fullscreen::backdrop,
.video-frame:-webkit-full-screen::backdrop {
  background: #000;
}

.video-frame:fullscreen > video,
.video-frame:-webkit-full-screen > video {
  grid-area: 1 / 1 !important;
  flex: 0 0 auto !important;
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  max-height: 100dvh !important;
  min-height: 0 !important;
  aspect-ratio: auto !important;
  object-fit: contain !important;
  background: #000 !important;
}

.video-frame:fullscreen .controls,
.video-frame:-webkit-full-screen .controls {
  grid-area: 1 / 1 !important;
  position: absolute !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  z-index: 20 !important;
  width: 100% !important;
  min-height: 82px !important;
  padding-bottom: max(10px, env(safe-area-inset-bottom)) !important;
  background:
    linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.72) 22%, rgba(0, 0, 0, 0.92)) !important;
}

.video-frame:fullscreen .empty-state,
.video-frame:-webkit-full-screen .empty-state {
  display: none !important;
}

@media (orientation: landscape) {
  .video-frame:fullscreen .controls,
  .video-frame:-webkit-full-screen .controls {
    min-height: 76px !important;
  }
}

/* 1.0+ mobile video sizing: keep the player height tied to the actual video, not the page viewport. */
@media (max-width: 860px) {
  .stage {
    display: block;
    min-height: 0;
  }

  .video-frame {
    flex: none !important;
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 0 !important;
    max-height: none !important;
    aspect-ratio: auto !important;
    overflow: visible;
    background: #030406;
  }

  .video-frame > video {
    flex: none !important;
    display: block;
    width: 100%;
    height: auto !important;
    min-height: 0 !important;
    max-height: min(58vh, calc(100dvh - 220px));
    aspect-ratio: var(--video-aspect, 16 / 9);
    object-fit: contain;
    background: #000;
  }

  .video-frame[data-aspect="16-9"] > video,
  .video-frame > video[data-fit="ratio-16-9"] {
    aspect-ratio: 16 / 9;
  }

  .video-frame[data-aspect="4-3"] > video,
  .video-frame > video[data-fit="ratio-4-3"] {
    aspect-ratio: 4 / 3;
  }

  .video-frame > video[data-fit="fill"] {
    aspect-ratio: var(--video-aspect, 16 / 9);
    object-fit: fill;
  }

  .video-frame .controls {
    flex: none;
  }

  .stage.controls-hidden .video-frame {
    background: transparent;
  }

  .stage.controls-hidden .video-frame .controls {
    display: none !important;
    height: 0 !important;
    min-height: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    margin: 0 !important;
  }

  .stage.controls-hidden .video-frame:not(:fullscreen):not(:-webkit-full-screen) {
    display: block !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
  }

  .stage.controls-hidden .video-frame:not(:fullscreen):not(:-webkit-full-screen) > video {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    max-height: none !important;
    aspect-ratio: var(--video-aspect, 16 / 9);
  }
}
