:root {
  --bg: #050508;
  --surface: #111116;
  --surface-2: #191920;
  --surface-3: #20212a;
  --text: #f4f4f7;
  --muted: #a9abb5;
  --soft: #d6d7df;
  --red: #ff1747;
  --red-dark: #9f0926;
  --gold: #f3b94f;
  --teal: #25c7b7;
  --violet: #9d5cff;
  --line: #2b2c35;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 23, 71, 0.08), transparent 340px),
    linear-gradient(180deg, #0c0b10 0%, var(--bg) 38%, #050508 100%);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  letter-spacing: 0;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 5vw;
  background: rgba(5, 5, 8, 0.9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 21px;
}

.brand-mark {
  display: block;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  object-fit: contain;
  background: #0d0d13;
  box-shadow: 0 0 24px rgba(229, 9, 47, 0.45);
}

.nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.nav a,
.chip,
button,
.button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 17, 22, 0.86);
  color: var(--text);
  padding: 10px 15px;
  font-weight: 700;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease, color 160ms ease;
}

.nav a:hover,
.button:hover,
button:hover {
  border-color: var(--red);
  color: #fff;
  background: #181821;
  transform: translateY(-1px);
}

.user-menu {
  position: relative;
}

.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 150px;
  padding: 7px 12px 7px 8px;
  background: transparent;
  border-color: transparent;
}

.user-menu-trigger:hover,
.user-menu.open .user-menu-trigger {
  background: #14141c;
  border-color: var(--line);
}

.user-menu-trigger img {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 50%;
  object-fit: cover;
  background: #111116;
  box-shadow: 0 0 20px rgba(255, 23, 71, 0.22);
}

.user-menu-trigger span {
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 40;
  display: none;
  min-width: 190px;
  padding: 8px;
  background: rgba(12, 12, 17, 0.98);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.user-menu.open .user-menu-dropdown {
  display: grid;
  gap: 6px;
}

.user-menu-dropdown a,
.user-menu-dropdown button {
  width: 100%;
  padding: 10px 11px;
  background: transparent;
  border-color: transparent;
  border-radius: 7px;
  color: var(--text);
  text-align: left;
  transform: none;
}

.user-menu-dropdown a:hover,
.user-menu-dropdown button:hover {
  background: #181821;
  border-color: var(--line);
  color: #fff;
  transform: none;
}

.button.primary,
button.primary {
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  border-color: var(--red);
  box-shadow: 0 12px 28px rgba(255, 23, 71, 0.24);
}

.hero {
  min-height: 68vh;
  display: grid;
  align-items: center;
  padding: 7vw 5vw 5vw;
  background:
    linear-gradient(90deg, rgba(5, 5, 8, 0.98) 0%, rgba(5, 5, 8, 0.82) 45%, rgba(5, 5, 8, 0.34) 100%),
    url("https://images.unsplash.com/photo-1518709268805-4e9042af2176?auto=format&fit=crop&w=1800&q=80") center/cover;
  border-bottom: 1px solid var(--line);
}

.home-spotlight {
  position: relative;
  min-height: 410px;
  display: grid;
  grid-template-columns: 180px minmax(0, 640px) 1fr;
  gap: 34px;
  align-items: center;
  padding: 42px 5vw;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background: #07070b;
}

.spotlight-bg {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(5, 5, 8, 0.96), rgba(5, 5, 8, 0.72), rgba(5, 5, 8, 0.96)),
    linear-gradient(135deg, #25104a, #08080d 60%, #3a0612);
  background-size: cover;
  background-position: center;
  filter: saturate(1.1);
  opacity: 0.82;
}

.spotlight-cover,
.spotlight-copy,
.spotlight-count {
  position: relative;
  z-index: 1;
}

.spotlight-cover .cover {
  width: 178px;
  border-radius: 12px;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.72);
}

.spotlight-copy h1 {
  font-size: clamp(38px, 5vw, 68px);
  line-height: 1.02;
}

.spotlight-copy p {
  max-width: 620px;
  color: #d3d4dc;
  font-size: 18px;
}

.status-pill {
  display: inline-flex;
  padding: 8px 13px;
  border-radius: 999px;
  background: #5869ff;
  color: white;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.spotlight-count {
  justify-self: end;
  align-self: end;
  display: flex;
  align-items: center;
  gap: 12px;
  color: white;
  font-size: 22px;
  font-weight: 800;
}

.spotlight-count span {
  width: 42px;
  height: 1px;
  background: var(--muted);
}

.home-section {
  padding: 34px 5vw;
  border-bottom: 1px solid var(--line);
  background: #111216;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-heading h2 {
  margin: 0;
  font-size: 24px;
}

.section-heading p {
  margin: 4px 0 0;
}

.home-rail {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 154px;
  gap: 14px;
  overflow-x: auto;
  padding: 2px 0 10px;
  scrollbar-width: thin;
}

.rail-card {
  display: block;
  min-width: 0;
}

.rail-card .cover {
  border-radius: 10px;
}

.rail-card small,
.rail-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rail-card strong {
  display: block;
  color: white;
  font-size: 15px;
  line-height: 1.35;
  margin-top: 4px;
}

.ranked-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 10px;
}

.rank-card {
  display: grid;
  grid-template-columns: 42px 50px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-height: 86px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #16171c;
}

.rank-number {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: #242b34;
  color: white;
  font-weight: 900;
}

.rank-card:nth-child(-n + 3) .rank-number {
  background: #ff9500;
}

.rank-thumb .cover {
  width: 50px;
  border-radius: 8px;
}

.rank-thumb .cover h3 {
  display: none;
}

.rank-card strong,
.rank-card p,
.rank-card small {
  display: block;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rank-card p {
  color: white;
  font-weight: 800;
}

.rank-card small {
  color: var(--muted);
  margin-top: 3px;
}

.hero-content {
  max-width: 720px;
}

.eyebrow {
  color: var(--red);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 13px;
}

h1 {
  margin: 12px 0;
  font-size: clamp(42px, 7vw, 88px);
  line-height: 0.95;
}

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

p {
  color: var(--muted);
  line-height: 1.65;
}

.hero-actions,
.toolbar,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.section > h2 {
  display: flex;
  align-items: center;
  gap: 10px;
}

.section > h2::before {
  content: "";
  width: 5px;
  height: 28px;
  border-radius: 8px;
  background: var(--red);
}

.section {
  padding: 50px 5vw;
}

.section.alt {
  background: rgba(13, 13, 18, 0.88);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

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

[data-new-episodes].grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

[data-popular-series].grid {
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  align-items: start;
}

[data-catalog-grid].grid {
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  align-items: start;
}

.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.card:hover {
  border-color: rgba(255, 23, 71, 0.72);
  transform: translateY(-4px);
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.56);
}

.cover {
  min-height: auto;
  aspect-ratio: 3 / 4.15;
  padding: 16px;
  display: flex;
  align-items: flex-end;
  background:
    linear-gradient(160deg, rgba(255, 23, 71, 0.9), rgba(10, 10, 16, 0.18)),
    var(--surface-2);
}

.cover.has-cover-image {
  position: relative;
  background-size: cover;
  background-position: center;
}

.cover.has-cover-image::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(5, 5, 8, 0.05), rgba(5, 5, 8, 0.72));
}

.cover.has-cover-image h3 {
  position: relative;
  z-index: 1;
}

.cover.blue {
  background: linear-gradient(160deg, #008a9b, #101017);
}

.cover.gold {
  background: linear-gradient(160deg, #ad7621, #111017);
}

.cover.violet {
  background: linear-gradient(160deg, #7d3ec9, #111017);
}

.cover h3 {
  margin: 0;
  font-size: 18px;
  text-shadow: 0 3px 18px rgba(0, 0, 0, 0.62);
}

.card-body {
  padding: 12px;
}

.card-body p {
  min-height: 42px;
  font-size: 14px;
  line-height: 1.45;
}

.compact-card .card-body p {
  min-height: auto;
  margin: 8px 0 0;
  color: var(--text);
}

.compact-card .card-body {
  padding: 10px 4px 0;
  background: transparent;
}

.compact-card {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.compact-card:hover {
  background: transparent;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.meta span,
.chip {
  color: var(--soft);
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 17, 22, 0.96);
  padding: 22px;
  box-shadow: var(--shadow);
}

.panel h3 {
  margin-top: 4px;
  font-size: 22px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  gap: 24px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #09090d;
  color: var(--text);
  padding: 12px;
  margin: 7px 0 14px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(255, 23, 71, 0.14);
}

label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 8px;
}

.table th,
.table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.table th {
  color: var(--red);
  background: #0d0d13;
  font-size: 13px;
  text-transform: uppercase;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b0b10;
}

.table-wrap .table {
  border-radius: 0;
}

.table tr:hover td {
  background: rgba(255, 23, 71, 0.06);
}

.admin-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 18px;
  margin-top: 24px;
  align-items: start;
}

.admin-menu {
  position: sticky;
  top: 86px;
  display: grid;
  gap: 10px;
  background: #0d0d13;
}

.tab-button {
  width: 100%;
  text-align: left;
}

.tab-button.active {
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  border-color: var(--red);
}

.admin-content {
  min-width: 0;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin: 22px 0;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #171720, #0d0d13);
  padding: 18px;
}

.stat strong {
  display: block;
  color: var(--red);
  font-size: 34px;
}

.stat span {
  color: var(--muted);
}

.admin-form {
  max-width: 760px;
  padding-top: 4px;
}

.inline-form {
  max-width: none;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) auto;
  gap: 14px;
  align-items: end;
}

.toolbar.compact {
  align-items: end;
  margin: 10px 0 18px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d0d13;
}

.toolbar.compact label {
  width: 100%;
}

.toolbar.compact select {
  width: min(320px, 100%);
}

.catalog-controls {
  margin-top: 18px;
}

.catalog-controls input {
  max-width: 520px;
}

.category-filter {
  margin-top: 8px;
}

.category-filter .chip {
  cursor: pointer;
}

.category-filter .chip.active {
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  border-color: var(--red);
  color: #fff;
}

.upload-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.upload-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
  margin: 10px 0 18px;
}

.cover-preview {
  margin: 8px 0 16px;
}

.cover-preview img {
  width: 180px;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #05060a;
}

.series-detail-cover {
  width: min(280px, 100%);
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  background: #05060a;
}

.preview-tile {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d0d13;
  padding: 8px;
  min-height: 120px;
}

.preview-tile img,
.db-thumb {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 6px;
  background: #05060a;
}

.preview-tile span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.db-thumb {
  width: 64px;
  height: 86px;
}

.reader {
  max-width: 900px;
  margin: 0 auto;
}

.episode-page {
  min-height: 520px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(145deg, #181820, #09090d 55%, #3a0612);
  color: #fff;
  font-size: 32px;
  font-weight: 800;
  box-shadow: var(--shadow);
}

.episode-page img {
  display: block;
  width: 100%;
  max-width: 860px;
  height: auto;
  border-radius: 8px;
}

.episode-page.has-image {
  min-height: auto;
  padding: 0;
  background: #05060a;
}

.reader-community {
  margin-top: 28px;
}

.reaction-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0;
}

.reaction-row button.active {
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  border-color: var(--red);
}

.comment-form {
  margin-top: 14px;
}

.comment {
  border-top: 1px solid var(--line);
  padding: 14px 0;
}

.comment p {
  margin-bottom: 0;
}

.comment strong {
  color: var(--text);
}

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

.profile-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 12px 0 20px;
}

.avatar {
  width: 86px;
  height: 86px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
  background: #0d0d13;
}

.locked {
  display: none;
}

.footer {
  padding: 28px 5vw;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .home-spotlight {
    grid-template-columns: 112px minmax(0, 1fr);
    gap: 18px;
    min-height: 360px;
  }

  .spotlight-cover .cover {
    width: 112px;
  }

  .spotlight-copy h1 {
    font-size: 34px;
  }

  .spotlight-count {
    display: none;
  }

  .home-rail {
    grid-auto-columns: 138px;
  }

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

  .admin-shell,
  .inline-form {
    grid-template-columns: 1fr;
  }

  [data-popular-series].grid,
  [data-catalog-grid].grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }

  .admin-menu {
    position: static;
  }

  .nav a,
  .chip,
  button,
  .button {
    padding: 9px 11px;
  }
}
