/* =========================================================
   编辑模式的样式 · 只在 body.editing 下生效
   ========================================================= */

body.editing {
  padding-bottom: min(48vh, 460px);
}

/* ---------- 选中 / 悬停高亮 ---------- */

body.editing .is-hover {
  outline: 1px dashed #6f9bff;
  outline-offset: 2px;
  cursor: crosshair;
}

body.editing .is-sel {
  outline: 2px solid #2f6fed !important;
  outline-offset: 2px;
  box-shadow: 0 0 0 6px rgba(47, 111, 237, .12);
  cursor: move;
}

body.editing [contenteditable="true"] {
  outline: 2px solid #f59e0b !important;
  outline-offset: 2px;
  background: rgba(245, 158, 11, .08);
  cursor: text;
}

/* ---------- 拖动 / 缩放 ---------- */

#ed-overlay {
  position: fixed;
  inset: 0;
  z-index: 2147483001;
  pointer-events: none;
  display: none;
}

#ed-overlay .ed-box {
  position: fixed;
  border: 1px dashed #f59e0b;
  pointer-events: none;
}

#ed-overlay .ed-h {
  position: fixed;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  background: #fff;
  border: 1px solid #f59e0b;
  border-radius: 2px;
  pointer-events: auto;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .35);
}

#ed-overlay .ed-nw, #ed-overlay .ed-se { cursor: nwse-resize; }
#ed-overlay .ed-ne, #ed-overlay .ed-sw { cursor: nesw-resize; }
#ed-overlay .ed-n, #ed-overlay .ed-s { cursor: ns-resize; }
#ed-overlay .ed-e, #ed-overlay .ed-w { cursor: ew-resize; }

/* ---------- 面板 ---------- */

#ed-root {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2147483000;
  display: flex;
  flex-direction: column;
  max-height: min(48vh, 460px);
  font: 13px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI",
        "Microsoft YaHei", "PingFang SC", sans-serif;
  color: #e6e9f0;
  background: rgba(16, 20, 28, .97);
  border-top: 1px solid #2b3342;
  box-shadow: 0 -14px 44px rgba(0, 0, 0, .42);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

#ed-root *, #ed-root *::before, #ed-root *::after { box-sizing: border-box; }

/* hidden 必须是硬隐藏，别被 .ed-field 的 display:block 盖掉 */
#ed-root [hidden] { display: none !important; }

.ed-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid #232a36;
  flex: none;
}

.ed-title {
  font-weight: 700;
  letter-spacing: .02em;
  color: #fff;
  white-space: nowrap;
}

.ed-title::before {
  content: "";
  display: inline-block;
  width: 7px; height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: #22c55e;
  vertical-align: 1px;
  animation: ed-blink 2.2s ease-in-out infinite;
}
@keyframes ed-blink { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.ed-sel {
  max-width: 30ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 2px 8px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 11.5px;
  color: #9dbaff;
  background: rgba(47, 111, 237, .16);
  border: 1px solid rgba(47, 111, 237, .3);
  border-radius: 5px;
}

.ed-state { font-size: 12px; color: #8b93a3; white-space: nowrap; }
.ed-state.dirty { color: #fbbf24; }

.ed-grow { flex: 1; }

/* ---------- 按钮 ---------- */

.ed-btn {
  padding: 5px 11px;
  font: inherit;
  font-size: 12.5px;
  color: #d5dae5;
  background: #1d2431;
  border: 1px solid #2e3747;
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .14s ease, border-color .14s ease, color .14s ease;
}
.ed-btn:hover { background: #263043; border-color: #3d4a60; color: #fff; }
.ed-btn:active { transform: translateY(1px); }

.ed-primary { background: #2f6fed; border-color: #2f6fed; color: #fff; font-weight: 600; }
.ed-primary:hover { background: #2a63d6; border-color: #2a63d6; color: #fff; }

.ed-danger:hover { background: #7f1d1d; border-color: #b91c1c; color: #fff; }

/* ---------- 面板主体 ---------- */

.ed-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  padding: 12px 14px 14px;
  overflow-y: auto;
}

.ed-col { min-width: 0; }

.ed-col h4 {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #7c8598;
}
.ed-col h4 + .ed-field, .ed-col h4 + .ed-row { margin-top: 0; }
.ed-row + h4 { margin-top: 14px; }

.ed-field {
  display: block;
  margin-bottom: 9px;
}
.ed-field > span {
  display: block;
  margin-bottom: 4px;
  font-size: 11.5px;
  color: #8b93a3;
}

.ed-field input,
.ed-field textarea,
.ed-row select,
.ed-inline input[type="text"] {
  width: 100%;
  padding: 6px 9px;
  font: inherit;
  font-size: 12.5px;
  color: #e6e9f0;
  background: #0e1219;
  border: 1px solid #2b3342;
  border-radius: 6px;
  transition: border-color .14s ease, box-shadow .14s ease;
}
.ed-field textarea { resize: vertical; min-height: 46px; line-height: 1.5; }

.ed-field input:focus,
.ed-field textarea:focus,
.ed-row select:focus {
  outline: none;
  border-color: #2f6fed;
  box-shadow: 0 0 0 2px rgba(47, 111, 237, .25);
}

.ed-field input:disabled,
.ed-field textarea:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.ed-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 9px;
}

.ed-row select {
  width: auto;
  flex: 1 1 90px;
  cursor: pointer;
}

.ed-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: #8b93a3;
}
.ed-inline > span { white-space: nowrap; }

#edAccent {
  width: 34px;
  height: 26px;
  padding: 2px;
  background: #0e1219;
  border: 1px solid #2b3342;
  border-radius: 6px;
  cursor: pointer;
}

.ed-hint {
  margin: 8px 0 0;
  font-size: 11.5px;
  line-height: 1.6;
  color: #737c8e;
}
.ed-hint code {
  padding: 1px 4px;
  font-family: ui-monospace, Consolas, monospace;
  background: #1d2431;
  border-radius: 4px;
  color: #b9c2d4;
}
.ed-hint.warn { color: #fbbf24; }

/* ---------- 窄屏 ---------- */

@media (max-width: 720px) {
  #ed-root { max-height: 62vh; }
  body.editing { padding-bottom: 62vh; }
  .ed-body { grid-template-columns: 1fr; gap: 12px; }
  .ed-state { display: none; }
}
