:root {
  --bg: #0f1419; --card: #1a2028; --text: #e8edf2; --muted: #8b98a8;
  --accent: #3b82f6; --accent2: #2563eb; --danger: #ef4444; --ok: #22c55e;
  --border: #2a3340; --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font: 16px/1.45 -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
a { color: var(--accent); text-decoration: none; }
main { max-width: 1200px; margin: 0 auto; padding: 12px 16px 60px; }
h1 { font-size: 1.6rem; margin: 10px 0 6px; }
h2 { font-size: 1.15rem; margin: 0 0 10px; }
h3 { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.hidden { display: none !important; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
code { background: #0b0f14; padding: 2px 6px; border-radius: 6px; word-break: break-all; }

.top { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--card); position: sticky; top: 0; z-index: 20; gap: 10px; }
.brand { font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top nav { display: flex; gap: 12px; align-items: center; font-size: .92rem; }
.who { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 12px 0; }
.gate { max-width: 420px; margin: 40px auto; }
label { display: block; margin: 10px 0; }
label.inline { display: inline-flex; align-items: center; gap: 6px; margin: 4px 12px 4px 0; }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 10px 12px; margin-top: 4px; background: #0b0f14; color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; font: inherit; }
label.inline input { width: auto; margin: 0; }
.btn { display: inline-block; padding: 10px 16px; border-radius: 8px; border: 1px solid var(--border);
  background: #243041; color: var(--text); cursor: pointer; font: inherit; text-decoration: none; line-height: 1.2; }
.btn:hover { background: #2d3b50; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent2); }
.btn.danger { background: #3a1d1d; border-color: #5a2a2a; }
.btn.small { padding: 5px 10px; font-size: .85rem; }
.btn.big { padding: 16px 26px; font-size: 1.1rem; }
.btn:disabled { opacity: .5; cursor: default; }
.flashes { max-width: 1200px; margin: 10px auto 0; padding: 0 16px; }
.flash { padding: 10px 14px; border-radius: 8px; margin: 6px 0; background: #1f2a3a; }
.flash.error { background: #3a1d1d; }
.flash.ok { background: #1d3a26; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table audio { max-width: 220px; height: 32px; }

.album-head { text-align: center; padding: 6px 0; }
.counts { margin: 0; font-size: .9rem; }
.uploader { padding: 12px; }
.drop { border: 2px dashed var(--border); border-radius: var(--radius); padding: 18px; text-align: center; transition: border-color .2s; }
.drop.over { border-color: var(--accent); background: #16213a; }
.drop p { margin: 10px 0 0; font-size: .9rem; }
.queue { margin-top: 10px; }
.queue ul { list-style: none; margin: 8px 0 0; padding: 0; max-height: 260px; overflow: auto; }
.queue li { display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center; padding: 6px 0; border-top: 1px solid var(--border); font-size: .9rem; }
.queue li img, .queue li .ph { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; background: #0b0f14; }
.queue li .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue li .st { color: var(--muted); white-space: nowrap; }
.queue li.ok .st { color: var(--ok); }
.queue li.err .st { color: var(--danger); }
.bar { height: 6px; background: #0b0f14; border-radius: 3px; overflow: hidden; margin-top: 4px; }
.bar > div { height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.queue-total { display: flex; align-items: center; gap: 10px; font-size: .9rem; }
.queue-total .bar { flex: 1; margin: 0; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; margin-top: 12px; }
@media (min-width: 700px) { .grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; } }
.tile { position: relative; aspect-ratio: 1; background: #0b0f14; border-radius: 10px; overflow: hidden; cursor: pointer; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .badge { position: absolute; left: 6px; top: 6px; background: rgba(0,0,0,.6); color: #fff; font-size: .75rem; padding: 2px 6px; border-radius: 6px; }
.tile .by { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 8px 6px; font-size: .78rem; color: #fff;
  background: linear-gradient(transparent, rgba(0,0,0,.7)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile.new { outline: 2px solid var(--accent); }
.tile.is-hidden { opacity: .45; }
.tile.no-clip::after { content: "не в клипе"; position: absolute; right: 6px; top: 6px; font-size: .7rem; background: rgba(239,68,68,.8); color: #fff; padding: 2px 6px; border-radius: 6px; }
.tile.dragging { opacity: .4; }
.tile .handle { position: absolute; right: 4px; bottom: 4px; width: 26px; height: 26px; border-radius: 6px; background: rgba(0,0,0,.6); color: #fff; display: none; align-items: center; justify-content: center; font-size: 14px; cursor: grab; }
body.admin-mode .tile .handle { display: flex; }

.clips-block { margin: 10px 0; }
.clips-list { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.clip-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; }
.clip-card video { width: 100%; max-height: 70vh; background: #000; border-radius: 8px; }
.clip-card .row { margin-top: 8px; justify-content: space-between; }
.clip-card .st { font-size: .9rem; }
.clip-card.v video { max-height: 80vh; }

.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.95); z-index: 50; display: flex; flex-direction: column; }
.lb-stage { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; padding: 8px; }
.lb-stage img, .lb-stage video { max-width: 100%; max-height: 100%; object-fit: contain; }
.lb-stage canvas { max-width: 100%; max-height: 100%; touch-action: none; }
.lb-caption { color: #ddd; text-align: center; padding: 6px 50px; font-size: .9rem; min-height: 28px; }
.lb-close { position: absolute; top: 8px; right: 10px; z-index: 2; background: rgba(255,255,255,.15); color: #fff; border: 0; border-radius: 50%; width: 40px; height: 40px; font-size: 20px; cursor: pointer; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: 50%; width: 44px; height: 44px; font-size: 28px; cursor: pointer; z-index: 2; }
.lb-nav.prev { left: 8px; } .lb-nav.next { right: 8px; }
.lb-admin { background: #10151c; padding: 8px 10px; display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; border-top: 1px solid var(--border); }
.lb-admin .btn { padding: 7px 10px; font-size: .85rem; }
.lb-admin input[type=text] { width: auto; flex: 1; min-width: 160px; margin: 0; padding: 7px 10px; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; width: 100%; height: 100%; }
.compare figure { margin: 0; display: flex; flex-direction: column; min-height: 0; }
.compare img { flex: 1; min-height: 0; object-fit: contain; width: 100%; }
.compare figcaption { text-align: center; color: #ccc; font-size: .85rem; padding: 4px; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-box { background: var(--card); border-radius: var(--radius); padding: 18px; width: 100%; max-width: 380px; }
.modal-box input { margin-bottom: 12px; }

#clips .clip-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 10px 0; border-top: 1px solid var(--border); align-items: center; }
#clips .clip-row video { width: 100%; max-width: 420px; background: #000; border-radius: 8px; }
#clips .clip-row.v video { max-width: 220px; }
#clips .prog { color: var(--muted); font-size: .9rem; }
#clips .err { color: var(--danger); font-size: .9rem; }
#clips .pub { color: var(--ok); font-size: .85rem; }

.howto { max-width: 560px; margin-top: 0; }
.howto ol { padding-left: 20px; } .howto li { margin: 6px 0; }
.howto-inline { max-width: 640px; margin: 8px auto 0; text-align: left; font-size: .92rem; color: var(--muted); }
.howto-inline summary { cursor: pointer; color: var(--accent); text-align: center; }
.howto-inline p { margin: 8px 0 0; }
.share-row { margin: 8px 0 0; display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; }
