:root {
  --bg: #07080c;
  --bg-2: #0d1119;
  --panel: rgba(15, 18, 28, 0.82);
  --panel-strong: rgba(13, 16, 25, 0.96);
  --line: rgba(255,255,255,0.08);
  --line-strong: rgba(255,255,255,0.16);
  --text: #f5f7fb;
  --muted: #9aa5ba;
  --primary: #e50914;
  --primary-2: #ff5a54;
  --blue: #1597ff;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.45);
  --radius: 24px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 14% 10%, rgba(229,9,20,.18), transparent 28%),
    radial-gradient(circle at 84% 10%, rgba(21,151,255,.16), transparent 24%),
    linear-gradient(180deg, #05060a, #090b12 48%, #05060a);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 32px 32px;
  opacity: .5;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.5), transparent 85%);
  pointer-events: none;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
img { display: block; }
.hidden { display: none !important; }

.bg-orb {
  position: fixed;
  width: 34rem;
  height: 34rem;
  border-radius: 999px;
  filter: blur(80px);
  z-index: -1;
  opacity: .45;
}
.orb-red { left: -12rem; top: -8rem; background: rgba(229,9,20,.20); }
.orb-blue { right: -10rem; top: 2rem; background: rgba(21,151,255,.16); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 28px 10px;
  backdrop-filter: blur(12px);
}

.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 48px; height: 48px; border-radius: 16px;
  display: grid; place-items: center;
  font-size: 24px; font-weight: 900;
  background: linear-gradient(135deg, var(--primary), var(--primary-2) 58%, var(--blue));
  box-shadow: 0 18px 40px rgba(229,9,20,.22);
}
.brand-title { font-size: 22px; font-weight: 900; letter-spacing: -.04em; }
.brand-sub { color: var(--muted); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; }

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

.page-shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 8px 0 40px;
}

.hero {
  position: relative;
  display: grid;
  grid-template-columns: 1.2fr .9fr;
  gap: 24px;
  min-height: calc(100vh - 110px);
  border: 1px solid var(--line);
  border-radius: 34px;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(6,8,12,.94), rgba(6,8,12,.76) 46%, rgba(6,8,12,.16)),
    linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.02));
  box-shadow: var(--shadow);
}

.hero-overlay {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 18% 24%, rgba(229,9,20,.18), transparent 26%),
    radial-gradient(circle at 82% 16%, rgba(21,151,255,.18), transparent 22%);
  pointer-events: none;
}

.hero-content {
  position: relative;
  z-index: 1;
  padding: 52px 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.hero-badge {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #ffd9dc;
  background: rgba(229,9,20,.10);
  border: 1px solid rgba(229,9,20,.20);
}

.hero h1 {
  margin: 18px 0 14px;
  font-size: clamp(46px, 7vw, 92px);
  line-height: .92;
  letter-spacing: -.06em;
}

.hero p {
  max-width: 760px;
  margin: 0;
  color: #a8b2c2;
  font-size: clamp(15px, 1.8vw, 18px);
  line-height: 1.9;
}

.hero-actions { margin-top: 26px; }
.search-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: rgba(10,12,18,.84);
  backdrop-filter: blur(14px);
}
.search-bar svg { width: 22px; height: 22px; fill: #cbd4e4; flex: 0 0 auto; }
.search-bar input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: #fff;
  font-size: 17px;
}
.search-bar input::placeholder { color: #6d788c; }

.quick-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
}

.primary-btn,
.ghost-btn,
.tag-btn,
.source-tab,
.episode-btn,
.icon-btn {
  transition: transform .2s ease, border-color .2s ease, background .2s ease, opacity .2s ease;
}
.primary-btn:hover,
.ghost-btn:hover,
.tag-btn:hover,
.source-tab:hover,
.episode-btn:hover,
.icon-btn:hover,
.card:hover { transform: translateY(-2px); }

.primary-btn {
  border: none;
  color: #fff;
  padding: 14px 22px;
  border-radius: 18px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 16px 36px rgba(229,9,20,.28);
}

.ghost-btn,
.tag-btn,
.source-tab,
.episode-btn,
.icon-btn,
.field-input {
  border: 1px solid var(--line);
  color: #edf1f8;
  background: rgba(255,255,255,.04);
}

.ghost-btn { padding: 12px 18px; border-radius: 18px; font-weight: 700; }
.ghost-btn.mini { padding: 10px 14px; border-radius: 14px; }
.tag-btn { padding: 10px 14px; border-radius: 999px; font-size: 13px; font-weight: 700; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 14px;
  display: grid; place-items: center; font-size: 26px;
}

.hero-posters {
  position: relative;
  min-height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 30px;
}
.hero-posters::before {
  content: "";
  position: absolute;
  inset: 10% 12% 10% 12%;
  border-radius: 30px;
  border: 1px solid rgba(255,255,255,.06);
  background:
    linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.01)),
    linear-gradient(135deg, rgba(229,9,20,.14), rgba(21,151,255,.10));
  transform: perspective(1200px) rotateY(-12deg);
}

.hero-poster {
  position: absolute;
  width: 220px;
  aspect-ratio: 2/3;
  border-radius: 26px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: end;
  gap: 8px;
  border: 1px solid rgba(255,255,255,.08);
  box-shadow: 0 30px 70px rgba(0,0,0,.35);
}
.hero-poster span { font-size: 11px; font-weight: 800; letter-spacing: .12em; color: rgba(255,255,255,.8); }
.hero-poster strong { font-size: 28px; line-height: 1; letter-spacing: -.05em; }
.hero-poster small { color: rgba(255,255,255,.76); font-size: 13px; }
.poster-a { left: 70px; bottom: 40px; transform: rotate(-10deg); background: linear-gradient(180deg, rgba(229,9,20,.24), rgba(12,14,22,.94)); }
.poster-b { left: 200px; bottom: 90px; transform: rotate(1deg); background: linear-gradient(180deg, rgba(21,151,255,.22), rgba(12,14,22,.94)); z-index: 2; }
.poster-c { left: 330px; bottom: 30px; transform: rotate(10deg); background: linear-gradient(180deg, rgba(111,71,255,.22), rgba(12,14,22,.94)); }

.results-section {
  margin-top: 22px;
  padding: 0 4px;
}
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}
.section-head h2 {
  margin: 0;
  font-size: clamp(30px, 4vw, 54px);
  line-height: .96;
  letter-spacing: -.05em;
}
.section-head p { margin: 10px 0 0; color: var(--muted); }
.section-head-actions { display: flex; gap: 10px; }

.grid-wall {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(228px, 1fr));
  gap: 18px;
}

.card {
  overflow: hidden;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(15,18,28,.96), rgba(8,10,14,.96));
  box-shadow: 0 16px 44px rgba(0,0,0,.20);
}
.card:hover {
  border-color: rgba(229,9,20,.22);
  box-shadow: 0 24px 56px rgba(0,0,0,.34);
}
.card-cover {
  position: relative;
  aspect-ratio: 2/3;
  background: linear-gradient(145deg, #131722, #090b11);
}
.card-cover img {
  width: 100%; height: 100%; object-fit: cover;
}
.card-cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,.04), rgba(0,0,0,.42));
}
.card-rank {
  position: absolute;
  z-index: 2;
  top: 16px;
  left: 16px;
  padding: 9px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  background: rgba(12,14,20,.44);
  border: 1px solid rgba(255,255,255,.08);
}
.card-body { padding: 14px 16px 16px; }
.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.card-type {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(229,9,20,.10);
  color: #ffd7db;
  font-size: 12px;
  font-weight: 700;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-remark { font-size: 12px; color: var(--muted); }
.card-title {
  margin: 0;
  font-size: 18px;
  line-height: 1.35;
  min-height: 49px;
  letter-spacing: -.03em;
}
.card-desc {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
  min-height: 44px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-footer {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,.06);
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #d9e1ef;
  font-size: 12px;
}

.empty-box {
  border-radius: 28px;
  padding: 70px 20px;
  text-align: center;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.03);
}
.empty-box h3 { margin: 0 0 10px; font-size: 26px; }
.empty-box p { margin: 0; color: var(--muted); }

.settings-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 40;
  width: min(420px, 92vw);
  height: 100vh;
  padding: 24px;
  background: rgba(10,12,18,.96);
  border-left: 1px solid var(--line);
  transform: translateX(102%);
  transition: transform .24s ease;
  box-shadow: var(--shadow);
}
.settings-panel.show { transform: translateX(0); }
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
}
.panel-kicker { color: var(--muted); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; }
.panel-header h3 { margin: 10px 0 0; font-size: 28px; letter-spacing: -.04em; }
.field-label { display: block; margin: 16px 0 8px; color: #cad3e4; font-size: 13px; font-weight: 700; }
.field-input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border-radius: 16px;
  outline: none;
}
.status-card {
  margin-top: 18px;
  padding: 16px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.04);
}
.status-row { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; color: var(--muted); }
.status-row strong { color: #fff; font-weight: 700; text-align: right; }
.mask {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(4px);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
}
.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.66);
  backdrop-filter: blur(4px);
}
.modal-card {
  position: relative;
  z-index: 1;
  width: min(1440px, calc(100% - 28px));
  height: min(92vh, 980px);
  margin: 4vh auto;
  display: grid;
  grid-template-columns: minmax(0, 1.38fr) minmax(320px, .82fr);
  overflow: hidden;
  border-radius: 28px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}
.modal-main {
  padding: 20px;
  border-right: 1px solid rgba(255,255,255,.06);
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.modal-side {
  padding: 20px;
  overflow: auto;
}
.modal-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}
.modal-kicker { color: var(--muted); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; }
.modal-top h3 {
  margin: 8px 0 0;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.05;
  letter-spacing: -.05em;
}
.meta-line {
  margin-top: 12px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  line-height: 1.8;
}
.meta-chip {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.04);
}

.player-shell {
  position: relative;
  overflow: hidden;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: #000;
  aspect-ratio: 16/9;
}
.player-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #cbd4e3;
  text-align: center;
  background: linear-gradient(145deg, #161a24, #090b11);
}
.play-placeholder-icon {
  width: 78px;
  height: 78px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.12);
  display: grid;
  place-items: center;
  font-size: 26px;
  margin: 0 auto 14px;
  background: rgba(255,255,255,.06);
}
#videoPlayer, #fallbackFrame {
  width: 100%;
  height: 100%;
  border: none;
  background: #000;
}

.detail-desc {
  margin-top: 16px;
  padding: 16px 18px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.04);
  color: #b1bccf;
  line-height: 1.9;
}
.cover-card,
.side-card {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.04);
  border-radius: 22px;
  overflow: hidden;
}
.cover-card { margin-bottom: 16px; }
.cover-card img {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  background: linear-gradient(145deg, #131722, #090b11);
}
.side-card { padding: 16px; margin-bottom: 16px; }
.side-title {
  margin-bottom: 12px;
  font-size: 14px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #dce4f2;
  font-weight: 800;
}
.source-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.source-tab {
  padding: 10px 14px;
  border-radius: 14px;
  font-weight: 700;
}
.source-tab.active,
.episode-btn.active {
  border-color: rgba(229,9,20,.22);
  background: linear-gradient(135deg, rgba(229,9,20,.16), rgba(21,151,255,.10));
}
.episode-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.episode-btn {
  min-height: 46px;
  border-radius: 14px;
  padding: 10px;
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(10,12,18,.92);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: .22s ease;
  z-index: 70;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 1180px) {
  .hero { grid-template-columns: 1fr; min-height: auto; }
  .hero-content { padding: 40px 32px 12px; }
  .hero-posters { min-height: 420px; }
  .hero-posters::before { inset: 8% 12%; }
  .poster-a { left: 10%; }
  .poster-b { left: calc(50% - 110px); }
  .poster-c { right: 10%; left: auto; }

  .modal-card { grid-template-columns: 1fr; height: auto; max-height: 92vh; }
  .modal-main { border-right: none; border-bottom: 1px solid rgba(255,255,255,.06); }
}

@media (max-width: 760px) {
  .topbar { padding-inline: 16px; }
  .page-shell { width: min(100%, calc(100% - 18px)); }
  .hero-content { padding: 24px 18px 10px; }
  .hero h1 { font-size: clamp(40px, 14vw, 58px); }
  .search-bar { flex-wrap: wrap; }
  .search-bar input { width: 100%; order: 2; }
  .search-bar svg { order: 1; }
  .search-bar .primary-btn { order: 3; width: 100%; }
  .section-head { flex-direction: column; align-items: flex-start; }
  .grid-wall { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .card-title { min-height: auto; font-size: 16px; }
  .card-desc { min-height: auto; -webkit-line-clamp: 3; }
  .hero-posters { min-height: 320px; padding: 16px; }
  .hero-poster { width: 130px; padding: 12px; border-radius: 20px; }
  .hero-poster strong { font-size: 18px; }
  .poster-a { left: 3%; bottom: 16px; }
  .poster-b { left: calc(50% - 65px); bottom: 52px; }
  .poster-c { right: 3%; bottom: 8px; }
  .episode-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 480px) {
  .grid-wall { grid-template-columns: 1fr 1fr; }
  .card-body { padding: 12px; }
  .modal-card { width: min(100% - 10px, 100%); margin: 8px auto; border-radius: 20px; }
  .modal-main, .modal-side { padding: 12px; }
}
