@import url("components.css");

:root {
  --bg: #050508;
  --bg2: #0f1117;
  --surface: #181b24;
  --surface2: #1f2430;
  --card: rgba(255, 255, 255, 0.04);
  --line: rgba(255, 255, 255, 0.08);
  --text: #f5f5f7;
  --muted: #9ca3af;
  --accent: #6366f1;
  --accent2: #e879f9;
  --accent-m: #5b8def;
  --green: #4ade80;
  --yellow: #fbbf24;
  --purple: #818cf8;
  --radius: 16px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; }
html {
  min-height: 100%;
  scrollbar-gutter: stable;
  scrollbar-width: auto;
  scrollbar-color: #6b7280 #1a1f2e;
}
html, body { min-height: 100%; }
body {
  font-family: var(--font);
  background: transparent;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  overflow-y: scroll;
}

/* Full-viewport background — один слой, cover + blur */
.site-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
  background-color: var(--bg);
}
.site-bg::before {
  content: "";
  position: absolute;
  inset: -5%;
  background-image: var(--site-bg-image, none);
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  filter: blur(var(--site-bg-blur, 8px));
  transform: scale(1.04);
}
.site-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(5, 5, 8, var(--site-bg-dim, 0.4));
}

/* —— Scrollbars (visible under content) —— */
* {
  scrollbar-width: auto;
  scrollbar-color: #6b7280 #1a1f2e;
}
*::-webkit-scrollbar {
  width: 14px;
  height: 14px;
}
*::-webkit-scrollbar-track {
  background: #1a1f2e;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
*::-webkit-scrollbar-thumb {
  background: #6b7280;
  border: 2px solid #1a1f2e;
  border-radius: 0;
}
*::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}
*::-webkit-scrollbar-corner {
  background: #1a1f2e;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
img { display: block; max-width: 100%; }
.muted { color: var(--muted); }
.link { color: #6eb5ff; text-decoration: none; }
.link:hover { text-decoration: underline; }

.layout-desktop { display: none; }
.layout-mobile { display: flex; flex-direction: column; min-height: 100vh; }

@media (min-width: 900px) {
  .layout-desktop {
    display: block;
    min-height: 100vh;
  }
  .layout-mobile { display: none; }
}

/* —— Stats inline row (variant 1, hero center) —— */
.stats-inline {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.85rem 1.25rem;
  background: rgba(26, 32, 48, 0.88);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.7rem 1.35rem;
  backdrop-filter: blur(10px);
}
.stats-inline.is-loading .stats-skeleton-inline { display: block; width: min(520px, 70vw); }
.stats-inline.is-loading .stats-inline-title,
.stats-inline.is-loading .stats-inline-row { display: none; }
.stats-skeleton { display: none; }
.stats-skeleton-inline { display: none; }
.stats-inline-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}
.stats-inline-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.65rem 1.35rem;
}
.stat-item {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  font-size: 0.88rem;
  white-space: nowrap;
}
.stat-lbl { color: var(--muted); }
.stat-item b {
  font-size: 1.05rem;
  font-weight: 700;
}
.stat-green { color: var(--green); }
.stat-yellow { color: var(--yellow); }
.stat-purple { color: var(--purple); }
.stats-error { font-size: 0.85rem; text-align: center; }
.stats-inline-compact {
  padding: 0.55rem 0.85rem;
  gap: 0.5rem 0.85rem;
  flex: 1 1 100%;
  max-width: none;
}
.stats-inline-compact .stats-inline-row { gap: 0.45rem 0.85rem; }
.stats-inline-compact .stat-item { font-size: 0.78rem; }
.stats-inline-compact .stat-item b { font-size: 0.92rem; }

/* —— Cinema hero (прозрачный, только site-bg) —— */
.desktop-main { min-width: 0; width: 100%; }
.hero {
  position: relative;
  padding: 1.25rem clamp(1rem, 2.5vw, 2rem) 1rem;
  background: transparent;
}
.hero-content {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: none;
  padding: 0 clamp(0.25rem, 1vw, 0.5rem);
}
.hero-top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem 1.5rem;
  margin-bottom: 1rem;
}
.hero-intro {
  grid-column: 1;
  justify-self: start;
  min-width: 0;
}
.stats-inline {
  grid-column: 2;
  justify-self: center;
}
@media (max-width: 899px) {
  .hero-top {
    grid-template-columns: 1fr;
  }
  .stats-inline {
    grid-column: 1;
    justify-self: stretch;
  }
}
.hero h1 {
  font-size: clamp(1.75rem, 3vw, 2.5rem);
  font-weight: 800;
  margin-bottom: 0.25rem;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.65);
}
.hero-sub {
  color: var(--muted);
  font-size: 0.92rem;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.55);
}
.hero-tabs { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; width: 100%; }
.hero-tab {
  padding: 0.5rem 1rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--muted);
  backdrop-filter: blur(8px);
  transition: 0.15s;
}
.hero-tab.on {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}
.hero-tab-cta {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}
.hero-tabs .auth-tab {
  margin-left: 0;
  font-size: 0.82rem;
}
.hero-tabs .auth-tab#authLogoutBtn {
  margin-left: auto;
}
body.read-only .hero-tab-cta,
body.read-only .open-search-btn,
body.read-only .add-fab {
  display: none !important;
}
.mobile-auth-btn {
  position: fixed;
  top: max(0.85rem, env(safe-area-inset-top));
  right: 0.75rem;
  z-index: 15;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(24, 27, 36, 0.92);
  font-size: 0.78rem;
  color: var(--text);
}
body.can-edit .mobile-auth-btn { display: none; }
.auth-modal {
  position: relative;
  z-index: 1;
  width: min(380px, 100%);
  margin-top: 12vh;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}
.overlay-backdrop { z-index: 0; }
.auth-form {
  padding: 1rem 1.15rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.auth-form input {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg2);
}
.auth-hint { font-size: 0.82rem; }
.auth-error { color: #f87171; font-size: 0.85rem; }
.auth-submit { width: 100%; margin-top: 0.25rem; }
.detail-form-readonly .detail-readonly-val {
  padding: 0.55rem 0;
  font-size: 0.95rem;
}
.detail-form-readonly .detail-hint { margin-top: 0.25rem; }
body.read-only .top-unrank { display: none !important; }

.cinema-main {
  width: 100%;
  max-width: none;
  padding: 0 clamp(1rem, 2.5vw, 2rem) 2.5rem;
}
.cinema-root { width: 100%; }
.shelf { margin-bottom: 1.75rem; width: 100%; }
.shelf-head {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  padding: 0 clamp(0.25rem, 0.5vw, 0.5rem);
}
.desktop-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  margin-bottom: 1rem;
}
.toolbar-search {
  flex: 1;
  min-width: 180px;
  max-width: 280px;
  padding: 0.55rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.filter-row { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.chip, .pill {
  padding: 0.42rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
  transition: 0.15s;
}
.chip.on, .pill.on {
  background: rgba(99, 102, 241, 0.2);
  border-color: rgba(99, 102, 241, 0.45);
  color: var(--text);
}
.panel { display: none; }
.panel.on { display: block; }
.section-sub { margin-bottom: 1rem; font-size: 0.88rem; }
.list-search-meta { display: block; margin-bottom: 0.75rem; font-size: 0.82rem; }

.shelf-head h2 { font-size: 1.1rem; }
.shelf-head span { color: var(--muted); font-size: 0.85rem; }
.poster-row {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 0;
  scroll-snap-type: x mandatory;
  scrollbar-width: auto;
}
.poster-row::-webkit-scrollbar {
  height: 14px;
}
.poster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(120px, 9vw, 165px), 1fr));
  gap: 0.75rem;
  width: 100%;
}
.poster-card {
  flex: 0 0 clamp(130px, 10vw, 165px);
  scroll-snap-align: start;
  border-radius: 14px;
  overflow: hidden;
  position: relative;
  aspect-ratio: 2/3;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: transform 0.2s, box-shadow 0.2s;
}
.poster-card:hover {
  transform: scale(1.04) translateY(-3px);
  box-shadow: 0 14px 36px rgba(99, 102, 241, 0.22);
  z-index: 2;
}
.poster-card img { width: 100%; height: 100%; object-fit: cover; }
.poster-card .ov {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.92), transparent 55%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 0.65rem;
  pointer-events: none;
}
.poster-card h3 { font-size: 0.78rem; line-height: 1.25; margin-bottom: 0.15rem; }
.poster-card .meta { font-size: 0.68rem; color: rgba(255, 255, 255, 0.75); }
.badge-rank {
  position: absolute;
  top: 6px;
  left: 6px;
  font-size: 0.65rem;
  padding: 0.15rem 0.4rem;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.65);
  z-index: 1;
}
.badge-season {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 0.62rem;
  padding: 0.15rem 0.35rem;
  border-radius: 6px;
  background: rgba(99, 102, 241, 0.85);
  z-index: 1;
}
.top-shelf.rank-1 .shelf-head h2 { color: #fcd34d; }
.top-shelf.rank-2 .shelf-head h2 { color: #cbd5e1; }
.top-shelf.rank-3 .shelf-head h2 { color: #fdba74; }
.poster-card-lg { flex: 0 0 170px; }
.top-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}
.top-empty-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }

/* —— Mobile compact (variant 3) —— */
.mobile-topbar {
  padding: max(0.85rem, env(safe-area-inset-top)) 1rem 0.65rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.mobile-topbar-head {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 0.55rem;
}
.mobile-topbar h1 { font-size: 1.3rem; font-weight: 700; }
.search-wrap { position: relative; }
.search-wrap input {
  width: 100%;
  padding: 0.6rem 0.85rem 0.6rem 2.35rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface2);
}
.search-wrap::before {
  content: "🔍";
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.55;
  font-size: 0.85rem;
}
.mobile-filters {
  display: flex;
  gap: 0.35rem;
  padding: 0.65rem 1rem;
  overflow-x: auto;
}
.mobile-scroll { flex: 1; overflow-y: auto; padding-bottom: 5.25rem; }
.list-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.list-item:active { background: rgba(255, 255, 255, 0.04); }
.thumb {
  width: 52px;
  height: 74px;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  flex-shrink: 0;
}
.list-item .body { flex: 1; min-width: 0; }
.list-item strong {
  display: block;
  font-size: 0.92rem;
  margin-bottom: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-item .meta { font-size: 0.76rem; color: var(--muted); }
.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 0.3rem;
  vertical-align: middle;
}
.status-dot.watching { background: var(--yellow); }
.status-dot.completed { background: var(--green); }
.status-dot.planned { background: var(--purple); }
.rank-pill {
  font-size: 0.72rem;
  padding: 0.2rem 0.45rem;
  border-radius: 8px;
  background: var(--surface2);
  border: 1px solid var(--line);
  flex-shrink: 0;
}
.top-slot {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.top-slot .num {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.top-slot.gold .num { background: linear-gradient(135deg, #fcd34d, #f59e0b); color: #1a1200; }
.top-slot.silver .num { background: linear-gradient(135deg, #e2e8f0, #94a3b8); color: #1a1a1a; }
.top-slot.bronze .num { background: linear-gradient(135deg, #fdba74, #ea580c); color: #1a0a00; }
.top-slot img { width: 46px; height: 66px; border-radius: 8px; object-fit: cover; }
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0.45rem 1rem max(0.55rem, env(safe-area-inset-bottom));
  background: rgba(24, 27, 36, 0.94);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  z-index: 20;
}
.bottom-nav button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  font-size: 0.65rem;
  color: var(--muted);
  padding: 0.3rem 0.65rem;
}
.bottom-nav button.on { color: var(--accent-m); }
.bottom-nav .ico { font-size: 1.2rem; }
.add-fab {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--accent-m);
  color: #fff;
  font-size: 1.5rem;
  margin-top: -1.1rem;
  box-shadow: 0 8px 22px rgba(91, 141, 239, 0.45);
  display: grid;
  place-items: center;
}

/* —— Add modal variant 4 —— */
.overlay.is-visible { display: flex !important; }
.modal.add-modal {
  position: relative;
  z-index: 1;
  width: min(720px, 100%);
  max-height: 90vh;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { font-size: 1.05rem; }
.modal-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 340px;
  max-height: calc(90vh - 60px);
}
.search-pane {
  border-right: 1px solid var(--line);
  padding: 1rem;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}
.add-search {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg2);
  margin-bottom: 0.5rem;
}
.search-pane .search-results { flex: 1; overflow-y: auto; max-height: none; }
.add-hit, .search-result {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  width: 100%;
  padding: 0.5rem;
  border-radius: 8px;
  border: 1px solid transparent;
  margin-bottom: 0.3rem;
  cursor: pointer;
  text-align: left;
  background: transparent;
  color: inherit;
}
.add-hit:hover, .add-hit.is-picked, .search-result:hover, .search-result.is-picked {
  background: rgba(249, 115, 22, 0.1);
  border-color: rgba(249, 115, 22, 0.25);
}
.add-hit img, .search-result img {
  width: 38px;
  height: 54px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}
.queue-pane {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.queue-title { font-size: 0.85rem; color: var(--muted); margin-bottom: 0.65rem; }
.search-pick-list { flex: 1; overflow-y: auto; min-height: 120px; }
.queue-item {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.85rem;
}
.queue-item img { width: 32px; height: 44px; border-radius: 4px; object-fit: cover; }
.queue-empty { color: var(--muted); font-size: 0.82rem; padding: 1rem 0; }
.queue-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}
.queue-actions .btn-primary { flex: 1; }

@media (max-width: 640px) {
  .modal-split { grid-template-columns: 1fr; max-height: 85vh; }
  .search-pane { border-right: none; border-bottom: 1px solid var(--line); max-height: 45vh; }
  .queue-pane { max-height: 35vh; }
}

.sk-shimmer {
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.04) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: 8px;
}
.sk-line { height: 0.75rem; margin-bottom: 0.35rem; }
.sk-line.short { width: 55%; }
.stats-inline.is-loading .stats-skeleton-inline { display: block; }
@keyframes shimmer { to { background-position: -200% 0; } }
.skeleton-row { height: 145px; border-radius: 14px; margin-bottom: 0.75rem; }

.anim-in {
  animation: fadeUp 0.35s ease both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.empty { padding: 2rem 0; text-align: center; }
