/* ============================================================
   Kitsuya — design system v3
   Kitsune brand: deep black · vermillion red accent · sharp corners
   ============================================================ */

:root {
  /* ---- surfaces (design spec) ---- */
  --bg: #0B0C10;
  --surface: #121318;
  --surface-2: #1A1C23;
  --surface-3: #252830;

  /* ---- borders ---- */
  --bd: #1F2430;
  --bd2: #323846;

  /* ---- text ---- */
  --paper: #F3F4F6;
  --muted-d: #9CA3AF;
  --muted-2: #4B5563;

  /* ---- brand (kitsune vermillion, matches logo) ---- */
  --accent: #E63946;
  --accent-dk: #C42D39;
  --accent-light: #FF6B73;
  --gold: #F59E0B;
  --mint: #10B981;
  --lavender: #8B5CF6;
  --coral: #F97316;

  /* ---- semantic ---- */
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --info: #3B82F6;

  /* ---- type (design spec) ---- */
  --font-display: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", monospace;
  --font-jp: "Shippori Mincho", serif;
  --font-logo: "Zen Dots", cursive;

  /* ---- layout ---- */
  --sidebar-w: 256px;
  --topbar-h: 64px;
  --main-pad-x: 24px;

  /* ---- shadows (minimal, crisp) ---- */
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.22);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.28);

  /* ---- legacy aliases (kept so existing views resolve) ---- */
  --bg-app: var(--bg);
  --bg-sidebar: var(--bg);
  --bg-surface: var(--surface);
  --bg-surface-2: var(--surface-2);
  --bg-elevated: var(--surface-3);
  --bg-input: var(--surface);
  --border: var(--bd);
  --border-strong: var(--bd2);
  --text-primary: var(--paper);
  --text-secondary: var(--muted-d);
  --text-muted: var(--muted-2);
  --brand-yellow: var(--accent);
  --brand-yellow-hover: var(--accent-dk);
  --brand-yellow-pressed: #A3242F;
  --radius: 8px;
  --radius-sm: 4px;
  --radius-lg: 12px;
  --font: var(--font-sans);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--paper);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }

h1, h2, h3, h4 {
  margin: 0 0 .5em;
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.15;
}
h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); }
h2 { font-size: clamp(1.3rem, 2.5vw, 1.6rem); }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
.muted { color: var(--muted-d); }
.small { font-size: 0.85rem; }

/* scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--bd); }
::-webkit-scrollbar-thumb:hover { background: var(--bd2); }
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* ============================================================
   Application shell — sidebar + content column
   ============================================================ */

.shell { display: flex; min-height: 100vh; }

/* ---------- sidebar (off-canvas on mobile, sticky on lg) ---------- */

.sidebar {
  position: fixed;
  top: 0; bottom: 0; left: 0;
  width: var(--sidebar-w);
  z-index: 60;
  background: var(--bg);
  border-right: 1px solid var(--bd);
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
}
.sidebar.sidebar-open { transform: translateX(0); }

.sidebar .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px;
  border-bottom: 1px solid var(--bd);
  flex-shrink: 0;
}
.logo-mark {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  color: var(--accent);
  border-radius: 5px;
  flex-shrink: 0;
}
.logo .wordmark {
  font-family: var(--font-logo);
  font-weight: 800;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--paper);
  white-space: nowrap;
}
.logo .logo-jp {
  font-family: var(--font-jp);
  font-size: 10px;
  color: var(--muted-d);
  margin-top: 3px;
}
.logo-close {
  margin-left: auto;
  width: 28px; height: 28px;
  border: 1px solid var(--bd);
  background: transparent;
  color: var(--muted-d);
  display: grid; place-items: center;
  border-radius: 5px;
}
.logo-close:hover { color: var(--paper); border-color: var(--bd2); }

.side-scroll { flex: 1; overflow-y: auto; padding: 16px 12px; }

.side-label {
  padding: 0 12px 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted-2);
}
.side-label .jp { font-family: var(--font-jp); letter-spacing: 0.02em; }
.side-nav { display: flex; flex-direction: column; gap: 2px; margin-bottom: 20px; }
.side-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-left: 2px solid transparent;
  color: var(--muted-d);
  font-size: 14px; font-weight: 500;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  white-space: nowrap;
}
.side-link svg { width: 16px; height: 16px; flex-shrink: 0; }
.side-link:hover { background: var(--surface); color: var(--paper); }
.side-link.active {
  background: var(--surface);
  color: var(--paper);
  border-left-color: var(--accent);
}
.side-link.active svg { color: var(--accent); }
.side-link.active .side-lbl { color: var(--paper); }

.side-divider { border: none; border-top: 1px solid var(--bd); margin: 8px 12px; }

.genre-links { display: flex; flex-direction: column; gap: 0; margin-bottom: 20px; }
.genre-links a {
  display: block;
  position: relative;
  padding: 7px 12px 7px 16px;
  color: var(--muted-d);
  font-size: 14px;
  font-weight: 500;
  transition: color 0.2s, padding-left 0.2s, background 0.2s;
  white-space: nowrap;
}
.genre-links a:hover {
  color: var(--paper);
  padding-left: 20px;
  background: var(--surface);
}
.genre-links a:hover::before {
  content: '';
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 4px; height: 4px;
  background: var(--accent);
}

/* sidebar stat card */
.side-stats { margin: 0 4px 16px; }
.side-stat-card {
  background: var(--surface);
  border: 1px solid var(--bd);
  padding: 12px 14px;
}
.side-stat-card .ss-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted-2);
}
.side-stat-card .ss-value {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--paper);
}
.side-stat-card .ss-value span { color: var(--muted-2); font-size: 0.8rem; }
.side-stat-card .ss-sub { color: var(--muted-d); font-size: 12px; margin-top: 4px; }

/* premium promo */
.premium-card { padding: 12px; border-top: 1px solid var(--bd); flex-shrink: 0; }
.premium-inner {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--bd);
  padding: 16px;
  overflow: hidden;
}
.premium-inner .asanoha-bg {
  position: absolute; top: 0; right: 0;
  width: 64px; height: 64px;
  opacity: 0.3;
  pointer-events: none;
}
.premium-inner > .relative { position: relative; }
.premium-tag {
  display: inline-block;
  background: var(--gold);
  color: var(--bg);
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}
.premium-card .p-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1rem;
  color: var(--paper);
  margin-bottom: 4px;
}
.premium-card .p-copy {
  color: var(--muted-d);
  font-size: 12px;
  line-height: 1.55;
  margin-bottom: 12px;
}
.premium-card .btn { width: 100%; }

/* ---------- sidebar overlay (mobile) ---------- */
.sidebar-overlay {
  position: fixed; inset: 0; z-index: 55;
  background: rgba(11, 12, 16, 0.8);
  display: none;
}
.sidebar-overlay.open { display: block; }

/* ---------- content column ---------- */
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ============================================================
   Top utility bar
   ============================================================ */

.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  background: rgba(11, 12, 16, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--bd);
}
@media (min-width: 1024px) { .topbar { padding: 0 32px; } }

.hamburger {
  width: 36px; height: 36px;
  border: 1px solid var(--bd);
  background: transparent;
  color: var(--muted-d);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.hamburger:hover { color: var(--paper); border-color: var(--bd2); }
@media (min-width: 1024px) { .hamburger { display: none; } }

.topbar .search-box { flex: 1; max-width: 560px; position: relative; display: flex; align-items: center; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* ---------- search ---------- */
.search-box input {
  width: 100%;
  padding: 9px 46px 9px 38px;
  border: 1px solid var(--bd);
  background: var(--surface);
  color: var(--paper);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}
.search-box input::placeholder { color: var(--muted-2); }
.search-box input:hover { border-color: var(--bd2); }
.search-box input:focus { border-color: var(--accent); }
.search-box .icon {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  color: var(--muted-d);
  display: grid; place-items: center;
  pointer-events: none;
}
.search-box .kbd {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted-d);
  border: 1px solid var(--bd);
  padding: 2px 6px;
  pointer-events: none;
}
@media (max-width: 639px) { .search-box .kbd { display: none; } }

.suggestions {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 70;
  background: var(--surface);
  border: 1px solid var(--bd);
  box-shadow: var(--shadow-md);
  overflow: hidden; display: none;
}
.suggestions.open { display: block; }
.suggestion { display: flex; gap: 12px; align-items: center; padding: 9px 12px; transition: background 0.12s; }
.suggestion:hover { background: var(--surface-2); }
.suggestion img { width: 56px; height: 36px; object-fit: cover; flex-shrink: 0; }
.suggestion .s-title { font-weight: 600; font-size: 14px; color: var(--paper); }
.suggestion .s-meta { font-size: 12px; color: var(--muted-d); }

/* ---------- avatar ---------- */
.avatar {
  width: 36px; height: 36px;
  background: var(--gold);
  color: var(--bg);
  font-weight: 800; font-size: 14px;
  display: grid; place-items: center;
  overflow: hidden;
  flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.icon-btn {
  width: 36px; height: 36px;
  display: inline-grid; place-items: center;
  border: 1px solid var(--bd);
  background: transparent;
  color: var(--muted-d);
  position: relative;
  transition: background 0.16s, color 0.16s, border-color 0.16s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--paper); border-color: var(--bd2); }
.icon-btn .dot {
  position: absolute; top: 8px; right: 8px;
  width: 6px; height: 6px;
  background: var(--accent);
}

/* live dot pulse */
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}
.live-dot { width: 8px; height: 8px; background: var(--accent); border-radius: 50%; display: inline-block; animation: pulse-dot 1.5s ease-in-out infinite; }

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px;
  border: 1px solid var(--bd2);
  background: var(--surface-2);
  color: var(--paper);
  font-weight: 700; font-size: 14px;
  border-radius: 5px;
  transition: background-color 0.16s, border-color 0.16s, color 0.16s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-dk); border-color: var(--accent-dk); }
.btn-primary:active { background: var(--brand-yellow-pressed); }

.btn-secondary { background: transparent; border-color: var(--bd2); color: var(--paper); }
.btn-secondary:hover { background: var(--surface-2); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--muted-d); }
.btn-ghost:hover { background: var(--surface-2); color: var(--paper); }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 14px; font-weight: 700; }

.btn-danger { background: rgba(230, 57, 70, 0.12); border-color: rgba(230, 57, 70, 0.4); color: #f08090; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }

/* ============================================================
   Asanoha pattern (SVG diamond grid)
   ============================================================ */
.asanoha-bg {
  background-image: url("data:image/svg+xml,%3Csvg width='30' height='30' viewBox='0 0 30 30' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M15 0L30 15L15 30L0 15Z' fill='none' stroke='%232A2538' stroke-width='0.5'/%3E%3C/svg%3E");
}

/* ============================================================
   Hero / featured banner
   ============================================================ */

.hero {
  position: relative;
  height: 460px;
  overflow: hidden;
  background: var(--bg);
  border-bottom: 1px solid var(--bd);
}
@media (min-width: 1024px) { .hero { height: 540px; } }

.hero-slide { position: absolute; inset: 0; }
.hero-bg { position: absolute; inset: 0; background-size: cover; background-position: center; }
.hero-overlay {
  position: absolute; inset: 0;
  background: rgba(11, 12, 16, 0.8);
}
.hero-pattern {
  position: absolute; inset: 0;
  opacity: 0.3;
  pointer-events: none;
}

/* sakura petals */
@keyframes petal-fall {
  0% { transform: translate(0, -10vh) rotate(0deg); opacity: 0; }
  10% { opacity: 0.7; }
  90% { opacity: 0.7; }
  100% { transform: translate(60px, 110vh) rotate(720deg); opacity: 0; }
}
.petal {
  position: absolute; top: 0;
  pointer-events: none;
  animation: petal-fall 18s linear infinite;
  z-index: 2;
}

.hero-content {
  position: relative; z-index: 3;
  height: 100%;
  display: flex; flex-direction: column; justify-content: flex-end;
  max-width: 720px;
  padding: 24px;
}
@media (min-width: 640px) { .hero-content { padding: 40px; } }

.hero-badges { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
.hero-badge {
  background: var(--mint);
  color: var(--bg);
  padding: 3px 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.hero-badge.rose { background: var(--accent); color: #fff; }
.hero-badge.ghost { background: transparent; border: 1px solid var(--bd2); color: var(--muted-d); }
.hero-jp { font-family: var(--font-jp); font-size: 14px; color: var(--gold); }
.hero-onair { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 11px; color: var(--accent); font-weight: 700; }

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 7vw, 4.4rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 0.9;
  color: var(--paper);
  margin: 0 0 12px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.hero-subtitle {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--muted-d);
  margin-bottom: 10px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.hero-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  color: var(--muted-d);
  font-size: 13.5px;
  margin-bottom: 10px;
}
.hero-meta .sep { color: var(--muted-2); }
.hero-meta .gold { color: var(--gold); font-weight: 800; display: inline-flex; align-items: center; gap: 4px; }

.hero-desc {
  color: var(--muted-d);
  font-size: 14px;
  line-height: 1.6;
  max-width: 520px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  margin: 0 0 18px;
}
@media (min-width: 1024px) { .hero-desc { font-size: 15px; } }

.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.hero-actions .btn { padding: 12px 22px; }

/* prev/next arrows */
.hero-arrow {
  position: absolute; top: 50%; transform: translateY(-50%);
  z-index: 5;
  width: 40px; height: 40px;
  border: 1px solid var(--bd2);
  background: rgba(21, 19, 28, 0.85);
  color: var(--paper);
  display: grid; place-items: center;
  transition: background 0.16s, border-color 0.16s;
}
.hero-arrow:hover { background: var(--surface-3); border-color: var(--bd2); }
.hero-arrow.prev { left: 14px; }
.hero-arrow.next { right: 14px; }
@media (max-width: 767px) { .hero-arrow { display: none; } }

/* indicator dots — bottom right, square */
.hero-dots {
  position: absolute; right: 24px; bottom: 20px; z-index: 5;
  display: flex; gap: 8px;
}
@media (min-width: 1024px) { .hero-dots { right: 40px; } }
.hero-dot {
  width: 8px; height: 8px;
  background: var(--bd2);
  border: none; padding: 0;
  transition: background 0.16s, transform 0.16s;
}
.hero-dot.active { background: var(--accent); }
.hero-dot:hover { background: var(--muted-d); }
@media (max-width: 767px) { .hero-dots { display: none; } }

/* ============================================================
   Content sections
   ============================================================ */

.section { margin: 28px 0; }
.container { width: min(1280px, 100%); margin-inline: auto; padding: 0 16px; }
@media (min-width: 1024px) { .container { padding: 0 32px; } }

.section-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.section-head h2 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.3rem, 2.5vw, 1.55rem);
  color: var(--paper);
  margin: 0;
}
.section-head .section-mark::before {
  content: '';
  display: inline-block;
  width: 24px; height: 1px;
  background: var(--accent);
  margin-right: 10px;
  vertical-align: middle;
}
.section-head .sec-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted-d);
  margin: 4px 0 0 34px;
}
.section-head .head-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.view-all {
  color: var(--muted-d);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  transition: color 0.16s;
  white-space: nowrap;
}
.view-all:hover { color: var(--paper); }
.view-all .va-arrow { display: inline-block; transition: transform 0.16s; }
.view-all:hover .va-arrow { transform: translateX(3px); }
@media (max-width: 639px) { .view-all { display: none; } }

/* carousel nav buttons (square, in section head) */
.carousel-nav { display: flex; gap: 8px; }
.carousel-btn {
  width: 36px; height: 36px;
  border: 1px solid var(--bd);
  background: transparent;
  color: var(--muted-d);
  display: grid; place-items: center;
  border-radius: 5px;
  transition: background 0.16s, color 0.16s, border-color 0.16s;
}
.carousel-btn:hover { background: var(--surface-2); color: var(--paper); border-color: var(--bd2); }
.carousel-btn[hidden] { display: none; }

/* ---------- horizontal rows ---------- */
.carousel { position: relative; min-width: 0; }
.row {
  display: flex; gap: 12px;
  overflow-x: auto;
  padding: 2px 16px 14px;
  margin: 0 -16px;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  scrollbar-color: var(--bd) transparent;
}
@media (min-width: 1024px) {
  .row { padding: 2px 32px 14px; margin: 0 -32px; }
}
.row::-webkit-scrollbar { height: 6px; }
.row::-webkit-scrollbar-thumb { background: var(--bd); }
.row::-webkit-scrollbar-track { background: transparent; }
.row > * { scroll-snap-align: start; flex: 0 0 auto; }
.row-card { width: 170px; }
@media (min-width: 640px) { .row-card { width: 190px; } }

/* ============================================================
   Anime cards — portrait 3:4
   ============================================================ */

.card {
  position: relative;
  display: block;
  background: var(--surface);
  border: 1px solid var(--bd);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.3s;
  overflow: hidden;
}
.card:hover { transform: translateY(-4px); border-color: var(--accent); }
.card:hover .poster-img { transform: scale(1.08); }
.poster-img { transition: transform 0.4s; }
.card:hover .play-overlay { opacity: 1; }
.play-overlay {
  position: absolute; inset: 0; z-index: 5;
  display: flex; align-items: center; justify-content: center;
  background: rgba(11, 12, 16, 0.5);
  opacity: 0;
  transition: opacity 0.25s;
}
.play-overlay .play-btn {
  width: 44px; height: 44px;
  background: var(--accent);
  color: #fff;
  display: grid; place-items: center;
}

.card-poster {
  position: relative;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background: var(--surface-2);
}
.card-poster img { width: 100%; height: 100%; object-fit: cover; }

/* top-left — rank or status */
.card-status { position: absolute; top: 8px; left: 8px; z-index: 3; }
.rank-badge {
  background: var(--accent);
  color: #fff;
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  z-index: 3;
}

/* top-right — rating */
.card-rating {
  position: absolute; top: 8px; right: 8px; z-index: 3;
  background: rgba(11, 12, 16, 0.9);
  border: 1px solid var(--bd);
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--gold);
  display: inline-flex; align-items: center; gap: 4px;
}

/* bottom-left — episode badge */
.card-overlay {
  position: absolute; bottom: 8px; left: 8px; z-index: 3;
}
.ov-ep {
  background: var(--mint);
  color: var(--bg);
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

/* hover actions */
.card-hover {
  position: absolute; inset: 0; z-index: 4;
  display: flex; flex-direction: column; justify-content: flex-end; gap: 8px;
  padding: 12px;
  background: rgba(11, 12, 16, 0.82);
  opacity: 0;
  transition: opacity 0.16s;
}
.card:hover .card-hover { opacity: 1; }
.card-hover .btn { width: 100%; }

.card-body { padding: 10px 10px 12px; }
.card-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  line-height: 1.25;
  color: var(--paper);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-jp {
  font-family: var(--font-jp);
  font-size: 10px;
  color: var(--muted-d);
  margin: 3px 0 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-meta {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted-d);
}
.card-progress { position: absolute; bottom: 0; left: 0; right: 0; height: 3px; background: var(--bd); }
.card-progress span { display: block; height: 100%; background: var(--accent); }

/* generic grid of cards (browse / search / genre) */
.grid { display: grid; gap: 14px; }
.grid-cards { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
@media (min-width: 640px) { .grid-cards { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); } }
.grid-cards .card { width: 100%; }

/* ============================================================
   Badges / chips
   ============================================================ */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px;
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
}
.badge-airing,
.badge-finished,
.badge-upcoming,
.badge-unknown,
.badge-healthy,
.badge-degraded,
.badge-offline,
.badge-unknown-status,
.badge-green,
.badge-red,
.badge-violet {
  background: rgb(0 0 0 / 62%);
  border: 1px solid var(--bd);
}
.badge-airing { color: var(--mint); }
.badge-finished { color: #9e97ae; }
.badge-upcoming { color: var(--lavender); }
.badge-unknown,
.badge-unknown-status { color: var(--muted-d); }
.badge-healthy,
.badge-green { color: var(--mint); }
.badge-degraded { color: var(--gold); }
.badge-offline,
.badge-red { color: #f08090; }
.badge-violet { color: var(--lavender); }
.badge-amber { background: rgba(255, 182, 39, 0.14); color: var(--gold); }

.chip {
  display: inline-block; padding: 6px 14px;
  border: 1px solid var(--bd);
  color: var(--muted-d);
  font-size: 13px; font-weight: 500;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.chip:hover { background: var(--surface-2); color: var(--paper); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }

.genre-pill {
  display: inline-flex; padding: 8px 16px;
  background: var(--surface);
  border: 1px solid var(--bd);
  color: var(--muted-d);
  font-weight: 500; font-size: 13.5px;
  transition: all 0.16s;
}
.genre-pill:hover { color: var(--paper); border-color: var(--accent); }

/* ============================================================
   Forms
   ============================================================ */

.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 6px; color: var(--muted-d); }
.input, select.input, textarea.input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--bd);
  background: var(--surface);
  color: var(--paper);
  font-size: 14.5px;
  outline: none;
  transition: border-color 0.16s;
}
.input:focus { border-color: var(--accent); }
textarea.input { min-height: 120px; resize: vertical; }
select.input option { background: var(--surface); }
.form-card { background: var(--surface); border: 1px solid var(--bd); padding: 28px 24px; max-width: 460px; margin-inline: auto; }
.form-error { color: var(--accent); font-size: 13px; margin-top: 4px; }
.error-list { background: rgba(230, 57, 70, 0.08); border: 1px solid rgba(230, 57, 70, 0.3); padding: 12px 16px; margin-bottom: 16px; font-size: 13.5px; color: #f08090; }
.checkbox-row { display: flex; align-items: center; gap: 10px; font-size: 14px; }

/* ============================================================
   Anime detail
   ============================================================ */

.detail-hero { position: relative; margin: 0; }
.detail-backdrop {
  position: absolute; inset: 0;
  height: clamp(320px, 48vh, 480px);
  background-size: cover; background-position: center 20%;
}
.detail-backdrop::after {
  content: "";
  position: absolute; inset: 0;
  background: rgba(11, 12, 16, 0.85);
}
.detail-body {
  position: relative; z-index: 2;
  display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 24px;
  padding-top: clamp(240px, 34vh, 340px);
  padding-bottom: 20px;
}
.detail-poster {
  overflow: hidden;
  box-shadow: var(--shadow-md);
  aspect-ratio: 2/3;
  background: var(--surface-2);
  border: 1px solid var(--bd);
}
.detail-poster img { width: 100%; height: 100%; object-fit: cover; }
.detail-title { font-size: clamp(1.8rem, 4vw, 2.6rem); font-weight: 800; letter-spacing: -0.02em; margin-bottom: 4px; }
.detail-alt-title { color: var(--muted-d); font-size: 14px; margin-bottom: 12px; font-family: var(--font-jp); }
.detail-meta { display: flex; flex-wrap: wrap; gap: 20px; margin: 14px 0; font-size: 14px; color: var(--muted-d); }
.detail-meta b { color: var(--muted-2); display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; font-family: var(--font-mono); font-weight: 700; }
.detail-desc { color: var(--muted-d); max-width: 760px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--bd); margin: 24px 0 20px; overflow-x: auto; }
.tab { padding: 11px 16px; font-weight: 600; color: var(--muted-d); border-bottom: 2px solid transparent; white-space: nowrap; }
.tab:hover { color: var(--paper); }
.tab.active { color: var(--paper); border-bottom-color: var(--accent); }

.episode-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.episode-item {
  display: flex; gap: 12px; align-items: flex-start; padding: 11px;
  background: var(--surface);
  border: 1px solid var(--bd);
  transition: border-color 0.16s, transform 0.16s;
}
.episode-item:hover { border-color: var(--accent); transform: translateY(-2px); }
.episode-num { font-size: 16px; font-weight: 800; color: var(--accent); min-width: 34px; text-align: center; line-height: 1.6; }
.episode-info .e-title { font-weight: 600; font-size: 14px; }
.episode-info .e-meta { font-size: 12.5px; color: var(--muted-d); margin-top: 3px; }
.episode-thumb { width: 96px; aspect-ratio: 16/9; object-fit: cover; background: var(--surface-2); }

/* ============================================================
   Watch page
   ============================================================ */

.watch-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; margin-top: 20px; }
.watch-main { min-width: 0; }
.player-wrap { position: relative; overflow: hidden; background: #000; box-shadow: var(--shadow-md); aspect-ratio: 16/9; }
.player-wrap video { width: 100%; height: 100%; }
.player-message { position: absolute; inset: 0; display: grid; place-items: center; background: #000; color: var(--muted-d); z-index: 2; text-align: center; padding: 16px; }
.player-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; }

/* Icon toolbar buttons */
.toolbar-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted-d);
  cursor: pointer;
  transition: background .15s, color .15s;
  flex-shrink: 0;
}
.toolbar-icon:hover { background: var(--surface-2); color: var(--text); }
.player-info { padding: 16px 18px; background: var(--surface); border: 1px solid var(--bd); margin-top: 14px; }
.episode-nav { display: flex; gap: 10px; margin-top: 14px; }
.episode-nav .btn { flex: 1; }

/* Lights Out — dim everything around the player */
.l-nav,
.l-footer,
.watch-side,
.episode-nav,
.player-info,
.comments { transition: opacity 0.35s ease; }
body.lights-out { background: #000; }
body.lights-out .watch-layout { grid-template-columns: 1fr; }
body.lights-out .watch-side { display: none; }
body.lights-out .l-nav,
body.lights-out .l-footer,
body.lights-out .episode-nav,
body.lights-out .player-info,
body.lights-out .comments {
  opacity: 0.1;
  pointer-events: none;
}
body.lights-out #lights-btn { color: var(--accent); }

.watch-side { display: flex; flex-direction: column; gap: 14px; }
.episode-list-panel { background: var(--surface); border: 1px solid var(--bd); display: flex; flex-direction: column; height: 400px; }
.episode-list-head { padding: 13px 16px; border-bottom: 1px solid var(--bd); font-weight: 800; display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
.episode-list-scroll { overflow-y: auto; flex: 1; min-height: 0; }
.episode-list-item { display: flex; gap: 11px; align-items: center; padding: 9px 14px; border-bottom: 1px solid rgba(245, 242, 232, 0.04); transition: background 0.12s; }
.episode-list-item:hover { background: var(--surface-2); }
.episode-list-item.active { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--accent); }
.episode-list-item .num { font-weight: 800; color: var(--accent); min-width: 26px; font-family: var(--font-mono); }
.episode-list-item .e-title { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.episode-list-item .e-progress { color: var(--muted-d); font-size: 12px; }

/* ============================================================
   Comments
   ============================================================ */

.comments { margin-top: 28px; }
.comment { display: flex; gap: 12px; padding: 16px 0; border-bottom: 1px solid rgba(245, 242, 232, 0.05); }
.comment-avatar {
  width: 40px; height: 40px;
  background: var(--surface-2);
  border: 1px solid var(--bd);
  color: var(--gold);
  display: grid; place-items: center;
  font-weight: 800; color: var(--paper); flex-shrink: 0; font-size: 14px;
}
.comment-body { flex: 1; min-width: 0; }
.comment-head { display: flex; gap: 10px; align-items: baseline; font-size: 13px; }
.comment-head .c-name { font-weight: 800; }
.comment-head .c-time { color: var(--muted-d); }
.comment-text { margin: 4px 0; font-size: 14.5px; }
.comment-actions { display: flex; gap: 14px; font-size: 13px; }
.comment-actions button { background: none; border: none; color: var(--muted-d); font-weight: 700; padding: 0; }
.comment-actions button:hover { color: var(--paper); }
.comment-reply { margin-left: 48px; padding-left: 16px; border-left: 2px solid var(--bd); }
.comment-form textarea { background: var(--surface); }

/* ============================================================
   Dashboard / stats / continue watching
   ============================================================ */

.dash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin: 20px 0; }
.stat-card { background: var(--surface); border: 1px solid var(--bd); padding: 16px 18px; }
.stat-card .stat-value { font-size: 26px; font-weight: 800; font-family: var(--font-display); }
.stat-card .stat-label { color: var(--muted-d); font-size: 13px; }

.continue-card {
  display: flex; gap: 14px; align-items: center;
  background: var(--surface);
  border: 1px solid var(--bd);
  padding: 12px;
  transition: border-color 0.16s;
}
.continue-card:hover { border-color: var(--bd2); }
.continue-card img { width: 88px; aspect-ratio: 2/3; object-fit: cover; }
.continue-info { flex: 1; min-width: 0; }
.continue-info .c-title { font-weight: 700; font-size: 14.5px; font-family: var(--font-display); }
.continue-info .c-ep { color: var(--muted-d); font-size: 13px; }
.progress-bar { height: 3px; background: var(--bd); overflow: hidden; margin-top: 8px; }
.progress-bar span { display: block; height: 100%; background: var(--accent); }

/* ============================================================
   Admin
   ============================================================ */

.admin-shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: calc(100vh - var(--topbar-h)); }
.admin-shell.site-main { padding: 0; }
.admin-side { background: var(--bg); border-right: 1px solid var(--bd); padding: 18px 12px; }
.admin-side a { display: block; padding: 8px 12px; color: var(--muted-d); font-weight: 500; font-size: 13.5px; margin-bottom: 2px; border-left: 2px solid transparent; transition: background 0.16s, color 0.16s; }
.admin-side a:hover { background: var(--surface); color: var(--paper); }
.admin-side a.active { background: var(--surface); color: var(--paper); border-left-color: var(--accent); }
.admin-side .side-label { font-size: 10px; font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted-2); padding: 14px 12px 6px; font-weight: 700; }
.admin-main { padding: 24px; min-width: 0; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--bd); }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; padding: 11px 14px; color: var(--muted-2); font-size: 10px; font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.08em; border-bottom: 1px solid var(--bd); font-weight: 700; }
.table td { padding: 11px 14px; border-bottom: 1px solid rgba(245, 242, 232, 0.05); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: rgba(255, 255, 255, 0.02); }

.avatar-sm { width: 30px; height: 30px; object-fit: cover; background: var(--surface-3); }
.poster-sm { width: 40px; height: 56px; object-fit: cover; background: var(--surface-3); }
.mono { font-family: var(--font-mono); font-size: 13px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 16px; font-size: 14px; }
.kv dt { color: var(--muted-d); }
.kv dd { margin: 0; }

/* ============================================================
   Alerts / toasts
   ============================================================ */

.alert { padding: 13px 17px; font-size: 14px; margin-bottom: 16px; border: 1px solid; }
.alert-success { background: rgba(46, 229, 198, 0.08); border-color: rgba(46, 229, 198, 0.3); color: #a5f2e6; }
.alert-error { background: rgba(230, 57, 70, 0.08); border-color: rgba(230, 57, 70, 0.3); color: #f08090; }
.alert-info { background: rgba(183, 148, 246, 0.08); border-color: rgba(183, 148, 246, 0.3); color: #d6c2f9; }

.notice {
  background: var(--surface);
  border: 1px solid var(--bd);
  color: var(--muted-d);
  padding: 12px 16px;
  font-size: 13.5px;
}

.toast-wrap { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.toast {
  background: var(--paper);
  color: var(--bg);
  padding: 12px 20px;
  font-weight: 700;
  font-size: 13px;
  border: 2px solid var(--bg);
  box-shadow: var(--shadow-md);
  animation: toastIn 0.25s ease;
  max-width: 90vw;
  text-align: center;
}
.toast-success { background: var(--paper); color: var(--bg); }
.toast-error { background: var(--accent); color: #fff; border-color: var(--bg); }
@keyframes toastIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ============================================================
   Skeleton / empty states
   ============================================================ */

.skeleton { background: var(--surface-2); }

.empty { text-align: center; padding: 48px 16px; color: var(--muted-d); }
.empty .empty-icon { font-size: 36px; margin-bottom: 10px; }
.empty h3 { color: var(--paper); }
.empty .btn { margin-top: 10px; }

/* ============================================================
   Footer
   ============================================================ */

.footer { border-top: 1px solid var(--bd); margin-top: 48px; background: var(--bg); }
.footer-inner { padding: 40px 0 24px; display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 1fr; gap: 28px; }
.footer h4 { font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted-2); margin-bottom: 12px; font-weight: 700; }
.footer a { display: block; color: var(--muted-d); font-size: 14px; padding: 3px 0; }
.footer a:hover { color: var(--accent); }
.footer .logo { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.footer .logo-mark { width: 32px; height: 32px; border-radius: 5px; }
.footer-blurb { color: var(--muted-2); font-size: 12.5px; max-width: 300px; line-height: 1.6; }
.footer-bottom {
  border-top: 1px solid var(--bd);
  padding: 16px 0;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted-2);
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  align-items: center;
}
.footer-bottom .sys { display: inline-flex; align-items: center; gap: 6px; color: var(--muted-d); }
.footer-langs { display: flex; gap: 8px; }
.footer-langs button {
  border: 1px solid var(--bd);
  background: transparent;
  color: var(--muted-d);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 6px 12px;
  border-radius: 5px;
  transition: color 0.16s, border-color 0.16s;
}
.footer-langs button:hover { color: var(--paper); border-color: var(--bd2); }

/* ============================================================
   Pagination
   ============================================================ */

.pagination { display: flex; gap: 6px; justify-content: center; margin: 28px 0; flex-wrap: wrap; }
.pagination a, .pagination span {
  min-width: 38px; height: 38px; display: inline-grid; place-items: center;
  border: 1px solid var(--bd); font-weight: 600; font-size: 13.5px;
  background: var(--surface); color: var(--muted-d);
}
.pagination a:hover { border-color: var(--accent); color: var(--paper); }
.pagination .current { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ============================================================
   Legacy top nav (admin layout keeps a slim header)
   ============================================================ */

.nav {
  position: sticky; top: 0; z-index: 50;
  height: var(--topbar-h);
  display: flex; align-items: center;
  background: rgba(11, 12, 16, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--bd);
}
.nav-inner { display: flex; align-items: center; gap: 20px; height: 100%; width: 100%; padding: 0 24px; }
.nav .logo { font-weight: 800; font-size: 1.2rem; letter-spacing: -0.02em; display: flex; align-items: center; gap: 10px; font-family: var(--font-logo); }
.nav-links { display: flex; gap: 4px; align-items: center; }
.nav-link {
  padding: 8px 14px;
  color: var(--muted-d); font-size: 14px; font-weight: 600;
  transition: background 0.16s, color 0.16s;
}
.nav-link:hover { color: var(--paper); background: var(--surface); }
.nav-link.active { color: #fff; background: var(--accent); }
.nav-search { flex: 1; max-width: 340px; margin-left: auto; position: relative; }
.nav-actions { display: flex; align-items: center; gap: 8px; }

/* ============================================================
   Misc utilities
   ============================================================ */

.divider { border: none; border-top: 1px solid var(--bd); margin: 24px 0; }
.flex { display: flex; gap: 10px; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.flex-wrap { flex-wrap: wrap; }
.mt-1 { margin-top: 10px; } .mt-2 { margin-top: 20px; } .mt-3 { margin-top: 30px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 10px; } .mb-2 { margin-bottom: 20px; }
.text-center { text-align: center; }
.pill-group { display: flex; flex-wrap: wrap; gap: 8px; }

.stars { color: var(--gold); letter-spacing: 2px; }
.rating-big { font-size: 2.2rem; font-weight: 800; color: var(--gold); font-family: var(--font-display); }
code { background: var(--surface-2); padding: 2px 6px; font-size: 0.82em; }
pre.code-block { background: var(--surface); border: 1px solid var(--bd); padding: 16px; overflow-x: auto; font-size: 13px; }

/* ============================================================
   Responsive
   ============================================================ */

/* large desktop */
@media (min-width: 1024px) {
  :root { --sidebar-w: 256px; }
  .sidebar { position: sticky; transform: none; height: 100vh; top: 0; }
  .sidebar-overlay { display: none !important; }
  .shell { }
}

/* tablet */
@media (max-width: 1023px) {
  .watch-layout { grid-template-columns: 1fr; }
  .watch-side { max-height: none; }
  .detail-body { grid-template-columns: 150px minmax(0, 1fr); gap: 18px; }
  .footer-inner { grid-template-columns: 1fr 1fr; }
  .footer-inner > div:first-child { grid-column: 1 / -1; }
}

/* mobile */
@media (max-width: 767px) {
  :root { --topbar-h: 60px; }
  .hide-mobile { display: none !important; }
  .site-main { padding: 20px 0 40px; }
  .detail-body { grid-template-columns: minmax(0, 1fr); }
  .detail-poster { width: 140px; }
  .hero-content { padding: 20px; }
  .grid-cards { gap: 10px; }
  .row { gap: 10px; }
  .row-card { width: 148px; }
  .card { width: 100%; }
  .footer-inner { gap: 20px; }
  .hero-actions .btn { flex: 1; justify-content: center; }
}

/* small phones */
@media (max-width: 420px) {
  .row-card { width: 136px; }
  .hero { height: 430px; }
  .hero-title { font-size: 2rem; }
  .hero-desc { -webkit-line-clamp: 2; }
  [data-rating-stars] { flex-wrap: wrap; }
}

/* ============================================================
   Reduced motion
   ============================================================ */

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

/* ============================================================
   Ad slots
   ============================================================ */
.ad-slot {
  margin: 16px auto;
  padding: 12px;
  text-align: center;
  font-size: 12px;
  color: var(--muted-2);
  border: 1px dashed var(--bd);
  border-radius: var(--radius-sm);
  background: var(--surface);
  max-width: 100%;
  overflow: hidden;
}
.ad-slot > * {
  max-width: 100%;
}
.ad-slot-hero {
  max-width: 728px;
}
.ad-slot-sidebar {
  max-width: 300px;
}
.ad-slot-footer {
  max-width: 100%;
  margin: 24px auto 8px;
}
.ad-slot-inline {
  max-width: 728px;
  margin: 8px auto;
}
.ad-slot-top {
  max-width: 100%;
  margin: 0 auto 16px;
}
