* { box-sizing: border-box; }

html, body { height: 100%; }
body {
  margin: 0;
  background: #0d0d0f;
  color: #e8e8ea;
  font: 15px/1.4 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow: hidden;
}

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

button {
  background: #1e1e24;
  border: 1px solid #33333d;
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
}
button:hover:not(:disabled) { background: #2a2a33; }
button:disabled { opacity: .45; cursor: default; }

#app { display: flex; height: 100%; }

/* ---------------- sidebar ---------------- */

#sidebar {
  width: 300px;
  flex: 0 0 300px;
  display: flex;
  flex-direction: column;
  background: #131317;
  border-right: 1px solid #22222a;
  overflow: hidden;
}
#app.collapsed #sidebar { display: none; }

.side-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 18px 16px 14px;
}
.side-head h1 {
  margin: 0;
  font-size: 15px;
  line-height: 1.25;
  letter-spacing: .14em;
  text-transform: uppercase;
  font-weight: 600;
}
.side-head h1 em { font-style: normal; color: #8a8a96; }
#hideBtn { padding: 3px 9px; line-height: 1; }

.side-filters {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 16px 12px;
  border-bottom: 1px solid #22222a;
}

select, input[type="search"] {
  width: 100%;
  background: #1e1e24;
  border: 1px solid #33333d;
  border-radius: 6px;
  padding: 7px 10px;
}
input[type="search"]::placeholder { color: #6a6a76; }

/* the scrolling list — built for 40+ entries */
.list { flex: 1; overflow-y: auto; padding: 8px; }
.list::-webkit-scrollbar { width: 10px; }
.list::-webkit-scrollbar-thumb { background: #2a2a33; border-radius: 6px; }

.group {
  padding: 14px 8px 6px;
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #6a6a76;
}

.item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  border-left: 2px solid transparent;
}
.item:hover { background: #1c1c22; }
.item.on {
  background: #22222a;
  border-left-color: #e8e8ea;
}
.item .t {
  flex: 1;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.count, .empty { color: #6a6a76; font-size: 12px; padding: 10px 16px; }
.count { border-top: 1px solid #22222a; }

/* ---------------- player ---------------- */

#main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

#stage { position: relative; flex: 1; background: #000; overflow: hidden; }

.frame {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 60ms linear;
}
.frame.active { opacity: 1; }
/* The iframe is held at a real 1920x1080 and scaled down with a transform.
   YouTube picks quality from the player's own viewport, which a CSS scale
   doesn't touch — so it always sees a 1080p-sized player and serves 1080p,
   however small the window actually is. */
.frame iframe {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1920px;
  height: 1080px;
  border: 0;
  display: block;
  transform: translate(-50%, -50%) scale(1);
  transform-origin: 50% 50%;
}

#shield { position: absolute; inset: 0; cursor: pointer; }

#gate {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: #000;          /* solid — hides the warm-up roll behind it */
  z-index: 5;
  text-align: center;
  padding: 20px;
}
#gate[hidden] { display: none; }
.gate-msg { color: #8a8a96; font-size: 15px; }

/* MOTD — shown on the cold-start gate only */
#motd {
  max-width: 46ch;
  text-align: center;
  color: #8a8a96;
  font-size: 14px;
  line-height: 1.6;
}
#motd[hidden] { display: none; }
#motd h2 {
  margin: 0 0 .6em;
  font-size: 15px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #e8e8ea;
}
#motd p { margin: 0 0 .8em; }
#motd p:last-child { margin-bottom: 0; }
#motd a { color: #e8e8ea; }
#startBtn { font-size: 20px; padding: 14px 34px; }
#startBtn[hidden] { display: none; }

/* only ever visible on the gate, so it disappears the moment you start */
.blurb {
  margin: 0;
  color: #55555f;
  font-size: 13px;
  animation: fade .5s ease-out .4s both;
}
.blurb kbd {
  font: inherit;
  border: 1px solid #33333d;
  border-radius: 4px;
  padding: 1px 6px;
  color: #8a8a96;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

/* brief tint on switch so the cut reads as intentional */
#flash {
  position: absolute; inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease-out;
}
#flash.on { opacity: .07; transition: none; }

/* ---------------- controls ---------------- */

#controls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #131317;
  border-top: 1px solid #22222a;
}
#showBtn { padding: 6px 10px; }
#app:not(.collapsed) #showBtn { opacity: .5; }
#seek { flex: 1; min-width: 60px; accent-color: #e8e8ea; }
#vol { width: 90px; accent-color: #8a8a96; }
.time { color: #8a8a96; font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.tabs { display: flex; gap: 6px; flex-wrap: nowrap; }
.tabs button { padding: 5px 10px; font-size: 13px; white-space: nowrap; }
.tabs button.on { background: #e8e8ea; color: #0d0d0f; border-color: #e8e8ea; }

/* side-angle sync nudger */
.syncbox {
  display: flex;
  align-items: center;
  gap: 2px;
  background: #1a1a20;
  border: 1px solid #2a2a33;
  border-radius: 6px;
  padding: 2px;
}
.syncbox button {
  border: 0;
  background: none;
  padding: 3px 8px;
  font-size: 15px;
  line-height: 1;
  color: #8a8a96;
}
.syncbox button:hover { background: #2a2a33; color: #e8e8ea; }
#sync {
  min-width: 104px;
  text-align: center;
  font-size: 12px;
  color: #8a8a96;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  user-select: none;
}
#sync:hover { color: #e8e8ea; }

/* ---------------- small screens ---------------- */

@media (max-width: 820px) {
  #sidebar { position: absolute; inset: 0 auto 0 0; z-index: 20; width: 82%; }
  #vol, .time { display: none; }
}


/* YT UI mode — shield steps aside so YouTube's own controls are reachable */
#app.unlocked #shield { pointer-events: none; }
.frame { pointer-events: none; }
.frame.active { pointer-events: auto; }

#ytBtn { font-size: 12px; color: #8a8a96; }
#ytBtn.on { background: #e8e8ea; color: #0d0d0f; border-color: #e8e8ea; }
