/* The store's interface: calm dark glass over the 3D view. The theme
   colours (set from themes.js) are used sparingly: the primary button,
   focus rings and small accents. Everything else is neutral. */
:root {
  --theme-bg: #0b0416;
  --theme-panel: rgba(20, 8, 38, 0.90);
  --theme-primary: #ff2a85;
  --theme-accent: #00f0ff;
  --theme-gold: #ffb800;
  --theme-text: #f8fafc;
  --theme-muted: #cbd5e1;
  --theme-danger: #ef4444;
  --theme-success: #22c55e;

  --ui-bg: rgba(18, 15, 26, 0.84);
  --ui-bg-solid: #17131f;
  --ui-raise: rgba(255, 255, 255, 0.055);
  --ui-raise-hover: rgba(255, 255, 255, 0.10);
  --ui-line: rgba(255, 255, 255, 0.10);
  --ui-text: #f1edf6;
  --ui-muted: #a8a1b6;
  --ui-faint: #7d768b;
  --ui-accent: color-mix(in srgb, var(--theme-primary) 72%, #3a2a3a);
  --ui-accent-soft: color-mix(in srgb, var(--theme-primary) 18%, transparent);
  --ui-warm: #f2c879;
  --ui-radius: 12px;
  --ui-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; }
html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: var(--theme-bg);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px; color: var(--ui-text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
kbd {
  display: inline-block; min-width: 20px; padding: 1px 5px; margin: 0 1px;
  border-radius: 5px; border: 1px solid var(--ui-line); background: var(--ui-raise);
  font: 600 11px/1.5 inherit; font-family: inherit; color: var(--ui-text); text-align: center;
}
.icon {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}
:focus-visible { outline: 2px solid color-mix(in srgb, var(--theme-primary) 70%, white); outline-offset: 2px; }

#canvas-container {
  position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 1; cursor: grab;
}
#canvas-container:active { cursor: grabbing; }
#canvas-container.hovering-vhs { cursor: pointer !important; }

/* ---- Top bar ---- */
.top-hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: grid; grid-template-columns: 1fr minmax(260px, 460px) 1fr; align-items: center; gap: 14px;
  padding: 12px 18px 22px;
  background: linear-gradient(180deg, rgba(8, 6, 14, 0.78) 0%, rgba(8, 6, 14, 0.42) 62%, transparent 100%);
  pointer-events: none;
}
.top-hud > * { pointer-events: auto; }

.brand {
  justify-self: start; display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  background: none; border: 0; padding: 4px 6px 4px 12px; border-left: 3px solid var(--ui-accent);
  border-radius: 2px; text-align: left;
}
.brand-mark {
  font-weight: 800; font-size: 17px; letter-spacing: 0.08em; text-transform: uppercase; color: #fff;
  line-height: 1.1; white-space: nowrap;
}
.brand-sub { font-size: 12px; color: var(--ui-muted); }
.brand:hover .brand-mark { color: var(--ui-warm); }

.search-box { position: relative; display: flex; align-items: center; }
.search-box .search-icon { position: absolute; left: 14px; z-index: 1; color: var(--ui-muted); pointer-events: none; }
.search-box input {
  width: 100%; height: 42px; padding: 0 40px 0 40px; border-radius: 999px;
  border: 1px solid var(--ui-line); background: var(--ui-bg);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  color: var(--ui-text); font-size: 14.5px; outline: none; user-select: text;
  box-shadow: var(--ui-shadow); transition: border-color 0.15s, background 0.15s;
}
.search-box input::placeholder { color: var(--ui-faint); }
.search-box input:focus { border-color: color-mix(in srgb, var(--theme-primary) 55%, transparent); background: var(--ui-bg-solid); }
.search-clear {
  position: absolute; right: 8px; z-index: 1; width: 28px; height: 28px; border-radius: 50%;
  display: none; align-items: center; justify-content: center;
  background: none; border: 0; color: var(--ui-muted);
}
.search-clear:hover { background: var(--ui-raise-hover); color: var(--ui-text); }
.search-clear .icon { width: 15px; height: 15px; }

.search-results {
  position: absolute; top: 50px; left: 0; right: 0; z-index: 30;
  background: var(--ui-bg-solid); border: 1px solid var(--ui-line); border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6); padding: 6px; max-height: 62vh; overflow-y: auto;
}
.result {
  display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 12px;
  width: 100%; padding: 7px 10px; border: 0; border-radius: 9px; background: none; text-align: left;
}
.result:hover, .result.selected { background: var(--ui-raise-hover); }
.result-thumb {
  width: 34px; height: 48px; border-radius: 4px; background: #2a2333 center/cover no-repeat;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.result-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.result-title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-title mark { background: none; color: var(--ui-warm); }
.result-meta { font-size: 12px; color: var(--ui-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-where { font-size: 12px; color: var(--ui-faint); white-space: nowrap; }
.results-empty { padding: 14px 12px; color: var(--ui-muted); font-size: 13px; }
.results-all {
  display: block; width: 100%; margin-top: 4px; padding: 10px 12px; border: 0; border-top: 1px solid var(--ui-line);
  border-radius: 0 0 9px 9px; background: none; color: var(--ui-warm); font-size: 13px; font-weight: 600; text-align: left;
}
.results-all:hover { background: var(--ui-raise); }

.hud-controls { justify-self: end; display: flex; align-items: center; gap: 6px; }
/* Never squeezed into two lines (that spills out of the pill); when the
   bar is too narrow for the labels, store.js drops them instead
   (Windows' display scaling and fonts make it narrower than it looks). */
.hud-controls > * { flex-shrink: 0; }
.hud-btn, .view-switch .tab { white-space: nowrap; }
.top-hud.fit-1 .hud-btn:not(.unlock-btn) span { display: none; }
.top-hud.fit-1 .hud-btn:not(.unlock-btn) { width: 40px; padding: 0; justify-content: center; }
.top-hud.fit-2 .view-switch .tab span { display: none; }
.top-hud.fit-2 .view-switch .tab { padding: 0 10px; }
.top-hud.fit-3 .unlock-btn span { display: none; }
.top-hud.fit-3 .unlock-btn { width: 40px; padding: 0; justify-content: center; }
.hud-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--ui-line); background: var(--ui-bg);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  color: var(--ui-text); font-size: 13.5px; font-weight: 600; box-shadow: var(--ui-shadow);
  transition: background 0.15s, border-color 0.15s;
}
.hud-btn:hover { background: var(--ui-bg-solid); border-color: rgba(255, 255, 255, 0.2); }
.hud-btn[aria-expanded="true"] { background: var(--ui-bg-solid); border-color: color-mix(in srgb, var(--theme-primary) 55%, transparent); }
.hud-btn.icon-only { width: 40px; padding: 0; justify-content: center; }

/* ---- Panels: directory and settings ---- */
.directory, .settings-menu {
  position: fixed; z-index: 25; background: var(--ui-bg);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--ui-line); border-radius: 16px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}
.directory {
  top: 72px; left: 18px; width: 380px; max-width: calc(100vw - 36px); max-height: calc(100vh - 140px);
  display: flex; flex-direction: column;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 14px 10px 18px;
}
.panel-head h2 { font-size: 16px; font-weight: 700; letter-spacing: 0.01em; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 50%; border: 0; background: none; color: var(--ui-muted);
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--ui-raise-hover); color: var(--ui-text); }
.directory-body { overflow-y: auto; padding: 0 14px 16px; display: flex; flex-direction: column; gap: 16px; }
.dir-section { display: flex; flex-direction: column; gap: 8px; }
.dir-heading {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ui-faint);
  padding: 0 4px;
}
.dir-heading .count { letter-spacing: 0; text-transform: none; font-weight: 500; }
.dir-list { display: flex; flex-direction: column; gap: 2px; }
.dir-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 10px; border-radius: 9px; border: 0; background: none; text-align: left; font-size: 14px;
}
.dir-item:hover { background: var(--ui-raise-hover); }
.dir-item .sub { font-size: 12px; color: var(--ui-faint); }
.dir-item.active { background: var(--ui-accent-soft); }
.dir-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 6px; }
.aisle-tile {
  display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 8px 4px;
  border-radius: 9px; border: 1px solid var(--ui-line); background: var(--ui-raise);
  font-weight: 700; font-size: 14px; transition: background 0.12s, border-color 0.12s;
}
.aisle-tile .sub { font-weight: 500; font-size: 11px; color: var(--ui-faint); }
.aisle-tile:hover { background: var(--ui-raise-hover); border-color: rgba(255, 255, 255, 0.2); }
.aisle-tile.active { border-color: color-mix(in srgb, var(--theme-primary) 60%, transparent); background: var(--ui-accent-soft); }

.settings-menu {
  top: 66px; right: 18px; width: 320px; max-width: calc(100vw - 36px); padding: 8px 0;
  max-height: calc(100vh - 84px); overflow-y: auto; overscroll-behavior: contain;
}
.settings-row { padding: 10px 18px; display: flex; flex-direction: column; gap: 8px; }
.settings-row + .settings-row { border-top: 1px solid var(--ui-line); }
.settings-row label, .settings-label {
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ui-faint);
}
.theme-select {
  width: 100%; height: 38px; padding: 0 10px; border-radius: 9px;
  border: 1px solid var(--ui-line); background: var(--ui-raise); color: var(--ui-text); outline: none;
}
.theme-select option { background: var(--ui-bg-solid); }
.size-tabs .tab { flex: 1; }
.size-note { margin: 0; font-size: 12.5px; line-height: 1.45; color: var(--ui-muted); }
.size-warn { margin: 0; font-size: 12.5px; line-height: 1.45; color: var(--ui-warm); }
.library-status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ui-text); line-height: 1.4; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--ui-warm); }
.status-dot.connected { background: #6fcf8e; }
.art-status {
  align-self: flex-start; padding: 0; border: 0; background: none;
  font-size: 12.5px; color: var(--ui-muted); text-align: left;
}
.art-status:hover { color: var(--ui-text); }
.art-status.has-failures { color: var(--ui-warm); }
.connected-servers { display: flex; flex-direction: column; gap: 8px; }
.connected-servers:empty { display: none; }
.server-card {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center;
  padding: 9px 11px; border-radius: 10px; border: 1px solid var(--ui-line); background: var(--ui-raise);
}
.server-card .server-name { font-size: 13px; font-weight: 600; color: var(--ui-text); line-height: 1.35; min-width: 0; overflow-wrap: anywhere; }
.server-card .server-sub { grid-column: 1 / -1; font-size: 12px; line-height: 1.45; color: var(--ui-muted); }
.server-card .server-libs { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px; }
.server-card .lib-chip {
  font-size: 11.5px; line-height: 1; padding: 5px 7px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.06); color: var(--ui-text); white-space: nowrap;
}
.server-card .lib-chip.off { color: var(--ui-faint); text-decoration: line-through; }
.signout-btn {
  height: 28px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--ui-line);
  background: none; color: var(--ui-muted); font-size: 12px; font-weight: 600; white-space: nowrap;
}
.signout-btn:hover { color: var(--ui-text); border-color: rgba(255, 255, 255, 0.25); }
.signout-btn.confirm { color: #fff; background: #b4233c; border-color: transparent; }
.library-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.library-actions .ui-btn { flex: 1; height: 34px; font-size: 12.5px; padding: 0 10px; }
.connected-servers.in-dialog { margin-bottom: 12px; }
.controls-list { list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ui-muted); }
.link-btn {
  align-self: flex-start; padding: 0; border: 0; background: none;
  color: var(--ui-warm); font-size: 13px; font-weight: 600;
}
.link-btn:hover { text-decoration: underline; }

/* ---- Buttons ---- */
.ui-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: 10px;
  font-weight: 600; font-size: 14px; border: 1px solid var(--ui-line);
  background: var(--ui-raise); color: var(--ui-text); transition: background 0.15s, border-color 0.15s, filter 0.15s;
}
.ui-btn:hover { background: var(--ui-raise-hover); border-color: rgba(255, 255, 255, 0.2); }
.ui-btn.primary { background: var(--ui-accent); border-color: transparent; color: #fff; }
.ui-btn.primary:hover { filter: brightness(1.12); background: var(--ui-accent); }
.ui-btn.secondary { background: var(--ui-raise); }
.ui-btn.wide { width: 100%; }

#reticle {
  position: fixed; top: 50%; left: 50%; width: 6px; height: 6px;
  transform: translate(-50%, -50%); border-radius: 50%; z-index: 10; pointer-events: none;
  background: rgba(255, 255, 255, 0.55); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
  transition: width 0.15s, height 0.15s, background 0.15s;
}
#reticle.active { width: 14px; height: 14px; background: transparent; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.75); }

#hover-tooltip {
  position: fixed; bottom: 70px; left: 50%; transform: translateX(-50%);
  z-index: 18; background: var(--ui-bg); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--ui-line); border-radius: 999px; padding: 8px 18px; display: none;
  align-items: center; gap: 10px; box-shadow: var(--ui-shadow); pointer-events: none;
}
#hover-tooltip .title { font-weight: 600; font-size: 14px; color: #fff; }
/* What a key does here (game-style controls; Thomas wants it shown). */
#hover-tooltip .tip-action { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ui-warm); white-space: nowrap; }
#hover-tooltip .tip-action[hidden] { display: none; }
#key-bar {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 16; pointer-events: none;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; max-width: calc(100vw - 340px);
  font-size: 12.5px; color: var(--ui-muted); background: rgba(18, 15, 26, 0.55); border-radius: 999px; padding: 5px 14px;
}
#key-bar[hidden] { display: none; }
#key-bar span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
body.touch #key-bar { display: none; }
body:has(#inspect-dock.open) #hover-tooltip,
body:has(#settings-menu:not([hidden])) #hover-tooltip,
body:has(#directory:not([hidden])) #hover-tooltip { display: none !important; }
/* First visit: the prompt sits above the welcome card, not over its text. */
body:has(#welcome-card:not([hidden])) #hover-tooltip { bottom: 210px; }
#hover-tooltip .meta { font-size: 12.5px; color: var(--ui-muted); }

/* ---- The tape in your hands ---- */
#inspect-dock {
  position: fixed; right: 24px; top: 50%;
  transform: translateY(-50%) translateX(24px);
  width: 380px; max-width: calc(100vw - 40px); max-height: calc(100vh - 140px); overflow-y: auto; z-index: 35;
  background: var(--ui-bg); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--ui-line); border-radius: 18px; padding: 22px 22px 20px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
  display: none; flex-direction: column; gap: 12px; opacity: 0; transition: opacity 0.22s ease, transform 0.22s ease;
}
#inspect-dock.open { display: flex; opacity: 1; transform: translateY(-50%) translateX(0); }
.dock-close { position: absolute; top: 12px; right: 12px; }
.inspect-title { font-size: 23px; font-weight: 750; line-height: 1.2; color: #fff; padding-right: 32px; }
.inspect-badge-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rating-badge {
  border: 1px solid rgba(255, 255, 255, 0.55); padding: 1px 6px; border-radius: 4px;
  font-weight: 700; font-size: 11.5px; color: #fff;
}
.spec-badge { color: var(--ui-muted); font-size: 13px; }
.spec-badge + .spec-badge::before { content: "·"; margin-right: 6px; color: var(--ui-faint); }
.inspect-genres { display: flex; gap: 6px; flex-wrap: wrap; }
.inspect-genre-tag {
  background: var(--ui-raise); border: 1px solid var(--ui-line); color: var(--ui-text);
  font-size: 12px; padding: 3px 10px; border-radius: 999px;
}
.inspect-summary {
  font-size: 14px; line-height: 1.6; color: #d9d3e2; max-height: 150px; overflow-y: auto; user-select: text;
}
.inspect-credits { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.credit-item { display: grid; grid-template-columns: 72px 1fr; gap: 8px; }
.credit-item dt { color: var(--ui-faint); }
.credit-item dd { color: var(--ui-text); }
.inspect-rental-note { font-size: 13px; color: var(--ui-warm); }
.inspect-rental-note:empty { display: none; }
.inspect-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.inspect-actions-row { display: flex; gap: 8px; }
.inspect-actions .ui-btn { flex: 1; min-height: 44px; }
.ui-btn .btn-key { margin-left: 8px; background: rgba(0, 0, 0, 0.22); border-color: rgba(255, 255, 255, 0.28); color: inherit; }
body.touch .ui-btn .btn-key { display: none; }
#btn-play-fullscreen { font-size: 15px; }

/* ---- Bottom: where you are, and a one-time welcome ---- */
.bottom-hud {
  position: fixed; bottom: 16px; left: 18px; right: 18px; z-index: 15;
  display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; pointer-events: none;
}
.where {
  padding: 7px 14px; border-radius: 999px; background: var(--ui-bg);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--ui-line); font-size: 12.5px; color: var(--ui-muted); box-shadow: var(--ui-shadow);
}
.where:empty { display: none; }
.welcome-card {
  pointer-events: auto; max-width: 420px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start;
  padding: 16px 18px; border-radius: 16px; background: var(--ui-bg);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--ui-line); box-shadow: var(--ui-shadow); font-size: 13.5px; line-height: 1.55; color: var(--ui-muted);
}
.welcome-card strong { color: var(--ui-text); font-size: 15px; }
.welcome-card .ui-btn { min-height: 34px; padding: 0 14px; font-size: 13px; }

/* ---- Player ---- */
#player-modal {
  position: fixed; inset: 0; z-index: 60; background: #000;
  display: none; flex-direction: column;
}
#player-modal.open { display: flex; }
.player-topbar {
  /* Over the picture, not above it: the film fills the screen and the bar
     fades away with the control bar. */
  position: absolute; top: 0; left: 0; right: 0; z-index: 6;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 18px 30px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.78), rgba(0, 0, 0, 0.4) 60%, transparent);
  transition: opacity 0.35s;
}
#player-modal.controls-idle .player-topbar { opacity: 0; pointer-events: none; }
.player-topbar .ui-btn.secondary { background: rgba(20, 16, 28, 0.55); }
.player-now-playing { display: flex; flex-direction: column; align-items: center; min-width: 0; flex: 1; }
#player-movie-title { font-size: 15px; font-weight: 650; color: #fff; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8); }
#player-stream-mode { font-size: 12px; color: rgba(255, 255, 255, 0.72); text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9); }
.player-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.player-topbar .ui-btn { min-height: 36px; padding: 0 13px; font-size: 13px; }
.player-stage {
  position: relative; flex: 1; display: flex; align-items: center;
  justify-content: center; background: #000; overflow: hidden;
}
#movie-video { width: 100%; height: 100%; max-height: 100vh; outline: none; background: #000; }
/* Drawn by the page itself, never handed to the graphics card as a
   separate layer: on Windows a 4K 10-bit film shown that way covered the
   controls (Thomas's laptop, RTX 4070 at 150% scaling). Not visible, and
   no dropped frames. */
#movie-video { opacity: 0.999; }
#movie-video::-webkit-media-text-track-container { transform: translateY(-64px); transition: transform 0.35s; }
#player-modal.controls-idle #movie-video::-webkit-media-text-track-container { transform: none; }
.vhs-osd {
  position: absolute; top: 78px; left: 32px; font-family: 'Courier New', monospace;
  font-size: 20px; font-weight: 700; color: #4ade80; text-shadow: 2px 2px 0 #000;
  pointer-events: none; opacity: 0; transition: opacity 0.4s;
}
.vhs-osd.visible { opacity: 0.9; }
.player-notice {
  position: absolute; bottom: 96px; left: 50%; transform: translateX(-50%); max-width: 80%;
  background: rgba(15, 12, 20, 0.88); border: 1px solid var(--ui-line); color: var(--ui-text);
  padding: 10px 16px; border-radius: 10px; font-size: 13px; text-align: center; z-index: 3;
}

/* ---- Dialogs: library and continue watching ---- */
#plex-modal, #rentals-modal, #unlock-modal {
  position: fixed; inset: 0; z-index: 50; background: rgba(6, 4, 10, 0.62);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: none; align-items: center; justify-content: center; padding: 20px;
}
#plex-modal.open, #rentals-modal.open, #unlock-modal.open { display: flex; }
/* The free version's unlock offer. */
#unlock-modal { z-index: 60; }
.unlock-dialog { max-width: 460px; }
.unlock-lead { margin: 0; color: var(--ui-text); font-size: 14.5px; line-height: 1.5; }
.unlock-list { margin: 0; padding-left: 20px; color: var(--ui-muted); font-size: 13.5px; line-height: 1.7; }
.unlock-actions { display: flex; gap: 10px; }
.unlock-actions > * { flex: 1; }
.unlock-buy { min-height: 46px; font-size: 15px; }
.unlock-was { margin: -6px 0 0; font-size: 12.5px; color: var(--ui-faint); text-align: center; }
.unlock-was:empty { display: none; }
.unlock-buy:disabled { opacity: 0.55; cursor: default; }
.unlock-status { margin: 0; min-height: 1em; font-size: 13px; color: var(--ui-warm); }
.unlock-status:empty { display: none; }
.unlock-restore { margin: 0; font-size: 12.5px; color: var(--ui-faint); }
.top-hud .unlock-btn { background: var(--ui-accent); border-color: transparent; color: #fff; }
.top-hud .unlock-btn:hover { background: var(--ui-accent); filter: brightness(1.1); }
/* Free version: what needs the unlock is marked (a dot on Simple, a tag
   in Settings). */
.lock-tag { display: none; }
body.locked .lock-tag {
  display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; vertical-align: 1px;
  background: var(--ui-accent); color: #fff; font-size: 10.5px; font-weight: 600; letter-spacing: 0.02em;
}
body.locked .view-tabs .tab[data-view="simple"] { position: relative; }
body.locked .view-tabs .tab[data-view="simple"]::after {
  content: ''; position: absolute; right: 3px; bottom: 3px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--ui-accent); box-shadow: 0 0 0 2px var(--ui-bg-solid);
}
.plex-dialog {
  background: var(--ui-bg-solid); border: 1px solid var(--ui-line); border-radius: 18px;
  max-width: 540px; width: 100%; max-height: 90vh; overflow-y: auto;
  padding: 6px 22px 22px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  display: flex; flex-direction: column; gap: 14px;
}
.plex-dialog .panel-head { padding: 12px 0 0; }
.plex-dialog .panel-head h2 { font-size: 19px; }
.form-group { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; }
.form-row .form-group { min-width: 180px; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--ui-muted); }
.form-group input, .form-group select {
  height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--ui-line);
  background: rgba(255, 255, 255, 0.04); color: var(--ui-text); font-size: 14px; outline: none; user-select: text;
}
.form-group input::placeholder { color: var(--ui-faint); }
.form-group input:focus { border-color: color-mix(in srgb, var(--theme-primary) 55%, transparent); }
.form-note { font-size: 12.5px; color: var(--ui-faint); line-height: 1.5; }
.plex-status-box {
  padding: 12px 14px; border-radius: 12px; font-size: 13.5px; line-height: 1.55;
  background: var(--ui-raise); color: var(--ui-muted); user-select: text;
}
.plex-status-box.success { background: rgba(80, 160, 110, 0.14); color: #c9eed5; }
.plex-status-box.error { background: rgba(200, 80, 80, 0.14); color: #f6cfcf; }
.divider-text { text-align: center; font-size: 12.5px; color: var(--ui-faint); }
.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: rgba(255, 255, 255, 0.04); }
.tab {
  flex: 1; height: 34px; border: 0; border-radius: 9px; background: none;
  font-size: 13.5px; font-weight: 600; color: var(--ui-muted);
}
.tab:hover { color: var(--ui-text); }
.tab.active { background: var(--ui-raise-hover); color: var(--ui-text); }
.tab-panel { display: flex; flex-direction: column; gap: 12px; }
.library-picker { padding: 14px; border-radius: 12px; background: var(--ui-raise); gap: 10px; }
.both-servers { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--ui-raise); font-size: 13px; color: var(--ui-muted); line-height: 1.45; cursor: pointer; }
.both-servers[hidden] { display: none; }
.both-servers strong { color: var(--ui-text, inherit); font-weight: 600; }
.both-servers input { width: 16px; height: 16px; margin-top: 2px; accent-color: var(--theme-primary); flex: none; }
.library-picker-list { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; }
.library-picker-foot { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; font-size: 13px; color: var(--ui-muted); }
.plex-dialog > .link-btn { align-self: center; color: var(--ui-muted); font-weight: 500; }

.rentals-list { display: flex; flex-direction: column; gap: 8px; }
.rentals-empty { color: var(--ui-muted); font-size: 13.5px; line-height: 1.55; padding: 8px 0; }
.rental-row {
  display: flex; align-items: center; gap: 12px; justify-content: space-between; flex-wrap: wrap;
  padding: 12px 14px; border-radius: 12px; background: var(--ui-raise);
}
.rental-info { display: flex; flex-direction: column; gap: 5px; min-width: 0; flex: 1; }
.rental-info strong { color: #fff; font-size: 14px; font-weight: 600; }
.rental-meta { font-size: 12.5px; color: var(--ui-muted); }
.rental-meta.late { color: #f0b4b4; }
.rental-bar { height: 3px; border-radius: 2px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.rental-bar > div { height: 100%; background: var(--ui-warm); }
.rental-actions { display: flex; gap: 8px; }
.rental-actions .ui-btn { min-height: 34px; padding: 0 12px; font-size: 13px; }

#toast {
  position: fixed; top: 74px; left: 50%; z-index: 70; max-width: min(520px, calc(100vw - 40px));
  background: var(--ui-bg-solid); border: 1px solid var(--ui-line); color: var(--ui-text);
  font-size: 13.5px; line-height: 1.45; padding: 10px 18px; border-radius: 12px; box-shadow: var(--ui-shadow);
  transform: translate(-50%, -10px); opacity: 0; pointer-events: none; transition: all 0.25s ease;
}
#toast.show { transform: translate(-50%, 0); opacity: 1; }

#loading-screen {
  position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, #1c1526 0%, #0b0810 70%); color: var(--ui-muted);
  font-size: 14px; transition: opacity 0.4s;
}
#loading-screen.hidden { display: none; }
.loading-card { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.loading-reel {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.12); border-top-color: var(--ui-warm); animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- TV box sets: seasons and episodes in the inspect dock ---- */
.inspect-episodes { display: flex; flex-direction: column; gap: 8px; }
.season-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.season-tab {
  background: var(--ui-raise); border: 1px solid var(--ui-line); color: var(--ui-text);
  font-size: 12.5px; padding: 5px 11px; border-radius: 999px;
}
.season-tab.active { background: var(--ui-accent-soft); border-color: color-mix(in srgb, var(--theme-primary) 55%, transparent); }
.episode-list { display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow-y: auto; }
.episode-row {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px;
  background: var(--ui-raise); border-radius: 9px; padding: 7px 10px; font-size: 13px; color: var(--ui-text);
}
.episode-row .ep-meta { display: block; color: var(--ui-faint); font-size: 11.5px; margin-top: 2px; }
.episode-row .ep-bar { height: 3px; background: rgba(255, 255, 255, 0.1); border-radius: 2px; margin-top: 4px; }
.episode-row .ep-bar div { height: 100%; background: var(--ui-warm); border-radius: 2px; }
.episode-row button { min-height: 30px; padding: 0 10px; font-size: 12.5px; }
.episodes-loading { font-size: 12.5px; color: var(--ui-faint); }

/* ---- Touch: a joystick to walk, drag anywhere else to look ---- */
#canvas-container { touch-action: none; }
.touch-stick {
  position: fixed; bottom: 90px; width: 120px; height: 120px; z-index: 40;
  border-radius: 50%; border: 1px solid var(--ui-line); background: rgba(18, 15, 26, 0.45);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: none; touch-action: none;
}
#touch-joystick { left: 26px; }
#touch-look { right: 26px; }
.touch-stick .knob {
  position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px;
  border-radius: 50%; background: rgba(255, 255, 255, 0.55); pointer-events: none;
}
body.touch .touch-stick { display: block; }
/* Game-style "use" button: whatever is under the dot in the middle. */
#touch-use {
  position: fixed; right: 48px; bottom: 226px; width: 76px; height: 76px; z-index: 40; /* above the look stick */
  border-radius: 50%; border: 1px solid var(--ui-line); background: rgba(18, 15, 26, 0.45);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); color: rgba(255, 255, 255, 0.55);
  display: none; align-items: center; justify-content: center; touch-action: none; cursor: pointer;
}
#touch-use.ready { color: #fff; border-color: rgba(255, 255, 255, 0.6); background: rgba(18, 15, 26, 0.65); }
body.touch #touch-use { display: flex; }
/* Touch screens have their own controls: no mouse choices in Settings. */
body.touch #controls-game { display: none !important; }
body:not(.touch) #controls-touch { display: none; }
/* The sticks step aside while you're holding a tape, and while Settings or
   Browse is open (on a phone they'd cover its lower half). */
body:has(#inspect-dock.open) .touch-stick, body:has(#inspect-dock.open) #touch-use,
body:has(#settings-menu:not([hidden])) .touch-stick, body:has(#settings-menu:not([hidden])) #touch-use,
body:has(#directory:not([hidden])) .touch-stick, body:has(#directory:not([hidden])) #touch-use { display: none !important; }
/* Phones on their side: sticks down in the corners under the thumbs. */
@media (max-height: 520px) {
  .touch-stick { bottom: 22px; width: 110px; height: 110px; }
  #touch-joystick { left: 22px; }
  #touch-look { right: 22px; }
  #touch-use { right: 39px; bottom: 146px; width: 64px; height: 64px; }
  body.touch .bottom-hud { bottom: 142px; } /* the aisle name sits above the left stick */
}

/* ---- Smaller screens ---- */
@media (max-width: 1440px) {
  .top-hud .hud-btn:not(.unlock-btn) span { display: none; }
  .top-hud .hud-btn:not(.unlock-btn) { width: 40px; padding: 0; justify-content: center; }
}
@media (max-width: 1080px) {
  .hud-btn span { display: none; }
  .hud-btn { width: 40px; padding: 0; justify-content: center; }
  .top-hud .view-switch .tab span { display: none; }
  .top-hud .view-switch .tab { padding: 0 10px; }
}
@media (max-width: 760px) {
  .top-hud { grid-template-columns: 1fr auto; padding: 8px 10px 14px; gap: 8px; }
  .search-box { grid-column: 1 / -1; grid-row: 2; }
  .brand-sub { display: none; }
  .brand-mark { font-size: 15px; }
  .directory { top: 116px; left: 10px; right: 10px; width: auto; max-height: calc(100vh - 200px); }
  .settings-menu { top: 60px; right: 10px; }
  #inspect-dock { right: 10px; left: 10px; width: auto; top: auto; bottom: 10px; transform: none; max-height: 52vh; }
  #inspect-dock.open { transform: none; }
  .welcome-card { max-width: none; }
  .bottom-hud { left: 10px; right: 10px; }
  #toast { top: 120px; }
}
/* Phones: the buttons need the whole width; the store's name is on the signs. */
@media (max-width: 480px) {
  .top-hud { grid-template-columns: minmax(0, 1fr); }
  .top-hud .brand { display: none; }
  .top-hud .hud-controls { justify-self: stretch; justify-content: space-between; min-width: 0; }
}

/* Rows in "Libraries on display". */
.library-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px;
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--ui-line); font-weight: 600; cursor: pointer;
}
.library-row input { accent-color: var(--ui-accent); width: 16px; height: 16px; }
.link-btn { text-align: left; }

/* ---- Previously Viewed bin ---- */
#bin-modal {
  position: fixed; inset: 0; z-index: 50; background: rgba(6, 4, 10, 0.62);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: none; align-items: center; justify-content: center; padding: 20px;
}
#bin-modal.open { display: flex; }
.bin-dialog { max-width: 860px; }
.bin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 14px; }
.bin-card {
  display: flex; flex-direction: column; gap: 4px; padding: 0; border: 0; background: none; text-align: left;
}
.bin-cover {
  aspect-ratio: 2 / 3; border-radius: 8px; overflow: hidden; background: #2a2333;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  transition: transform 0.15s;
}
.bin-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bin-card:hover .bin-cover { transform: translateY(-3px); }
.bin-title { font-size: 13px; font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bin-meta { font-size: 11.5px; color: var(--ui-faint); }
.bin-more { grid-column: 1 / -1; justify-self: center; }

/* ---- Simple view: the library as a poster grid (js/simple.js) ---- */
#simple-view {
  position: fixed; inset: 0; z-index: 45; display: flex; flex-direction: column;
  background: radial-gradient(1200px 600px at 20% -10%, color-mix(in srgb, var(--theme-primary) 9%, transparent), transparent 70%), var(--ui-bg-solid);
  color: var(--ui-text);
}
#simple-view[hidden] { display: none; }
body.simple-on #canvas-container, body.simple-on .bottom-hud { visibility: hidden; }
.sv-bar {
  display: flex; align-items: center; gap: 14px; padding: 12px 20px;
  border-bottom: 1px solid var(--ui-line); background: rgba(14, 11, 20, 0.7);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.sv-brand .brand-mark { font-size: 16px; font-weight: 800; letter-spacing: 0.08em; border-left: 3px solid var(--ui-accent); padding-left: 10px; white-space: nowrap; }
.sv-tabs { display: flex; gap: 4px; overflow: hidden; flex: 1; min-width: 0; }
.sv-tab[hidden] { display: none; }
.sv-more-btn { display: inline-flex; align-items: center; gap: 4px; padding: 0 10px 0 14px; max-width: 200px; }
.sv-more-btn span { overflow: hidden; text-overflow: ellipsis; }
.sv-more-caret { width: 15px; height: 15px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.sv-more-menu {
  position: fixed; z-index: 60; min-width: 200px; max-width: min(320px, calc(100vw - 16px)); max-height: min(60vh, 420px); overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px; padding: 6px;
  background: var(--ui-bg-solid); border: 1px solid var(--ui-line); border-radius: 12px; box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6);
}
.sv-more-menu[hidden] { display: none; }
.sv-more-item {
  text-align: left; padding: 9px 12px; border: 0; border-radius: 8px; background: none;
  color: var(--ui-muted); font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sv-more-item:hover, .sv-more-item:focus-visible { color: var(--ui-text); background: var(--ui-raise); outline: none; }
.sv-more-item.active { color: var(--ui-text); background: var(--ui-raise-hover); }
.sv-tabs::-webkit-scrollbar { display: none; }
.sv-tab {
  flex: none; height: 34px; padding: 0 14px; border-radius: 999px; border: 1px solid transparent; background: none;
  color: var(--ui-muted); font-size: 13.5px; font-weight: 600; white-space: nowrap;
}
.sv-tab:hover { color: var(--ui-text); background: var(--ui-raise); }
.sv-tab.active { color: var(--ui-text); background: var(--ui-raise-hover); border-color: var(--ui-line); }
.sv-search { position: relative; display: flex; align-items: center; width: min(300px, 32vw); }
.sv-search .icon { position: absolute; left: 12px; color: var(--ui-muted); pointer-events: none; }
.sv-search input {
  width: 100%; height: 38px; padding: 0 12px 0 36px; border-radius: 999px; border: 1px solid var(--ui-line);
  background: var(--ui-raise); color: var(--ui-text); font-size: 14px; outline: none;
}
.sv-search input:focus { border-color: color-mix(in srgb, var(--theme-primary) 55%, transparent); background: var(--ui-bg-solid); }
.sv-actions { display: flex; gap: 6px; }
.sv-actions .hud-btn { box-shadow: none; }
.sv-main { flex: 1; overflow-y: auto; padding: 18px 20px 40px; }
.sv-row { margin-bottom: 26px; }
.sv-row-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.sv-row-head h2 { font-size: 18px; font-weight: 700; }
.sv-row-sub { color: var(--ui-faint); font-size: 13px; }
.sv-see-all { margin-left: auto; }
.sv-strip { display: grid; grid-auto-flow: column; grid-auto-columns: 148px; gap: 14px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: thin; }
.sv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 18px 14px; }
.sv-page-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.sv-page-head h1 { font-size: 22px; font-weight: 700; }
.sv-count { color: var(--ui-faint); font-size: 13px; }
.sv-sort { margin-left: auto; color: var(--ui-muted); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.sv-sort select { height: 32px; border-radius: 8px; border: 1px solid var(--ui-line); background: var(--ui-raise); color: var(--ui-text); padding: 0 8px; }
.sv-card { display: flex; flex-direction: column; gap: 6px; padding: 0; border: 0; background: none; color: inherit; text-align: left; min-width: 0; }
.sv-poster {
  position: relative; aspect-ratio: 2 / 3; border-radius: 10px; overflow: hidden; background: var(--ui-raise);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35); transition: transform 0.15s, box-shadow 0.15s;
}
.sv-card:hover .sv-poster, .sv-card:focus-visible .sv-poster { transform: translateY(-3px); box-shadow: 0 12px 26px rgba(0, 0, 0, 0.5), 0 0 0 2px color-mix(in srgb, var(--theme-primary) 55%, transparent); }
.sv-poster img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.25s; }
.sv-poster img.ready { opacity: 1; }
.sv-fallback { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end; padding: 12px; gap: 6px; }
.sv-fb-icon { font-size: 30px; }
.sv-fb-title { font-weight: 800; font-size: 14px; line-height: 1.15; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6); }
.sv-progress { position: absolute; left: 8px; right: 8px; bottom: 8px; height: 4px; border-radius: 4px; background: rgba(0, 0, 0, 0.55); overflow: hidden; }
.sv-progress > * { display: block; height: 100%; background: var(--ui-warm); }
.sv-progress.inline { position: static; display: block; margin-top: 6px; width: 140px; }
.sv-watched { position: absolute; top: 8px; right: 8px; width: 22px; height: 22px; border-radius: 50%; background: rgba(0, 0, 0, 0.6); color: var(--ui-warm); font-size: 12px; display: flex; align-items: center; justify-content: center; }
.sv-play-badge { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 42px; height: 42px; border-radius: 50%; background: rgba(0, 0, 0, 0.55); display: flex; align-items: center; justify-content: center; font-size: 15px; opacity: 0.85; }
.sv-card-title { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sv-card-meta { font-size: 12px; color: var(--ui-faint); margin-top: -3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sv-empty { color: var(--ui-muted); padding: 30px 0; }

.sv-details { position: fixed; inset: 0; z-index: 46; display: flex; justify-content: center; align-items: flex-start; overflow-y: auto; padding: 40px 16px; }
.sv-details[hidden] { display: none; }
.sv-d-scrim { position: fixed; inset: 0; background: rgba(6, 4, 10, 0.7); }
.sv-d-panel { position: relative; width: min(920px, 100%); border-radius: 18px; overflow: hidden; background: var(--ui-bg-solid); border: 1px solid var(--ui-line); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6); }
.sv-d-hero { position: relative; height: 260px; background: color-mix(in srgb, var(--theme-primary) 14%, #120e18) center / cover no-repeat; }
.sv-d-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(23, 19, 31, 0.1), var(--ui-bg-solid)); }
.sv-d-close { position: absolute; top: 12px; right: 12px; background: rgba(0, 0, 0, 0.5); color: var(--ui-text); }
.sv-d-body { position: relative; display: flex; gap: 22px; padding: 0 26px 24px; margin-top: -120px; }
.sv-d-poster { flex: none; width: 190px; }
.sv-d-info { flex: 1; min-width: 0; padding-top: 70px; }
.sv-d-info h2 { font-size: 26px; font-weight: 800; line-height: 1.15; }
.sv-d-facts, .sv-d-genres { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.sv-d-facts span { font-size: 12.5px; padding: 3px 9px; border-radius: 999px; background: var(--ui-raise-hover); color: var(--ui-text); }
.sv-d-genres span { font-size: 12.5px; color: var(--ui-muted); }
.sv-d-genres span + span::before { content: "•"; margin-right: 6px; color: var(--ui-faint); }
.sv-d-tagline { margin-top: 12px; color: var(--ui-warm); font-style: italic; }
.sv-d-summary { margin-top: 8px; color: var(--ui-muted); line-height: 1.55; }
.sv-d-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.sv-d-buttons .ui-btn { width: auto; padding: 0 18px; }
.sv-d-credits { display: grid; gap: 6px; margin-top: 16px; font-size: 13px; }
.sv-d-credits div { display: flex; gap: 10px; }
.sv-d-credits dt { width: 70px; flex: none; color: var(--ui-faint); }
.sv-d-credits dd { color: var(--ui-muted); }
.sv-episodes { padding: 0 26px 26px; }
.sv-season-tabs { overflow-x: auto; margin-bottom: 10px; }
.sv-season-tabs .tab { flex: none; padding: 0 14px; }
.sv-ep-list { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.sv-ep { width: 100%; display: flex; align-items: center; gap: 14px; padding: 10px 12px; border: 0; border-radius: 10px; background: none; color: inherit; text-align: left; }
.sv-ep:hover { background: var(--ui-raise); }
.sv-ep-num { width: 26px; flex: none; color: var(--ui-faint); font-weight: 700; text-align: right; }
.sv-ep-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sv-ep-text span { font-size: 12.5px; color: var(--ui-faint); }
.sv-ep-play { color: var(--ui-muted); }

@media (max-width: 760px) {
  .sv-bar { flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
  .sv-tabs { order: 3; flex-basis: 100%; }
  .sv-search { flex: 1; width: auto; }
  .sv-actions .hud-btn span { display: none; }
  .sv-actions .hud-btn { width: 38px; padding: 0; justify-content: center; }
  .sv-main { padding: 14px 16px 32px; }
  .sv-strip { grid-auto-columns: 118px; gap: 10px; }
  .sv-grid { grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 14px 10px; }
  .sv-details { padding: 0; }
  .sv-d-panel { border-radius: 0; min-height: 100%; }
  .sv-d-hero { height: 180px; }
  .sv-d-body { flex-direction: column; padding: 0 16px 20px; margin-top: -90px; gap: 14px; }
  .sv-d-poster { width: 130px; }
  .sv-d-info { padding-top: 0; }
  .sv-episodes { padding: 0 16px 20px; }
}

/* ---- View switch (3D store / Simple), in both top bars ---- */
.view-switch {
  display: inline-flex; gap: 2px; padding: 3px; height: 40px; border-radius: 999px;
  border: 1px solid var(--ui-line); background: var(--ui-bg);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); box-shadow: var(--ui-shadow);
}
.view-switch .tab {
  flex: none; height: 32px; padding: 0 12px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px;
}
.view-switch .tab .icon { width: 16px; height: 16px; }
.view-switch .tab.active { background: var(--ui-accent); color: #fff; }
.sv-actions .view-switch { box-shadow: none; }
@media (max-width: 760px) {
  .view-switch .tab span { display: none; }
  .view-switch .tab { padding: 0 10px; }
}

/* ---- Settings in Simple view: above it, without the store-only rows ---- */
body.simple-on .settings-menu { z-index: 48; }
body.simple-on .settings-menu .store-only { display: none; }
.check-row {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  font-size: 13.5px !important; font-weight: 500 !important; letter-spacing: 0 !important; text-transform: none !important; color: var(--ui-text) !important;
}
.check-row input { width: 16px; height: 16px; accent-color: var(--theme-primary); }
.users-now { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13.5px; }
.users-now .ui-btn { min-height: 32px; padding: 0 12px; font-size: 13px; flex: none; }

/* ---- Player: tracks menu, skip button, up next ---- */
#movie-video::cue { font-size: 1.15em; line-height: 1.35; background: rgba(0, 0, 0, 0.62); color: #fff; }
.player-menu {
  position: absolute; bottom: 82px; right: 16px; z-index: 6; display: flex; gap: 6px;
  max-width: calc(100% - 32px); max-height: calc(100% - 24px); overflow-y: auto; padding: 10px;
  background: rgba(15, 12, 20, 0.94); border: 1px solid var(--ui-line); border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6);
}
.player-menu[hidden], .tracks-col[hidden] { display: none; }
.player-quality .tracks-col { min-width: 230px; }
.track-option small { display: block; font-size: 11.5px; color: var(--ui-faint); margin-top: 2px; }
.track-option:disabled { opacity: 0.55; cursor: default; }
.track-option:disabled:hover { background: none; color: var(--ui-muted); }
.tracks-col { display: flex; flex-direction: column; gap: 2px; min-width: 190px; }
.tracks-col h3 { font-size: 11.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ui-faint); padding: 4px 10px 6px; }
.track-option {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 0; border-radius: 8px;
  background: none; color: var(--ui-muted); font-size: 13.5px; text-align: left;
}
.track-option::before { content: ''; width: 14px; flex: none; text-align: center; color: var(--ui-warm); }
.track-option.active { color: var(--ui-text); }
.track-option.active::before { content: '✓'; }
.track-option:hover { background: var(--ui-raise-hover); color: var(--ui-text); }
.skip-btn {
  position: absolute; right: 32px; bottom: 96px; z-index: 4; min-height: 44px; padding: 0 22px;
  border-radius: 10px; border: 1px solid rgba(255, 255, 255, 0.35); background: rgba(15, 12, 20, 0.82);
  color: #fff; font-size: 15px; font-weight: 650; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.skip-btn:hover { background: rgba(30, 24, 40, 0.95); border-color: rgba(255, 255, 255, 0.6); }
.skip-btn[hidden], .up-next[hidden] { display: none; }
.up-next {
  position: absolute; right: 32px; bottom: 96px; z-index: 4; width: min(340px, calc(100% - 32px));
  display: flex; flex-direction: column; gap: 4px; padding: 16px 18px;
  background: rgba(15, 12, 20, 0.92); border: 1px solid var(--ui-line); border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6); color: var(--ui-text);
}
.up-next-label { font-size: 11.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ui-faint); }
#up-next-title { font-size: 15px; font-weight: 650; }
.up-next-count { font-size: 13px; color: var(--ui-warm); min-height: 1em; }
.up-next-actions { display: flex; gap: 8px; margin-top: 8px; }
.up-next-actions .ui-btn { flex: 1; min-height: 36px; font-size: 13px; padding: 0 10px; }
@media (max-width: 760px) {
  .skip-btn, .up-next { right: 16px; bottom: 96px; }
  .player-tracks { flex-direction: column; left: 16px; right: 16px; }
  .pc-volume, #pc-back, #pc-forward { display: none; }
}

/* ---- Player: the control bar ---- */
.player-controls {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5; padding: 26px 18px 10px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.82), rgba(0, 0, 0, 0.45) 60%, transparent);
  transition: opacity 0.35s;
}
#player-modal.controls-idle .player-controls { opacity: 0; pointer-events: none; }
#player-modal.controls-idle .player-stage { cursor: none; }
.pc-timeline { position: relative; height: 18px; display: flex; align-items: center; cursor: pointer; touch-action: none; outline-offset: 4px; }
.pc-rail { position: relative; width: 100%; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.2); overflow: hidden; transition: height 0.15s; }
.pc-timeline:hover .pc-rail, .pc-timeline:focus-visible .pc-rail { height: 6px; }
.pc-buffered, .pc-played, .pc-marks { position: absolute; top: 0; bottom: 0; left: 0; }
.pc-buffered { background: rgba(255, 255, 255, 0.28); }
.pc-marks { right: 0; }
.pc-mark { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--ui-warm) 45%, transparent); }
.pc-played { background: var(--theme-primary); }
.pc-thumb {
  position: absolute; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 0 3px color-mix(in srgb, var(--theme-primary) 55%, transparent);
  transform: scale(0); transition: transform 0.15s; pointer-events: none;
}
.pc-timeline:hover .pc-thumb, .pc-timeline:focus-visible .pc-thumb { transform: scale(1); }
.pc-hover {
  position: absolute; bottom: 20px; transform: translateX(-50%); padding: 3px 8px; border-radius: 6px;
  background: rgba(15, 12, 20, 0.92); border: 1px solid var(--ui-line); color: var(--ui-text);
  font-size: 12px; font-variant-numeric: tabular-nums; pointer-events: none; white-space: nowrap;
}
.pc-hover[hidden] { display: none; }
.pc-row { display: flex; align-items: center; gap: 4px; margin-top: 4px; }
.pc-spacer { flex: 1; }
.pc-btn {
  width: 40px; height: 40px; display: grid; place-items: center; border: 0; border-radius: 10px;
  background: none; color: rgba(255, 255, 255, 0.86); flex: none;
}
.pc-btn:hover, .pc-btn[aria-expanded="true"] { background: rgba(255, 255, 255, 0.1); color: #fff; }
.pc-btn[hidden] { display: none; }
.pc-btn .icon { width: 22px; height: 22px; }
.pc-icon { width: 24px; height: 24px; fill: currentColor; }
#player-modal.is-paused .pc-when-playing, #player-modal:not(.is-paused) .pc-when-paused { display: none; }
#player-modal.is-fullscreen .pc-when-windowed, #player-modal:not(.is-fullscreen) .pc-when-fullscreen { display: none; }
#player-modal.is-muted .pc-wave, #player-modal:not(.is-muted) .pc-muted-x { display: none; }
.pc-volume {
  --fill: 100%; width: 84px; height: 4px; margin: 0 8px 0 2px; appearance: none; -webkit-appearance: none;
  border-radius: 2px; cursor: pointer;
  background: linear-gradient(to right, #fff var(--fill), rgba(255, 255, 255, 0.22) var(--fill));
}
.pc-volume::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 0; }
.pc-volume::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 0; }
.pc-time { font-size: 13px; color: rgba(255, 255, 255, 0.82); font-variant-numeric: tabular-nums; white-space: nowrap; margin-left: 4px; }

/* ---- Who's watching ---- */
#users-modal {
  position: fixed; inset: 0; z-index: 55; background: rgba(6, 4, 10, 0.62);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
#users-modal[hidden], .users-secret[hidden], .users-error[hidden] { display: none; }
.users-dialog {
  width: min(520px, 100%); max-height: calc(100vh - 40px); overflow-y: auto;
  background: var(--ui-bg-solid); border: 1px solid var(--ui-line); border-radius: 18px; box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
}
.users-body { padding: 4px 18px 10px; display: flex; flex-direction: column; gap: 16px; }
.users-server h3 { font-size: 11.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ui-faint); margin-bottom: 10px; }
.users-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.user-tile {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 8px 12px;
  border-radius: 14px; border: 1px solid var(--ui-line); background: var(--ui-raise); color: var(--ui-text);
}
.user-tile:hover { background: var(--ui-raise-hover); border-color: rgba(255, 255, 255, 0.2); }
.user-tile.current { border-color: color-mix(in srgb, var(--theme-primary) 60%, transparent); cursor: default; }
.user-tile.picked { border-color: var(--ui-warm); }
.user-avatar {
  width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 750; color: #fff; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.15);
}
.user-name { font-size: 14px; font-weight: 650; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-sub { font-size: 12px; color: var(--ui-faint); min-height: 1em; }
.users-note { font-size: 13px; color: var(--ui-muted); margin-top: 8px; }
.users-error { font-size: 13px; color: #f6a5a5; margin-top: 6px; }
.users-secret { padding: 4px 18px 18px; display: flex; flex-direction: column; gap: 8px; }
.users-secret label { font-size: 11.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ui-faint); }
.users-secret-row { display: flex; gap: 8px; }
.users-secret-row input {
  flex: 1; height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--ui-line);
  background: var(--ui-raise); color: var(--ui-text); font-size: 16px; letter-spacing: 0.1em; outline: none;
}

/* ---- Simple view playlists ---- */
.sv-pl-cover {
  position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden;
  background: linear-gradient(150deg, color-mix(in srgb, var(--theme-primary) 55%, #1a1424), #120e19 75%);
  display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s, box-shadow 0.15s;
}
.sv-pl-card:hover .sv-pl-cover { transform: translateY(-3px); box-shadow: 0 12px 26px rgba(0, 0, 0, 0.5), 0 0 0 2px color-mix(in srgb, var(--theme-primary) 55%, transparent); }
.sv-pl-icon { font-size: 40px; color: rgba(255, 255, 255, 0.75); }
.sv-pl-cover.mosaic { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; background: #0c0a10; }
.sv-pl-cover.mosaic .sv-poster { aspect-ratio: auto; border-radius: 0; box-shadow: none; }
.sv-pl-actions { margin-left: auto; display: flex; gap: 8px; }
.sv-pl-actions .ui-btn { min-height: 36px; font-size: 13.5px; }
.sv-pl-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-width: 900px; }
.sv-pl-row { width: 100%; display: flex; align-items: center; gap: 14px; padding: 8px 12px; border: 0; border-radius: 10px; background: none; color: inherit; text-align: left; }
.sv-pl-row:hover { background: var(--ui-raise); }
.sv-pl-thumb { width: 44px; flex: none; border-radius: 6px; }

/* ---- Scrollbars: thin and dark, tinted with the theme ---- */
:root { color-scheme: dark; }
* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--theme-primary) 40%, #3a3346) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--theme-primary) 40%, #3a3346); border-radius: 999px;
  border: 2px solid transparent; background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background-color: color-mix(in srgb, var(--theme-primary) 65%, #3a3346); }
::-webkit-scrollbar-corner { background: transparent; }

/* Simple view's bar: libraries get the room on narrower screens. */
#sv-user-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 1440px) {
  .sv-actions #sv-library span { display: none; }
  .sv-actions #sv-library { width: 40px; padding: 0; justify-content: center; }
}
@media (max-width: 1180px) {
  .sv-actions .view-switch .tab span { display: none; }
  .sv-actions .view-switch .tab { padding: 0 10px; }
}
.ui-btn:disabled { opacity: 0.5; cursor: default; pointer-events: none; }

/* Short screens (a phone on its side): the buttons stay in view at the
   bottom of the box panel while its details scroll. */
@media (max-height: 520px) {
  #inspect-dock { padding-bottom: 0; }
  #inspect-dock .inspect-actions {
    position: sticky; bottom: 0; margin: 0 -22px; padding: 10px 22px 14px;
    background: rgb(20, 17, 28); border-top: 1px solid var(--ui-line); /* solid: details scroll under it */
  }
}

/* The system's "reduce motion" / Windows "animation effects off": menus and
   messages appear without sliding or fading. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
  *:not(.loading-reel) { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
