:root {
  --bg: #0D0B14; --panel: #15121F; --panel-2: #1C1829; --line: #2A2539; --line-2: #3A3350;
  --text: #F3F0FA; --muted: #9C95B2; --primary: #8B5CF6; --secondary: #EC4899; --ok: #34D399; --warn: #FBBF24; --err: #F87171;
  --grad: linear-gradient(120deg, #8B5CF6, #EC4899);
  --r: 14px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--text); font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
a { color: inherit; text-decoration: none; }
.ico { display: inline-grid; place-items: center; width: 1.15em; height: 1.15em; flex: none; }
.ico svg { width: 100%; height: 100%; }

/* botões */
.abtn { display: inline-flex; align-items: center; justify-content: center; gap: .5em; padding: .65em 1.05em; border-radius: 12px; border: 1px solid var(--line-2); background: var(--panel-2); font-weight: 600; transition: all .2s; white-space: nowrap; }
.abtn:hover:not(:disabled) { border-color: var(--primary); }
.abtn:disabled { opacity: .45; cursor: not-allowed; }
.abtn.primary { background: var(--grad); border-color: transparent; color: #fff; box-shadow: 0 8px 22px -10px var(--primary); }
.abtn.primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 12px 28px -10px var(--secondary); }
.abtn.ghost { background: transparent; }
.abtn.small { padding: .45em .75em; font-size: .85rem; border-radius: 10px; }
.abtn.big { padding: .9em 1.3em; font-size: 1rem; width: 100%; }
.abtn.danger { color: var(--err); }
.abtn.danger:hover { border-color: var(--err); }
.abtn.add { width: 100%; border-style: dashed; background: transparent; color: var(--muted); }
.abtn.add:hover { color: var(--text); }
.abtn.loading { pointer-events: none; }
.abtn.loading .ico { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* login */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; position: relative; overflow: hidden; }
.login-bg span { position: fixed; width: 60vmax; height: 60vmax; border-radius: 50%; filter: blur(100px); opacity: .25; pointer-events: none; }
.login-bg span:first-child { background: var(--primary); top: -30vmax; left: -20vmax; }
.login-bg span:last-child { background: var(--secondary); bottom: -30vmax; right: -20vmax; }
.login-card { position: relative; width: min(400px, 100%); padding: 36px 30px; border-radius: 26px; background: color-mix(in srgb, var(--panel) 85%, transparent); border: 1px solid var(--line); backdrop-filter: blur(20px); display: grid; gap: 14px; text-align: center; box-shadow: 0 40px 80px -40px #000; }
.login-logo { width: 64px; height: 64px; margin: 0 auto 6px; border-radius: 20px; background: var(--grad); color: #fff; display: grid; place-items: center; padding: 16px; animation: pulse 2.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--primary) 55%, transparent); } 60% { box-shadow: 0 0 0 14px transparent; } }
.login-card h1 { font-size: 1.5rem; letter-spacing: -.02em; }
.login-sub { color: var(--muted); margin-bottom: 8px; }
.login-card input { padding: .9em 1em; border-radius: 12px; border: 1px solid var(--line-2); background: var(--bg); outline: none; text-align: center; }
.login-card input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 20%, transparent); }
.login-err { color: var(--err); min-height: 1.2em; font-size: .9rem; }
.login-back { display: inline-flex; align-items: center; justify-content: center; gap: .3em; color: var(--muted); font-size: .88rem; }
.login-back:hover { color: var(--text); }

/* layout */
.adm { display: grid; grid-template-columns: 236px 400px 1fr; height: 100vh; overflow: hidden; }
.side { display: flex; flex-direction: column; border-right: 1px solid var(--line); background: var(--panel); min-height: 0; }
.brand { display: flex; align-items: center; gap: .7rem; padding: 18px 16px; border-bottom: 1px solid var(--line); }
.brand-mark { width: 38px; height: 38px; border-radius: 12px; background: var(--grad); color: #fff; display: grid; place-items: center; padding: 9px; flex: none; }
.brand-mark svg { width: 100%; height: 100%; }
.brand strong { display: block; font-size: .98rem; }
.brand small { color: var(--muted); font-size: .75rem; }
.tabs { flex: 1; overflow-y: auto; padding: 8px 10px 16px; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.tab-group { padding: 16px 10px 6px; font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.tab { display: flex; align-items: center; gap: .7rem; width: 100%; padding: .55rem .7rem; border-radius: 10px; color: var(--muted); font-weight: 500; text-align: left; transition: all .15s; }
.tab:hover { color: var(--text); background: var(--panel-2); }
.tab.on { color: var(--text); background: color-mix(in srgb, var(--primary) 18%, var(--panel-2)); box-shadow: inset 2px 0 0 var(--primary); }
.tab.on .ico { color: var(--primary); }
.side-foot { display: flex; gap: 6px; padding: 12px; border-top: 1px solid var(--line); }
.side-foot .abtn { flex: 1; }

.editor { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: color-mix(in srgb, var(--panel) 55%, var(--bg)); }
.ed-header { display: flex; align-items: flex-start; gap: .8rem; padding: 20px 22px 16px; border-bottom: 1px solid var(--line); }
.ed-title { display: flex; align-items: center; gap: .5rem; font-size: 1.15rem; letter-spacing: -.01em; }
.ed-title .ico { color: var(--primary); }
.ed-desc { color: var(--muted); font-size: .86rem; margin-top: 2px; }
.menu-btn { display: none; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line-2); place-items: center; flex: none; }
.ed-body { flex: 1; overflow-y: auto; padding: 18px 22px 120px; display: grid; gap: 16px; align-content: start; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }

/* campos */
.field { display: grid; gap: 6px; }
.field > label { font-weight: 600; font-size: .85rem; }
.field small { color: var(--muted); font-size: .78rem; }
.f-head { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-top: 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.ed-body > .f-head:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.f-info { color: var(--muted); font-size: .85rem; padding: 10px 12px; border-radius: 10px; background: var(--panel-2); }
input[type=text], input[type=number], input[type=search], select, textarea { width: 100%; padding: .62em .8em; border-radius: 10px; border: 1px solid var(--line-2); background: var(--bg); outline: none; transition: border-color .15s, box-shadow .15s; }
textarea { resize: vertical; min-height: 60px; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent); }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239C95B2' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .7em center; padding-right: 2.2em; }
.color { display: flex; gap: 8px; }
.swatch { position: relative; width: 42px; height: 38px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line-2); flex: none; cursor: pointer; }
.swatch input { position: absolute; inset: -8px; width: calc(100% + 16px); height: calc(100% + 16px); border: 0; cursor: pointer; }
.hex { font-family: ui-monospace, monospace; text-transform: uppercase; }
.range { display: flex; align-items: center; gap: 10px; }
.range input { flex: 1; accent-color: var(--primary); }
.range output { min-width: 52px; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-size: .85rem; }
.switch { display: flex; align-items: center; gap: .7rem; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { position: relative; width: 40px; height: 23px; border-radius: 999px; background: var(--line-2); transition: background .2s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 2px 6px rgb(0 0 0 / .3); }
.switch input:checked + .track { background: var(--grad); }
.switch input:checked + .track::after { transform: translateX(17px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 35%, transparent); }
.sw-label { font-weight: 500; }
.icon-btn { display: flex; align-items: center; gap: .6rem; padding: .5em .7em; border-radius: 10px; border: 1px solid var(--line-2); background: var(--bg); text-align: left; }
.icon-btn > .ico:first-child { width: 30px; height: 30px; padding: 6px; border-radius: 9px; background: color-mix(in srgb, var(--primary) 18%, transparent); color: var(--primary); }
.icon-btn span:nth-child(2) { flex: 1; }
.icon-btn:hover { border-color: var(--primary); }

.img-ctl { display: flex; gap: 10px; }
.img-thumb { width: 74px; height: 74px; flex: none; border-radius: 12px; overflow: hidden; border: 1px solid var(--line-2); background: repeating-conic-gradient(#221d30 0 25%, #191523 0 50%) 0 0 / 14px 14px; display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.img-thumb img { width: 100%; height: 100%; object-fit: cover; }
.img-thumb.empty .ico { width: 26px; height: 26px; }
.img-side { flex: 1; display: grid; gap: 8px; align-content: start; min-width: 0; }
.img-actions { display: flex; gap: 6px; }

/* listas */
.list { display: grid; gap: 8px; }
.list-head { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.list-head .f-head { margin: 0; padding: 0; border: 0; }
.list-head .count { font-size: .75rem; padding: .1em .6em; border-radius: 999px; background: var(--panel-2); color: var(--muted); }
.item { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); overflow: hidden; }
.item.open { border-color: var(--line-2); }
.item-head { display: flex; align-items: center; gap: .6rem; padding: .55rem .6rem .55rem .75rem; cursor: pointer; }
.item-head > .ico { color: var(--primary); }
.item-n { width: 22px; height: 22px; border-radius: 7px; background: var(--panel-2); display: grid; place-items: center; font-size: .72rem; font-weight: 700; color: var(--muted); flex: none; }
.item-title { flex: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.item-actions { display: flex; gap: 2px; }
.item-actions button { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; color: var(--muted); }
.item-actions button:hover:not(:disabled) { background: var(--panel-2); color: var(--text); }
.item-actions button.danger:hover { color: var(--err); }
.item-actions button:disabled { opacity: .3; cursor: default; }
.item-actions .ico { width: 15px; height: 15px; }
.item-caret { color: var(--muted); transition: transform .2s; display: grid; }
.item.open .item-caret { transform: rotate(180deg); }
.item-body { display: grid; gap: 14px; padding: 6px 14px 16px; border-top: 1px solid var(--line); padding-top: 14px; }

/* temas */
.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.preset { display: grid; gap: 6px; padding: 6px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); font-size: .78rem; font-weight: 600; text-align: center; transition: all .15s; }
.preset:hover { border-color: var(--line-2); transform: translateY(-1px); }
.preset.on { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent); }
.pv-swatch { position: relative; height: 54px; border-radius: 9px; overflow: hidden; display: block; border: 1px solid rgb(255 255 255 / .08); }
.pv-swatch i { position: absolute; left: 8px; top: 10px; width: 46%; height: 12px; border-radius: 99px; }
.pv-swatch b { position: absolute; left: 8px; right: 8px; bottom: 8px; height: 16px; border-radius: 5px; }
.pv-swatch em { position: absolute; right: 10px; top: 10px; width: 12px; height: 12px; border-radius: 50%; }

/* seções */
.sec-list { display: grid; gap: 6px; margin-top: 10px; }
.sec-row { display: flex; align-items: center; gap: .6rem; padding: .5rem .5rem .5rem .7rem; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); }
.sec-row.off .sec-name { color: var(--muted); text-decoration: line-through; }
.sec-name { flex: 1; text-align: left; font-weight: 600; }
.switch.mini .track { width: 34px; height: 20px; }
.switch.mini .track::after { width: 14px; height: 14px; }
.switch.mini input:checked + .track::after { transform: translateX(14px); }

.backup { display: grid; gap: 10px; }
.backup .abtn { justify-content: flex-start; }
.storage { display: flex; gap: .6rem; align-items: flex-start; padding: 12px; border-radius: 12px; font-size: .88rem; }
.storage.ok { background: color-mix(in srgb, var(--ok) 12%, transparent); color: var(--ok); }
.storage.warn { background: color-mix(in srgb, var(--warn) 12%, transparent); color: var(--warn); }

/* prévia */
.preview { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: radial-gradient(circle at 50% 0%, #1b1530, var(--bg) 60%); }
.pv-bar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.devices { display: flex; gap: 2px; padding: 3px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); }
.dev { width: 34px; height: 30px; border-radius: 9px; display: grid; place-items: center; color: var(--muted); }
.dev.on { background: var(--panel-2); color: var(--text); }
.save-state { flex: 1; text-align: right; color: var(--ok); font-size: .82rem; font-weight: 600; display: flex; align-items: center; justify-content: flex-end; gap: .4em; }
.save-state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.save-state.dirty { color: var(--warn); }
.save-state.dirty::before { animation: pulse-dot 1.4s infinite; }
@keyframes pulse-dot { 50% { opacity: .3; } }
.pv-stage { flex: 1; overflow: auto; display: flex; justify-content: center; padding: 16px; min-height: 0; }
.pv-frame { width: 100%; height: 100%; border-radius: 14px; overflow: hidden; border: 1px solid var(--line-2); box-shadow: 0 30px 60px -30px #000; transition: width .35s cubic-bezier(.2,.8,.2,1); background: #000; }
.pv-frame[data-device=tablet] { width: 820px; flex: none; }
.pv-frame[data-device=mobile] { width: 390px; flex: none; border-radius: 30px; border-width: 8px; border-color: #26213a; }
.pv-frame iframe { width: 100%; height: 100%; border: 0; display: block; background: #fff; }
.view-toggle { display: none; }

/* modal */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; background: rgb(5 3 10 / .7); backdrop-filter: blur(6px); animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.modal-card { width: min(560px, 100%); max-height: 80vh; display: flex; flex-direction: column; gap: 12px; padding: 18px; border-radius: 20px; background: var(--panel); border: 1px solid var(--line-2); }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 6px; overflow-y: auto; padding: 2px; }
.icon-grid button { display: grid; justify-items: center; gap: 6px; padding: 12px 4px 8px; border-radius: 12px; border: 1px solid var(--line); font-size: .7rem; color: var(--muted); transition: all .15s; }
.icon-grid button .ico { width: 24px; height: 24px; color: var(--text); }
.icon-grid button:hover { border-color: var(--primary); color: var(--text); transform: translateY(-2px); }
.icon-grid button.on { background: color-mix(in srgb, var(--primary) 20%, transparent); border-color: var(--primary); }

/* toasts */
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: grid; gap: 8px; max-width: min(380px, calc(100% - 32px)); }
.toast { display: flex; gap: .6rem; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line-2); box-shadow: 0 20px 40px -20px #000; animation: slide .3s cubic-bezier(.2,.8,.2,1); transition: opacity .4s, transform .4s; }
.toast.ok .ico { color: var(--ok); } .toast.warn .ico { color: var(--warn); } .toast.err .ico { color: var(--err); }
.toast.out { opacity: 0; transform: translateY(10px); }
@keyframes slide { from { opacity: 0; transform: translateY(16px); } }

/* responsivo */
@media (max-width: 1280px) { .adm { grid-template-columns: 210px 360px 1fr; } }
@media (max-width: 1020px) {
  .adm { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 50; transform: translateX(-100%); transition: transform .3s; box-shadow: 20px 0 40px -20px #000; }
  .nav-open .side { transform: none; }
  .menu-btn { display: grid; }
  .editor, .preview { grid-area: 1 / 1; }
  .view-edit .preview { visibility: hidden; }
  .view-preview .editor { visibility: hidden; }
  .view-toggle { display: inline-flex; align-items: center; gap: .5em; position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 40; padding: .75em 1.2em; border-radius: 999px; background: var(--grad); color: #fff; font-weight: 700; box-shadow: 0 12px 30px -10px var(--primary); }
  .pv-stage { padding: 8px 8px 72px; }
  .pv-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; visibility: visible; border-bottom: 0; border-top: 1px solid var(--line); }
  .view-toggle { bottom: 76px; }
  .ed-body { padding-bottom: 160px; }
}
@media (max-width: 600px) {
  .pv-bar { flex-wrap: wrap; }
  .devices { display: none; }
  .ed-header, .ed-body { padding-left: 16px; padding-right: 16px; }
}
