/* Shared stylesheet — viewer + moderator pages */
:root {
  --blue: #007bff;
  --blue-dark: #0062cc;
  --blue-soft: #e7f1ff;
  --green: #28a745;
  --green-soft: #e6f6ea;
  --red: #dc3545;
  --red-soft: #fdecee;
  --yellow: #ffc107;
  --yellow-soft: #fff6db;
  --ink: #1f2933;
  --muted: #64748b;
  --line: #e3e8ef;
  --bg: #f3f6fa;
  --card: #ffffff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .08);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); color: var(--ink); line-height: 1.5;
  background: radial-gradient(1200px 500px at 50% -200px, #dbe9ff 0%, var(--bg) 60%) no-repeat, var(--bg);
  min-height: 100vh;
}
a { color: var(--blue); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }

/* ---------- layout ---------- */
.site-header {
  display: flex; align-items: center; gap: .75rem; padding: 1rem 1.25rem;
  max-width: 1100px; margin: 0 auto;
}
.site-header.centered { justify-content: center; flex-wrap: wrap; text-align: center; gap: .75rem; }
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.1rem; color: var(--ink); text-decoration: none; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px; background: var(--blue); color: #fff;
  display: grid; place-items: center; font-size: 1.1rem; box-shadow: 0 4px 12px rgba(0, 123, 255, .35);
}
.header-spacer { flex: 1; }
.container { max-width: 1100px; margin: 0 auto; padding: 0 1.25rem 3rem; }
.narrow { max-width: 460px; margin: 4vh auto 0; }
.medium { max-width: 900px; margin: 0 auto; }
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.5rem; border: 1px solid rgba(227, 232, 239, .7);
}
.card + .card { margin-top: 1.25rem; }
.card-title { display: flex; align-items: center; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.card-title h2 { margin: 0; }
.stack > * + * { margin-top: 1rem; }

/* ---------- forms ---------- */
.field { display: block; margin-bottom: 1rem; }
.field > span { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .35rem; }
.input, .field input, .field textarea, select {
  width: 100%; padding: .7rem .85rem; font: inherit; color: inherit;
  border: 1px solid #cdd5df; border-radius: 10px; background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .field input:focus, .field textarea:focus, select:focus {
  outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0, 123, 255, .2);
}
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
@media (max-width: 480px) { .row-2 { grid-template-columns: 1fr; gap: 0; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .65rem 1.1rem; font: inherit; font-weight: 600; line-height: 1.2;
  border: 1px solid transparent; border-radius: 10px; cursor: pointer;
  background: var(--blue); color: #fff; text-decoration: none;
  transition: background .15s, transform .05s, box-shadow .15s;
}
.btn:hover { background: var(--blue-dark); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(0, 123, 255, .35); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-block { width: 100%; padding: .8rem 1rem; font-size: 1.05rem; }
.btn-sm { padding: .35rem .65rem; font-size: .82rem; border-radius: 8px; }
.btn-green { background: var(--green); } .btn-green:hover { background: #218838; }
.btn-red { background: var(--red); } .btn-red:hover { background: #c82333; }
.btn-ghost { background: #fff; color: var(--ink); border-color: #cdd5df; }
.btn-ghost:hover { background: #f1f5f9; }
.btn-link { background: none; color: var(--blue); padding: 0; border: 0; font: inherit; font-weight: 600; cursor: pointer; }
.btn-link:hover { background: none; text-decoration: underline; }

.alert { border-radius: 10px; padding: .75rem 1rem; font-size: .95rem; margin-bottom: 1rem; }
.alert-error { background: var(--red-soft); color: #842029; border: 1px solid #f5c2c7; }
.alert-info { background: var(--blue-soft); color: #084298; border: 1px solid #b6d4fe; }
.privacy { font-size: .8rem; color: var(--muted); margin: 1rem 0 0; text-align: center; }

/* ---------- status pills / badges ---------- */
.pill {
  display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .6rem; border-radius: 999px;
  font-size: .78rem; font-weight: 700; letter-spacing: .02em; white-space: nowrap;
}
.pill-green { background: var(--green-soft); color: #1e7b34; }
.pill-red { background: var(--red-soft); color: #b02a37; }
.pill-yellow { background: var(--yellow-soft); color: #8a6100; }
.pill-gray { background: #eef1f5; color: #475569; }
.pill-blue { background: var(--blue-soft); color: #0b5ed7; }
.count-badge {
  min-width: 1.6rem; height: 1.6rem; padding: 0 .45rem; border-radius: 999px; display: inline-grid; place-items: center;
  background: var(--yellow); color: #3b2a00; font-weight: 800; font-size: .85rem;
}
.count-badge.zero { background: #e2e8f0; color: #64748b; }
.live-dot { width: .6rem; height: .6rem; border-radius: 50%; display: inline-block; background: #cbd5e1; flex: none; }
.live-dot.on { background: var(--green); box-shadow: 0 0 0 0 rgba(40, 167, 69, .6); animation: pulse 2s infinite; }
.live-dot.wait { background: var(--yellow); }
.live-dot.red { background: var(--red); animation: pulse-red 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(40,167,69,.55); } 70% { box-shadow: 0 0 0 8px rgba(40,167,69,0); } 100% { box-shadow: 0 0 0 0 rgba(40,167,69,0); } }
@keyframes pulse-red { 0% { box-shadow: 0 0 0 0 rgba(220,53,69,.55); } 70% { box-shadow: 0 0 0 8px rgba(220,53,69,0); } 100% { box-shadow: 0 0 0 0 rgba(220,53,69,0); } }

/* ---------- viewer badges (initials) ---------- */
.badges { display: flex; flex-wrap: wrap; gap: .5rem; }
/* Currently Watching list scrolls inside its panel */
.watching-list { max-height: 240px; overflow-y: auto; align-content: flex-start; padding-right: .25rem; }
.watching-search { width: 100%; padding: .45rem .7rem; margin-bottom: .6rem; }
.viewer-badge {
  display: inline-flex; align-items: center; gap: .5rem; padding: .3rem .8rem .3rem .3rem;
  background: #f8fafc; border: 1px solid var(--line); border-radius: 999px; font-size: .9rem; max-width: 100%;
}
.viewer-badge .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none;
  color: #fff; font-weight: 700; font-size: .8rem; background: var(--blue); letter-spacing: .02em;
}
.empty { color: var(--muted); font-size: .9rem; }

/* ---------- viewer page ---------- */
.hero-title { font-size: 1.6rem; margin-bottom: .25rem; }
.player-wrap {
  position: relative; width: 100%; aspect-ratio: 16 / 9; background: #0b1220; border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
}
.player-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
@supports not (aspect-ratio: 16 / 9) { .player-wrap { height: 0; padding-top: 56.25%; } }
.watch-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 1.25rem 0 .75rem; flex-wrap: wrap; }
.state-card { text-align: center; padding: 2.5rem 1.5rem; }
.state-icon { font-size: 2.6rem; line-height: 1; margin-bottom: .75rem; }
.waiting-dots { display: inline-flex; gap: .45rem; margin: 1rem 0 1.25rem; }
.waiting-dots span {
  width: .8rem; height: .8rem; border-radius: 50%; background: var(--blue); opacity: .25;
  animation: bounce 1.4s infinite ease-in-out both;
}
.waiting-dots span:nth-child(2) { animation-delay: .16s; }
.waiting-dots span:nth-child(3) { animation-delay: .32s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(.6); opacity: .25; } 40% { transform: scale(1); opacity: 1; } }
.state-removed { border-top: 4px solid var(--red); }
.state-waiting { border-top: 4px solid var(--yellow); }
.state-offline { border-top: 4px solid var(--muted); }
@media (prefers-reduced-motion: reduce) {
  .waiting-dots span, .live-dot.on, .live-dot.red { animation: none; opacity: 1; }
}

/* ---------- moderator page ---------- */
.topbar-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
/* ---------- moderator dashboard ---------- */
#dash-view > .card, #dash-view > .dash-panels, #dash-view > .dash-extras { margin-bottom: 1.25rem; }
.stat-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem 1.5rem; padding: 1rem 1.5rem; }
.stat-stream { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; flex: 1 1 420px; }
.stat-stream .input { flex: 1 1 240px; padding: .5rem .75rem; min-width: 0; }
.stats { display: flex; gap: .6rem; }
.stat { display: flex; flex-direction: column; align-items: center; min-width: 84px; padding: .45rem .8rem; border-radius: 10px; background: #f4f6fa; }
.stat-num { font-size: 1.35rem; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.stat-pending.hot { background: var(--yellow-soft); }
.stat-pending.hot .stat-num { color: #8a6100; }
.dash-panels { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 1.25rem; align-items: stretch; }
.dash-panels > .card, .dash-extras > .card { margin: 0; }
.dash-panels .panel { display: flex; flex-direction: column; min-height: 0; }
.watching-card .watching-list { flex: 1 1 0; min-height: 120px; max-height: none; }
@media (max-width: 860px) {
  .dash-panels { grid-template-columns: minmax(0, 1fr); }
  .watching-card .watching-list { flex: none; max-height: 240px; }
}
.dash-extras { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.25rem; align-items: start; }
.fold { padding: 0; }
.fold > summary { display: flex; align-items: center; gap: .5rem; padding: 1rem 1.5rem; cursor: pointer; list-style: none; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after { content: "▸"; margin-left: auto; color: var(--muted); transition: transform .15s ease; }
.fold[open] > summary::after { transform: rotate(90deg); }
.fold > summary h2 { margin: 0; font-size: 1.05rem; }
.fold > :not(summary) { margin-left: 1.5rem; margin-right: 1.5rem; }
.fold[open] { padding-bottom: 1.25rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: center; margin-bottom: 1rem; }
.toolbar .input { max-width: 260px; padding: .5rem .75rem; }
.check { display: inline-flex; align-items: center; gap: .4rem; font-size: .9rem; cursor: pointer; user-select: none; }
.check input { width: 1.05rem; height: 1.05rem; accent-color: var(--blue); }
.toolbar .grow { flex: 1; }
.table-wrap { overflow-x: auto; margin: 0 -1.5rem; padding: 0 1.5rem; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th {
  text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  padding: .6rem .6rem; border-bottom: 2px solid var(--line); white-space: nowrap;
}
table.data td { padding: .65rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tr.row-pending td { background: #fffdf4; }
table.data tr.row-banned td { background: #fff7f8; }
.name-cell { display: flex; gap: .55rem; align-items: flex-start; }
.name-cell .who { font-weight: 600; overflow-wrap: anywhere; }
.note { font-size: .78rem; color: var(--muted); }
.note.red { color: #b02a37; }
.actions { display: flex; flex-wrap: wrap; gap: .35rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .82rem; overflow-wrap: anywhere; }
table.data td.mono { white-space: nowrap; }
table.data td.name-td { min-width: 190px; }
.container.wide { max-width: 1400px; }
.site-header.wide { max-width: 1400px; }
.showing { font-size: .85rem; color: var(--muted); margin-top: .75rem; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .45rem 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.list li:last-child { border-bottom: 0; }
.list .sub { display: block; font-size: .75rem; color: var(--muted); }
.inline-form { display: flex; gap: .4rem; margin-top: .75rem; }
.inline-form .input { padding: .45rem .6rem; min-width: 0; }
.seg { display: inline-flex; border: 1px solid #cdd5df; border-radius: 10px; overflow: hidden; }
.seg label { padding: .45rem .9rem; cursor: pointer; font-weight: 600; font-size: .9rem; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--blue); color: #fff; }
.seg label:has(input:focus-visible) { box-shadow: inset 0 0 0 3px rgba(0, 123, 255, .35); }

dialog {
  border: 0; border-radius: var(--radius); box-shadow: 0 20px 60px rgba(15, 23, 42, .3);
  padding: 1.5rem; width: min(440px, calc(100vw - 2rem));
}
dialog::backdrop { background: rgba(15, 23, 42, .45); }
.radio { display: flex; gap: .6rem; align-items: flex-start; padding: .6rem .75rem; border: 1px solid var(--line); border-radius: 10px; margin-bottom: .5rem; cursor: pointer; }
.radio:has(input:checked) { border-color: var(--blue); background: var(--blue-soft); }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }
.toast {
  position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); background: #111827; color: #fff;
  padding: .6rem 1rem; border-radius: 10px; font-size: .9rem; box-shadow: var(--shadow); z-index: 50; max-width: calc(100vw - 2rem);
}

/* Mobile: turn the viewer table into cards */
@media (max-width: 720px) {
  .card { padding: 1.1rem; }
  .table-wrap { margin: 0; padding: 0; }
  table.data thead { display: none; }
  table.data, table.data tbody, table.data tr, table.data td { display: block; width: 100%; }
  table.data tr { border: 1px solid var(--line); border-radius: 12px; margin-bottom: .75rem; padding: .4rem .2rem; background: #fff; }
  table.data td { border: 0; padding: .3rem .7rem; display: flex; gap: .75rem; }
  table.data td[data-label]::before {
    content: attr(data-label); flex: 0 0 5.5rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding-top: .15rem;
  }
  table.data td.empty-row::before { content: none; }
  .toolbar .input { max-width: none; width: 100%; }
  table.data td.mono { white-space: normal; }
  table.data td.name-td { min-width: 0; }
  .site-header { flex-wrap: wrap; }
  .topbar-actions { width: 100%; justify-content: flex-start; }
}
.site-footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 1.5rem 1rem 2rem; }
.mt { margin-top: .75rem; }
.name-cell > div { min-width: 0; }
.name-cell .pill { white-space: normal; }

/* Currently Watching collapsed */
.watching-card.collapsed .watching-search, .watching-card.collapsed .watching-list { display: none !important; }
.watching-card.collapsed { align-self: start; }
