:root {
  color-scheme: dark;
  --bg: #070b14;
  --bg-deep: #020409;
  --surface: rgba(255, 255, 255, 0.06);
  --surface-soft: rgba(255, 255, 255, 0.03);
  --surface-strong: rgba(255, 255, 255, 0.12);
  --surface-ink: rgba(5, 9, 15, 0.85);
  --ink: #ffffff;
  --muted: #8b9db1;
  --muted-strong: #c8d6e5;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --accent: #5ce1e6;
  --accent-strong: #a4fbfb;
  --accent-ink: #001214;
  --rose: #ff7eb3;
  --gold: #f2c94c;
  --warm: #ff9a9e;
  --shadow: 0 40px 100px -10px rgba(0, 0, 0, 0.7), 0 20px 40px -15px rgba(92, 225, 230, 0.15);
  --shadow-soft: 0 20px 50px -10px rgba(0, 0, 0, 0.5);
  --glass-blur: blur(30px) saturate(150%);
  --inner-glow: inset 0 1px 1px rgba(255, 255, 255, 0.15), inset 0 -1px 1px rgba(255, 255, 255, 0.02);
  --transition-bezier: cubic-bezier(0.25, 1, 0.2, 1);
  --transition-elastic: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg-deep);
}

body {
  position: relative;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 15% 0%, rgba(92, 225, 230, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 85% 20%, rgba(255, 126, 179, 0.06) 0%, transparent 45%),
    radial-gradient(circle at 50% 100%, rgba(10, 25, 45, 0.8) 0%, transparent 60%),
    linear-gradient(180deg, #09121f 0%, #04080e 45%, #020409 100%);
  background-color: var(--bg-deep);
  color: var(--ink);
  font-family: "Inter", "Outfit", system-ui, -apple-system, sans-serif;
  letter-spacing: 0.01em;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body.modal-open {
  overflow: hidden;
}

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

button,
input {
  font: inherit;
}

button {
  letter-spacing: 0;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid rgba(138, 219, 210, 0.72);
  outline-offset: 3px;
}

input::placeholder {
  color: rgba(215, 226, 238, 0.54);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto minmax(220px, 620px) auto;
  gap: 20px;
  align-items: center;
  padding: 14px clamp(16px, 4vw, 48px);
  background: linear-gradient(180deg, rgba(7, 11, 20, 0.85), rgba(4, 7, 12, 0.75));
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}

.topbar::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(92, 225, 230, 0.4), rgba(255, 126, 179, 0.3), transparent);
  content: "";
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 800;
}

.brand-mark {
  display: inline-flex;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  box-shadow: 0 10px 24px rgba(83, 198, 189, 0.18);
  overflow: hidden;
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.top-search {
  display: flex;
  gap: 8px;
}

.top-actions {
  position: relative;
  justify-self: end;
}

.settings-toggle {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: var(--muted-strong);
  background: rgba(245, 250, 255, 0.075);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--inner-glow);
  cursor: pointer;
  backdrop-filter: blur(18px) saturate(130%);
  -webkit-backdrop-filter: blur(18px) saturate(130%);
  transition: color 180ms ease, border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.settings-toggle:hover,
.settings-toggle.active {
  color: var(--accent-strong);
  background: rgba(92, 225, 230, 0.15);
  border-color: rgba(92, 225, 230, 0.5);
  transform: scale(1.05);
}

.settings-icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.settings-menu[hidden] {
  display: none;
}

.settings-menu {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  z-index: 35;
  display: grid;
  gap: 14px;
  width: min(360px, calc(100vw - 24px));
  padding: 16px;
  color: var(--ink);
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02) 50%, rgba(255, 255, 255, 0.04)),
    rgba(5, 9, 15, 0.85);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: var(--shadow), var(--inner-glow);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  transform-origin: top right;
  animation: dropIn 0.3s var(--transition-elastic) forwards;
}

@keyframes dropIn {
  from { opacity: 0; transform: scale(0.95) translateY(-10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.settings-menu-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.settings-menu-header strong {
  display: block;
  font-size: 16px;
}

.settings-menu-header span,
.settings-stat span,
.settings-row span,
.settings-note {
  color: var(--muted);
  font-size: 12px;
}

.settings-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.settings-stat {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 12px;
  background: rgba(246, 250, 255, 0.065);
  border: 1px solid rgba(235, 246, 255, 0.095);
  border-radius: 8px;
  box-shadow: var(--inner-glow);
}

.settings-stat strong {
  font-size: 24px;
  line-height: 1;
}

.settings-list {
  display: grid;
  gap: 9px;
}

.settings-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  min-width: 0;
}

.settings-row strong {
  min-width: 0;
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 760;
  text-align: right;
}

.settings-note {
  margin-top: -5px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(235, 246, 255, 0.08);
}

.settings-about-button {
  min-height: 34px;
  color: var(--accent-strong);
  background: rgba(138, 219, 210, 0.105);
  border: 1px solid rgba(138, 219, 210, 0.3);
  border-radius: 8px;
  box-shadow: var(--inner-glow);
  cursor: pointer;
  font-weight: 760;
}

.settings-about-button:hover {
  background: rgba(138, 219, 210, 0.16);
}

.mobile-bottom-search {
  display: none;
}

.mobile-search-panel,
.mobile-category-nav {
  display: none;
}

.top-search input {
  width: 100%;
  min-height: 44px;
  padding: 11px 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--inner-glow);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  transition: all 0.3s var(--transition-bezier);
}

.top-search input:focus {
  border-color: rgba(92, 225, 230, 0.5);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: var(--inner-glow), 0 0 15px rgba(92, 225, 230, 0.15);
}

.top-search button,
.primary-button,
.secondary-button,
.episode-grid a,
.episode-button,
.candidate {
  border-radius: 8px;
  cursor: pointer;
}

.top-search button,
.primary-button,
.speed-test-button {
  border: 1px solid rgba(164, 251, 251, 0.3);
  color: #ffffff;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.15), rgba(92, 225, 230, 0.25) 50%, rgba(45, 153, 153, 0.4));
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.4), 0 10px 20px rgba(92, 225, 230, 0.2);
  font-weight: 800;
  transition: all 0.3s var(--transition-elastic);
}

.top-search button,
.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 11px 18px;
}

.top-search button:hover,
.primary-button:hover,
.speed-test-button:hover:not(:disabled) {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.25), rgba(92, 225, 230, 0.35) 50%, rgba(55, 175, 175, 0.5));
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.5), 0 15px 25px rgba(92, 225, 230, 0.3);
  transform: translateY(-2px);
}

.top-search button:active,
.primary-button:active,
.speed-test-button:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.2), 0 5px 10px rgba(92, 225, 230, 0.15);
}

.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 10px 14px;
  color: var(--muted-strong);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));
  border: 1px solid var(--line);
  box-shadow: var(--inner-glow);
  font-weight: 760;
  transition: all 0.3s var(--transition-bezier);
}

.secondary-button.active,
.secondary-button:hover {
  border-color: rgba(92, 225, 230, 0.4);
  color: var(--accent-strong);
  background: rgba(92, 225, 230, 0.15);
  transform: translateY(-1px);
}

.page {
  width: min(1320px, calc(100% - 48px));
  margin: 0 auto;
  padding: 48px 0 80px;
}

.workspace,
.detail-layout,
.player-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: start;
}

.panel,
.compact-band,
.recommend-filters,
.detail-main,
.player-info,
.empty-state,
.notice,
.flash {
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.055) 50%, rgba(255, 255, 255, 0.085));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft), var(--inner-glow);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}

.panel {
  position: relative;
}

.compact-band {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-top: 18px;
  padding: 14px 16px;
}

.compact-band h2 {
  margin: 0;
  font-size: 16px;
  white-space: nowrap;
}

.detail-main h1,
.player-info h1,
.section h1 {
  margin: 0;
  font-size: clamp(30px, 5vw, 56px);
  line-height: 1.02;
}

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

.recommend-browser {
  display: grid;
  gap: 16px;
}

.recommend-browser .recommend-filters {
  width: fit-content;
  max-width: 100%;
}

.recommend-filters {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.filter-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.filter-row > span {
  padding-top: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-tab {
  min-height: 34px;
  padding: 7px 14px;
  color: var(--muted-strong);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--inner-glow);
  cursor: pointer;
  font-weight: 760;
  transition: all 0.3s var(--transition-bezier);
}

.filter-tab.active,
.filter-tab:hover {
  color: #ffffff;
  background: linear-gradient(180deg, rgba(92, 225, 230, 0.2), rgba(45, 153, 153, 0.15));
  border-color: rgba(92, 225, 230, 0.5);
  box-shadow: var(--inner-glow), 0 8px 20px rgba(92, 225, 230, 0.2);
  transform: translateY(-1px);
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  color: var(--muted);
  font-weight: 800;
}

.pagination[hidden] {
  display: none;
}

.pagination-button {
  min-height: 36px;
  padding: 8px 14px;
  color: var(--muted-strong);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--inner-glow);
  cursor: pointer;
  font-weight: 800;
}

.pagination-button:hover:not(:disabled) {
  color: var(--accent-strong);
  background: rgba(138, 219, 210, 0.15);
  border-color: rgba(138, 219, 210, 0.42);
}

.pagination-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.side-panel,
.compact {
  padding: 18px;
}

.side-panel h2,
.compact h2,
.detail-main h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
}

.section-title h2 {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  background: linear-gradient(120deg, #ffffff 30%, #c8d6e5 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 7px 12px;
  color: var(--muted-strong);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--inner-glow);
  transition: all 0.3s var(--transition-bezier);
}

.chip:hover {
  color: #ffffff;
  border-color: rgba(255, 126, 179, 0.4);
  background: rgba(255, 126, 179, 0.15);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(255, 126, 179, 0.2), var(--inner-glow);
}

.section {
  margin-top: 56px;
}

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

.section-title h1,
.section-title h2,
.detail-main h1,
.player-info h1 {
  text-shadow: 0 12px 34px rgba(92, 225, 230, 0.15);
}

.section-title h1,
.detail-main h1,
.player-info h1 {
  font-weight: 800;
}

.section-title p {
  margin: 5px 0 0;
}

.section-title.small {
  align-items: center;
}

.section-title.small span {
  color: var(--muted);
  font-size: 13px;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 20px;
  min-width: 0;
}

.paged-item {
  min-width: 0;
}

.media-card {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  padding: 10px;
  background: linear-gradient(150deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02) 50%, rgba(255, 255, 255, 0.04));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3), var(--inner-glow);
  transition: all 0.4s var(--transition-elastic);
}

.media-card:hover {
  transform: translateY(-6px) scale(1.02);
  background: linear-gradient(150deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.03) 50%, rgba(255, 255, 255, 0.06));
  border-color: rgba(92, 225, 230, 0.4);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5), 0 0 20px rgba(92, 225, 230, 0.15), var(--inner-glow);
}

.media-card::before {
  position: absolute;
  inset: 0 0 auto;
  height: 54%;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), transparent);
  content: "";
}

.poster {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  isolation: isolate;
  color: #fff;
  background:
    linear-gradient(145deg, rgba(92, 225, 230, 0.1), rgba(255, 126, 179, 0.05)),
    #0a0f1a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  box-shadow: 0 20px 42px rgba(0, 0, 0, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  font-size: 44px;
  font-weight: 800;
}

.poster::before,
.poster::after {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  content: "";
}

.poster::before {
  background:
    linear-gradient(128deg, rgba(255, 255, 255, 0.24) 0%, rgba(255, 255, 255, 0.065) 18%, transparent 42%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 30%);
  opacity: 0.62;
}

.poster::after {
  top: 54%;
  background: linear-gradient(180deg, transparent, rgba(3, 5, 9, 0.76));
}

.rating-badge,
.progress-badge {
  position: absolute;
  z-index: 2;
  padding: 4px 8px;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  font-size: 12px;
  font-weight: 800;
}

.rating-badge {
  right: 8px;
  top: 8px;
  background: rgba(231, 155, 123, 0.78);
}

.progress-badge {
  left: 8px;
  bottom: 8px;
  background: rgba(92, 191, 177, 0.78);
}

.poster img,
.poster-frame img {
  width: 100%;
  min-width: 0;
  height: 100%;
  object-fit: cover;
}

.poster img {
  transition: transform 0.5s var(--transition-elastic), filter 0.5s ease;
}

.media-card:hover .poster img {
  transform: scale(1.08);
}

.poster-fallback {
  position: relative;
  z-index: 2;
  display: none;
  padding: 14px;
  color: #fff;
  font-size: clamp(24px, 5vw, 46px);
  font-weight: 800;
  line-height: 1.08;
  text-align: center;
  word-break: break-all;
}

.poster:not(:has(img)) .poster-fallback,
.poster.poster-missing .poster-fallback {
  display: block;
}

.card-body {
  padding-top: 10px;
}

.card-title {
  display: block;
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.card-title:hover {
  color: var(--accent-strong);
}

.card-meta,
.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.card-meta {
  gap: 6px;
  font-variant-numeric: tabular-nums;
}

.card-meta span,
.meta-row span {
  padding: 3px 7px;
  color: var(--muted-strong);
  background: rgba(246, 250, 255, 0.06);
  border: 1px solid rgba(235, 246, 255, 0.075);
  border-radius: 999px;
}

.card-meta span {
  padding-inline: 6px;
  white-space: nowrap;
}

.empty-state,
.notice {
  padding: 18px;
  color: var(--muted);
}

.empty-state {
  border-style: dashed;
}

.notice {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
  color: var(--warm);
}

.notice-fab {
  position: fixed;
  right: 18px;
  bottom: 28px;
  z-index: 40;
  min-width: 58px;
  min-height: 58px;
  padding: 0 15px;
  color: var(--accent-strong);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(138, 219, 210, 0.24));
  border: 1px solid rgba(215, 255, 250, 0.34);
  border-radius: 999px;
  box-shadow: var(--shadow);
  cursor: pointer;
  font-weight: 800;
}

.notice-fab:hover {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.24), rgba(138, 219, 210, 0.34));
}

.notice-modal[hidden],
.about-modal[hidden] {
  display: none;
}

.notice-modal,
.about-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
}

.notice-backdrop,
.about-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 5, 9, 0.62);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.notice-dialog,
.about-dialog {
  position: relative;
  display: grid;
  gap: 16px;
  width: min(560px, 100%);
  padding: 22px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.075));
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: var(--shadow), var(--inner-glow);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}

.notice-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.notice-dialog-header h2 {
  margin: 0;
  font-size: 22px;
}

.notice-dialog-body {
  display: grid;
  gap: 14px;
  color: var(--muted);
  line-height: 1.7;
}

.notice-dialog-body p {
  margin: 5px 0 0;
}

.about-dialog-body {
  display: grid;
  gap: 10px;
  color: var(--muted-strong);
  line-height: 1.75;
}

.about-dialog-body p {
  margin: 0;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  color: var(--muted-strong);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--inner-glow);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.icon-button:hover {
  color: var(--accent-strong);
  border-color: rgba(138, 219, 210, 0.42);
  background: rgba(138, 219, 210, 0.105);
}

.detail-layout {
  grid-template-columns: 280px minmax(0, 1fr);
}

.poster-frame {
  aspect-ratio: 2 / 3;
  overflow: hidden;
  background:
    linear-gradient(145deg, rgba(138, 219, 210, 0.14), rgba(216, 142, 175, 0.085)),
    #101823;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow), var(--inner-glow);
}

.poster-placeholder {
  display: grid;
  place-items: center;
  height: 100%;
  color: #fff;
  font-size: 80px;
  font-weight: 800;
}

.detail-main {
  min-width: 0;
  padding: 24px;
}

.description {
  color: #d5deea;
  line-height: 1.75;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0;
}

.episode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.episode-grid a,
.episode-button {
  min-height: 38px;
  padding: 8px 10px;
  color: var(--ink);
  text-align: center;
  background: rgba(246, 250, 255, 0.064);
  border: 1px solid var(--line);
  box-shadow: var(--inner-glow);
}

.episode-button.active,
.episode-grid a:hover,
.episode-button:hover {
  color: var(--accent-strong);
  background: rgba(138, 219, 210, 0.12);
  border-color: rgba(138, 219, 210, 0.42);
}

.player-layout {
  grid-template-columns: minmax(0, 1fr) 360px;
}

.player-main {
  min-width: 0;
}

.video-shell {
  position: relative;
  width: 100%;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: #010206;
  border: 1px solid rgba(235, 246, 255, 0.14);
  border-radius: 8px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

.video-shell::before {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  background: linear-gradient(130deg, rgba(255, 255, 255, 0.12), transparent 24%, transparent 76%, rgba(138, 219, 210, 0.06));
  content: "";
}

.video-shell video,
.art-player {
  width: 100%;
  height: 100%;
  background: #010206;
}

.artplayer-app {
  font-family: inherit;
}

.player-loading-hint,
.player-gesture-hint {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 7;
  padding: 9px 13px;
  color: #fff;
  background: rgba(4, 8, 13, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  box-shadow: var(--inner-glow);
  backdrop-filter: blur(16px) saturate(145%);
  -webkit-backdrop-filter: blur(16px) saturate(145%);
  font-size: 14px;
  font-weight: 800;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.player-gesture-hint {
  z-index: 8;
  color: var(--accent-strong);
  background: rgba(15, 45, 49, 0.82);
  font-size: 18px;
}

.player-loading-hint[hidden],
.player-gesture-hint[hidden] {
  display: none;
}

.player-info {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-top: 18px;
  padding: 18px;
}

.player-info h1 {
  font-size: clamp(24px, 4vw, 38px);
}

.player-sidebar {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.mobile-player-tabs {
  display: none;
}

.candidate-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  max-height: 264px;
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
  scrollbar-color: rgba(138, 219, 210, 0.42) rgba(255, 255, 255, 0.08);
  scrollbar-width: thin;
}

.speed-test-button {
  width: 100%;
  min-height: 38px;
  border-radius: 8px;
  cursor: pointer;
}

.speed-test-button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.candidate {
  display: grid;
  gap: 4px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 56px;
  padding: 10px;
  color: var(--ink);
  text-align: left;
  background: rgba(246, 250, 255, 0.065);
  border: 1px solid var(--line);
  box-shadow: var(--inner-glow);
}

.candidate-empty {
  min-width: 0;
  padding: 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.07);
  border: 1px dashed var(--line);
  border-radius: 8px;
  font-size: 13px;
  text-align: center;
}

.candidate.active,
.candidate:hover {
  border-color: rgba(138, 219, 210, 0.42);
  background: rgba(138, 219, 210, 0.105);
}

.candidate-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.candidate-metrics {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.candidate-metrics.error {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  color: var(--warm);
  font-weight: 760;
}

.status-dot {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  background: var(--warm);
  border-radius: 50%;
}

.episode-grid.side {
  grid-template-columns: repeat(3, 1fr);
  max-height: 420px;
  overflow: auto;
  scrollbar-color: rgba(138, 219, 210, 0.42) rgba(255, 255, 255, 0.08);
  scrollbar-width: thin;
}

.flash-list {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.flash {
  padding: 12px 14px;
}

.flash.success {
  color: var(--accent-strong);
}

.flash.error {
  color: var(--warm);
}

code {
  padding: 2px 5px;
  color: var(--accent-strong);
  background: rgba(138, 219, 210, 0.1);
  border: 1px solid rgba(138, 219, 210, 0.2);
  border-radius: 5px;
}

@media (hover: hover) {
  .top-search button,
  .primary-button,
  .secondary-button,
  .filter-tab,
  .pagination-button,
  .chip,
  .episode-grid a,
  .episode-button,
  .candidate,
  .notice-fab,
  .speed-test-button {
    transition: transform 180ms ease, border-color 180ms ease, background 180ms ease, color 180ms ease, box-shadow 180ms ease;
  }

  .top-search button:hover,
  .primary-button:hover,
  .secondary-button:hover,
  .pagination-button:hover:not(:disabled),
  .notice-fab:hover,
  .speed-test-button:hover:not(:disabled) {
    transform: translateY(-1px);
  }

  .media-card:hover {
    background:
      linear-gradient(150deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.055) 52%, rgba(255, 255, 255, 0.085));
    border-color: rgba(138, 219, 210, 0.26);
    box-shadow: 0 24px 52px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.18);
    transform: translateY(-4px);
  }

  .media-card:hover .poster img {
    filter: saturate(1.08) contrast(1.04);
    transform: scale(1.045);
  }
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .topbar,
  .panel,
  .compact-band,
  .recommend-filters,
  .detail-main,
  .player-info,
  .empty-state,
  .notice,
  .flash,
  .notice-dialog,
  .settings-menu,
  .mobile-category-nav,
  .mobile-bottom-search {
    background: rgba(14, 20, 31, 0.96);
  }
}

@media (max-width: 860px) {
  body.has-mobile-nav {
    padding-bottom: calc(78px + env(safe-area-inset-bottom));
  }

  .topbar {
    grid-template-columns: 1fr;
    gap: 0;
    padding-block: 12px;
  }

  .topbar .brand {
    justify-self: center;
  }

  .top-actions {
    position: absolute;
    right: 12px;
    top: 50%;
    margin-top: -20px;
  }

  .settings-toggle {
    width: 40px;
    height: 40px;
  }

  .settings-menu {
    position: fixed;
    top: calc(64px + env(safe-area-inset-top));
    right: 10px;
    left: auto;
    width: min(292px, calc(100vw - 20px));
    max-height: calc(100dvh - 188px - env(safe-area-inset-bottom));
    gap: 8px;
    padding: 10px;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .settings-menu-header strong {
    font-size: 14px;
  }

  .settings-menu-header span,
  .settings-stat span,
  .settings-row span,
  .settings-note {
    font-size: 11px;
  }

  .settings-stat-grid {
    gap: 5px;
  }

  .settings-stat {
    padding: 8px 9px;
  }

  .settings-stat strong {
    font-size: 18px;
  }

  .settings-list {
    gap: 6px;
  }

  .settings-row {
    gap: 8px;
  }

  .settings-row strong {
    font-size: 11px;
  }

  .top-search {
    display: none;
  }

  .recommend-browser {
    display: none;
  }

  .browse-header .recommend-browser,
  .browse-filters {
    display: grid;
  }

  .recommend-browser .recommend-filters,
  .browse-filters {
    width: 100%;
  }

  .browse-header {
    margin-top: 14px;
  }

  .browse-header .section-title {
    margin-bottom: 8px;
  }

  .browse-header .section-title h1 {
    font-size: 28px;
  }

  .browse-filters {
    position: sticky;
    top: 61px;
    z-index: 16;
    margin-inline: -10px;
    padding: 10px 10px 12px;
    background: rgba(8, 14, 23, 0.76);
    border-bottom: 1px solid var(--line);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
  }

  .filter-row {
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 8px;
  }

  .filter-row > span {
    padding-top: 7px;
    font-size: 12px;
  }

  .filter-tabs {
    flex-wrap: nowrap;
    gap: 7px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 2px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .filter-tabs::-webkit-scrollbar {
    display: none;
  }

  .filter-tab {
    flex: 0 0 auto;
    min-height: 32px;
    padding: 6px 11px;
    font-size: 13px;
    white-space: nowrap;
  }

  .mobile-category-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 45;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0;
    padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
    background: rgba(8, 14, 23, 0.78);
    border-top: 1px solid var(--line);
    box-shadow: 0 -18px 44px rgba(0, 0, 0, 0.34), var(--inner-glow);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
  }

  .mobile-category-link {
    display: grid;
    place-items: center;
    gap: 4px;
    min-width: 0;
    min-height: 50px;
    color: var(--muted);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 760;
  }

  .mobile-category-link.active {
    color: var(--accent-strong);
    background: rgba(138, 219, 210, 0.12);
    border-color: rgba(138, 219, 210, 0.22);
    box-shadow: var(--inner-glow);
  }

  .mobile-category-icon {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .mobile-search-panel {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(76px + env(safe-area-inset-bottom));
    z-index: 46;
    display: block;
  }

  .mobile-search-panel[hidden] {
    display: none;
  }

  .mobile-bottom-search {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding: 10px;
    background: rgba(8, 14, 23, 0.84);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow), var(--inner-glow);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
  }

  .mobile-bottom-search input {
    width: 100%;
    min-height: 42px;
    padding: 11px 12px;
    color: var(--ink);
    background: rgba(246, 250, 255, 0.075);
    border: 1px solid var(--line);
    border-radius: 8px;
  }

  .mobile-bottom-search button {
    min-height: 42px;
    padding: 0 16px;
    color: var(--accent-strong);
    background: rgba(138, 219, 210, 0.18);
    border: 1px solid rgba(215, 255, 250, 0.32);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 800;
    white-space: nowrap;
  }

  .mobile-bottom-search button:hover {
    background: rgba(138, 219, 210, 0.28);
  }

  .notice-fab {
    bottom: calc(92px + env(safe-area-inset-bottom));
  }

  .workspace,
  .detail-layout,
  .player-layout {
    grid-template-columns: 1fr;
  }

  .detail-layout {
    gap: 16px;
  }

  .poster-frame {
    width: min(240px, 70vw);
    margin: 0 auto;
  }

  .player-info {
    display: block;
  }

  .player-layout {
    display: flex;
    flex-direction: column;
    gap: 14px;
  }

  .player-main {
    display: contents;
  }

  .video-shell {
    order: 1;
  }

  .player-sidebar {
    order: 2;
    display: grid;
    gap: 0;
    width: 100%;
    overflow: hidden;
    background: rgba(8, 14, 23, 0.76);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow-soft), var(--inner-glow);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
  }

  .mobile-player-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-height: 50px;
    background: rgba(246, 250, 255, 0.058);
    border-bottom: 1px solid var(--line);
  }

  .mobile-player-tabs.single-tab {
    grid-template-columns: 1fr;
  }

  .mobile-player-tab {
    display: grid;
    place-items: center;
    min-width: 0;
    color: var(--muted);
    background: transparent;
    border: 0;
    cursor: pointer;
    font-weight: 800;
  }

  .mobile-player-tab.active {
    color: var(--accent-strong);
    background: rgba(138, 219, 210, 0.12);
  }

  .player-sidebar .panel {
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .player-sidebar .compact {
    padding: 14px 16px 18px;
  }

  .player-sidebar .panel {
    max-height: none;
    overflow: auto;
  }

  .player-sidebar .mobile-hidden {
    display: none;
  }

  .episode-panel .section-title.small {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .episode-panel .section-title.small h2 {
    display: none;
  }

  .episode-panel .section-title.small span {
    color: var(--accent-strong);
    font-size: 14px;
    font-weight: 800;
  }

  .episode-panel .section-title.small::after {
    color: var(--muted-strong);
    font-size: 18px;
    font-weight: 800;
    content: "\2195";
  }

  .prefer-panel .section-title.small h2 {
    display: none;
  }

  .prefer-panel .section-title.small {
    justify-content: center;
    margin-bottom: 12px;
  }

  .prefer-panel .section-title.small span {
    color: var(--muted-strong);
    font-weight: 800;
  }

  .player-sidebar.no-episodes .prefer-panel {
    display: block;
  }

  .player-sidebar.no-episodes .prefer-panel .section-title.small h2 {
    display: block;
  }

  .player-info {
    order: 3;
    margin-top: 0;
  }

  .player-main > .description {
    order: 4;
    margin-top: 0;
  }

  .episode-grid.side,
  .candidate-list {
    max-height: 44vh;
  }

  .episode-grid.side {
    grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
    gap: 10px;
    margin-top: 14px;
    overflow-x: hidden;
  }

  .episode-button {
    min-height: 40px;
    font-weight: 800;
  }

  .episode-button.active {
    color: var(--accent-strong);
    background: rgba(138, 219, 210, 0.18);
    border-color: rgba(138, 219, 210, 0.38);
  }
}

@media (max-width: 560px) {
  .page {
    width: min(100% - 20px, 1240px);
    padding-top: 16px;
  }

  .compact-band {
    align-items: flex-start;
    flex-direction: column;
  }

  .detail-main {
    padding: 18px;
  }

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

  .media-card {
    padding: 7px;
  }

  .player-sidebar .compact {
    padding: 14px 16px 18px;
  }

  .speed-test-button {
    min-height: 36px;
  }

  .episode-grid.side,
  .candidate-list {
    max-height: 260px;
  }

  .episode-grid.side {
    grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
    gap: 10px;
  }

  .episode-button {
    min-height: 40px;
    padding: 8px 6px;
    font-size: 13px;
  }

  .candidate {
    min-height: 50px;
    padding: 8px;
  }

  .candidate-title {
    font-size: 13px;
  }

  .candidate-metrics {
    font-size: 11px;
  }

  .player-info {
    padding: 14px;
  }

  .player-info h1 {
    font-size: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
