:root {
  color-scheme: dark;
  --bg: #000;
  --panel: #242424;
  --panel-strong: #303030;
  --text: #f5f5f1;
  --muted: #b3b3b3;
  --line: #454545;
  --red: #e50914;
  --red-deep: #b20710;
  --accent: #e50914;
  --green: #2eb67d;
  --focus: #67d5ff;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
video:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.app-shell {
  min-height: 100vh;
}

.login-view,
.profile-view {
  display: grid;
  place-content: center;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(229, 9, 20, 0.16), transparent 24rem),
    var(--bg);
  padding: 1.5rem;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 4.5rem;
  height: 4.5rem;
  margin: 0 auto 1.25rem;
  border-radius: 0.45rem;
  background: linear-gradient(135deg, var(--red), var(--red-deep));
  color: #fff;
  font-size: 2.5rem;
  font-weight: 900;
}

.login-view h1 {
  margin: 0 0 2rem;
  text-align: center;
  font-size: clamp(2.4rem, 8vw, 5rem);
  line-height: 1;
}

.app-logo-title {
  margin: 0;
  line-height: 1;
}

.app-logo-title img {
  display: block;
  width: clamp(15rem, 30vw, 24rem);
  max-width: 100%;
  height: auto;
}

.login-logo-title img {
  width: min(32rem, calc(100vw - 3rem));
  margin: 0 auto;
}

.login-form,
.profile-login-form {
  width: min(31rem, calc(100vw - 3rem));
}

.profile-login-form {
  margin: 1.15rem auto 0;
  text-align: left;
}

.login-form label,
.profile-login-form label {
  display: block;
  margin-bottom: 0.55rem;
  color: var(--muted);
}

.password-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
}

.password-row input {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 0.4rem;
  background: var(--panel);
  color: var(--text);
  padding: 0.95rem 1rem;
}

.password-row button,
.ghost-button {
  border: 1px solid transparent;
  border-radius: 0.4rem;
  background: var(--red);
  color: #fff;
  padding: 0.9rem 1rem;
  font-weight: 750;
}

.ghost-button {
  background: var(--panel-strong);
  border-color: var(--line);
}

.back-button {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 3.25rem;
  height: 3.25rem;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel-strong);
  color: var(--text);
  padding: 0;
}

.back-button:hover,
.back-button:focus-visible {
  border-color: var(--red);
}

.icon-button svg {
  width: 1.45rem;
  height: 1.45rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.back-button svg {
  width: 2rem;
  height: 2rem;
}

.form-error {
  min-height: 1.5rem;
  color: #ffb4b4;
}

.profile-shell {
  width: min(56rem, calc(100vw - 3rem));
  text-align: center;
}

.profile-view h1 {
  margin: 0 0 2rem;
  font-size: clamp(2.1rem, 6vw, 4rem);
  line-height: 1.05;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr));
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.profile-card {
  display: grid;
  justify-items: center;
  gap: 0.75rem;
  min-height: 9.25rem;
  border: 2px solid #3a3a3a;
  border-radius: 7px;
  background: #111111;
  color: var(--text);
  padding: 1rem;
}

.profile-card:hover,
.profile-card:focus,
.profile-card.is-active {
  border-color: var(--red);
  outline: 0;
  box-shadow: 0 0 0 2px rgba(229, 9, 20, 0.36);
}

.profile-avatar {
  display: grid;
  place-items: center;
  width: 4.8rem;
  height: 4.8rem;
  border: 2px solid #3a3a3a;
  border-radius: 50%;
  background: #1f1f1f;
  color: #fff;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 2rem;
  font-weight: 900;
}

.profile-name {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: 1rem;
  font-weight: 850;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.account-menu {
  position: relative;
  display: flex;
  justify-content: flex-end;
}

.profile-button {
  display: grid;
  place-items: center;
  width: 3.6rem;
  height: 3.6rem;
  border: 2px solid #3a3a3a;
  border-radius: 50%;
  background: #1f1f1f;
  color: #fff;
  padding: 0;
}

.profile-button:hover,
.profile-button:focus,
.profile-button[aria-expanded="true"] {
  border-color: var(--red);
  outline: 0;
  box-shadow: 0 0 0 2px rgba(229, 9, 20, 0.36);
}

.profile-button-initial {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  background: transparent;
  color: #fff;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 1.65rem;
  font-weight: 900;
  line-height: 1;
}

.profile-menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  right: 0;
  width: 330px;
  max-width: calc(100vw - 40px);
  border: 1px solid #555;
  border-radius: 7px;
  background: #141414;
  padding: 8px;
  font-family: Arial, Helvetica, sans-serif;
}

.profile-menu button,
.profile-menu a {
  display: block;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  color: #fff;
  padding: 14px;
  text-align: left;
  font: inherit;
  font-size: 20px;
  text-decoration: none;
}

.profile-menu button:hover,
.profile-menu button:focus,
.profile-menu a:hover,
.profile-menu a:focus {
  border-color: var(--red);
  background: #2a1214;
  outline: 0;
}

.profile-menu button:focus,
.profile-menu a:focus {
  box-shadow: 0 0 0 2px rgba(229, 9, 20, 0.36);
}

.library-view {
  position: relative;
  width: min(108rem, 100%);
  margin: 0 auto;
  padding: 1.25rem;
}

.library-view::before {
  content: "";
  position: fixed;
  z-index: 0;
  top: 50%;
  left: 50%;
  width: min(34rem, 72vmin);
  aspect-ratio: 1;
  pointer-events: none;
  transform: translate(-50%, -50%);
  background: url("/superflix-x-icon.png?v=36") center / contain no-repeat;
  opacity: 0.08;
}

.library-view > * {
  position: relative;
  z-index: 1;
}

.library-view > .topbar { z-index: 4; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid rgba(229, 9, 20, 0.7);
  padding: 1rem 0 1.25rem;
}

.topbar .app-logo-title {
  flex: 1 1 auto;
  min-width: 0;
}

.topbar h1,
.player-header h2 {
  margin: 0;
  line-height: 1.05;
}

.topbar .app-logo-title img {
  width: clamp(12rem, 24vw, 20rem);
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  flex-wrap: nowrap;
  flex: 0 0 auto;
  justify-content: flex-end;
  gap: 0.65rem;
}

.section-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  padding: 0.9rem 0 0.55rem;
}

.section-tabs button {
  min-height: 2.4rem;
  border: 1px solid var(--line);
  border-radius: 0.4rem;
  background: rgba(42, 42, 42, 0.76);
  color: var(--muted);
  padding: 0.45rem 0.8rem;
  font-weight: 800;
}

.section-tabs button:hover,
.section-tabs button:focus-visible,
.section-tabs button.is-active {
  border-color: var(--accent);
  color: var(--text);
}

.section-tabs button.is-active {
  background: rgba(229, 9, 20, 0.2);
}

.section-tabs button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.58rem;
  overflow-x: auto;
  padding: 1.05rem 0 0.35rem;
  color: var(--muted);
  font-size: clamp(1.08rem, 1.2vw, 1.35rem);
  font-weight: 850;
  line-height: 1.2;
}

.breadcrumb button {
  flex: 0 0 auto;
  border: 0;
  border-radius: 0.35rem;
  appearance: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  padding: 0.38rem 0.48rem;
}

.breadcrumb button:not(:disabled):hover,
.breadcrumb button:not(:disabled):focus-visible {
  background: var(--panel-strong);
}

.breadcrumb span {
  color: var(--muted);
  font-weight: 500;
}

.breadcrumb button:disabled {
  color: var(--accent);
  cursor: default;
  opacity: 1;
  -webkit-text-fill-color: var(--accent);
}

.folder-heading {
  padding: 0.65rem 0 0.15rem;
}

.folder-heading p {
  margin: 0;
  color: var(--muted);
}

.library-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0;
  padding: 1.35rem 0 3rem;
}

.media-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: auto;
  width: 176px;
  border: 1px solid transparent;
  border-radius: 0.5rem;
  background:
    linear-gradient(#202020, #202020) padding-box,
    linear-gradient(145deg, rgba(229, 9, 20, 0.9), rgba(46, 182, 125, 0.78)) border-box;
  background-color: #202020;
  color: inherit;
  padding: 0;
  text-align: center;
  overflow: hidden;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease, background 160ms ease;
}

.watched-badge {
  position: absolute;
  z-index: 2;
  top: 0.55rem;
  right: 0.55rem;
  display: grid;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 50%;
  background: rgba(229, 9, 20, 0.92);
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  font-weight: 950;
}

.media-duration {
  position: absolute;
  right: 0.5rem;
  bottom: 0.5rem;
  z-index: 2;
  padding: 0.22rem 0.4rem;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.82);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.media-progress {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.18);
}

.media-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--red);
}

.media-card:hover,
.media-card:focus-visible {
  border-color: var(--red);
  background: #282828;
  box-shadow: 0 0 0 1px rgba(229, 9, 20, 0.28);
  transform: translateY(-1px);
}

.library-grid > .media-card,
.search-group-grid > .media-card { margin-bottom: 16px; }

.poster {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  flex-shrink: 0;
  aspect-ratio: 16 / 9;
  border-radius: 0;
  background:
    linear-gradient(145deg, rgba(229, 9, 20, 0.95), rgba(46, 182, 125, 0.9)),
    var(--panel-strong);
  color: #fff;
  font-size: 1.45rem;
  font-weight: 950;
  overflow: hidden;
}

.poster img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 160ms ease;
}

.poster.has-image img {
  opacity: 1;
}

.poster.has-image .poster-fallback {
  display: none;
}

.media-card-content {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  min-height: 7rem;
  padding: 0.95rem 1rem 1rem;
}

.media-card h2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  min-height: 2.55em;
  margin: 0 0 0.55rem;
  overflow: hidden;
  font-size: 1.08rem;
  font-weight: 600;
  line-height: 1.18;
}

.media-meta,
.media-path {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.25;
}

.media-card:not(.collection-card) .media-card-content,
.media-card-content.is-title-only {
  min-height: 0;
}

.media-card:not(.collection-card) h2,
.media-card-content.is-title-only h2 {
  margin-bottom: 0;
}

.media-path {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  margin-top: auto;
  padding-top: 0.65rem;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.empty-state {
  padding: 3rem 0;
  color: var(--muted);
}

.empty-state h2 {
  margin: 0 0 0.5rem;
  color: var(--text);
}

.media-detail-view {
  min-height: 100vh;
  background: #000;
}

.detail-hero {
  position: relative;
  min-height: 100vh;
  /* Clip the oversized backdrop; real content determines the page height. */
  overflow: hidden;
  overflow: clip;
  isolation: isolate;
  background:
    radial-gradient(circle at 78% 16%, rgba(229, 9, 20, 0.18), transparent 28rem),
    #020202;
}

.detail-hero::before {
  content: "";
  position: absolute;
  inset: -1.25rem;
  z-index: -2;
  background: var(--detail-backdrop-image, url("/superflix-x-icon.png?v=36")) center / cover no-repeat;
  filter: blur(0.2rem);
  opacity: 0.42;
  transform: scale(1.03);
}

.detail-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.96) 0%, rgba(0, 0, 0, 0.74) 38%, rgba(0, 0, 0, 0.34) 100%),
    linear-gradient(0deg, #000 0%, rgba(0, 0, 0, 0.2) 46%, rgba(0, 0, 0, 0.78) 100%);
}

.detail-back-button {
  position: absolute;
  z-index: 3;
  top: 1.25rem;
  left: max(1.25rem, calc((100vw - 108rem) / 2 + 1.25rem));
}

.detail-hero-inner {
  display: grid;
  grid-template-columns: minmax(18rem, 36rem) minmax(0, 1fr);
  align-items: center;
  gap: clamp(1.5rem, 4vw, 4.5rem);
  width: min(108rem, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 5.75rem 1.25rem 7rem;
}

.detail-hero-inner.is-portrait-artwork {
  grid-template-columns: min(32%, 28rem) minmax(0, 1fr);
}

.detail-artwork-column {
  position: relative;
  z-index: 2;
  width: 100%;
  min-width: 0;
}

.detail-artwork {
  position: relative;
  width: 100%;
  margin: 0;
  aspect-ratio: 16 / 9;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 0.6rem;
  background:
    linear-gradient(145deg, rgba(229, 9, 20, 0.9), rgba(46, 182, 125, 0.78)),
    var(--panel-strong);
  box-shadow: 0 2rem 5rem rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.detail-artwork img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.detail-artwork-fallback {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: #fff;
  font-size: clamp(2rem, 6vw, 5rem);
  font-weight: 950;
}

.detail-artwork.has-image .detail-artwork-fallback {
  display: none;
}

.detail-summary {
  position: relative;
  z-index: 1;
  min-width: 0;
  padding-bottom: 0;
}

.detail-eyebrow {
  margin: 0 0 0.55rem;
  color: var(--accent);
  font-size: 0.84rem;
  font-weight: 900;
  text-transform: uppercase;
}

.detail-summary h1 {
  margin: 0;
  max-width: 62rem;
  font-size: clamp(2.1rem, 5vw, 5.25rem);
  line-height: 0.98;
}

.detail-subtitle {
  max-width: 56rem;
  margin: 0.85rem 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.3vw, 1.25rem);
}

.detail-action-band {
  position: relative;
  margin: 1.25rem 0;
  padding: 1rem 0;
}

/* The full-width band sits behind the artwork, not over it. */
.detail-action-band::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: 0;
  bottom: 0;
  left: -100vw;
  right: -100vw;
  border-top: 1px solid #e50914;
  border-bottom: 1px solid #e50914;
  background: #000;
  pointer-events: none;
}

.detail-action-bar {
  container-type: inline-size;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  max-width: 100%;
  margin: 0;
}

.detail-action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  flex: 0 1 auto;
  min-width: 0;
  min-height: 3rem;
  border: 1px solid rgba(247, 242, 234, 0.26);
  border-radius: 0.45rem;
  background: rgba(42, 42, 42, 0.9);
  color: var(--text);
  padding: 0.65rem 1rem;
  font-weight: 900;
}

.detail-action-button.detail-metadata-button {
  position: absolute;
  z-index: 4;
  top: 1.25rem;
  right: max(1.25rem, calc((100vw - 108rem) / 2 + 1.25rem));
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 50%;
  font: 700 24px/1 Georgia, serif;
}

.detail-action-bar .detail-action-button {
  white-space: nowrap;
}

@media (max-width: 1024px) {
  .detail-action-bar .detail-action-button {
    flex: 0 0 52px;
    width: 52px;
    height: 52px;
    padding: 0;
  }
  .detail-action-bar .detail-action-button span { display: none; }
}

@container (max-width: 40rem) {
  .detail-action-bar .detail-action-button {
    flex: 0 0 52px;
    width: 52px;
    height: 52px;
    padding: 0;
  }
  .detail-action-bar .detail-action-button span { display: none; }
}

.detail-action-button svg {
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.detail-action-button svg polygon {
  fill: currentColor;
  stroke: currentColor;
}

.detail-action-button:hover,
.detail-action-button:focus-visible {
  border-color: var(--red);
  background: rgba(229, 9, 20, 0.25);
}

.detail-action-primary {
  border-color: var(--red);
  background: var(--red);
}

.detail-action-primary:hover,
.detail-action-primary:focus-visible {
  background: var(--red-deep);
}

.detail-essential-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 0.8rem;
  max-width: 58rem;
  margin: 1rem 0 0;
}

.detail-progress {
  position: absolute;
  z-index: 2;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.18);
}

.detail-progress span {
  display: block;
  height: 100%;
  background: var(--red);
}

.detail-watched-badge {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 2.6rem;
  height: 2.6rem;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 50%;
  background: rgba(229, 9, 20, 0.92);
  color: #fff;
  font-size: 1.35rem;
  font-weight: 950;
}

.detail-duration {
  position: absolute;
  z-index: 2;
  right: 0.65rem;
  bottom: 0.65rem;
  padding: 0.25rem 0.45rem;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.82);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.detail-essential-field {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-left: 2px solid var(--red);
  border-radius: 0.45rem;
  background: rgba(18, 18, 18, 0.7);
  padding: 0.78rem 0.9rem;
}

.detail-essential-field.detail-superscore-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-content: center;
  align-items: center;
  gap: 0.45rem;
}

.detail-essential-field.detail-superscore-field dt {
  margin: 0;
  color: var(--text);
  font-size: 1rem;
  font-weight: 850;
  text-transform: none;
}

.detail-essential-field.detail-superscore-field dd {
  color: #ffd166;
}

.superscore-select {
  appearance: auto;
  max-width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  background: #1c1c1c;
  color: #ffd166;
  font: inherit;
  font-weight: 900;
  padding: 0.15rem 0.25rem;
}

.detail-essential-field.detail-superscore-field .score-status {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 400;
}

.superscore-select:focus-visible {
  outline: 1px solid var(--red);
  outline-offset: 0.2rem;
}

.detail-essential-field dt {
  margin: 0 0 0.25rem;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 900;
  text-transform: uppercase;
}

.detail-essential-field dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 1rem;
  font-weight: 850;
}

.detail-status {
  margin: 1rem 0 0;
  color: var(--accent);
}

.detail-catalog { margin-top: 1rem; max-width: 58rem; }
.detail-catalog-facts { max-width: 58rem; }
.catalog-description { margin: 0 0 0.9rem; color: #e4e4e4; font-size: 1rem; line-height: 1.55; overflow-wrap: anywhere; }
.catalog-facts {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-left: 2px solid var(--red);
  border-radius: 0.45rem;
  background: rgba(18, 18, 18, 0.7);
  padding: 0.78rem 0.9rem;
  color: #bdbdbd;
  font-size: 0.88rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.catalog-facts > * { display: block; }
.catalog-facts > * + * { margin-top: 0.35rem; }
.catalog-facts a { color: #ffd166; text-decoration: none; }
.catalog-manage-link { display: inline-block; margin-top: 1rem; color: #fff; text-underline-offset: 3px; }
.catalog-credit { font-size: 0.85rem; }
.catalog-credit a { color: #aaa; }

.metadata-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.72);
  padding: 1.25rem;
  backdrop-filter: blur(12px);
}

.metadata-dialog {
  display: flex;
  flex-direction: column;
  width: min(78rem, 100%);
  height: min(86vh, 62rem);
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  background: rgba(12, 12, 12, 0.98);
  box-shadow: 0 2rem 6rem rgba(0, 0, 0, 0.62);
  overflow: hidden;
}

.metadata-dialog-header {
  flex-shrink: 0;
  position: sticky;
  z-index: 1;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
  background: rgba(12, 12, 12, 0.98);
  padding: 1rem;
}

.metadata-dialog-header h2 {
  margin: 0;
  font-size: 1.45rem;
}

.metadata-dialog-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  padding: 1rem;
}

.detail-section {
  min-width: 0;
}

.detail-section h3 {
  margin: 0 0 0.85rem;
  font-size: 1rem;
  color: var(--muted);
}

.detail-meta-grid {
  display: grid;
  grid-template-columns: minmax(10rem, 0.36fr) minmax(0, 1fr);
  gap: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: rgba(24, 24, 24, 0.78);
  overflow: hidden;
}

.detail-meta-grid dt,
.detail-meta-grid dd {
  min-width: 0;
  margin: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0.75rem 0.85rem;
}

.detail-meta-grid dt {
  color: var(--muted);
  font-weight: 850;
}

.detail-meta-grid dd {
  overflow-wrap: anywhere;
}

.detail-meta-grid dt:nth-last-child(2),
.detail-meta-grid dd:last-child {
  border-bottom: 0;
}

.detail-empty {
  grid-column: 1 / -1;
  color: var(--muted);
}

.detail-status {
  margin: 0.85rem 0 0;
  color: var(--accent);
}

.player-view {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 0;
  background: #050505;
}

.player-header {
  position: absolute;
  z-index: 2;
  top: 0;
  right: 0;
  left: 0;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.82), transparent);
  opacity: 1;
  transform: translateY(0);
  transition: opacity 180ms ease, transform 180ms ease;
}

.player-header h2 {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  font-size: clamp(1.15rem, 2vw, 1.75rem);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-stage {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  background: #000;
  overflow: hidden;
}

.video-player {
  display: block;
  width: 100%;
  height: 100%;
  background: #000;
  object-fit: contain;
}

.player-controls {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.75rem;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.86) 22%);
  opacity: 1;
  transform: translateY(0);
  transition: opacity 180ms ease, transform 180ms ease;
}

.player-stage.controls-hidden {
  cursor: none;
}

.player-stage.controls-hidden .player-controls {
  opacity: 0;
  pointer-events: none;
  transform: translateY(0.75rem);
}

.player-stage.controls-hidden .player-header {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-0.75rem);
}

.control-button {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  min-width: 2.75rem;
  width: 2.75rem;
  height: 2.5rem;
  border: 1px solid rgba(247, 242, 234, 0.28);
  border-radius: 0.35rem;
  background: rgba(42, 42, 42, 0.9);
  color: var(--text);
  padding: 0 0.65rem;
  font-weight: 850;
}

.control-button:hover,
.control-button:focus-visible,
.control-button.is-active {
  border-color: var(--accent);
  background: rgba(229, 9, 20, 0.24);
}

.control-button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.caption-button {
  font-size: 0.88rem;
  letter-spacing: 0;
}

.control-cluster {
  position: relative;
  flex: 0 0 auto;
}

.control-popover {
  position: absolute;
  z-index: 3;
  right: 0;
  bottom: calc(100% + 0.65rem);
  border: 1px solid rgba(247, 242, 234, 0.25);
  border-radius: 0.45rem;
  background: rgba(12, 12, 12, 0.97);
  box-shadow: 0 1rem 2.5rem rgba(0, 0, 0, 0.42);
}

.volume-popover {
  display: grid;
  place-items: center;
  width: 3.25rem;
  height: 9rem;
  padding: 0.8rem 0.45rem;
}

.caption-popover {
  min-width: 13rem;
  max-width: min(18rem, calc(100vw - 2rem));
  max-height: 10rem;
  overflow-y: auto;
  padding: 0.35rem;
}

.caption-option {
  display: block;
  width: 100%;
  min-height: 2.3rem;
  border: 0;
  border-radius: 0.35rem;
  background: transparent;
  color: var(--text);
  padding: 0.55rem 0.65rem;
  text-align: left;
}

.caption-option:hover,
.caption-option:focus-visible,
.caption-option.is-active {
  background: rgba(229, 9, 20, 0.22);
  color: #fff;
}

.time-label {
  flex: 0 0 3.4rem;
  color: var(--text);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.seek-bar {
  flex: 1 1 10rem;
  min-width: 7rem;
  accent-color: var(--red);
}

.volume-slider {
  width: 2.2rem;
  height: 7.2rem;
  accent-color: var(--accent);
  cursor: pointer;
  writing-mode: vertical-lr;
  direction: rtl;
}

.control-spacer {
  flex: 0 1 0.4rem;
}

.player-expanded,
.player-expanded body {
  overflow: hidden;
}

.player-view.is-expanded {
  position: fixed;
  z-index: 50;
  top: 0;
  right: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.player-view.is-expanded .player-stage {
  height: 100%;
}

.player-view.is-expanded .player-header {
  padding-top: max(0.85rem, env(safe-area-inset-top));
  padding-left: max(0.85rem, env(safe-area-inset-left));
  padding-right: max(0.85rem, env(safe-area-inset-right));
}

.player-view.is-expanded .player-controls {
  padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
  padding-left: max(0.75rem, env(safe-area-inset-left));
  padding-right: max(0.75rem, env(safe-area-inset-right));
}

.player-view.is-expanded .player-error {
  position: absolute;
  z-index: 4;
  top: 6rem;
  right: 1rem;
  left: 1rem;
}

.player-status {
  position: absolute;
  z-index: 4;
  top: 4.75rem;
  left: 1rem;
  margin: 0;
  color: var(--accent);
}

.player-error {
  margin: 0.75rem 0 0;
  color: #ffb4b4;
}

[hidden] {
  display: none !important;
}

@media (max-width: 720px) {
  .topbar {
    align-items: center;
    flex-direction: row;
    gap: 0.75rem;
  }

  .topbar .app-logo-title img {
    width: min(14rem, calc(100vw - 7.25rem));
  }

  .topbar-actions {
    justify-content: flex-end;
  }

  .password-row button {
    width: 100%;
  }

  .password-row {
    grid-template-columns: 1fr;
  }

  .library-grid {
    gap: 0;
    padding-top: 1rem;
  }

  .media-card-content {
    min-height: 6.45rem;
    padding: 0.7rem 0.72rem 0.78rem;
  }

  .media-card h2 {
    font-size: 0.92rem;
    line-height: 1.15;
    min-height: 2.3em;
    margin-bottom: 0.4rem;
  }

  .media-meta,
  .media-path {
    font-size: 0.78rem;
  }

  .media-detail-view {
    min-height: 100vh;
  }

  .detail-back-button {
    top: 1rem;
    left: 1rem;
  }

  .detail-action-button.detail-metadata-button {
    top: 1rem;
    right: 1rem;
  }

  .detail-hero-inner,
  .detail-hero-inner.is-portrait-artwork,
  .detail-hero-inner.is-landscape-artwork {
    grid-template-columns: 1fr;
    align-items: end;
    gap: 1.1rem;
    padding: 5.75rem 1rem 2rem;
  }

  .detail-hero-inner.is-portrait-artwork .detail-artwork-column {
    width: 80%;
    margin: 0 auto;
  }

  .detail-summary h1 {
    font-size: clamp(2rem, 12vw, 3.6rem);
  }

  .detail-action-bar,
  .detail-essential-grid {
    width: 100%;
  }

  .detail-essential-grid {
    grid-template-columns: 1fr;
  }

  .detail-meta-grid {
    grid-template-columns: 1fr;
  }

  .detail-meta-grid dt {
    border-bottom: 0;
    padding-bottom: 0.2rem;
  }

  .detail-meta-grid dd {
    padding-top: 0.2rem;
  }

  .player-controls {
    flex-wrap: wrap;
    padding: 0.65rem;
  }

  .seek-bar {
    flex-basis: 9rem;
  }

  .volume-slider {
    height: 6rem;
  }
}

@media (orientation: landscape) and (max-height: 620px) and (max-width: 1024px) {
  .detail-hero-inner,
  .detail-hero-inner.is-portrait-artwork,
  .detail-hero-inner.is-landscape-artwork {
    grid-template-columns: minmax(14rem, 38vw) minmax(0, 1fr);
    align-items: center;
    gap: 1rem;
    min-height: 100svh;
    padding: 4.2rem 1rem 2rem;
  }

  .detail-hero-inner.is-portrait-artwork {
    grid-template-columns: 28vw minmax(0, 1fr);
  }

  .detail-hero-inner.is-portrait-artwork .detail-artwork-column {
    width: 100%;
  }

  .detail-summary h1 {
    font-size: clamp(1.75rem, 4.7vw, 3.1rem);
    line-height: 1;
  }

  .detail-subtitle {
    margin-top: 0.45rem;
    font-size: 0.95rem;
  }

  .detail-action-bar {
    gap: 0.5rem;
  }

  .detail-action-button {
    min-height: 44px;
    padding: 0.42rem 0.65rem;
    font-size: 0.86rem;
  }

  .detail-essential-grid {
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
    gap: 0.5rem;
    margin-top: 0.65rem;
  }

  .detail-essential-field {
    padding: 0.55rem 0.6rem;
  }

  .detail-essential-field dt {
    font-size: 0.68rem;
  }

  .detail-essential-field dd {
    font-size: 0.86rem;
  }

  .detail-essential-field.detail-superscore-field dt {
    font-size: 0.86rem;
  }

}
