:root {
  --bg: #121417; --card: #1c2027; --fg: #e8eaed; --muted: #9aa3ad;
  --accent: #4f9cf9; --danger: #f06a6a; --ok: #5ec27f; --line: #2a2f38;
}
* { box-sizing: border-box; }
html { color-scheme: dark; }
body { margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.top { display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; color: var(--fg); font-size: 18px; }
.top nav { display: flex; gap: 16px; align-items: center; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 16px; }
.foot { padding: 16px; color: var(--muted); text-align: center; font-size: 13px; }
h1 { font-size: 24px; margin: 0 0 12px; }
h2 { font-size: 18px; margin: 20px 0 8px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--danger); }
.flash { padding: 10px 14px; border-radius: 8px; background: #2a2f38; }
.flash.error { background: #4a2626; }
.flash.ok { background: #244a31; }
.card { background: var(--card); border-radius: 12px; padding: 20px; }
.card.narrow { max-width: 480px; margin: 24px auto; }
label { display: block; margin: 12px 0; color: var(--muted); }
input[type=text], input[type=email], textarea, .share, input.title {
  width: 100%; margin-top: 6px; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: #0f1114; color: var(--fg); font: inherit; }
input.code { font-size: 26px; letter-spacing: 6px; text-transform: uppercase; text-align: center; }
input[type=file] { margin-top: 6px; color: var(--muted); }
.btn { display: inline-block; padding: 10px 18px; border-radius: 8px; border: 0;
  background: var(--accent); color: #fff; font: inherit; cursor: pointer; }
.btn:hover { text-decoration: none; filter: brightness(1.1); }
.btn.small { padding: 6px 12px; font-size: 14px; }
button.link { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 0; }
button.link.danger { color: var(--danger); }
.inline { display: inline; }
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* загрузки */
.trow { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.tmain { flex: 1; min-width: 0; }
.tname { color: var(--fg); font-weight: 600; word-break: break-word; }
.tstate { color: var(--muted); font-size: 14px; margin-top: 2px; }
.bar { height: 6px; background: #0f1114; border-radius: 3px; margin-top: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); transition: width .5s; }

/* плитки */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-top: 12px; }
.tile { background: var(--card); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.poster { display: block; position: relative; aspect-ratio: 16/9; background: #0f1114; }
.poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.noposter { display: flex; align-items: center; justify-content: center; height: 100%; font-size: 40px; }
.badge { position: absolute; left: 8px; bottom: 8px; padding: 3px 8px; border-radius: 6px;
  background: rgba(0,0,0,.7); font-size: 12px; color: #fff; }
.badge.err { background: var(--danger); }
.tinfo { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; }
input.title { padding: 6px 8px; font-weight: 600; background: transparent; border-color: transparent; }
input.title:focus { background: #0f1114; border-color: var(--line); }
.meta { font-size: 13px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.share { flex: 1; min-width: 120px; padding: 6px 8px; font-size: 12px; color: var(--muted); margin: 0; }
.files { list-style: none; padding: 0; margin: 8px 0 16px; }
.files li { padding: 6px 0; border-bottom: 1px solid var(--line); word-break: break-word; }
.files label { margin: 0; color: var(--fg); display: flex; gap: 8px; align-items: baseline; }
.files .fname { flex: 1; }
.files li.picked { color: var(--fg); }

/* плеер */
body.watch .wrap { max-width: 1280px; }
.wtitle { font-size: 20px; }
.player video { width: 100%; max-height: 80vh; background: #000; border-radius: 8px; display: block; }
.controls { display: flex; gap: 16px; align-items: center; margin-top: 8px; min-height: 28px; flex-wrap: wrap; }
.controls label { margin: 0; display: inline-flex; gap: 8px; align-items: center; }
.controls select { padding: 4px 8px; border-radius: 6px; background: #0f1114; color: var(--fg); border: 1px solid var(--line); font: inherit; }
.resume { background: var(--ok); color: #000; padding: 4px 10px; border-radius: 6px; font-size: 14px; }
.waiting { text-align: center; padding: 24px; background: var(--card); border-radius: 12px; }
.waiting img { max-width: 480px; width: 100%; border-radius: 8px; }

@media (max-width: 600px) {
  .wrap { padding: 10px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
  .top nav { gap: 10px; font-size: 14px; }
}

/* сериалы и скачивание */
.btn.ghost { background: transparent; border: 1px solid var(--accent); color: var(--accent); }
.stitle { color: var(--fg); font-weight: 600; padding: 6px 8px; display: block; }
.tile.series .badge { background: rgba(79,156,249,.85); }
.episodes { margin-top: 20px; }
.episodes ol { padding-left: 24px; }
.episodes li.current { color: var(--fg); }
.episodes .dl { margin-left: 8px; }

/* полоска «смотрели до» на постере */
.seen { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255,255,255,.25); }
.seen i { display: block; height: 100%; background: var(--accent); }

/* «Сделать общим» */
.shared-form { margin: 2px 0 6px; }
label.check { display: inline-flex; gap: 8px; align-items: center; margin: 0; font-size: 14px; cursor: pointer; }
label.check input { width: auto; margin: 0; }

/* поиск по трекерам */
.search-form { display: flex; gap: 8px; margin: 8px 0; }
.search-form input { flex: 1; margin: 0; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: #0f1114; color: var(--fg); font: inherit; }
.results { overflow-x: auto; }
.rtable { width: 100%; border-collapse: collapse; font-size: 14px; }
.rtable th { text-align: left; color: var(--muted); font-weight: 500; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.rtable td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.rtable .rtitle a { color: var(--fg); }
.nowrap { white-space: nowrap; }
.ok { color: var(--ok); }
button.link.small { font-size: 13px; margin-left: 8px; }

/* панель действий под плеером и блок «Другие фильмы» */
.wactions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 6px 0 12px; }
.wactions .keys { margin-left: auto; }
.others { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 12px 0 16px;
  padding: 12px 14px; background: var(--card); border-radius: 12px; }
.others .share { flex: 1; min-width: 200px; }

/* крупные кнопки под видео */
.bigbar { display: flex; gap: 10px; justify-content: center; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.bigbtn { display: inline-flex; align-items: center; justify-content: center; gap: 2px;
  min-width: 64px; height: 64px; padding: 0 14px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--card); color: var(--fg); font: inherit; font-size: 28px; line-height: 1;
  cursor: pointer; text-decoration: none; }
.bigbtn small { font-size: 13px; color: var(--muted); }
.bigbtn.play { min-width: 96px; height: 76px; font-size: 38px; background: var(--accent); border-color: var(--accent); color: #fff; }
.bigbtn:hover, .bigbtn:focus-visible { filter: brightness(1.2); text-decoration: none; outline: 3px solid #fff; outline-offset: 2px; }
.bigbtn.off { opacity: .3; cursor: default; pointer-events: none; }
@media (max-width: 600px) {
  .bigbtn { min-width: 52px; height: 54px; padding: 0 10px; font-size: 24px; }
  .bigbtn.play { min-width: 76px; height: 64px; font-size: 32px; }
}

/* оценка */
.rating { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 4px 0 10px; }
.stars { display: inline-flex; gap: 2px; }
.star { background: none; border: 0; font-size: 30px; line-height: 1; color: #3a4150; cursor: pointer; padding: 0 2px; }
.star.on { color: #f5c518; }
.star:focus-visible { outline: 2px solid #fff; border-radius: 4px; }

/* сдвиг звука */
.sync { margin: 8px 0 12px; }
.sync summary { cursor: pointer; }
.sync-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 8px; }

/* Объединение сериалов и переименование */
.merge-form, .title-form { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; margin: .5rem 0; }
.merge-form select, .title-form input { max-width: 100%; padding: .3rem .5rem; border: 1px solid var(--line, #ccd); border-radius: 6px; background: inherit; color: inherit; font: inherit; }
.tile .merge-form { margin: .25rem 0 0; width: 100%; }
.tile .merge-form select { flex: 1; min-width: 0; font-size: .85rem; }

/* Описание фильма или сериала */
.plot { margin: .6rem 0 .8rem; max-width: 60rem; white-space: pre-line; line-height: 1.5; }
.describe-form { margin: .4rem 0 .8rem; }
.describe-form textarea { width: 100%; max-width: 60rem; padding: .5rem; border: 1px solid var(--line, #ccd); border-radius: 6px; background: inherit; color: inherit; font: inherit; resize: vertical; }
.describe-form .row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-top: .4rem; }

/* Код для приставки */
.tvcode { display: flex; gap: .6rem; align-items: flex-start; margin: .6rem 0; padding: .6rem .8rem; border: 1px dashed var(--line, #ccd); border-radius: 8px; max-width: 60rem; }
.tvcode .tvicon { font-size: 1.4rem; line-height: 1; }
.tvcode .code { font-family: ui-monospace, Consolas, monospace; font-size: 1.35rem; font-weight: 700; letter-spacing: .15em; padding: 0 .3rem; }

/* Разделы «Фильмы» и «Сериалы» */
.sections { display: flex; gap: 1rem; margin: .4rem 0 .2rem; }
.sections a { text-decoration: none; font-weight: 600; padding: .25rem .7rem; border: 1px solid var(--line, #ccd); border-radius: 999px; }
.section-title { margin: 1.2rem 0 .6rem; font-size: 1.25rem; scroll-margin-top: 4rem; }
.section-title .muted { font-weight: 400; font-size: .9em; }
