:root {
  color-scheme: dark;
  --bg: #111318;
  --panel: #191d25;
  --panel-strong: #202631;
  --text: #f5f7fb;
  --muted: #9da7b7;
  --line: #313846;
  --accent: #5eead4;
  --accent-strong: #2dd4bf;
  --danger: #ff7a90;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.32);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(94, 234, 212, 0.14), transparent 34rem),
    linear-gradient(135deg, #111318 0%, #171923 48%, #101217 100%);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 2rem clamp(1rem, 4vw, 3rem) 1rem;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 4.4rem);
  line-height: 0.95;
}

h2 {
  font-size: 1rem;
  letter-spacing: 0;
}

p,
li,
.note {
  color: var(--muted);
  line-height: 1.6;
}

.topbar p {
  margin-top: 0.65rem;
}

.status {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.55rem 0.8rem;
  color: var(--accent);
  background: rgba(25, 29, 37, 0.8);
}

.layout {
  display: grid;
  grid-template-columns: minmax(17rem, 0.8fr) minmax(0, 1.7fr);
  gap: 1rem;
  padding: 1rem clamp(1rem, 4vw, 3rem) 3rem;
}

.panel,
.player-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(25, 29, 37, 0.88);
  box-shadow: var(--shadow);
}

.panel {
  padding: 1rem;
}

.player-section {
  grid-row: span 3;
  padding: 1rem;
}

.room-panel,
.helper-panel {
  display: grid;
  gap: 0.9rem;
}

label {
  display: grid;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.88rem;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #10131a;
  color: var(--text);
  outline: none;
  padding: 0.72rem 0.78rem;
}

textarea {
  min-height: 6.6rem;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.14);
}

.check {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.check input {
  width: auto;
}

.button-row,
.media-loader,
.section-heading,
.now-playing {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.section-heading,
.now-playing {
  justify-content: space-between;
}

.section-heading {
  margin-bottom: 0.9rem;
}

.section-heading p {
  margin-top: 0.35rem;
}

button,
.file-button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #071411;
  cursor: pointer;
  font-weight: 700;
  padding: 0.72rem 0.9rem;
  white-space: nowrap;
}

button.secondary {
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--text);
}

.file-button.secondary-file {
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--text);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

button:active,
.file-button:active {
  transform: translateY(1px);
}

.file-button input {
  display: none;
}

.media-loader {
  margin-bottom: 0.85rem;
}

.media-loader input {
  min-width: 0;
}

.broadcast-panel {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 19, 26, 0.72);
  padding: 0.85rem;
}

.relay-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 19, 26, 0.72);
  padding: 0.85rem;
}

.relay-copy {
  display: grid;
  gap: 0.25rem;
}

.relay-copy span {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.relay-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.broadcast-copy {
  display: grid;
  gap: 0.25rem;
}

.broadcast-copy span,
.broadcast-status {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.broadcast-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.broadcast-video {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid #05070b;
  border-radius: 8px;
  background: #020305;
}

.player-frame {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid #05070b;
  border-radius: 8px;
  background: #020305;
}

.player-frame video,
.youtube-mount,
.youtube-mount iframe {
  width: 100%;
  height: 100%;
}

.player-frame video {
  display: block;
  background: #020305;
}

.youtube-mount iframe {
  border: 0;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 0.45rem;
  padding: 1rem;
  text-align: center;
  color: var(--muted);
  pointer-events: none;
}

.empty-state strong {
  color: var(--text);
}

.empty-state[hidden],
.player-frame video[hidden] {
  display: none;
}

.drop-hint {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  border: 2px dashed var(--accent);
  background: rgba(16, 19, 26, 0.84);
  color: var(--text);
  font-weight: 700;
  text-align: center;
  padding: 1rem;
}

.drop-hint[hidden] {
  display: none;
}

.player-frame.drag-over {
  border-color: var(--accent);
}

.player-frame.window-full {
  position: fixed;
  inset: 0;
  z-index: 999999;
  width: 100vw;
  height: 100vh;
  border-radius: 0;
  aspect-ratio: auto;
}

.now-playing {
  min-height: 2.5rem;
  color: var(--muted);
}

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

.playback-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin-bottom: 0.85rem;
}

.share-progress {
  min-width: 10rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.library-panel {
  display: grid;
  gap: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 19, 26, 0.72);
  padding: 0.85rem;
}

.library-panel[hidden] {
  display: none;
}

.library-header,
.library-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem 0.8rem;
  align-items: center;
}

.library-actions {
  display: flex;
  gap: 0.45rem;
  align-items: center;
}

.library-header span,
.library-path,
.library-meta {
  color: var(--muted);
  font-size: 0.82rem;
}

.library-list {
  display: grid;
  gap: 0.45rem;
  max-height: 14rem;
  overflow: auto;
}

.library-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #10131a;
  padding: 0.6rem;
}

.library-item.active {
  border-color: var(--accent);
}

.library-title,
.library-path,
.library-meta {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-title {
  color: var(--text);
  font-weight: 700;
}

.library-meta {
  margin-top: 0.25rem;
}

.library-play-btn,
.library-share-btn {
  padding: 0.55rem 0.75rem;
}

.meta-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.55rem 0.8rem;
  border-top: 1px solid var(--line);
  padding-top: 0.8rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.meta-grid strong {
  color: var(--text);
}

ol {
  margin: 0;
  padding-left: 1.3rem;
}

.note {
  border-left: 3px solid var(--accent-strong);
  padding-left: 0.8rem;
}

code {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #10131a;
  color: var(--accent);
  padding: 0.1rem 0.25rem;
}

.log {
  min-height: 4.4rem;
  max-height: 8rem;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #10131a;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
  padding: 0.65rem;
}

@media (max-width: 860px) {
  .topbar {
    display: grid;
  }

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

  .player-section {
    grid-row: auto;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding-top: 1rem;
  }

  .section-heading,
  .media-loader,
  .relay-actions,
  .broadcast-actions,
  .button-row {
    align-items: stretch;
    flex-direction: column;
  }

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

  .section-heading button,
  .media-loader button,
  .relay-actions button,
  .broadcast-actions button,
  .file-button,
  .button-row button {
    width: 100%;
  }

  .player-frame {
    aspect-ratio: 9 / 16;
  }
}
