:root {
  --bg: #05070a;
  --panel: #11161d;
  --panel-strong: #171f29;
  --text: #f1f7fb;
  --muted: #91a3ae;
  --cyan: #00d9ff;
  --cyan-soft: rgba(0, 217, 255, 0.2);
  --border: rgba(255, 255, 255, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, Segoe UI, Arial, sans-serif;
  scrollbar-color: rgba(0, 217, 255, 0.55) rgba(255, 255, 255, 0.06);
}

body.admin-panel-open {
  overflow: hidden;
}

::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(90deg, rgba(0, 217, 255, 0.28), rgba(0, 217, 255, 0.72));
  border: 3px solid rgba(5, 7, 10, 0.88);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--cyan);
}

.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(rgba(5, 7, 10, 0.72), rgba(5, 7, 10, 0.96)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.08) 0 1px, transparent 1px 154px),
    repeating-linear-gradient(0deg, rgba(0, 217, 255, 0.08) 0 1px, transparent 1px 226px),
    radial-gradient(circle at 50% 5%, rgba(0, 217, 255, 0.28), transparent 34%),
    #06090d;
  filter: saturate(1.2);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(220px, 560px) auto;
  gap: 18px;
  align-items: center;
  padding: 18px 34px;
  background: rgba(5, 7, 10, 0.78);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(20px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  width: fit-content;
  color: var(--text);
  text-decoration: none;
  font-size: 18px;
  font-weight: 700;
  border-radius: 8px;
}

.brand:hover .brand-mark,
.brand:focus-visible .brand-mark {
  box-shadow: 0 0 30px rgba(0, 217, 255, 0.34), inset 0 0 16px rgba(0, 217, 255, 0.28);
}

.brand:focus-visible {
  outline: 2px solid rgba(0, 217, 255, 0.72);
  outline-offset: 6px;
}

.topbar-actions {
  justify-self: end;
  display: flex;
  gap: 10px;
}

.system-banner {
  display: grid;
  gap: 6px;
  margin: 18px 34px 0;
  padding: 14px 16px;
  color: var(--text);
  background: rgba(255, 184, 77, 0.12);
  border: 1px solid rgba(255, 184, 77, 0.42);
  border-radius: 8px;
}

.system-banner-critical {
  background: rgba(255, 82, 82, 0.12);
  border-color: rgba(255, 82, 82, 0.48);
}

.system-banner strong {
  font-size: 14px;
}

.system-banner p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.update-banner {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.update-banner-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.update-banner-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.update-banner .close-button {
  position: static;
  flex: 0 0 auto;
}

@media (max-width: 640px) {
  .update-banner {
    grid-template-columns: 1fr;
  }

  .update-banner-actions {
    justify-content: space-between;
  }
}

.brand-mark,
.login-mark {
  width: 26px;
  height: 26px;
  border: 2px solid var(--cyan);
  border-radius: 6px;
  box-shadow: 0 0 24px var(--cyan-soft), inset 0 0 14px var(--cyan-soft);
}

.search-shell {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  width: 100%;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
}

.search-shell input,
.login-modal input,
.self-account-form input,
.account-form input,
.library-form input,
.settings-form input,
.download-form input,
.poster-form input,
.manual-copy-bar input,
.subtitle-search input,
.metadata-match-modal input,
.series-poster-modal input,
.channel-match-modal input,
select,
textarea {
  width: 100%;
  color: var(--text);
  background: transparent;
  border: 0;
  outline: 0;
  font: inherit;
}

.icon-button,
.close-button {
  justify-self: end;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 13px;
  cursor: pointer;
}

.shell {
  padding: 28px 34px 80px;
}

.home-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin: 0 0 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.home-toolbar h2,
.home-toolbar p {
  margin: 0;
}

.live-tv-view {
  display: grid;
  gap: 18px;
}

body.live-tv-page .shell {
  padding-right: 0;
  padding-left: 0;
}

body.live-tv-page .live-tv-heading,
body.live-tv-page .live-tv-filter {
  margin-right: 34px;
  margin-left: 34px;
}

.live-tv-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.live-tv-heading h2,
.live-tv-heading p {
  margin: 0;
}

.live-tv-heading .status {
  margin-top: 6px;
}

.live-tv-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 8px;
}

.guide-arrow-button {
  display: grid;
  place-items: center;
  width: 42px;
  min-width: 42px;
  min-height: 38px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

.live-tv-guide {
  min-width: 0;
}

.live-tv-filter {
  display: grid;
  grid-template-columns: auto minmax(220px, 420px);
  gap: 12px;
  align-items: center;
  width: fit-content;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.live-tv-filter input {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  color: var(--text);
  background: #111820;
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: 0;
  font: inherit;
}

.live-tv-filter input:focus {
  border-color: var(--cyan);
}

.guide-scroll {
  max-height: none;
  overflow-x: auto;
  overflow-y: visible;
  background: #0b1016;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.guide-row {
  display: grid;
  grid-template-columns: 210px minmax(var(--guide-min-width), 1fr);
  width: max(100%, calc(210px + var(--guide-min-width)));
  min-height: 82px;
  border-bottom: 1px solid var(--border);
}

.guide-time-row {
  position: sticky;
  top: 0;
  z-index: 4;
  min-height: 48px;
  background: #101720;
}

.guide-channel-cell {
  position: sticky;
  left: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-width: 0;
  padding: 10px 12px;
  color: var(--text);
  text-align: left;
  background: #111820;
  border: 0;
  border-right: 1px solid var(--border);
  cursor: pointer;
}

.guide-channel-cell:hover,
.guide-channel-cell:focus-visible {
  background: #16232c;
  outline: 2px solid rgba(0, 217, 255, 0.5);
  outline-offset: -2px;
}

.guide-channel-cell img,
.guide-channel-initials {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  object-fit: contain;
  color: var(--cyan);
  background: #080c11;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 900;
}

.guide-channel-cell strong,
.guide-channel-cell small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.guide-channel-cell small {
  margin-top: 4px;
  color: var(--muted);
}

.guide-time-corner {
  z-index: 5;
  grid-template-columns: 1fr;
  min-height: 48px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
  cursor: default;
}

.guide-track {
  position: relative;
  min-width: 0;
  background: repeating-linear-gradient(90deg, transparent 0 119px, rgba(255, 255, 255, 0.06) 119px 120px);
}

.guide-time-track span {
  position: absolute;
  top: 16px;
  color: var(--muted);
  font-size: 12px;
  transform: translateX(8px);
}

.guide-programme {
  position: absolute;
  top: 6px;
  bottom: 6px;
  display: grid;
  align-content: center;
  gap: 5px;
  min-width: 0;
  overflow: hidden;
  padding: 9px 11px;
  color: var(--text);
  text-align: left;
  background: #1b2631;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  cursor: pointer;
}

.guide-programme:hover,
.guide-programme:focus-visible {
  z-index: 2;
  background: #243746;
  border-color: var(--cyan);
  outline: 0;
}

.guide-programme.current {
  background: #173440;
  border-color: rgba(0, 217, 255, 0.72);
}

.guide-programme strong,
.guide-programme span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.guide-programme strong {
  font-size: 14px;
}

.guide-programme span {
  color: var(--muted);
  font-size: 11px;
}

.guide-programme-empty {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
}

.guide-now-line {
  position: absolute;
  inset-block: 0;
  z-index: 3;
  width: 2px;
  pointer-events: none;
  background: #ff4f87;
  box-shadow: 0 0 10px rgba(255, 79, 135, 0.6);
}

.guide-empty {
  margin: 0;
  padding: 28px;
  color: var(--muted);
}

.segmented-control {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  min-width: min(360px, 100%);
  padding: 3px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.segmented-control button {
  min-height: 38px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 6px;
  padding: 8px 12px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.segmented-control button.active {
  color: #001217;
  background: var(--cyan);
}

.segmented-control button:not(.active):hover,
.segmented-control button:not(.active):focus-visible {
  color: var(--text);
  background: rgba(0, 217, 255, 0.12);
  outline: 0;
}

.row {
  margin: 0 0 34px;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
}

.section-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

h2 {
  margin: 0;
  font-size: 22px;
}

.rail {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 168px;
  gap: 14px;
  overflow-x: auto;
  padding: 2px 0 18px;
  scrollbar-color: rgba(0, 217, 255, 0.68) rgba(255, 255, 255, 0.06);
  scrollbar-width: thin;
}

.rail::-webkit-scrollbar {
  height: 10px;
}

.rail::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
}

.rail::-webkit-scrollbar-thumb {
  background: linear-gradient(90deg, rgba(0, 217, 255, 0.38), rgba(0, 217, 255, 0.78));
  border: 2px solid rgba(5, 7, 10, 0.9);
  border-radius: 999px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(154px, 178px));
  gap: 16px;
}

.card {
  display: grid;
  grid-template-rows: auto 5px 1.35em 2.7em;
  gap: 9px;
  min-width: 0;
  align-content: start;
  background: transparent;
  border: 0;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.poster {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 2 / 3;
  border-radius: 8px;
  border: 1px solid var(--border);
  background:
    linear-gradient(145deg, rgba(0, 217, 255, 0.28), rgba(255, 255, 255, 0.04)),
    linear-gradient(30deg, #121923, #252d38);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.34);
  font-size: 42px;
  font-weight: 800;
  background-position: center;
  background-size: cover;
  overflow: hidden;
}

.poster.is-watched,
.poster-large.is-watched {
  box-shadow:
    0 0 0 1px rgba(0, 217, 255, 0.34),
    0 16px 32px rgba(0, 0, 0, 0.34);
}

.watched-marker {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  display: block;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.4);
}

.watched-marker::after {
  content: "";
  position: absolute;
  left: 8px;
  top: 6px;
  width: 7px;
  height: 12px;
  border: solid #001217;
  border-width: 0 3px 3px 0;
  transform: rotate(45deg);
}

.new-episode-marker {
  position: absolute;
  left: 8px;
  bottom: 8px;
  z-index: 2;
  max-width: calc(100% - 16px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid rgba(0, 217, 255, 0.48);
  border-radius: 999px;
  padding: 5px 8px;
  color: #001217;
  background: var(--cyan);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.42);
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}

.poster.with-image {
  background-color: #101820;
  background-image: var(--poster-image);
}

.poster.thumbnail-art {
  aspect-ratio: 16 / 9;
  font-size: 30px;
}

.poster.thumbnail-art.with-image {
  background-repeat: no-repeat;
  background-size: cover;
}

.poster.image-art,
.poster.image-art.with-image {
  aspect-ratio: 1;
  background-size: contain;
  background-repeat: no-repeat;
}

.poster.image-folder-art,
.poster.image-folder-art.with-image {
  aspect-ratio: 1;
  background-color: #101820;
  background-size: cover;
  background-repeat: no-repeat;
}

.poster.playlist-art,
.poster.playlist-art.with-image {
  aspect-ratio: 2 / 3;
  background-color: #101820;
  background-size: cover;
  background-repeat: no-repeat;
}

.card:hover .poster,
.card:focus-visible .poster {
  border-color: var(--cyan);
  transform: translateY(-3px);
}

.card-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.35;
  font-weight: 700;
}

.card-progress-slot {
  height: 5px;
}

.card-progress-slot .progress-track {
  height: 100%;
}

.progress-track {
  height: 5px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.11);
  border-radius: 999px;
}

.progress-fill {
  display: block;
  height: 100%;
  width: var(--progress, 0%);
  background: var(--cyan);
}

.card-subtitle,
.eyebrow,
.status,
.field-note,
.error {
  color: var(--muted);
  font-size: 13px;
}

.card-subtitle {
  display: -webkit-box;
  height: 2.7em;
  overflow: hidden;
  line-height: 1.35;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.field-note {
  line-height: 1.35;
}

.detail-progress {
  display: grid;
  gap: 8px;
}

.hidden {
  display: none !important;
}

.details {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(220px, 34%) 1fr;
  gap: 24px;
  width: min(860px, 100vw);
  height: 100vh;
  padding: 28px;
  background: rgba(10, 14, 19, 0.96);
  border-left: 1px solid var(--border);
  box-shadow: -20px 0 80px rgba(0, 0, 0, 0.6);
  transform: translateX(100%);
  transition: transform 180ms ease;
  overflow-y: auto;
}

.details.open {
  transform: translateX(0);
}

.image-viewer {
  position: fixed;
  inset: 0 min(520px, 42vw) 0 0;
  z-index: 15;
  display: grid;
  place-items: center;
  padding: 72px 36px 36px;
  background: rgba(2, 5, 8, 0.94);
}

.image-viewer img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.58);
}

.image-viewer-close {
  right: auto;
  left: 18px;
  z-index: 1;
}

body.image-viewer-open .details {
  width: min(520px, 42vw);
  grid-template-columns: 1fr;
}

body.image-viewer-open .details .poster-panel {
  display: none;
}

.close-button {
  position: absolute;
  top: 18px;
  right: 18px;
}

.poster-panel {
  display: grid;
  align-self: start;
  gap: 12px;
}

.poster-large {
  position: relative;
  display: grid;
  place-items: center;
  align-self: start;
  aspect-ratio: 2 / 3;
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(0, 217, 255, 0.35), rgba(255, 255, 255, 0.05)),
    linear-gradient(20deg, #111820, #2c3541);
  border: 1px solid var(--border);
  font-size: 68px;
  font-weight: 800;
  background-position: center;
  background-size: cover;
  overflow: hidden;
}

.poster-large.with-image {
  background-color: #101820;
  background-image: var(--poster-image);
}

.poster-large.thumbnail-art {
  aspect-ratio: 16 / 9;
  font-size: 48px;
}

.poster-large.image-preview {
  aspect-ratio: 1;
  background-size: contain;
  background-repeat: no-repeat;
}

.poster-form {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.poster-form.hidden {
  display: none;
}

.details-body {
  display: grid;
  align-content: start;
  gap: 16px;
  min-width: 0;
  min-height: 100%;
}

.details h1 {
  margin: 0;
  font-size: 34px;
}

.overview {
  margin: 0;
  color: #c9d5db;
  line-height: 1.5;
}

.file-path-block {
  display: grid;
  gap: 8px;
}

.file-path-block .compact-button {
  justify-self: start;
  min-width: 150px;
}

.hierarchy-nav,
.view-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.nav-chip {
  min-height: 34px;
  color: var(--text);
  background: rgba(0, 217, 255, 0.1);
  border: 1px solid rgba(0, 217, 255, 0.42);
  border-radius: 8px;
  padding: 7px 11px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.text-button {
  color: var(--cyan);
  background: transparent;
  border: 0;
  padding: 4px 0;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.text-button:hover,
.text-button:focus-visible {
  color: var(--text);
  outline: 0;
}

.nav-chip:hover,
.nav-chip:focus-visible {
  background: rgba(0, 217, 255, 0.2);
  outline: 0;
}

.library-results {
  display: grid;
  gap: 18px;
}

.library-status {
  min-height: 18px;
  margin: 4px 0 0;
}

.library-sentinel {
  min-height: 1px;
}

.view-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin: 0 0 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.view-header h2,
.view-header p {
  margin: 0;
}

.details label,
.self-account-form label,
.account-form label,
.library-form label,
.settings-form label,
.login-modal {
  display: grid;
  gap: 8px;
}

select,
textarea,
.subtitle-search input,
.metadata-match-modal input,
.channel-match-modal input,
.self-account-form input,
.account-form input,
.library-form input,
.settings-form input,
.download-form input,
.poster-form input,
.login-modal input {
  min-height: 44px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}

select {
  color-scheme: dark;
  color: var(--text);
  background-color: rgba(17, 22, 29, 0.98);
  border-color: rgba(0, 217, 255, 0.24);
}

select:focus {
  border-color: rgba(0, 217, 255, 0.72);
  box-shadow: 0 0 0 3px rgba(0, 217, 255, 0.12);
}

select option,
select optgroup {
  color: var(--text);
  background-color: #11161d;
}

select option:checked {
  color: #001217;
  background-color: var(--cyan);
}

textarea {
  resize: vertical;
}

.subtitle-search {
  display: grid;
  gap: 10px;
}

.subtitle-search-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.library-view-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 18px;
}

.library-sort-control,
.library-filter-control {
  min-width: min(320px, 100%);
}

.metadata-match-modal {
  width: min(720px, 100%);
}

.series-poster-modal {
  width: min(560px, 100%);
}

.series-poster-modal h2,
.series-poster-modal p {
  margin: 0;
}

.series-poster-form {
  display: grid;
  gap: 12px;
}

.series-poster-form label {
  display: grid;
  gap: 8px;
}

.metadata-match-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(90px, 140px) auto;
  gap: 12px;
  align-items: end;
}

.metadata-match-form label,
.metadata-match-modal label {
  display: grid;
  gap: 8px;
}

.choice-modal.channel-match-modal {
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(1240px, 100%);
  height: min(820px, calc(100vh - 48px));
  padding: 26px;
  overflow: hidden;
}

.channel-match-header,
.channel-match-footer,
.channel-match-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.channel-match-header h2,
.channel-match-header p,
.channel-match-footer p {
  margin: 0;
}

.channel-match-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(420px, 1.2fr);
  min-height: 0;
  border-block: 1px solid var(--border);
}

.channel-match-column {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  min-width: 0;
  min-height: 0;
  padding: 18px 18px 18px 0;
}

.channel-match-guide-column {
  grid-template-rows: auto auto minmax(0, 1fr);
  padding-inline: 18px 0;
  border-left: 1px solid var(--border);
}

.channel-match-column label {
  display: grid;
  flex: 1;
  gap: 8px;
  min-width: 0;
}

.channel-match-grid select {
  width: 100%;
  min-height: 0;
  padding: 6px;
}

.channel-match-grid option,
.channel-match-grid optgroup {
  padding: 7px 9px;
}

.channel-match-count {
  align-self: end;
  padding-bottom: 12px;
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.channel-match-selection {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 240px);
  align-items: center;
  gap: 16px;
  min-height: 52px;
  padding: 10px 12px;
  color: var(--muted);
  background: rgba(0, 217, 255, 0.06);
  border-left: 3px solid var(--cyan);
}

.channel-match-selection strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.channel-deinterlace-control {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.85rem;
}

.channel-deinterlace-control select {
  min-height: 38px;
  padding-block: 6px;
}

.channel-match-footer .status {
  min-width: 0;
}

.library-form {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(130px, 180px) minmax(220px, 2fr) minmax(180px, auto) minmax(130px, auto);
  gap: 12px;
  align-items: end;
}

.library-progress-field,
.library-progress-toggle {
  display: flex !important;
  align-items: center;
  gap: 9px !important;
  color: var(--text);
}

.library-progress-field {
  min-height: 44px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.library-progress-toggle {
  width: fit-content;
  min-height: 34px;
}

.library-progress-field input[type="checkbox"],
.library-progress-toggle input[type="checkbox"] {
  width: 18px;
  min-height: 18px;
  height: 18px;
  padding: 0;
  accent-color: var(--cyan);
}

.path-picker-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: stretch;
}

.path-picker-control input {
  cursor: default;
}

.folder-picker {
  display: grid;
  gap: 12px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.folder-picker.hidden {
  display: none;
}

.folder-picker-heading,
.folder-picker-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.folder-picker-heading strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--text);
}

.folder-roots {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.folder-list {
  display: grid;
  max-height: 320px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.folder-row {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 10px 12px;
  color: var(--text);
  text-align: left;
  background: rgba(0, 0, 0, 0.18);
  border: 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

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

.folder-row:hover,
.folder-row:focus-visible {
  background: rgba(0, 217, 255, 0.12);
  outline: 0;
}

.folder-row small {
  overflow-wrap: anywhere;
  color: var(--muted);
}

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

.library-manager-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: grab;
}

.library-manager-card[draggable="false"] {
  cursor: default;
}

.library-manager-card.dragging {
  opacity: 0.48;
  cursor: grabbing;
}

.library-manager-card.drop-target {
  border-color: rgba(0, 217, 255, 0.78);
  box-shadow: 0 0 0 2px rgba(0, 217, 255, 0.14);
}

.optimizer-library-card {
  width: 100%;
  cursor: default;
}

.optimizer-library-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.optimizer-library-actions .settings-toggle {
  min-width: 130px;
}

#optimizerLibraryList {
  grid-column: 1 / -1;
  width: 100%;
}

.optimizer-library-settings {
  display: grid;
  grid-template-columns: minmax(240px, 2fr) minmax(210px, 1.4fr) minmax(180px, 1fr) minmax(140px, 1fr) minmax(140px, 1fr);
  gap: 12px;
  align-items: end;
}

.optimizer-library-settings label,
.optimizer-library-settings select,
.optimizer-library-settings input {
  width: 100%;
}

.optimizer-library-settings .settings-toggle {
  align-self: end;
  height: 44px;
  min-height: 44px;
  padding: 10px 12px;
}

.optimizer-work-panel,
.optimizer-failures-panel {
  display: grid;
  gap: 14px;
  margin-top: 16px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.optimizer-work-panel.hidden,
.optimizer-failures-panel.hidden {
  display: none;
}

.optimizer-current-jobs,
.optimizer-queue-preview {
  display: grid;
  gap: 10px;
}

.optimizer-queue-preview h4 {
  margin: 0;
  color: var(--text);
}

.optimizer-work-card {
  grid-template-columns: 82px minmax(0, 1fr);
  align-items: center;
  cursor: default;
}

.optimizer-work-card.active {
  border-color: rgba(0, 217, 255, 0.42);
  background: rgba(0, 217, 255, 0.07);
}

.optimizer-work-art {
  display: grid;
  place-items: center;
  width: 82px;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  color: var(--text);
  background:
    linear-gradient(145deg, rgba(0, 217, 255, 0.28), rgba(255, 255, 255, 0.04)),
    linear-gradient(30deg, #121923, #252d38);
  background-position: center;
  background-size: cover;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 22px;
  font-weight: 900;
}

.optimizer-work-art.with-image {
  background-color: #101820;
  background-image: var(--poster-image);
}

.optimizer-work-body {
  display: grid;
  min-width: 0;
  gap: 8px;
}

.optimizer-work-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.optimizer-work-heading h3 {
  overflow: hidden;
  margin: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.optimizer-work-heading span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

.optimizer-failure-card {
  cursor: default;
}

.optimizer-failure-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.optimizer-failure-heading > div {
  min-width: 0;
}

.optimizer-failure-heading span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.82rem;
}

.optimizer-failure-message,
.optimizer-failure-path {
  overflow-wrap: anywhere;
}

.optimizer-failure-message {
  margin: 0;
  color: var(--text);
}

@media (max-width: 980px) {
  .optimizer-library-settings {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .optimizer-library-settings {
    grid-template-columns: 1fr;
  }
}

.currently-playing-card {
  cursor: default;
}

.currently-playing-heading,
.currently-playing-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.currently-playing-heading > div {
  display: grid;
  gap: 4px;
}

.currently-playing-heading span,
.currently-playing-meta {
  color: var(--muted);
  font-size: 13px;
}

.currently-playing-meta {
  justify-content: start;
}

.library-manager-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
}

.library-manager-heading h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.drag-handle {
  color: var(--cyan);
  font-weight: 900;
  letter-spacing: 1px;
}

.library-path {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 13px;
}

.library-card-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 8px;
  max-width: min(520px, 48vw);
}

.account-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.library-card-actions .compact-button {
  min-width: max-content;
}

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

.share-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
}

.primary-button {
  min-height: 46px;
  color: #001217;
  background: var(--cyan);
  border: 0;
  border-radius: 8px;
  font-weight: 800;
  cursor: pointer;
}

.secondary-button {
  min-height: 46px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--cyan-soft);
  border-radius: 8px;
  font-weight: 800;
  cursor: pointer;
}

.compact-button {
  min-height: 38px;
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.action-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.manual-copy-bar {
  display: grid;
  gap: 8px;
  padding: 12px;
  background: rgba(0, 217, 255, 0.08);
  border: 1px solid rgba(0, 217, 255, 0.28);
  border-radius: 8px;
}

.manual-copy-bar span {
  color: var(--muted);
  font-size: 13px;
}

.manual-copy-bar input {
  min-height: 42px;
  padding: 9px 10px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.drawer-management {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  align-self: end;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.compact-actions {
  gap: 8px;
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(2, 4, 7, 0.45);
  backdrop-filter: blur(28px);
}

.login-overlay.hidden {
  display: none;
}

.login-modal,
.choice-modal,
.admin-panel-modal {
  width: min(420px, 100%);
  padding: 34px;
  background: rgba(15, 21, 28, 0.88);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.54);
}

.choice-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(2, 4, 7, 0.58);
  backdrop-filter: blur(18px);
}

.choice-overlay.admin-overlay {
  place-items: stretch;
  padding: 0;
  background: rgba(2, 4, 7, 0.72);
}

#iptvMatchOverlay {
  z-index: 80;
}

.choice-overlay.hidden {
  display: none;
}

.choice-modal {
  display: grid;
  gap: 16px;
}

.self-account-form {
  display: grid;
  gap: 12px;
}

.download-modal {
  width: min(720px, 100%);
}

.download-form {
  display: grid;
  gap: 12px;
}

.live-download-choice {
  display: grid;
  gap: 14px;
  padding: 16px;
  background: rgba(0, 210, 235, 0.07);
  border: 1px solid rgba(0, 210, 235, 0.35);
  border-radius: 8px;
}

.live-download-choice.hidden {
  display: none;
}

.live-download-choice p {
  margin: 4px 0 0;
}

.download-list {
  display: grid;
  gap: 10px;
  max-height: min(48vh, 420px);
  overflow-x: hidden;
  overflow-y: auto;
}

.download-card {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.download-group {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.playlist-download-items {
  display: grid;
  gap: 8px;
  margin-top: 4px;
}

.playlist-download-item {
  display: grid;
  gap: 7px;
  min-width: 0;
  padding: 10px;
  background: rgba(255, 255, 255, 0.045);
  border-left: 2px solid rgba(0, 217, 255, 0.22);
}

.download-heading,
.download-meta {
  display: grid;
  align-items: center;
  gap: 10px;
}

.download-heading {
  grid-template-columns: minmax(0, 1fr) max-content;
}

.download-meta {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.download-heading strong {
  display: block;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.download-heading span {
  white-space: nowrap;
}

.download-meta span:nth-child(2) {
  text-align: center;
}

.download-meta span:last-child {
  text-align: right;
}

.download-heading span,
.download-meta {
  color: var(--muted);
  font-size: 13px;
}

.download-card .status,
.download-group .status,
.playlist-download-item .status {
  min-width: 0;
  overflow-wrap: anywhere;
}

.download-complete {
  border-color: rgba(0, 217, 255, 0.36);
}

.download-failed {
  border-color: rgba(255, 82, 82, 0.52);
}

.admin-panel-modal {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  width: 100%;
  height: 100vh;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(12, 18, 25, 0.98), rgba(9, 13, 18, 0.96)),
    rgba(15, 21, 28, 0.94);
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.admin-sidebar {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 24px;
  min-height: 0;
  padding: 28px 22px;
  background: rgba(8, 13, 18, 0.86);
  border-right: 1px solid var(--border);
}

.admin-sidebar h2,
.admin-page-heading h2 {
  margin: 0;
}

.admin-nav {
  display: grid;
  align-content: start;
  gap: 8px;
}

.admin-nav-button {
  min-height: 44px;
  width: 100%;
  padding: 10px 12px;
  color: var(--text);
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.admin-nav-button:hover,
.admin-nav-button:focus-visible,
.admin-nav-button.active {
  background: rgba(0, 217, 255, 0.12);
  border-color: rgba(0, 217, 255, 0.42);
  outline: 0;
}

.admin-close {
  justify-self: stretch;
}

.admin-main {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 30px;
}

.admin-page {
  display: grid;
  gap: 14px;
  align-content: start;
}

.admin-page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.account-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) minmax(260px, 0.9fr);
  gap: 12px;
  align-items: stretch;
}

.account-libraries-field {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  grid-column: 3;
  grid-row: 1 / span 2;
  min-height: 100%;
}

.account-libraries-field select {
  width: 100%;
  height: 100%;
  min-height: 0;
}

.account-card.editing {
  border-color: rgba(0, 217, 255, 0.7);
  background:
    linear-gradient(90deg, rgba(0, 217, 255, 0.13), rgba(255, 255, 255, 0.04)),
    rgba(255, 255, 255, 0.05);
  box-shadow: 0 0 0 1px rgba(0, 217, 255, 0.14);
}

.account-card.editing h3 {
  color: var(--cyan);
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(170px, 1fr));
  gap: 8px;
  grid-column: 1 / span 2;
  grid-row: 2;
  padding: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.permission-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
}

.permission-grid input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--cyan);
}

.settings-form {
  display: grid;
  gap: 14px;
}

.settings-form fieldset {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
  margin: 0;
  padding: 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.settings-form legend {
  padding: 0 8px;
  color: var(--cyan);
  font-weight: 900;
}

.settings-form label:has(input[type="checkbox"]) {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.settings-form input[type="checkbox"] {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  accent-color: var(--cyan);
}

.settings-toggle {
  align-self: end;
}

.settings-feature-body {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.settings-feature-body.hidden {
  display: none;
}

.backup-settings-form {
  margin-bottom: 24px;
}

.backup-directory-field {
  grid-column: 1 / -1;
}

.backup-schedule-body {
  align-items: end;
}

.backup-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(62px, 1fr));
  gap: 8px;
  grid-column: 1 / -1;
}

.backup-days label {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
}

.backup-card-meta {
  color: var(--muted);
  font-size: 0.88rem;
}

.backup-progress {
  display: grid;
  gap: 10px;
  margin: 0 0 18px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.backup-progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.backup-progress-meta strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 900px) {
  .backup-days {
    grid-template-columns: repeat(4, minmax(62px, 1fr));
  }
}

.settings-action-button {
  align-self: end;
  min-height: 46px;
}

.compact-feature-body {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.api-key-form {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(240px, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.api-key-form label {
  display: grid;
  gap: 8px;
}

.api-key-form input {
  width: 100%;
  min-height: 44px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  outline: 0;
  font: inherit;
}

.api-key-secret {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  background: rgba(0, 217, 255, 0.08);
  border: 1px solid rgba(0, 217, 255, 0.36);
  border-radius: 8px;
}

.api-key-secret code {
  min-width: 0;
  overflow: auto;
  padding: 10px 12px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.28);
  border-radius: 8px;
}

.api-key-card.revoked {
  opacity: 0.65;
}

.duplicate-list {
  display: grid;
  gap: 14px;
}

.duplicate-group {
  display: grid;
  gap: 10px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.duplicate-heading h3,
.duplicate-heading p {
  margin: 0;
}

.duplicate-items {
  display: grid;
  gap: 8px;
}

.duplicate-row {
  display: grid;
  grid-template-columns: minmax(180px, 0.42fr) minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 12px;
  color: var(--text);
  text-align: left;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

.duplicate-row:hover,
.duplicate-row:focus-visible {
  border-color: rgba(0, 217, 255, 0.45);
  outline: 0;
}

.duplicate-row span {
  display: grid;
  gap: 4px;
}

.duplicate-row small {
  color: var(--muted);
}

.duplicate-row code {
  min-width: 0;
  overflow: hidden;
  color: rgba(235, 245, 250, 0.82);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-form > .action-row {
  grid-column: 1 / -1;
}

@media (max-width: 860px) {
  .channel-match-grid {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }

  .choice-modal.channel-match-modal {
    height: calc(100vh - 24px);
    padding: 18px;
  }

  .channel-match-column,
  .channel-match-guide-column {
    min-height: 360px;
    padding: 14px 0;
    border-left: 0;
  }

  .channel-match-guide-column {
    border-top: 1px solid var(--border);
  }

  .channel-match-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .channel-match-selection {
    grid-template-columns: 1fr;
  }

  .admin-panel-modal {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .admin-sidebar {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    padding: 18px;
  }

  .admin-nav {
    grid-column: 1 / -1;
    display: flex;
    overflow-x: auto;
  }

  .admin-nav-button {
    width: auto;
    white-space: nowrap;
  }

  .admin-main {
    padding: 18px;
  }

  .admin-page-heading {
    align-items: start;
    flex-direction: column;
  }

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

  .library-manager-heading {
    grid-template-columns: 1fr;
  }

  .library-card-actions {
    justify-content: start;
    max-width: none;
  }

  .account-libraries-field {
    grid-column: auto;
    grid-row: auto;
  }

  .permission-grid {
    grid-template-columns: 1fr;
    grid-column: auto;
    grid-row: auto;
  }

  .settings-form fieldset,
  .settings-feature-body,
  .compact-feature-body,
  .api-key-form,
  .api-key-secret,
  .duplicate-row {
    grid-template-columns: 1fr;
  }

  .duplicate-row code {
    white-space: normal;
    word-break: break-word;
  }
}

.hardware-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.hardware-grid > div,
.hardware-chart-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.hardware-grid p,
.hardware-grid strong,
.hardware-chart-card p,
.hardware-chart-card h3 {
  margin: 0;
}

.hardware-charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.hardware-chart-card canvas {
  width: 100%;
  height: 220px;
}

.meter {
  height: 10px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
}

.meter span {
  display: block;
  width: var(--meter, 0%);
  height: 100%;
  background: var(--cyan);
}

.log-view {
  min-height: 360px;
  max-height: 60vh;
  overflow: auto;
  white-space: pre-wrap;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.choice-modal h2,
.choice-modal p {
  margin: 0;
}

.resume-cancel-row {
  display: grid;
  place-items: center;
  margin-top: 4px;
}

.resume-cancel-row .secondary-button {
  min-width: 160px;
}

.login-modal h1,
.login-modal p {
  margin: 0;
}

.player-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(2, 4, 7, 0.78);
  backdrop-filter: blur(18px);
}

.player-shell {
  display: grid;
  gap: 14px;
  width: min(1120px, 100%);
  max-height: calc(100vh - 56px);
  padding: 18px;
  background: rgba(10, 14, 19, 0.96);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.62);
}

.player-overlay.live-player {
  place-items: stretch;
  padding: 0;
}

.player-overlay.live-player .player-shell {
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: 100%;
  height: 100vh;
  max-height: 100vh;
  padding: 18px 24px;
  overflow: hidden;
  border-width: 0;
  border-radius: 0;
}

.player-overlay.live-player .video-player-slot {
  display: grid;
  min-height: 0;
}

.player-overlay.live-player .video-playback-surface {
  width: 100%;
  height: 100%;
  min-height: 0;
  aspect-ratio: auto;
}

.player-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
}

.player-heading h2,
.player-heading p {
  margin: 0;
}

.player-heading-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.player-close {
  position: static;
}

.video-playback-surface {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #000;
  border: 1px solid rgba(0, 217, 255, 0.28);
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

.video-playback-surface.audio-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  border: 0;
}

.web-player {
  display: block;
  width: 100%;
  height: 100%;
  background: #000;
  border: 0;
  object-fit: contain;
  outline: 0;
}

.video-player-slot {
  min-width: 0;
}

.video-controls {
  position: absolute;
  right: 12px;
  bottom: 12px;
  left: 12px;
  display: grid;
  grid-template-columns: 38px 44px minmax(90px, 1fr) 44px 38px 90px 38px 38px;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 7px 9px;
  color: var(--text);
  background: rgba(8, 13, 18, 0.92);
  border: 1px solid rgba(0, 217, 255, 0.3);
  border-radius: 7px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.42);
  opacity: 1;
  transform: translateY(0);
  transition: opacity 160ms ease, transform 160ms ease;
}

.video-playback-surface.controls-hidden {
  cursor: none;
}

.video-playback-surface.controls-hidden .video-controls {
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px);
}

.video-control-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 34px;
  padding: 0;
  color: var(--text);
  background: #19232d;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1;
  text-indent: -1px;
}

.video-control-button:hover,
.video-control-button:focus-visible {
  color: #061014;
  background: var(--cyan);
  border-color: var(--cyan);
  outline: 0;
}

.video-control-button:disabled {
  color: #71808a;
  background: #111820;
  border-color: var(--border);
  cursor: default;
}

.video-time {
  color: #aab7c1;
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.video-controls input[type="range"] {
  width: 100%;
  height: 18px;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

.video-controls input[type="range"]::-webkit-slider-runnable-track {
  height: 5px;
  background: #34414c;
  border-radius: 3px;
}

.video-controls input[type="range"]::-webkit-slider-thumb {
  width: 14px;
  height: 14px;
  margin-top: -4.5px;
  appearance: none;
  background: var(--cyan);
  border: 2px solid #061014;
  border-radius: 50%;
}

.video-controls input[type="range"]::-moz-range-track {
  height: 5px;
  background: #34414c;
  border-radius: 3px;
}

.video-controls input[type="range"]::-moz-range-progress {
  height: 5px;
  background: var(--cyan);
  border-radius: 3px;
}

.video-controls input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--cyan);
  border: 2px solid #061014;
  border-radius: 50%;
}

.video-playback-surface:fullscreen,
.video-playback-surface:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  aspect-ratio: auto;
  border: 0;
  border-radius: 0;
}

.video-mini-player {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 70;
  display: grid;
  gap: 10px;
  width: min(480px, calc(100vw - 48px));
  padding: 12px;
  color: var(--text);
  background: rgba(10, 14, 19, 0.98);
  border: 1px solid rgba(0, 217, 255, 0.38);
  border-radius: 8px;
  box-shadow: 0 18px 52px rgba(0, 0, 0, 0.58);
}

.video-mini-player-drag {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px 36px;
  align-items: center;
  gap: 8px;
  min-width: 0;
  cursor: move;
  touch-action: none;
  user-select: none;
}

.video-mini-player-heading {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.video-mini-player-heading p,
.video-mini-player-heading strong {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.video-mini-player-slot {
  min-width: 0;
  overflow: hidden;
  background: #000;
  border: 1px solid rgba(0, 217, 255, 0.2);
  border-radius: 6px;
}

.video-mini-player .web-player {
  display: block;
  max-height: none;
  border: 0;
  border-radius: 0;
}

.video-mini-player .video-playback-surface {
  border: 0;
  border-radius: 0;
}

.video-mini-player .video-controls {
  right: 7px;
  bottom: 7px;
  left: 7px;
  grid-template-columns: 34px 38px minmax(70px, 1fr) 38px 34px 34px 34px;
  min-height: 40px;
  padding: 4px 6px;
  gap: 5px;
}

.video-mini-player .video-control-button {
  width: 34px;
  height: 30px;
}

.video-mini-player .video-volume {
  display: none;
}

.video-mini-player > .status {
  min-height: 0;
  margin: 0;
}

.music-player {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 70;
  display: grid;
  gap: 12px;
  width: min(520px, calc(100vw - 48px));
  padding: 14px;
  color: var(--text);
  background: rgba(10, 14, 19, 0.97);
  border: 1px solid rgba(0, 217, 255, 0.38);
  border-radius: 8px;
  box-shadow: 0 18px 52px rgba(0, 0, 0, 0.58);
}

.music-player-drag {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 36px;
  align-items: center;
  gap: 12px;
  min-width: 0;
  cursor: move;
  touch-action: none;
  user-select: none;
}

.music-player-cover {
  display: grid;
  place-items: center;
  width: 56px;
  aspect-ratio: 1;
  overflow: hidden;
  color: #071014;
  background-color: var(--cyan);
  background-position: center;
  background-size: cover;
  border-radius: 6px;
  font-weight: 800;
}

.music-player-cover.with-image {
  background-color: #101820;
  background-image: var(--poster-image);
}

.music-player-heading {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.music-player-heading p,
.music-player-heading strong,
.music-player-heading span {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.music-player-heading strong {
  font-size: 1rem;
}

.music-player-heading span {
  color: var(--muted);
  font-size: 0.82rem;
}

.music-icon-button,
.music-command-button {
  display: grid;
  place-items: center;
  min-height: 34px;
  padding: 7px 10px;
  color: var(--text);
  background: #19232d;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  line-height: 1;
}

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

.music-icon-button:hover,
.music-command-button:hover,
.music-icon-button:focus-visible,
.music-command-button:focus-visible {
  color: #061014;
  background: var(--cyan);
  border-color: var(--cyan);
  outline: 0;
}

.music-command-button:disabled {
  color: #71808a;
  background: #111820;
  cursor: default;
}

.music-player-controls {
  display: grid;
  grid-template-columns: 64px 42px minmax(120px, 1fr) 42px 54px;
  grid-template-areas: "play current seek duration next";
  align-items: center;
  gap: 8px;
}

#musicPlayPause { grid-area: play; }
#musicCurrentTime { grid-area: current; }
#musicSeek { grid-area: seek; }
#musicDuration { grid-area: duration; }
#musicNext { grid-area: next; }

.music-player-volume {
  display: grid;
  grid-template-columns: 58px minmax(90px, 150px) minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.music-player-volume .status {
  margin: 0;
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.music-time {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  text-align: center;
}

.music-player input[type="range"] {
  width: 100%;
  height: 18px;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

.music-player input[type="range"]::-webkit-slider-runnable-track {
  height: 5px;
  background: #34414c;
  border-radius: 3px;
}

.music-player input[type="range"]::-webkit-slider-thumb {
  width: 14px;
  height: 14px;
  margin-top: -4.5px;
  appearance: none;
  background: var(--cyan);
  border: 2px solid #061014;
  border-radius: 50%;
}

.music-player input[type="range"]::-moz-range-track {
  height: 5px;
  background: #34414c;
  border-radius: 3px;
}

.music-player input[type="range"]::-moz-range-progress {
  height: 5px;
  background: var(--cyan);
  border-radius: 3px;
}

.music-player input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--cyan);
  border: 2px solid #061014;
  border-radius: 50%;
}

.error {
  color: #ff8a8a;
}

@media (max-width: 760px) {
  .image-viewer {
    inset: 0 0 44vh;
    padding: 64px 14px 14px;
  }

  body.image-viewer-open .details {
    top: 56vh;
    width: 100vw;
    height: 44vh;
    padding: 22px 18px;
    overflow-y: auto;
  }

  .player-overlay {
    padding: 12px;
  }

  .player-shell {
    padding: 12px;
  }

  .video-controls {
    right: 7px;
    bottom: 7px;
    left: 7px;
    grid-template-columns: 34px 38px minmax(70px, 1fr) 38px 34px 34px 34px;
    min-height: 40px;
    padding: 4px 6px;
    gap: 5px;
  }

  .video-control-button {
    width: 34px;
    height: 30px;
  }

  .video-volume {
    display: none;
  }

  .video-mini-player {
    top: auto !important;
    right: 12px !important;
    bottom: 12px !important;
    left: 12px !important;
    width: auto;
  }

  .music-player {
    top: auto !important;
    right: 12px !important;
    bottom: 12px !important;
    left: 12px !important;
    width: auto;
  }

  .music-player-controls {
    grid-template-columns: 60px 1fr 1fr 50px;
    grid-template-areas:
      "play current duration next"
      "seek seek seek seek";
    gap: 7px;
  }

  .music-player-volume {
    grid-template-columns: 58px minmax(80px, 1fr);
  }

  .music-player-volume .status {
    grid-column: 1 / -1;
    text-align: left;
  }

  .topbar {
    grid-template-columns: 1fr auto;
    padding: 14px;
  }

  .search-shell {
    grid-column: 1 / -1;
  }

  .topbar-actions {
    grid-column: 1 / -1;
    justify-self: stretch;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .shell {
    padding: 18px 14px 60px;
  }

  body.live-tv-page .live-tv-heading,
  body.live-tv-page .live-tv-filter {
    margin-right: 14px;
    margin-left: 14px;
  }

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

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

  .library-form,
  .subtitle-search-row {
    grid-template-columns: 1fr;
  }

  .poster-large {
    width: min(180px, 48vw);
  }

  .view-header {
    align-items: start;
    flex-direction: column;
  }

  .home-toolbar {
    align-items: start;
    flex-direction: column;
  }

  .live-tv-heading {
    align-items: start;
    flex-direction: column;
  }

  .live-tv-actions {
    justify-content: start;
  }

  .live-tv-filter {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .guide-row {
    grid-template-columns: 150px minmax(var(--guide-min-width), 1fr);
    width: max(100%, calc(150px + var(--guide-min-width)));
  }

  .guide-channel-cell {
    grid-template-columns: 36px minmax(0, 1fr);
    padding: 8px;
  }

  .guide-channel-cell img,
  .guide-channel-initials {
    width: 36px;
    height: 36px;
  }

  .segmented-control {
    width: 100%;
  }
}
