:root {
  color-scheme: dark;
  --bg: #0f0f11; --panel: #16161a; --panel-2: #1d1d22; --line: #2c2c33; --line-2: #3a3a43;
  --text: #f2f2f4; --text-2: #a7a7b0; --accent: #ffc400; --accent-text: #0b0b0c; --danger: #ff6b6b; --ok: #4ade80;
  --radius: 8px; --font: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); display: flex; flex-direction: column; overflow: hidden; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
button, input, select, textarea { font: inherit; color: inherit; }

/* Barra superior */
.bar { display: flex; align-items: center; gap: 16px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
.bar__brand { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.bar__brand small { display: block; color: var(--text-2); font-size: 12px; }
.bar__logo { width: 32px; height: 32px; border-radius: 8px; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; font-weight: 900; }
.bar__group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bar select { min-width: 200px; }

.btn { border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); padding: 7px 12px; border-radius: var(--radius); cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn:hover { border-color: #55555f; }
.btn--primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn--primary:hover { filter: brightness(1.08); }
.btn--ghost { background: transparent; }
.btn--sm { padding: 4px 10px; font-size: 13px; }
.btn--danger { color: var(--danger); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

select, input[type=text], input[type=url], input[type=number], input[type=email], input[type=tel], textarea {
  background: var(--bg); border: 1px solid var(--line-2); border-radius: 6px; padding: 7px 9px; width: 100%;
}
textarea { resize: vertical; min-height: 64px; }

/* Layout */
.layout { flex: 1; display: grid; grid-template-columns: minmax(380px, 460px) 1fr; min-height: 0; }
.panel { border-right: 1px solid var(--line); overflow-y: auto; padding: 12px 14px 80px; background: var(--panel); }
.panel__status { color: var(--text-2); font-size: 12px; margin-bottom: 10px; }
.panel__status.ok { color: var(--ok); }

.checks { border: 1px solid var(--line-2); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 12px; background: var(--panel-2); font-size: 13px; }
.checks summary { cursor: pointer; font-weight: 700; }
.checks ul { margin: 8px 0 0; padding-left: 18px; color: var(--text-2); max-height: 180px; overflow: auto; }
.checks .warn { color: #fbbf24; }

/* Grupos do formulário */
.grp { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; background: var(--panel); }
.grp > summary { list-style: none; cursor: pointer; padding: 11px 12px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.grp > summary::-webkit-details-marker { display: none; }
.grp > summary::before { content: "▸"; color: var(--text-2); transition: transform .2s; }
.grp[open] > summary::before { transform: rotate(90deg); }
.grp > summary .hint { margin-left: auto; font-weight: 500; color: var(--text-2); font-size: 12px; }
.grp__body { padding: 4px 12px 14px; display: grid; gap: 12px; }
.grp__desc { color: var(--text-2); font-size: 12.5px; margin: 0; }

.fld { display: grid; gap: 5px; }
.fld > span { font-weight: 600; font-size: 13px; }
.fld small { color: var(--text-2); font-size: 12px; }
.fld--row { grid-template-columns: 1fr auto; align-items: center; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.color { display: flex; align-items: center; gap: 8px; }
.color input[type=color] { width: 40px; height: 34px; padding: 0; border: 1px solid var(--line-2); border-radius: 6px; background: none; cursor: pointer; flex: none; }
.color input[type=text] { font-family: ui-monospace, Menlo, monospace; }

.range { display: flex; align-items: center; gap: 10px; }
.range input[type=range] { flex: 1; accent-color: var(--accent); }
.range output { width: 64px; text-align: right; font-family: ui-monospace, Menlo, monospace; color: var(--text-2); }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; }
.switch input { accent-color: var(--accent); width: 16px; height: 16px; }

.img { display: grid; grid-template-columns: 96px 1fr; gap: 10px; align-items: center; }
.img__thumb { width: 96px; height: 96px; border-radius: 6px; border: 1px dashed var(--line-2); background: repeating-conic-gradient(#222 0 25%, #1a1a1a 0 50%) 0 0/16px 16px; display: grid; place-items: center; overflow: hidden; color: var(--text-2); font-size: 11px; text-align: center; }
.img__thumb img { width: 100%; height: 100%; object-fit: contain; }
.img__actions { display: flex; flex-wrap: wrap; gap: 6px; }

.list { display: grid; gap: 8px; }
.item { border: 1px solid var(--line); border-radius: 6px; padding: 10px; display: grid; gap: 8px; background: var(--panel-2); }
.item__head { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-2); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.item__head .btn { margin-left: auto; }
.item__head .btn + .btn { margin-left: 0; }

.palette { display: flex; flex-wrap: wrap; gap: 6px; }
.palette button { border: 1px solid var(--line-2); border-radius: 999px; padding: 4px 10px 4px 4px; background: var(--panel-2); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
.palette i { width: 18px; height: 18px; border-radius: 50%; display: inline-block; box-shadow: inset 0 0 0 1px rgba(255,255,255,.2); }

/* Prévia */
.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #08080a; }
.stage__bar { display: flex; align-items: center; gap: 12px; padding: 8px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius); overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 6px 12px; cursor: pointer; color: var(--text-2); font-weight: 600; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }
.toggle { display: inline-flex; gap: 6px; align-items: center; color: var(--text-2); cursor: pointer; }
.toggle input { accent-color: var(--accent); }
.stage__viewport { flex: 1; overflow: hidden; position: relative; display: flex; justify-content: center; padding: 16px; }
.stage__frame { transform-origin: top center; box-shadow: 0 0 0 1px var(--line-2), 0 20px 60px rgba(0,0,0,.5); background: #fff; flex: none; }
.stage__frame iframe { border: 0; display: block; width: 100%; height: 100%; background: #000; }

/* Diálogo e aviso */
.dlg { border: 1px solid var(--line-2); border-radius: 12px; background: var(--panel); color: var(--text); padding: 20px; width: min(420px, 92vw); }
.dlg::backdrop { background: rgba(0,0,0,.6); }
.dlg h2 { margin: 0 0 14px; font-size: 18px; }
.dlg label { display: grid; gap: 6px; margin-bottom: 12px; font-weight: 600; }
.dlg__actions { display: flex; justify-content: flex-end; gap: 8px; }
.toast { position: fixed; left: 50%; bottom: 20px; translate: -50% 0; background: var(--panel-2); border: 1px solid var(--line-2); padding: 10px 16px; border-radius: 999px; opacity: 0; transition: opacity .25s; pointer-events: none; z-index: 20; max-width: 90vw; }
.toast.on { opacity: 1; }
.busy { cursor: progress; }

@media (max-width: 960px) {
  body { overflow: auto; }
  .layout { grid-template-columns: 1fr; }
  .panel { border-right: 0; border-bottom: 1px solid var(--line); max-height: none; overflow: visible; }
  .stage { height: 80vh; }
}

/* Senha */
html:not(.is-unlocked) .bar, html:not(.is-unlocked) .layout { visibility: hidden; }
.gate { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: var(--bg); padding: 16px; }
.gate__box { width: min(340px, 100%); display: grid; gap: 10px; padding: 28px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--panel); }
.gate__box h1 { margin: 6px 0 8px; font-size: 20px; }
.gate__box label:not(.switch) { font-weight: 600; font-size: 13px; }
.gate__box input[type=password] { background: var(--bg); border: 1px solid var(--line-2); border-radius: 6px; padding: 10px; width: 100%; }
.gate__box .btn { padding: 10px; margin-top: 6px; }
.gate__err { color: var(--danger); margin: 0; font-size: 13px; }
