:root {
  color: #f5f7ff;
  background: #090b10;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #090b10;
  --card: #11151e;
  --line: #1c2638;
  --btn: #171e2c;
  --btn-line: #2d394f;
  --text: #edf1fa;
  --muted: #b7c1d5;
  --accent: #8fa7ff;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; }
body { margin: 0; min-width: 320px; background: var(--bg); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

.app-shell { width: 100vw; height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 40px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  background: #0c1018;
}
.topbar h1 { margin: 0; font-size: 13px; font-weight: 650; letter-spacing: 0.02em; }
.topbar-meta { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; }
.badge {
  border: 1px solid var(--btn-line);
  border-radius: 99px;
  padding: 2px 8px;
  background: var(--btn);
  color: #dce5fa;
}
.nav a { color: var(--accent); text-decoration: none; margin-left: 8px; }
.nav a:hover { text-decoration: underline; }

.stream-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 2px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #253047;
}
.stream-grid.focus-mode {
  grid-template-columns: minmax(0, 1fr) clamp(190px, 21vw, 380px);
  grid-template-rows: repeat(3, minmax(0, 1fr));
}
.stream-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--card);
}
.stream-card .video-wrap { flex: 1; }
.stream-grid.focus-mode .stream-card.focused { grid-column: 1; grid-row: 1 / span 3; }
.stream-grid.focus-mode .stream-card:not(.focused) { grid-column: 2; }
.stream-grid.focus-mode .stream-card:not(.focused) .video-overlay { transform: scale(0.88); transform-origin: top left; }
.stream-grid.focus-mode .stream-card:not(.focused) .card-footer { min-height: 27px; padding-block: 1px; }
.stream-grid.focus-mode .stream-card:not(.focused) .icon-button { width: 23px; height: 23px; font-size: 11px; }
.stream-grid.focus-mode .stream-card:not(.focused) .quality,
.stream-grid.focus-mode .stream-card:not(.focused) .source,
.stream-grid.focus-mode .stream-card:not(.focused) .room-input { height: 23px; font-size: 9px; }

.video-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #050609;
}
.stage {
  position: absolute;
  inset: 0;
}
.danmaku-host {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}
.video, .frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #050609;
}
.video { object-fit: contain; }

.video-overlay {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  border-radius: 99px;
  padding: 4px 7px;
  background: #080b12b8;
  color: #d7deed;
  font-size: 11px;
  backdrop-filter: blur(6px);
}
.status-dot { width: 7px; height: 7px; border-radius: 99px; background: #ffaf37; }
[data-state="live"] .status-dot { background: #34d399; box-shadow: 0 0 10px #34d399; }
[data-state="paused"] .status-dot { background: #fbbf24; }
[data-state="error"] .status-dot { background: #fb7185; }

.empty-state {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  padding: 44px;
  color: var(--muted);
  text-align: center;
  line-height: 1.55;
  background: #0a0d14e8;
}
.empty-state[hidden] { display: none; }

.card-footer {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-height: 32px;
  padding: 5px 7px;
  border-top: 1px solid var(--line);
  background: linear-gradient(90deg, #11151ef5, #11151ef0);
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.stream-card:hover .card-footer,
.stream-card:focus-within .card-footer { opacity: 1; pointer-events: auto; transform: translateY(0); }
.footer-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.room-label { display: inline; margin: 0 5px 0 0; font-size: 11px; font-weight: 700; }
.room-link { color: var(--accent); font-size: 10px; text-decoration: none; }
.room-link:hover { text-decoration: underline; }
.card-actions { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
.quality, .source, .room-input {
  height: 27px;
  border: 1px solid var(--btn-line);
  border-radius: 6px;
  padding: 0 6px;
  color: #dce5fa;
  background: var(--btn);
  font-size: 10px;
}
.quality { width: 86px; }
.source { width: 88px; }
.room-input { width: min(220px, 42vw); min-width: 96px; }
.quality:disabled, .source:disabled, .room-input:disabled { opacity: 0.55; }
.icon-button {
  width: 27px;
  height: 27px;
  border: 1px solid var(--btn-line);
  border-radius: 6px;
  color: var(--text);
  background: var(--btn);
  font-size: 12px;
  line-height: 1;
}
.icon-button:hover { border-color: #8099ec; }
.icon-button.apply { width: auto; padding: 0 8px; font-size: 11px; }
.icon-button.on { border-color: #34d399; color: #34d399; }
.volume {
  width: 72px;
  height: 27px;
  accent-color: #8fa7ff;
  cursor: pointer;
}

.danmaku-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  pointer-events: none;
}
.danmaku-item {
  position: absolute;
  left: 100%;
  white-space: nowrap;
  color: #fff;
  font-size: 16px;
  font-weight: 650;
  text-shadow: 0 0 2px #000, 1px 1px 2px #000;
  animation: danmaku-fly 8s linear forwards;
}
@keyframes danmaku-fly {
  from { transform: translateX(0); }
  to { transform: translateX(calc(-100vw - 100%)); }
}

.auth-dialog {
  width: min(560px, calc(100vw - 24px));
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px 14px;
  background: #11151e;
  color: var(--text);
}
.auth-dialog::backdrop { background: #05070ccc; }
.auth-dialog h2 { margin: 0 0 8px; font-size: 16px; }
.auth-dialog p { margin: 0 0 10px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.auth-dialog label { display: block; margin: 10px 0 4px; font-size: 12px; }
.auth-dialog textarea {
  width: 100%;
  min-height: 72px;
  resize: vertical;
  border: 1px solid var(--btn-line);
  border-radius: 8px;
  padding: 8px;
  background: #0b0f16;
  color: var(--text);
  font-size: 11px;
}
.auth-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }

@media (max-width: 760px) {
  .room-label {
    display: inline-block;
    max-width: 72px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
  }
  .room-input { width: 110px; }
}
.stream-card.embed-chrome .card-footer {
  position: static;
  opacity: 1;
  pointer-events: auto;
  transform: none;
  flex-shrink: 0;
}
.stream-card.embed-chrome .sound,
.stream-card.embed-chrome .volume,
.stream-card.embed-chrome .pause,
.stream-card.embed-chrome .quality,
.stream-card.embed-chrome .danmaku {
  display: none;
}
.stream-card.embed-chrome .video-overlay { display: none; }

@media (hover: none) {
  .card-footer { opacity: 1; pointer-events: auto; transform: none; }
}

.launch {
  height: 100%;
  overflow: auto;
  padding: 40px 20px 60px;
}
.launch-wrap { max-width: 820px; margin: 0 auto; }
.launch h1 { margin: 0 0 8px; font-size: 28px; }
.launch p { color: var(--muted); line-height: 1.65; }
.cards { display: grid; gap: 12px; margin-top: 22px; }
.launch a.card {
  display: block;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: inherit;
  text-decoration: none;
}
.launch a.card:hover { border-color: #8099ec; }
.launch a.card h2 { margin: 0 0 6px; font-size: 16px; }
.launch a.card p { margin: 0; font-size: 13px; }
