*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --ink: #f2f0ea;
  --dim: rgba(242,240,234,0.5);
  --glass: rgba(14,14,16,0.55);
  --accent: #e7c27a;
  --sans: 'Helvetica Neue', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
}
html, body { height: 100%; }
body {
  margin: 0; background: #000; color: var(--ink);
  font-family: var(--sans); overflow: hidden; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }

#bg { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
body.grabbing #bg { cursor: grabbing; }
body.grabbing { cursor: grabbing; }
#css3d { position: fixed; inset: 0; pointer-events: none; z-index: 1; }
#css3d iframe { border: 0; }

/* the on-wall screen */
/* the cinema screen = a black panel sized to the real HDRI screen recess;
   the video fills it and Vimeo auto-letterboxes within (black bg) */
.screen3d {
  width: 2080px; height: 940px;    /* ~2.21:1, fills the cinema screen recess */
  background: #000;
  box-shadow: 0 0 180px 70px rgba(231,194,122,0.10);
  pointer-events: none;
}
.screen-inner { width: 100%; height: 100%; pointer-events: none; }
.screen-inner iframe { width: 100%; height: 100%; pointer-events: auto; display: block; }


/* cinema vignette */
.vignette {
  position: fixed; inset: 0; z-index: 2; pointer-events: none;
  background: radial-gradient(120% 90% at 50% 45%, transparent 55%, rgba(0,0,0,0.5) 100%);
}

/* top bar */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.4rem;
  background: linear-gradient(to bottom, rgba(0,0,0,0.6), rgba(0,0,0,0.15) 70%, transparent);
}
.topbar::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
  background: linear-gradient(to right, transparent 6%, rgba(242,240,234,0.22) 50%, transparent 94%);
}
.home img { height: 24px; filter: invert(1); opacity: 0.92; }
.modes { display: flex; gap: 0.4rem; }
.mode {
  font-size: 0.68rem; letter-spacing: 0.18em; text-transform: uppercase;
  padding: 0.5rem 0.9rem; border-radius: 999px; color: var(--dim);
  border: 1px solid transparent; transition: color 0.2s, border-color 0.2s;
}
.mode.active { color: var(--ink); border-color: rgba(242,240,234,0.3); }
.mode[disabled] { opacity: 0.4; cursor: default; }
.toggles { display: flex; gap: 0.5rem; }
.tg {
  width: 46px; height: 42px; display: flex; align-items: center; justify-content: center;
  color: rgba(242,240,234,0.45); background: transparent; border: none; border-radius: 10px;
  transition: color .2s;
}
.tg svg { width: 25px; height: 25px; }
.tg:hover { color: var(--ink); }
.tg.active { color: var(--ink); }

/* now playing */
.nowplaying {
  position: fixed; top: 4.4rem; left: 1.5rem; z-index: 9;
  display: flex; flex-direction: column; gap: 0.2rem;
  text-shadow: 0 2px 16px rgba(0,0,0,0.7);
  opacity: 0; transform: translateY(-6px); transition: opacity 0.4s, transform 0.4s;
}
.nowplaying.show { opacity: 1; transform: translateY(0); }
.np-label { font-size: 0.58rem; letter-spacing: 0.26em; text-transform: uppercase; color: var(--accent); }
.np-title { font-size: 1.05rem; font-weight: 600; max-width: 60vw; }

/* drag hint */
.hint {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%); z-index: 8;
  font-size: 0.74rem; letter-spacing: 0.12em; color: rgba(242,240,234,0.85);
  background: rgba(0,0,0,0.4); padding: 0.7rem 1.2rem; border-radius: 999px;
  backdrop-filter: blur(6px); pointer-events: none; transition: opacity 0.5s;
}
.hint.hide { opacity: 0; }

/* mobile tilt-to-look enable button */
.gyro-cta {
  position: fixed; bottom: 6.5rem; left: 50%; transform: translateX(-50%); z-index: 9;
  display: none; align-items: center; gap: 0.5rem;
  padding: 0.62rem 1.1rem; border-radius: 999px;
  background: rgba(20,20,24,0.6); backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.16); color: var(--ink);
  font-size: 0.72rem; letter-spacing: 0.06em; cursor: pointer;
  animation: gyropulse 2.4s ease-in-out infinite;
}
.gyro-cta svg { width: 18px; height: 18px; flex: 0 0 auto; }
@keyframes gyropulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(231,194,122,0.0); }
  50%      { box-shadow: 0 0 0 5px rgba(231,194,122,0.07); }
}

/* ── bottom dock: stacked playback controls + library menu ──── */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; flex-direction: column; align-items: stretch;
  background: linear-gradient(to top, rgba(0,0,0,0.84), rgba(0,0,0,0.25) 78%, transparent);
  pointer-events: none;
}
.dock > * { pointer-events: auto; }

/* playback controls tray */
.controls-tray {
  display: flex; align-items: center; gap: 0.85rem;
  margin: 0.85rem 1.2rem 0.25rem; padding: 0.45rem 0.85rem;
  background: rgba(20,20,24,0.5); backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.09); border-radius: 14px;
  max-height: 58px; opacity: 1;
  transition: max-height .42s cubic-bezier(.16,1,.3,1), opacity .3s, margin .42s, padding .42s, transform .42s, border-width .42s;
}
.controls-tray.hidden {
  max-height: 0; opacity: 0; margin-top: 0; margin-bottom: 0;
  padding-top: 0; padding-bottom: 0; transform: translateY(6px);
  overflow: hidden; pointer-events: none; border-width: 0;
}
.ctl-btn {
  width: 34px; height: 34px; flex: 0 0 auto; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; color: var(--ink);
  transition: background .2s;
}
.ctl-btn:hover { background: rgba(255,255,255,0.1); }
.ctl-btn .ic { width: 19px; height: 19px; }
.ic-pause, .ic-voloff { display: none; }
.ctl-play.playing .ic-play { display: none; }
.ctl-play.playing .ic-pause { display: inline; }
.ctl-vol.muted .ic-volon { display: none; }
.ctl-vol.muted .ic-voloff { display: inline; }
.ctl-time { font-size: 0.72rem; font-variant-numeric: tabular-nums; color: var(--dim); flex: 0 0 auto; min-width: 32px; }
.ctl-dur { text-align: right; }
.ctl-scrub { flex: 1 1 auto; }
.ctl-volslider { flex: 0 0 70px; }
.ctl-scrub, .ctl-volslider {
  -webkit-appearance: none; appearance: none; height: 4px; border-radius: 999px;
  background: rgba(255,255,255,0.2); cursor: pointer; outline: none;
}
.ctl-scrub::-webkit-slider-thumb, .ctl-volslider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 13px; height: 13px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 3px rgba(231,194,122,0.18); transition: transform .15s;
}
.ctl-scrub::-webkit-slider-thumb:hover, .ctl-volslider::-webkit-slider-thumb:hover { transform: scale(1.18); }
.ctl-scrub::-moz-range-thumb, .ctl-volslider::-moz-range-thumb {
  width: 13px; height: 13px; border: none; border-radius: 50%; background: var(--accent);
}

/* ── the library menu (in-flow inside the dock) ─────────────── */
.remote {
  padding: 0.5rem 1.2rem 1.0rem;
  max-height: 240px; opacity: 1;
  transition: max-height .45s cubic-bezier(.16,1,.3,1), opacity .3s, padding .45s;
}
.remote.hidden { max-height: 0; opacity: 0; padding-top: 0; padding-bottom: 0; overflow: hidden; pointer-events: none; }
.remote-cats {
  display: flex; gap: 0.45rem; overflow-x: auto; padding-bottom: 0.7rem;
  scrollbar-width: none;
}
.remote-cats::-webkit-scrollbar { display: none; }
.cat {
  flex: 0 0 auto; font-size: 0.66rem; letter-spacing: 0.1em; text-transform: uppercase;
  padding: 0.45rem 0.85rem; border-radius: 999px; white-space: nowrap;
  background: rgba(255,255,255,0.08); color: rgba(242,240,234,0.7);
  transition: background 0.2s, color 0.2s;
}
.cat.active { background: var(--ink); color: #111; }
.cat .cat-n { opacity: 0.5; margin-left: 0.35rem; }

.remote-rail {
  display: flex; gap: 0.7rem; overflow-x: auto; padding: 0.2rem 0 0.2rem;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.remote-rail::-webkit-scrollbar { display: none; }
.thumb {
  flex: 0 0 auto; position: relative; width: 168px; height: 95px;
  border-radius: 8px; overflow: hidden; background: #1a1a1a center/cover no-repeat;
  outline: 2px solid transparent; outline-offset: 2px;
  transition: outline-color 0.2s, transform 0.2s;
}
.thumb:hover { transform: translateY(-2px); }
.thumb.active { outline-color: var(--accent); }
.thumb::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.7), transparent 55%);
}
.thumb-title {
  position: absolute; left: 8px; right: 8px; bottom: 6px; z-index: 2;
  font-size: 0.64rem; line-height: 1.2; color: #fff;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.thumb-dur {
  position: absolute; top: 6px; right: 6px; z-index: 2;
  font-size: 0.58rem; background: rgba(0,0,0,0.65); padding: 0.1rem 0.35rem; border-radius: 4px;
  font-variant-numeric: tabular-nums;
}
.thumb-port { position: absolute; top: 6px; left: 6px; z-index: 2; font-size: 0.7rem; opacity: 0.85; }

/* loader */
.loader {
  position: fixed; inset: 0; z-index: 50; background: #000;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.8s ease;
}
.loader.hidden { opacity: 0; pointer-events: none; }
.loader-inner { display: flex; flex-direction: column; align-items: center; gap: 1.1rem; }
.loader-bar { width: 150px; height: 1px; background: rgba(255,255,255,0.18); overflow: hidden; position: relative; }
.loader-bar i { position: absolute; top: 0; left: 0; height: 100%; width: 40%; background: var(--accent); animation: slide 1.2s cubic-bezier(0.65,0,0.35,1) infinite; }
@keyframes slide { 0%{transform:translateX(-100%)} 50%{transform:translateX(150%)} 100%{transform:translateX(400%)} }
.loader-label { font-size: 0.62rem; letter-spacing: 0.4em; text-transform: uppercase; color: var(--dim); padding-left: 0.4em; }

@media (max-width: 640px) {
  .thumb { width: 132px; height: 75px; }
  .np-title { max-width: 78vw; font-size: 0.95rem; }
  .nowplaying { top: 3.5rem; left: 1rem; }

  /* top bar fits a phone */
  .topbar { padding: 0.7rem 0.9rem; }
  .home img { height: 21px; }
  .mode { padding: 0.42rem 0.7rem; font-size: 0.6rem; letter-spacing: 0.12em; }
  .modes { gap: 0.2rem; }
  .toggles { gap: 0.25rem; }
  .tg { width: 40px; height: 38px; }
  .tg svg { width: 22px; height: 22px; }

  /* controls tray: drop the volume slider (phones use hardware volume), tighten */
  .ctl-volslider { display: none; }
  .controls-tray { gap: 0.5rem; margin: 0.55rem 0.7rem 0.2rem; padding: 0.38rem 0.6rem; }
  .ctl-btn { width: 32px; height: 32px; }
  .ctl-btn .ic { width: 18px; height: 18px; }
  .ctl-time { font-size: 0.68rem; min-width: 30px; }
  .remote { padding: 0.45rem 0.7rem 0.9rem; }
}

/* ── no-WebGL / opt-in grid fallback (body.grid-mode) ──────────── */
body.grid-mode #bg, body.grid-mode #css3d, body.grid-mode .vignette,
body.grid-mode .dock, body.grid-mode .hint, body.grid-mode .nowplaying,
body.grid-mode .modes, body.grid-mode .toggles { display: none !important; }
.grid-view { display: none; }
body.grid-mode .grid-view { display: block; }
.grid-view {
  position: fixed; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: #060606; padding: 4.5rem 1.1rem 3rem; z-index: 6;
}
.grid-head { text-align: center; margin: 0 auto 1.6rem; max-width: 60rem; }
.grid-head h1 { font-size: 0.72rem; letter-spacing: 0.4em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.grid-head p { font-size: 0.8rem; color: var(--dim); margin-top: 0.5rem; }
.grid-cats { display: flex; gap: 0.45rem; overflow-x: auto; scrollbar-width: none; padding: 0 0 1.1rem; max-width: 70rem; margin: 0 auto; }
.grid-cats::-webkit-scrollbar { display: none; }
.grid-items {
  display: grid; gap: 0.7rem; max-width: 70rem; margin: 0 auto;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}
.gitem {
  position: relative; aspect-ratio: 16/9; border-radius: 10px; overflow: hidden;
  background: #1a1a1a center/cover no-repeat; cursor: pointer; border: none; padding: 0;
  outline: 2px solid transparent; outline-offset: 2px; transition: outline-color .2s, transform .2s;
}
.gitem:hover { transform: translateY(-2px); outline-color: var(--accent); }
.gitem::after { content: ''; position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,0.75), transparent 55%); }
.gitem-t { position: absolute; left: 8px; right: 8px; bottom: 7px; z-index: 2; font-size: 0.7rem; line-height: 1.2; color: #fff; text-align: left;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.gitem-d { position: absolute; top: 7px; right: 7px; z-index: 2; font-size: 0.6rem; background: rgba(0,0,0,0.65); padding: 0.1rem 0.35rem; border-radius: 4px; font-variant-numeric: tabular-nums; }

/* lightbox player */
.lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,0.92); display: none; align-items: center; justify-content: center; padding: 1rem; }
.lightbox.show { display: flex; }
.lightbox-inner { width: min(100%, 1100px); aspect-ratio: 16/9; background: #000; border-radius: 8px; overflow: hidden; }
.lightbox-inner iframe { width: 100%; height: 100%; border: 0; }
.lightbox-close { position: fixed; top: 1.2rem; right: 1.3rem; z-index: 61; width: 42px; height: 42px; border-radius: 50%;
  background: rgba(20,20,24,0.7); border: 1px solid rgba(255,255,255,0.14); color: var(--ink); font-size: 1.2rem; cursor: pointer; }
