[hidden] { display: none !important; }
:root {
  --bg: #1d1f23; --panel: #26292e; --panel2: #2e3238; --line: #3a3f46; --text: #e4e6ea; --muted: #8d939c;
  --acc: #3d8bfd; --acc2: #2c6fd6; --canvas: #3a3d42; --danger: #e5484d;
  font: 13px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
kbd { font: 11px ui-monospace, monospace; color: var(--muted); margin-left: auto; padding-left: 16px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.muted { color: var(--muted); font-size: 12px; }
.spacer { flex: 1; }

body { display: grid; grid-template-rows: 40px 1fr 26px; }

/* menu */
.menubar { display: flex; align-items: center; gap: 8px; padding: 0 10px; background: var(--panel); border-bottom: 1px solid var(--line); z-index: 10; }
.brand { font-weight: 700; letter-spacing: .3px; margin-right: 10px; color: #fff; }
.menubar nav { display: flex; }
.menu { position: relative; }
.menu > button { background: none; border: 0; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.menu > button:hover, .menu.open > button { background: var(--panel2); }
.drop { display: none; position: absolute; top: 100%; left: 0; min-width: 260px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 4px; box-shadow: 0 10px 30px #0008; }
.menu.open .drop { display: block; }
.drop button { display: flex; width: 100%; text-align: left; background: none; border: 0; padding: 6px 10px; border-radius: 5px; cursor: pointer; }
.drop button:hover { background: var(--acc); }
.drop button:hover kbd { color: #fff; }

.btn { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; cursor: pointer; }
.btn:hover { border-color: #555c66; }
.btn.primary { background: var(--acc); border-color: var(--acc); color: #fff; }
.btn.primary:hover { background: var(--acc2); }
.btn.sm { padding: 4px 8px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: default; }

#main { display: grid; grid-template-columns: 48px 1fr 300px; min-height: 0; }

/* barra de ferramentas */
#toolbar { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; padding: 6px 0; gap: 2px; overflow-y: auto; }
#toolbar hr { width: 28px; }
#toolbar button[data-tool] { width: 36px; height: 34px; border: 0; background: none; border-radius: 6px; cursor: pointer; display: grid; place-items: center; }
#toolbar button[data-tool]:hover { background: var(--panel2); }
#toolbar button[data-tool].on { background: var(--acc); }
#toolbar svg { width: 20px; height: 20px; fill: currentColor; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; }
.swatches { position: relative; width: 36px; height: 40px; margin-top: 10px; }
.swatches button { position: absolute; width: 22px; height: 22px; border: 2px solid #fff; border-radius: 3px; cursor: pointer; padding: 0; }
#swFill { left: 2px; top: 2px; z-index: 2; }
#swStroke { left: 12px; top: 14px; box-shadow: inset 0 0 0 4px var(--panel); }
.swatches button.none { background: linear-gradient(to top right, #fff 45%, #e5484d 46%, #e5484d 54%, #fff 55%) !important; }

/* palco */
#stage { position: relative; background: var(--canvas); overflow: hidden; min-width: 0; }
#cv, #overlay { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#overlay { pointer-events: none; }
#cv { touch-action: none; }
#splitBar { position: absolute; top: 0; bottom: 0; width: 3px; background: var(--acc); cursor: ew-resize; z-index: 3; }
#splitBar span { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); background: var(--acc); color: #fff; padding: 3px 8px; border-radius: 10px; white-space: nowrap; font-size: 11px; }
#dropHint { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; pointer-events: none; }
#dropHint > div { pointer-events: auto; padding: 40px 50px; border: 2px dashed #5a6069; border-radius: 16px; background: #2a2d32cc; }
#dropHint h2 { margin: 0 0 6px; font-weight: 600; }
#dropHint p { color: var(--muted); margin: 0 0 16px; }
#stage.dragover #dropHint > div { border-color: var(--acc); background: #2c6fd633; }
#busy { position: absolute; left: 50%; top: 16px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; background: #000c; padding: 8px 16px; border-radius: 20px; z-index: 5; }
.spin { width: 16px; height: 16px; border: 2px solid #fff4; border-top-color: #fff; border-radius: 50%; animation: sp 0.8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }

/* painéis */
#panels { background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; background: none; border: 0; padding: 10px 4px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; font-size: 12px; }
.tabs button.on { color: var(--text); border-bottom-color: var(--acc); }
section[data-panel] { display: none; padding: 10px 12px 30px; overflow-y: auto; flex: 1; }
section[data-panel].on { display: block; }
section h4 { margin: 14px 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
label.row { display: flex; flex-direction: column; gap: 4px; margin: 6px 0; }
select, input[type=number], input:not([type]) , dialog input[type=number] { background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: 5px 6px; min-width: 0; }
input[type=color] { width: 36px; height: 28px; border: 1px solid var(--line); border-radius: 5px; background: var(--bg); padding: 2px; cursor: pointer; }
label.rng { display: grid; grid-template-columns: 1fr auto; gap: 2px 6px; margin: 8px 0; }
label.rng output { color: var(--muted); font-variant-numeric: tabular-nums; }
label.rng input { grid-column: 1 / -1; width: 100%; accent-color: var(--acc); }
label.chk { display: flex; align-items: center; gap: 6px; margin: 6px 0; cursor: pointer; }
.row2 { display: flex; gap: 8px; align-items: center; margin: 8px 0; flex-wrap: wrap; }
.row2 > .btn.primary { margin-left: auto; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 6px 0; }
.row3 label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.xywh { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.xywh label { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.xywh input { width: 100%; }
.palette { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; }
.palette span { width: 22px; height: 22px; border-radius: 4px; border: 1px solid #0006; cursor: pointer; }
.palette span:hover { outline: 2px solid #fff; }

#layerList, .hist { list-style: none; margin: 8px 0; padding: 0; }
#layerList li { display: flex; align-items: center; gap: 6px; padding: 6px 6px; border-radius: 5px; cursor: pointer; }
#layerList li:hover { background: var(--panel2); }
#layerList li.active { background: #3d8bfd33; }
#layerList li .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#layerList li .ct { color: var(--muted); font-size: 11px; }
#layerList li button { background: none; border: 0; cursor: pointer; padding: 2px 4px; opacity: .85; }
#layerList li button.off { opacity: .3; }
#layerList li .sw { width: 12px; height: 12px; border-radius: 3px; border: 1px solid #0008; }
.hist li { padding: 5px 8px; border-radius: 5px; cursor: pointer; display: flex; gap: 6px; }
.hist li:hover { background: var(--panel2); }
.hist li.cur { background: #3d8bfd33; }
.hist li.future { opacity: .45; }

#status { display: flex; gap: 18px; align-items: center; padding: 0 12px; background: var(--panel); border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; width: 400px; box-shadow: 0 20px 60px #000a; }
dialog::backdrop { background: #0008; }
dialog h3 { margin: 0 0 10px; }
dialog menu { display: flex; justify-content: flex-end; gap: 8px; padding: 0; margin: 16px 0 0; }
dialog .row2 label { display: flex; flex-direction: column; gap: 3px; flex: 1; }

@media (max-width: 900px) {
  #main { grid-template-columns: 44px 1fr; }
  #panels { position: fixed; right: 0; top: 40px; bottom: 26px; width: 290px; z-index: 6; box-shadow: -10px 0 30px #0007; }
}
