* {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
  --bg: #eef2f5;
  --panel: #ffffff;
  --ink: #14212b;
  --muted: #667684;
  --line: #d8e0e7;
  --soft: #f6f8fa;
  --primary: #1f6f8b;
  --primary-dark: #15566d;
  --danger: #b03a48;
  --ok: #208060;
  --code: #0d1720;
}

body {
  margin: 0;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  background: #17232d;
  color: #fff;
}

.topbar h1,
.topbar p,
h2,
p {
  margin: 0;
}

.topbar h1 {
  font-size: 22px;
  font-weight: 760;
}

.topbar p {
  margin-top: 4px;
  color: #b8c6d1;
  font-size: 13px;
}

.top-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.app-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 14px;
  width: min(1380px, calc(100vw - 28px));
  margin: 14px auto 28px;
}

.side,
.workspace {
  display: grid;
  gap: 14px;
  align-content: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
}

.panel-title,
.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

h2 {
  font-size: 16px;
  font-weight: 760;
}

.muted,
.status-line {
  color: var(--muted);
  font-size: 13px;
}

.create-room {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

input,
select {
  width: 100%;
  height: 38px;
  border: 1px solid #c8d1db;
  border-radius: 7px;
  padding: 0 11px;
  font-size: 14px;
  background: #fff;
  color: var(--ink);
}

button,
a.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--primary);
  border-radius: 7px;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

button:hover,
a.button:hover {
  background: var(--primary-dark);
}

button.ghost,
a.button.ghost {
  background: #fff;
  color: #25475a;
  border-color: #b8c6d4;
}

button.ghost:hover,
a.button.ghost:hover {
  background: #f5f8fa;
}

button.danger {
  background: var(--danger);
  border-color: var(--danger);
}

button.active-toggle {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
}

button.active-toggle:hover {
  background: #17694e;
  border-color: #17694e;
}

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

.pill,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: #e5f3ef;
  color: var(--ok);
  font-size: 12px;
  font-weight: 800;
}

.pill {
  background: rgba(255, 255, 255, 0.12);
  color: #e6f0f6;
}

.pill.bad {
  background: #f8e3e6;
  color: var(--danger);
}

.room-list-panel {
  max-height: calc(100vh - 174px);
  overflow: auto;
}

.room-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.room-row {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 56px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.room-row:hover,
.room-row.active {
  border-color: var(--primary);
  background: #f3fbfd;
}

.room-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--primary);
}

.room-main {
  display: grid;
  min-width: 0;
}

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

.room-main small {
  color: var(--muted);
  font-family: Consolas, "Roboto Mono", monospace;
  font-size: 12px;
}

.room-detail-panel {
  display: grid;
  gap: 14px;
}

.detail-head h2 {
  font-size: 22px;
}

.detail-actions,
.quick-actions,
.control-actions,
.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.quick-actions {
  padding: 12px;
  border: 1px solid #dbe6ed;
  border-radius: 9px;
  background: #f8fbfc;
}

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

.link-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
}

.link-card span {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

code {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 8px 9px;
  border: 1px solid #d4dde5;
  border-radius: 6px;
  background: var(--soft);
  font-family: Consolas, "Roboto Mono", monospace;
  font-size: 12px;
}

.mini {
  min-height: 32px;
  padding: 0 10px;
}

.control-panel {
  display: grid;
  gap: 12px;
}

.compact-section {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.compact-section summary {
  cursor: pointer;
  color: #25475a;
  font-size: 13px;
  font-weight: 800;
}

.compact-toolbar {
  margin-top: 10px;
}

.compact-toolbar select {
  flex: 1 1 260px;
}

.table-wrap {
  max-height: 240px;
  overflow: auto;
  margin-top: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  border-bottom: 1px solid #e1e7ed;
  text-align: left;
  padding: 8px;
  vertical-align: top;
}

th {
  color: #4b5b68;
  font-size: 12px;
  background: #f8fafc;
  position: sticky;
  top: 0;
}

.log {
  min-height: 160px;
  max-height: 320px;
  overflow: auto;
  background: var(--code);
  color: #d9f3ff;
  border-radius: 7px;
  padding: 10px;
  font-size: 12px;
  white-space: pre-wrap;
}

.compact-log {
  min-height: 90px;
  max-height: 160px;
}

.error-text {
  color: var(--danger);
  font-weight: 800;
}

video,
audio,
img {
  max-width: 100%;
}

.stream-page {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: #000;
}

.stream-stage {
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 0;
  display: grid;
  place-items: center;
  background: #000;
}

.stream-stage > * {
  grid-area: 1 / 1;
}

.stream-stage video {
  width: 100vw;
  height: 100vh;
  display: block;
  object-fit: contain;
  background: #000;
}

.stream-stage img {
  width: 100vw;
  height: 100vh;
  display: none;
  object-fit: contain;
  background: #000;
}

.stream-stage video[srcObject=""],
.stream-stage video:not([src]) {
  background: #000;
}

.listen-shell {
  width: 100vw;
  height: 100vh;
  display: grid;
  place-items: center;
  background: #05080b;
}

.audio-state {
  width: min(220px, 58vw);
  aspect-ratio: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  gap: 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #101820;
  color: #dfeaf2;
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.42);
}

.audio-state:hover {
  background: #13202a;
}

.state-icon {
  width: 86px;
  height: 86px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #2f3b45;
}

.state-icon::before {
  content: "";
  display: block;
}

.state-icon.off::before {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #9aa8b4;
}

.state-icon.connecting {
  border: 4px solid rgba(255, 255, 255, 0.12);
  border-top-color: #7bc4ff;
  animation: spin 1s linear infinite;
}

.state-icon.connecting::before {
  width: 0;
  height: 0;
}

.state-icon.play {
  background: #19a56b;
  box-shadow: 0 0 0 12px rgba(25, 165, 107, 0.14);
}

.state-icon.play::before {
  width: 0;
  height: 0;
  margin-left: 7px;
  border-top: 24px solid transparent;
  border-bottom: 24px solid transparent;
  border-left: 38px solid #fff;
}

.state-label {
  display: none;
}

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

.media-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 380px);
  gap: 12px;
  align-items: start;
}

@media (max-width: 980px) {
  .topbar,
  .app-grid,
  .link-board {
    grid-template-columns: 1fr;
  }

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

  .room-list-panel {
    max-height: none;
  }
}
