:root {
  --bg: #0f1320;
  --bg-grad: radial-gradient(circle at 20% 15%, #1c2338 0%, #0f1320 55%);
  --card-bg: rgba(255,255,255,0.04);
  --card-border: rgba(255,255,255,0.09);
  --text: #eef1f8;
  --text-dim: #8891a8;
  --accent: #9db4ff;
  --track: rgba(255,255,255,0.08);

  --ambient-btn-size: 80px;
  --ambient-icon-size: 23px;
  --ambient-toggle-size: 60px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background-color: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  position: relative;
  overflow-x: hidden;
}

/* Full-bleed looping background video.
   Positive, explicit z-index stack (video 0 < scrim 1 < content 2) instead of
   negative z-index — negative values can end up painted behind the page's
   own canvas background depending on stacking context, which is what made
   the video invisible. */
.bg-video {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
  background: var(--bg-grad), var(--bg);
}

.bg-scrim {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(6,8,14,0.15) 0%, rgba(6,8,14,0.05) 45%, rgba(6,8,14,0.55) 100%),
    linear-gradient(0deg, rgba(6,8,14,0.35) 0%, rgba(6,8,14,0) 30%);
}

.dash {
  position: relative;
  z-index: 2;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: clamp(20px, 6vw, 64px);
}

/* Glass stat panel */
.panel {
  width: 100%;
  max-width: 360px;
  background: rgba(15,19,32,0.45);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 28px;
  padding: clamp(24px, 4vw, 36px);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}

.stat-block { text-align: left; }

.stat-label {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 500;
  color: rgba(238,241,248,0.65);
  text-transform: none;
  letter-spacing: 0.01em;
}

.stat-value {
  margin: 0 0 10px;
  font-size: clamp(40px, 7vw, 52px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}

.stat-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: rgba(238,241,248,0.6);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
  flex: 0 0 auto;
}

.stat-block.stale .dot { background: #d18a4a; }
.stat-block.error .dot { background: #d1524a; }
.stat-block.error .stat-value { color: #f2a49c; }

.divider {
  height: 1px;
  background: rgba(255,255,255,0.14);
  margin: 22px 0;
}

@media (max-width: 640px) {
  .dash {
    align-items: flex-end;
    justify-content: center;
    padding-bottom: clamp(110px, 22vw, 150px);
  }
  .panel { max-width: 420px; }
}

/* Ambient widget */

#yt-player-container {
  position: fixed;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  bottom: 0;
  right: 0;
}

.ambient-widget {
  position: fixed;
  bottom: max(16px, env(safe-area-inset-bottom));
  left: max(16px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  z-index: 10;
}

.ambient-panel {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(20,24,34,0.65);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  min-width: 150px;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transform: translateY(6px);
  transition: max-height 0.25s ease, opacity 0.2s ease, transform 0.2s ease;
}
.ambient-panel.open {
  max-height: 260px;
  opacity: 1;
  transform: translateY(0);
}

.ambiance-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: #c4cbdc;
  cursor: pointer;
  background: transparent;
  border: none;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
  font-family: inherit;
}
.ambiance-option:hover {
  background: rgba(255,255,255,0.06);
  color: #eef1f8;
}
.ambiance-option.active {
  color: #9db4ff;
  background: rgba(157,180,255,0.08);
}
.ambiance-option .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9db4ff;
  opacity: 0;
}
.ambiance-option.active .dot { opacity: 1; }

.ambient-panel .volume-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 4px;
  border-top: 1px solid rgba(255,255,255,0.08);
  margin-top: 4px;
}
.ambient-panel .volume-row input[type="range"] {
  flex: 1;
  accent-color: #9db4ff;
}
.ambient-panel .volume-row span {
  font-size: 11px;
  color: #6b7488;
}

/* iOS/iPadOS can't drive the YouTube volume via JS, so the slider is a dead
   control there — hidden by a class ambient.js adds after sniffing the UA. */
.no-volume-control .volume-row { display: none; }

.ambient-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ambient-btn {
  position: relative;
  width: var(--ambient-btn-size);
  height: var(--ambient-btn-size);
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.06);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}
.ambient-btn:hover {
  background: rgba(255,255,255,0.1);
  transform: scale(1.04);
}
.ambient-btn:active { transform: scale(0.97); }
.ambient-btn:disabled { opacity: 0.5; cursor: default; }

.ambient-btn::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1px solid rgba(157, 180, 255, 0.35);
  opacity: 0;
  transform: scale(0.9);
}
.ambient-btn.playing::before {
  animation: breathe 3.2s ease-in-out infinite;
}
@keyframes breathe {
  0%   { opacity: 0.55; transform: scale(0.92); }
  50%  { opacity: 0;    transform: scale(1.35); }
  100% { opacity: 0;    transform: scale(1.35); }
}

.ambient-btn svg {
  width: var(--ambient-icon-size);
  height: var(--ambient-icon-size);
  fill: #dfe4ee;
}
.icon-pause { display: none; }
.ambient-btn.playing .icon-play { display: none; }
.ambient-btn.playing .icon-pause { display: block; }

.ambient-toggle-btn {
  width: var(--ambient-toggle-size);
  height: var(--ambient-toggle-size);
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.05);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #c4cbdc;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.15s ease;
}
.ambient-toggle-btn:hover { background: rgba(255,255,255,0.1); }

.now-playing {
  font-size: 11px;
  color: #6b7488;
  padding: 0 4px 2px;
}

@media (prefers-reduced-motion: reduce) {
  .ambient-btn.playing::before { animation: none; opacity: 0.25; }
}

@media (max-width: 420px) {
  :root {
    --ambient-btn-size: 64px;
    --ambient-icon-size: 19px;
    --ambient-toggle-size: 48px;
  }
}
