:root {
  --bg: #0e0f12;
  --panel: #17191e;
  --panel-2: #1f2229;
  --line: #2a2e37;
  --text: #e9eaee;
  --muted: #8c92a0;
  --accent: #ff5a36;
  --accent-2: #ff8a6b;
  --ok: #3ccf8e;
  --warn: #f2b84b;
  --err: #ff5c6c;
  --radius: 12px;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* иначе display: flex у элемента перебивает атрибут hidden */
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { min-height: 100vh; line-height: 1.5; }
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; color: inherit; }

header.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  padding: 14px clamp(16px, 4vw, 40px);
  background: rgba(14, 15, 18, .85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.logo { font-weight: 800; letter-spacing: .08em; font-size: 20px; display: flex; align-items: center; gap: 8px; }
.logo i { width: 12px; height: 12px; border-radius: 3px; background: var(--accent); display: inline-block; transform: rotate(45deg); }
header.top .spacer { flex: 1; }
.search {
  width: min(360px, 45vw); padding: 9px 14px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line); outline: none;
}
.search:focus { border-color: var(--accent); }

main { padding: 24px clamp(16px, 4vw, 40px) 60px; max-width: 1400px; margin: 0 auto; }
h1 { font-size: 26px; margin: 0 0 18px; }
h2 { font-size: 18px; margin: 0 0 12px; }
.muted { color: var(--muted); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 22px; }
.card { display: block; border-radius: var(--radius); overflow: hidden; background: var(--panel); transition: transform .15s; }
.card:hover { transform: translateY(-3px); }
.thumb { position: relative; aspect-ratio: 16 / 9; background: #000 center / cover no-repeat; }
.thumb .dur {
  position: absolute; right: 8px; bottom: 8px; padding: 1px 7px; border-radius: 6px;
  background: rgba(0, 0, 0, .75); font-size: 12px; font-variant-numeric: tabular-nums;
}
.card .meta { padding: 10px 14px 14px; }
.card .title { font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
/* Список видео на сайте — строки как в админке */
.list { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.vrow { display: flex; align-items: center; gap: 16px; padding: 12px 16px; border-bottom: 1px solid var(--line); transition: background .15s; }
.vrow:last-child { border-bottom: 0; }
.vrow:hover { background: var(--panel-2); }
.vrow .thumb { flex: none; width: 200px; border-radius: 8px; overflow: hidden; }
.vrow .thumb.cover { width: 96px; aspect-ratio: 2 / 3; }
.vrow .rating { color: var(--warn); }
.vrow .info { flex: 1; min-width: 0; }
.vrow .title { font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vrow .sub { font-size: 13px; margin-top: 2px; }
.vrow .desc-line { font-size: 13px; color: #c8cbd3; margin-top: 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.vrow .btn { flex: none; padding: 6px 14px; font-size: 13px; }
.empty { padding: 60px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }

/* Плеер */
.player-wrap { background: #000; border-radius: var(--radius); overflow: hidden; position: relative; }
.player-wrap video { display: block; width: 100%; max-height: 78vh; background: #000; }
.player-bar { display: flex; align-items: center; gap: 12px; margin: 14px 0 6px; flex-wrap: wrap; }
.player-bar h1 { margin: 0; flex: 1; min-width: 220px; }
select, .btn {
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel-2); cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { color: var(--err); }
.btn:disabled { opacity: .5; cursor: default; }
.desc { white-space: pre-wrap; color: #c8cbd3; margin-top: 8px; }

/* Админка */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 24px; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; color: var(--muted); }
.field input, .field textarea {
  padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); outline: none;
}
.field input:focus, .field textarea:focus { border-color: var(--accent); }
.drop {
  display: block;
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 28px; text-align: center;
  cursor: pointer; transition: border-color .15s, background .15s; margin-bottom: 14px;
}
.drop.over, .drop:hover { border-color: var(--accent); background: rgba(255, 90, 54, .05); }
.drop strong { display: block; margin-bottom: 4px; }
.kp-row { display: flex; gap: 8px; }
.kp-row input { flex: 1; min-width: 0; }
.kp-preview { display: flex; align-items: center; gap: 12px; margin: -4px 0 14px; padding: 10px; border-radius: 8px; background: var(--panel-2); }
.kp-preview img { width: 54px; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 4px; }
.bar { height: 6px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.bar.ok > i { background: var(--ok); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
td.mini { width: 120px; }
td.mini img { width: 112px; aspect-ratio: 16/9; object-fit: cover; border-radius: 6px; background: #000; display: block; }
.status { font-size: 12px; padding: 2px 8px; border-radius: 99px; border: 1px solid currentColor; white-space: nowrap; }
.status.ready { color: var(--ok); }
.status.processing, .status.queued { color: var(--warn); }
.status.error { color: var(--err); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.actions .btn { padding: 5px 10px; font-size: 13px; }
.err-text { color: var(--err); font-size: 12px; max-width: 420px; white-space: pre-wrap; word-break: break-word; }

.disk { margin: -4px 0 14px; font-size: 13px; color: var(--muted); }
.disk b { color: var(--text); font-weight: 600; }
.disk-bar { display: flex; height: 6px; margin-top: 6px; border-radius: 99px; overflow: hidden; background: var(--panel-2); }
.disk-bar i { display: block; height: 100%; }
.disk-bar .used-other { background: #4a4f5c; }
.disk-bar .used-videos { background: var(--accent); }
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 20;
  width: min(440px, calc(100vw - 32px)); padding: 12px 16px; border-radius: var(--radius);
  background: var(--panel-2); border: 1px solid var(--line); box-shadow: 0 8px 30px rgba(0, 0, 0, .5);
  font-size: 14px;
}
.toast .bar { margin-top: 8px; }
.login { max-width: 380px; margin: 10vh auto; }
.msg { min-height: 1.5em; font-size: 14px; color: var(--err); }

@media (max-width: 720px) {
  .hide-sm { display: none; }
  td.mini { width: 80px; }
  td.mini img { width: 76px; }
  .search { width: 100%; }
  .vrow { gap: 12px; padding: 10px 12px; }
  .vrow .thumb { width: 120px; }
  .vrow .thumb.cover { width: 64px; }
  .vrow .btn, .vrow .desc-line { display: none; }
  header.top { flex-wrap: wrap; }
}
.push { font-size: 12px; color: var(--muted); margin-top: 4px; }
.push .bar { margin-top: 4px; }
.push.ok { color: var(--ok); }

/* Кнопка «Конвертировать» в шапке: точка — запущен ли ASG на Mac */
.btn.convert { display: inline-flex; align-items: center; gap: 8px; }
.btn.convert .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.btn.convert.up .dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(60, 207, 142, .2); }
.local-hint {
  position: sticky; top: 63px; z-index: 9; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px clamp(16px, 4vw, 40px); background: var(--panel-2); border-bottom: 1px solid var(--line); font-size: 14px;
}
.local-hint-body { flex: 1; min-width: 240px; display: grid; gap: 8px; }
.local-cmd { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.local-cmd code {
  padding: 7px 12px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line);
  font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; user-select: all;
}
.local-cmd .btn { padding: 6px 12px; font-size: 13px; }
@media (max-width: 720px) { .local-hint { top: 0; position: static; } }
