:root {
  --bg: #0d0b14;
  --panel: #16131f;
  --panel-2: #1d1929;
  --line: #2a2538;
  --text: #ece9f5;
  --muted: #9690ab;
  --accent: #7c5cff;
  --live: #ff3b5c;
  --ok: #2fd08a;
  --warn: #f5a524;
  --radius: 14px;
  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; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.err { color: #ff7a8e; min-height: 1em; margin: 6px 0; }
.warn { color: var(--warn); background: #f5a52414; border: 1px solid #f5a52440; padding: 8px 12px; border-radius: 10px; margin: 0; }
h2 { font-size: 15px; margin: 0; font-weight: 650; letter-spacing: .2px; }

/* botões */
.btn { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer; transition: .15s; white-space: nowrap; }
.btn:hover { border-color: #463f5c; background: #241f33; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { background: var(--live); border-color: var(--live); color: #fff; }
.btn.danger:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 11px; font-size: 13px; }
.btn.wide { width: 100%; }
.danger-text { color: #ff7a8e; }

/* formulário */
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.label { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input, select, textarea { background: #0f0d17; color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; font: inherit; font-size: 14px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
input[type=color] { padding: 3px; height: 40px; cursor: pointer; }
input[type=range] { padding: 0; accent-color: var(--accent); }
textarea { resize: vertical; }
.small-input { width: auto; padding: 5px 8px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row textarea { flex: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.span2 { grid-column: span 2; }
.switch { flex-direction: row; align-items: center; gap: 10px; color: var(--text); cursor: pointer; }
.switch input { display: none; }
.switch span { width: 40px; height: 22px; border-radius: 22px; background: var(--line); position: relative; flex: none; transition: .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { left: 21px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(circle at 30% 20%, #2a1d52 0, transparent 50%), var(--bg); }
.login-card { width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 28px; }
.login-card .muted { margin: 2px 0 20px; }

/* topo */
.brand { display: flex; align-items: center; gap: 9px; font-weight: 750; font-size: 17px; }
.brand.big { font-size: 22px; }
.dot { width: 11px; height: 11px; border-radius: 50%; background: var(--live); box-shadow: 0 0 12px var(--live); }
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 14px; padding: 12px 20px; background: #0d0b14e6; backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; margin-left: auto; }
.tabs button { background: none; border: 0; color: var(--muted); font: inherit; font-weight: 600; padding: 7px 12px; border-radius: 9px; cursor: pointer; }
.tabs button.active { background: var(--panel-2); color: var(--text); }
.pill { font-size: 12px; font-weight: 750; letter-spacing: .6px; padding: 4px 10px; border-radius: 99px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.pill.preview { color: var(--warn); border-color: #f5a52455; }
.pill.live { color: #fff; background: var(--live); border-color: var(--live); animation: pulse 2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px #ff3b5c33; } }

/* layout */
.tab { padding: 20px; max-width: 1280px; margin: 0 auto; }
.grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
#tab-scenes .grid { grid-template-columns: 300px minmax(0, 1fr); }
.col-main, .col-side { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }

/* prévia */
.preview-card { padding: 0; overflow: hidden; }
.preview { position: relative; aspect-ratio: 16/9; background: #000; }
.preview img { width: 100%; height: 100%; object-fit: contain; display: block; }
.preview-empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--muted); }
.onair { position: absolute; top: 12px; left: 12px; background: #000a; border: 1px solid #fff3; padding: 5px 10px; border-radius: 8px; font-size: 13px; font-weight: 650; }
.onair.fb { background: #f5a524dd; color: #1a1300; border-color: transparent; }
.controls { display: flex; gap: 8px; padding: 12px; align-items: center; flex-wrap: wrap; }
.timer { margin-left: auto; font-family: ui-monospace, monospace; color: var(--live); font-weight: 700; }

/* botões de cena */
.scene-buttons { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.scene-btn { --c: var(--accent); position: relative; text-align: left; background: var(--panel-2); border: 2px solid var(--line); border-radius: 12px; padding: 14px 14px 12px; color: var(--text); font: inherit; cursor: pointer; min-height: 84px; display: flex; flex-direction: column; justify-content: space-between; gap: 6px; transition: .15s; overflow: hidden; }
.scene-btn::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--c); }
.scene-btn:hover { border-color: color-mix(in srgb, var(--c) 60%, var(--line)); }
.scene-btn b { font-size: 15px; }
.scene-btn small { color: var(--muted); font-size: 12px; }
.scene-btn.active { border-color: var(--c); background: color-mix(in srgb, var(--c) 16%, var(--panel-2)); }
.scene-btn .badge { position: absolute; top: 8px; right: 8px; font-size: 10px; font-weight: 800; letter-spacing: .5px; padding: 2px 7px; border-radius: 6px; background: var(--live); color: #fff; }
.scene-btn .badge.fb { background: var(--warn); color: #1a1300; }

/* status */
.led { width: 10px; height: 10px; border-radius: 50%; background: #4a4460; }
.led.ok { background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.led.warn { background: var(--warn); box-shadow: 0 0 10px var(--warn); }
.led.bad { background: var(--live); box-shadow: 0 0 10px var(--live); }
.big-text { font-size: 20px; font-weight: 700; }
.bar { height: 8px; background: #0f0d17; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); margin: 4px 0 8px; }
.bar > div { height: 100%; width: 0; background: var(--ok); transition: width .5s; }

/* listas */
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.list li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--panel-2); border: 1px solid transparent; cursor: pointer; }
.list li.sel { border-color: var(--accent); }
.list li i { width: 12px; height: 12px; border-radius: 4px; flex: none; }
.list li small { margin-left: auto; color: var(--muted); }

.drop { border: 2px dashed var(--line); border-radius: 12px; padding: 28px; text-align: center; cursor: pointer; color: var(--muted); }
.drop.over { border-color: var(--accent); color: var(--text); }
.drop input { display: none; }
.media-list { list-style: none; padding: 0; margin: 14px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.media-list li { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.media-list .thumb { aspect-ratio: 16/9; background: #000; display: grid; place-items: center; color: var(--muted); font-size: 28px; }
.media-list .thumb img, .media-list .thumb video { width: 100%; height: 100%; object-fit: cover; }
.media-list .meta { padding: 8px 10px; display: flex; align-items: center; gap: 8px; font-size: 13px; }
.media-list .meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }

.copy { display: grid; grid-template-columns: 60px minmax(0,1fr) auto; gap: 8px; align-items: center; margin-bottom: 8px; font-size: 13px; }
.copy span { color: var(--muted); }
.copy code { background: #0f0d17; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.blur { filter: blur(4px); transition: .2s; }
.blur:hover { filter: none; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 30px); background: #2a2538; color: var(--text); padding: 10px 18px; border-radius: 10px; opacity: 0; transition: .25s; pointer-events: none; z-index: 50; border: 1px solid #3a3450; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: #4a1621; border-color: #7a2535; }

@media (max-width: 900px) {
  .grid, #tab-scenes .grid { grid-template-columns: 1fr; }
  .tabs { order: 5; width: 100%; margin: 0; overflow-x: auto; }
  .top { padding: 10px 16px; }
  .tab { padding: 16px; }
  #logout { margin-left: auto; }
}
@media (max-width: 560px) {
  .form-grid { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .scene-buttons { grid-template-columns: 1fr 1fr; }
}

/* multicanal */
.channel-sel { width: auto; max-width: 220px; padding: 6px 10px; font-weight: 650; background: var(--panel-2); }
.subhead { font-size: 12px; font-weight: 750; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); margin: 8px 0 10px; padding-top: 12px; border-top: 1px solid var(--line); }
.autoend { margin: 0 12px 12px; padding: 9px 12px; border-radius: 10px; background: #f5a52418; border: 1px solid #f5a52455; color: var(--warn); font-size: 13px; font-weight: 600; }
.list li .mdot { width: 8px; height: 8px; border-radius: 50%; background: #4a4460; flex: none; }
.list li .mdot.live { background: var(--live); box-shadow: 0 0 8px var(--live); }
.list li .mdot.preview { background: var(--warn); }
@media (max-width: 900px) { .channel-sel { max-width: 150px; } }
