:root {
  --bg: #101210;
  --header: #161916;
  --panel: #1b1e1b;
  --panel2: #242824;
  --line: #2e332e;
  --text: #e9ece9;
  --muted: #99a399;
  --accent: #4db22e;
  --accent-hover: #5cc93c;
  --good: #4db22e;
  --mid: #FF5722;
}

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

html { scrollbar-gutter: stable; }

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;
}

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 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: var(--accent); }

.top-search {
  flex: 1;
  display: flex;
  max-width: 420px;
  margin-left: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  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: var(--accent); }

.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;
}

.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 #303030;
  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;
}

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

.panel {
  background: var(--panel);
  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: 999px;
  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: var(--accent);
  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: var(--accent);
  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 #303030;
}

.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(--panel);
  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 #303030;
  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: 16px; }

.bottombar { display: none; }

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

  .topbar-in { gap: 12px; }

  .page { padding-bottom: 84px; }

  .footer { padding-bottom: 74px; }

  .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-bottom: env(safe-area-inset-bottom);
    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: var(--accent); }

  .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: #303030;
}

.colstack-name {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 8px 12px;
    color: #fff;
    background: rgb(88 88 88 / 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;
}