/* =========================
   THEME VARIABLES
========================= */
:root{
  --bg: #0b0c10;
  --text: #e8e8e8;
  --muted: rgba(232,232,232,.7);
  --panel: #11121a;
  --panel2: #0f1016;
  --border: rgba(255,255,255,.08);
  --border2: rgba(255,255,255,.12);
  --shadow: rgba(0,0,0,.25);
}

body.light{
  --bg: #f5f6fa;
  --text: #14161a;
  --muted: rgba(20,22,26,.65);
  --panel: #ffffff;
  --panel2: #f0f2f7;
  --border: rgba(20,22,26,.12);
  --border2: rgba(20,22,26,.16);
  --shadow: rgba(0,0,0,.12);
}

* { box-sizing: border-box; }
body {
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial;
  background: var(--bg);
  color: var(--text);
}
a { color: inherit; text-decoration: none; }
.wrap { width: min(1100px, calc(100% - 32px)); margin: 0 auto; }

.topbar {
  position: sticky; top:0;
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

/* ВАЖНО: шапка — бренд + тумблер в 1-й строке, поиск всегда снизу */
.topbar__inner {
  display:grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "brand nav"
    "search search";
  gap:12px;
  align-items:center;
  padding:14px 0;
}
.brand { grid-area: brand; font-weight:800; letter-spacing:.5px; }
.nav { grid-area: nav; display:flex; justify-content:flex-end; align-items:center; }
.search { grid-area: search; display:flex; gap:8px; }

.search input {
  width:100%;
  padding:10px 12px;
  border-radius:10px;
  border:1px solid var(--border2);
  background: var(--panel);
  color: var(--text);
}
.search button {
  padding:10px 12px;
  border-radius:10px;
  border:1px solid var(--border2);
  background: color-mix(in oklab, var(--panel) 82%, #2b2d3a);
  color: var(--text);
  cursor:pointer;
}
.search button:hover { filter: brightness(1.07); }

.h1 { font-size: 28px; margin: 18px 0; }
.h2 { font-size: 20px; margin: 0; }
.muted { opacity: .7; color: var(--text); }
.small { font-size: 12px; }
.footer { padding: 28px 0 40px; opacity:.75; }

.grid { display:grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap:14px; }
.card {
  background: var(--panel);
  border:1px solid var(--border);
  border-radius:14px;
  overflow:hidden;
  transition:.15s;
}
.card:hover { transform: translateY(-2px); border-color: color-mix(in oklab, var(--border) 40%, #ffffff); }
.poster { aspect-ratio: 2/3; background: var(--panel2); display:flex; align-items:center; justify-content:center; }
.poster img { width:100%; height:100%; object-fit:cover; display:block; }
.noimg { padding:14px; opacity:.7; font-size:13px; }
.noimg.big { height: 420px; display:flex; align-items:center; justify-content:center; }

.catalogCard { padding-bottom: 10px; }
.catalogTitle { padding: 10px 12px 0; font-weight: 800; line-height: 1.25; }

/* ====== MOVIE PAGE ====== */
.movie { display:grid; grid-template-columns: 320px 1fr; gap:18px; align-items:start; margin-top: 14px; }
.movie__poster img { width:100%; border-radius:16px; border:1px solid var(--border); }
.movie__desc { line-height:1.55; opacity:.95; margin-top: 12px; }

.movie__fields {
  margin-top: 10px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: color-mix(in oklab, var(--panel2) 70%, transparent);
  display: grid;
  gap: 10px;
}

.fieldRow { display:grid; grid-template-columns: 110px 1fr; gap: 12px; align-items: baseline; }
.fieldName { opacity: .7; font-size: 13px; }
.fieldValue { font-size: 14px; }

.metaLink { text-decoration: underline; text-decoration-color: color-mix(in oklab, var(--text) 25%, transparent); }
.metaLink:hover { text-decoration-color: color-mix(in oklab, var(--text) 55%, transparent); }

.block { margin-top: 16px; padding: 14px; background: var(--panel); border:1px solid var(--border); border-radius:14px; }
.block__title { font-weight:700; margin-bottom:8px; }

/* базовая кнопка */
.btn {
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  padding:10px 12px; border-radius:12px; border:1px solid var(--border2);
  background: color-mix(in oklab, var(--panel) 85%, #2b2d3a);
  color: var(--text); cursor:pointer;
}
.btn:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity:.5; cursor:not-allowed; }

/* =========================
   Theme Switch (Uiverse)
========================= */
.switch { font-size: 17px; position: relative; display: inline-block; width: 4em; height: 2.2em; border-radius: 30px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.12); }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; inset: 0; background-color: #2a2a2a; transition: 0.4s; border-radius: 30px; overflow: hidden; }
.slider:before {
  position: absolute; content: "";
  height: 1.2em; width: 1.2em; border-radius: 20px;
  left: 0.5em; bottom: 0.5em; transition: 0.4s;
  transition-timing-function: cubic-bezier(0.81, -0.04, 0.38, 1.5);
  box-shadow: inset 8px -4px 0px 0px #fff;
}
.switch input:checked + .slider { background-color: #00a6ff; }
.switch input:checked + .slider:before { transform: translateX(1.8em); box-shadow: inset 15px -4px 0px 15px #ffcf48; }
.star { background-color: #fff; border-radius: 50%; position: absolute; width: 5px; height: 5px; transition: all 0.4s; }
.star_1 { left: 2.5em; top: 0.5em; }
.star_2 { left: 2.2em; top: 1.2em; }
.star_3 { left: 3em; top: 0.9em; }
.switch input:checked ~ .slider .star { opacity: 0; }
.cloud { width: 3.5em; position: absolute; bottom: -1.4em; left: -1.1em; opacity: 0; transition: all 0.4s; }
.switch input:checked ~ .slider .cloud { opacity: 1; }

/* =========================
   NEW "РЕШИТЬ" (Uiverse StealthWorm)
========================= */
.decideUibtn {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 13rem;
  overflow: hidden;
  height: 3rem;
  background-size: 300% 300%;
  cursor: pointer;
  backdrop-filter: blur(1rem);
  border-radius: 5rem;
  transition: 0.5s;
  animation: gradient_301 5s ease infinite;
  border: double 4px transparent;
  background-image: linear-gradient(#212121, #212121),
    linear-gradient(
      137.48deg,
      #ffdb3b 10%,
      #fe53bb 45%,
      #8f51ea 67%,
      #0044ff 87%
    );
  background-origin: border-box;
  background-clip: content-box, border-box;
  user-select:none;
}
.decideUibtn:disabled { opacity:.6; cursor:not-allowed; transform:none; animation:none; }

.decideUibtn strong {
  z-index: 2;
  font-size: 12px;
  letter-spacing: 5px;
  color: #ffffff;
  text-shadow: 0 0 4px white;
}

.decideUibtn #container-stars {
  position: absolute;
  z-index: -1;
  width: 100%;
  height: 100%;
  overflow: hidden;
  transition: 0.5s;
  backdrop-filter: blur(1rem);
  border-radius: 5rem;
}
.decideUibtn #glow { position: absolute; display: flex; width: 12rem; }
.decideUibtn .circle {
  width: 100%;
  height: 30px;
  filter: blur(2rem);
  animation: pulse_3011 4s infinite;
  z-index: -1;
}
.decideUibtn .circle:nth-of-type(1) { background: rgba(254, 83, 186, 0.636); }
.decideUibtn .circle:nth-of-type(2) { background: rgba(142, 81, 234, 0.704); }

.decideUibtn:hover #container-stars { z-index: 1; background-color: #212121; }
.decideUibtn:hover { transform: scale(1.06); }
.decideUibtn:active { border: double 4px #fe53bb; animation: none; }
.decideUibtn:active .circle { background: #fe53bb; }

.decideUibtn #stars { position: relative; background: transparent; width: 200rem; height: 200rem; }
.decideUibtn #stars::after {
  content: "";
  position: absolute;
  top: -10rem; left: -100rem;
  width: 100%; height: 100%;
  animation: animStarRotate 90s linear infinite;
  background-image: radial-gradient(#ffffff 1px, transparent 1%);
  background-size: 50px 50px;
}
.decideUibtn #stars::before {
  content: "";
  position: absolute;
  top: 0; left: -50%;
  width: 170%; height: 500%;
  animation: animStar 60s linear infinite;
  background-image: radial-gradient(#ffffff 1px, transparent 1%);
  background-size: 50px 50px;
  opacity: 0.5;
}

@keyframes animStar { from { transform: translateY(0); } to { transform: translateY(-135rem); } }
@keyframes animStarRotate { from { transform: rotate(360deg); } to { transform: rotate(0); } }
@keyframes gradient_301 {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
@keyframes pulse_3011 {
  0% { transform: scale(0.75); box-shadow: 0 0 0 0 rgba(0, 0, 0, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(0, 0, 0, 0); }
  100% { transform: scale(0.75); box-shadow: 0 0 0 0 rgba(0, 0, 0, 0.7); }
}

/* ====== GAME ====== */
.game {
  margin-top: 16px;
  margin-bottom: 18px;
  padding: 14px;
  background: color-mix(in oklab, var(--panel2) 70%, transparent);
  border: 1px solid var(--border);
  border-radius: 16px;
}

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

.game__filters {
  display:grid;
  grid-template-columns: repeat(3, minmax(200px, 1fr));
  gap:10px;
  margin-bottom: 12px;
}

.field label { display:block; font-size: 12px; opacity:.8; margin-bottom: 6px; }
.field input, .field select {
  width:100%;
  padding:10px 12px;
  border-radius:10px;
  border:1px solid var(--border2);
  background: var(--panel);
  color: var(--text);
}

.stepper { display:flex; gap:8px; align-items:center; }
.stepbtn{
  height: 40px;
  min-width: 44px;
  border-radius: 10px;
  border: 1px solid var(--border2);
  background: color-mix(in oklab, var(--panel) 85%, #2b2d3a);
  color: var(--text);
  cursor:pointer;
  font-size: 16px;
  line-height: 1;
}
.stepbtn:hover{ filter: brightness(1.07); }

.clearwrap { display:flex; flex-direction: column; }

.game__result {
  padding: 12px;
  border-radius: 14px;
  border: 1px dashed color-mix(in oklab, var(--border) 80%, #ffffff);
  background: color-mix(in oklab, var(--panel) 75%, transparent);
}

.warn { padding: 12px; border-radius: 12px; border: 1px solid rgba(255,200,80,.35); background: rgba(255,200,80,.12); }

/* ====== RESULT CARD (FIX OVERLAP) ====== */
.gamecard{
  display:grid;
  grid-template-columns: 150px 1fr;
  gap: 14px;
  align-items: start;
  border-radius: 14px;
  overflow:hidden;
  border: 1px solid var(--border);
  background: var(--panel);
}
.gamecard__poster{
  width: 150px;
  aspect-ratio: 2/3;
  background: var(--panel2);
  display:flex;
  align-items:center;
  justify-content:center;
  flex: 0 0 auto;
}
.gamecard__poster img{
  width:100%;
  height:100%;
  object-fit:cover;
  display:block;
}
.gamecard__info{
  padding: 12px 12px 12px 0;
  min-width: 0;
}
.gamecard__title{
  font-weight: 900;
  font-size: 16px;
  margin: 2px 0 10px;
  overflow-wrap: anywhere;
}
.kv{ display:grid; gap:8px; margin-bottom: 10px; }
.kvRow{ display:grid; grid-template-columns: 90px 1fr; gap: 10px; align-items: baseline; min-width:0; }
.kvK{ opacity:.7; font-size: 13px; }
.kvV{ font-size: 13px; opacity:.95; overflow-wrap:anywhere; }

.gameDesc{
  opacity:.9;
  font-size: 13px;
  line-height: 1.45;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  overflow-wrap:anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ====== Autocomplete dropdown ====== */
.acWrap{ position: relative; }
.acDrop{
  position:absolute;
  top: calc(100% + 6px);
  left:0; right:0;
  z-index: 50;
  background: var(--panel);
  border: 1px solid var(--border2);
  border-radius: 12px;
  overflow:hidden;
  box-shadow: 0 12px 30px var(--shadow);
}
.acDrop.hidden{ display:none; }
.acItem{ padding: 10px 12px; cursor:pointer; font-size: 14px; }
.acItem:hover{ background: color-mix(in oklab, var(--panel) 70%, #3b3d4a); }
.acEmpty{ padding: 10px 12px; }

/* ====== Каталог ====== */
.catalogHead { display:flex; align-items:flex-end; justify-content:space-between; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.catalogControls { display:flex; align-items:center; gap: 10px; flex-wrap: wrap; }
.pp {
  display:flex; align-items:center; gap:8px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: color-mix(in oklab, var(--panel2) 60%, transparent);
}
.pp select { padding: 8px 10px; border-radius: 10px; border:1px solid var(--border2); background: var(--panel); color: var(--text); }
.activeFilters { margin-top: -6px; margin-bottom: 10px; opacity: .8; font-size: 13px; }
.moreBlock {
  margin: 16px 0 6px;
  display:flex; align-items:center; justify-content:space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: color-mix(in oklab, var(--panel2) 60%, transparent);
}

/* ====== Responsive ====== */
@media (max-width: 860px) {
  .movie { grid-template-columns: 1fr; }
  .game__filters { grid-template-columns: 1fr 1fr; }
  .fieldRow { grid-template-columns: 1fr; gap: 4px; }
}

@media (max-width: 720px) {
  .h1 { font-size: 22px; margin: 14px 0; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .catalogTitle { font-size: 14px; }
}

@media (max-width: 520px) {
  .game__filters { grid-template-columns: 1fr; }
  .decideUibtn { width: 100%; }
}

/* МОБИЛЬНЫЙ РЕЗУЛЬТАТ: как карточка фильма — вертикально */
@media (max-width: 480px) {
  .grid { grid-template-columns: 1fr; }

  .gamecard{
    grid-template-columns: 1fr;
    gap: 0;
  }
  .gamecard__poster{
    width: 100%;
    max-height: 420px;
  }
  .gamecard__info{
    padding: 12px;
  }
  .kvRow{ grid-template-columns: 1fr; gap: 2px; }
  .gameDesc{
    -webkit-line-clamp: 8;
  }
} /* <-- ВОТ ЭТОГО ЗАКРЫТИЯ У ТЕБЯ НЕ БЫЛО */

/* =========================
   ADMIN (PC table + Mobile cards + tools)
========================= */
.adminPage { margin-top: 16px; }
.adminHead { margin-bottom: 14px; }

.adminToolbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  flex-wrap: wrap;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: color-mix(in oklab, var(--panel2) 60%, transparent);
}

.adminWho { opacity:.9; }
.adminBtns { display:flex; gap:10px; flex-wrap: wrap; }

.adminTools{
  margin-top: 12px;
  display:flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
}

.adminSearch{
  flex: 1 1 320px;
}

.adminSearch input{
  width:100%;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--border2);
  background: var(--panel);
  color: var(--text);
}

.adminPP{
  display:flex;
  flex-direction: column;
  gap:6px;
}
.adminPP select{
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border2);
  background: var(--panel);
  color: var(--text);
}

.adminStat{
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: color-mix(in oklab, var(--panel2) 60%, transparent);
}

/* Таблица */
.adminTable{
  width: 100%;
  margin: 14px auto 0;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--panel);
  overflow: hidden;
}

/* 6 колонок: Контент | Жанры | Тип | Год | Режиссёр | Действия */
.adminTable__head{
  display:grid;
  grid-template-columns:
    minmax(260px, 1.45fr)
    minmax(220px, 1.1fr)
    0.5fr
    0.45fr
    minmax(220px, 1.1fr)
    minmax(240px, 1fr);
  gap: 14px;
  padding: 14px 14px;
  font-size: 12px;
  opacity: .75;
  background: color-mix(in oklab, var(--panel2) 55%, transparent);
  border-bottom: 1px solid var(--border);
}

.adminList{ display:grid; }

.adminItem{
  display:grid;
  grid-template-columns:
    minmax(260px, 1.45fr)
    minmax(220px, 1.1fr)
    0.5fr
    0.45fr
    minmax(220px, 1.1fr)
    minmax(240px, 1fr);
  gap: 14px;
  padding: 14px 14px;
  border-bottom: 1px solid var(--border);
  align-items:center;
}

.adminItem:last-child{ border-bottom: none; }

.adminContent{ min-width:0; }
.adminTitle{
  font-weight: 900;
  line-height: 1.2;
  overflow-wrap:anywhere;
}

.adminLink{
  display:inline-block;
  margin-top: 6px;
  font-size: 12px;
  opacity:.75;
  text-decoration: underline;
  text-decoration-color: color-mix(in oklab, var(--text) 25%, transparent);
}

.adminCell{ font-size: 13px; opacity:.92; min-width:0; }
.adminClamp{ overflow-wrap:anywhere; }

.adminActions{
  display:flex;
  gap:10px;
  justify-content:flex-end;
  align-items:center;
  flex-wrap: wrap;
}
.adminActions form{ margin: 0; }

.btn.danger{
  border-color: rgba(255,80,80,.35);
  background: rgba(255,80,80,.12);
}
.btn.danger:hover{ filter: brightness(1.08); }

.btn.disabled{
  pointer-events: none;
  opacity: .5;
}

/* Пагинация */
.adminPager{
  margin-top: 14px;
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: color-mix(in oklab, var(--panel2) 60%, transparent);
}
.adminPager__mid{ opacity:.85; }

/* Mobile: превращаем строки в карточки */
@media (max-width: 720px){
  .adminTable__head{ display:none; }

  .adminItem{
    grid-template-columns: 1fr;
    gap: 8px;
    align-items: start;
  }

  .adminActions{ justify-content:flex-start; }

  .adminCell::before{
    display:block;
    font-size: 11px;
    opacity:.7;
    margin-bottom: 2px;
  }

  /* подписи колонок на мобиле (после content идут: genres, type, year, director) */
  .adminItem > .adminCell:nth-child(2)::before{ content:"Жанры"; }
  .adminItem > .adminCell:nth-child(3)::before{ content:"Тип"; }
  .adminItem > .adminCell:nth-child(4)::before{ content:"Год"; }
  .adminItem > .adminCell:nth-child(5)::before{ content:"Режиссёр"; }
}
/* =========================
   ADMIN FORM (new/edit) – нормальный UI
========================= */
.adminFormPage { margin-top: 16px; }

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

.adminFormWrap{
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: color-mix(in oklab, var(--panel2) 65%, transparent);
}

.adminForm{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: start;
}

.adminForm .field{
  display:flex;
  flex-direction: column;
  gap: 6px;
}

.adminForm .field label{
  font-size: 12px;
  opacity: .82;
}

.adminForm input,
.adminForm select,
.adminForm textarea{
  width: 100%;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--border2);
  background: var(--panel);
  color: var(--text);
  outline: none;
}

.adminForm input:focus,
.adminForm select:focus,
.adminForm textarea:focus{
  border-color: color-mix(in oklab, var(--border2) 40%, #ffffff);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--panel) 30%, transparent);
}

.adminForm textarea{
  min-height: 120px;
  resize: vertical;
}

/* file input — чтобы не был “виндовый ужас” */
.adminForm input[type="file"]{
  padding: 10px 12px;
  background: color-mix(in oklab, var(--panel) 85%, #2b2d3a);
}

/* широкие поля */
.adminForm .span2{ grid-column: 1 / -1; }

/* кнопки снизу */
.adminFormActions{
  grid-column: 1 / -1;
  display:flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items:center;
  justify-content:flex-start;
  margin-top: 6px;
}

/* мобилка */
@media (max-width: 860px){
  .adminForm{ grid-template-columns: 1fr; }
}