:root {
  --bg: #0f172a; --panel: #1e293b; --panel-2: #273449; --border: #334155;
  --text: #e2e8f0; --muted: #94a3b8; --primary: #22c55e; --primary-d: #16a34a;
  --danger: #ef4444; --warn: #f59e0b; --info: #38bdf8; --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--info); }
button, input, select { font: inherit; }
button { cursor: pointer; border: 0; border-radius: 8px; padding: 9px 14px; background: var(--panel-2); color: var(--text); }
button:hover { filter: brightness(1.15); }
button.primary { background: var(--primary); color: #052e16; font-weight: 600; }
button.danger { background: var(--danger); color: #fff; }
button.ghost { background: transparent; border: 1px solid var(--border); }
button.sm { padding: 5px 10px; font-size: 13px; }
button:disabled { opacity: .5; cursor: default; }
input, select { background: #0b1220; color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; width: 100%; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
h1, h2, h3 { margin: 0 0 12px; }
.muted { color: var(--muted); font-size: 13px; }

/* Auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth .card { width: 100%; max-width: 420px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; }
.brand .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 12px var(--primary); }
.tabs { display: flex; gap: 6px; margin: 16px 0; }
.tabs button { flex: 1; }
.tabs button.active { background: var(--primary); color: #052e16; font-weight: 600; }

/* Layout */
.layout { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.sidebar { background: var(--panel); border-right: 1px solid var(--border); padding: 18px 14px; display: flex; flex-direction: column; gap: 6px; }
.sidebar nav button { width: 100%; text-align: left; background: transparent; }
.sidebar nav button.active { background: var(--panel-2); }
.sidebar .spacer { flex: 1; }
.main { padding: 24px; max-width: 1200px; }
.toolbar { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.on { background: #14532d; color: #86efac; }
.badge.off { background: #450a0a; color: #fca5a5; }
.badge.info { background: #0c4a6e; color: #bae6fd; }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--panel-2); border: 1px solid var(--border); padding: 12px 16px; border-radius: 8px; max-width: 360px; z-index: 50; }
.toast.err { border-color: var(--danger); }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 40; padding: 20px; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.code-input { font-size: 28px; letter-spacing: 8px; text-transform: uppercase; text-align: center; font-family: ui-monospace, monospace; }

/* Media */
.media-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.media-card .thumb { aspect-ratio: 16/9; background: #000; display: grid; place-items: center; overflow: hidden; }
.media-card .thumb img, .media-card .thumb video { width: 100%; height: 100%; object-fit: contain; }
.media-card .body { padding: 10px 12px; font-size: 13px; }
.media-card .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 24px; text-align: center; color: var(--muted); margin-bottom: 16px; }
.dropzone.over { border-color: var(--primary); color: var(--text); }
.progress { height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; margin-top: 10px; }
.progress > div { height: 100%; background: var(--primary); width: 0; transition: width .2s; }

/* Playlist editor */
.editor { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .editor { grid-template-columns: 1fr; } .layout { grid-template-columns: 1fr; } .sidebar { flex-direction: row; flex-wrap: wrap; } }
.list { display: flex; flex-direction: column; gap: 6px; }
.item { display: flex; gap: 10px; align-items: center; background: var(--panel-2); border-radius: 8px; padding: 8px 10px; }
.item .th { width: 64px; height: 36px; background: #000; border-radius: 4px; overflow: hidden; flex: none; display: grid; place-items: center; }
.item .th img, .item .th video { width: 100%; height: 100%; object-fit: cover; }
.item .nm { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.item input[type=number] { width: 70px; padding: 5px 8px; }
.item.dragging { opacity: .4; }
.screen-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.screen-card .title { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.kv { font-size: 13px; color: var(--muted); }
.kv b { color: var(--text); font-weight: 500; }
.help { background: #0c4a6e33; border: 1px solid #0c4a6e; border-radius: 8px; padding: 12px 14px; font-size: 14px; margin-bottom: 16px; }
.empty { color: var(--muted); padding: 30px; text-align: center; border: 1px dashed var(--border); border-radius: var(--radius); }
