:root {
  color-scheme: dark;
  --bg: #101214;
  --panel: #191a1c;
  --panel-2: #222326;
  --text: #f4f1e8;
  --muted: #a9a397;
  --line: #34312c;
  --accent: #f5b642;
  --accent-2: #31c6b1;
  --danger: #ef6f5e;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.36);
  --page-background: #101214;
  --panel-glass: rgba(25, 26, 28, 0.94);
  --sidebar-background: rgba(13, 15, 16, 0.9);
  --field: #111315;
  --segmented: rgba(17, 19, 21, 0.9);
  --on-accent: #151515;
  --active-border: rgba(245, 182, 66, 0.48);
  --poster-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
  --poster-fallback: linear-gradient(135deg, #303835, #172724);
  --watched-background: rgba(49, 198, 177, 0.94);
  --on-watched: #07110f;
  --progress-track: rgba(8, 10, 11, 0.78);
  --badge-background: rgba(16, 18, 20, 0.86);
  --danger-background: rgba(239, 111, 94, 0.16);
  --danger-text: #ffb7ad;
  --backdrop: rgba(0, 0, 0, 0.72);
  --summary: #d6d1c6;
  --meta-surface: #101214;
  --playback-background: rgba(49, 198, 177, 0.18);
}

:root[data-resolved-theme="light"] {
  color-scheme: light;
  --bg: #f3f5f4;
  --panel: #ffffff;
  --panel-2: #e5e9e7;
  --text: #1b1f1d;
  --muted: #5f6763;
  --line: #cbd2ce;
  --accent: #d99000;
  --accent-2: #007f72;
  --danger: #b43b2f;
  --shadow: 0 20px 60px rgba(28, 39, 34, 0.16);
  --page-background: #f3f5f4;
  --panel-glass: rgba(255, 255, 255, 0.96);
  --sidebar-background: rgba(247, 249, 248, 0.94);
  --field: #ffffff;
  --segmented: #e6eae8;
  --on-accent: #171717;
  --active-border: rgba(190, 125, 0, 0.58);
  --poster-shadow: 0 10px 24px rgba(25, 41, 34, 0.16);
  --poster-fallback: linear-gradient(135deg, #dfe8e4, #cbd9d4);
  --watched-background: rgba(0, 127, 114, 0.95);
  --on-watched: #ffffff;
  --progress-track: rgba(20, 30, 26, 0.24);
  --badge-background: rgba(255, 255, 255, 0.92);
  --danger-background: rgba(180, 59, 47, 0.12);
  --danger-text: #a32f25;
  --backdrop: rgba(20, 27, 24, 0.48);
  --summary: #3e4743;
  --meta-surface: #edf0ef;
  --playback-background: rgba(0, 127, 114, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page-background);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  color: inherit;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, opacity 120ms ease, transform 120ms ease;
}

button:active:not(:disabled) {
  transform: scale(0.98);
}

button:disabled {
  cursor: default;
  opacity: 0.62;
}

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

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-glass);
  box-shadow: var(--shadow);
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 900;
  letter-spacing: 0;
}

.login-panel h1 {
  margin: 18px 0 22px;
  font-size: 30px;
  letter-spacing: 0;
}

.login-panel .app-version {
  margin: -16px 0 22px;
}

.login-panel label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 14px;
}

.login-row {
  display: flex;
  gap: 10px;
}

.login-row input,
.search input,
.toolbar select,
.theme-field select {
  min-width: 0;
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
  color: var(--text);
  padding: 0 12px;
}

.login-row button,
.search button,
.primary-button,
.mini-primary {
  min-height: 42px;
  border-radius: 6px;
  background: var(--accent);
  color: var(--on-accent);
  padding: 0 14px;
  font-weight: 800;
}

.login-row button {
  white-space: nowrap;
}

.password-field {
  position: relative;
  flex: 1;
  min-width: 0;
}

.password-field input {
  padding-right: 68px;
}

.login-row .password-toggle {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 60px;
  background: transparent;
  color: var(--text);
  padding: 0 10px;
}

.error-text {
  min-height: 22px;
  color: var(--danger);
}

.theme-field {
  display: grid;
  gap: 6px;
}

.login-panel .theme-field {
  margin-bottom: 16px;
}

.theme-field span,
.theme-field label {
  color: var(--muted);
  font-size: 12px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 22px 16px;
  border-right: 1px solid var(--line);
  background: var(--sidebar-background);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.brand .app-version {
  margin-top: 1px;
  font-size: 11px;
  text-align: left;
}

.library-list {
  display: grid;
  gap: 8px;
}

.library-button,
.ghost-button {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border-radius: 6px;
  background: transparent;
  text-align: left;
}

.library-button {
  border: 1px solid transparent;
}

.library-button[data-active="true"] {
  background: var(--panel-2);
  border-color: var(--active-border);
}

.device-downloads-button {
  border-color: var(--line);
}

.library-button span,
.library-button small {
  display: block;
}

.library-button small {
  margin-top: 2px;
  color: var(--muted);
  text-transform: capitalize;
}

.ghost-button {
  margin-top: auto;
  border: 1px solid var(--line);
  color: var(--muted);
  text-align: center;
}

.sidebar-footer {
  display: grid;
  gap: 10px;
  margin-top: auto;
}

.sidebar-footer .ghost-button {
  margin-top: 0;
}

.app-version {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.content {
  min-width: 0;
  padding: 24px;
}

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

.topbar h1 {
  margin: 5px 0 0;
  font-size: 36px;
  line-height: 1.05;
  letter-spacing: 0;
}

.breadcrumbs {
  min-height: 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.breadcrumbs button {
  padding: 0;
  background: transparent;
  color: inherit;
}

.search {
  width: min(420px, 100%);
  display: flex;
  gap: 8px;
}

.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--segmented);
}

.segmented button {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
}

.segmented button.active {
  background: var(--panel-2);
  color: var(--text);
}

.toolbar select {
  width: 165px;
}

.toolbar #genre-filter {
  width: 180px;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}

.scan-button {
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  white-space: nowrap;
}

.status {
  min-height: 24px;
  color: var(--muted);
  margin-bottom: 10px;
}

.status[data-kind="error"] {
  color: var(--danger);
}

.status[data-kind="success"] {
  color: var(--accent-2);
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 18px;
  align-items: start;
  transition: opacity 120ms ease;
}

.media-grid.is-refreshing {
  opacity: 0.64;
  pointer-events: none;
}

.load-more-button {
  display: block;
  width: min(280px, 100%);
  min-height: 42px;
  margin: 28px auto 0;
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  font-weight: 800;
}

.load-more-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.media-card {
  min-width: 0;
  content-visibility: auto;
  contain-intrinsic-size: auto 340px;
}

.poster-button {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  border-radius: 8px;
  background: var(--panel-2);
  box-shadow: var(--poster-shadow);
  transition: box-shadow 150ms ease, transform 150ms ease;
}

.poster-button img,
.poster-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  object-fit: cover;
}

.skeleton-card {
  content-visibility: visible;
  animation: skeleton-pulse 1.15s ease-in-out infinite alternate;
}

.skeleton-block,
.skeleton-line {
  background: var(--panel-2);
}

.skeleton-line {
  height: 12px;
  border-radius: 4px;
}

.skeleton-title {
  width: 78%;
  margin-top: 4px;
}

.skeleton-meta {
  width: 48%;
  margin-top: 10px;
}

@keyframes skeleton-pulse {
  from { opacity: 0.48; }
  to { opacity: 0.9; }
}

@media (hover: hover) {
  .media-card:hover .poster-button {
    transform: translateY(-2px);
    box-shadow: 0 16px 34px rgba(0, 0, 0, 0.34);
  }
}

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

.poster-fallback {
  background: var(--poster-fallback);
  color: var(--accent);
  font-size: 54px;
  font-weight: 900;
}

.watched,
.collection-badge {
  position: absolute;
  left: 8px;
  top: 8px;
  padding: 4px 7px;
  border-radius: 4px;
  background: var(--watched-background);
  color: var(--on-watched);
  font-size: 12px;
  font-weight: 800;
}

.collection-badge {
  background: var(--accent);
  color: var(--on-accent);
}

.my-list-badge {
  position: absolute;
  right: 8px;
  top: 8px;
  padding: 4px 7px;
  border-radius: 4px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 12px;
  font-weight: 800;
}

.queue-badge {
  position: absolute;
  right: 8px;
  top: 8px;
  padding: 4px 7px;
  border-radius: 4px;
  background: var(--accent-2);
  color: var(--on-accent);
  font-size: 12px;
  font-weight: 800;
}

.queue-badge.stacked {
  top: 38px;
}

.resume-progress {
  position: absolute;
  right: 8px;
  bottom: 8px;
  left: 8px;
  height: 5px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--progress-track);
}

.resume-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.subtitle-badge {
  position: absolute;
  right: 8px;
  top: 8px;
  padding: 4px 7px;
  border-radius: 4px;
  background: var(--badge-background);
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.subtitle-badge.stacked-1 {
  top: 38px;
}

.subtitle-badge.stacked-2 {
  top: 68px;
}

.card-body {
  padding-top: 9px;
}

.card-body h3 {
  min-height: 40px;
  margin: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  font-size: 15px;
  line-height: 1.35;
  letter-spacing: 0;
}

.card-body p {
  min-height: 20px;
  margin: 4px 0 8px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.mini-primary,
.mini-secondary,
.mini-danger,
.secondary-button,
.icon-button {
  min-height: 32px;
  border-radius: 6px;
}

.mini-secondary,
.secondary-button,
.icon-button {
  background: var(--panel-2);
  color: var(--text);
}

.mini-danger {
  background: var(--danger-background);
  color: var(--danger-text);
}

.danger-button {
  background: var(--danger-background);
  color: var(--danger-text);
}

.details-dialog,
.match-dialog,
.media-delete-dialog,
.collection-dialog,
.collection-name-dialog,
.player-dialog,
.subtitle-dialog,
.device-downloads-dialog,
.device-downloads-confirm {
  width: min(900px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
}

.details-dialog::backdrop,
.match-dialog::backdrop,
.media-delete-dialog::backdrop,
.collection-dialog::backdrop,
.collection-name-dialog::backdrop,
.player-dialog::backdrop,
.subtitle-dialog::backdrop,
.device-downloads-dialog::backdrop,
.device-downloads-confirm::backdrop {
  background: var(--backdrop);
}

.device-downloads-dialog {
  width: min(760px, calc(100vw - 28px));
  max-height: calc(100dvh - 28px);
  overflow: hidden;
}

.device-downloads-dialog[open] {
  display: grid;
  grid-template-rows: auto auto auto auto minmax(120px, 1fr) auto;
}

.device-downloads-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.device-downloads-head p {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.device-downloads-head h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
}

.device-storage-overview {
  display: grid;
  gap: 10px;
  margin: 18px -16px 0;
  padding: 14px 16px;
  border-block: 1px solid var(--line);
  background: var(--panel-2);
}

.device-storage-overview > div:first-child {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.device-storage-overview strong {
  font-size: 16px;
}

.device-storage-overview span {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.device-storage-meter {
  height: 6px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--progress-track);
}

.device-storage-meter span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent-2);
  transition: width 160ms ease;
}

.device-downloads-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 14px;
}

.device-downloads-toolbar > div {
  display: flex;
  gap: 8px;
}

.device-downloads-toolbar button {
  min-height: 38px;
  padding: 0 13px;
}

.device-downloads-toolbar strong {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.device-downloads-status {
  min-height: 24px;
  padding-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.device-downloads-status[data-kind="error"] {
  color: var(--danger);
}

.device-downloads-status[data-kind="success"] {
  color: var(--accent-2);
}

.device-downloads-list {
  min-height: 0;
  overflow: auto;
  border-block: 1px solid var(--line);
}

.device-download-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 70px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.device-download-row:last-child {
  border-bottom: 0;
}

.device-download-row:has(input:checked) {
  background: var(--playback-background);
}

.device-download-row input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.device-download-copy {
  min-width: 0;
}

.device-download-copy strong,
.device-download-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.device-download-copy strong {
  font-size: 15px;
}

.device-download-copy span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.device-download-size {
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.device-downloads-empty {
  margin: 0;
  padding: 28px 4px;
  color: var(--muted);
  text-align: center;
}

.device-downloads-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding-top: 14px;
}

.device-downloads-actions button {
  min-height: 42px;
}

.device-downloads-confirm {
  width: min(480px, calc(100vw - 28px));
}

.device-downloads-confirm h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.15;
}

.device-downloads-confirm p {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.device-downloads-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.device-downloads-confirm-actions button {
  min-width: 104px;
  min-height: 42px;
}

.media-delete-dialog {
  width: min(620px, calc(100vw - 28px));
  overflow-x: hidden;
}

.media-delete-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.media-delete-head > div {
  min-width: 0;
}

.media-delete-head p {
  margin: 0 0 5px;
  color: var(--danger-text);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.media-delete-head h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
}

.media-delete-status {
  min-height: 22px;
  margin: 16px 0 10px;
  color: var(--muted);
}

.media-delete-status[data-kind="error"] {
  color: var(--danger);
}

.media-delete-summary {
  margin: 0 0 12px;
  line-height: 1.5;
}

.media-delete-paths {
  max-height: 170px;
  overflow: auto;
  border-block: 1px solid var(--line);
  padding: 8px 0;
}

.media-delete-paths div {
  padding: 5px 2px;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.media-delete-warnings {
  margin: 12px 0;
  padding-left: 20px;
  color: var(--danger-text);
  line-height: 1.45;
}

.media-delete-confirm-field {
  display: grid;
  gap: 7px;
  font-size: 13px;
  font-weight: 700;
}

.media-delete-confirm-field input {
  width: 100%;
  min-height: 42px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
  color: var(--text);
}

.media-delete-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.media-delete-actions button {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 6px;
}

.collection-dialog {
  width: min(620px, calc(100vw - 28px));
  overflow-x: hidden;
}

.collection-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.collection-head > div {
  min-width: 0;
}

.collection-head .icon-button {
  flex: 0 0 auto;
}

.collection-head p {
  margin: 0 0 5px;
  color: var(--accent);
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 800;
}

.collection-head h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.collection-create-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 18px;
}

#collection-filter,
#collection-create-title,
#collection-name-input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
  color: var(--text);
  padding: 0 12px;
}

#collection-filter {
  margin-top: 10px;
}

.collection-status {
  min-height: 24px;
  margin: 10px 0;
  color: var(--muted);
  font-size: 14px;
}

.collection-status[data-kind="error"] {
  color: var(--danger);
}

.collection-status[data-kind="success"] {
  color: var(--accent-2);
}

.collection-list {
  display: grid;
  min-width: 0;
  gap: 6px;
  max-height: min(56vh, 520px);
  overflow: auto;
}

.collection-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  min-width: 0;
}

.collection-row input {
  width: 19px;
  height: 19px;
  accent-color: var(--accent);
}

.collection-row strong,
.collection-row small {
  display: block;
}

.collection-row > span:not(.collection-count) {
  min-width: 0;
}

.collection-row strong {
  overflow-wrap: anywhere;
}

.collection-row small,
.collection-count {
  color: var(--muted);
  font-size: 12px;
}

.collection-row.is-readonly {
  opacity: 0.68;
}

.collection-actions {
  display: flex;
  gap: 5px;
}

.collection-action {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--field);
  color: var(--text);
  padding: 0 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.collection-action.danger {
  color: var(--danger);
}

.collection-action:disabled {
  cursor: wait;
  opacity: 0.55;
}

.collection-name-dialog {
  width: min(430px, calc(100vw - 28px));
}

.collection-name-dialog h2 {
  margin: 0 0 16px;
  font-size: 22px;
}

.collection-name-dialog label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.collection-name-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.details-layout {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(0, 1fr);
  gap: 22px;
}

.details-layout img {
  width: 100%;
  border-radius: 8px;
}

.details-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.details-head h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
  letter-spacing: 0;
}

#details-kicker {
  margin: 0 0 7px;
  color: var(--accent);
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

#details-summary {
  color: var(--summary);
  line-height: 1.55;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.meta-row span {
  padding: 5px 8px;
  border-radius: 5px;
  background: var(--meta-surface);
  color: var(--muted);
}

.details-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.match-dialog {
  width: min(820px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  overflow-x: hidden;
}

.match-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.match-head > div {
  min-width: 0;
}

.match-head p {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.match-head h2 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 24px;
  line-height: 1.1;
}

.match-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 105px 140px auto;
  align-items: end;
  gap: 10px;
}

.match-form label {
  display: grid;
  min-width: 0;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.match-form input,
.match-form select {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
  color: var(--text);
  padding: 0 11px;
}

.match-form button {
  min-height: 42px;
}

.match-status {
  min-height: 24px;
  margin: 12px 0 8px;
  color: var(--muted);
  font-size: 14px;
}

.match-status[data-kind="error"] {
  color: var(--danger);
}

.match-status[data-kind="success"] {
  color: var(--accent-2);
}

.match-results {
  display: grid;
  max-height: min(58vh, 560px);
  gap: 7px;
  overflow: auto;
}

.match-result {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  align-items: center;
  min-width: 0;
  gap: 13px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
}

.match-result-poster {
  width: 72px;
  aspect-ratio: 2 / 3;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 5px;
  background: var(--poster-fallback);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.match-result-poster img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.match-result-copy {
  min-width: 0;
}

.match-result-heading {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.match-result-heading strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.match-badge {
  padding: 3px 6px;
  border-radius: 4px;
  background: var(--playback-background);
  color: var(--accent-2);
  font-size: 11px;
  font-weight: 800;
}

.match-badge.current {
  background: var(--meta-surface);
  color: var(--muted);
}

.match-badge.artwork {
  background: var(--playback-background);
  color: var(--accent-2);
}

.match-result-copy small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.match-result-copy p {
  display: -webkit-box;
  margin: 7px 0 0;
  overflow: hidden;
  color: var(--summary);
  font-size: 13px;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.match-result-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

.match-use,
.match-poster-use {
  min-height: 38px;
  white-space: nowrap;
}

.match-poster-use {
  border: 1px solid var(--line);
  background: var(--meta-surface);
}

.primary-button,
.secondary-button {
  padding: 0 16px;
}

.icon-button {
  width: 34px;
  padding: 0;
}

.player-dialog {
  width: min(1120px, calc(100vw - 22px));
  padding: 0;
}

.player-dialog header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 0 12px 0 16px;
}

.player-dialog header strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.player-controls label {
  color: var(--muted);
  font-size: 13px;
}

.player-controls .toggle-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  white-space: nowrap;
}

.player-controls .toggle-field[hidden],
.up-next-banner[hidden] {
  display: none;
}

.toggle-field input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.playback-mode {
  padding: 5px 8px;
  border-radius: 5px;
  background: var(--playback-background);
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.player-controls select {
  width: min(230px, 38vw);
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
  color: var(--text);
  padding: 0 8px;
}

.player-controls #playback-speed {
  width: 82px;
}

.subtitle-load-status {
  max-width: min(240px, 38vw);
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subtitle-load-status.error {
  color: var(--danger);
}

.subtitle-load-status[hidden] {
  display: none;
}

.player-controls .secondary-button {
  min-height: 32px;
  padding: 0 12px;
}

.player-stage {
  position: relative;
  background: #000;
}

.player-dialog video {
  display: block;
  width: 100%;
  max-height: calc(100vh - 120px);
  background: #000;
}

.player-dialog.window-fill {
  width: 100vw;
  max-width: none;
  height: 100vh;
  max-height: none;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: #000;
  overflow: hidden;
}

.player-dialog.window-fill header,
.player-dialog.window-fill .player-error,
.player-dialog.window-fill .up-next-banner {
  display: none;
}

.player-dialog.window-fill .player-stage,
.player-dialog.window-fill video {
  height: 100%;
  max-height: none;
}

.player-dialog.window-fill.cursor-idle {
  cursor: none;
}

.skip-intro-button {
  position: absolute;
  right: 22px;
  bottom: 72px;
  z-index: 4;
  min-width: 126px;
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 6px;
  background: rgba(18, 18, 18, 0.9);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.34);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
}

.skip-intro-button:hover,
.skip-intro-button:focus-visible {
  border-color: #fff;
  background: rgba(38, 38, 38, 0.96);
}

.skip-intro-button[hidden] {
  display: none;
}

.player-error {
  padding: 10px 16px;
  border-top: 1px solid color-mix(in srgb, var(--danger) 45%, var(--line));
  background: color-mix(in srgb, var(--danger) 12%, var(--panel-2));
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

.player-error[hidden] {
  display: none;
}

.up-next-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 50px;
  padding: 8px 12px 8px 16px;
  border-top: 1px solid var(--line);
  background: var(--panel-2);
}

.up-next-banner strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subtitle-dialog {
  width: min(760px, calc(100vw - 28px));
  max-height: calc(100dvh - 28px);
  overflow: auto;
}

.subtitle-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.subtitle-head p {
  margin: 0 0 5px;
  color: var(--accent);
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 800;
}

.subtitle-head h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
}

.subtitle-available {
  margin-bottom: 20px;
}

.subtitle-section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.subtitle-section-heading h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.2;
}

.subtitle-section-heading p {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.subtitle-count {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.subtitle-saved-status {
  min-height: 20px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.subtitle-saved-status[data-kind="error"] {
  color: var(--danger);
}

.subtitle-saved-status[data-kind="success"] {
  color: var(--accent-2);
}

.subtitle-saved-list {
  display: grid;
  gap: 8px;
  max-height: min(30vh, 260px);
  overflow: auto;
}

.subtitle-saved-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 62px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
}

.subtitle-saved-option[data-selected="true"] {
  border-color: var(--active-border);
  background: var(--playback-background);
}

.subtitle-saved-option strong,
.subtitle-saved-option p {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subtitle-saved-option p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.subtitle-saved-option button {
  min-width: 82px;
}

.subtitle-search {
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.subtitle-search-heading {
  align-items: start;
  margin-bottom: 12px;
}

.subtitle-form {
  display: grid;
  grid-template-columns: minmax(120px, 160px) minmax(0, 1fr) auto;
  gap: 10px;
}

.subtitle-form input,
.subtitle-form select {
  min-width: 0;
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
  color: var(--text);
  padding: 0 12px;
}

.subtitle-status {
  min-height: 24px;
  margin: 12px 0;
  color: var(--muted);
  font-size: 14px;
}

.subtitle-status[data-kind="error"] {
  color: var(--danger);
}

.subtitle-status[data-kind="success"] {
  color: var(--accent-2);
}

.subtitle-results {
  display: grid;
  gap: 8px;
  max-height: min(52vh, 460px);
  overflow: auto;
}

.subtitle-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
}

.subtitle-result strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subtitle-result p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
    gap: 12px;
    padding: 14px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .library-list {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: thin;
    scroll-snap-type: x proximity;
  }

  .library-button {
    flex: 0 0 auto;
    width: auto;
    min-height: 42px;
    padding: 7px 11px;
    scroll-snap-align: start;
  }

  .library-button span,
  .library-button small {
    white-space: nowrap;
  }

  .library-button small {
    display: inline;
    margin: 0 0 0 6px;
  }

  .device-storage-overview > div:first-child {
    display: grid;
    gap: 4px;
  }

  .device-storage-overview span {
    text-align: left;
  }

  .device-downloads-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .device-downloads-toolbar > div {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .device-download-row {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .device-download-size {
    grid-column: 2;
    font-size: 13px;
  }

  .sidebar-footer {
    display: flex;
    align-items: end;
    gap: 8px;
    margin-top: 0;
  }

  .sidebar-footer .theme-field {
    flex: 1 1 auto;
    min-width: 0;
  }

  .sidebar-footer .ghost-button {
    flex: 0 0 auto;
    width: auto;
    min-height: 42px;
    padding-inline: 14px;
  }

  .content {
    padding: 16px;
  }

  .topbar,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    gap: 12px;
    margin-bottom: 14px;
  }

  .topbar h1 {
    font-size: 28px;
  }

  .search,
  .toolbar-actions,
  .toolbar select {
    width: 100%;
  }

  .toolbar-actions select {
    min-width: 0;
    width: 100%;
  }

  .toolbar-actions {
    align-items: stretch;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-left: 0;
  }

  .toolbar-actions button {
    min-height: 42px;
    min-width: 0;
    width: 100%;
  }

  .segmented {
    display: flex;
    width: 100%;
    overflow-x: auto;
    scrollbar-width: thin;
    scroll-snap-type: x proximity;
  }

  .segmented button {
    flex: 0 0 auto;
    padding: 0 12px;
    font-size: 13px;
    scroll-snap-align: start;
  }

  .media-grid {
    grid-template-columns: repeat(auto-fill, minmax(135px, 1fr));
    gap: 14px;
  }

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

  .details-layout img {
    max-width: 180px;
  }

  .subtitle-form,
  .subtitle-result {
    grid-template-columns: 1fr;
  }

  .match-form {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .match-form label:first-child,
  .match-form button {
    grid-column: 1 / -1;
  }

  .match-result {
    grid-template-columns: 62px minmax(0, 1fr);
    align-items: start;
  }

  .match-result-poster {
    width: 62px;
  }

  .match-result-actions {
    grid-column: 2;
    flex-direction: row;
    flex-wrap: wrap;
    justify-self: start;
  }

  .collection-create-form {
    grid-template-columns: 1fr;
  }

  .collection-row {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .collection-actions {
    grid-column: 2 / -1;
    justify-content: flex-end;
  }

  .player-dialog header {
    align-items: flex-start;
    flex-direction: column;
    padding: 10px 12px;
  }

  .player-controls {
    justify-content: flex-start;
    width: 100%;
  }

  .player-dialog video {
    max-height: calc(100vh - 210px);
  }

  .skip-intro-button {
    right: 12px;
    bottom: 64px;
  }
}
