:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #101214;
  color: #f2f4f7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(46, 125, 50, 0.16), transparent 35%),
    linear-gradient(315deg, rgba(3, 169, 244, 0.16), transparent 34%),
    #101214;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
  min-height: 100dvh;
}

.topbar,
.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
}

.topbar {
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

h1,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0;
}

#status {
  margin-top: 4px;
  color: #aeb7c3;
  font-size: 14px;
}

#activity-status {
  min-height: 18px;
  margin-top: 3px;
  color: #d5dbe3;
  font-size: 13px;
}

#rename-button {
  min-width: 92px;
}

.name-dialog {
  width: min(560px, calc(100vw - 32px));
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: #171b20;
  color: #f2f4f7;
  padding: 0;
}

.name-dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.initial-name-form {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.initial-name-form h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0;
}

.initial-name-form input,
.initial-name-form textarea,
.initial-name-form button {
  width: 100%;
}

.captcha-control {
  display: grid;
  gap: 7px;
}

.captcha-control[hidden] {
  display: none;
}

.captcha-label {
  color: #d5dbe3;
  font-size: 13px;
  font-weight: 650;
}

.captcha-row {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 8px;
  align-items: stretch;
}

.captcha-control canvas {
  width: 160px;
  height: 42px;
  border-radius: 8px;
  background: #f2f4f7;
}

.captcha-control input {
  width: 100%;
}

.initial-name-form textarea {
  min-height: 110px;
  resize: vertical;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

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

.voice-controls label {
  display: grid;
  gap: 5px;
  color: #aeb7c3;
  font-size: 12px;
  font-weight: 650;
}

.voice-controls input {
  width: 100%;
  height: 18px;
  padding: 0;
}

@media (max-width: 620px) {
  .captcha-row {
    grid-template-columns: 1fr;
  }

  .captcha-control canvas {
    width: 100%;
  }

  .voice-controls {
    grid-template-columns: 1fr;
  }
}

input,
select,
textarea {
  width: min(42vw, 260px);
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  padding: 0 12px;
  font: inherit;
}

textarea {
  height: auto;
  line-height: 1.4;
  padding: 10px 12px;
}

select {
  width: min(36vw, 260px);
  cursor: pointer;
}

button {
  min-width: 92px;
  height: 42px;
  border: 0;
  border-radius: 8px;
  background: #1f8f5f;
  color: white;
  cursor: pointer;
  font-weight: 650;
}

button:hover {
  filter: brightness(1.08);
}

button[aria-pressed="false"] {
  background: #4a535f;
}

.stage {
  display: grid;
  grid-template-rows: var(--watch-panel-height, 320px) 14px minmax(0, 1fr);
  gap: 0;
  min-height: 0;
  padding: 18px 18px 12px;
}

.stage.is-watch-collapsed {
  grid-template-rows: 0 20px minmax(0, 1fr);
}

.watch-panel {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(240px, 360px);
  grid-template-rows: 100%;
  gap: 14px;
  align-items: stretch;
  min-height: 0;
  overflow: auto;
}

.stage.is-watch-collapsed .watch-panel {
  overflow: hidden;
}

.watch-main {
  display: grid;
  min-height: 0;
}

.youtube-form {
  display: flex;
  align-items: stretch;
  gap: 10px;
  padding: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.youtube-form input {
  width: 100%;
}

.youtube-form button {
  height: 42px;
}

.youtube-shell {
  position: relative;
  display: none;
  overflow: hidden;
  min-height: 0;
  border-radius: 8px;
  background: #171b20;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.youtube-shell.is-active {
  display: block;
}

#youtube-player,
#youtube-player iframe {
  width: 100%;
  height: 100%;
}

.watch-resize-handle {
  position: relative;
  min-width: 0;
  width: 100%;
  height: 14px;
  border: 0;
  border-radius: 0;
  background: transparent;
  cursor: row-resize;
}

.stage.is-watch-collapsed .watch-resize-handle {
  cursor: default;
}

.watch-resize-handle::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(140px, 32vw);
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.24);
  transform: translate(-50%, -50%);
}

.watch-collapse-button {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 1;
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: #1f8f5f;
  color: #ffffff;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  transform: translate(-50%, -50%);
}

.watch-collapse-button:hover,
.watch-collapse-button:focus-visible {
  filter: brightness(1.12);
  outline: 2px solid rgba(255, 255, 255, 0.42);
  outline-offset: 2px;
}

.watch-resize-handle:hover::before,
.watch-resize-handle:focus-visible::before,
.stage.is-resizing-watch .watch-resize-handle::before {
  background: rgba(255, 255, 255, 0.46);
}

.stage.is-resizing-watch {
  user-select: none;
}

.playlist-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.playlist-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  color: #d9dee7;
  font-weight: 700;
}

.playlist-header button {
  min-width: 86px;
  height: 34px;
  background: #4a535f;
  font-size: 12px;
}

.playlist-list {
  display: grid;
  align-content: start;
  gap: 6px;
  min-height: 0;
  margin: 0;
  padding: 10px;
  overflow: auto;
  list-style: none;
}

.playlist-list:empty::before {
  content: "No videos added";
  color: #aeb7c3;
  font-size: 13px;
}

.playlist-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  gap: 6px;
}

.playlist-item button {
  min-height: 42px;
  min-width: 0;
  border-radius: 6px;
}

.playlist-play {
  display: grid;
  gap: 2px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
  color: #f2f4f7;
  text-align: left;
  font-weight: 600;
}

.playlist-title,
.playlist-timestamp {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.playlist-timestamp {
  color: #aeb7c3;
  font-size: 11px;
  font-weight: 600;
}

.playlist-item.is-active .playlist-timestamp {
  color: rgba(255, 255, 255, 0.82);
}

.playlist-item.is-active .playlist-play {
  background: #1f8f5f;
}

.playlist-delete {
  background: #4a535f;
}

.remote-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  grid-auto-rows: minmax(210px, 1fr);
  gap: 14px;
  align-content: stretch;
  min-height: 100%;
}

.remote-grid.has-presentation {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  grid-auto-rows: minmax(130px, auto);
  align-content: start;
}

.tile {
  position: relative;
  overflow: hidden;
  min-height: 220px;
  aspect-ratio: 16 / 10;
  border-radius: 8px;
  background: #1b2026;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.presentation-tile {
  grid-column: 1 / -1;
  min-height: min(58vh, 620px);
  aspect-ratio: 16 / 9;
}

.remote-grid.has-presentation .tile:not(.presentation-tile) {
  min-height: 130px;
}

.remote-grid.has-presentation .tile:not(.presentation-tile) .tile-name {
  font-size: 12px;
}

.tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #171b20;
}

.camera-off-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #171b20;
}

.camera-off-placeholder[hidden] {
  display: none;
}

.camera-off-placeholder img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-off-placeholder span {
  position: absolute;
  left: 12px;
  top: 12px;
  padding: 5px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.58);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.remote-mute-indicator {
  position: absolute;
  right: 12px;
  top: 12px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  font-size: 19px;
  font-weight: 800;
  line-height: 1;
}

.remote-mute-indicator[hidden] {
  display: none;
}

.presentation-tile video {
  object-fit: contain;
}

.tile-name {
  position: absolute;
  left: 12px;
  bottom: 12px;
  max-width: max(90px, calc(100% - 190px));
  padding: 6px 9px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.56);
  color: #fff;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.participant-audio-controls {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: grid;
  gap: 4px;
  width: min(150px, calc(100% - 24px));
  padding: 7px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.58);
}

.participant-audio-controls label {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  color: #fff;
  font-size: 11px;
}

.participant-audio-controls input {
  width: 100%;
  height: 18px;
  padding: 0;
}

.empty-stage {
  display: grid;
  place-items: center;
  min-height: min(58vh, 560px);
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: #aeb7c3;
  font-size: 15px;
}

.remote-grid:has(.tile) .empty-stage {
  display: none;
}

.controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 88px;
  align-items: center;
  column-gap: 20px;
  row-gap: 14px;
  justify-content: initial;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(16, 18, 20, 0.92);
}

.control-panel {
  display: flex;
  align-items: end;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  min-width: 0;
}

.device-controls {
  display: flex;
  align-items: end;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  min-width: 0;
}

.device-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 180px);
  grid-template-rows: 14px 36px;
  align-items: end;
  column-gap: 8px;
  row-gap: 5px;
  width: 224px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.symbol-button {
  display: inline-grid;
  place-items: center;
  grid-column: 1;
  grid-row: 2;
  width: 36px;
  height: 36px;
  min-width: 0;
  padding: 0;
  font-size: 18px;
  line-height: 1;
}

.device-row select {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: 36px;
  font-size: 13px;
}

.symbol-button[aria-pressed="false"] {
  background: #5a6470;
  opacity: 0.72;
}

.device-row label {
  display: grid;
  grid-column: 2;
  grid-row: 1 / 3;
  grid-template-rows: 14px 36px;
  row-gap: 5px;
  min-width: 0;
}

.device-row label span {
  grid-row: 1;
  justify-self: start;
  margin-left: -44px;
  color: #aeb7c3;
  font-size: 12px;
  font-weight: 650;
}

.device-row label select {
  grid-row: 2;
}

.control-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
}

.control-actions button {
  height: 36px;
  min-width: 104px;
  font-size: 13px;
}

.self-mic-control {
  display: grid;
  grid-template-columns: minmax(120px, 160px) minmax(88px, 112px);
  align-items: end;
  gap: 8px;
  min-width: 238px;
}

.self-mic-control > label {
  display: grid;
  grid-template-rows: 12px 18px;
  gap: 5px;
  color: #aeb7c3;
  font-size: 11px;
  font-weight: 650;
}

.self-mic-control input[type="range"] {
  width: 100%;
  height: 18px;
  padding: 0;
}

.self-mic-level {
  display: grid;
  grid-template-rows: 18px 14px;
  gap: 5px;
}

.self-mic-level meter {
  width: 100%;
  height: 18px;
  align-self: end;
}

.noise-suppression-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  color: #aeb7c3;
  font-size: 10px;
  font-weight: 650;
  white-space: nowrap;
}

.noise-suppression-toggle input {
  width: 12px;
  height: 12px;
  margin: 0;
  padding: 0;
  flex: 0 0 auto;
}

.self-preview {
  position: relative;
  overflow: hidden;
  width: 100%;
  min-width: 88px;
  align-self: end;
  aspect-ratio: 16 / 10;
  border-radius: 8px;
  background: #1b2026;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
}

.self-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #171b20;
}

.self-preview span {
  position: absolute;
  left: 10px;
  bottom: 10px;
  max-width: calc(100% - 20px);
  padding: 5px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.58);
  color: #fff;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (min-width: 681px) and (max-width: 980px) {
  .control-panel {
    display: grid;
    grid-template-rows: auto auto;
    justify-content: stretch;
  }

  .device-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
  }

  .device-row {
    grid-template-columns: 40px minmax(0, 1fr);
    width: 100%;
  }

  .device-row select {
    width: 100%;
  }

  .control-actions {
    justify-content: end;
  }
}

@media (max-width: 680px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
    padding: 14px;
  }

  input {
    width: 100%;
  }

  select {
    width: 100%;
  }

  button {
    min-width: 76px;
  }

  .stage {
    padding: 10px;
    grid-template-rows: var(--watch-panel-height, 430px) 14px minmax(0, 1fr);
  }

  .stage.is-watch-collapsed {
    grid-template-rows: 0 20px minmax(0, 1fr);
  }

  .watch-panel {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(220px, 1fr) minmax(160px, auto);
    min-height: 430px;
  }

  .remote-grid {
    grid-template-columns: 1fr;
    grid-auto-rows: minmax(190px, 1fr);
  }

  .controls {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .device-controls {
    width: 100%;
  }

  .device-row {
    grid-template-columns: 40px minmax(0, 1fr);
    width: 100%;
  }

  .control-actions button {
    min-width: min(100%, 220px);
  }

  .self-preview {
    justify-self: center;
    width: 88px;
  }
}
