/* ==========================================================================
   Modo edición: barra superior, inspector y controles de bloques
   ========================================================================== */

/* ---------- Barra de edición (fuera del Mac) ---------- */
.editbar {
  position: fixed; z-index: 200; top: 14px; left: calc(50% - var(--insp) / 2); transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px;
  padding: 6px 6px 6px 14px; border-radius: 99px;
  font-size: 12.5px; font-weight: 500; color: #fff;
  background: rgba(22,22,26,.88);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 10px 30px -10px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.1);
  animation: ebIn .6s var(--spring);
  transition: left .5s var(--out);
  white-space: nowrap;
  max-width: calc(100vw - var(--insp) - 24px);
  overflow-x: auto; scrollbar-width: none;
}
.editbar[hidden] { display: none; }
@keyframes ebIn { from { opacity: 0; transform: translate(-50%, -30px); } }
.eb-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.editbar button { padding: 7px 12px; border-radius: 99px; color: #fff; font-weight: 600; }
.editbar button:hover { background: rgba(255,255,255,.12); }
.editbar .eb-primary { background: var(--accent); }
.editbar .eb-primary:hover { background: color-mix(in srgb, var(--accent) 85%, #fff); }
.editbar .eb-x { opacity: .6; padding: 7px 10px; }
.eb-status { opacity: .55; min-width: 64px; }
.eb-status.saving { opacity: 1; color: #FEBC2E; }
.eb-switch { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; margin-right: 4px; }
.eb-switch input { display: none; }
.eb-switch i { position: relative; width: 30px; height: 18px; border-radius: 99px; background: rgba(255,255,255,.25); transition: background .2s; }
.eb-switch i::after { content: ""; position: absolute; left: 2px; top: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .3s var(--spring); }
.eb-switch input:checked + i { background: #34C759; }
.eb-switch input:checked + i::after { transform: translateX(12px); }

/* ---------- Inspector (panel derecho) ---------- */
.inspector {
  position: fixed; z-index: 150; top: 0; right: 0; bottom: 0;
  width: 380px; max-width: 100vw;
  display: flex; flex-direction: column;
  background: var(--tex-grain), #FBFAF8;
  border-left: 1px solid rgba(0,0,0,.08);
  box-shadow: -20px 0 50px -20px rgba(0,0,0,.25);
  transform: translateX(105%);
  transition: transform .5s var(--out);
  font-size: 13px; color: var(--ink);
}
body.inspecting .inspector { transform: none; }
.insp-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 20px 20px 14px; border-bottom: 1px solid rgba(0,0,0,.07); }
.insp-head small { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.insp-head h3 { font-family: var(--serif); font-weight: 400; font-size: 26px; line-height: 1.1; margin-top: 2px; }
.insp-close { width: 30px; height: 30px; border-radius: 50%; background: rgba(0,0,0,.06); font-size: 13px; }
.insp-close:hover { background: rgba(0,0,0,.12); }
.insp-body { flex: 1; overflow: auto; padding: 16px 20px 40px; }
.insp-body::-webkit-scrollbar { width: 10px; }
.insp-body::-webkit-scrollbar-thumb { background: rgba(0,0,0,.15); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }

.fld { display: grid; gap: 6px; margin-bottom: 16px; }
.fld > label, .fld > .lbl { font-size: 12px; font-weight: 600; color: #44444A; }
.fld .hint { font-size: 11px; color: var(--muted); }
.fld input[type="text"], .fld input[type="url"], .fld textarea, .fld select {
  width: 100%; font: inherit; font-size: 13px; padding: 9px 11px; border-radius: 9px;
  border: 1px solid rgba(0,0,0,.12); background: #fff; color: var(--ink); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.fld textarea { resize: vertical; line-height: 1.5; }
.fld input:focus, .fld textarea:focus, .fld select:focus { border-color: var(--select); box-shadow: 0 0 0 3px rgba(47,111,237,.15); }
.fld input[type="range"] { width: 100%; accent-color: var(--accent); }
.fld .range-row { display: flex; gap: 10px; align-items: center; }
.fld .range-row output { min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.fld input[type="color"] { width: 44px; height: 32px; border: 1px solid rgba(0,0,0,.12); border-radius: 8px; padding: 2px; background: #fff; }
.fld .color-row { display: flex; gap: 8px; align-items: center; }
.fld .toggle-row { display: flex; align-items: center; justify-content: space-between; }

.img-field { display: grid; gap: 8px; }
.img-drop {
  position: relative; display: grid; place-items: center; gap: 4px;
  min-height: 110px; border-radius: 12px; overflow: hidden; text-align: center;
  border: 2px dashed rgba(0,0,0,.15); background: rgba(0,0,0,.02);
  color: var(--muted); font-weight: 600; font-size: 12px; cursor: pointer;
  transition: border-color .2s, background .2s;
}
.img-drop:hover, .img-drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); color: var(--ink); }
.img-drop img { width: 100%; max-height: 180px; object-fit: cover; display: block; }
.img-drop .ico { width: 22px; height: 22px; }
.img-thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.img-thumb { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: #eee; }
.img-thumb img { width: 100%; height: 100%; object-fit: cover; }
.img-thumb .tb { position: absolute; top: 3px; display: flex; gap: 2px; right: 3px; opacity: 0; transition: opacity .15s; }
.img-thumb:hover .tb { opacity: 1; }
.img-thumb .tb button { width: 20px; height: 20px; border-radius: 6px; background: rgba(0,0,0,.65); color: #fff; font-size: 11px; line-height: 1; }
.img-add { aspect-ratio: 1; border-radius: 8px; border: 2px dashed rgba(0,0,0,.15); display: grid; place-items: center; color: var(--muted); font-size: 22px; }
.img-add:hover { border-color: var(--accent); color: var(--accent); }
.mini-btn { font-size: 12px; font-weight: 600; padding: 6px 10px; border-radius: 8px; background: rgba(0,0,0,.06); }
.mini-btn:hover { background: rgba(0,0,0,.1); }
.mini-btn.danger { color: #D93036; }
.mini-btn.primary { background: var(--ink); color: #fff; }

.lst { display: grid; gap: 8px; }
.lst-item { border: 1px solid rgba(0,0,0,.09); border-radius: 12px; background: #fff; overflow: hidden; }
.lst-item > summary {
  list-style: none; display: flex; align-items: center; gap: 8px;
  padding: 10px 10px 10px 12px; cursor: pointer; font-weight: 600;
}
.lst-item > summary::-webkit-details-marker { display: none; }
.lst-item > summary::before { content: "▸"; font-size: 10px; color: var(--muted); transition: transform .2s; }
.lst-item[open] > summary::before { transform: rotate(90deg); }
.lst-item > summary .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lst-item > summary button { width: 24px; height: 24px; border-radius: 6px; color: var(--muted); font-size: 12px; }
.lst-item > summary button:hover { background: rgba(0,0,0,.07); color: var(--ink); }
.lst-body { padding: 4px 12px 2px; border-top: 1px solid rgba(0,0,0,.06); }
.lst-add { width: 100%; padding: 10px; border-radius: 12px; border: 2px dashed rgba(0,0,0,.14); font-weight: 600; color: var(--muted); }
.lst-add:hover { border-color: var(--accent); color: var(--accent); }

.insp-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; padding-top: 16px; border-top: 1px solid rgba(0,0,0,.07); }
.insp-note { font-size: 12px; line-height: 1.5; color: var(--muted); padding: 10px 12px; border-radius: 10px; background: rgba(0,0,0,.04); margin-bottom: 16px; }

/* ---------- Controles dentro de las ventanas ---------- */
.editing .blocks > .blk { position: relative; border-radius: .7em; outline: 1.5px dashed transparent; outline-offset: .6em; transition: outline-color .2s; cursor: pointer; }
.editing .blocks > .blk:hover { outline-color: color-mix(in srgb, var(--accent) 55%, transparent); }
.editing .blocks > .blk.selected { outline: 2px solid var(--accent); }
.editing .blocks > .blk a, .editing .blocks > .blk button:not(.blk-tools button) { pointer-events: none; }
.blk-tools {
  position: absolute; z-index: 5; top: -1.7em; right: -.4em;
  display: none; gap: .15em; padding: .2em;
  background: var(--accent); border-radius: .6em; box-shadow: 0 4px 12px -4px rgba(0,0,0,.4);
}
.editing .blk:hover > .blk-tools, .editing .blk.selected > .blk-tools { display: flex; animation: menuIn .2s var(--spring); }
.blk-tools button { width: 1.9em; height: 1.9em; border-radius: .4em; display: grid; place-items: center; color: #fff; }
.blk-tools button:hover { background: rgba(255,255,255,.22); }
.blk-tools .ico { width: 1.05em; height: 1.05em; }
.blk-tools .blk-type { color: #fff; font-size: .75em; font-weight: 700; padding: 0 .6em 0 .4em; display: flex; align-items: center; letter-spacing: .04em; }
.blk-insert {
  position: relative; height: 1.9em; margin: -.1em 0; display: none; align-items: center; justify-content: center;
}
.editing .blk-insert { display: flex; }
.blk-insert::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 2px; background: var(--accent); opacity: 0; transition: opacity .2s; }
.blk-insert button {
  position: relative; width: 1.7em; height: 1.7em; border-radius: 50%;
  background: var(--accent); color: #fff; display: grid; place-items: center;
  opacity: 0; transform: scale(.5); transition: opacity .2s, transform .3s var(--spring);
}
.blk-insert button .ico { width: 1em; height: 1em; }
.blk-insert:hover::before { opacity: .5; }
.blk-insert:hover button { opacity: 1; transform: none; }
.add-big {
  display: none; width: 100%; margin-top: 1.6em; padding: 1.1em; border-radius: .9em;
  border: 2px dashed color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--accent); font-weight: 700;
  align-items: center; justify-content: center; gap: .5em;
  transition: background .2s, transform .3s var(--spring);
}
.add-big .ico { width: 1.2em; height: 1.2em; }
.editing .add-big { display: flex; }
.add-big:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); transform: translateY(-2px); }
.editing .empty-folder { display: none; }
.empty-folder { display: grid; justify-items: center; gap: .6em; padding: 4em 1em; color: var(--w-muted); text-align: center; }

.block-menu { display: grid; grid-template-columns: 1fr 1fr; gap: .15em; min-width: 22em; }
.block-menu .menu-head { grid-column: 1 / -1; }

@media (max-width: 719px) {
  .inspector { width: 100vw; top: 30vh; border-radius: 20px 20px 0 0; transform: translateY(105%); }
  body.inspecting .inspector { transform: none; }
  .editbar { top: auto; bottom: 12px; font-size: 11px; max-width: calc(100vw - 16px); overflow-x: auto; }
  .eb-status, #ebProfile { display: none; }
}
