:root {
  --bg: #0f0f16;
  --panel: #1a1a25;
  --card: #22222f;
  --line: #2b2b3a;
  --text: #f2f2f5;
  --muted: #a0a0b2;
  --accent: #e53935;
  --ok: #43a047;
  --warn: #ffb74d;
}
* { box-sizing: border-box; }
/* Rules below set display on elements that are toggled with the hidden attribute. */
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 "Segoe UI", system-ui, -apple-system, sans-serif; }
/* No visible scroll bars: pages, rows and drawers scroll by wheel, touch and keys. */
* { scrollbar-width: none; }
*::-webkit-scrollbar { display: none; }
a { color: inherit; }
button { padding: 9px 18px; border-radius: 6px; border: 0; background: var(--accent); color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
button.ghost { background: #2c2c3c; }
button.small { padding: 4px 10px; font-size: 13px; }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, a:focus-visible, .card:focus-visible, .rel:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input, select { padding: 8px 10px; border-radius: 6px; border: 1px solid #343447; background: var(--panel); color: var(--text); font: inherit; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 13px; }

/* Login */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-box { width: min(360px, 100%); display: grid; gap: 14px; padding: 32px; background: var(--panel); border-radius: 12px; }
.login-box h1 { margin: 0 0 6px; text-align: center; }
.login-box label { display: grid; gap: 6px; color: var(--muted); font-size: 14px; }
.login-logo { width: 56px; margin: 0 auto; }
.error { color: #ff8a80; min-height: 1.3em; }
.hint { color: var(--muted); font-size: 13px; margin: 0; text-align: center; }

/* Layout */
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 20px; text-decoration: none; letter-spacing: .2px; flex: none; }
.logo img { width: 28px; height: 28px; }

/* Admin header: many tabs, wraps. */
.adminbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 20px; padding: 10px 28px; background: rgba(15,15,22,.96); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.adminbar nav { display: flex; gap: 14px; flex-wrap: wrap; }
.adminbar nav a { color: var(--muted); text-decoration: none; }
.adminbar nav a.active, .adminbar nav a:hover { color: var(--text); }
.user-menu { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }

/* App header: one 64 px row inside the page container. */
/* No backdrop-filter: it would make the bar the containing block of the
   fixed drawer and the phone menus, cutting them to the bar's height. */
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(15,15,22,.97); border-bottom: 1px solid var(--line); }
.topbar .bar { max-width: 1600px; margin: 0 auto; height: 64px; padding: 0 28px; display: flex; align-items: center; gap: 24px; }
.topbar .icon { display: none; flex: none; width: 40px; height: 40px; padding: 8px; border-radius: 8px; background: transparent; color: var(--text); }
.topbar .icon:hover { background: #ffffff14; }
.topbar .icon svg { width: 24px; height: 24px; display: block; }
.nav { display: flex; align-items: center; gap: 4px; min-width: 0; }
.nav > a, .dd-btn { display: inline-flex; align-items: center; gap: 4px; height: 40px; padding: 0 12px; border-radius: 8px; color: var(--muted); text-decoration: none;
  background: transparent; font-weight: 500; font-size: 15px; white-space: nowrap; transition: color .15s, background .15s; }
.nav > a:hover, .dd-btn:hover, .dd.open > .dd-btn { color: var(--text); background: #ffffff0f; }
.nav > a.active, .dd.active > .dd-btn { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); border-radius: 8px 8px 0 0; }
.caret { width: 12px; height: 12px; transition: transform .15s; }
.dd { position: relative; }
.dd.open .caret { transform: rotate(180deg); }
.dd-menu { position: absolute; top: calc(100% + 6px); left: 0; min-width: 200px; padding: 6px; display: flex; flex-direction: column; background: #1b1b27; border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 12px 32px #0009; opacity: 0; visibility: hidden; transform: translateY(-4px); transition: opacity .12s, transform .12s, visibility 0s linear .12s; z-index: 30; }
.dd-menu.right { left: auto; right: 0; }
/* Visible at once when opening, so the first item can take focus. */
.dd.open > .dd-menu { opacity: 1; visibility: visible; transform: none; transition: opacity .12s, transform .12s, visibility 0s; }
.dd-menu a { padding: 9px 12px; border-radius: 6px; color: var(--text); text-decoration: none; white-space: nowrap; }
.dd-menu a:hover, .dd-menu a:focus-visible { background: #ffffff12; outline: none; }
.dd-menu a[aria-current=page] { color: var(--accent); }
.search { position: relative; margin-left: auto; flex: 0 1 320px; min-width: 160px; }
.search input { width: 100%; height: 40px; padding: 0 12px 0 38px; border-radius: 20px; background: #1d1d29; border-color: #303042; }
.search input:focus { outline: none; border-color: var(--accent); background: #22222f; }
.search-ico { position: absolute; left: 12px; top: 10px; width: 20px; height: 20px; color: var(--muted); pointer-events: none; }
.profile .dd-btn { gap: 8px; padding: 0 8px 0 4px; color: var(--text); }
.ava { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; font-weight: 700; font-size: 14px; flex: none; }
#whoami { max-width: 140px; overflow: hidden; text-overflow: ellipsis; }

/* Tablet: tighter items, the name goes, the search narrows. */
@media (max-width: 1240px) {
  .topbar .bar { gap: 14px; padding: 0 20px; }
  .nav > a, .dd-btn { padding: 0 9px; }
  #whoami { display: none; }
  .search { flex-basis: 240px; }
}
/* Narrow: the sections move into a drawer behind the menu button. */
@media (max-width: 1023px) {
  .topbar .burger { display: block; }
  .nav { display: none; position: fixed; top: 64px; left: 0; right: 0; bottom: 0; flex-direction: column; align-items: stretch; gap: 2px; padding: 12px 16px 24px;
    background: var(--bg); overflow-y: auto; z-index: 25; }
  .nav-open .nav { display: flex; }
  .nav > * { flex: none; }
  .nav > a, .nav .dd-btn { height: 48px; font-size: 17px; color: var(--text); }
  .nav > a.active, .nav .dd.active > .dd-btn { box-shadow: inset 3px 0 0 var(--accent); border-radius: 0 8px 8px 0; }
  .nav .dd-btn .caret { display: none; }
  .nav .dd-menu { position: static; opacity: 1; visibility: visible; transform: none; box-shadow: none; border: 0; background: transparent; padding: 0 0 6px 16px; min-width: 0; }
  .nav .dd-menu a { padding: 12px; color: var(--muted); }
  .search { flex: 1 1 auto; }
}
/* Phone: the search opens as a row under the bar. */
@media (max-width: 640px) {
  .topbar .bar { padding: 0 8px; gap: 6px; }
  .topbar .search-toggle { display: block; margin-left: auto; }
  .search { display: none; position: absolute; top: 64px; left: 0; right: 0; margin: 0; padding: 8px 12px 12px; background: var(--bg); border-bottom: 1px solid var(--line); }
  .search-ico { left: 24px; top: 18px; }
  .search-open .search { display: block; }
  .logo span { display: inline; }
  .dd-menu.right { position: fixed; top: 64px; right: 8px; }
}

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 8px; }
.chip { padding: 5px 12px; border-radius: 16px; border: 1px solid var(--line); color: var(--muted); text-decoration: none; font-size: 14px; }
.chip.active, .chip:hover { color: var(--text); border-color: var(--accent); }
.chip span { opacity: .6; }
label.check { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 14px; }
.card .sum { font-size: 11px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 2px; }
.rel .h .src { font-weight: 400; color: var(--muted); font-size: 13px; margin-left: 10px; }
h2 a { color: inherit; text-decoration: none; }
h2 a:hover { color: var(--accent); }
main { padding: 16px 28px 90px; max-width: 1600px; margin: 0 auto; }
h2 { font-size: 20px; margin: 24px 0 12px; }
.empty { color: var(--muted); padding: 32px 0; }
.status { color: var(--warn); min-height: 1.4em; margin-top: 8px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 8px 0 16px; }

/* Cards */
.rowwrap { position: relative; }
.rowbtn { position: absolute; top: 0; bottom: 8px; width: 48px; z-index: 2; padding: 0; border-radius: 0; font-size: 34px; line-height: 1; color: #fff; opacity: 0; transition: opacity .15s; }
.rowbtn.prev { left: 0; background: linear-gradient(90deg, var(--bg) 20%, transparent); }
.rowbtn.next { right: 0; background: linear-gradient(270deg, var(--bg) 20%, transparent); }
.rowwrap:hover .rowbtn { opacity: .9; }
@media (hover: none) { .rowbtn { display: none; } }
.row { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x proximity; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 18px; }
.card { position: relative; width: 160px; flex: none; cursor: pointer; border-radius: 8px; overflow: hidden; background: var(--card); aspect-ratio: 2 / 3; transition: transform .12s; scroll-snap-align: start; text-decoration: none; }
.grid .card { width: auto; }
.card:hover, .card:focus { transform: scale(1.04); box-shadow: 0 0 0 2px var(--accent); }
.card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .cap { position: absolute; bottom: 0; left: 0; right: 0; padding: 8px; background: linear-gradient(transparent, rgba(0,0,0,.92)); }
.card .name { font-size: 13px; font-weight: 600; }
.card .sub { font-size: 11px; color: var(--muted); }
.card .ph { padding: 12px; color: var(--muted); }
.card .bar { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--accent); }

/* Title page */
.title { display: flex; gap: 32px; flex-wrap: wrap; }
/* A wide Kinopoisk cover behind the card, faded into the page. */
.title.with-cover { position: relative; isolation: isolate; padding: 24px; border-radius: 12px; overflow: hidden; }
.title.with-cover::before { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(90deg, var(--bg) 25%, rgba(15,15,22,.75)), var(--cover) center / cover; }
.title .poster { width: 260px; max-width: 100%; flex: none; aspect-ratio: 2 / 3; border-radius: 8px; background: var(--card) center / cover; }
.title .info { flex: 1; min-width: 280px; }
.title h1 { margin: 0 0 4px; font-size: 30px; }
.meta { color: var(--muted); }
.desc { max-width: 900px; margin: 12px 0; }
.releases { margin-top: 12px; display: grid; gap: 8px; }
.rel { padding: 10px 14px; background: var(--panel); border-radius: 6px; cursor: pointer; }
.rel:hover { background: #262636; }
.rel .h { font-weight: 600; }
.rel .s, .rel .t { color: var(--muted); font-size: 13px; }
.seasons { margin: 12px 0; display: flex; gap: 8px; flex-wrap: wrap; }

/* Player */
.player { position: relative; background: #000; width: 100%; aspect-ratio: 16 / 9; max-height: calc(100vh - 160px); border-radius: 8px; overflow: hidden; }
.player video { width: 100%; height: 100%; display: block; background: #000; }
.player .overlay { position: absolute; top: 10px; right: 12px; padding: 6px 10px; background: rgba(0,0,0,.6); border-radius: 6px; font-size: 13px; }
.player .spinner { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); pointer-events: none; }
.controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 0; }
.controls input[type=range] { flex: 1; min-width: 200px; accent-color: var(--accent); }
.controls .time { font-variant-numeric: tabular-nums; color: var(--muted); }
.player:fullscreen { max-height: none; border-radius: 0; }

/* Panels */
.panel { background: var(--panel); border-radius: 10px; padding: 16px 18px; margin-bottom: 16px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.stat { background: var(--panel); border-radius: 10px; padding: 14px 16px; }
.stat b { display: block; font-size: 24px; }
.stat span { color: var(--muted); font-size: 13px; }
.settings label { display: flex; align-items: center; gap: 12px; margin: 8px 0; flex-wrap: wrap; }
.settings label span { width: 320px; max-width: 100%; }
.diag { font: 13px/1.6 ui-monospace, Consolas, monospace; color: var(--muted); white-space: pre-wrap; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 10px; background: #2c2c3c; font-size: 12px; }
.tag.ok { background: #1b3d1f; }
.tag.bad { background: #4a1c1c; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; }
.charts .bars { height: 90px; margin-top: 8px; }
ul.hints { margin: 0; padding-left: 18px; color: var(--warn); }
.bars div { flex: 1; background: var(--accent); min-height: 2px; border-radius: 2px 2px 0 0; }
footer#nowplaying { position: fixed; bottom: 0; left: 0; right: 0; display: flex; gap: 16px; align-items: center; padding: 10px 28px; background: #181824; border-top: 1px solid var(--line); }
footer .bar { flex: 1; height: 4px; background: #333; border-radius: 2px; overflow: hidden; }
footer .bar div { height: 100%; background: var(--accent); }
.code { font: 700 32px ui-monospace, monospace; letter-spacing: 4px; }

@media (max-width: 700px) {
  .adminbar { padding: 10px 14px; gap: 10px; }
  main { padding: 12px 14px 90px; }
  .card { width: 128px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
}

.site-footer { color: var(--muted); font-size: 13px; text-align: center; padding: 24px 16px 96px; }
.site-footer a { color: var(--muted); }
.banner { margin: 12px 28px 0; padding: 10px 14px; border-radius: 8px; background: #2a1f1f; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.downloads a { display: inline-block; margin: 2px 6px; }
pre.cmd { background: var(--panel); padding: 10px 12px; border-radius: 6px; overflow-x: auto; font-size: 13px; }
