:root {
  --bg: #070b14;
  --bg-2: #10182a;
  --panel: #151e33;
  --line: #2a3654;
  --text: #eef3ff;
  --muted: #93a0bf;
  --accent: #3ee0c7;
  --accent-2: #7aa2ff;
  --danger: #ff6b7a;
  --focus: #3ee0c7;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  font-family: "Segoe UI", "Helvetica Neue", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
}
body { overflow: hidden; }

#app {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

#chrome, #hint {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: linear-gradient(180deg, rgba(7, 11, 20, 0.96), rgba(7, 11, 20, 0.72));
  transition: opacity 0.35s ease, transform 0.35s ease;
}
#hint {
  justify-content: center;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 15px;
  background: linear-gradient(0deg, rgba(7, 11, 20, 0.96), rgba(7, 11, 20, 0.55));
}
#hint span + span::before {
  content: "·";
  margin-right: 16px;
  opacity: 0.5;
}

body.watching.idle #chrome,
body.watching.idle #hint {
  opacity: 0;
  pointer-events: none;
}
body.watching.idle #chrome { transform: translateY(-12px); }
body.watching.idle #hint { transform: translateY(12px); }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
}
.brand strong { display: block; font-size: 18px; letter-spacing: 0.04em; }
.brand span { color: var(--muted); font-size: 13px; }

.layouts { display: flex; gap: 8px; flex: 1; justify-content: center; }
.layouts button,
#chrome button,
.primary,
.pane-chrome button {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 16px;
  cursor: pointer;
}
.layouts button.active,
.primary {
  background: var(--accent);
  color: #06221d;
  border-color: var(--accent);
  font-weight: 700;
}
.chrome-right { display: flex; gap: 10px; align-items: center; }
.quality { color: var(--muted); font-size: 13px; display: flex; gap: 8px; align-items: center; }
.quality select, .field input, #pickerFilter {
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 16px;
}

#stage {
  position: relative;
  min-height: 0;
  padding: 8px;
  display: grid;
  gap: 8px;
  background: #000;
}
.layout-sbs { grid-template-columns: 1fr 1fr; }
.layout-quad { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.layout-triple {
  grid-template-columns: 2fr 1fr;
  grid-template-rows: 1fr 1fr;
}
.layout-triple .pane:nth-child(1) { grid-row: 1 / 3; }
.layout-pip {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}
.layout-pip .pane {
  grid-area: 1 / 1;
  z-index: 1;
}
.layout-pip .pane.pip-mini {
  position: absolute;
  width: min(32vw, 560px);
  height: min(32vh, 320px);
  right: 28px;
  bottom: 28px;
  z-index: 4;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.pane {
  position: relative;
  overflow: hidden;
  background: #000;
  border: 3px solid transparent;
  border-radius: 10px;
  min-height: 0;
}
.pane.focused { border-color: var(--focus); }
.pane video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}
.pane-chrome, .pane-status {
  position: absolute;
  left: 0;
  right: 0;
  pointer-events: none;
}
.pane-chrome {
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 14px;
  background: linear-gradient(180deg, rgba(0,0,0,0.7), transparent);
}
.pane-chrome button { pointer-events: auto; }
.bug {
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-weight: 700;
  text-shadow: 0 1px 4px #000;
}
.bug .num { color: var(--accent); font-size: 28px; }
.bug .name { font-size: 22px; }
.now { color: var(--muted); font-size: 16px; margin-top: 4px; }
.pane-status {
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 28px;
  text-align: center;
  padding: 24px;
}
.pane.has-video .pane-status { display: none; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 16, 0.72);
  display: grid;
  place-items: center;
  z-index: 20;
}
.overlay[hidden] { display: none; }
.sheet {
  width: min(920px, 92vw);
  height: min(820px, 88vh);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-rows: auto auto 1fr;
  padding: 18px;
  gap: 12px;
}
.sheet.narrow {
  width: min(560px, 92vw);
  height: auto;
  grid-template-rows: auto;
}
.lock-sheet {
  text-align: center;
}
.lock-sheet .help { margin: 0; }
#pinInput {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px;
  height: 1px;
}
.pin-dots {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin: 8px 0 4px;
}
.pin-dots span {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: transparent;
}
.pin-dots span.filled {
  background: var(--accent);
  border-color: var(--accent);
}
.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.pin-pad button {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 16px;
  min-height: 64px;
  font-size: 28px;
  cursor: pointer;
}
.sheet header { display: flex; justify-content: space-between; align-items: center; }
.sheet h2 { margin: 0; font-size: 28px; }
.field { display: grid; gap: 8px; color: var(--muted); font-size: 15px; }
.help, .status { color: var(--muted); line-height: 1.45; }
.status.error { color: var(--danger); }
.status.ok { color: var(--accent); }

.channel-list {
  overflow: auto;
  display: grid;
  gap: 6px;
  align-content: start;
}
.channel {
  display: grid;
  grid-template-columns: 90px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: var(--panel);
  cursor: pointer;
  font-size: 22px;
  text-align: left;
  color: inherit;
  width: 100%;
}
.channel .num { color: var(--accent); font-weight: 700; }
.channel .meta { color: var(--muted); font-size: 16px; }
.channel.favorite { border-color: #3ee0c755; }
.channel:hover, .channel.active { border-color: var(--accent); background: #1b2744; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 88px;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 12px 18px;
  border-radius: 12px;
  z-index: 30;
}
#toast[hidden] { display: none; }

@media (max-width: 900px) {
  #chrome { flex-wrap: wrap; }
  .bug .num { font-size: 20px; }
  .channel { font-size: 18px; }
  .layout-pip .pane.pip-mini {
    width: 42vw;
    height: 24vh;
    right: 12px;
    bottom: 12px;
  }
}
