:root {
  --bg: #0b0d12;
  --bg-2: #12151c;
  --bg-3: #1a1e28;
  --line: #262b38;
  --text: #eceef3;
  --muted: #9aa1b2;
  --accent: #ff5a4f;
  --accent-2: #ff7a70;
  --ok: #3ecf8e;
  --warn: #f5b942;
  --bad: #ef5b5b;
  --radius: 12px;
  --gutter: clamp(14px, 4vw, 48px);
  --top-h: 64px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; border-radius: 8px; }
img { display: block; }

/* ---------- top bar ---------- */
.top {
  position: fixed; inset: 0 0 auto 0; z-index: 50;
  height: var(--top-h);
  display: flex; align-items: center; gap: 22px;
  padding: 0 var(--gutter);
  background: linear-gradient(180deg, rgba(11,13,18,.96), rgba(11,13,18,.72));
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255,255,255,.04);
}
.logo { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 20px; letter-spacing: .2px; }
.logo-mark {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
  background: var(--accent); color: #fff; font-size: 13px; padding-left: 2px;
}
.burger { background: none; border: 0; width: 42px; height: 42px; margin-left: -8px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.burger[hidden] { display: none; }
.burger.back { margin-left: -14px; }
.burger:hover { background: rgba(255,255,255,.07); }

/* ---------- drawer ---------- */
.drawer-back { position: fixed; inset: 0; z-index: 60; background: rgba(4,5,8,.6); backdrop-filter: blur(2px); }
.drawer-back[hidden] { display: none; }
.drawer {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 70; width: min(300px, 84vw);
  padding: 14px 12px; overflow-y: auto; background: #14171f; border-right: 1px solid var(--line);
  transform: translateX(-102%); transition: transform .22s ease; visibility: hidden;
}
.drawer.open { transform: none; visibility: visible; box-shadow: 14px 0 40px rgba(0,0,0,.5); }
.drawer nav { display: grid; gap: 2px; }
.drawer a { display: flex; align-items: center; gap: 16px; padding: 12px 16px; border-radius: 14px; font-weight: 600; color: #c9ceda; }
.drawer a:hover { background: rgba(255,255,255,.06); color: #fff; }
.drawer a.active { background: #f1f2f6; color: #14171f; }
.drawer hr { border: 0; border-top: 1px solid var(--line); margin: 8px 6px; }
.search { margin-left: auto; flex: 0 1 340px; }
.search input {
  width: 100%; height: 40px; padding: 0 14px 0 38px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%239aa1b2' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='8' cy='8' r='6'/%3E%3Cpath d='m13 13 4 4'/%3E%3C/svg%3E") no-repeat 12px center;
  outline: none;
}
.search input:focus { border-color: var(--accent); }
.status { background: none; border: 0; padding: 10px; border-radius: 50%; display: grid; place-items: center; }
.status i { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 3px rgba(255,255,255,.06); }
.status i.ok { background: var(--ok); }
.status i.bad { background: var(--bad); }
.status i.warn { background: var(--warn); }

main { padding-top: var(--top-h); min-height: 100vh; outline: none; }

/* ---------- hero ---------- */
.hero {
  position: relative; min-height: min(68vh, 560px);
  display: flex; align-items: flex-end;
  padding: 80px var(--gutter) 56px;
  background: var(--bg-2) center / cover no-repeat;
  isolation: isolate;
}
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    linear-gradient(90deg, rgba(11,13,18,.95) 0%, rgba(11,13,18,.55) 48%, rgba(11,13,18,.1) 100%),
    linear-gradient(0deg, var(--bg) 0%, rgba(11,13,18,0) 38%);
}
.hero-body { max-width: 620px; }
.hero h1 { margin: 0 0 8px; font-size: clamp(28px, 5vw, 52px); line-height: 1.08; letter-spacing: -.5px; }
.hero .meta { color: var(--muted); display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; font-weight: 600; }
.hero p { margin: 0 0 22px; color: #cfd3de; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.page-pad { height: 18px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 20px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg-3); font-weight: 700; white-space: nowrap;
}
.btn:hover { background: #232838; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.small { height: 36px; padding: 0 14px; font-size: 14px; }
.btn[disabled] { opacity: .5; cursor: default; }

/* ---------- rows / cards ---------- */
.row { margin: 26px 0 8px; }
.row h2 { margin: 0 var(--gutter) 12px; font-size: 20px; letter-spacing: -.2px; }
.rail-wrap { position: relative; }
.rail {
  display: flex; gap: 14px; overflow-x: auto; scroll-snap-type: x proximity;
  padding: 4px var(--gutter) 14px; scrollbar-width: none;
  scroll-padding: 0 var(--gutter); /* иначе snap прижимает первую карточку к краю */
}
.rail::-webkit-scrollbar { display: none; }
.arrow {
  position: absolute; top: 4px; bottom: 14px; width: 48px; z-index: 5; border: 0; font-size: 34px; color: #fff;
  opacity: 0; transition: opacity .15s; display: none;
}
.arrow.l { left: 0; background: linear-gradient(90deg, rgba(11,13,18,.9), transparent); }
.arrow.r { right: 0; background: linear-gradient(270deg, rgba(11,13,18,.9), transparent); }
@media (hover: hover) {
  .arrow { display: block; }
  .rail-wrap:hover .arrow, .arrow:focus-visible { opacity: 1; }
}
.arrow { width: 44px; }
.card { flex: 0 0 auto; width: clamp(120px, 15vw, 172px); scroll-snap-align: start; border-radius: var(--radius); }
.poster {
  position: relative; aspect-ratio: 2 / 3; border-radius: var(--radius); overflow: hidden;
  background: var(--bg-3); border: 1px solid var(--line);
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.poster img { width: 100%; height: 100%; object-fit: cover; }
.poster > span { display: grid; place-items: center; height: 100%; padding: 10px; text-align: center; color: var(--muted); font-weight: 600; }
.card:hover .poster, .card:focus-visible .poster { transform: translateY(-4px) scale(1.02); border-color: var(--accent); box-shadow: 0 10px 28px rgba(0,0,0,.5); }
.rate {
  position: absolute; top: 8px; left: 8px; padding: 2px 7px; border-radius: 999px; font-size: 12px;
  background: rgba(11,13,18,.82); color: var(--warn);
}
.cap { padding: 8px 2px 0; }
.cap span { display: block; font-weight: 600; font-size: 14px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cap small { color: var(--muted); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(clamp(120px, 15vw, 172px), 1fr)); gap: 18px 14px; padding: 0 var(--gutter) 40px; }
.grid .card { width: auto; }
.page-title { margin: 28px var(--gutter) 16px; font-size: 26px; }

/* ---------- skeleton / empty ---------- */
.skel { height: 260px; margin: 22px var(--gutter); border-radius: var(--radius); background: linear-gradient(100deg, var(--bg-2) 30%, var(--bg-3) 50%, var(--bg-2) 70%) 0 0 / 300% 100%; animation: shimmer 1.3s infinite linear; }
@keyframes shimmer { to { background-position: -300% 0; } }
.notice { margin: 28px var(--gutter); padding: 18px 20px; border-radius: var(--radius); background: var(--bg-2); border: 1px solid var(--line); }
.notice.err { border-color: rgba(239,91,91,.5); }
.notice b { display: block; margin-bottom: 4px; }
.notice code { background: var(--bg-3); padding: 1px 6px; border-radius: 6px; }

/* ---------- title page ---------- */
.t-hero { position: relative; padding: 40px var(--gutter) 28px; background: var(--bg-2) center top / cover no-repeat; isolation: isolate; }
.t-hero::before { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(0deg, var(--bg) 4%, rgba(11,13,18,.82) 60%, rgba(11,13,18,.7)); }
.t-wrap { display: grid; grid-template-columns: minmax(130px, 240px) 1fr; gap: clamp(16px, 3vw, 36px); align-items: start; padding-top: 18px; }
.t-poster { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); aspect-ratio: 2/3; background: var(--bg-3); }
.t-poster img { width: 100%; height: 100%; object-fit: cover; }
.t-info h1 { margin: 0 0 4px; font-size: clamp(26px, 4vw, 44px); line-height: 1.1; letter-spacing: -.5px; }
.t-info .orig { color: var(--muted); margin-bottom: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.chip { padding: 3px 11px; border-radius: 999px; background: rgba(255,255,255,.07); font-size: 13px; font-weight: 600; }
.chip.rating { color: var(--warn); }
.tagline { color: var(--accent-2); font-style: italic; margin: 6px 0; }
.overview { max-width: 760px; color: #d4d8e3; }

.section { margin: 30px var(--gutter); }
.section > h2 { margin: 0 0 14px; font-size: 20px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; align-items: center; }
.filters input[type=search], .filters select {
  height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-2); padding: 0 12px; min-width: 0;
}
.filters input[type=search] { flex: 1 1 180px; max-width: 320px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { height: 36px; padding: 0 12px; background: var(--bg-2); border: 0; border-right: 1px solid var(--line); color: var(--muted); font-weight: 600; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent); color: #fff; }

.tors { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.tor {
  display: grid; grid-template-columns: 1fr auto auto; gap: 14px; align-items: center;
  padding: 12px 14px; border-radius: var(--radius); background: var(--bg-2); border: 1px solid var(--line);
}
.tor:hover { border-color: #3a4156; }
.t-title { font-weight: 600; overflow-wrap: anywhere; line-height: 1.35; }
.t-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.tag { padding: 1px 8px; border-radius: 6px; background: var(--bg-3); color: var(--muted); font-size: 12px; font-weight: 700; }
.tag.q { color: #fff; background: #3b4766; }
.tag.q2160 { background: #8b5cf6; }
.tag.q1080 { background: #2f7de1; }
.tag.q720 { background: #2a9d8f; }
.tag.voice { color: #c7cbd6; font-weight: 600; }
.t-side { display: grid; gap: 2px; text-align: right; font-size: 13px; color: var(--muted); min-width: 92px; }
.seed { font-weight: 800; font-size: 15px; }
.seed.ok { color: var(--ok); } .seed.warn { color: var(--warn); } .seed.bad { color: var(--bad); }
.empty { color: var(--muted); padding: 22px; text-align: center; background: var(--bg-2); border: 1px dashed var(--line); border-radius: var(--radius); }
.more-note { color: var(--muted); font-size: 13px; margin-top: 10px; }

.cast { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: thin; }
.person { display: block; flex: 0 0 96px; text-align: center; font-size: 13px; }
.person .ph { width: 76px; height: 76px; border-radius: 50%; margin: 0 auto 6px; background: var(--bg-3) center / cover; border: 1px solid var(--line); }
.person small { color: var(--muted); display: block; }

a.person:hover .ph { border-color: var(--accent); }
.btn.fav.on { color: var(--accent-2); border-color: var(--accent); }
.actions .btn { margin: 0; }

.card { position: relative; }
.rm { position: absolute; top: 6px; right: 6px; z-index: 3; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(11,13,18,.85); color: #fff; font-size: 13px; opacity: .85; }
.rm:hover { background: var(--bad); opacity: 1; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile { padding: 18px 14px; border-radius: var(--radius); background: var(--bg-2); border: 1px solid var(--line); font-weight: 700; text-align: center; }
.tile:hover { border-color: var(--accent); background: var(--bg-3); }
.tile.net { background: linear-gradient(135deg, #1e2433, #161a24); }

.fform { margin: 0 var(--gutter) 18px; }
.fform input[type=number] { width: 96px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-2); padding: 0 10px; }
.more-wrap { display: grid; place-items: center; padding: 0 var(--gutter) 30px; }
.more-wrap .notice { margin: 0; width: 100%; }

.pcard { text-align: center; }
.pcard .ph { aspect-ratio: 1; border-radius: 50%; background: var(--bg-3) center / cover; border: 1px solid var(--line); margin-bottom: 8px; transition: border-color .15s, transform .15s; }
.pcard:hover .ph { border-color: var(--accent); transform: scale(1.03); }
.pcard b { display: block; font-size: 14px; line-height: 1.25; }
.pcard small { color: var(--muted); }
.grid:has(.pcard) { grid-template-columns: repeat(auto-fill, minmax(clamp(110px, 12vw, 150px), 1fr)); }
.p-head { display: grid; grid-template-columns: 160px 1fr; gap: clamp(16px, 3vw, 32px); padding: 34px var(--gutter) 6px; align-items: start; }
.p-head h1 { margin: 0 0 4px; font-size: clamp(26px, 4vw, 40px); }
.p-head .orig { color: var(--muted); margin-bottom: 10px; }
.p-head .ph.big { width: 160px; height: 160px; border-radius: 50%; background: var(--bg-3) center / cover; border: 1px solid var(--line); }
.bio { display: -webkit-box; -webkit-line-clamp: 8; -webkit-box-orient: vertical; overflow: hidden; }
.page-title.sm { font-size: 20px; margin-top: 22px; }

/* ---------- modal player ---------- */
.modal-back { position: fixed; inset: 0; z-index: 100; background: rgba(4,5,8,.82); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 14px; overflow-y: auto; }
.modal { position: relative; width: min(980px, 100%); max-height: calc(100vh - 28px); overflow-y: auto; background: var(--bg-2); border: 1px solid var(--line); border-radius: 16px; padding: 22px; }
.modal h3 { margin: 0 44px 2px 0; font-size: 20px; }
.modal .sub { margin: 0 0 16px; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.x { position: absolute; top: 12px; right: 12px; width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--bg-3); font-size: 18px; }
.x:hover { background: #2a3040; }
.loading { display: flex; align-items: center; gap: 14px; padding: 26px 4px; }
.spin { width: 26px; height: 26px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
video { width: 100%; max-height: 62vh; background: #000; border-radius: 10px; display: block; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.hint { padding: 10px 14px; border-radius: 10px; background: rgba(245,185,66,.1); border: 1px solid rgba(245,185,66,.4); color: #f3d38b; margin: 10px 0; font-size: 14px; }
.hint.info { background: rgba(255,255,255,.04); border-color: var(--line); color: var(--muted); }
.hint.err { background: rgba(239,91,91,.1); border-color: rgba(239,91,91,.5); color: #f6aaaa; }
.files { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 6px; max-height: 280px; overflow-y: auto; }
.file { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; width: 100%; text-align: left; padding: 10px 12px; border-radius: 10px; background: var(--bg-3); border: 1px solid transparent; }
.file:hover { border-color: #3a4156; }
.file.on { border-color: var(--accent); background: rgba(255,90,79,.1); }
.file .ep { min-width: 46px; font-weight: 800; color: var(--accent-2); }
.file .nm { overflow-wrap: anywhere; font-size: 14px; }
.file .sz { color: var(--muted); font-size: 13px; }

/* ---------- toasts ---------- */
.toasts { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 200; display: grid; gap: 8px; width: min(440px, calc(100% - 28px)); }
.toast { padding: 12px 16px; border-radius: 12px; background: #232838; border: 1px solid #3a4156; box-shadow: 0 8px 28px rgba(0,0,0,.5); animation: pop .2s ease; }
.toast.err { border-color: rgba(239,91,91,.6); }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .top { gap: 10px; }
  .logo span:last-child { display: none; }
  .search { flex: 1 1 140px; }
  .t-wrap { grid-template-columns: 110px 1fr; }
  .p-head { grid-template-columns: 96px 1fr; }
  .p-head .ph.big { width: 96px; height: 96px; }
  .tor { grid-template-columns: 1fr auto; }
  .tor .btn { grid-column: 1 / -1; width: 100%; }
  .t-side { text-align: left; display: flex; gap: 12px; align-items: baseline; grid-column: 1 / -1; grid-row: 2; }
  .hero { min-height: 52vh; padding-bottom: 36px; }
  .modal { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
