:root {
  color-scheme: dark;
  --text: #f7f8fb;
  --muted: #aab6c8;
  --accent: #78b7ff;
  --panel: #121b2d;
  --border: #ffffff19;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  background: radial-gradient(circle at 20% -10%, #477dff30, transparent 32rem),
              radial-gradient(circle at 85% 5%, #66ffcc10, transparent 28rem), #0a0d16;
}

h1, h2, p { margin: 0; }
button, input { font: inherit; }
button {
  min-height: 44px;
  padding: 8px 16px;
  color: inherit;
  background: linear-gradient(#ffffff12, #ffffff05);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  touch-action: manipulation;
}
button:hover { background-color: #ffffff12; }
button:disabled { opacity: .38; cursor: default; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
button[aria-pressed=true], .views [aria-current] {
  color: var(--accent);
  background: #78b7ff1a;
  border-color: #78b7ff55;
}
svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  flex: none;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.topbar img { border-radius: 11px; }
.topbar h1 { flex: 1; font-size: clamp(16px, 2vw, 21px); line-height: 1.25; }
small { display: block; color: var(--muted); font-size: 13px; font-weight: 400; }
.topbar small { margin-top: 3px; }
.views { display: flex; justify-content: center; gap: 8px; padding: 12px; }
.views button { min-width: 120px; }
.eyebrow { color: var(--accent); font-size: 11px; font-weight: 700; letter-spacing: .18em; margin-bottom: 6px; }
#library { max-width: 860px; margin: auto; padding: 18px 20px 245px; }
#library h2 { font-size: clamp(25px, 4vw, 34px); letter-spacing: -.035em; }
.browse, #crumbs { display: flex; align-items: center; gap: 6px; }
.browse { margin: 14px 0; }
#crumbs { flex-wrap: wrap; }
#crumbs button { background: none; border: 0; color: var(--muted); font-size: 13px; padding: 6px 9px; }
#filter {
  width: 100%;
  min-height: 50px;
  padding: 10px 16px;
  margin-bottom: 14px;
  color: inherit;
  background: #080d18;
  border: 1px solid var(--border);
  border-radius: 16px;
}
.items { display: grid; gap: 9px; }
.row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  min-height: 72px;
  text-align: left;
  border-radius: 17px;
  background: linear-gradient(135deg, #1b273f, #121b2d);
}
.row[aria-current] { border-color: #78b7ff88; background: #78b7ff20; }
.row img, .details img { flex: none; object-fit: contain; background: #000; border-radius: 10px; }
.row strong, .row small { overflow-wrap: anywhere; }
.row .row-label { flex: 1; min-width: 0; }
.folder-mark { color: var(--accent); font-size: 24px; }
.empty { color: var(--muted); padding: 14px 0; }

#player { max-width: 1360px; margin: auto; padding: 0 20px max(14px, env(safe-area-inset-bottom)); }
.stage {
  position: relative;
  overflow: hidden;
  height: clamp(200px, 52vh, 760px);
  height: clamp(200px, 52dvh, 760px);
  background: #000;
  border-radius: 20px;
}
video { display: block; width: 100%; height: 100%; object-fit: contain; }
video.fill { object-fit: cover; }
.stage-top { display: none; }
.tv {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  background: radial-gradient(ellipse at top, #203b61, #080d18);
  text-align: center;
}
.details {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  background: none;
  border: 0;
  border-radius: 12px;
  padding: 8px 0 0;
  max-width: 100%;
}
.details span { min-width: 0; }
.details strong, .details small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.controls { max-width: 860px; margin: auto; }
.timeline { display: flex; align-items: center; gap: 10px; padding: 7px 0; color: var(--muted); font: 12px ui-monospace, monospace; }
.timeline span { min-width: 42px; }
.timeline span:last-child { text-align: right; }
.timeline input { flex: 1; min-width: 0; height: 26px; accent-color: var(--accent); }
.transport { display: flex; justify-content: center; align-items: center; gap: clamp(2px, 1.5vw, 14px); }
.primary { width: 58px; height: 58px; background: linear-gradient(135deg, #9ccaff, #477dff); color: #081121; }
.primary svg { width: 26px; height: 26px; fill: currentColor; }
#fit { font-size: 12px; }
#repeatOne { position: absolute; font-size: 10px; background: var(--panel); }
#notice { padding: 9px 13px; margin-top: 8px; background: #14233b; border-radius: 12px; color: #dbeaff; font-size: 13px; }
body:not([data-view=library]) #library { display: none; }
body:not([data-view=playing]) #player:not(.immersive) {
  position: fixed;
  inset: auto 0 0;
  z-index: 5;
  max-width: none;
  padding-inline: max(12px, calc((100vw - 820px) / 2));
  border-top: 1px solid var(--border);
  background: #10192bf5;
}
body:not([data-view=playing]) #player:not(.immersive) .stage { display: none; }
body:not([data-view=playing]) #fit { display: none; }

/* The same overlay also works when an embedded browser denies native fullscreen. */
body.fullscreen-open { overflow: hidden; }
#player.immersive {
  position: fixed;
  inset: 0;
  z-index: 100;
  max-width: none;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  background: #000;
}
.immersive .stage { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 0; }
.immersive .details { display: none; }
.immersive .stage-top {
  position: absolute;
  inset: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(8px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 30px max(16px, env(safe-area-inset-left));
  background: linear-gradient(#000b, transparent);
}
.stage-top strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.immersive .controls {
  position: absolute;
  inset: auto 0 0;
  max-width: none;
  padding: 22px max(16px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: linear-gradient(transparent, #000e);
}
.immersive .timeline { max-width: 900px; margin: auto; }
.immersive #notice { position: absolute; inset: 65px 5% auto; }
.immersive .stage-top, .immersive .controls { transition: opacity .18s; }
.immersive.ui-hidden .stage-top, .immersive.ui-hidden .controls { opacity: 0; pointer-events: none; }
.immersive.ui-hidden { cursor: none; }

@media (max-width: 480px) {
  #player, #library { padding-inline: 12px; }
  .topbar { gap: 8px; }
  .topbar img { width: 34px; height: 34px; }
  .transport .icon { width: 42px; height: 44px; }
  .transport .primary { width: 49px; height: 49px; }
  .transport { gap: 2px; }
  .immersive .controls { padding-inline: max(8px, env(safe-area-inset-left)) max(8px, env(safe-area-inset-right)); }
}
@media (orientation: landscape) and (max-height: 600px) {
  .topbar { min-height: 55px; }
  .views { padding: 5px; }
  .stage { height: max(140px, calc(100dvh - 244px)); }
  .details img { width: 40px; height: 40px; }
  .timeline { padding-block: 1px; }
}
@media (prefers-reduced-motion: reduce) {
  .immersive .stage-top, .immersive .controls { transition: none; }
}

@media (max-width: 345px) {
  .transport .icon { width: 38px; }
  .transport .primary { width: 46px; }
}

.info-panel {
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 24px;
  background: linear-gradient(140deg, #273346, #0f1724);
  box-shadow: inset 0 1px 0 #ffffff14, 0 24px 70px #0005;
}
#menuPanel {
  position: fixed;
  inset: var(--menu-top, 80px) max(12px, env(safe-area-inset-right)) auto auto;
  width: min(360px, calc(100% - 24px));
  max-height: calc(100vh - var(--menu-top, 80px) - 12px);
  max-height: calc(100dvh - var(--menu-top, 80px) - 12px);
  margin: 0;
  padding: 16px;
  overscroll-behavior: contain;
}
#menuPanel::backdrop { background: #02060c99; }
#menuPanel h2 { font-size: 19px; }
#menuPanel .row { width: 100%; min-height: 60px; padding: 10px; background: #ffffff08; }
#menuPanel .row:hover { background: #ffffff12; }
#menuPanel .row svg { flex: none; color: var(--accent); }
#menuPanel .row strong { font-size: 14px; }
.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.close-button { width: 44px; height: 44px; font-size: 24px; }
#about { max-width: 800px; margin: auto; padding: 18px 16px 245px; }
.about-card { padding: clamp(18px, 4vw, 32px); }
.about-card h2 { font-size: clamp(24px, 4vw, 32px); letter-spacing: -.03em; }
.about-copy { color: var(--muted); }
.about-copy strong, .about-copy h3 { color: var(--text); }
.about-copy p + p { margin-top: 8px; }
.about-copy h3 { margin: 18px 0 4px; font-size: 16px; }

@media (max-width: 480px) {
  .topbar .icon { width: 44px; height: 44px; }
}