:root {
  --bg: #160f17;
  --panel: #221828;
  --panel-2: #2e2138;
  --text: #ece6ee;
  --muted: #9a8aa6;
  --accent: #a855f7;
  --accent-2: #8b3fd6;
  --danger: #ff5c5c;
  --ok: #35c98a;
  --border: #3a2c42;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

body { display: flex; flex-direction: column; }

a { color: var(--accent); }

/* ---------- centered login cards ---------- */
.center {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 2rem;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

/* ---------- login side images ---------- */
/* Pinned to the bottom corners of the window; scale with the viewport. */
.side-img {
  position: fixed;
  bottom: 0;
  height: 100vh;
  z-index: 0;
  display: flex;
  align-items: flex-end; /* pin image to the bottom of the window */
}
.side-left  { left: 0;  width: 33vw; justify-content: flex-start; } /* hug bottom-left corner */
.side-right { right: 0; width: 33vw; justify-content: flex-end; }   /* hug bottom-right corner */
.side-img img {
  max-width: 100%;
  max-height: 100vh;
  object-fit: contain;
  object-position: bottom;
  display: block;
}
/* Keep the login card above the side images. */
.center { position: relative; z-index: 1; }

.card h1 {
  margin: 0 0 0.25rem;
  font-size: 1.4rem;
}
.card p.sub {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 0.7rem 0.8rem;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 1rem;
}
input:focus { outline: 2px solid var(--accent); border-color: transparent; }

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 0.7rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  transition: background 0.15s ease;
}
button:hover { background: var(--accent-2); }
button.secondary { background: var(--panel-2); border: 1px solid var(--border); }
button.danger { background: var(--danger); }
button.block { width: 100%; }

.error {
  color: var(--danger);
  font-size: 0.85rem;
  min-height: 1.2em;
  margin-bottom: 0.5rem;
}
.note { color: var(--muted); font-size: 0.8rem; }

/* ---------- stream layout ---------- */
.topbar {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.topbar .brand { font-weight: 700; letter-spacing: 0.5px; }
.topbar .actions { display: flex; gap: 0.5rem; align-items: center; }
.status-dot {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  background: var(--muted); margin-right: 0.4rem;
}
.status-dot.live { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.status-dot.err { background: var(--danger); }

.layout {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
}
.player-wrap {
  flex: 1;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-width: 0;
}
video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}
.overlay {
  position: absolute;
  color: var(--muted);
  font-size: 0.95rem;
  text-align: center;
  pointer-events: none;
}
.overlay.clickable {
  pointer-events: auto;
  cursor: pointer;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  transition: transform 0.12s ease, color 0.12s ease;
}
.overlay.clickable:hover { color: #fff; transform: scale(1.04); }
.overlay .overlay-text { font-size: 1rem; font-weight: 600; }

/* ---------- player controls ---------- */
.controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1rem 0.7rem;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  opacity: 1;
  transition: opacity 0.25s ease;
}
.controls.hidden { display: none; }
.controls.faded { opacity: 0; pointer-events: none; }

.ctrl-btn {
  background: transparent;
  border: none;
  padding: 0.25rem;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}
.ctrl-btn:hover { background: rgba(255, 255, 255, 0.12); }
.ctrl-btn .icon-muted { display: none; }
.ctrl-btn.is-muted .icon-volume { display: none; }
.ctrl-btn.is-muted .icon-muted { display: inline; }

#fsBtn { margin-left: auto; }
.ctrl-btn .icon-fs-close { display: none; }
.ctrl-btn.is-fullscreen .icon-fs-open { display: none; }
.ctrl-btn.is-fullscreen .icon-fs-close { display: inline; }

.volume {
  -webkit-appearance: none;
  appearance: none;
  width: 110px;
  height: 4px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.3);
  cursor: pointer;
}
.volume::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: none;
}
.volume::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: none;
}

/* ---------- chat panel ---------- */
.chat {
  width: 320px;
  background: var(--panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.chat.hidden { display: none; }
.chat-head {
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--muted);
  display: flex; justify-content: space-between;
}
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.6rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.msg { font-size: 0.9rem; line-height: 1.3; word-wrap: break-word; }
.msg .who { font-weight: 700; color: var(--accent); }
.msg .who.admin { color: var(--ok); }
.msg.system { color: var(--muted); font-style: italic; font-size: 0.82rem; }
.chat-input {
  display: flex;
  gap: 0.4rem;
  padding: 0.6rem;
  border-top: 1px solid var(--border);
}
.chat-input input { margin: 0; }
.chat-input button { padding: 0.6rem 0.9rem; }

.nick-gate {
  padding: 0.8rem;
  border-top: 1px solid var(--border);
  display: flex; gap: 0.4rem;
}

/* ---------- admin ---------- */
.admin-wrap { max-width: 640px; margin: 3rem auto; padding: 0 1rem; }
.keybox {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.8rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  word-break: break-all;
  margin-bottom: 0.5rem;
}
.row { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.field { margin-bottom: 1.2rem; }
.field .lbl { color: var(--muted); font-size: 0.8rem; margin-bottom: 0.3rem; }
.warn {
  background: rgba(255, 92, 92, 0.1);
  border: 1px solid var(--danger);
  color: #ffbcbc;
  border-radius: 8px;
  padding: 0.7rem 0.9rem;
  font-size: 0.85rem;
  margin-bottom: 1.2rem;
}

@media (max-width: 700px) {
  .chat { width: 100%; position: absolute; inset: 0; }
}
