:root {
  --bg: #122231;
  --header: #38516a;
  --panel: #112231;
  --panel2: #223649;
  --line: #000000;
  --text: #e9ece9;
  --muted: #a6defe;
  --accent: #0057aa;
  --accent-hover: #247bcf;
  --good: #4db22e;
  --mid: #FF5722;
  --bb: #283949;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scrollbar-gutter: stable; overflow-x: hidden; }

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }

img { display: block; }

button, select, input {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
}

button { cursor: pointer; }

.topbar {
  background: var(--header);
  border-bottom: 1px solid var(--line);
}

.topbar-in {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: 54px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--accent);
  flex-shrink: 0;
}

.logo img {     width: 28px;
    height: 28px;
    border: 2px solid #a6defe;
    border-radius: 5px;}

.logo svg { width: 28px; height: 28px; }

.logo span {
  color: var(--text);
  font-size: 17px;
  font-weight: 800;
}

.nav {
  display: flex;
  overflow: auto hidden;
  scrollbar-width: none;
}

.nav::-webkit-scrollbar { display: none; }

.nav a {
  padding: 17px 14px;
  white-space: nowrap;
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  transition: color .15s;
}

.nav a:hover { color: var(--text); }

.nav a.active { color: #ffffff; }

.top-search {
  flex: 1;
  display: flex;
  max-width: 420px;
  margin-left: auto;
  background: var(--panel);
  border-radius: 999px;
  overflow: hidden;
}

.top-search input {
  flex: 1;
  min-width: 0;
  padding: 8px 6px 8px 16px;
}

.top-search input::placeholder { color: var(--muted); }

.top-search button {
  padding: 0 14px;
  color: var(--muted);
  display: flex;
  align-items: center;
}

.top-search button:hover { color: var(--accent); }

.top-search svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
}

.top-search:focus-within { border-color: var(--accent); }
.top-search input:focus { outline: none; }

.top-saved {
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  transition: color .15s;
}

.top-saved:hover, .top-saved.active { color: #fff; }

.top-saved svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.page {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 24px 16px 48px;
  flex: 1;
}

.footer {
  padding: 14px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--line);
}

.h1, .h2, .detail-title {
  font-weight: 700;
}

.h1 {
  font-size: 22px;
  margin-bottom: 18px;
}

.h2 {
  font-size: 18px;
  margin: 28px 0 14px;
}

.is-tv .h2 {
  font-size: 24px;
  margin: 28px 0 14px;
}

.h2:first-child { margin-top: 0; }

.h2 a { transition: color .15s; }

.h2 a:hover { color: var(--accent); }

.h2-arr {
  color: var(--accent);
  margin-left: 6px;
}

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

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

@media (max-width: 640px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 10px; }
}

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

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.card .poster {
  display: block;
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--bb);
  background: var(--panel2);
  aspect-ratio: 2 / 3;
  outline: 1px solid transparent;
  transition: outline-color .15s;
}

.card:hover .poster { outline-color: var(--accent); }

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

.badge {
    position: absolute;
    top: 6px;
    right: 6px;
    min-width: 34px;
    text-align: center;
    padding: 1px 6px;
    border-radius: 5px;
    background: #3f453f;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
    z-index: 10;
    border: 1px solid rgb(255 255 255 / 20%);
}

.badge.good { background: var(--good); color: #fff; }
.badge.mid { background: var(--mid); color: #fff; }

.card .title {
  display: -webkit-box;
  margin-top: 8px;
  font-weight: 600;
  font-size: 13px;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.is-tv .card .title {
    font-size: 19px;
  }

.card .meta {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panel {
  background: var(--header);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 20px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.chip {
  padding: 6px 14px;
  border-radius: 5px;
  background: var(--panel2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  transition: color .15s, border-color .15s;
}

.chip:hover { color: var(--text); border-color: var(--muted); }

.chip.on {
    background: var(--accent);
    border-color: #a6defe;
  color: #fff;
}

.selects {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.sel {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  min-width: 160px;
  appearance: auto;
}

.sel option { background: var(--panel2); }

.btn {
  padding: 8px 18px;
  border-radius: 6px;
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--line);
  transition: background .15s, border-color .15s;
}

.btn:hover { border-color: var(--muted); }

.btn.primary {
    background: var(--accent);
    border-color: #a6defe;
  color: #fff;
  font-weight: 600;
}

.btn.primary:hover { background: var(--accent-hover); }

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

.notice {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  text-align: center;
  color: var(--muted);
}

.notice.error { color: #e07a5f; }

.more-wrap {
  display: flex;
  justify-content: center;
  margin-top: 24px;
}

.search-form {
  display: flex;
  gap: 10px;
  margin-bottom: 22px;
}

.search-input {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 14px;
}

.search-input::placeholder { color: var(--muted); }

.search-input:focus {
  outline: none;
  border-color: var(--accent);
}

.detail-top {
  display: flex;
  gap: 24px;
  margin-bottom: 24px;
}

.detail-poster {
  flex: 0 0 220px;
  position: relative;
}

.detail-poster .badge {
  top: 8px;
  right: 8px;
  font-size: 13px;
}

.detail-poster img {
  width: 100%;
  border-radius: 8px;
  background: var(--panel2);
  border: 1px solid var(--bb);
}

.detail-info { flex: 1; min-width: 0; }

.detail-title { font-size: 24px; }

.detail-orig {
  color: var(--muted);
  margin: 2px 0 14px;
}

.facts { margin-bottom: 14px; }

.fact {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 13px;
}

.fact .k {
  color: var(--muted);
  flex: 0 0 110px;
}

.tag {
  display: inline-block;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 10px;
  margin: 0 4px 4px 0;
  font-size: 12px;
}

.overview { line-height: 1.65; margin-bottom: 16px; max-width: 640px; }

.tabs {
  display: flex;
  background: var(--header);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto hidden;
  margin-bottom: 18px;
}

.tabs button {
  padding: 10px 18px;
  color: var(--muted);
  white-space: nowrap;
  font-weight: 600;
}

.tabs button:hover { color: var(--text); }

.tabs button.on {
  color: #fff;
  background: var(--accent);
}

.people {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 16px 12px;
}

.person img {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 8px;
  background: var(--panel2);
}

.person .name {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 600;
}

.person .role {
  color: var(--muted);
  font-size: 12px;
}

.video-wrap {
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
}

.video-wrap iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

#col-sect { margin-bottom: 24px; }

#custom-slot:not(:empty) { margin-bottom: 24px; }

#custom-slot iframe {
  width: 100%;
  border: 1px solid var(--bb);
  border-radius: 8px;
}

#custom-slot iframe:not([height]) { aspect-ratio: 16 / 9; }

.player-slot {
  margin-top: 18px;
}

.season {
  display: flex;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}

.season img {
  width: 70px;
  border-radius: 4px;
  background: var(--panel2);
}

.season .s-title { font-weight: 700; }

.season .s-meta { color: var(--muted); font-size: 12px; margin: 2px 0 6px; }

.season .s-over {
  font-size: 13px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.save-btn { float: right; }

.save-btn.saved {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.skeleton {
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.spin {
  width: 28px;
  height: 28px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
  .spin { animation: none; }
  .card .poster, .chip, .btn, .nav a { transition: none; }
}

@media (max-width: 720px) {
  .topbar-in { flex-wrap: wrap; gap: 0 20px; padding-bottom: 0; }
  .logo { padding: 10px 0 6px; }
  .nav { width: 100%; margin: 0 -16px; padding: 0 16px; }
  .nav a { padding: 4px 10px 12px; font-size: 13px; }
  .nav a:first-child { padding-left: 0; }
  .detail-top { flex-direction: column; }
  .detail-poster { flex-basis: auto; max-width: 220px; margin: 0 auto;}
  .fact .k { flex-basis: 90px; }
  .sel { min-width: 130px; flex: 1; }
}

.top-search input, .search-input, .sel { font-size: 13px; }

.bottombar { display: none; }
.bottombar svg { fill: currentColor; }

@media (max-width: 720px) {
  .nav, .top-saved { display: none; }

  .topbar-in { gap: 12px; }

  .page {
    padding-top: max(24px, env(safe-area-inset-top, 24px)) !important;
    padding-bottom: calc(85px + env(safe-area-inset-bottom, 16px)) !important;
    padding-left: max(14px, env(safe-area-inset-left, 14px)) !important;
    padding-right: max(14px, env(safe-area-inset-right, 14px)) !important;
  }

  .footer { padding-bottom: calc(85px + env(safe-area-inset-bottom, 16px)); }

  .bottombar {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--header);
    border-top: 1px solid var(--line);
    padding-top: 6px;
    padding-bottom: max(16px, env(safe-area-inset-bottom, 16px));
    padding-left: 10px;
    padding-right: 10px;
    z-index: 20;
  }

  #custom-slot iframe:not([height]) {
    aspect-ratio: 4 / 3;
  }

  .bottombar a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 2px 9px;
    color: var(--muted);
    font-size: 10px;
  }

  .bottombar svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
  }

  .bottombar .active { color: #ffffff; }

  .selects .btn { flex: 1; }
}
.col-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

@media (max-width: 720px) {
  .col-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 10px; }
}

@media (max-width: 420px) {
  .col-grid { grid-template-columns: 1fr; }
}

.colstack {
  position: relative;
  display: block;
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel2);
  aspect-ratio: 16 / 9;
  outline: 1px solid transparent;
  transition: outline-color .15s;
}

.colstack:hover { outline-color: var(--accent); }

.colstack-imgs {
  position: absolute;
  inset: 0;
  display: flex;
}

.colstack-imgs img {
  flex: 1;
  min-width: 0;
  height: 100%;
  object-fit: cover;
}

.colstack .badge {
    top: auto;
    bottom: 7px;
    right: 8px;
    z-index: 11;
    background: #0057aa;
}

.colstack-name {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 8px 12px;
    color: #fff;
    background: rgb(56 81 106 / 50%);
    backdrop-filter: saturate(180%) blur(20px);
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);
    font-weight: 700;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    z-index: 10;
    text-overflow: ellipsis;
}
.colstack-imgs {
    display: flex;
}

.colstack-imgs img {
    width: 60px; 
    position: relative;
    margin-left: -12px; 
}

.colstack-imgs img:first-child {
    margin-left: 0;
    z-index: 3;
    box-shadow: 8px 0 12px rgba(0,0,0,.55);
}

.colstack-imgs img:nth-child(2) {
    z-index: 2;
    box-shadow: 8px 0 12px rgba(0,0,0,.55);
}

.colstack-imgs img:nth-child(3) {
    z-index: 1;
}

/* ==========================================================================
   CATALOG BAR (Tabs, Filter button, Sort button)
   ========================================================================== */
.cat-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.cat-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.cat-title {
  font-size: 22px;
  font-weight: 700;
}

.cat-tabs {
  display: none; /* Hidden on Desktop PC, shown on Mobile & TV */
  gap: 8px;
  background: var(--panel);
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--line);
}

.cat-tab {
  padding: 7px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  transition: all .15s;
}

.cat-tab:hover {
  color: var(--text);
}

.cat-tab.active {
  background: var(--accent);
  color: #fff;
}

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

.cat-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--header);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  transition: border-color .15s, background .15s;
}

.cat-btn:hover {
  border-color: var(--accent);
}

.cat-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  opacity: 0.8;
}

.cat-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}

.sort-wrap {
  position: relative;
}

.sort-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--header);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  min-width: 160px;
  z-index: 100;
  overflow: hidden;
}

.sort-opt {
  padding: 10px 16px;
  text-align: left;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s;
}

.sort-opt:hover {
  background: var(--panel2);
  color: var(--text);
}

.sort-opt.active {
  color: #fff;
  font-weight: 700;
  background: var(--panel2);
}

/* ==========================================================================
   FILTER MODAL DIALOG
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-window {
  background: var(--header);
  border: 1px solid var(--line);
  border-radius: 12px;
  width: 100%;
  max-width: 440px;
  padding: 22px 24px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.6);
}

.modal-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.modal-heading {
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  font-size: 24px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
}

.modal-close:hover { color: #fff; }

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 24px;
}

.modal-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.modal-row .sel {
  width: 100%;
  background: var(--panel2);
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.modal-actions .btn {
  flex: 1;
}

/* ==========================================================================
   MOBILE OVERRIDES (<= 720px)
   ========================================================================== */
@media (max-width: 720px) {
  .topbar {
    display: none !important;
  }



  .cat-title {
    display: none !important;
  }

  .cat-tabs {
    display: flex !important;
    width: 100%;
  }

  .cat-tab {
    flex: 1;
    text-align: center;
  }

  .cat-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 18px;
  }

  .cat-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
  }

  .cat-btn {
    width: 100%;
    justify-content: center;
  }

  .sort-wrap {
    width: 100%;
  }

  .sort-menu {
    left: 0;
    right: 0;
  }
}

/* ==========================================================================
   TV / MEDIA STATION X MODE (.is-tv)
   ========================================================================== */
.is-tv .topbar {
  display: none !important;
}

.is-tv .footer {
  display: none !important;
}

.is-tv .bottombar {
  display: flex !important;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 114px;
  background: var(--header);
  border-right: 1px solid var(--line);
  border-top: none;
  z-index: 100;
  align-items: center;
  padding-top: 28px;
  gap: 20px;
}

.is-tv .bottombar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text);
  opacity: 0.65;
  text-decoration: none;
  gap: 4px;
  font-size: 16px;
  transition: all 0.2s;
  outline: none;
  width: 68px;
  padding: 8px 0;
  border-radius: 8px;
}

.is-tv .bottombar a svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.is-tv .bottombar a.active,
.is-tv .bottombar a:hover,
.is-tv .bottombar a:focus {
  opacity: 1;
  color: #fff;
}

.is-tv .bottombar a:focus {
  background: var(--panel2);
  outline: 2px solid var(--accent);
  transform: scale(1.08);
}

.is-tv .page {
  margin-left: 114px;
  width: calc(100% - 114px);
  max-width: calc(100% - 114px) !important;
  padding: 28px 100px 48px !important;
  box-sizing: border-box;
}

.is-tv .cat-title {
  display: none !important;
}

.is-tv .cat-tabs {
  display: flex !important;
}

.is-tv .cat-bar {
  display: flex !important;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.is-tv .grid {
  grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
  gap: 22px 14px !important;
}

@media (max-width: 1440px) {
  .is-tv .grid {
    grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 1100px) {
  .is-tv .grid {
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
  }
}

.is-tv .card {
  transition: transform 0.2s, outline 0.15s;
  outline: 3px solid transparent;
  outline-offset: 4px;
  border-radius: 8px;
}

.is-tv .card:focus {
  transform: scale(1.07);
  outline-color: var(--accent);
  z-index: 10;
}

.is-tv .cat-btn:focus,
.is-tv .cat-tab:focus,
.is-tv .btn:focus,
.is-tv .chip:focus,
.is-tv .sort-opt:focus,
.is-tv .colstack:focus {
  outline: 2px solid var(--accent);
  transform: scale(1.04);
}

.tv-logo { display: none !important; }
.is-tv .tv-logo {
  display: flex !important;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  pointer-events: none;
}
.is-tv .tv-logo img {
  width: 48px;
  height: 48px;
  border: 2px solid #a6defe;
  border-radius: 8px;
  object-fit: contain;
}

.is-tv .col-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.is-tv .colstack-name {
  font-size: 18px;
}

#col-sect {
  margin-top: 32px;
}