:root {
  --bg: #f5f6f8; --card: #fff; --ink: #1c2230; --muted: #6b7382; --line: #e3e6eb;
  --accent: #2f6fed; --accent-ink: #fff; --danger: #d23b3b; --warn: #b36b00; --ok: #1d8a4b;
  --radius: 12px; --shadow: 0 1px 2px rgba(20,30,50,.06), 0 4px 16px rgba(20,30,50,.05);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111318; --card: #1a1d24; --ink: #e8eaef; --muted: #9aa1ae; --line: #2b303a;
          --accent: #5b8cff; --shadow: none; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font: 13px/1.3 ui-monospace, SFMono-Regular, Consolas, monospace; background: rgba(127,127,127,.12);
  padding: 1px 5px; border-radius: 4px; }
h1 { font-size: 26px; line-height: 1.2; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.warn { color: var(--warn); }
.err { color: var(--danger); margin: 0 0 10px; }

.top { display: flex; align-items: center; gap: 24px; padding: 0 20px; height: 56px;
  background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--ink); font-size: 16px; }
.brand:hover { text-decoration: none; }
.brand svg { width: 26px; height: 26px; fill: var(--accent); }
.top nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.top nav a { padding: 7px 12px; border-radius: 8px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.top nav a:hover { background: rgba(127,127,127,.1); text-decoration: none; }
.top nav a.on { color: var(--ink); background: rgba(47,111,237,.1); }
.logout { margin: 0; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 24px 20px 60px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.head p { margin: 0; }
.crumbs { margin: 0 0 8px; }
.flash { background: #e9f3ff; color: #0f3d8a; border: 1px solid #c7dcff; padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; }
@media (prefers-color-scheme: dark) { .flash { background: #172540; color: #cfe0ff; border-color: #29406b; } }
.note { background: #fff7e6; border: 1px solid #f2d59b; color: #6b4a00; padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; }
@media (prefers-color-scheme: dark) { .note { background: #2d2412; border-color: #5a4518; color: #f1d9a4; } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 16px; }
.split { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }
.sticky-col { position: sticky; top: 76px; }
@media (max-width: 900px) { .sticky-col { position: static; } }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 640px) { .grid3 { grid-template-columns: 1fr; } }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.row input[type=text], .row input:not([type]) { flex: 1; min-width: 160px; }

/* поля */
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line);
  border-radius: 9px; padding: 9px 11px; width: 100%; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,111,237,.18); }
select { appearance: none; -webkit-appearance: none; padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%236b7382' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; }
textarea { resize: vertical; font: 13px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace; }
input[type=color] { padding: 3px; height: 40px; width: 72px; cursor: pointer; }
input[type=file] { padding: 7px; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); margin: 2px 0 0; flex: none; cursor: pointer; }
.field.color { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.field.color > span { margin: 0; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 10px; cursor: pointer; }
.check.big { padding: 12px; border: 1px solid var(--line); border-radius: 10px; margin: 6px 0 14px; }
.pgroup { border: 0; margin: 0 0 14px; padding: 0 0 6px; border-bottom: 1px solid var(--line); }
.pgroup:last-of-type { border-bottom: 0; }
.pgroup legend { font-weight: 700; font-size: 14px; padding: 0; margin-bottom: 10px; }
[data-field].is-off { opacity: .45; }

/* кнопки */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: 600 14px/1 inherit;
  font-family: inherit; padding: 10px 16px; border-radius: 9px; border: 1px solid var(--line); background: var(--card);
  color: var(--ink); cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { border-color: #c5cad3; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.small { padding: 7px 11px; font-size: 13px; }
.btn.wide { width: 100%; }
.btn.top-save { margin-bottom: 16px; }

/* вход */
.auth { max-width: 380px; margin: 8vh auto 0; }
.auth h1 { margin-bottom: 2px; }

/* список роликов */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters input[type=search] { flex: 1 1 260px; width: auto; }
.filters select { width: auto; min-width: 150px; }
.folders { margin-bottom: 12px; }
.folders summary { cursor: pointer; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.folder-list { display: grid; gap: 6px; max-width: 640px; }
.folder-row { display: flex; gap: 8px; align-items: center; }
.folder-row input { flex: 1; }
.folder-row .muted { white-space: nowrap; font-size: 13px; }
.bulkbar { position: sticky; top: 64px; z-index: 5; display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--accent); border-radius: 10px; padding: 8px 12px; margin-bottom: 10px; }
.bulkbar select { width: auto; padding-top: 6px; padding-bottom: 6px; }
.bulkbar[hidden] { display: none; }
table.list { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.list th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted);
  padding: 10px; border-bottom: 1px solid var(--line); font-weight: 700; }
.list td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.list tr:last-child td { border-bottom: 0; }
.list tr.off td { opacity: .55; }
.list .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.list .chk { width: 34px; }
.list .th { width: 108px; }
.list .th img { width: 96px; height: 54px; object-fit: cover; border-radius: 6px; background: #0b0d12; display: block; }
.list a.t { font-weight: 600; color: var(--ink); }
.list.compact td, .list.compact th { padding: 6px 8px; font-size: 13px; }
@media (max-width: 700px) {
  .list th:nth-child(4), .list td:nth-child(4), .list th:nth-child(7), .list td:nth-child(7) { display: none; }
  .list .th { width: 76px; } .list .th img { width: 64px; height: 36px; }
}
.empty { background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); padding: 40px; text-align: center; color: var(--muted); }
.pager { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 16px; }
.pager a { padding: 6px 11px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); }
.pager a.on { background: var(--accent); color: #fff; border-color: var(--accent); }

/* страница ролика */
.preview { position: relative; width: 100%; background: #000; border-radius: var(--radius); overflow: hidden; margin-bottom: 16px; }
.preview iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
/* вертикальный ролик: не выше 72% окна, по центру (отступ сверху в % считается от ширины — пропорция сохраняется) */
.preview.portrait { width: min(100%, calc(72vh * var(--ar))); margin-left: auto; margin-right: auto; }
.code-block { margin-bottom: 12px; }
.code-block label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.code-block textarea, .code-block input { margin-bottom: 6px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 12px; }
.stats div { background: rgba(127,127,127,.07); border-radius: 10px; padding: 10px; }
.stats b { display: block; font-size: 22px; }
.stats span { font-size: 12px; color: var(--muted); }
@media (max-width: 520px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.poster { width: 100%; max-height: 360px; object-fit: contain; border-radius: 8px; background: #000; display: block; margin-bottom: 6px; }
.icon-prev { width: 72px; height: 72px; object-fit: contain; background: #333; border-radius: 10px; padding: 6px; }
.plain { margin: 0; padding-left: 18px; }
.danger-zone { display: flex; gap: 10px; flex-wrap: wrap; }
.danger-zone form { margin: 0; }
.meter { height: 10px; background: rgba(127,127,127,.18); border-radius: 5px; overflow: hidden; margin-bottom: 10px; }
.meter i { display: block; height: 100%; background: var(--accent); }
.token-new { background: rgba(29,138,75,.1); border: 1px solid rgba(29,138,75,.35); border-radius: 10px; padding: 12px; margin-bottom: 12px; }
.token-new input { margin: 8px 0; font-family: ui-monospace, Consolas, monospace; }

/* оформления плеера */
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.pcard { display: flex; flex-direction: column; gap: 10px; margin: 0; }
.pcard-head { display: flex; align-items: center; gap: 8px; }
.pcard-head h2 { margin: 0; }
.pcard .row form { margin: 0; }
.pill { display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  padding: 2px 8px; border-radius: 999px; background: rgba(47,111,237,.12); color: var(--accent); vertical-align: middle; }
.preview.small { margin-bottom: 0; }
.head .row input { min-width: 220px; }
