:root {
  color-scheme: dark;
  --bg: #0a0b0d;
  --panel: rgba(22, 24, 28, 0.72);
  --panel-solid: #16181c;
  --accent: #4f8cff;
  --accent-soft: rgba(79, 140, 255, 0.15);
  --text: #f2f3f5;
  --muted: #9aa1ac;
  --error: #ff6b6b;
  --live: #ff4545;
  --border: rgba(255, 255, 255, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(ellipse at top, #15171b 0%, var(--bg) 60%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.screen {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* Critical: a plain [hidden] attribute has the same CSS specificity as a
   single class selector, so without this, the `.screen { display: flex }`
   rule above wins the tie (same specificity, later in source) and the
   `hidden` attribute is silently ignored — both screens render stacked on
   top of each other regardless of which one JS thinks is showing. */
.screen[hidden] {
  display: none !important;
}

/* --- Login --- */

.lang-pill {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  background: var(--panel);
  border: 1px solid var(--border);
  backdrop-filter: blur(12px);
  color: var(--text);
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  font-size: 0.8rem;
  cursor: pointer;
}
.lang-pill:hover { background: var(--panel-solid); }

.card {
  background: var(--panel);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  padding: 2.25rem;
  border-radius: 20px;
  width: min(380px, 90vw);
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}
.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
}
.brand h1 { margin: 0; font-size: 1.3rem; font-weight: 600; letter-spacing: -0.01em; }

.hint { color: var(--muted); font-size: 0.85rem; line-height: 1.4; margin: 0.1rem 0; }
.error { color: var(--error); font-size: 0.85rem; margin: 0; }

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
}
input {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s ease;
}
input:focus { border-color: var(--accent); }

.btn-primary {
  background: linear-gradient(180deg, var(--accent), #3b73e0);
  border: none;
  color: white;
  padding: 0.75rem;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 0.25rem;
  transition: filter 0.15s ease, transform 0.1s ease;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: scale(0.98); }

/* --- Viewer --- */

#view-screen { padding: 0; }

#stage {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: black;
  touch-action: none;
}
#stage.dragging { cursor: grabbing; }
#stage.zoomed { cursor: grab; }

#player {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform-origin: center center;
  will-change: transform;
}

.overlay-bar {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.9rem 1rem;
  transition: opacity 0.3s ease;
  z-index: 2;
}
#top-bar {
  top: 0;
  justify-content: space-between;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.55), transparent);
}
#top-bar-actions { display: flex; gap: 0.5rem; }

#bottom-bar {
  bottom: 0;
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.65), transparent);
}

#stage.controls-hidden .overlay-bar {
  opacity: 0;
  pointer-events: none;
}

.live-badge {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}
.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 8px var(--live);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.status-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
  text-align: center;
  background: rgba(0, 0, 0, 0.5);
  padding: 0.5rem 1rem;
  border-radius: 10px;
  margin: 0;
  pointer-events: none;
}
.status-overlay:empty { display: none; }

.icon-btn {
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  transition: background 0.15s ease, transform 0.1s ease;
  flex-shrink: 0;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.16); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 1.1rem; height: 1.1rem; }

.controls { gap: 0.75rem; flex-wrap: nowrap; }
.spacer { flex: 1; }

.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 90px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
  outline: none;
  cursor: pointer;
}
.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.25);
}
.volume-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.25);
}

.zoom-group {
  display: flex;
  gap: 0.4rem;
  background: rgba(255, 255, 255, 0.05);
  padding: 0.25rem;
  border-radius: 12px;
  border: 1px solid var(--border);
}
.zoom-group .icon-btn {
  background: transparent;
  border: none;
  width: 2.2rem;
  height: 2.2rem;
}
.zoom-group .icon-btn:hover { background: rgba(255, 255, 255, 0.1); }

@media (max-width: 520px) {
  .controls { gap: 0.4rem; padding: 0.75rem 0.6rem; }
  .volume-slider { width: 56px; }
  .zoom-group { padding: 0.15rem; gap: 0.2rem; }
  .icon-btn { width: 2.2rem; height: 2.2rem; }
}
