:root {
  --bg: #08080d;
  --panel: #13131d;
  --panel-2: #1b1b29;
  --border: #2a2a3d;
  --text: #f3f3f8;
  --muted: #9b9bb2;
  --accent: #7c5cff;
  --accent-2: #20d3a3;
  --warn: #ffb547;
  --danger: #ff5c7a;
  --radius: 16px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Heebo', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: 0;
  border-radius: 12px;
  padding: 12px 18px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-weight: 600;
  transition: transform 0.08s ease, background 0.15s ease, opacity 0.15s ease;
}

button:active {
  transform: scale(0.97);
}

button:disabled {
  opacity: 0.45;
  cursor: default;
}

button.primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}

button.danger {
  color: var(--danger);
}

button.small {
  padding: 6px 12px;
  font-size: 0.85rem;
  border-radius: 10px;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  background: var(--panel-2);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.chip::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.chip.ok::before {
  background: var(--accent-2);
}

.chip.warn::before {
  background: var(--warn);
}

.chip.bad::before {
  background: var(--danger);
}

/* ------------------------------------------------------------------ viewer */

body.viewer {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #000;
}

.viewer video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
  text-align: center;
  background: radial-gradient(circle at 50% 30%, #1d1640 0%, #08080d 70%);
  z-index: 5;
}

.overlay h1 {
  margin: 0;
  font-size: 2.2rem;
  letter-spacing: 0.02em;
}

.overlay p {
  margin: 0;
  max-width: 320px;
  line-height: 1.5;
  color: var(--muted);
}

.join-btn {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  font-size: 1.4rem;
  background: var(--accent);
  border: 0;
  color: #fff;
  box-shadow: 0 0 0 0 rgba(124, 92, 255, 0.6);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(124, 92, 255, 0.55);
  }
  70% {
    box-shadow: 0 0 0 26px rgba(124, 92, 255, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(124, 92, 255, 0);
  }
}

.waiting {
  background: rgba(0, 0, 0, 0.55);
  pointer-events: none;
}

.waiting .spinner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent);
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.hud {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  inset-inline: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  z-index: 6;
  transition: opacity 0.4s ease;
}

.hud.faded {
  opacity: 0;
  pointer-events: none;
}

.hud .chip {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
}

.debug {
  position: absolute;
  bottom: max(10px, env(safe-area-inset-bottom));
  left: 10px;
  z-index: 7;
  font: 12px/1.45 ui-monospace, Menlo, Consolas, monospace;
  background: rgba(0, 0, 0, 0.7);
  padding: 8px 10px;
  border-radius: 8px;
  direction: ltr;
  white-space: pre;
  pointer-events: none;
}

/* ------------------------------------------------------------------ admin */

body.admin {
  min-height: 100vh;
  padding: 16px;
  padding-bottom: 48px;
}

.admin header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  max-width: 1100px;
  margin: 0 auto 16px;
}

.admin header h1 {
  margin: 0;
  font-size: 1.4rem;
}

.admin header h1 span {
  color: var(--accent);
}

.grid {
  display: grid;
  gap: 16px;
  max-width: 1100px;
  margin: 0 auto;
  grid-template-columns: 1fr;
}

@media (min-width: 900px) {
  .grid {
    grid-template-columns: 1.4fr 1fr;
  }
  .grid .span-2 {
    grid-column: span 2;
  }
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  min-width: 0;
}

.card h2 {
  margin: 0 0 12px;
  font-size: 1rem;
  color: var(--muted);
  font-weight: 600;
}

.player video {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 12px;
  display: block;
}

.transport {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.transport .play {
  flex: 1 1 160px;
  font-size: 1.2rem;
  padding: 16px;
}

.time {
  font-variant-numeric: tabular-nums;
  direction: ltr;
  color: var(--muted);
}

.seek {
  width: 100%;
  margin-top: 12px;
  accent-color: var(--accent);
  direction: ltr;
}

.banner {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 181, 71, 0.12);
  border: 1px solid rgba(255, 181, 71, 0.35);
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat {
  background: var(--panel-2);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
}

.stat b {
  display: block;
  font-size: 1.6rem;
  font-variant-numeric: tabular-nums;
}

.stat small {
  color: var(--muted);
}

.join {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.join img {
  width: 150px;
  height: 150px;
  background: #fff;
  border-radius: 12px;
  padding: 6px;
  cursor: zoom-in;
}

.join .link {
  flex: 1 1 200px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

input[type='text'],
input[type='password'],
input[type='url'] {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  outline: none;
}

input:focus {
  border-color: var(--accent);
}

.row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.videos {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.videos li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--panel-2);
  border: 1px solid transparent;
}

.videos li.active {
  border-color: var(--accent);
}

.videos .name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

progress {
  width: 100%;
  height: 8px;
  accent-color: var(--accent);
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
  direction: ltr; /* −10 on the left, +10 on the right, matching the slider */
}

.slider-row input[type='range'] {
  flex: 1;
  accent-color: var(--accent);
  direction: ltr;
}

.slider-row output {
  min-width: 72px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  direction: ltr;
}

.hint {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.55;
  margin: 10px 0 0;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  cursor: pointer;
}

.toggle input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

.login {
  max-width: 360px;
  margin: 12vh auto 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
}

.login h1 {
  margin: 0 0 8px;
}

.error {
  color: var(--danger);
  min-height: 1.2em;
  margin: 0;
}

.qr-full {
  position: fixed;
  inset: 0;
  background: #fff;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: #111;
  cursor: zoom-out;
  padding: 24px;
}

.qr-full img {
  width: min(80vw, 80vh);
  height: min(80vw, 80vh);
}

.qr-full div {
  font-size: clamp(1rem, 3vw, 2rem);
  font-weight: 700;
  direction: ltr;
  word-break: break-all;
  text-align: center;
}
