/* ==========================================================================
   rustAnimeX — UI/UX Prototype Stylesheet
   Light-first清爽二次元风格 + Dark Mode + Dark Theater Stage
   ========================================================================== */

:root {
  /* Palette tokens (light / dark) */
  --bg-page-light: #f8fafc;
  --bg-page-dark: #0b0f19;
  --bg-surface-light: #ffffff;
  --bg-surface-dark: #151b2b;
  --bg-subtle-light: #f1f5f9;
  --bg-subtle-dark: #1e293b;
  --bg-hover-light: #e2e8f0;
  --bg-hover-dark: #283548;

  --border-light: #e2e8f0;
  --border-dark: #242e42;

  --text-primary-light: #0f172a;
  --text-primary-dark: #f1f5f9;
  --text-secondary-light: #64748b;
  --text-secondary-dark: #94a3b8;

  --brand-primary-light: #0ea5e9;
  --brand-primary-dark: #38bdf8;
  --brand-soft-light: #e0f2fe;
  --brand-soft-dark: #0c2d48;

  --accent-anime-light: #f43f5e;
  --accent-anime-dark: #fb7185;
  --accent-soft-light: #ffe4e6;
  --accent-soft-dark: #3f1624;

  --warn-light: #f59e0b;
  --warn-dark: #fbbf24;
  --success-light: #10b981;
  --success-dark: #34d399;

  /* Default (fallback) active tokens */
  --bg-page: var(--bg-page-light);
  --bg-surface: var(--bg-surface-light);
  --bg-subtle: var(--bg-subtle-light);
  --bg-hover: var(--bg-hover-light);
  --border: var(--border-light);
  --text-primary: var(--text-primary-light);
  --text-secondary: var(--text-secondary-light);
  --brand-primary: var(--brand-primary-light);
  --brand-soft: var(--brand-soft-light);
  --accent-anime: var(--accent-anime-light);
  --accent-soft: var(--accent-soft-light);
  --warn: var(--warn-light);
  --success: var(--success-light);

  /* Theater stage tokens */
  --bg-theater: #0f1117;
  --bg-theater-panel: #171b24;
  --border-theater: #262c3a;

  /* Layout & radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --header-h: 60px;
  --mobile-nav-h: 58px;

  /* Base color-scheme stays light dark; meta tag overrides via :has() below */
  color-scheme: light dark;
  interpolate-size: allow-keywords;
}

/* Fallback for browsers without light-dark() support */
@media (prefers-color-scheme: dark) {
  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) {
    --bg-page: var(--bg-page-dark);
    --bg-surface: var(--bg-surface-dark);
    --bg-subtle: var(--bg-subtle-dark);
    --bg-hover: var(--bg-hover-dark);
    --border: var(--border-dark);
    --text-primary: var(--text-primary-dark);
    --text-secondary: var(--text-secondary-dark);
    --brand-primary: var(--brand-primary-dark);
    --brand-soft: var(--brand-soft-dark);
    --accent-anime: var(--accent-anime-dark);
    --accent-soft: var(--accent-soft-dark);
    --warn: var(--warn-dark);
    --success: var(--success-dark);
  }
}

:root:has(> head > meta[name="color-scheme"][content="dark"]) {
  color-scheme: dark;
  --bg-page: var(--bg-page-dark);
  --bg-surface: var(--bg-surface-dark);
  --bg-subtle: var(--bg-subtle-dark);
  --bg-hover: var(--bg-hover-dark);
  --border: var(--border-dark);
  --text-primary: var(--text-primary-dark);
  --text-secondary: var(--text-secondary-dark);
  --brand-primary: var(--brand-primary-dark);
  --brand-soft: var(--brand-soft-dark);
  --accent-anime: var(--accent-anime-dark);
  --accent-soft: var(--accent-soft-dark);
  --warn: var(--warn-dark);
  --success: var(--success-dark);
}

:root:has(> head > meta[name="color-scheme"][content="light"]) {
  color-scheme: light;
}

@supports (color: light-dark(white, black)) {
  :root {
    --bg-page: light-dark(var(--bg-page-light), var(--bg-page-dark));
    --bg-surface: light-dark(var(--bg-surface-light), var(--bg-surface-dark));
    --bg-subtle: light-dark(var(--bg-subtle-light), var(--bg-subtle-dark));
    --bg-hover: light-dark(var(--bg-hover-light), var(--bg-hover-dark));
    --border: light-dark(var(--border-light), var(--border-dark));
    --text-primary: light-dark(var(--text-primary-light), var(--text-primary-dark));
    --text-secondary: light-dark(var(--text-secondary-light), var(--text-secondary-dark));
    --brand-primary: light-dark(var(--brand-primary-light), var(--brand-primary-dark));
    --brand-soft: light-dark(var(--brand-soft-light), var(--brand-soft-dark));
    --accent-anime: light-dark(var(--accent-anime-light), var(--accent-anime-dark));
    --accent-soft: light-dark(var(--accent-soft-light), var(--accent-soft-dark));
    --warn: light-dark(var(--warn-light), var(--warn-dark));
    --success: light-dark(var(--success-light), var(--success-dark));
  }
}

/* Theme toggle icon visibility driven purely by CSS (matches meta + system pref) */
.theme-icon-to-dark { display: inline-flex; }
.theme-icon-to-light { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) .theme-icon-to-dark {
    display: none;
  }
  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) .theme-icon-to-light {
    display: inline-flex;
  }
}

:root:has(> head > meta[name="color-scheme"][content="dark"]) .theme-icon-to-dark {
  display: none;
}
:root:has(> head > meta[name="color-scheme"][content="dark"]) .theme-icon-to-light {
  display: inline-flex;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-family: system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background-color: var(--bg-page);
  color: var(--text-primary);
  accent-color: var(--brand-primary);
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
  overflow-y: scroll;
}

@supports (scrollbar-gutter: stable) {
  html {
    overflow-y: auto;
    scrollbar-gutter: stable;
  }
}

body {
  margin: 0;
  min-height: 100dvh;
  background-color: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.5;
  padding-bottom: 0;
}

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

button, input, select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
}

/* Guarantee HTML hidden attribute always wins over author display: flex / grid rules */
[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Containers */
.container {
  width: 100%;
  max-width: 1280px;
  margin-inline: auto;
  padding-inline: 16px;
}

.container-wide {
  width: 100%;
  max-width: 1440px;
  margin-inline: auto;
  padding-inline: 16px;
}

/* ==========================================================================
   Header Navigation
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  background: color-mix(in srgb, var(--bg-surface) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, #0ea5e9, #f43f5e);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 900;
  box-shadow: 0 3px 10px rgba(14, 165, 233, 0.28);
}

.brand-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background: var(--brand-soft);
  color: var(--brand-primary);
}

.desktop-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.nav-link {
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: background-color 0.15s, color 0.15s;
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-subtle);
}

.nav-link.active {
  color: var(--brand-primary);
  background: var(--brand-soft);
  font-weight: 600;
}

/* Search bar + Instant Suggestions */
.search-wrap {
  position: relative;
  flex: 1;
  max-width: 420px;
  margin-inline: auto;
}

.search-form {
  display: flex;
  align-items: center;
  background: var(--bg-subtle);
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  padding: 0 12px;
  height: 38px;
  transition: border-color 0.15s, background-color 0.15s;
}

.search-form:focus-within {
  background: var(--bg-surface);
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-primary) 16%, transparent);
}

.search-icon {
  color: var(--text-secondary);
  flex-shrink: 0;
  display: inline-flex;
}

.search-input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  outline: none;
  padding: 0 8px;
  font-size: 13.5px;
}

.search-kbd {
  font-size: 11px;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  border-radius: 5px;
  padding: 1px 6px;
}

.search-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 6px;
  z-index: 60;
  display: none;
}

.search-dropdown.open {
  display: block;
}

.search-suggest-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  transition: background-color 0.12s;
}

.search-suggest-item:hover {
  background: var(--bg-subtle);
}

.search-suggest-thumb {
  width: 34px;
  height: 46px;
  border-radius: 5px;
  object-fit: cover;
  flex-shrink: 0;
}

.search-suggest-meta {
  min-width: 0;
  flex: 1;
}

.search-suggest-title {
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-suggest-sub {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Header Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s, border-color 0.15s;
}

.icon-btn:hover {
  background: var(--bg-subtle);
  border-color: var(--brand-primary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  padding: 7px 16px;
  font-size: 13.5px;
  font-weight: 600;
  transition: transform 0.12s, background-color 0.15s, border-color 0.15s, opacity 0.15s;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--brand-primary);
  color: #ffffff;
}

.btn-primary:hover {
  filter: brightness(1.06);
}

.btn-accent {
  background: var(--accent-anime);
  color: #ffffff;
}

.btn-subtle {
  background: var(--bg-subtle);
  color: var(--text-primary);
  border-color: var(--border);
}

.btn-subtle:hover {
  background: var(--bg-hover);
}

.btn-sm {
  padding: 5px 12px;
  font-size: 12.5px;
}

.user-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 3px 12px 3px 4px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  font-size: 13px;
  font-weight: 600;
}

.user-pill:hover {
  border-color: var(--brand-primary);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #38bdf8, #f43f5e);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
}

.unread-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent-anime);
  border: 2px solid var(--bg-surface);
}

/* Prototype SEO Route Preview Bar */
.proto-bar {
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
}

.proto-bar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-block: 6px;
  flex-wrap: wrap;
}

.seo-url-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  color: var(--text-primary);
}

.seo-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
}

.seo-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.seo-pill {
  padding: 1px 7px;
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  font-size: 11px;
}

/* ==========================================================================
   Main Content Sections & Cards
   ========================================================================== */
.main-view {
  padding-block: 18px 48px;
}

/* Continue watching bar */
.continue-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 14px;
  margin-bottom: 16px;
  border-radius: var(--radius-md);
  background: var(--brand-soft);
  border: 1px solid color-mix(in srgb, var(--brand-primary) 26%, transparent);
  font-size: 13.5px;
}

.continue-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--brand-primary);
  min-width: 0;
}

.continue-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.continue-close {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  padding: 2px 6px;
  border-radius: 6px;
}

.continue-close:hover {
  background: color-mix(in srgb, var(--brand-primary) 14%, transparent);
}

/* Section Headers */
.section-block {
  margin-bottom: 28px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.section-title {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.section-title::before {
  content: "";
  width: 4px;
  height: 18px;
  border-radius: 4px;
  background: var(--brand-primary);
}

.section-title.accent::before {
  background: var(--accent-anime);
}

.section-more {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.section-more:hover {
  color: var(--brand-primary);
}

/* Weekday Quick Strip */
.day-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}

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

.day-pill {
  padding: 5px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: all 0.15s;
}

.day-pill:hover {
  border-color: var(--brand-primary);
  color: var(--text-primary);
}

.day-pill.active {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #ffffff;
}

.today-strip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.schedule-mini-card {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}

.schedule-mini-card:hover {
  border-color: var(--brand-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.schedule-mini-poster {
  width: 50px;
  aspect-ratio: 3 / 4;
  border-radius: 7px;
  object-fit: cover;
  flex-shrink: 0;
}

.schedule-mini-info {
  min-width: 0;
  flex: 1;
}

.schedule-mini-time {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent-anime);
}

.schedule-mini-title {
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 2px 0;
}

.schedule-mini-ep {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Anime Poster Grid (3:4 Locked Aspect Ratio -> 0 CLS) */
.anime-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 18px;
}

.anime-card {
  display: flex;
  flex-direction: column;
  transition: transform 0.18s ease;
}

.anime-card:hover {
  transform: translateY(-3px);
}

.poster-box {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.poster-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.25s ease;
}

.anime-card:hover .poster-img {
  transform: scale(1.04);
}

.badge-status {
  position: absolute;
  top: 7px;
  left: 7px;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(6px);
}

.badge-status.ongoing {
  background: color-mix(in srgb, var(--accent-anime) 92%, transparent);
}

.badge-ep {
  position: absolute;
  right: 7px;
  bottom: 7px;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: rgba(15, 23, 42, 0.74);
  backdrop-filter: blur(6px);
}

.badge-score {
  position: absolute;
  top: 7px;
  right: 7px;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  color: #fef08a;
  background: rgba(15, 23, 42, 0.72);
}

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

.card-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: color 0.15s;
}

.anime-card:hover .card-title {
  color: var(--brand-primary);
}

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

/* ==========================================================================
   Catalog Filter Panel & Pagination
   ========================================================================== */
.filter-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 20px;
}

.filter-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding-block: 7px;
  border-bottom: 1px dashed var(--border);
}

.filter-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.filter-label {
  width: 48px;
  flex-shrink: 0;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-secondary);
  padding-top: 4px;
}

.filter-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
}

.chip {
  padding: 4px 11px;
  border-radius: var(--radius-full);
  border: 1px solid transparent;
  background: transparent;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all 0.12s;
}

.chip:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.chip.active {
  background: var(--brand-soft);
  color: var(--brand-primary);
  font-weight: 600;
  border-color: color-mix(in srgb, var(--brand-primary) 30%, transparent);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 28px;
}

.page-link {
  min-width: 36px;
  height: 36px;
  padding-inline: 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.page-link:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.page-link.active {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #fff;
}

/* ==========================================================================
   Schedule Full Page
   ========================================================================== */
.schedule-sticky-bar {
  position: sticky;
  top: var(--header-h);
  z-index: 20;
  background: color-mix(in srgb, var(--bg-page) 92%, transparent);
  backdrop-filter: blur(10px);
  padding-block: 10px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.schedule-day-section {
  margin-bottom: 24px;
}

.schedule-full-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

.schedule-row-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border);
}

.schedule-row-poster {
  width: 62px;
  aspect-ratio: 3 / 4;
  border-radius: 7px;
  object-fit: cover;
  flex-shrink: 0;
}

.schedule-row-body {
  min-width: 0;
  flex: 1;
}

.schedule-row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
}

/* ==========================================================================
   Detail Page
   ========================================================================== */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.breadcrumb a:hover {
  color: var(--brand-primary);
}

.detail-hero {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 24px;
  padding: 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 22px;
}

.detail-poster {
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius-md);
  object-fit: cover;
  border: 1px solid var(--border);
}

.detail-title {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  line-height: 1.25;
}

.detail-orig {
  margin: 4px 0 12px;
  font-size: 13.5px;
  color: var(--text-secondary);
}

.meta-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 12px;
}

.meta-pill {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.meta-pill.accent {
  background: var(--accent-soft);
  color: var(--accent-anime);
}

.detail-meta-line {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 4px 0;
}

.detail-meta-line strong {
  color: var(--text-primary);
}

.detail-synopsis {
  margin: 12px 0 16px;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.65;
}

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

.two-col-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 22px;
  align-items: start;
}

.surface-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 20px;
}

/* Episode Grid */
.ep-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.ep-range-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.ep-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 8px;
}

.ep-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  padding-inline: 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  transition: all 0.14s;
  overflow: hidden;
}

.ep-btn:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
  background: var(--brand-soft);
}

.ep-btn.active {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #ffffff;
}

.ep-btn.watched {
  color: var(--text-secondary);
}

.ep-btn.watched::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: color-mix(in srgb, var(--brand-primary) 55%, transparent);
}

/* Side Recommendations */
.side-rec-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.side-rec-item {
  display: flex;
  gap: 10px;
  align-items: center;
}

.side-rec-img {
  width: 54px;
  aspect-ratio: 3 / 4;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

.side-rec-title {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.3;
}

.side-rec-item:hover .side-rec-title {
  color: var(--brand-primary);
}

.side-rec-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 3px;
}

/* ==========================================================================
   Watch Page — Dark Theater Stage (Component-Specific color-scheme)
   ========================================================================== */
.theater-stage {
  /* Force dark color-scheme for immersive video viewing even on light page */
  color-scheme: only dark;
  background: var(--bg-theater);
  /* Mandatory re-specification of inherited color properties */
  color: #f1f5f9;
  accent-color: #38bdf8;
  padding-block: 16px 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-theater);
}

.theater-stage.lights-off {
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.88);
  position: relative;
  z-index: 50;
}

.theater-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
  align-items: stretch;
}

.player-column {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.player-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  overflow: hidden;
  background: #05070c;
  border: 1px solid var(--border-theater);
  border-bottom: 0;
  user-select: none;
}

.player-scene {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 24% 28%, rgba(56, 189, 248, 0.25), transparent 46%),
    radial-gradient(circle at 76% 68%, rgba(244, 63, 94, 0.22), transparent 50%),
    linear-gradient(160deg, #0b1220 0%, #111827 55%, #090d16 100%);
}

.player-scene-badge {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.1);
  color: #bae6fd;
  margin-bottom: 10px;
}

.player-scene-title {
  font-size: 20px;
  font-weight: 800;
  text-align: center;
  padding-inline: 16px;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.65);
}

.player-scene-sub {
  margin-top: 6px;
  font-size: 13px;
  color: #94a3b8;
}

/* Subtitle area (bottom safe zone protected from danmaku) */
.player-subtitle {
  position: absolute;
  left: 50%;
  bottom: 58px;
  transform: translateX(-50%);
  padding: 4px 12px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.56);
  color: #ffffff;
  font-size: 15px;
  font-weight: 600;
  text-shadow: 0 1px 3px #000;
  white-space: nowrap;
  pointer-events: none;
  z-index: 6;
}

/* Danmaku overlay (Top 50% safe zone!) */
.danmaku-layer {
  position: absolute;
  top: 10px;
  left: 0;
  right: 0;
  height: 50%;
  overflow: hidden;
  pointer-events: none;
  z-index: 5;
}

.danmaku-item {
  position: absolute;
  left: 100%;
  white-space: nowrap;
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.9), 0 0 4px rgba(0, 0, 0, 0.8);
  will-change: transform;
  animation: danmaku-scroll linear forwards;
}

.danmaku-item.mine {
  border: 1px solid #38bdf8;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(14, 165, 233, 0.25);
}

@keyframes danmaku-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-1600px); }
}

/* Source Error Fallback Overlay */
.player-fallback-overlay {
  position: absolute;
  inset: 0;
  z-index: 12;
  background: rgba(5, 7, 12, 0.86);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.player-fallback-overlay.open {
  display: flex;
}

.fallback-box {
  max-width: 390px;
  width: 100%;
  background: #171b24;
  border: 1px solid #334155;
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
}

.fallback-title {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 700;
  color: #fbbf24;
}

.fallback-desc {
  margin: 0 0 14px;
  font-size: 13px;
  color: #cbd5e1;
}

.fallback-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Player Controls */
.player-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  padding: 10px 14px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.88), transparent);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.progress-range {
  flex: 1;
  height: 4px;
  cursor: pointer;
}

.controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
}

.controls-left, .controls-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ctrl-btn {
  border: 0;
  background: rgba(255, 255, 255, 0.1);
  color: #f8fafc;
  border-radius: 6px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 600;
}

.ctrl-btn:hover {
  background: rgba(56, 189, 248, 0.28);
}

.ctrl-btn.active {
  background: #0ea5e9;
  color: #fff;
}

/* Danmaku Input Bar directly below Player */
.danmaku-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  background: var(--bg-theater-panel);
  border: 1px solid var(--border-theater);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  flex-wrap: wrap;
}

.danmaku-stat {
  font-size: 12px;
  color: #94a3b8;
  white-space: nowrap;
}

.danmaku-input-wrap {
  flex: 1;
  min-width: 180px;
  display: flex;
  align-items: center;
  background: #0b0f19;
  border: 1px solid #2d3748;
  border-radius: var(--radius-full);
  padding: 2px 4px 2px 12px;
}

.danmaku-input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: #f8fafc;
  outline: none;
  font-size: 13px;
}

.danmaku-color-select {
  border: 0;
  background: transparent;
  color: #cbd5e1;
  font-size: 12px;
  margin-right: 4px;
}

/* Right Episode + Source Sidebar inside Dark Stage */
.theater-sidebar {
  background: var(--bg-theater-panel);
  border: 1px solid var(--border-theater);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  max-height: 560px;
  overflow: hidden;
}

.source-section-label {
  font-size: 11.5px;
  font-weight: 700;
  color: #94a3b8;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.source-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-theater);
}

.source-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 7px;
  border: 1px solid #2f384b;
  background: #0f131d;
  color: #cbd5e1;
  font-size: 12px;
  font-weight: 600;
}

.source-pill:hover {
  border-color: #38bdf8;
  color: #fff;
}

.source-pill.active {
  background: #0ea5e9;
  border-color: #0ea5e9;
  color: #fff;
}

.source-pill.broken {
  opacity: 0.7;
  border-style: dashed;
}

.source-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #34d399;
}

.source-pill.broken .source-dot {
  background: #f59e0b;
}

.theater-ep-scroll {
  overflow-y: auto;
  flex: 1;
  padding-right: 4px;
}

.theater-ep-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.theater-ep-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  border-radius: 6px;
  border: 1px solid #2b3344;
  background: #10141f;
  color: #cbd5e1;
  font-size: 12.5px;
  font-weight: 600;
}

.theater-ep-btn:hover {
  border-color: #38bdf8;
  color: #fff;
}

.theater-ep-btn.active {
  background: #0ea5e9;
  border-color: #0ea5e9;
  color: #fff;
}

/* Watch action bar below theater */
.watch-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.watch-title {
  margin: 0;
  font-size: 21px;
  font-weight: 800;
}

/* ==========================================================================
   Comments & Spoiler Protection
   ========================================================================== */
.comment-composer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}

.comment-textarea {
  width: 100%;
  min-height: 78px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-primary);
  resize: vertical;
  outline: none;
  font: inherit;
  font-size: 13.5px;
}

.comment-textarea:focus {
  border-color: var(--brand-primary);
  background: var(--bg-surface);
}

.comment-composer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.comment-item {
  display: flex;
  gap: 11px;
  padding-block: 14px;
  border-top: 1px solid var(--border);
}

.comment-body {
  min-width: 0;
  flex: 1;
}

.comment-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.comment-author {
  font-weight: 700;
}

.comment-time {
  font-size: 12px;
  color: var(--text-secondary);
}

.comment-text {
  margin: 6px 0 8px;
  font-size: 14px;
  line-height: 1.6;
}

.spoiler-chip {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 5px;
  background: var(--text-primary);
  color: transparent;
  cursor: pointer;
  user-select: none;
  transition: all 0.18s;
}

.spoiler-chip.revealed {
  background: var(--accent-soft);
  color: var(--text-primary);
  user-select: text;
}

.comment-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
  color: var(--text-secondary);
}

.comment-act-btn {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.comment-act-btn:hover, .comment-act-btn.liked {
  color: var(--accent-anime);
}

/* ==========================================================================
   User Center
   ========================================================================== */
.user-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}

.user-tab {
  border: 0;
  background: transparent;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
}

.user-tab.active {
  color: var(--brand-primary);
  border-bottom-color: var(--brand-primary);
}

.history-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

/* ==========================================================================
   Native Modal Dialog (light-dismiss closedby="any")
   ========================================================================== */
dialog.auth-dialog {
  width: min(400px, calc(100vw - 28px));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
}

dialog.auth-dialog::backdrop {
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.dialog-title {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}

.form-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-input {
  height: 38px;
  padding: 0 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  outline: none;
}

.form-input:focus {
  border-color: var(--brand-primary);
  background: var(--bg-surface);
}

/* Toast Notification */
.toast-container {
  position: fixed;
  right: 16px;
  bottom: 20px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 10px 15px;
  border-radius: var(--radius-md);
  background: #0f172a;
  color: #f8fafc;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  border: 1px solid #334155;
  animation: toast-in 0.2s ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Hero Carousel Slideshow (Native Scroll Snap + Continuous CSS Order Looping)
   ========================================================================== */
.hero-carousel {
  position: relative;
  margin-bottom: 24px;
}

.hero-carousel-viewport {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  background: #0b1220;
}

.carousel-controls {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-inline: 12px;
  pointer-events: none;
}

.carousel-ctrl-btn {
  pointer-events: auto;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(15, 23, 42, 0.68);
  color: #ffffff;
  backdrop-filter: blur(8px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  transition: background-color 0.16s, border-color 0.16s, transform 0.14s;
}

.carousel-ctrl-btn:hover {
  background: rgba(14, 165, 233, 0.9);
  border-color: #ffffff;
  transform: scale(1.05);
}

.carousel-ctrl-btn:focus-visible,
.carousel-markers button:focus-visible,
.carousel-autoplay-btn:focus-visible,
.carousel-track:focus-visible {
  outline: 2.5px solid #38bdf8;
  outline-offset: 2px;
}

.carousel-track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  touch-action: manipulation;
  scrollbar-width: none;
}

.carousel-track::-webkit-scrollbar {
  display: none;
}

@media (prefers-reduced-motion: no-preference) {
  .carousel-track {
    scroll-behavior: smooth;
  }
}

.carousel-track > .hero-slide {
  flex: 0 0 100%;
  scroll-snap-align: center;
  position: relative;
  min-height: 360px;
  height: clamp(290px, 34vw, 410px);
  display: flex;
  align-items: flex-end;
  color: #ffffff;
  overflow: hidden;
}

/* Continuous looping: park end slides beside current slide without cloning DOM */
.hero-carousel .carousel-track > :first-child {
  order: clamp(0, var(--current) - (var(--children-count, sibling-count()) - 3), 1);
}

.hero-carousel .carousel-track > :last-child {
  order: calc(-1 * clamp(0, 2 - var(--current), 1));
}

.hero-slide-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
}

.hero-slide-scrim {
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(96deg, rgba(9, 13, 24, 0.9) 0%, rgba(9, 13, 24, 0.62) 48%, rgba(9, 13, 24, 0.14) 100%),
    linear-gradient(to top, rgba(9, 13, 24, 0.78) 0%, transparent 45%);
}

.hero-slide-content {
  position: relative;
  z-index: 2;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 66px 32px;
}

.hero-slide-info {
  max-width: 580px;
  min-width: 0;
}

.hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 700;
}

.hero-kicker-badge {
  padding: 3px 9px;
  border-radius: var(--radius-full);
  background: var(--accent-anime-light);
  color: #ffffff;
}

.hero-kicker-score {
  padding: 3px 9px;
  border-radius: var(--radius-full);
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fef08a;
}

.hero-slide-title {
  margin: 0;
  font-size: clamp(22px, 3vw, 34px);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.015em;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.45);
}

.hero-slide-meta {
  margin: 7px 0 10px;
  font-size: 13px;
  color: #cbd5e1;
}

.hero-slide-desc {
  margin: 0 0 16px;
  font-size: 13.5px;
  line-height: 1.6;
  color: #e2e8f0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hero-slide-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.hero-btn-ghost {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(8px);
}

.hero-btn-ghost:hover {
  background: rgba(255, 255, 255, 0.24);
}

.hero-slide-poster-float {
  width: 146px;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius-md);
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.48);
  flex-shrink: 0;
  transform: rotate(2deg);
}

/* Marker Bar & Autoplay Control */
.hero-carousel-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
}

.carousel-markers {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

/* >= 24x24px accessible hit target via transparent border + background-clip */
.carousel-markers button {
  position: relative;
  min-width: 24px;
  min-height: 24px;
  padding: 0;
  border: 7px solid transparent;
  background-clip: padding-box;
  background-color: color-mix(in srgb, var(--text-secondary) 45%, transparent);
  border-radius: var(--radius-full);
  transition: min-width 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
  touch-action: manipulation;
}

.carousel-markers button:hover {
  background-color: var(--text-primary);
}

/* Active state uses size expansion + border ring (not color alone - WCAG 1.4.1) */
.carousel-markers button[aria-current="true"] {
  min-width: 42px;
  background-color: var(--brand-primary);
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.75);
}

.carousel-autoplay-btn {
  height: 26px;
  padding-inline: 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  touch-action: manipulation;
}

.carousel-autoplay-btn:hover {
  border-color: var(--brand-primary);
  color: var(--text-primary);
}

/* ==========================================================================
   Mobile Bottom Tab Bar & Responsive Breakpoints
   ========================================================================== */
.mobile-bottom-nav {
  display: none;
}

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
  padding-block: 24px;
  font-size: 12.5px;
  color: var(--text-secondary);
}

@media (max-width: 1279px) {
  .anime-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 16px;
  }
}

@media (max-width: 1023px) {
  .anime-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
  }
  .theater-grid {
    grid-template-columns: 1fr;
  }
  .theater-sidebar {
    max-height: 300px;
  }
  .two-col-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 767px) {
  :root {
    --header-h: 54px;
  }
  .carousel-track > .hero-slide {
    min-height: 260px;
    height: 276px;
  }
  .hero-slide-content {
    padding: 18px 46px 20px;
  }
  .hero-slide-poster-float,
  .hero-slide-desc {
    display: none;
  }
  .carousel-controls {
    padding-inline: 6px;
  }
  .carousel-ctrl-btn {
    width: 34px;
    height: 34px;
  }
  body {
    padding-bottom: calc(var(--mobile-nav-h) + env(safe-area-inset-bottom, 0px));
  }
  .desktop-nav, .brand-tag, .search-kbd, .header-login-text {
    display: none;
  }
  .anime-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
  }
  .detail-hero {
    grid-template-columns: 112px 1fr;
    gap: 14px;
    padding: 14px;
  }
  .detail-title {
    font-size: 18px;
  }
  .theater-stage {
    padding-top: 0;
  }
  .theater-stage .container-wide {
    padding-inline: 0;
  }
  .player-frame {
    border-radius: 0;
    border-inline: 0;
    position: sticky;
    top: var(--header-h);
    z-index: 25;
  }
  .danmaku-bar {
    border-radius: 0;
    border-inline: 0;
  }
  .theater-sidebar {
    margin-inline: 12px;
  }
  .toast-container {
    bottom: calc(var(--mobile-nav-h) + 12px);
    left: 12px;
    right: 12px;
  }
  .mobile-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 45;
    height: calc(var(--mobile-nav-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: color-mix(in srgb, var(--bg-surface) 94%, transparent);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
  }
  .mobile-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
  }
  .mobile-tab.active {
    color: var(--brand-primary);
  }
}

@media (max-width: 359px) {
  .anime-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.real-video-el { position: absolute; inset: 0; width: 100%; height: 100%; background: #000; object-fit: contain; z-index: 2; }

/* ==========================================================================
   shadcn/ui-inspired Select Component
   Modern CSS Customizable <select> (appearance: base-select) + Popover Fallback
   ========================================================================== */
.shadcn-select,
.shadcn-select::picker(select) {
  appearance: base-select;
}

.shadcn-select {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background-color: var(--bg-surface);
  color: var(--text-primary);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.4;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  cursor: pointer;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

.shadcn-select:hover {
  background-color: var(--bg-subtle);
}

.shadcn-select:focus-visible {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-primary) 18%, transparent);
}

.shadcn-select > button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  background: transparent;
  border: 0;
  padding: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: inherit;
}

.shadcn-select selectedcontent {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shadcn-select::picker-icon {
  color: var(--text-secondary);
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.shadcn-select:open::picker-icon {
  transform: rotate(180deg);
}

/* Picker popover styled like shadcn SelectContent (no overflow: hidden so tall lists remain scrollable) */
.shadcn-select::picker(select) {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px -4px rgba(15, 23, 42, 0.16), 0 4px 10px -2px rgba(15, 23, 42, 0.08);
  padding: 4px;
  margin-block: 5px;
  min-width: anchor-size(width);
  max-block-size: min(280px, 50vh);

  transition:
    display 0.18s ease,
    overlay 0.18s ease,
    opacity 0.18s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  transition-behavior: allow-discrete;
  opacity: 0;
  transform: translateY(-4px) scale(0.98);
}

.shadcn-select:open::picker(select) {
  opacity: 1;
  transform: translateY(0) scale(1);
}

@starting-style {
  .shadcn-select:open::picker(select) {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }
}

.shadcn-select option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 13.5px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background-color 0.12s ease;
}

.shadcn-select option:hover,
.shadcn-select option:focus-visible {
  background-color: var(--bg-subtle);
  outline: none;
}

/* Checked state: background + bold + checkmark (not color alone) */
.shadcn-select option:checked {
  font-weight: 600;
  background-color: var(--brand-soft);
  color: var(--text-primary);
}

.shadcn-select option::checkmark {
  order: 1;
  margin-inline-start: auto;
  color: var(--brand-primary);
  font-weight: 700;
}

/* Compact dark variant inside theater danmaku bar */
.shadcn-select.shadcn-select-compact {
  width: auto;
  min-width: 88px;
  min-height: 30px;
  padding: 0 9px;
  border-radius: var(--radius-full);
  border-color: #2d3748;
  background-color: #151b2b;
  color: #f1f5f9;
  font-size: 12.5px;
  margin-right: 4px;
}

.shadcn-select.shadcn-select-compact:hover {
  background-color: #1e293b;
}

.shadcn-select.shadcn-select-compact::picker(select) {
  background-color: #151b2b;
  color: #f1f5f9;
  border-color: #334155;
  min-width: 120px;
}

.shadcn-select.shadcn-select-compact option {
  color: #f1f5f9;
}

.shadcn-select.shadcn-select-compact option:hover,
.shadcn-select.shadcn-select-compact option:focus-visible {
  background-color: #1e293b;
}

.shadcn-select.shadcn-select-compact option:checked {
  background-color: #0c2d48;
  color: #f8fafc;
}

.color-dot-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(148, 163, 184, 0.55);
  flex-shrink: 0;
}

/* Fallback shadcn Select Popover (used automatically when appearance: base-select is unsupported, e.g. Firefox) */
.shadcn-fb-wrap {
  position: relative;
  width: 100%;
}

.shadcn-fb-wrap.compact {
  width: auto;
  margin-right: 4px;
}

.shadcn-fb-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.shadcn-fb-wrap.compact .shadcn-fb-trigger {
  min-height: 30px;
  min-width: 84px;
  padding: 0 10px;
  border-radius: var(--radius-full);
  border-color: #2d3748;
  background: #151b2b;
  color: #f1f5f9;
  font-size: 12.5px;
}

.shadcn-fb-chevron {
  color: var(--text-secondary);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.shadcn-fb-wrap.open .shadcn-fb-chevron {
  transform: rotate(180deg);
}

.shadcn-fb-menu {
  position: absolute;
  left: 0;
  top: calc(100% + 5px);
  min-width: 100%;
  max-height: 260px;
  overflow-y: auto;
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: 0 12px 32px -4px rgba(15, 23, 42, 0.18);
  z-index: 90;
  display: none;
}

.shadcn-fb-wrap.compact .shadcn-fb-menu {
  background: #151b2b;
  color: #f1f5f9;
  border-color: #334155;
  min-width: 124px;
  top: auto;
  bottom: calc(100% + 6px);
}

.shadcn-fb-wrap.open .shadcn-fb-menu {
  display: block;
}

.shadcn-fb-opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 13.5px;
  text-align: left;
}

.shadcn-fb-opt:hover {
  background: var(--bg-subtle);
}

.shadcn-fb-wrap.compact .shadcn-fb-opt:hover {
  background: #1e293b;
}

.shadcn-fb-opt[aria-selected="true"] {
  font-weight: 600;
  background: var(--brand-soft);
}

.shadcn-fb-wrap.compact .shadcn-fb-opt[aria-selected="true"] {
  background: #0c2d48;
}

@media (prefers-reduced-motion: reduce) {
  .shadcn-select::picker(select),
  .shadcn-select::picker-icon,
  .shadcn-fb-chevron {
    transition: none !important;
  }
}


