/* CHUD
   Warm dark bunker aesthetic (not generic purple-blue AI chrome) */

:root {
  --bg: #12100e;
  --bg-raised: #1a1714;
  --bg-card: #201c18;
  --bg-input: #161310;
  --bg-hover: #2a241f;
  --line: #3a322b;
  --line-soft: #2c261f;
  --text: #f0e6d8;
  --muted: #9a8b78;
  --faint: #6a5e50;
  --accent: #c45c26;
  --accent-2: #d4a574;
  --accent-hover: #e06a2e;
  --accent-glow: rgba(196, 92, 38, 0.28);
  --danger: #d4524a;
  --ok: #6aab6e;
  --rec: #c43c48;
  --radius: 14px;
  --radius-sm: 9px;
  --font: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --inset: inset 0 1px 0 rgba(255, 240, 220, 0.06);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
}
body {
  min-height: 100dvh;
  background-image:
    radial-gradient(ellipse 80% 50% at 10% -10%, rgba(196, 92, 38, 0.12), transparent 50%),
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(80, 60, 40, 0.2), transparent 45%),
    linear-gradient(180deg, #161310 0%, var(--bg) 40%);
}
button, input, select { font: inherit; color: inherit; }
.hidden { display: none !important; }

.noise {
  pointer-events: none;
  position: fixed; inset: 0; z-index: 0; opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

#app { position: relative; z-index: 1; display: flex; flex-direction: column; min-height: 100dvh; }

/* Auth */
.auth-body {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 30% 0%, rgba(196, 92, 38, 0.18), transparent 55%),
    var(--bg);
}
.auth-card {
  width: min(400px, 100%);
  background: linear-gradient(165deg, #241f1a 0%, var(--bg-card) 100%);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 32px 28px;
  text-align: center;
  box-shadow: var(--shadow), var(--inset);
}
.auth-card h1 {
  margin: 10px 0 4px;
  font-size: 1.75rem;
  letter-spacing: 0.12em;
  font-weight: 700;
}
.auth-tabs { display: flex; gap: 8px; margin: 20px 0 14px; }
.auth-tabs button {
  flex: 1; border: 1px solid var(--line); background: var(--bg-input);
  border-radius: var(--radius-sm); padding: 10px; cursor: pointer;
  color: var(--muted); font-weight: 600;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.auth-tabs button.on {
  background: var(--accent); border-color: #a34a1c; color: #fff;
  box-shadow: 0 4px 16px var(--accent-glow);
}
.auth-form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.auth-form label { font-size: 0.82rem; color: var(--muted); display: flex; flex-direction: column; gap: 6px; font-weight: 500; }
.auth-msg { margin-top: 12px; font-size: 0.9rem; }
.auth-msg.err { color: var(--danger); }
.tiny { font-size: 0.75rem; margin-top: 16px; color: var(--faint); }

.brand-logo {
  width: 42px; height: 42px; border-radius: 12px; object-fit: cover;
  border: 2px solid var(--line); flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(0,0,0,0.4), 0 0 0 1px rgba(212,165,116,0.15);
}
.brand-logo.xl {
  width: 80px; height: 80px; border-radius: 20px; margin: 0 auto 6px;
  display: block; border-width: 3px;
}

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(18, 16, 14, 0.85);
  backdrop-filter: blur(14px) saturate(1.2);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-text h1 {
  margin: 0; font-size: 1.15rem; letter-spacing: 0.18em; font-weight: 700;
  color: var(--text);
}
.brand-sub {
  margin: 2px 0 0; color: var(--muted); font-size: 0.68rem;
  letter-spacing: 0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: min(52vw, 420px);
}
.brand-sub .acro { color: var(--accent-2); font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.pill {
  font-size: 0.7rem; font-weight: 600; padding: 5px 11px; border-radius: 999px;
  background: var(--bg-input); border: 1px solid var(--line); color: var(--muted);
  font-family: var(--mono); letter-spacing: 0.04em;
}
.pill.user { border-color: #4a3c30; color: var(--accent-2); }
.pill.playing { color: var(--ok); border-color: #3d6a40; background: rgba(106,171,110,0.1); }
.pill.rec { color: #fff; background: var(--rec); border-color: var(--rec); }

/* Tabs */
.main-tabs {
  display: flex; gap: 3px; overflow-x: auto; padding: 10px 12px 12px;
  border-bottom: 1px solid var(--line-soft);
  scrollbar-width: thin;
  background: linear-gradient(180deg, rgba(26,23,20,0.6), transparent);
}
.main-tabs button {
  flex: 0 0 auto; border: 1px solid transparent; background: transparent;
  color: var(--muted); padding: 8px 14px; border-radius: 999px;
  cursor: pointer; font-weight: 600; font-size: 0.8rem; white-space: nowrap;
  transition: all 0.15s ease;
}
.main-tabs button:hover { color: var(--text); background: var(--bg-hover); }
.main-tabs button.active {
  background: linear-gradient(180deg, #d46a30, var(--accent));
  color: #fff; border-color: #a34a1c;
  box-shadow: 0 4px 18px var(--accent-glow), var(--inset);
}

.workspace {
  flex: 1; display: grid; grid-template-columns: minmax(300px, 400px) 1fr;
  min-height: 0;
}
.player-col {
  border-right: 1px solid var(--line-soft);
  padding: 14px;
  background: linear-gradient(180deg, rgba(32,28,24,0.5), transparent 40%);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
/* PC: stream chat under a wider video when open */
@media (min-width: 901px) {
  body.has-site-chat .workspace {
    display: flex;
    flex-direction: column;
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
  body.has-site-chat .player-col {
    width: 100%;
    max-width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--line-soft);
    flex: 0 0 auto;
  }
  body.has-site-chat .player-card {
    max-width: min(1200px, 100%);
    margin: 0 auto;
    width: 100%;
  }
  body.has-site-chat #player-wrap {
    width: 100%;
    aspect-ratio: 16 / 9;
    min-height: min(52vh, 560px);
    max-height: min(70vh, 820px);
  }
  body.has-site-chat .chat-panel:not(.hidden) {
    width: 100%;
    max-width: min(1200px, 100%);
    margin: 10px auto 0;
    height: min(28vh, 280px);
    max-height: min(28vh, 280px);
  }
  body.has-site-chat .content-col {
    flex: 1 1 auto;
    min-height: 200px;
  }
}
.player-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 2px);
  overflow: hidden;
  box-shadow: var(--shadow), var(--inset);
}
.player-bevel { padding: 6px; background: linear-gradient(145deg, #2c261f, #161310); }
#player-wrap {
  position: relative; width: 100%; aspect-ratio: 16/9; background: #000;
  border-radius: 8px; overflow: hidden;
}
#player { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
#embed-frame {
  position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #000;
}
#player-wrap.embed-mode #player { visibility: hidden; position: absolute; }
#player-empty {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; color: var(--muted); gap: 6px;
  pointer-events: none;
  background: radial-gradient(circle at 50% 40%, #1e1914, #0a0908 70%);
}
#player-wrap.playing #player-empty { display: none; }
.empty-icon {
  font-size: 1.6rem; opacity: 0.45; width: 48px; height: 48px;
  border: 2px solid var(--line); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.empty-hint { font-size: 0.75rem; color: var(--faint); }
.player-info { padding: 14px 14px 6px; }
.now-title { font-weight: 700; font-size: 0.95rem; letter-spacing: 0.01em; }
.now-sub { color: var(--muted); font-size: 0.76rem; margin-top: 3px; font-family: var(--mono); }
.player-toolbar {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px 14px;
}

.tool {
  border: 1px solid var(--line); background: var(--bg-input); color: var(--text);
  border-radius: var(--radius-sm); padding: 8px 11px; cursor: pointer;
  font-size: 0.76rem; font-weight: 600;
  transition: background 0.12s, border-color 0.12s, transform 0.08s;
}
.tool:hover { background: var(--bg-hover); border-color: #524538; }
.tool:active { transform: translateY(1px); }
.tool.danger { color: #f0a8a4; border-color: #6a3030; }
.tool.sm { padding: 6px 9px; font-size: 0.72rem; }
.tool.recording { background: var(--rec); border-color: var(--rec); color: #fff; }
.tool.hidden { display: none !important; }
.ghost-tool { opacity: 0.85; }

/* Library sheet under player */
/* Live chat under player — compose always pinned under scrolling log */
.chat-panel {
  margin-top: 12px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow), var(--inset);
  display: flex;
  flex-direction: column;
  min-height: 220px;
  max-height: min(42vh, 380px);
  height: min(42vh, 380px);
}
.chat-panel.hidden { display: none !important; }
.chat-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px; padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(255,240,220,0.03);
  font-size: 0.85rem;
  flex: 0 0 auto;
}
.chat-head-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.chat-status {
  display: block; font-size: 0.72rem; color: var(--muted); font-weight: 500; margin-top: 2px;
  font-family: var(--mono);
}
.chat-status.live { color: var(--ok); }
.chat-status.err { color: #e8908a; }
.tool.on { background: var(--accent); border-color: #a34a1c; color: #fff; }
.chat-log {
  flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 8px 10px; min-height: 0;
  font-size: 0.82rem; line-height: 1.35;
  background: var(--bg-input);
}
.chat-line { margin-bottom: 6px; word-break: break-word; }
.chat-line .u { color: var(--accent-2); font-weight: 700; margin-right: 6px; }
.chat-line .t { color: var(--text); }
.chat-line.status { color: var(--muted); font-style: italic; font-size: 0.78rem; }
.chat-embed {
  flex: 1 1 auto; width: 100%; min-height: 0; border: 0; background: #0d0d0d;
}
.chat-embed.hidden { display: none !important; }
.chat-compose,
#chat-compose {
  display: flex; gap: 8px; padding: 8px 10px;
  border-top: 1px solid var(--line-soft); background: var(--bg-raised);
  flex: 0 0 auto; flex-shrink: 0; align-items: center; min-height: 40px;
}
.chat-compose .input,
#chat-input { flex: 1; min-width: 0; padding: 6px 8px; font-size: 11px; }

.sheet {
  margin-top: 12px; background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px; box-shadow: var(--shadow);
}
.sheet-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px; font-size: 0.85rem;
}
.sheet-list { display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow: auto; }
.sheet-list button {
  text-align: left; border: 1px solid var(--line-soft); background: var(--bg-input);
  border-radius: 8px; padding: 9px 11px; cursor: pointer; color: var(--text);
  font-size: 0.82rem;
}
.sheet-list button:hover { border-color: var(--accent); background: var(--bg-hover); }

.content-col { min-width: 0; padding: 16px 16px 28px; overflow: auto; }
/* Panels: only the active tab is visible — never show inactive panels */
.panel {
  display: none !important;
  animation: none;
}
.panel.active:not([hidden]) {
  display: block !important;
}
.panel[hidden] {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
  height: 0 !important;
  overflow: hidden !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
}
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.panel-head {
  display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
.panel-head h2 {
  margin: 0; font-size: 1.35rem; font-weight: 700; letter-spacing: -0.02em;
}
.lede { margin: 4px 0 0; color: var(--muted); font-size: 0.84rem; }
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; flex: 1; justify-content: flex-end; }
.panel-hint { color: var(--faint); font-size: 0.82rem; margin: 0 0 12px; }
.section-title {
  font-size: 0.78rem; margin: 22px 0 10px; color: var(--faint);
  text-transform: uppercase; letter-spacing: 0.12em; font-weight: 600;
}

.input {
  background: var(--bg-input); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 9px 12px; min-width: 0;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.input.grow { flex: 1; min-width: 120px; }

.btn {
  border: 1px solid var(--line); background: var(--bg-input); border-radius: var(--radius-sm);
  padding: 9px 14px; cursor: pointer; font-weight: 600; font-size: 0.84rem;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.btn:hover { background: var(--bg-hover); }
.btn.primary {
  background: linear-gradient(180deg, #d46a30, var(--accent));
  border-color: #a34a1c; color: #fff;
  box-shadow: 0 4px 14px var(--accent-glow), var(--inset);
}
.btn.primary:hover { background: linear-gradient(180deg, #e07a3c, var(--accent-hover)); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 7px 10px; font-size: 0.76rem; }
.btn.block { width: 100%; }
.danger-text { color: #e8908a !important; }

.filter-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; align-items: center; }
.row.gap { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.file-actions { margin-top: 8px; }
.check {
  display: flex; align-items: center; gap: 10px; font-size: 0.9rem;
  color: var(--muted); margin: 10px 0;
}
.field { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; color: var(--muted); }
.muted { color: var(--muted); }

.seg {
  display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 12px;
  padding: 4px; background: var(--bg-raised); border: 1px solid var(--line-soft);
  border-radius: 12px; width: fit-content; max-width: 100%;
}
.seg button {
  border: 0; background: transparent; color: var(--muted);
  padding: 7px 12px; border-radius: 9px; cursor: pointer;
  font-size: 0.78rem; font-weight: 600;
}
.seg button.on {
  background: var(--bg-card); color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,0.35); border: 1px solid var(--line-soft);
}

.results.list { display: flex; flex-direction: column; gap: 8px; }
.card {
  display: flex; gap: 12px;
  background: linear-gradient(145deg, #241f1a, var(--bg-card));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.12s, box-shadow 0.15s;
  box-shadow: var(--inset);
}
.card:hover {
  border-color: #6a5240;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3), var(--inset);
  transform: translateY(-1px);
}
.card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 8px 28px var(--accent-glow);
}
.card .thumb {
  width: 96px; height: 60px; border-radius: 8px; background: var(--bg-input);
  object-fit: cover; flex-shrink: 0; border: 1px solid var(--line-soft);
}
.card .thumb.wide { width: 80px; height: 52px; }
.card .body { min-width: 0; flex: 1; }
.card .title { font-weight: 600; font-size: 0.9rem; line-height: 1.3; word-break: break-word; }
.card .sub { color: var(--muted); font-size: 0.76rem; margin-top: 4px; }

.badge {
  display: inline-block; font-size: 0.62rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em;
  background: rgba(196, 92, 38, 0.15); border: 1px solid rgba(196, 92, 38, 0.35);
  border-radius: 5px; padding: 2px 6px; margin-right: 6px; vertical-align: middle;
  color: var(--accent-2); font-family: var(--mono);
}
.badge.live {
  background: rgba(196, 60, 72, 0.2); border-color: #8a3038; color: #f0a0a6;
}

.home-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 12px;
}
.home-card {
  background: linear-gradient(160deg, #2a241e 0%, var(--bg-card) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 14px;
  cursor: pointer; text-align: left;
  transition: border-color 0.15s, transform 0.12s;
  box-shadow: var(--inset);
  position: relative;
  overflow: hidden;
}
.home-card::after {
  content: ""; position: absolute; top: 0; right: 0; width: 40%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(196,92,38,0.06));
  pointer-events: none;
}
.home-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.home-card strong { display: block; margin-bottom: 6px; font-size: 0.95rem; }
.home-card span { color: var(--muted); font-size: 0.75rem; }

/* Happenings cards */
.happening-card {
  align-items: flex-start;
  gap: 12px;
  border-left: 3px solid var(--accent);
}
.happening-dot {
  width: 10px; height: 10px; margin-top: 6px; flex-shrink: 0;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.happenings-list .card .title { font-size: 0.88rem; line-height: 1.35; }

/* Storage meter (Library) */
.storage-meter {
  margin: 0 0 14px;
  padding: 12px 14px;
  background: linear-gradient(145deg, #241f1a, var(--bg-card));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--inset);
}
.storage-top {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 0.82rem; font-weight: 600; margin-bottom: 8px;
}
.storage-top .mono, .mono { font-family: var(--mono); font-weight: 500; color: var(--accent-2); font-size: 0.78rem; }
.storage-bar {
  height: 10px; border-radius: 999px; background: var(--bg-input);
  border: 1px solid var(--line-soft); overflow: hidden;
}
.storage-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #8a4a20, var(--accent), var(--accent-2));
  border-radius: 999px;
  transition: width 0.35s ease;
}
.storage-fill.warn { background: linear-gradient(90deg, #a65a20, #d4a020); }
.storage-fill.crit { background: linear-gradient(90deg, #8a2020, var(--danger)); }
.storage-sub { margin-top: 6px; font-size: 0.72rem; color: var(--faint); }

/* TV/Movies poster grid */
.poster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 12px;
}
.poster-card {
  display: flex; flex-direction: column; gap: 6px;
  background: linear-gradient(145deg, #241f1a, var(--bg-card));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden; cursor: pointer;
  box-shadow: var(--inset);
  transition: border-color 0.15s, transform 0.12s;
}
.poster-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.poster-card.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-glow); }
.poster-card .poster-img {
  width: 100%; aspect-ratio: 2/3; object-fit: cover;
  background: var(--bg-input); display: block;
}
.poster-card .poster-body { padding: 8px 10px 10px; }
.poster-card .title { font-size: 0.8rem; font-weight: 600; line-height: 1.25; }
.poster-card .sub { font-size: 0.7rem; color: var(--muted); margin-top: 3px; }
.poster-card .badge { margin-right: 4px; }

/* ── Peer Chat (home) ────────────────────────────────────── */
.peer-layout {
  display: grid;
  /* Chat keeps the wider share; MN rail can go narrower */
  grid-template-columns: minmax(260px, 1fr) minmax(180px, min(280px, 32%));
  gap: 10px;
  align-items: stretch;
  min-height: 0;
}
.peer-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: none;
  min-width: 240px;
}
.peer-side {
  min-width: 160px;
  max-width: 300px;
}
.peer-chat-log {
  flex: 1;
  min-height: 260px;
  overflow: auto;
  background: #faf9f6;
  color: #1a1a1a;
  font-size: 13px;
  padding: 10px 12px;
  margin: 0 0 8px;
  border: 1px solid var(--line, #c0c0c0);
  font-family: Tahoma, "Segoe UI", sans-serif;
}
.peer-chat-line { margin: 0 0 8px; line-height: 1.45; word-break: break-word; }
.peer-chat-line .pc-who { color: #0a3d8f; font-weight: 700; }
.peer-chat-line .pc-house { color: #8a5a00; font-size: 11px; margin-left: 4px; }
.peer-chat-line .pc-time { color: #888; font-size: 10px; margin-left: 6px; }
.peer-chat-compose { display: flex; gap: 8px; align-items: center; }
.room-code-display {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-align: center;
  padding: 12px 8px;
  margin: 6px 0 8px;
  background: #1a1a22;
  border: 1px solid #3a3a4a;
  border-radius: 6px;
  color: #8f8;
  user-select: all;
}
.room-code-input {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
  font-size: 16px;
}
.peer-advanced summary {
  cursor: pointer;
  color: #9ab;
  font-size: 12px;
  margin-bottom: 6px;
}
.voice-bar {
  border: 1px solid #3a3a4a;
  border-radius: 6px;
  background: #14141c;
  padding: 10px 12px;
  margin-bottom: 10px;
}
.voice-bar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.voice-title { color: #8f8; font-size: 13px; }
.voice-status { color: #9ab; font-size: 12px; }
.voice-status.on { color: #6f6; font-weight: 600; }
.voice-status.muted-me { color: #fa8; }
.voice-actions .btn[disabled] { opacity: 0.45; }
.voice-peers {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 8px;
}
.voice-chip {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #222;
  border: 1px solid #444;
  color: #ddd;
}
.voice-chip.muted { opacity: 0.55; text-decoration: line-through; }
.voice-chip.me { border-color: #6a6; color: #8f8; }
.voice-chip.talking { border-color: #4c4; box-shadow: 0 0 0 1px #4c4; }
.peer-side { display: flex; flex-direction: column; gap: 0; min-width: 0; }
.peer-side .groupbox { margin-bottom: 10px; }
.peer-side textarea.input { width: 100%; resize: vertical; font-size: 11px; }
.peer-list { font-size: 12px; max-height: 200px; overflow: auto; }
.peer-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  border-bottom: 1px solid var(--line-soft, #333);
}
.peer-row .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #666; flex-shrink: 0;
}
.peer-row .dot.on { background: #2d8a2d; box-shadow: 0 0 4px #2d8a2d; }
.peer-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 1100px) {
  .peer-layout {
    display: flex;
    flex-direction: column;
    grid-template-columns: 1fr;
  }
  .peer-main { max-height: none; }
  .peer-side { width: 100%; max-width: 100%; }
}

/* ── Movie Night ─────────────────────────────────────────── */
.mn-layout {
  display: grid;
  grid-template-columns: 1fr minmax(260px, 320px);
  gap: 14px;
  align-items: start;
}
.mn-main { min-width: 0; }
.mn-now {
  margin-bottom: 12px;
  padding: 10px 12px;
}
.mn-now-body {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: baseline;
}
.mn-now-title { font-weight: 700; }
.mn-chat {
  display: flex;
  flex-direction: column;
  min-height: 420px;
  max-height: calc(100vh - 200px);
  padding: 8px 10px 10px;
  position: sticky;
  top: 8px;
}
.mn-chat-log {
  flex: 1;
  min-height: 200px;
  overflow: auto;
  background: #000;
  color: #cfc;
  font-size: 12px;
  font-family: Tahoma, sans-serif;
  padding: 6px 8px;
  margin-bottom: 8px;
  border: 1px solid var(--line, #444);
}
.mn-chat-line { margin: 0 0 4px; line-height: 1.35; word-break: break-word; }
.mn-chat-line .mn-who { color: #8cf; font-weight: 600; }
.mn-chat-line .mn-time { color: #666; font-size: 10px; margin-left: 6px; }
.mn-chat-compose { display: flex; gap: 6px; align-items: center; }
.mn-chat-hint { margin: 6px 0 0; }
.mn-vote-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.mn-vote-row .btn { font-size: 0.72rem; padding: 2px 8px; }
.poster-card .mn-votes {
  color: var(--accent, #c45c26);
  font-weight: 700;
}
.poster-card.mn-voted {
  border-color: var(--accent, #c45c26);
  box-shadow: 0 0 0 1px rgba(196, 92, 38, 0.35);
}
#mn-search-results:empty { display: none; }
#mn-search-results:not(:empty) {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-soft, #333);
}
@media (max-width: 900px) {
  .mn-layout { grid-template-columns: 1fr; }
  .mn-chat {
    position: static;
    max-height: 360px;
  }
}

/* Chat account cards (Settings) */
.chat-auth-list {
  display: flex; flex-direction: column; gap: 10px; margin: 0 0 16px;
}
.chat-auth-card {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px;
  background: linear-gradient(145deg, #241f1a, var(--bg-card));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--inset);
}
.chat-auth-card .meta strong { display: block; font-size: 0.95rem; }
.chat-auth-card .meta .sub { color: var(--muted); font-size: 0.78rem; margin-top: 2px; }
.chat-auth-card .pill {
  display: inline-block; margin-top: 6px; padding: 2px 8px; border-radius: 999px;
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.03em;
  background: var(--bg-input); color: var(--faint); border: 1px solid var(--line-soft);
}
.chat-auth-card .pill.on {
  color: #1a3a12; background: #9dce7a; border-color: #6a9a4a;
}
.chat-auth-editor {
  margin: 0 0 18px; padding: 14px;
  background: var(--bg-raised); border: 1px solid var(--line);
  border-radius: var(--radius);
}
.chat-auth-fields { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.chat-auth-fields .field { margin: 0; }
textarea.input.mono {
  font-family: var(--mono); font-size: 0.75rem; resize: vertical; min-height: 100px;
  width: 100%;
}
.chat-compose.disabled { opacity: 0.55; }
#chat-input:disabled { cursor: not-allowed; }

/* Library folders */
.library-layout {
  display: grid; grid-template-columns: minmax(140px, 200px) 1fr; gap: 14px; min-height: 280px;
}
.folder-rail {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--bg-raised); border: 1px solid var(--line-soft);
  border-radius: var(--radius); padding: 8px; max-height: 70vh; overflow: auto;
}
.folder-rail button {
  text-align: left; border: 1px solid transparent; background: transparent;
  border-radius: 8px; padding: 10px 11px; cursor: pointer; color: var(--muted);
  font-size: 0.82rem; font-weight: 600;
}
.folder-rail button:hover { background: var(--bg-hover); color: var(--text); }
.folder-rail button.on {
  background: var(--bg-card); color: var(--text); border-color: var(--line);
  box-shadow: var(--inset);
}
.folder-rail .count {
  float: right; font-family: var(--mono); font-size: 0.7rem; color: var(--faint); font-weight: 500;
}
.folder-main {
  background: var(--bg-raised); border: 1px solid var(--line-soft);
  border-radius: var(--radius); padding: 12px 14px; min-height: 200px;
}
.folder-title-row {
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px; margin-bottom: 12px; flex-wrap: wrap;
}
.folder-title-row h3 { margin: 0; font-size: 1rem; }

.sub-tabs {
  display: flex; gap: 4px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 2px;
}
.sub-tabs button {
  flex: 0 0 auto; border: 1px solid transparent; background: transparent; color: var(--muted);
  padding: 8px 12px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 0.8rem;
}
.sub-tabs button.active {
  background: var(--bg-card); color: var(--text); border-color: var(--line);
}
.sub { display: none; }
.sub.active { display: block; }

.settings-box {
  background: linear-gradient(165deg, #241f1a, var(--bg-card));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; display: flex; flex-direction: column; gap: 14px; max-width: 440px;
  box-shadow: var(--inset);
}
.status-box {
  background: var(--bg-input); border: 1px solid var(--line-soft); border-radius: 10px;
  padding: 12px; font-size: 0.74rem; overflow: auto; color: var(--muted);
  white-space: pre-wrap; font-family: var(--mono); max-height: 240px;
}

.empty-state, .error-state {
  padding: 28px 18px; text-align: center; color: var(--muted);
  border: 1px dashed var(--line); border-radius: var(--radius);
  background: rgba(0,0,0,0.15);
}
.error-state { color: #e8908a; border-color: #6a3030; }

#toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: #2a221c; border: 1px solid var(--line); color: var(--text);
  padding: 11px 18px; border-radius: 999px; z-index: 100; font-size: 0.84rem;
  max-width: 90vw; box-shadow: var(--shadow);
}
#spinner {
  position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 100;
  background: linear-gradient(90deg, transparent, var(--accent), var(--accent-2), transparent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

@media (max-width: 900px) {
  html, body { overflow-x: hidden; max-width: 100vw; }
  #app { overflow-x: hidden; max-width: 100vw; }
  .workspace {
    grid-template-columns: 1fr;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }
  .player-col {
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }
  .content-col {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
    box-sizing: border-box;
  }
  #player-wrap { max-height: 36vh; width: 100%; }
  .library-layout { grid-template-columns: 1fr; }
  .folder-rail { flex-direction: row; flex-wrap: wrap; overflow-x: hidden; max-height: none; }
  .folder-rail button { white-space: nowrap; }
  .brand-sub { max-width: 40vw; }
  .main-tabs { flex-wrap: wrap; overflow-x: hidden; }
  .filter-row, .head-actions { flex-wrap: wrap; width: 100%; }
  .input.grow { flex: 1 1 100%; min-width: 0; width: 100%; }
  .peer-layout, .mn-layout { grid-template-columns: 1fr; }
  .card { max-width: 100%; min-width: 0; }
  .results.poster-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }
}

@media (max-width: 480px) {
  .results.poster-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  #player-wrap { max-height: 32vh; }
}


