:root {
  color-scheme: dark;
  --bg: #050608;
  --bg-2: #090a0d;
  --panel: #101217;
  --panel-2: #171a21;
  --panel-3: #1e222b;
  --text: #f7f7f2;
  --muted: #a5a8b3;
  --line: rgba(255, 255, 255, 0.12);
  --lime: #7cff00;
  --orange: #ff8a00;
  --cyan: #22d3ee;
  --danger: #ff5c7a;
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(124, 255, 0, 0.08), transparent 22rem),
    linear-gradient(145deg, #050608, #0a0b10 54%, #06070a);
  color: var(--text);
}
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.46; transform: none !important; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  display: flex;
  width: min(19rem, 86vw);
  flex-direction: column;
  gap: 1.5rem;
  transform: translateX(-100%);
  border-right: 1px solid var(--line);
  background: rgba(6, 7, 10, 0.98);
  padding: 1rem;
  transition: transform 220ms ease;
  backdrop-filter: blur(18px);
}
.sidebar.open { transform: translateX(0); }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 3rem;
  font-size: 1.08rem;
  font-weight: 900;
  text-transform: uppercase;
}
.brand-mark { width: 2.5rem; height: 2.5rem; flex: 0 0 auto; }
.nav-list { display: grid; gap: 0.45rem; }
.nav-list a {
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--muted);
  padding: 0.75rem 0.85rem;
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  transition: background 180ms ease, color 180ms ease, border-color 180ms ease;
}
.nav-list a.active, .nav-list a:hover {
  border-color: rgba(124, 255, 0, 0.45);
  background: rgba(124, 255, 0, 0.12);
  color: var(--text);
}

.main { min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 4.25rem;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 9, 12, 0.86);
  padding: 0.75rem 1rem;
  backdrop-filter: blur(16px);
}
.top-actions { display: flex; align-items: center; gap: 0.5rem; }
.sidebar-toggle, .ghost-button, .primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.55rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(23, 26, 33, 0.9);
  color: var(--text);
  padding: 0 0.9rem;
  font-weight: 800;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}
.sidebar-toggle { width: 2.65rem; padding: 0; }
.icon-button { width: 2.55rem; padding: 0; font-size: 1.35rem; line-height: 1; }
.primary-button {
  border-color: rgba(124, 255, 0, 0.58);
  background: var(--lime);
  color: #061006;
}
.ghost-button.active-action {
  border-color: rgba(34, 211, 238, 0.55);
  background: rgba(34, 211, 238, 0.14);
  color: #d9fbff;
}
.sidebar-toggle:hover, .ghost-button:hover, .primary-button:hover {
  transform: translateY(-1px);
  border-color: rgba(124, 255, 0, 0.58);
}

.search-wrap { position: relative; flex: 1; }
.search-wrap input, .filters select, .source-select {
  width: 100%;
  min-height: 2.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(16, 18, 23, 0.94);
  color: var(--text);
  outline: none;
  padding: 0 0.95rem;
}
.search-wrap input:focus, .filters select:focus, .source-select:focus {
  border-color: rgba(124, 255, 0, 0.72);
}
.search-results {
  position: absolute;
  inset: calc(100% + 0.55rem) 0 auto 0;
  z-index: 45;
  max-height: 25rem;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(10, 11, 15, 0.98);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
}
.search-hit {
  display: grid;
  grid-template-columns: 3rem 1fr;
  gap: 0.75rem;
  align-items: center;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  padding: 0.65rem;
  text-align: left;
}
.search-hit img { width: 3rem; height: 4rem; border-radius: 6px; object-fit: cover; }

.view {
  width: min(100%, 1540px);
  margin: 0 auto;
  padding: 1rem;
  animation: viewIn 240ms ease both;
}
@keyframes viewIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.home-spotlight { display: grid; gap: 1rem; }
.hero {
  position: relative;
  display: grid;
  min-height: 28rem;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  background: var(--panel);
}
.hero img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0.58; }
.hero::after {
  position: absolute;
  inset: 0;
  content: "";
  background:
    linear-gradient(90deg, rgba(5, 6, 8, 0.96), rgba(5, 6, 8, 0.66) 50%, rgba(5, 6, 8, 0.22)),
    linear-gradient(0deg, rgba(5, 6, 8, 0.92), transparent 48%);
}
.home-hero { min-height: 33rem; }
.hero-content {
  position: relative;
  z-index: 1;
  align-self: end;
  display: grid;
  gap: 0.8rem;
  max-width: 56rem;
  padding: 1.25rem;
}
h1, h2, h3 { margin: 0; letter-spacing: 0; }
.hero h1, .watch-copy h1 {
  margin: 0;
  font-size: 2.35rem;
  line-height: 1.02;
}
.hero p, .watch-copy p, .details-copy {
  max-width: 48rem;
  color: #d8dbe3;
  line-height: 1.65;
}
.eyebrow, .meta-row, .card-meta, .section-kicker {
  color: var(--muted);
  font-size: 0.86rem;
}
.section-kicker {
  color: var(--lime);
  font-weight: 900;
  text-transform: uppercase;
}
.hero-actions, .watch-actions, .quick-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
}

.spotlight-rail {
  display: grid;
  gap: 0.7rem;
  align-content: start;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(16, 18, 23, 0.78);
  padding: 0.85rem;
}
.trend-item {
  display: grid;
  grid-template-columns: 2.2rem 3.25rem 1fr;
  gap: 0.7rem;
  align-items: center;
  width: 100%;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
  padding: 0.55rem;
  text-align: left;
}
.trend-item:hover { border-color: rgba(255, 138, 0, 0.55); }
.trend-item span { color: var(--orange); font-weight: 900; }
.trend-item img { width: 3.25rem; height: 4.45rem; border-radius: 6px; object-fit: cover; }
.trend-item strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
  justify-content: space-between;
  margin: 1.35rem 0 1rem;
}
.filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.65rem; width: 100%; }
.anime-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.8rem; }
.anime-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(16, 18, 23, 0.92);
  transition: transform 190ms ease, border-color 190ms ease, box-shadow 190ms ease;
}
.anime-card:hover {
  transform: translateY(-5px);
  border-color: rgba(124, 255, 0, 0.44);
  box-shadow: 0 20px 55px rgba(0, 0, 0, 0.45);
}
.poster { position: relative; aspect-ratio: 2 / 3; background: var(--panel-2); }
.poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.watch-progress {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  display: block;
  height: 0.24rem;
  background: linear-gradient(90deg, var(--lime), var(--orange), var(--cyan));
}
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 1.65rem;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(5, 6, 8, 0.76);
  color: var(--text);
  padding: 0 0.55rem;
  font-size: 0.78rem;
  font-weight: 850;
}
.poster .badge { position: absolute; top: 0.5rem; left: 0.5rem; }
.card-body { display: grid; gap: 0.45rem; padding: 0.75rem; }
.card-title { min-height: 2.6rem; font-weight: 800; line-height: 1.25; }
.card-meta { display: flex; flex-wrap: wrap; gap: 0.45rem; }

.section { margin-top: 1.4rem; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 0.9rem; }
.personal-panel {
  display: grid;
  gap: 1rem;
  border-block: 1px solid var(--line);
  background: rgba(16, 18, 23, 0.58);
  padding: 1rem 0;
}
.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.7rem; }
.stat {
  display: grid;
  gap: 0.15rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(5, 6, 8, 0.36);
  padding: 0.75rem;
}
.stat strong { font-size: 1.35rem; }
.stat span, .continue-item small { color: var(--muted); }
.continue-rail { display: grid; gap: 0.65rem; }
.continue-item {
  display: grid;
  grid-template-columns: 3.2rem 1fr;
  gap: 0.75rem;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(23, 26, 33, 0.68);
  color: var(--text);
  padding: 0.55rem;
  text-align: left;
}
.continue-item:hover { border-color: rgba(34, 211, 238, 0.5); }
.continue-item img { width: 3.2rem; height: 4.3rem; border-radius: 6px; object-fit: cover; }
.continue-item span { display: grid; gap: 0.25rem; min-width: 0; }
.continue-item strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.watch-room {
  position: relative;
  display: grid;
  gap: 1rem;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 1rem;
}
.watch-room::before {
  position: absolute;
  inset: 0;
  content: "";
  background-image:
    linear-gradient(90deg, rgba(5, 6, 8, 0.98), rgba(5, 6, 8, 0.74) 46%, rgba(5, 6, 8, 0.36)),
    var(--watch-bg, linear-gradient(#101217, #101217));
  background-position: center;
  background-size: cover;
  opacity: 0.86;
}
.watch-copy, .watch-stage { position: relative; z-index: 1; min-width: 0; }
.watch-copy { display: grid; gap: 0.75rem; align-content: end; }
.watch-stage .player { height: 100%; }
.details-layout, .watch-layout { display: grid; gap: 1rem; }
.details-stack { display: grid; gap: 1rem; align-content: start; }
.details-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(16, 18, 23, 0.82);
  padding: 1rem;
}

.player {
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: var(--radius);
  background: #020305;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.48);
}
.player-frame { position: relative; aspect-ratio: 16 / 9; background: #020305; }
.player-frame iframe, .player-frame video, .provider-frame { width: 100%; height: 100%; border: 0; background: #020305; }
.provider-frame { position: absolute; inset: 0; z-index: 2; }
.provider-frame.loaded { z-index: 3; }
.provider-video { position: absolute; inset: 0; z-index: 2; object-fit: contain; }
.provider-video.loaded { z-index: 3; }
.provider-embed {
  display: grid;
  place-items: center;
  overflow: hidden;
  background: linear-gradient(180deg, #12151b, #030407);
}
.provider-embed-art {
  position: absolute;
  inset: 0;
  opacity: 0.36;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent 34%);
  background-position: center;
  background-size: cover;
  filter: saturate(0.95) contrast(0.98);
}
.provider-embed-copy {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 0.7rem;
  justify-items: center;
  max-width: 32rem;
  padding: 1rem;
  text-align: center;
}
.provider-embed-copy strong { font-size: 1.15rem; }
.provider-cover {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: rgba(2, 3, 5, 0.74);
  padding: 1rem;
  text-align: center;
}
.provider-cover strong {
  max-width: min(34rem, 88%);
  font-size: 1.45rem;
  line-height: 1.06;
}
.provider-cover span:not(.badge) { color: var(--muted); }
.provider-cover.provider-warning { background: linear-gradient(135deg, rgba(255, 138, 0, 0.14), transparent), #020305; }
.provider-cover.hidden { display: none; }
.player-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding: 0.75rem;
  background: rgba(5, 6, 8, 0.94);
}
.player-actions { display: flex; flex-wrap: wrap; gap: 0.55rem; align-items: center; }
.episode-progress {
  width: 6.5rem;
  height: 0.5rem;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}
.episode-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--lime), var(--orange));
}
.source-select { width: auto; max-width: 12.5rem; min-height: 2.55rem; padding: 0 0.65rem; cursor: pointer; }
.subtitle-overlay {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  left: 1rem;
  z-index: 5;
  display: none;
  justify-content: center;
  pointer-events: none;
}
.subtitle-overlay.active { display: flex; }
.subtitle-overlay span {
  max-width: 80%;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  padding: 0.45rem 0.7rem;
  text-align: center;
  line-height: 1.45;
}

.episode-list, .chip-list, .character-grid { display: grid; gap: 0.6rem; }
.episode-list {
  grid-template-columns: repeat(auto-fill, minmax(4.7rem, 1fr));
  max-height: 20rem;
  overflow: auto;
}
.episode-button, .chip {
  min-height: 2.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(23, 26, 33, 0.9);
  color: var(--text);
  padding: 0 0.65rem;
  font-weight: 800;
}
.episode-button.active, .chip.active, .chip:hover {
  border-color: rgba(124, 255, 0, 0.58);
  background: rgba(124, 255, 0, 0.14);
}
.character-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.character {
  display: grid;
  grid-template-columns: 3.2rem 1fr;
  gap: 0.75rem;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(23, 26, 33, 0.66);
  padding: 0.55rem;
}
.character img { width: 3.2rem; height: 3.2rem; border-radius: 50%; object-fit: cover; }
.empty-state, .error-state {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(16, 18, 23, 0.82);
  color: var(--muted);
  padding: 1.2rem;
}
.error-state { border-color: rgba(255, 92, 122, 0.45); color: #ffd2da; }

.skeleton { position: relative; overflow: hidden; background: rgba(255, 255, 255, 0.1); }
.skeleton::after {
  position: absolute;
  inset: 0;
  content: "";
  transform: translateX(-100%);
  animation: shimmer 1.25s infinite;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.12), transparent);
}
@keyframes shimmer { to { transform: translateX(100%); } }
.line { display: block; height: 0.9rem; border-radius: 999px; }
.line.short { width: 62%; }

@media (min-width: 760px) {
  .view { padding: 1.25rem; }
  .filters { grid-template-columns: repeat(4, minmax(8rem, 1fr)); width: auto; }
  .anime-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
  .continue-rail { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .personal-panel { grid-template-columns: minmax(15rem, 0.8fr) minmax(16rem, 0.7fr) minmax(22rem, 1.4fr); align-items: center; }
  .hero-content { padding: 1.75rem; }
  .hero h1, .watch-copy h1 { font-size: 3.35rem; }
  .provider-cover strong { font-size: 1.7rem; }
}

@media (min-width: 940px) {
  .sidebar {
    position: sticky;
    inset: auto;
    top: 0;
    z-index: 38;
    width: auto;
    min-height: 4.25rem;
    transform: none;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 0.65rem 2rem;
  }
  .nav-list { display: flex; align-items: center; gap: 0.35rem; margin: 0; }
  .nav-list a { padding: 0.7rem 0.85rem; }
  .topbar { top: 4.25rem; padding: 0.75rem 2rem; }
  .sidebar-toggle { display: none; }
  .search-wrap { max-width: 48rem; }
}

@media (min-width: 1120px) {
  .view { padding: 1.5rem 2rem 2rem; }
  .home-spotlight { grid-template-columns: minmax(0, 1fr) minmax(19rem, 0.3fr); }
  .anime-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .watch-room { grid-template-columns: minmax(21rem, 0.58fr) minmax(0, 1.42fr); align-items: end; padding: 1.25rem; }
  .details-layout { grid-template-columns: minmax(22rem, 0.78fr) minmax(0, 1.22fr); align-items: start; }
  .hero h1, .watch-copy h1 { font-size: 4rem; }
}
