/* ==========================================================================
   KITSUBANE — Apple TV+ / visionOS / Kinopoisk HD Design System
   ========================================================================== */

:root,
[data-theme="cyber"] {
  color-scheme: dark;
  --bg: #07080D;
  --surface: #11131C;
  --surface-glass: rgba(18, 21, 32, 0.62);
  --header-bg: rgba(9, 13, 22, 0.92);
  --accent: #06B6D4;
  --accent-secondary: #6366F1;
  --text: #F8FAFC;
  --text-muted: #94A3B8;

  --bg-primary: var(--bg);
  --bg-base: var(--bg);
  --bg-elevated: var(--surface);
  --glass-surface: var(--surface-glass);
  --glass-bg: var(--surface-glass);
  --glass-bg-elevated: rgba(24, 28, 44, 0.78);
  --glass-bg-recessed: rgba(8, 10, 16, 0.56);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-highlight: rgba(255, 255, 255, 0.09);
  --accent-primary: var(--accent);
  --accent-glow: rgba(6, 182, 212, 0.32);
  --text-primary: var(--text);
  --text-main: var(--text);
  --text-secondary: var(--text-muted);
}

[data-theme="tokyo"] {
  color-scheme: dark;
  --bg: #090611;
  --surface: #140E21;
  --surface-glass: rgba(24, 16, 40, 0.64);
  --header-bg: rgba(14, 9, 26, 0.94);
  --accent: #A855F7;
  --accent-secondary: #EC4899;
  --text: #FAF5FF;
  --text-muted: #B8A5D6;

  --bg-primary: var(--bg);
  --bg-base: var(--bg);
  --bg-elevated: var(--surface);
  --glass-surface: var(--surface-glass);
  --glass-bg: var(--surface-glass);
  --glass-bg-elevated: rgba(34, 22, 56, 0.8);
  --glass-bg-recessed: rgba(10, 6, 18, 0.6);
  --glass-border: rgba(255, 255, 255, 0.09);
  --glass-highlight: rgba(255, 255, 255, 0.1);
  --accent-primary: var(--accent);
  --accent-glow: rgba(168, 85, 247, 0.35);
  --text-primary: var(--text);
  --text-main: var(--text);
  --text-secondary: var(--text-muted);
}

[data-theme="sakura"] {
  color-scheme: light;
  --bg: #F3F4F8;
  --surface: #FFFFFF;
  --surface-glass: rgba(255, 255, 255, 0.72);
  --header-bg: rgba(245, 246, 250, 0.94);
  --accent: #E11D48;
  --accent-secondary: #4F46E5;
  --text: #0F172A;
  --text-muted: #64748B;

  --bg-primary: var(--bg);
  --bg-base: var(--bg);
  --bg-elevated: var(--surface);
  --glass-surface: var(--surface-glass);
  --glass-bg: var(--surface-glass);
  --glass-bg-elevated: rgba(255, 255, 255, 0.9);
  --glass-bg-recessed: rgba(226, 232, 240, 0.65);
  --glass-border: rgba(15, 23, 42, 0.08);
  --glass-highlight: rgba(255, 255, 255, 0.9);
  --accent-primary: var(--accent);
  --accent-glow: rgba(225, 29, 72, 0.24);
  --text-primary: var(--text);
  --text-main: var(--text);
  --text-secondary: var(--text-muted);
}

/* ==========================================================================
   Cohesive Circular Ripple Theme Transition (View Transitions API + Fallback)
   ========================================================================== */

@keyframes themeCircleReveal {
  from {
    clip-path: circle(0px at var(--theme-x, 50%) var(--theme-y, 50%));
  }
  to {
    clip-path: circle(150vmax at var(--theme-x, 50%) var(--theme-y, 50%));
  }
}

::view-transition-old(root) {
  animation: none;
  mix-blend-mode: normal;
  z-index: 1;
}

::view-transition-new(root) {
  animation: themeCircleReveal 420ms cubic-bezier(0.22, 1, 0.36, 1) both;
  mix-blend-mode: normal;
  z-index: 2;
}

html.theme-transitioning,
html.theme-transitioning * {
  transition:
    background-color 0.35s ease,
    color 0.35s ease,
    border-color 0.35s ease,
    box-shadow 0.35s ease !important;
}

/* ==========================================================================
   Single Root Scrollbar & Minimal Dark Scrollbar Styling
   ========================================================================== */

* {
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.32) var(--bg);
}

html {
  overflow-x: hidden;
  overflow-y: auto;
  height: auto;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, sans-serif;
  overflow-x: clip !important;
  overflow-y: visible !important;
  min-height: 100vh;
  height: auto;
}

#app,
main,
.view,
#playerView,
#catalogView {
  overflow-y: visible !important;
  height: auto !important;
  max-height: none !important;
}

#player-modal {
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--accent) 42%, rgba(148, 163, 184, 0.35)),
    rgba(148, 163, 184, 0.28)
  );
  border-radius: 9999px;
}

::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--accent) 75%, rgba(148, 163, 184, 0.4));
}

input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-fade-in {
  animation: fade-in-up 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* ==========================================================================
   Solid Frosted Top Header (Zero Scroll Bleed-Through)
   ========================================================================== */

header {
  background: var(--header-bg);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  padding-bottom: 14px !important;
  box-shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.65);
}

[data-theme="sakura"] header {
  box-shadow: 0 10px 28px -12px rgba(15, 23, 42, 0.14);
}

header .glass-pill,
header nav {
  background: var(--header-bg);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  box-shadow:
    0 12px 28px -10px rgba(0, 0, 0, 0.65),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

[data-theme="sakura"] header .glass-pill,
[data-theme="sakura"] header nav {
  box-shadow:
    0 10px 24px -10px rgba(15, 23, 42, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

/* ==========================================================================
   Borderless Floating Glass Surfaces & Pills
   ========================================================================== */

.glass-pill,
.glass-pill-nav,
.glass-panel {
  background: var(--surface-glass);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: none;
  box-shadow:
    0 20px 40px -15px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

[data-theme="sakura"] .glass-pill,
[data-theme="sakura"] .glass-pill-nav,
[data-theme="sakura"] .glass-panel {
  box-shadow:
    0 18px 36px -14px rgba(15, 23, 42, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.glass-elevated {
  background: var(--glass-bg-elevated);
  backdrop-filter: blur(26px) saturate(180%);
  -webkit-backdrop-filter: blur(26px) saturate(180%);
  border: none;
  box-shadow:
    0 24px 48px -15px rgba(0, 0, 0, 0.65),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.glass-recessed {
  background: var(--glass-bg-recessed);
  border: none;
}

.glass-input {
  background: var(--glass-bg-recessed);
  color: var(--text);
  border: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.glass-input::placeholder {
  color: var(--text-muted);
}

.glass-button {
  background: var(--surface-glass);
  color: var(--text);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: none;
  box-shadow:
    0 10px 24px -10px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.09);
}

.glass-button:hover {
  background: var(--glass-bg-elevated);
}

.glass-accent-btn {
  background: var(--accent);
  color: #FFFFFF;
  border: none;
  box-shadow:
    0 12px 28px -8px var(--accent-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.glass-accent-btn:hover {
  filter: brightness(1.08);
}

.modal-backdrop {
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
}

/* ==========================================================================
   Rich Profile Modal (Banner, Floating Avatar, Stats & Rank Progress)
   ========================================================================== */

.profile-banner {
  position: relative;
  width: 100%;
  height: 120px;
  overflow: hidden;
  background: linear-gradient(135deg, #06b6d4 0%, #6366f1 55%, #a855f7 100%);
}

.profile-banner-btn {
  color: #fff;
  background: rgba(9, 13, 22, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.profile-banner-btn:hover {
  background: rgba(9, 13, 22, 0.9);
  border-color: var(--accent);
}

.profile-avatar-wrap {
  position: relative;
  width: 76px;
  height: 76px;
  border-radius: 9999px;
  overflow: hidden;
  border: 4px solid var(--bg);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 10px 24px -8px rgba(0, 0, 0, 0.7);
  cursor: pointer;
}

.profile-avatar-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(7, 8, 13, 0.58);
  color: #fff;
  font-size: 16px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.profile-avatar-wrap:hover .profile-avatar-overlay {
  opacity: 1;
}

.profile-stats-box {
  background: var(--glass-bg-recessed);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 16px;
}

.rank-progress-track {
  width: 100%;
  height: 7px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.rank-progress-fill {
  height: 100%;
  border-radius: 9999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-secondary));
  box-shadow: 0 0 14px var(--accent-glow);
  transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==========================================================================
   Role Badges & Comment Spoilers
   ========================================================================== */

.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 9999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.03em;
  line-height: 1.4;
}

.role-badge-owner {
  background: linear-gradient(135deg, rgba(250, 204, 21, 0.24), rgba(6, 182, 212, 0.24));
  color: #fde047;
  border: 1px solid rgba(250, 204, 21, 0.4);
}

.role-badge-admin {
  background: rgba(244, 63, 94, 0.2);
  color: #fb7185;
  border: 1px solid rgba(244, 63, 94, 0.35);
}

.role-badge-mod {
  background: rgba(99, 102, 241, 0.22);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.35);
}

.spoiler-blur {
  filter: blur(6px);
  user-select: none;
  transition: filter 0.25s ease;
}

.spoiler-blur.spoiler-revealed {
  filter: none;
  user-select: text;
}

.spoiler-overlay-pill {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 5px 14px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: rgba(9, 13, 22, 0.86);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.spoiler-overlay-pill:hover {
  background: var(--accent);
  border-color: var(--accent);
}

/* ==========================================================================
   Hero Seamless Dissolve Masks
   ========================================================================== */

.hero-fade-bottom {
  background: linear-gradient(
    to top,
    var(--bg) 0%,
    color-mix(in srgb, var(--bg) 88%, transparent) 24%,
    color-mix(in srgb, var(--bg) 35%, transparent) 62%,
    transparent 100%
  );
}

.hero-fade-left {
  background: linear-gradient(
    to right,
    var(--bg) 0%,
    color-mix(in srgb, var(--bg) 82%, transparent) 34%,
    color-mix(in srgb, var(--bg) 25%, transparent) 70%,
    transparent 100%
  );
}

/* ==========================================================================
   Zero-Gap Locked 2:3 Poster Card Architecture
   ========================================================================== */

.poster-card {
  position: relative;
  aspect-ratio: 2 / 3;
  width: 100%;
  overflow: hidden;
  border-radius: 16px;
  background: var(--surface);
  box-shadow:
    0 20px 40px -15px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  isolation: isolate;
}

[data-theme="sakura"] .poster-card {
  box-shadow:
    0 18px 34px -14px rgba(15, 23, 42, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.poster-card > img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.005);
  will-change: transform;
  transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

.group:hover .poster-card > img {
  transform: scale(1.06);
}

.poster-hover-gradient {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.3s ease;
  background: linear-gradient(
    to top,
    rgba(7, 8, 13, 0.92) 0%,
    rgba(7, 8, 13, 0.38) 45%,
    transparent 100%
  );
}

.group:hover .poster-hover-gradient {
  opacity: 1;
}

/* ==========================================================================
   Continue Watching 16:9 Card & History Controls
   ========================================================================== */

.continue-card {
  position: relative;
  aspect-ratio: 16 / 9;
  width: 100%;
  overflow: hidden;
  border-radius: 16px;
  background: var(--surface);
  box-shadow:
    0 20px 40px -15px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  isolation: isolate;
}

.continue-card > img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.005);
  transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

.group:hover .continue-card > img {
  transform: scale(1.06);
}

.continue-clear-btn {
  height: 32px;
  padding: 0 14px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-glass);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
}

.continue-clear-btn:hover {
  color: #f43f5e;
  background: var(--glass-bg-elevated);
}

.cw-remove-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 20;
  width: 28px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(9, 13, 22, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #fff;
  opacity: 0.78;
  transition: opacity 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.group:hover .cw-remove-btn,
.cw-remove-btn:focus-visible {
  opacity: 1;
}

.cw-remove-btn:hover {
  background: #f43f5e;
  border-color: #f43f5e;
  color: #fff;
  transform: scale(1.08);
}

.live-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 9999px;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.line-clamp-1 {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}