:root {
  --bg: #0b0d12;
  --panel: #12151d;
  --panel-2: #181c26;
  --line: #292f3c;
  --text: #f6f7fb;
  --muted: #9ba5b6;
  --accent: #e83e8c;
  --accent-2: #ff69ad;
  --success: #3ecf8e;
  --warning: #f5b942;
  --danger: #ff5c71;
  --radius: 12px;
  --shadow: 0 18px 45px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; color: var(--text); background: var(--bg); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
a { color: inherit; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at top, #23283a, #0b0d12 58%); }
.login-card { width: min(430px, 100%); padding: 38px; border: 1px solid var(--line); border-radius: 22px; background: rgba(18,21,29,.96); box-shadow: var(--shadow); }
.login-mark, .brand-mark { display: grid; place-items: center; flex: 0 0 auto; background: var(--accent); color: white; font-weight: 900; letter-spacing: -.04em; }
.login-mark { width: 62px; height: 62px; border-radius: 18px; font-size: 1.45rem; margin-bottom: 26px; }
.login-card h1 { margin: 4px 0 8px; font-size: 2rem; }
.login-copy { margin: 0 0 28px; color: var(--muted); }
.login-form { display: grid; gap: 18px; }
.login-form label, .field { display: grid; gap: 7px; color: #dce1eb; font-size: .9rem; }
input, textarea, select, .rich-editor { width: 100%; border: 1px solid #363d4c; border-radius: 9px; background: #0e1118; color: var(--text); padding: 11px 12px; outline: none; }
input:focus, textarea:focus, select:focus, .rich-editor:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(232,62,140,.12); }
textarea { min-height: 120px; resize: vertical; }
.alert { padding: 12px 14px; border-radius: 9px; margin: 0 0 18px; }
.alert.error { border: 1px solid rgba(255,92,113,.45); background: rgba(255,92,113,.12); color: #ffb7c0; }
.eyebrow { display: block; margin-bottom: 4px; color: var(--muted); font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .13em; }

.editor-page { height: 100vh; overflow: hidden; }
.topbar { height: 64px; display: grid; grid-template-columns: minmax(250px, 1fr) auto minmax(390px, 1fr); align-items: center; gap: 18px; padding: 0 16px; border-bottom: 1px solid var(--line); background: #0e1118; }
.top-brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark { width: 38px; height: 38px; border-radius: 10px; }
.top-brand strong, .top-brand small { display: block; }
.top-brand small { color: var(--muted); font-size: .72rem; }
.top-status { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .78rem; }
.status-pill { padding: 5px 9px; border-radius: 999px; border: 1px solid var(--line); }
.status-pill.saved { color: #9ce9c3; background: rgba(62,207,142,.09); border-color: rgba(62,207,142,.28); }
.status-pill.dirty { color: #ffd67a; background: rgba(245,185,66,.09); border-color: rgba(245,185,66,.3); }
.status-pill.busy { color: #d2c5ff; background: rgba(139,112,255,.12); border-color: rgba(139,112,255,.32); }
.top-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.top-actions form { margin: 0; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 38px; padding: 8px 13px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel-2); color: var(--text); text-decoration: none; cursor: pointer; transition: .16s ease; }
.button:hover { border-color: #50596a; transform: translateY(-1px); }
.button.primary { border-color: var(--accent); background: var(--accent); font-weight: 750; }
.button.primary:hover { background: var(--accent-2); }
.button.ghost { background: transparent; }
.button.danger { border-color: rgba(255,92,113,.4); color: #ffadb8; background: rgba(255,92,113,.08); }
.button.small { min-height: 32px; padding: 6px 10px; font-size: .78rem; }
.button.full { width: 100%; }
.icon-button { width: 36px; height: 36px; display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: 9px; background: transparent; cursor: pointer; font-size: 1.05rem; }
.icon-button:hover { background: var(--panel-2); }

.studio { height: calc(100vh - 64px); display: grid; grid-template-columns: 275px minmax(420px, 1fr) 350px; }
.panel { min-width: 0; background: var(--panel); }
.left-panel { display: grid; grid-template-rows: minmax(245px, 42%) 1fr; border-right: 1px solid var(--line); overflow: hidden; }
.right-panel { border-left: 1px solid var(--line); overflow: hidden; }
.panel-section { display: flex; flex-direction: column; min-height: 0; border-bottom: 1px solid var(--line); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; padding: 16px; }
.panel-heading h2 { margin: 0; font-size: 1rem; }
.sortable-list { padding: 0 9px 14px; overflow: auto; min-height: 0; }
.list-item { display: grid; grid-template-columns: 24px 1fr auto; align-items: center; gap: 8px; min-height: 47px; margin-bottom: 5px; padding: 7px 8px; border: 1px solid transparent; border-radius: 9px; color: #dfe4ed; cursor: pointer; user-select: none; }
.list-item:hover { background: var(--panel-2); }
.list-item.active { border-color: rgba(232,62,140,.55); background: rgba(232,62,140,.11); }
.list-item.dragging { opacity: .35; }
.drag-handle { color: #667085; cursor: grab; font-size: .85rem; letter-spacing: -2px; }
.item-copy { min-width: 0; }
.item-copy strong, .item-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-copy strong { font-size: .86rem; }
.item-copy small { color: var(--muted); font-size: .7rem; }
.item-tools { display: flex; gap: 3px; }
.mini-button { width: 26px; height: 26px; display: grid; place-items: center; border: 0; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; }
.mini-button:hover { background: #2a3040; color: white; }
.visibility-dot { width: 8px; height: 8px; border-radius: 999px; background: var(--success); }
.visibility-dot.hidden { background: #596273; }
.empty-state { margin: 10px; padding: 22px 12px; border: 1px dashed #353c49; border-radius: 10px; color: var(--muted); text-align: center; font-size: .82rem; }

.workspace { min-width: 0; display: flex; flex-direction: column; background: #090b10; }
.workspace-toolbar { min-height: 50px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; padding: 8px 14px; border-bottom: 1px solid var(--line); background: #10131a; }
.device-switch { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 9px; }
.device-button { width: 34px; height: 28px; border: 0; border-radius: 6px; background: transparent; cursor: pointer; color: var(--muted); }
.device-button.active { background: #2a3040; color: white; }
.preview-title { min-width: 0; text-align: center; }
.preview-title strong, .preview-title span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-title strong { font-size: .82rem; }
.preview-title span { color: var(--muted); font-size: .68rem; }
.canvas-shell { flex: 1; min-height: 0; overflow: auto; padding: 24px; display: grid; justify-items: center; align-items: start; background-image: linear-gradient(45deg, #0c0f15 25%, transparent 25%), linear-gradient(-45deg, #0c0f15 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #0c0f15 75%), linear-gradient(-45deg, transparent 75%, #0c0f15 75%); background-size: 22px 22px; background-position: 0 0, 0 11px, 11px -11px, -11px 0; }
.device-frame { width: 100%; height: calc(100vh - 162px); border: 1px solid #343b4a; border-radius: 10px; overflow: hidden; background: white; box-shadow: var(--shadow); transition: width .22s ease; }
.device-frame.tablet { width: min(820px, 100%); }
.device-frame.mobile { width: min(390px, 100%); }
.device-frame iframe { width: 100%; height: 100%; border: 0; background: white; }

.inspector-tabs { height: 49px; display: grid; grid-template-columns: repeat(6, 1fr); border-bottom: 1px solid var(--line); overflow-x: auto; }
.inspector-tabs button { min-width: 52px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); cursor: pointer; font-size: .7rem; }
.inspector-tabs button.active { color: white; border-bottom-color: var(--accent); background: rgba(232,62,140,.07); }
.inspector { height: calc(100% - 49px); overflow: auto; padding: 17px; }
.inspector h2 { margin: 0 0 4px; font-size: 1.05rem; }
.inspector-copy { margin: 0 0 18px; color: var(--muted); font-size: .8rem; }
.form-grid { display: grid; gap: 14px; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 42px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; background: #0e1118; }
.check-row span { font-size: .82rem; }
.toggle { appearance: none; width: 38px; height: 22px; padding: 0; border: 0; border-radius: 999px; background: #3b4250; position: relative; cursor: pointer; }
.toggle::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: white; transition: .18s; }
.toggle:checked { background: var(--accent); }
.toggle:checked::after { transform: translateX(16px); }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; padding-top: 15px; border-top: 1px solid var(--line); }
.color-field { display: grid; grid-template-columns: 48px 1fr; gap: 8px; }
.color-field input[type=color] { height: 42px; padding: 3px; }
.rich-toolbar { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px; border: 1px solid #363d4c; border-bottom: 0; border-radius: 9px 9px 0 0; background: #151923; }
.rich-toolbar button { min-width: 30px; height: 28px; border: 0; border-radius: 5px; background: transparent; cursor: pointer; }
.rich-toolbar button:hover { background: #2a3040; }
.rich-editor { min-height: 210px; border-radius: 0 0 9px 9px; overflow: auto; }
.code-editor { min-height: 230px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .78rem; }
.help-text { color: var(--muted); font-size: .72rem; line-height: 1.45; }

.modal { width: min(560px, calc(100vw - 30px)); max-height: min(780px, calc(100vh - 30px)); padding: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--text); box-shadow: var(--shadow); overflow: auto; }
.modal::backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(4px); }
.modal.wide { width: min(900px, calc(100vw - 30px)); padding-bottom: 20px; }
.modal > form { padding-bottom: 0; }
.modal-heading { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 18px 20px; border-bottom: 1px solid var(--line); background: rgba(18,21,29,.98); }
.modal-heading h2 { margin: 0; font-size: 1.1rem; }
#formDialogBody { display: grid; gap: 14px; padding: 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 15px 20px; border-top: 1px solid var(--line); }
.modal-actions.left { justify-content: flex-start; }
.upload-row { display: grid; grid-template-columns: 1fr auto; gap: 9px; padding: 18px 20px; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; padding: 0 20px 20px; }
.media-card { overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: #0e1118; }
.media-card img { width: 100%; height: 118px; display: block; object-fit: cover; background: #202532; }
.media-info { padding: 9px; }
.media-info strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .72rem; }
.media-actions { display: grid; grid-template-columns: 1fr auto; gap: 5px; margin-top: 8px; }
.backups-list { padding: 0 20px 20px; }
.backup-item { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.backup-item strong, .backup-item small { display: block; }
.backup-item small { color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 100; max-width: min(560px, calc(100vw - 30px)); padding: 11px 15px; border: 1px solid var(--line); border-radius: 10px; background: #1b202b; box-shadow: var(--shadow); transform: translate(-50%, 18px); opacity: 0; pointer-events: none; transition: .22s; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.error { border-color: rgba(255,92,113,.5); color: #ffc0c8; }

@media (max-width: 1180px) {
  .studio { grid-template-columns: 245px minmax(390px, 1fr) 315px; }
  .topbar { grid-template-columns: 220px 1fr auto; }
  .publish-date { display: none; }
}
@media (max-width: 900px) {
  .editor-page { overflow: auto; }
  .topbar { height: auto; min-height: 64px; grid-template-columns: 1fr auto; padding: 10px 12px; }
  .top-status { display: none; }
  .top-actions { flex-wrap: wrap; }
  .studio { height: auto; min-height: calc(100vh - 64px); grid-template-columns: 220px minmax(420px, 1fr); }
  .right-panel { grid-column: 1 / -1; min-height: 500px; border-left: 0; border-top: 1px solid var(--line); }
  .device-frame { height: 650px; }
}
/* TM Site Studio v2 — editor por blocos */
.studio { grid-template-columns: 310px minmax(460px, 1fr) 370px; }
.left-panel { display: grid; grid-template-rows: minmax(150px, 25%) minmax(190px, 33%) minmax(220px, 42%); }
.compact-list .list-item { min-height: 40px; }
.blocks-section { background: linear-gradient(180deg, rgba(87,181,255,.035), transparent 35%); }
.block-list { flex: 1; }
.block-item { grid-template-columns: 20px 28px minmax(0,1fr) auto; }
.block-type-icon { width: 26px; height: 26px; display: grid; place-items: center; border: 1px solid #384151; border-radius: 7px; background: #0d1119; color: #85c9ff; font-size: .72rem; font-weight: 800; }
.block-library-button { margin: 0 10px 12px; min-height: 36px; border-style: dashed; background: rgba(87,181,255,.06); color: #a9dcff; }
.block-library-button:hover { border-color: #57b5ff; }
.canvas-actions { display: flex; gap: 7px; }
.canvas-help { flex: 0 0 auto; padding: 7px 14px; border-top: 1px solid var(--line); background: #10131a; color: var(--muted); text-align: center; font-size: .72rem; }
.device-frame { height: calc(100vh - 190px); }
.inspector-tabs { grid-template-columns: repeat(7, minmax(52px, 1fr)); }
.inspector-tabs button { min-width: 54px; }
.button:disabled, .icon-button:disabled { opacity: .35; cursor: not-allowed; transform: none; }
.modal-copy { margin: 0; padding: 16px 20px 4px; color: var(--muted); font-size: .84rem; }
.block-library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; padding: 18px 20px 24px; }
.library-card { min-height: 130px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 7px; padding: 16px; border: 1px solid var(--line); border-radius: 13px; background: #0e1118; text-align: left; cursor: pointer; transition: .16s ease; }
.library-card:hover { transform: translateY(-2px); border-color: #57b5ff; background: #151b25; box-shadow: 0 12px 30px rgba(0,0,0,.25); }
.library-card strong { font-size: .95rem; }
.library-card small { color: var(--muted); line-height: 1.35; }
.library-icon { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid #3a4658; border-radius: 10px; background: rgba(87,181,255,.08); color: #8bd0ff; font-weight: 900; }
.block-library-modal { min-height: 420px; }
.inspector details { border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.inspector details summary { padding: 10px 12px; cursor: pointer; background: #0e1118; }
.inspector details textarea { border: 0; border-top: 1px solid var(--line); border-radius: 0; }

@media (max-width: 1320px) {
  .studio { grid-template-columns: 275px minmax(420px,1fr) 335px; }
  .topbar { grid-template-columns: 230px 1fr auto; }
  .top-actions .button { padding-inline: 9px; }
}
@media (max-width: 1050px) {
  .studio { grid-template-columns: 250px minmax(390px,1fr); }
  .right-panel { position: fixed; right: 0; top: 64px; bottom: 0; width: min(380px, 90vw); z-index: 30; box-shadow: -18px 0 45px rgba(0,0,0,.38); }
}

