:root {
  color-scheme: dark;
  font-family:
    Inter,
    "Hiragino Sans",
    "Yu Gothic UI",
    "Yu Gothic",
    Meiryo,
    sans-serif;
  background: #090a0d;
  color: #f4f5f7;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(
      circle at 15% 0%,
      rgba(112, 67, 255, 0.18),
      transparent 34rem
    ),
    #090a0d;
}

button,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.app-shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.player-brand-group {
  display: flex;
  align-items: flex-end;
  gap: 24px;
}

.player-nav {
  display: flex;
  gap: 5px;
  padding-bottom: 1px;
}

.player-nav a {
  padding: 8px 11px;
  border-radius: 8px;
  color: #9296a2;
  font-size: 0.78rem;
  text-decoration: none;
}

.player-nav a:hover,
.player-nav a.is-active {
  background: rgba(121, 94, 255, 0.14);
  color: #d5ccff;
}

.eyebrow {
  margin: 0 0 4px;
  color: #a88cff;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.18em;
}

h1 {
  margin: 0;
  font-size: clamp(1.3rem, 2vw, 1.85rem);
  font-weight: 760;
}

.status-group {
  display: flex;
  align-items: center;
  gap: 9px;
}

.preload-status {
  color: #737784;
  font-size: 0.78rem;
}

.preload-status.is-ready {
  color: #8de2b5;
}

.preload-status.is-error {
  color: #ff9da8;
}

.status-pill {
  min-width: 7.5rem;
  padding: 8px 12px;
  border: 1px solid #323541;
  border-radius: 999px;
  background: rgba(20, 22, 28, 0.82);
  color: #c8cad2;
  font-size: 0.82rem;
  text-align: center;
}

.status-pill.is-ready {
  border-color: #275a42;
  color: #8de2b5;
}

.status-pill.is-error {
  border-color: #6e3138;
  color: #ff9da8;
}

.player-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 22px;
  align-items: start;
}

.video-column {
  min-width: 0;
}

.video-frame {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid #262933;
  border-radius: 14px;
  background: #000;
  box-shadow:
    0 24px 70px rgba(0, 0, 0, 0.42);
  touch-action: pan-x;
  user-select: none;
}

.player-video {
  position: absolute;
  inset: 0;
  display: none;
  width: 100%;
  height: 100%;
  background: #000;
}

.player-video.is-active {
  display: block;
  z-index: 1;
}

.video-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: none;
  place-content: center;
  gap: 14px;
  padding: 24px;
  background: rgba(0, 0, 0, 0.72);
  color: #e9eaf0;
  text-align: center;
}

.video-frame.is-loading .video-overlay,
.video-frame.is-error .video-overlay {
  display: grid;
}

.video-frame.is-error .spinner {
  display: none;
}

.video-overlay p {
  margin: 0;
}

.gesture-hint {
  position: absolute;
  z-index: 2;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  padding: 7px 11px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.58);
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.72rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease;
}

.video-frame.is-gesturing .gesture-hint {
  opacity: 1;
}

.spinner {
  width: 34px;
  height: 34px;
  margin: 0 auto;
  border: 3px solid rgba(255, 255, 255, 0.18);
  border-top-color: #a88cff;
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.controls-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.quality-control,
.playback-mode-control {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #b9bbc5;
  font-size: 0.9rem;
}

.quality-control select,
.playback-mode-control select {
  min-width: 88px;
  padding: 9px 30px 9px 11px;
  border: 1px solid #343844;
  border-radius: 9px;
  background: #16181e;
  color: #f4f5f7;
}

.playback-mode-control select {
  min-width: 144px;
}

.unseen-status {
  color: #8d91a0;
  font-size: 0.78rem;
  white-space: nowrap;
}

.unseen-status.is-complete {
  color: #d2b1ff;
}

.primary-button,
.secondary-button {
  min-height: 40px;
  padding: 8px 18px;
  border-radius: 9px;
  font-weight: 700;
}

.primary-button {
  margin-left: auto;
  border: 1px solid #795eff;
  background: #795eff;
  color: white;
}

.primary-button:hover:not(:disabled) {
  background: #8a73ff;
}

.secondary-button {
  border: 1px solid #383c48;
  background: #191b22;
  color: #e7e8ed;
}

.secondary-button:hover:not(:disabled) {
  border-color: #575c69;
  background: #22252e;
}

.shortcut-hint {
  margin: 10px 0 0;
  color: #717582;
  font-size: 0.78rem;
}

.detail-panel {
  overflow: hidden;
  border: 1px solid #262933;
  border-radius: 14px;
  background: rgba(18, 20, 26, 0.88);
}

.poster-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  background: #101116;
}

.poster-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.poster-placeholder {
  display: grid;
  width: 100%;
  height: 100%;
  place-content: center;
  color: #595d69;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.detail-copy {
  padding: 18px;
}

.release-date {
  min-height: 1.2em;
  margin: 0 0 7px;
  color: #9296a2;
  font-size: 0.78rem;
}

h2 {
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.55;
}

.metadata {
  display: grid;
  gap: 12px;
  margin: 20px 0;
}

.metadata div {
  display: grid;
  grid-template-columns: 5.2rem minmax(0, 1fr);
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid #282b34;
}

.metadata dt {
  color: #808491;
  font-size: 0.78rem;
}

.metadata dd {
  min-width: 0;
  margin: 0;
  color: #d7d9df;
  font-size: 0.86rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.product-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 42px;
  border: 1px solid #424653;
  border-radius: 9px;
  color: #e5e6eb;
  text-decoration: none;
}

.product-link:hover {
  border-color: #787d8c;
  background: #20232b;
}

.error-panel {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid #71343b;
  border-radius: 12px;
  background: rgba(87, 30, 37, 0.32);
  color: #ffb3bb;
}

.error-panel p {
  margin: 7px 0 0;
  color: #e3a1a8;
}

.video-column:fullscreen {
  display: grid;
  align-content: center;
  width: 100vw;
  height: 100vh;
  padding: 16px;
  background: #000;
}

.video-column:fullscreen .video-frame {
  width: 100%;
  max-height: calc(100vh - 86px);
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.video-column:fullscreen .controls-row {
  width: min(1100px, 100%);
  margin: 12px auto 0;
}

.video-column:fullscreen .shortcut-hint {
  display: none;
}

@media (max-width: 920px) {
  .player-layout {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    display: grid;
    grid-template-columns: minmax(180px, 38%) 1fr;
  }

  .poster-wrap {
    height: 100%;
    aspect-ratio: auto;
  }
}

@media (max-width: 680px) {
  .app-shell {
    padding: 14px;
  }

  .topbar {
    align-items: center;
  }

  .player-brand-group {
    align-items: center;
    gap: 12px;
  }

  .player-nav a {
    padding: 7px 8px;
  }

  .status-group {
    display: block;
    text-align: right;
  }

  .preload-status {
    margin-bottom: 4px;
  }

  .detail-panel {
    display: block;
  }

  .poster-wrap {
    aspect-ratio: 3 / 2;
  }

  .controls-row {
    flex-wrap: wrap;
  }

  .primary-button {
    margin-left: 0;
  }

  .shortcut-hint {
    display: none;
  }
}


.favorite-button.is-active {
  border-color: #8d72ff;
  background: rgba(121, 94, 255, 0.18);
  color: #d9d0ff;
}

.danger-button {
  border-color: #5f363c;
  color: #ffb0b8;
}

.danger-button:hover:not(:disabled) {
  border-color: #91434d;
  background: rgba(125, 42, 52, 0.28);
}

#library-count:not(:empty)::before {
  content: "(";
}

#library-count:not(:empty)::after {
  content: ")";
}

.library-dialog {
  width: min(920px, calc(100vw - 28px));
  max-height: min(760px, calc(100vh - 28px));
  padding: 0;
  border: 1px solid #343844;
  border-radius: 14px;
  background: #111319;
  color: #f4f5f7;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.68);
}

.library-dialog::backdrop {
  background: rgba(0, 0, 0, 0.76);
  backdrop-filter: blur(4px);
}

.library-shell {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  max-height: min(760px, calc(100vh - 28px));
  padding: 20px;
}

.library-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.library-header h2 {
  font-size: 1.2rem;
}

.library-tabs {
  display: flex;
  gap: 8px;
  margin-top: 18px;
  border-bottom: 1px solid #2b2e38;
}

.library-tab {
  padding: 10px 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: #9296a2;
}

.library-tab.is-active {
  border-bottom-color: #8a73ff;
  color: #f4f5f7;
}

.library-status {
  min-height: 1.4em;
  margin: 12px 0;
  color: #8d91a0;
  font-size: 0.82rem;
}

.library-list {
  display: grid;
  gap: 10px;
  overflow-y: auto;
  padding-right: 4px;
}

.library-empty {
  display: grid;
  min-height: 180px;
  place-content: center;
  color: #777b87;
  text-align: center;
}

.library-item {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 10px;
  border: 1px solid #292c35;
  border-radius: 10px;
  background: #17191f;
}

.library-item-image {
  width: 132px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 7px;
  background: #090a0d;
}

.library-item-copy {
  min-width: 0;
}

.library-item-title {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.45;
}

.library-item-date {
  margin: 6px 0 0;
  color: #777b87;
  font-size: 0.75rem;
}

.library-item-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.library-item-actions button {
  min-height: 34px;
  padding: 6px 11px;
}

@media (max-width: 680px) {
  .library-shell {
    padding: 14px;
  }

  .library-item {
    grid-template-columns: 96px minmax(0, 1fr);
  }

  .library-item-image {
    width: 96px;
  }

  .library-item-actions {
    grid-column: 1 / -1;
    justify-content: stretch;
  }

  .library-item-actions button {
    flex: 1;
  }
}


/* ==================================================================
   Phase 4A — cinematic design system
   ================================================================== */

:root {
  --page-bg: #07080b;
  --surface-1: rgba(17, 19, 25, 0.86);
  --surface-2: rgba(25, 27, 35, 0.88);
  --surface-3: #1c1f28;
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.17);
  --text: #f7f7fa;
  --text-soft: #c7c9d1;
  --text-muted: #858996;
  --accent: #a87cff;
  --accent-2: #ff5da8;
  --accent-3: #7d6cff;
  --accent-glow: rgba(153, 104, 255, 0.3);
  --success: #7ce0af;
  --danger: #ff8a99;
  --shadow-xl:
    0 38px 110px rgba(0, 0, 0, 0.56);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 12px;
}

html {
  background: var(--page-bg);
}

body.player-page {
  position: relative;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(
      circle at 8% -10%,
      rgba(146, 93, 255, 0.2),
      transparent 34rem
    ),
    radial-gradient(
      circle at 92% 14%,
      rgba(255, 74, 155, 0.11),
      transparent 28rem
    ),
    linear-gradient(180deg, #0b0c11, #07080b 58%);
  color: var(--text);
}

.ambient-backdrop {
  position: fixed;
  z-index: -2;
  inset: -70px;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transition: opacity 650ms ease;
}

body.has-ambient .ambient-backdrop {
  opacity: 0.44;
}

.ambient-backdrop img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter:
    blur(80px)
    saturate(1.05)
    brightness(0.48);
  transform: scale(1.12);
}

.ambient-backdrop-scrim {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(
      circle at 28% 18%,
      transparent,
      rgba(7, 8, 11, 0.3) 45%,
      rgba(7, 8, 11, 0.94) 82%
    ),
    linear-gradient(
      180deg,
      rgba(7, 8, 11, 0.32),
      #07080b 78%
    );
}

.player-shell {
  width: min(1560px, 100%);
  padding: 18px 30px 52px;
}

.topbar {
  position: sticky;
  z-index: 18;
  top: 0;
  align-items: center;
  min-height: 70px;
  margin: 0 -12px 22px;
  padding: 10px 12px;
  border-bottom: 1px solid transparent;
  background: rgba(7, 8, 11, 0.68);
  backdrop-filter: blur(22px) saturate(1.25);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  position: relative;
  display: grid;
  width: 42px;
  height: 42px;
  place-content: center;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 13px;
  background:
    linear-gradient(
      145deg,
      var(--accent-2),
      var(--accent-3) 68%
    );
  box-shadow:
    0 10px 30px rgba(119, 76, 255, 0.35),
    inset 0 1px rgba(255, 255, 255, 0.35);
  font-weight: 900;
}

.brand-mark::after {
  position: absolute;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 50%;
  content: "";
  transform: translate(14px, 14px);
}

.brand-mark span {
  position: relative;
  z-index: 1;
}

.brand-copy strong,
.brand-copy small {
  display: block;
}

.brand-copy strong {
  font-size: 0.95rem;
  letter-spacing: 0.12em;
}

.brand-copy small {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 0.65rem;
  letter-spacing: 0.04em;
}

.player-brand-group {
  align-items: center;
}

.player-nav {
  align-items: center;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(18, 20, 27, 0.72);
}

.player-nav a {
  min-width: 58px;
  padding: 8px 12px;
  border-radius: 9px;
  color: var(--text-muted);
  text-align: center;
}

.player-nav a:hover,
.player-nav a.is-active {
  background:
    linear-gradient(
      135deg,
      rgba(168, 124, 255, 0.26),
      rgba(255, 93, 168, 0.12)
    );
  color: var(--text);
}

.status-group {
  gap: 10px;
}

.preload-status {
  color: var(--text-muted);
}

.status-pill {
  min-width: 6.8rem;
  border-color: var(--line);
  background: rgba(20, 22, 29, 0.72);
  color: var(--text-soft);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.05);
}

.player-layout {
  grid-template-columns: minmax(0, 1fr) 370px;
  gap: 26px;
}

.stage-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 30px;
  margin: 0 2px 9px;
}

.now-playing-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-soft);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.15em;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow:
    0 0 0 5px rgba(255, 93, 168, 0.12),
    0 0 18px rgba(255, 93, 168, 0.8);
}

.stage-heading-hint {
  color: var(--text-muted);
  font-size: 0.7rem;
}

.video-frame {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-xl);
  box-shadow:
    var(--shadow-xl),
    0 0 0 1px rgba(168, 124, 255, 0.06);
}

.video-frame::after {
  position: absolute;
  z-index: 2;
  inset: 0;
  border-radius: inherit;
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.08),
    inset 0 -1px rgba(255, 255, 255, 0.04);
  content: "";
  pointer-events: none;
}

.video-overlay {
  background:
    radial-gradient(
      circle at 50% 45%,
      rgba(31, 24, 53, 0.72),
      rgba(4, 5, 8, 0.92)
    );
}

.spinner {
  width: 42px;
  height: 42px;
  border-color: rgba(255, 255, 255, 0.12);
  border-top-color: var(--accent);
  box-shadow: 0 0 24px var(--accent-glow);
}

.gesture-hint {
  top: 18px;
  padding: 8px 13px;
  border-color: var(--line-strong);
  background: rgba(8, 9, 13, 0.72);
  color: var(--text-soft);
  backdrop-filter: blur(16px);
}

.controls-row {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(
      180deg,
      rgba(29, 31, 40, 0.88),
      rgba(17, 19, 25, 0.9)
    );
  box-shadow:
    0 18px 50px rgba(0, 0, 0, 0.3),
    inset 0 1px rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(18px);
}

.quality-control,
.playback-mode-control {
  gap: 7px;
  padding-left: 4px;
  color: var(--text-muted);
  font-size: 0.74rem;
}

.quality-control select,
.playback-mode-control select {
  min-height: 40px;
  border-color: var(--line);
  border-radius: 10px;
  background: rgba(8, 9, 13, 0.72);
  color: var(--text);
}

.unseen-status {
  align-self: center;
  padding: 0 5px;
  color: var(--text-muted);
  font-size: 0.72rem;
}

.primary-button,
.secondary-button {
  min-height: 40px;
  padding: 8px 13px;
  border-radius: 10px;
  transition:
    transform 120ms ease,
    border-color 120ms ease,
    background 120ms ease,
    color 120ms ease;
}

.primary-button:hover:not(:disabled),
.secondary-button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.primary-button {
  border-color: transparent;
  background:
    linear-gradient(
      135deg,
      var(--accent-2),
      var(--accent-3)
    );
  box-shadow:
    0 10px 24px rgba(114, 76, 238, 0.28);
}

.secondary-button {
  border-color: var(--line);
  background: rgba(12, 14, 19, 0.74);
  color: var(--text-soft);
}

.secondary-button:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: rgba(40, 42, 52, 0.86);
  color: var(--text);
}

.nav-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.favorite-button.is-active {
  border-color: rgba(255, 211, 108, 0.42);
  background: rgba(255, 211, 108, 0.11);
  color: #ffd978;
}

.danger-button {
  border-color: rgba(255, 138, 153, 0.22);
  color: #ffacb7;
}

.shortcut-hint {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 15px;
  margin: 12px 3px 0;
  color: var(--text-muted);
  font-size: 0.68rem;
}

.shortcut-hint span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.shortcut-hint kbd {
  min-width: 24px;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-bottom-color: rgba(255, 255, 255, 0.22);
  border-radius: 6px;
  background: rgba(19, 21, 28, 0.78);
  color: var(--text-soft);
  font: inherit;
  text-align: center;
  box-shadow: inset 0 -1px rgba(0, 0, 0, 0.36);
}

.detail-panel {
  position: sticky;
  top: 92px;
  overflow: hidden;
  border-color: var(--line);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(
      180deg,
      rgba(30, 32, 42, 0.88),
      rgba(15, 17, 23, 0.9)
    );
  box-shadow:
    0 24px 70px rgba(0, 0, 0, 0.34),
    inset 0 1px rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(22px);
}

.detail-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

.detail-kicker {
  color: var(--text-muted);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.15em;
}

.detail-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 15px rgba(124, 224, 175, 0.7);
}

.poster-wrap {
  aspect-ratio: 16 / 10;
  background: #0c0d12;
}

.poster-wrap::after {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(
      180deg,
      transparent 55%,
      rgba(12, 13, 18, 0.7)
    );
  content: "";
  pointer-events: none;
}

.detail-copy {
  padding: 20px;
}

.release-date {
  color: var(--text-muted);
  font-size: 0.72rem;
  letter-spacing: 0.03em;
}

.detail-copy h2 {
  font-size: 1.12rem;
  line-height: 1.55;
  letter-spacing: 0.005em;
}

.metadata {
  gap: 0;
  margin: 20px 0;
}

.metadata div {
  grid-template-columns: 4.7rem minmax(0, 1fr);
  padding: 11px 0;
  border-top-color: var(--line);
}

.metadata dt {
  color: var(--text-muted);
  font-size: 0.72rem;
}

.metadata dd {
  color: var(--text-soft);
  font-size: 0.82rem;
}

.product-link {
  gap: 8px;
  min-height: 44px;
  border-color: var(--line-strong);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--text-soft);
}

.product-link:hover {
  border-color: rgba(168, 124, 255, 0.55);
  background: rgba(168, 124, 255, 0.11);
  color: var(--text);
}

.error-panel {
  border-color: rgba(255, 138, 153, 0.34);
  border-radius: var(--radius-md);
  background: rgba(83, 25, 35, 0.42);
}

.library-dialog {
  border-color: var(--line-strong);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(
      180deg,
      rgba(29, 31, 40, 0.98),
      rgba(13, 15, 20, 0.99)
    );
  box-shadow: var(--shadow-xl);
}

.library-dialog::backdrop {
  background: rgba(2, 3, 5, 0.78);
  backdrop-filter: blur(12px);
}

.library-shell {
  padding: 24px;
}

.library-tabs {
  border-bottom-color: var(--line);
}

.library-tab.is-active {
  border-bottom-color: var(--accent);
  color: var(--text);
}

.library-item {
  border-color: var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.035);
}

:where(
  button,
  select,
  a
):focus-visible {
  outline: 2px solid rgba(191, 160, 255, 0.92);
  outline-offset: 3px;
}

@media (max-width: 1120px) {
  .player-layout {
    grid-template-columns: minmax(0, 1fr) 320px;
  }

  .controls-row {
    padding: 9px;
  }
}

@media (max-width: 920px) {
  .player-shell {
    padding-inline: 18px;
  }

  .player-layout {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    position: static;
    display: grid;
    grid-template-columns: minmax(210px, 34%) 1fr;
  }

  .detail-panel-header {
    grid-column: 1 / -1;
  }
}

@media (max-width: 680px) {
  .player-shell {
    padding: 8px 10px 92px;
  }

  .topbar {
    min-height: 58px;
    margin-bottom: 12px;
    padding-inline: 4px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 11px;
  }

  .brand-copy small,
  .stage-heading-hint,
  .preload-status {
    display: none;
  }

  .player-brand-group {
    gap: 8px;
  }

  .player-nav {
    padding: 2px;
  }

  .player-nav a {
    min-width: 48px;
    padding: 7px 9px;
  }

  .status-pill {
    min-width: 0;
    padding: 7px 9px;
    font-size: 0.7rem;
  }

  .video-frame {
    border-radius: 16px;
  }

  .controls-row {
    position: fixed;
    z-index: 22;
    right: 8px;
    bottom: 8px;
    left: 8px;
    max-height: 72px;
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    border-radius: 16px;
    scrollbar-width: none;
  }

  .controls-row::-webkit-scrollbar {
    display: none;
  }

  .controls-row > * {
    flex: 0 0 auto;
  }

  .quality-control > span,
  .playback-mode-control > span,
  .unseen-status {
    display: none;
  }

  .quality-control,
  .playback-mode-control {
    padding-left: 0;
  }

  .playback-mode-control select {
    width: 128px;
    min-width: 128px;
  }

  .detail-panel {
    display: block;
    border-radius: 16px;
  }

  .detail-panel-header {
    min-height: 40px;
  }

  .poster-wrap {
    aspect-ratio: 16 / 9;
  }

  .shortcut-hint {
    display: none;
  }

  .library-shell {
    padding: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}


/* ==================================================================
   Phase 4A.1 — ambient background visibility hotfix
   ================================================================== */

body.player-page {
  isolation: isolate;
}

.ambient-backdrop {
  z-index: 0;
}

.player-shell {
  position: relative;
  z-index: 1;
}

body.has-ambient .ambient-backdrop {
  opacity: 0.68;
}

.ambient-backdrop img {
  filter:
    blur(62px)
    saturate(1.22)
    brightness(0.66);
  transform: scale(1.1);
}

.ambient-backdrop-scrim {
  background:
    radial-gradient(
      circle at 30% 20%,
      rgba(7, 8, 11, 0.08),
      rgba(7, 8, 11, 0.26) 48%,
      rgba(7, 8, 11, 0.8) 88%
    ),
    linear-gradient(
      180deg,
      rgba(7, 8, 11, 0.18),
      rgba(7, 8, 11, 0.9) 86%
    );
}

@media (max-width: 680px) {
  body.has-ambient .ambient-backdrop {
    opacity: 0.54;
  }

  .ambient-backdrop img {
    filter:
      blur(52px)
      saturate(1.15)
      brightness(0.6);
  }
}


/* ==================================================================
   Phase 4A.2 — clearly visible ambient artwork
   ================================================================== */

body.player-page {
  background:
    radial-gradient(
      circle at 8% -10%,
      rgba(146, 93, 255, 0.12),
      transparent 34rem
    ),
    linear-gradient(
      180deg,
      rgba(8, 9, 13, 0.7),
      rgba(5, 6, 9, 0.92) 72%
    );
}

.ambient-backdrop {
  inset: 0;
  overflow: hidden;
}

body.has-ambient .ambient-backdrop {
  opacity: 1;
}

.ambient-backdrop img {
  width: 112%;
  height: 112%;
  margin: -6%;
  opacity: 0.9;
  object-position: center 24%;
  filter:
    blur(34px)
    saturate(1.55)
    contrast(1.08)
    brightness(0.88);
  transform: scale(1.04);
  mix-blend-mode: screen;
}

.ambient-backdrop-scrim {
  background:
    radial-gradient(
      ellipse at 50% 16%,
      rgba(7, 8, 11, 0.02) 0%,
      rgba(7, 8, 11, 0.16) 42%,
      rgba(7, 8, 11, 0.58) 78%,
      rgba(7, 8, 11, 0.82) 100%
    ),
    linear-gradient(
      180deg,
      rgba(7, 8, 11, 0.06),
      rgba(7, 8, 11, 0.48) 56%,
      rgba(7, 8, 11, 0.88) 100%
    );
}

.player-shell::before {
  position: fixed;
  z-index: -1;
  top: 0;
  right: 0;
  left: 0;
  height: 44vh;
  background:
    linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.025),
      transparent
    );
  content: "";
  pointer-events: none;
}

@media (max-width: 680px) {
  body.has-ambient .ambient-backdrop {
    opacity: 0.92;
  }

  .ambient-backdrop img {
    opacity: 0.82;
    object-position: center top;
    filter:
      blur(28px)
      saturate(1.42)
      contrast(1.05)
      brightness(0.78);
  }

  .ambient-backdrop-scrim {
    background:
      linear-gradient(
        180deg,
        rgba(7, 8, 11, 0.12),
        rgba(7, 8, 11, 0.72) 68%,
        rgba(7, 8, 11, 0.94)
      );
  }
}


/* ==================================================================
   Phase 4A.3 — recognizable ambient artwork
   ================================================================== */

body.has-ambient .ambient-backdrop {
  opacity: 1;
}

.ambient-backdrop img {
  width: 104%;
  height: 104%;
  margin: -2%;
  opacity: 0.72;
  object-position: center 22%;
  filter:
    blur(9px)
    saturate(1.12)
    contrast(1.03)
    brightness(0.7);
  transform: scale(1.015);
  mix-blend-mode: normal;
}

.ambient-backdrop-scrim {
  background:
    linear-gradient(
      90deg,
      rgba(7, 8, 11, 0.5) 0%,
      rgba(7, 8, 11, 0.24) 42%,
      rgba(7, 8, 11, 0.38) 72%,
      rgba(7, 8, 11, 0.64) 100%
    ),
    linear-gradient(
      180deg,
      rgba(7, 8, 11, 0.1) 0%,
      rgba(7, 8, 11, 0.28) 45%,
      rgba(7, 8, 11, 0.82) 100%
    );
}

.topbar,
.controls-row,
.detail-panel {
  backdrop-filter:
    blur(18px)
    saturate(1.18);
}

@media (max-width: 680px) {
  body.has-ambient .ambient-backdrop {
    opacity: 0.94;
  }

  .ambient-backdrop img {
    width: 106%;
    height: 106%;
    margin: -3%;
    opacity: 0.66;
    object-position: center top;
    filter:
      blur(7px)
      saturate(1.08)
      contrast(1.02)
      brightness(0.62);
  }

  .ambient-backdrop-scrim {
    background:
      linear-gradient(
        180deg,
        rgba(7, 8, 11, 0.16) 0%,
        rgba(7, 8, 11, 0.42) 48%,
        rgba(7, 8, 11, 0.9) 100%
      );
  }
}


/* ==================================================================
   Phase 4A.4 — recognizable wallpaper background
   ================================================================== */

body.has-ambient .ambient-backdrop {
  opacity: 1;
}

.ambient-backdrop img {
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0.64;
  object-fit: cover;
  object-position: center 20%;
  filter:
    blur(1.5px)
    saturate(0.94)
    contrast(1.03)
    brightness(0.56);
  transform: none;
  mix-blend-mode: normal;
}

.ambient-backdrop-scrim {
  background:
    linear-gradient(
      90deg,
      rgba(7, 8, 11, 0.44) 0%,
      rgba(7, 8, 11, 0.12) 38%,
      rgba(7, 8, 11, 0.18) 62%,
      rgba(7, 8, 11, 0.54) 100%
    ),
    linear-gradient(
      180deg,
      rgba(7, 8, 11, 0.06) 0%,
      rgba(7, 8, 11, 0.2) 48%,
      rgba(7, 8, 11, 0.78) 100%
    );
}

.player-shell {
  text-shadow:
    0 1px 12px rgba(0, 0, 0, 0.34);
}

.video-frame,
.controls-row,
.detail-panel {
  box-shadow:
    0 28px 80px rgba(0, 0, 0, 0.5),
    inset 0 1px rgba(255, 255, 255, 0.05);
}

@media (max-width: 680px) {
  .ambient-backdrop img {
    opacity: 0.56;
    object-position: center top;
    filter:
      blur(1px)
      saturate(0.9)
      contrast(1.02)
      brightness(0.5);
  }

  .ambient-backdrop-scrim {
    background:
      linear-gradient(
        180deg,
        rgba(7, 8, 11, 0.1) 0%,
        rgba(7, 8, 11, 0.32) 52%,
        rgba(7, 8, 11, 0.9) 100%
      );
  }
}
