:root {
  --bg: #0e1014;
  --panel: #171a21;
  --panel2: #1f232c;
  --line: #2a2f3a;
  --text: #e8eaef;
  --muted: #8b93a3;
  --accent: #e5484d;
  --accent2: #ff6b70;
  --ok: #3dd68c;
  --warn: #f5a524;
  --radius: 12px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
h2 { margin: 0; font-size: 20px; }
h3 { margin: 0 0 12px; }
code { background: var(--panel2); padding: 2px 6px; border-radius: 6px; font-size: 13px; }
.muted { color: var(--muted); }
.small-text { font-size: 13px; }
.red { color: var(--accent2); }
.error { color: var(--accent2); background: #e5484d1a; padding: 8px 10px; border-radius: 8px; margin: 4px 0; }
.empty { color: var(--muted); text-align: center; padding: 40px 10px; }

.brand { font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 10px; }
.logo { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: #fff; font-size: 14px; }

.btn { border: 1px solid var(--line); background: var(--panel2); color: var(--text); padding: 9px 14px; border-radius: 9px; cursor: pointer; font: inherit; }
.btn:hover { border-color: #3a4150; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--accent2); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.danger { color: var(--accent2); }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 6px; font-size: 15px; line-height: 1; }
.icon-btn:hover { background: var(--panel2); color: var(--text); }

input, select { width: 100%; background: var(--bg); border: 1px solid var(--line); color: var(--text); padding: 10px 12px; border-radius: 9px; font: inherit; }
input:focus, select:focus { outline: 2px solid #e5484d66; border-color: var(--accent); }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0; }
label input, label select { margin-top: 5px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(420px, 100%); }
.login-card .btn { width: 100%; margin-top: 8px; padding: 12px; }
#login-mac, #login-code { font-family: ui-monospace, Menlo, monospace; letter-spacing: 1px; text-transform: uppercase; }

.topbar { display: flex; align-items: center; gap: 16px; padding: 14px 24px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 10; }
.topbar .device { margin-left: auto; color: var(--muted); font-size: 14px; }
.tabs { display: flex; gap: 4px; padding: 10px 24px 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { background: none; border: 0; color: var(--muted); padding: 10px 14px; font: inherit; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.content { padding: 24px; max-width: 1100px; margin: 0 auto; }

.banner { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; background: #f5a5241a; border-bottom: 1px solid #f5a52455; padding: 12px 24px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.end { justify-content: flex-end; margin-top: 14px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.toolbar.wrap { flex-wrap: wrap; }
.toolbar h2 { margin-right: auto; }
.toolbar select { width: auto; min-width: 180px; }
.toolbar input[type=search] { width: 260px; }
.status { font-size: 13px; color: var(--muted); margin-left: auto; }
.status.ok { color: var(--ok); }

.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: none; color: var(--muted); padding: 7px 12px; border-radius: 7px; cursor: pointer; font: inherit; }
.seg button.active { background: var(--panel2); color: var(--text); }

.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.pl-card { display: flex; flex-direction: column; gap: 10px; }
.pl-card .head { display: flex; align-items: center; gap: 10px; }
.pl-card .name { font-weight: 600; font-size: 16px; }
.badge { font-size: 11px; padding: 3px 8px; border-radius: 99px; background: var(--panel2); color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.badge.active { background: #3dd68c22; color: var(--ok); }
.stats { display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.stats b { color: var(--text); }
.pl-card .actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cat-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.cat-list li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); user-select: none; }
.cat-list li:last-child { border-bottom: 0; }
.cat-list li.is-hidden .cname { color: var(--muted); text-decoration: line-through; }
.cat-list li.dragging { opacity: .4; }
.cat-list li.drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.cat-list li.drop-after { box-shadow: inset 0 -2px 0 var(--accent); }
.handle { cursor: grab; color: var(--muted); padding: 4px; font-size: 18px; line-height: 1; }
.pos { width: 34px; color: var(--muted); font-size: 12px; text-align: right; }
.cname { flex: 1; }
.count { color: var(--muted); font-size: 12px; min-width: 60px; text-align: right; }
.toggle { position: relative; width: 38px; height: 22px; flex: none; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle span { position: absolute; inset: 0; background: var(--line); border-radius: 99px; cursor: pointer; transition: .15s; }
.toggle span::after { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; }
.toggle input:checked + span { background: var(--ok); }
.toggle input:checked + span::after { transform: translateX(16px); }

.media-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.media-list li { display: flex; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.media-list img, .media-list .ph { width: 44px; height: 44px; object-fit: contain; border-radius: 6px; background: var(--panel2); flex: none; }
.media-list .meta { flex: 1; min-width: 0; }
.media-list .sub { color: var(--muted); font-size: 12px; }
.bar { height: 4px; background: var(--line); border-radius: 4px; margin-top: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); }

dialog { border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: var(--radius); width: min(520px, 94vw); padding: 22px; }
dialog::backdrop { background: #0009; }
details { margin-top: 10px; color: var(--muted); font-size: 13px; }
.narrow { max-width: 460px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; z-index: 100; box-shadow: 0 6px 30px #0008; }
.toast.err { border-color: var(--accent); }

@media (max-width: 640px) {
  .topbar .device { display: none; }
  .content { padding: 14px; }
  .row2 { grid-template-columns: 1fr; }
  .toolbar input[type=search] { width: 100%; }
  .count { display: none; }
}
