:root {
  --bg: #0d1117;
  --bg2: #161b22;
  --panel: #1c2333;
  --panel-edge: #2d3a52;
  --fg: #e6edf3;
  --muted: #8b9bb4;
  --accent: #3d8bfd;
  --accent-dim: #1f4f8a;
  --link: #6cb6ff;
  --ok: #3fb950;
  --bad: #f85149;
  --warn: #d29922;
  --radius: 10px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
}
* { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--fg);
  background:
    radial-gradient(900px 420px at 0% 0%, #1a2a44 0%, transparent 55%),
    radial-gradient(700px 380px at 100% 10%, #1a2438 0%, transparent 50%),
    var(--bg);
  min-height: 100%;
  min-height: 100dvh;
  padding: 1rem 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.topbar h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 650;
  letter-spacing: 0.06em;
}
.topbar-actions { display: flex; align-items: center; gap: 0.5rem; }
#status { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.9rem; }
.msg { color: var(--warn); margin: 0.4rem 0 0; }

/* Free-form workspace — panels are positioned/resized by the user */
.app-workspace {
  flex: 1;
  position: relative;
  min-height: 520px;
  overflow: hidden;
  border: 1px dashed rgba(45, 58, 82, 0.65);
  border-radius: var(--radius);
  background: rgba(13, 17, 23, 0.35);
}

.panel {
  background: linear-gradient(180deg, #1e2738 0%, var(--panel) 100%);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  padding: 0.85rem 1rem 1.15rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.app-workspace .panel {
  position: absolute;
  min-width: 200px;
  min-height: 140px;
  overflow: hidden;
  z-index: 1;
}
.app-workspace .panel.layout-swap {
  transition: left 0.16s ease, top 0.16s ease, width 0.16s ease, height 0.16s ease;
}
.app-workspace .panel.dragging,
.app-workspace .panel.resizing {
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  border-color: var(--accent);
  user-select: none;
  z-index: 5;
  transition: none;
}
.app-workspace .panel.swap-target {
  border-color: #7eb6ff;
  box-shadow: 0 0 0 2px rgba(126, 182, 255, 0.35);
}
.app-workspace .panel.layout-preview {
  outline: 1px dashed rgba(126, 182, 255, 0.55);
  outline-offset: 1px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}
.panel-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
  flex: 1;
}
.panel-head h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #c5d0e0;
}
.panel-collapse {
  flex: 0 0 auto;
  width: 1.35rem;
  height: 1.35rem;
  padding: 0;
  border: 1px solid #3a4860;
  border-radius: 4px;
  background: #182033;
  color: #c5d0e0;
  cursor: pointer;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
}
.panel-collapse::before {
  content: "▼";
  display: block;
  transform: scale(0.85);
}
.panel.collapsed .panel-collapse::before { content: "▶"; }
.panel.collapsed > :not(.panel-head) { display: none !important; }
.panel.collapsed {
  min-height: 0;
  padding-bottom: 0.55rem;
}
.panel.collapsed .panel-head { margin-bottom: 0; }
.app-workspace .panel.collapsed {
  height: auto !important;
  min-height: 0;
}
.app-workspace .panel-head[data-drag-handle] {
  margin: -0.25rem -0.35rem 0.65rem;
  padding: 0.35rem 0.45rem;
  border-radius: 8px;
  cursor: grab;
  touch-action: none;
}
.app-workspace .panel.collapsed .panel-head[data-drag-handle] { margin-bottom: 0; }
.app-workspace .panel-head[data-drag-handle]:active { cursor: grabbing; }
.app-workspace .panel-head[data-drag-handle] h2 { pointer-events: none; }
.app-workspace .panel-head .btn-ghost,
.app-workspace .panel-head .tab,
.app-workspace .panel-head .ws-dot,
.app-workspace .panel-head .tabs,
.app-workspace .panel-head .panel-collapse {
  cursor: pointer;
  pointer-events: auto;
}
.panel-resizer {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
  touch-action: none;
  background:
    linear-gradient(135deg, transparent 50%, #6b7a94 50%) no-repeat bottom right / 10px 10px,
    linear-gradient(135deg, transparent 60%, #4a5670 60%) no-repeat bottom right / 14px 14px;
  opacity: 0.85;
  border-radius: 2px;
}
.panel-resizer:hover { opacity: 1; }

/* Phone / narrow: stack catalog panels (no free-drag absolute layout) */
@media (max-width: 800px) {
  html, body {
    height: auto;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  body {
    display: block;
    padding: 0.65rem 0.75rem calc(1.25rem + env(safe-area-inset-bottom, 0px));
    gap: 0;
  }
  .topbar {
    margin-bottom: 0.65rem;
  }
  .topbar h1 { font-size: 1.1rem; }
  .app-workspace {
    position: static;
    display: flex;
    flex-direction: column;
    flex: none;
    gap: 0.65rem;
    min-height: 0;
    height: auto;
    overflow: visible;
    border: none;
    background: transparent;
  }
  .app-workspace .panel {
    position: static !important;
    left: auto !important;
    top: auto !important;
    width: 100% !important;
    height: auto !important;
    min-width: 0;
    min-height: 0;
    max-height: none;
    overflow: visible;
  }
  .app-workspace .panel .panel-resizer {
    display: none;
  }
  .app-workspace .panel.collapsed .list,
  .app-workspace .panel.collapsed .chat-log {
    max-height: 0;
  }
  .app-workspace .panel .list,
  .app-workspace .chat-log {
    max-height: 36vh;
    flex: none;
  }
  .app-workspace .chat-panel {
    min-height: 0;
    margin-bottom: 0.5rem;
    padding-bottom: 1rem;
  }
  .app-workspace .chat-log {
    min-height: 8rem;
  }
  #btnResetLayout { display: none; }
}

.list-filter-wrap {
  position: relative;
  width: 100%;
  margin: 0 0 0.55rem;
}
.list-filter {
  width: 100%;
  margin: 0 0 0.55rem;
  padding: 0.4rem 0.55rem;
  border: 1px solid #33415c;
  border-radius: 8px;
  background: #0f141f;
  color: var(--fg);
  font-size: 0.9rem;
  box-sizing: border-box;
}
.list-filter-wrap .list-filter {
  margin: 0;
  padding-right: 2rem;
}
.list-filter::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}
.list-filter:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(61, 139, 253, 0.25);
}
.list-filter.filter-invalid {
  border-color: var(--bad);
  box-shadow: 0 0 0 1px rgba(248, 81, 73, 0.35);
}
.list-filter-clear {
  position: absolute;
  right: 0.2rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.6rem;
  height: 1.6rem;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #9aa4b5;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
}
.list-filter-clear:hover {
  color: var(--fg);
  background: rgba(255, 255, 255, 0.06);
}
.list-filter-clear[hidden] { display: none !important; }
.list {
  list-style: none;
  padding: 0;
  margin: 0;
  overflow: auto;
  flex: 1;
  min-height: 0;
}
.list li[hidden] { display: none !important; }
.list li {
  padding: 0.45rem 0.35rem;
  border-bottom: 1px solid #273247;
  cursor: pointer;
  font-size: 0.92rem;
  word-break: break-word;
}
.list li:last-child { border-bottom: none; }
.list li:hover { background: rgba(61, 139, 253, 0.08); border-radius: 6px; }
.list a {
  color: var(--link);
  text-decoration: none;
  font-weight: 500;
}
.list a:hover { text-decoration: underline; }

.audio-row { cursor: default; }
.audio-pick {
  display: flex; align-items: flex-start; gap: 0.45rem;
  cursor: pointer; width: 100%;
}
.audio-pick input { margin-top: 0.2rem; flex-shrink: 0; }
.audio-pick-label { flex: 1; min-width: 0; }
#audioPanel {
  display: flex;
  flex-direction: column;
}
#audioPanel > .list-fold { min-height: 0; }
#imagesPanel {
  display: flex;
  flex-direction: column;
}
#imagesPanel > .list-fold { min-height: 0; flex: 1; }
.image-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  cursor: default;
}
.image-thumb-link {
  flex-shrink: 0;
  display: block;
  width: 56px;
  height: 56px;
  border-radius: 6px;
  overflow: hidden;
  background: #1a2233;
  border: 1px solid #273247;
}
.image-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.image-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.image-meta .muted { font-size: 0.8rem; }
.playlist-builder {
  flex-shrink: 0; margin-top: 0.35rem; padding-top: 0.5rem;
  border-top: 1px solid #273247; font-size: 0.88rem;
  overflow: auto; max-height: 55%;
}
.playlist-builder > .list-fold { margin-bottom: 0; }
.playlist-builder-row {
  display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center;
  margin-bottom: 0.35rem;
}
.playlist-builder-row .list-filter { flex: 1; min-width: 8rem; margin: 0; }
.list-fold {
  margin-bottom: 0.4rem;
  border: 1px solid #273247;
  border-radius: 8px;
  background: rgba(15, 20, 31, 0.45);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}
.list-fold-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.45rem;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}
.list-fold-head strong {
  font-size: 0.82rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #c5d0e0;
}
.list-fold-head .muted { font-size: 0.8rem; }
.list-fold-body {
  padding: 0 0.45rem 0.4rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}
.list-fold-body .list { flex: 1; min-height: 0; }
.list-fold.collapsed .list-fold-body { display: none !important; }
.list-fold.collapsed .panel-collapse::before { content: "▶"; }
.list-fold.collapsed {
  margin-bottom: 0.35rem;
  flex: 0 0 auto;
}
#playlistDraftBlock.list-fold { flex: 0 0 auto; }
#playlistDraftBlock .list-fold-body { gap: 0.4rem; padding-top: 0.45rem; }
#playlistDraftBlock .playlist-builder-row { margin-bottom: 0; }
.playlist-select {
  flex: 1; min-width: 8rem; padding: 0.35rem 0.45rem;
  background: #1e1e1e; border: 1px solid #555; border-radius: 4px; color: #e0e0e0;
}
.playlist-draft {
  max-height: 7.5rem; margin: 0 0 0.35rem; padding: 0.25rem 0;
  list-style: decimal; list-style-position: inside;
}
.playlist-draft-item {
  display: flex; align-items: center; justify-content: space-between; gap: 0.35rem;
  cursor: default; font-size: 0.85rem;
}
.playlist-rm { padding: 0.1rem 0.4rem !important; min-width: auto; }
.playlist-auto {
  display: inline-flex; align-items: center; gap: 0.35rem;
  color: var(--muted); font-size: 0.85rem; cursor: pointer; user-select: none;
}
.playlist-hint { margin: 0.25rem 0 0; font-size: 0.8rem; }
.np-body {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.15rem 0.25rem 0.35rem;
  min-height: 0;
}
.np-body audio { display: none; }
.np-queue-pos { font-size: 0.8rem; }
.np-seek-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
.np-seek-row input[type="range"] { flex: 1; min-width: 0; }
.np-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}
.np-speed-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted, #a0a8b8);
}
.np-speed-label select {
  background: var(--panel-inset, #2a2a2a);
  color: inherit;
  border: 1px solid var(--panel-edge, #555);
  border-radius: 4px;
  padding: 0.2rem 0.35rem;
}
.np-vol-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--muted, #a0a8b8);
  min-width: 0;
}
.np-vol-label input[type="range"] {
  width: 7rem;
  max-width: 40vw;
  min-width: 4rem;
}
.np-shuffle {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.35rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--panel-edge, #3a4458);
}
.np-shuffle-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}
.np-shuffle-add-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.np-shuffle-add-row .playlist-select { flex: 1; min-width: 0; }
.np-shuffle-add {
  min-width: 2rem;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1;
  padding: 0.25rem 0.55rem !important;
}
.np-shuffle-list {
  max-height: 8rem;
  overflow: auto;
  margin: 0;
  padding: 0.15rem 0 0.15rem 1.25rem;
}
.np-shuffle-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.15rem 0;
}
.np-shuffle-item.active { color: #9ecbff; font-weight: 600; }
.np-shuffle-item .np-shuffle-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.np-shuffle-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}
.np-shuffle-hint { margin: 0; font-size: 0.78rem; }
.viewer-vol-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.65rem 0 0;
  padding: 0.45rem 0.55rem;
  border: 1px solid #333;
  border-radius: 6px;
  background: rgba(255,255,255,0.04);
}
.viewer-vol-bar .np-vol-label { flex: 1; }
.viewer-vol-bar input[type="range"] { flex: 1; width: auto; max-width: none; }
.audio-queue-bar {
  margin: 0.75rem 0 0; padding: 0.65rem 0.75rem;
  border: 1px solid #333; border-radius: 6px; background: rgba(255,255,255,0.04);
}
.audio-queue-bar.hidden { display: none; }
.audio-queue-meta { margin-bottom: 0.45rem; }
.audio-queue-actions {
  display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center;
}

.app-workspace .chat-panel { min-height: 140px; }
.panel-head-actions { display: flex; align-items: center; gap: 0.45rem; }
.chat-log {
  flex: 1;
  min-height: 140px;
  overflow: auto;
  overflow-x: hidden;
  background: var(--bg2);
  border: 1px solid #243049;
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  font-size: 0.92rem;
  line-height: 1.45;
  margin-bottom: 0.65rem;
}
.chat-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.35rem 0.5rem;
  align-items: start;
  margin: 0 0 0.45rem;
  max-width: 100%;
}
.chat-line-body {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: pre-wrap;
}
.chat-line .who {
  color: var(--link);
  font-weight: 600;
  margin-right: 0.35rem;
}
.chat-line.system { color: var(--muted); font-style: italic; display: block; }
.chat-line .chat-del {
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  line-height: 1;
  border: none;
  background: transparent;
  color: #e57373;
  cursor: pointer;
  font-size: 1rem;
  opacity: 0.55;
}
.chat-line .chat-del:hover { opacity: 1; background: transparent; }
.chat-emoji {
  display: inline-block;
  width: 22px;
  height: 22px;
  object-fit: contain;
  vertical-align: -4px;
  margin: 0 1px;
}
.chat-emoji.jumbo {
  width: 48px;
  height: 48px;
  vertical-align: middle;
  display: block;
  margin: 0.2rem 0;
}
.chat-media {
  display: block;
  margin: 0.35rem 0 0;
  max-width: 100%;
  max-height: min(42vh, 100%);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 6px;
  background: #0f141f;
}
.chat-media-preview { font-size: 0.8rem; max-width: 8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-form { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.chat-form input[type="text"], .chat-form #chatInput { flex: 1; min-width: 8rem; }

input, button {
  font: inherit;
  background: #0f141f;
  color: var(--fg);
  border: 1px solid #33405a;
  border-radius: 7px;
  padding: 0.5rem 0.75rem;
}
input:focus, button:focus {
  outline: 2px solid var(--accent-dim);
  outline-offset: 1px;
}
button {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
}
button:hover { filter: brightness(1.08); }
.btn-ghost {
  background: transparent;
  border: 1px solid #3a4a66;
  color: var(--fg);
  font-size: 0.8rem;
  padding: 0.3rem 0.55rem;
  font-weight: 500;
}

.ws-dot {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  background: var(--muted);
  display: inline-block;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.25);
}
.ws-dot.on { background: var(--ok); box-shadow: 0 0 8px rgba(63, 185, 80, 0.55); }
.ws-dot.off { background: var(--bad); }

.join-panel { max-width: 420px; }
.join-panel label { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.75rem; }
.join-panel input { width: 100%; }
.join-tabs { display: flex; gap: 0.35rem; margin-bottom: 0.85rem; }
.join-tabs .tab { flex: 1; }
.join-pane button[type="submit"] { width: 100%; }
.admin-login-toggle { margin-top: 0.75rem; width: 100%; }
.admin-login-card { max-width: 22rem; width: 100%; }
.admin-login-form label { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.75rem; }
.admin-login-form input { width: 100%; }
.admin-login-form .modal-actions { margin-top: 0.25rem; }
.admin-2fa-card { max-width: 22rem; }
.admin-2fa-qr {
  display: block;
  width: 256px;
  height: 256px;
  max-width: 100%;
  margin: 0.75rem auto;
  background: #fff;
  border-radius: 6px;
}
.admin-2fa-code-label { display: flex; flex-direction: column; gap: 0.35rem; margin-top: 0.5rem; }
.admin-2fa-code-label input { width: 100%; }

a.btn-ghost {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: var(--fg);
}
.admin-body {
  max-width: 960px;
  margin: 0 auto;
  width: 100%;
}
.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.admin-tabs .tab {
  border: 1px solid var(--panel-edge);
  background: var(--bg2);
  color: var(--fg);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  font-size: 0.85rem;
}
.admin-tabs .tab.active {
  background: var(--accent-dim);
  border-color: var(--accent);
}
.admin-panel { width: 100%; }
.admin-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  margin-top: 0.65rem;
}
.admin-row input {
  flex: 1 1 140px;
  min-width: 120px;
  padding: 0.45rem 0.55rem;
  border: 1px solid #33415c;
  border-radius: 8px;
  background: #0f141f;
  color: var(--fg);
}
.admin-pre {
  margin: 0.5rem 0 0;
  padding: 0.65rem 0.75rem;
  background: #0f141f;
  border: 1px solid #243049;
  border-radius: 8px;
  overflow: auto;
  max-height: 280px;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
}
.admin-table-wrap {
  width: 100%;
  overflow: auto;
  margin-top: 0.5rem;
  border: 1px solid #243049;
  border-radius: 8px;
  background: #0f141f;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}
.admin-table th,
.admin-table td {
  padding: 0.45rem 0.55rem;
  text-align: left;
  border-bottom: 1px solid #243049;
  vertical-align: middle;
}
.admin-table th {
  background: #1a2333;
  color: #c5d0e0;
  font-weight: 650;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
.admin-table tbody tr:nth-child(even) { background: rgba(255, 255, 255, 0.02); }
.admin-table tbody tr:hover { background: rgba(61, 139, 253, 0.08); }
.admin-table .empty-row td { text-align: center; padding: 0.85rem; }
.admin-table .mono,
.admin-cwd.mono,
span.mono { font-family: var(--mono); font-size: 0.8em; }
.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  white-space: normal;
  min-width: 10rem;
}
.admin-act {
  border: 0;
  border-radius: 6px;
  padding: 0.2rem 0.5rem;
  font-size: 0.78rem;
  cursor: pointer;
  background: #3a4558;
  color: var(--fg);
}
.admin-act-ok { background: #2e7d32; color: #fff; }
.admin-act-bad { background: #8b0000; color: #fff; }
.admin-kv {
  margin-top: 0.75rem;
  border: 1px solid #243049;
  border-radius: 8px;
  overflow: hidden;
  background: #0f141f;
}
.admin-kv-row {
  display: grid;
  grid-template-columns: 9rem 1fr;
  gap: 0.5rem;
  padding: 0.4rem 0.65rem;
  border-bottom: 1px solid #1c2638;
  font-size: 0.88rem;
}
.admin-kv-row:last-child { border-bottom: 0; }
.admin-kv-k { color: var(--muted); }
.admin-kv-v { word-break: break-word; }
.admin-pathbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.35rem;
}
.admin-flash-err { color: var(--bad) !important; }
.admin-alert-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  padding: 0.75rem;
  pointer-events: none;
  display: flex;
  justify-content: center;
}
.admin-alert-banner.hidden { display: none; }
.admin-alert-card {
  pointer-events: auto;
  width: min(520px, 100%);
  background: linear-gradient(180deg, #2a3348 0%, #1a2233 100%);
  border: 1px solid var(--accent);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  padding: 0.85rem 1rem 1rem;
}
.admin-alert-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.admin-alert-msg { margin: 0.45rem 0 0; font-size: 0.95rem; }
.admin-alert-note { margin: 0.25rem 0 0; font-size: 0.85rem; }
.admin-alert-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.75rem;
}
.admin-alert-prefs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  margin-top: 0.55rem;
}
.admin-alert-mute {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.65rem;
  font-size: 0.8rem;
  color: var(--muted);
  cursor: pointer;
}
.admin-capture-facing {
  border: 1px solid #33415c;
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  margin: 0.5rem 0 0;
}
.admin-capture-facing legend {
  padding: 0 0.3rem;
  color: #c5d0e0;
  font-size: 0.85rem;
}
.admin-capture-facing label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-right: 1rem;
  cursor: pointer;
  font-size: 0.9rem;
}
.admin-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
@media (max-width: 720px) {
  .admin-grid-2 { grid-template-columns: 1fr; }
}
.admin-subh {
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 600;
}
.admin-cwd {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--link);
}
.admin-capture-preview {
  width: 100%;
  max-height: 360px;
  background: #000;
  border-radius: 8px;
  border: 1px solid #243049;
  margin-top: 0.5rem;
  object-fit: cover;
}
.admin-ingest-body {
  max-width: 720px;
  margin: 0 auto;
}
.admin-ingest-panel { width: 100%; }
.admin-ingest-label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0.75rem 0;
  font-size: 0.9rem;
  color: #c5d0e0;
}
.admin-ingest-label textarea {
  width: 100%;
  min-height: 10rem;
  resize: vertical;
  font-family: var(--mono);
  font-size: 0.88rem;
  line-height: 1.4;
  padding: 0.65rem 0.75rem;
  border: 1px solid #33415c;
  border-radius: 8px;
  background: #0f141f;
  color: var(--fg);
}
.admin-ingest-fmt {
  border: 1px solid #33415c;
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  margin: 0 0 1rem;
}
.admin-ingest-fmt legend {
  padding: 0 0.35rem;
  color: #c5d0e0;
  font-size: 0.85rem;
}
.admin-ingest-fmt label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.35rem 0;
  cursor: pointer;
}
.admin-ingest-actions {
  justify-content: flex-end;
  margin-top: 1rem;
}
.admin-ingest-log {
  max-height: 220px;
  margin-top: 0.85rem;
  background: var(--bg2);
  border: 1px solid #243049;
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
}
.admin-ingest-log li.ingest-fail { color: var(--bad); }
.admin-finished-btn {
  background: var(--ok) !important;
  border-color: transparent !important;
  color: #04140a !important;
  font-weight: 650;
}
.xfer-progress-bar.done,
#ingestPct.done { color: var(--ok); }
.xfer-progress-bar.done {
  background: var(--ok);
}

.muted { color: var(--muted); }
code { font-family: var(--mono); font-size: 0.88em; }

.viewer video {
  width: 100%;
  max-height: 70vh;
  background: #000;
  border-radius: var(--radius);
}
body.viewer { display: block; }
.viewer-cast-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}
.yt-quality-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
}
.yt-quality-wrap.hidden { display: none; }
.yt-quality-wrap select {
  background: #1a2233;
  color: #e8eef8;
  border: 1px solid #334155;
  border-radius: 4px;
  padding: 0.25rem 0.4rem;
  min-width: 5.5rem;
}
.viewer-cast-bar .casting,
.party-actions .casting {
  background: rgba(46, 125, 50, 0.35);
  border-color: #2e7d32;
}
.cast-unavailable { opacity: 0.45; }
.cast-picker-card { max-width: 28rem; width: 100%; }
.cast-caps { display: flex; flex-direction: column; gap: 0.5rem; margin: 0.75rem 0; }
.cast-cap-row {
  display: flex; gap: 0.6rem; align-items: flex-start;
  padding: 0.5rem 0.65rem; border-radius: 6px; background: rgba(255,255,255,0.04);
}
.cast-cap-row .cast-cap-dot {
  width: 0.65rem; height: 0.65rem; border-radius: 50%; margin-top: 0.35rem; flex-shrink: 0;
  background: #888;
}
.cast-cap-row.ok .cast-cap-dot { background: #2e7d32; }
.cast-cap-row.no .cast-cap-dot { background: #c62828; }
.cast-devices { display: flex; flex-direction: column; gap: 0.4rem; margin: 0.5rem 0 0.75rem; }
.cast-device-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.15rem;
  width: 100%; text-align: left; padding: 0.65rem 0.75rem;
  background: #2a2a2a; border: 1px solid #555; border-radius: 6px; color: #e0e0e0; cursor: pointer;
}
.cast-device-btn:hover { border-color: #3a7bd5; }
.cast-manual {
  display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: flex-end;
  margin-bottom: 0.75rem; padding-top: 0.5rem; border-top: 1px solid #333;
}
.cast-mirror-guide {
  margin: 0.5rem 0 0.75rem; padding: 0.75rem; border-radius: 6px;
  background: rgba(255,255,255,0.06); border: 1px solid #444; color: #e0e0e0; font-size: 0.9rem;
}
.cast-mirror-guide ol { margin: 0.5rem 0 0; padding-left: 1.25rem; }
.cast-mirror-guide li { margin: 0.35rem 0; }
.cast-mirror-guide #castMirrorDone { margin: 0.5rem 0 0; width: 100%; }
.cast-manual label { flex: 1; min-width: 10rem; font-size: 0.85rem; color: #a0a8b8; }
.cast-manual input {
  display: block; width: 100%; margin-top: 0.25rem; padding: 0.4rem 0.5rem;
  background: #1e1e1e; border: 1px solid #555; border-radius: 4px; color: #e0e0e0;
}

.tabs { display: flex; gap: 0.25rem; }
.tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0.3rem 0.6rem;
}
.tab.active {
  color: var(--fg);
  border-color: #3a4a66;
  background: rgba(61, 139, 253, 0.12);
}
.tab-pane { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.tab-pane.hidden { display: none; }
.upload-hint { margin: 0 0 0.75rem; font-size: 0.88rem; }
.upload-form { display: flex; flex-direction: column; gap: 0.65rem; }
.upload-form label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.88rem; }
.file-pick span {
  display: inline-block;
  background: var(--accent-dim);
  color: #fff;
  padding: 0.4rem 0.7rem;
  border-radius: 7px;
  cursor: pointer;
  width: fit-content;
}
.file-pick input[type="file"] { display: none; }

.xfer-progress {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.25rem;
}
.xfer-progress.hidden { display: none; }
.xfer-progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.82rem;
  color: var(--muted);
}
#xferProgressPct { color: var(--link); font-weight: 650; font-variant-numeric: tabular-nums; }
.xfer-progress-track {
  height: 0.55rem;
  border-radius: 999px;
  background: #2a3548;
  overflow: hidden;
}
.xfer-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  transition: width 0.12s linear;
}

.modal {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.55); z-index: 40; padding: 1rem;
}
.hidden { display: none !important; }
.modal.hidden { display: none !important; }
.modal-card {
  background: var(--panel); border: 1px solid var(--panel-edge); border-radius: var(--radius);
  padding: 1.1rem 1.25rem; max-width: 420px; width: 100%;
  box-shadow: 0 16px 40px rgba(0,0,0,0.45);
}
.modal-card.modal-card-wide { max-width: 720px; }
.modal-card h3 { margin: 0 0 0.5rem; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.35rem; }
.modal-head h3 { margin: 0; }
.modal-x { font-size: 1.25rem; line-height: 1; min-width: 2rem; padding: 0.2rem 0.45rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1rem; }
.admin-table input.peer-check { width: auto; margin: 0; }

/* Watch party */
body.party-page {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 100dvh;
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
}
.party-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.party-topbar h1 { margin: 0; font-size: 1.2rem; }
.party-actions { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.party-vol,
.party-seek {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--muted);
  font-size: 0.85rem;
  width: 100%;
}
.party-vol input[type="range"],
.party-seek input[type="range"] {
  flex: 1 1 auto;
  min-width: 8rem;
  accent-color: #5b8def;
}
.party-seek label,
.party-vol label {
  flex: 0 0 auto;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.party-invite-list {
  list-style: none;
  margin: 0.45rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.party-invite-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid #243049;
  border-radius: 8px;
  background: #0f141f;
  font-size: 0.88rem;
}
.admin-row select.playlist-select {
  flex: 1 1 220px;
  min-width: 160px;
  padding: 0.45rem 0.55rem;
  border: 1px solid #33415c;
  border-radius: 8px;
  background: #0f141f;
  color: var(--fg);
}
#btnPartyPeerAdd {
  flex: 0 0 auto;
  min-width: 2.4rem;
  font-weight: 700;
  font-size: 1.1rem;
}
.party-layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 320px);
  gap: 0.75rem;
  min-height: 0;
}
.party-stage {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  border: 1px solid var(--panel-edge);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.party-stage video {
  width: 100%;
  flex: 1;
  min-height: 240px;
  max-height: calc(100dvh - 8rem);
  background: #000;
  object-fit: contain;
  /* Avoid odd compositor green flashes on some GPU/HEVC paths */
  transform: translateZ(0);
}
.party-unlock {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: rgba(6, 10, 18, 0.72);
  padding: 1rem;
  text-align: center;
}
.party-unlock.hidden { display: none; }
.party-unlock-btn {
  font: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  padding: 0.85rem 1.4rem;
  border-radius: 10px;
  border: 1px solid #3d5a80;
  background: #1b2a44;
  color: #e8eef8;
  cursor: pointer;
}
.party-unlock-btn:hover { background: #243756; }
.party-chat {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: calc(100dvh - 6rem);
}
.party-chat .list {
  flex: 1;
  min-height: 120px;
  background: var(--bg2);
  border: 1px solid #243049;
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  margin-bottom: 0.5rem;
}
.party-chat .chat-form { margin-top: auto; }

@media (max-width: 800px) {
  .party-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(180px, 40vh);
  }
  .party-stage video {
    max-height: 48dvh;
    min-height: 180px;
  }
  .party-chat {
    max-height: none;
  }
}

.yt-oauth-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0.65rem 0.45rem;
  font-size: 0.85rem;
}
.yt-oauth-bar .btn-ghost { padding: 0.2rem 0.55rem; }
.yt-search-form {
  display: flex;
  gap: 0.4rem;
  margin: 0 0.65rem 0.4rem;
}
.yt-search-form input {
  flex: 1;
  min-width: 0;
  background: var(--bg2, #151b28);
  border: 1px solid #2a3548;
  color: inherit;
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
}
.yt-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0 0.65rem 0.45rem;
}
.yt-filters select {
  flex: 1 1 5rem;
  min-width: 0;
  background: var(--bg2, #151b28);
  border: 1px solid #2a3548;
  color: inherit;
  border-radius: 6px;
  padding: 0.25rem 0.35rem;
  font-size: 0.8rem;
}
.yt-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0.65rem 0.4rem;
  font-size: 0.85rem;
}
.yt-tabs { display: inline-flex; gap: 0.25rem; }
.yt-status { margin: 0 0.65rem 0.35rem; min-height: 1.1em; font-size: 0.85rem; }
.yt-table {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0 0.5rem 0.5rem;
  min-height: 0;
  border: 1px solid #243049;
  border-radius: 8px;
  margin: 0 0.65rem 0.35rem;
  background: rgba(13, 17, 23, 0.35);
}
.yt-feed {
  flex: 1;
  overflow: auto;
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.15rem 1rem;
  align-content: start;
  padding: 0.75rem 0.8rem 0.85rem;
  min-height: 0;
  margin: 0 0.65rem 0.35rem;
  border: 1px solid #243049;
  border-radius: 8px;
  background: rgba(13, 17, 23, 0.35);
}
.yt-vcard {
  cursor: pointer;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.yt-vcard:hover .yt-vcard-thumb { filter: brightness(1.06); }
.yt-vcard:hover .yt-vcard-title { color: #fff; }
.yt-vcard-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  background: #0d121c;
}
.yt-vcard-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.yt-vcard-meta {
  display: grid;
  grid-template-columns: 2.4rem minmax(0, 1fr);
  gap: 0.55rem;
  align-items: start;
}
.yt-vcard-meta-solo { grid-template-columns: minmax(0, 1fr); }
.yt-vcard-avatar {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  object-fit: cover;
  background: #243049;
  cursor: pointer;
}
.yt-vcard-text { min-width: 0; }
.yt-vcard-title {
  font-size: 0.98rem;
  font-weight: 650;
  line-height: 1.35;
  color: #f1f5fb;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.yt-vcard-sub {
  margin-top: 0.28rem;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.yt-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.4rem;
}
.yt-action-btn {
  font-size: 0.72rem;
  line-height: 1.2;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  border: 1px solid #334155;
  background: rgba(15, 23, 42, 0.65);
  color: #cbd5e1;
  cursor: pointer;
}
.yt-action-btn:hover {
  border-color: #3d8bfd;
  color: #fff;
  background: rgba(61, 139, 253, 0.15);
}
.yt-row {
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1fr) 4.25rem;
  align-items: center;
  gap: 0.55rem;
  padding: 0.4rem 0.45rem;
  cursor: pointer;
  border-bottom: 1px solid #243049;
  min-width: 0;
}
.yt-row:last-child { border-bottom: none; }
.yt-row:not(.yt-row-head):hover { background: rgba(61, 139, 253, 0.08); }
.yt-row-head {
  cursor: default;
  position: sticky;
  top: 0;
  z-index: 1;
  background: #1a2233;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding-top: 0.35rem;
  padding-bottom: 0.35rem;
}
.yt-thumb-spacer { width: 4.5rem; height: 1px; }
.yt-thumb {
  position: relative;
  width: 4.5rem;
  height: 2.55rem;
  flex-shrink: 0;
  border-radius: 4px;
  overflow: hidden;
  background: #0d121c;
}
.yt-thumb-avatar {
  width: 2.4rem;
  height: 2.4rem;
  margin-left: 1.05rem;
  border-radius: 50%;
}
.yt-channel-link {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  color: var(--link, #6cb6ff);
  font: inherit;
  cursor: pointer;
  text-align: left;
}
.yt-channel-link:hover { text-decoration: underline; }
.yt-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.yt-dur {
  position: absolute;
  right: 0.3rem;
  bottom: 0.25rem;
  background: rgba(0, 0, 0, 0.82);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.08rem 0.28rem;
  border-radius: 3px;
  line-height: 1.2;
}
.yt-main {
  min-width: 0;
  overflow: hidden;
}
.yt-title {
  font-size: 0.86rem;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.yt-sub {
  font-size: 0.72rem;
  margin-top: 0.12rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.yt-kind {
  font-size: 0.72rem;
  text-align: right;
  white-space: nowrap;
}
.yt-more-row { padding: 0 0.65rem 0.55rem; }
/* Fixed ~3 cards per row (larger thumbs/titles). Narrow panels fall back to 2 or 1. */
#ytstreamPanel .yt-feed {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
@media (max-width: 1100px) {
  #ytstreamPanel .yt-feed,
  .yt-feed { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  #ytstreamPanel .yt-feed,
  .yt-feed { grid-template-columns: 1fr; }
}
