:root {
  --bg: #f3f4f6; --surface: #fff; --surface2: #f7f8fa; --line: #e3e5e9; --line2: #d3d6dc;
  --text: #1d2127; --muted: #6b7280; --accent: #2563c9; --accent-ink: #fff; --accent-soft: #e8effb;
  --good: #1a7f43; --bad: #c0322b; --warn: #a15c00; --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17191d; --surface: #1f2228; --surface2: #262a31; --line: #2f343c; --line2: #3b414a;
    --text: #e8eaed; --muted: #9aa1ab; --accent: #6ea0f0; --accent-ink: #0d1424; --accent-soft: #23314a;
    --good: #5bc27e; --bad: #f07a72; --warn: #e6a64a; --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; min-height: 100dvh; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface2); padding: 1px 5px; border-radius: 5px; }
h1 { font-size: 20px; margin: 0; } h2 { font-size: 16px; margin: 0 0 12px; }
.ic { width: 20px; height: 20px; fill: currentColor; flex: none; }
.muted { color: var(--muted); } .good { color: var(--good); } .bad { color: var(--bad); }
.nowrap { white-space: nowrap; } .wrap { word-break: break-word; }

/* шапка и меню */
.top { display: flex; align-items: center; gap: 14px; padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 16px; color: var(--text); }
.brand .ic { color: var(--accent); }
.ts-chip { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); background: var(--surface2); border: 1px solid var(--line); padding: 3px 10px; border-radius: 99px; max-width: 46vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ts-chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--line2); flex: none; }
.ts-chip.on i { background: var(--good); } .ts-chip.off i { background: var(--bad); }
.logout { margin-left: auto; }
.nav { display: flex; gap: 2px; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.nav a { padding: 11px 12px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.nav a:hover { color: var(--text); text-decoration: none; }
.nav a.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 500; }
.main { max-width: 1240px; margin: 0 auto; padding: 18px 20px 40px; }
body.bare .main { display: grid; place-items: center; min-height: 100dvh; }

/* карточки и формы */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h1, .card-head h2 { margin: 0; }
.tools { display: flex; gap: 6px; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line2); background: var(--surface); color: var(--text); font: inherit; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn .ic { width: 16px; height: 16px; }
.danger-text { color: var(--bad); }
button.link { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; padding: 0; }
button.link:hover { color: var(--text); }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line2); border-radius: 8px; height: 36px; padding: 0 10px; min-width: 0; }
textarea { height: auto; padding: 8px 10px; width: 100%; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
input[type=range] { height: auto; padding: 0; border: 0; background: none; accent-color: var(--accent); }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.field input, .field select { width: 100%; }
.field.wide { margin: 12px 0 0; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px 16px; margin-bottom: 16px; }
.checks { display: flex; flex-direction: column; gap: 9px; margin-bottom: 16px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check.small { font-size: 12px; color: var(--muted); }
.settings h2 { margin-top: 6px; padding-top: 14px; border-top: 1px solid var(--line); }
.settings h2:first-child { border-top: 0; padding-top: 0; }
.form-foot { display: flex; align-items: center; gap: 10px; padding-top: 4px; flex-wrap: wrap; }
.saved { color: var(--good); font-size: 13px; }
.saved.err { color: var(--bad); }
.field .err-text { color: var(--bad); font-size: 12px; }
.row-form { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.row-form input { flex: 1 1 200px; }
.hint { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
details.hint summary { cursor: pointer; color: var(--accent); }
.msg { padding: 9px 12px; border-radius: 8px; margin: 0 0 12px; }
.msg.good { background: color-mix(in srgb, var(--good) 12%, transparent); color: var(--good); }
.msg.bad { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); }
.empty { color: var(--muted); padding: 14px 0; margin: 0; text-align: center; }
.tip { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--line2); color: var(--muted); font-size: 11px; cursor: help; position: relative; vertical-align: 1px; }
.tip:hover::after, .tip:focus::after { content: attr(data-tip); position: absolute; left: 50%; bottom: 140%; transform: translateX(-50%); width: max-content; max-width: 280px; background: var(--text); color: var(--surface); padding: 7px 9px; border-radius: 7px; font-size: 12px; line-height: 1.35; z-index: 30; white-space: normal; font-weight: 400; }
.tabs { display: flex; gap: 4px; margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 7px 12px; border-radius: 8px; color: var(--muted); white-space: nowrap; }
.tabs a.on { background: var(--surface); border: 1px solid var(--line); color: var(--text); }
.chip { display: inline-flex; align-items: center; height: 28px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line2); background: var(--surface); color: var(--text); font: inherit; font-size: 13px; cursor: pointer; }
.chip.on, .chip:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.pick { display: flex; gap: 5px; flex-wrap: wrap; }
.pick .chip { height: 24px; font-size: 12px; }
.code-out { font: 22px ui-monospace, monospace; letter-spacing: 2px; background: var(--surface2); padding: 10px 14px; border-radius: 8px; }
.code-out small { display: block; font: 13px system-ui; letter-spacing: 0; color: var(--muted); margin-top: 4px; }
ul.plain { margin: 0; padding-left: 18px; }

/* таблицы */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-weight: 500; color: var(--muted); font-size: 13px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.table td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table.compact td { padding: 6px 8px; }
.table .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.table.log td { font-size: 13px; }
.lv-warn td:last-child { color: var(--warn); } .lv-error td:last-child { color: var(--bad); }

/* вход */
.login { width: min(360px, 92vw); display: flex; flex-direction: column; gap: 12px; }
.login h1 { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.login h1 .ic { color: var(--accent); }
.login label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }

/* плеер */
.grid-player .col { min-width: 0; }
.grid-player { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.now { display: grid; grid-template-columns: 112px 1fr; gap: 6px 16px; }
.cover { grid-row: span 1; width: 112px; height: 112px; border-radius: 8px; background: var(--surface2) center / cover no-repeat; display: grid; place-items: center; color: var(--line2); }
.cover .ic { width: 40px; height: 40px; }
.cover.has .ic { display: none; }
.now-info { min-width: 0; align-self: center; }
.now-title { font-size: 18px; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.now-artist { color: var(--muted); margin-top: 3px; overflow-wrap: anywhere; }
.now-meta { color: var(--muted); font-size: 12px; margin-top: 6px; }
.progress { grid-column: 1 / -1; height: 6px; background: var(--surface2); border-radius: 99px; margin-top: 10px; cursor: pointer; position: relative; }
.progress .bar { height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .4s linear; }
.progress.live { cursor: default; } .progress.live .bar { width: 100% !important; opacity: .35; }
.times { grid-column: 1 / -1; display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.controls { grid-column: 1 / -1; display: flex; justify-content: center; align-items: center; gap: 14px; margin: 4px 0; }
.ctl { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line2); background: var(--surface); color: var(--text); display: grid; place-items: center; cursor: pointer; }
.ctl:hover { background: var(--surface2); }
.ctl.big { width: 58px; height: 58px; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.ctl.big .ic { width: 26px; height: 26px; }
.ctl:disabled { opacity: .4; cursor: default; }
.volume { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; color: var(--muted); }
.volume input { flex: 1; }
.volume span { width: 28px; text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; }
.modes { grid-column: 1 / -1; display: flex; gap: 12px; flex-wrap: wrap; margin-top: 6px; }
.modes label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); flex: 1 1 150px; }
.listeners { grid-column: 1 / -1; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 9px; margin-top: 6px; }
.search { display: flex; gap: 8px; }
.search input { flex: 1; }
.search select { width: 140px; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 4px; }
.quick select { height: 28px; border-radius: 99px; padding: 0 10px; font-size: 13px; max-width: 100%; }
.results-head { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 13px; margin: 10px 0 4px; }
.tracks { list-style: none; margin: 0; padding: 0; }
.tracks li { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto auto; align-items: center; gap: 10px; padding: 7px 4px; border-bottom: 1px solid var(--line); }
.tracks li:last-child { border-bottom: 0; }
.tracks .th { width: 40px; height: 40px; border-radius: 6px; background: var(--surface2) center / cover; display: grid; place-items: center; color: var(--line2); }
.tracks .th .ic { width: 18px; height: 18px; }
.tracks .t { min-width: 0; }
.tracks .t b { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tracks .t span { display: block; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tracks .d { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.tracks .b { display: flex; gap: 4px; }
.tracks .b .btn { width: 32px; padding: 0; }
.queue li { grid-template-columns: 22px 40px minmax(0, 1fr) auto auto; }
.queue .grip { color: var(--line2); cursor: grab; display: grid; place-items: center; }
.queue li.dragging { opacity: .5; } .queue li.over { box-shadow: inset 0 2px 0 var(--accent); }
.src-tag { display: inline-block; font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; margin-left: 4px; }

/* файлы */
.upload { margin-bottom: 14px; display: flex; flex-direction: column; gap: 10px; }
.drop { border: 1.5px dashed var(--line2); border-radius: var(--radius); padding: 24px; display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; text-align: center; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop input { display: none; }
.up-progress { height: 6px; background: var(--surface2); border-radius: 99px; } .up-progress .bar { height: 100%; width: 0; background: var(--accent); border-radius: 99px; }

/* уведомления */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--text); color: var(--surface); padding: 10px 14px; border-radius: 8px; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.18); }
.toast.bad { background: var(--bad); color: #fff; }

/* пульт */
.remote-page .top { position: static; }
.remote-page .main { padding-top: 12px; }

@media (max-width: 900px) {
  .grid-player { grid-template-columns: minmax(0, 1fr); }
  .grid-player .col:last-child { order: -1; }
  .main { padding: 12px 12px 32px; }
  .top { padding: 8px 12px; gap: 10px; }
  .nav { padding: 0 6px; }
}
@media (max-width: 560px) {
  .now { grid-template-columns: 72px 1fr; gap: 6px 12px; }
  .cover { width: 72px; height: 72px; }
  .now-title { font-size: 16px; }
  .hide-sm { display: none; }
  .search select { width: 104px; }
  .tracks li { grid-template-columns: 40px minmax(0, 1fr) auto; }
  .tracks .d { display: none; }
  .queue li { grid-template-columns: 40px minmax(0, 1fr) auto; }
  .queue .grip { display: none; }
  .card { padding: 14px; }
  .logout button { font-size: 13px; }
  .ts-chip { max-width: 40vw; }
}

/* голосование за пропуск и гостевая страница */
.vote-info { text-align: center; font-size: .85rem; opacity: .8; margin: -.25rem 0 .5rem; }
.ctl.voted { opacity: .55; }
.guest-name { font: inherit; opacity: .85; cursor: pointer; }
