/* =========================================================
   调试模式（仅开发用，正式访客看不到入口）
   快捷键 P 唤起 / 关闭
   所有样式都以 body.dbg-on 为前缀，关闭后完全无副作用
   ========================================================= */

/* ---------- 编辑态：关掉动效，方便操作 ----------
   注意：这里刻意【不】覆盖 transform —— CSS 的 !important 在计算样式时会压过内联样式，
   一旦压掉，用户在面板里设的 scale() 就既看不到也读不回来（缩放无法累加）。 */
body.dbg-on #main *,
body.dbg-on #dbg-root * { transition: none !important; animation: none !important; }

/* 光标：可点选；禁止误选文字 / 拖拽图片 */
body.dbg-on #main {
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
}
body.dbg-on #main img { -webkit-user-drag: none; }
body.dbg-on #main [contenteditable="true"] {
  cursor: text;
  user-select: text;
  -webkit-user-select: text;
  outline: 1px solid #4de2ff;
  outline-offset: 2px;
}

/* 悬停高亮 */
body.dbg-on #main .dbg-hover {
  outline: 1px dashed #4de2ff !important;
  outline-offset: 1px;
  cursor: crosshair;
}
/* 已选中 */
body.dbg-on #main .dbg-sel {
  outline: 2px solid #ff5fa2 !important;
  outline-offset: 2px;
}
/* 正在拖动 */
body.dbg-on #main .dbg-dragging { cursor: grabbing !important; }

/* ---------- 顶部提示条 ---------- */
#dbg-hint {
  position: fixed;
  top: 0; left: 50%;
  transform: translateX(-50%);
  z-index: 999998;
  display: none;
  gap: 16px;
  align-items: center;
  padding: 7px 18px;
  font-family: var(--mono, monospace);
  font-size: 11px;
  letter-spacing: 1px;
  color: #bfe9ff;
  background: rgba(3, 5, 12, 0.94);
  border: 1px solid rgba(96, 214, 255, 0.35);
  border-top: none;
  white-space: nowrap;
}
body.dbg-on #dbg-hint { display: flex; }
#dbg-hint b { color: #4de2ff; font-weight: normal; }
#dbg-hint span { color: #7b8ba3; }

/* ---------- 面板 ---------- */
#dbg-root {
  position: fixed;
  top: 0; right: 0;
  width: 340px;
  height: 100vh;
  z-index: 999999;
  display: none;
  flex-direction: column;
  font-family: var(--mono, monospace);
  font-size: 11px;
  color: #dbe8f8;
  background: rgba(6, 10, 18, 0.97);
  border-left: 1px solid rgba(96, 214, 255, 0.35);
  box-shadow: -18px 0 40px rgba(0, 0, 0, 0.6);
}
body.dbg-on #dbg-root { display: flex; }

/* =========================================================
   关键：默认【不】改变页面排版
   面板是浮层，内容区宽度与线上完全一致 → 所见即所得。
   只有在手动打开「让位」时才把内容向左挤。
   ========================================================= */
body.dbg-on.dbg-push .app { padding-right: 340px; }

/* ---------- 折叠态：只留一条窄边，便于按真实整宽布局精调位置 ---------- */
#dbg-root { transition: opacity 0.15s; }
#dbg-root.collapsed { width: 36px; }
body.dbg-on.dbg-push.dbg-collapsed .app { padding-right: 36px; }

/* ---------- 透视态：面板半透明，看清底下的内容；鼠标移上去恢复 ---------- */
#dbg-root.peek { opacity: 0.22; }
#dbg-root.peek:hover,
#dbg-root.peek:focus-within { opacity: 1; }
#dbg-root.collapsed .dbg-head { flex-direction: column; padding: 8px 0; gap: 12px; }
#dbg-root.collapsed .dbg-head b,
#dbg-root.collapsed .dbg-head #dbg-close,
#dbg-root.collapsed .dbg-head .badge,
#dbg-root.collapsed .dbg-crumbs,
#dbg-root.collapsed .dbg-opts,
#dbg-root.collapsed .dbg-selbar,
#dbg-root.collapsed .dbg-jump,
#dbg-root.collapsed .dbg-tabs,
#dbg-root.collapsed .dbg-mods,
#dbg-root.collapsed .dbg-body,
#dbg-root.collapsed .dbg-foot { display: none; }
#dbg-root.collapsed .dbg-head .tools { flex-direction: column; gap: 6px; }

#dbg-root * { box-sizing: border-box; }
#dbg-root ::-webkit-scrollbar { width: 6px; }
#dbg-root ::-webkit-scrollbar-thumb { background: rgba(96, 214, 255, 0.3); }

.dbg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(96, 214, 255, 0.2);
  flex-shrink: 0;
}
.dbg-head b { color: #4de2ff; font-weight: normal; letter-spacing: 2px; }
.dbg-head .tools { display: flex; align-items: center; gap: 6px; }
.dbg-head button {
  font-family: inherit; font-size: 11px;
  color: #7e8fa8; border: 1px solid rgba(96, 214, 255, 0.2);
  background: none; padding: 3px 8px; cursor: pointer;
}
.dbg-head button:hover { color: #4de2ff; border-color: #4de2ff; }
.dbg-head .badge {
  font-size: 10px;
  color: #ff9ec7;
  border: 1px solid rgba(255, 95, 162, 0.4);
  background: rgba(255, 95, 162, 0.1);
  padding: 2px 6px;
  white-space: nowrap;
}

/* ---------- 排版选项行（让位 / 透视） ---------- */
.dbg-opts {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-bottom: 1px solid rgba(96, 214, 255, 0.14);
  flex-shrink: 0;
}
.dbg-opts .dbg-btn { flex: 1; font-size: 10px; padding: 5px 6px; }
.dbg-opts .dbg-btn.on {
  color: #4de2ff;
  border-color: #4de2ff;
  background: rgba(77, 226, 255, 0.16);
}
.dbg-opts .state { font-size: 10px; color: #5f6d82; white-space: nowrap; }

/* ---------- DOM 面包屑（照 DevTools 的做法） ---------- */
.dbg-crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1px;
  padding: 7px 12px;
  border-bottom: 1px solid rgba(96, 214, 255, 0.14);
  flex-shrink: 0;
  max-height: 62px;
  overflow-y: auto;
}
.dbg-crumbs button {
  font-family: inherit;
  font-size: 10px;
  color: #8fa0b8;
  background: none;
  border: none;
  padding: 2px 5px;
  cursor: pointer;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dbg-crumbs button:hover { color: #4de2ff; background: rgba(77, 226, 255, 0.14); }
.dbg-crumbs button.cur { color: #ff9ec7; }
.dbg-crumbs .sep { color: #3a475c; font-size: 10px; }
.dbg-crumbs .none { color: #5f6d82; }

/* ---------- 已修改清单 ---------- */
.dbg-mods { display: none; }
.dbg-mods.on { display: block; }
.dbg-mods .item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 0;
  border-bottom: 1px dashed rgba(96, 214, 255, 0.1);
}
.dbg-mods .item .txt {
  flex: 1;
  color: #b7c6da;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.dbg-mods .item .txt:hover { color: #4de2ff; }
.dbg-mods .item .gone { color: #5f6d82; }
.dbg-mods .empty { color: #5f6d82; padding: 8px 0; }

/* ---------- 图片缩略图 ---------- */
.dbg-thumb {
  margin-top: 6px;
  padding: 6px;
  border: 1px solid rgba(96, 214, 255, 0.2);
  background: #0b1220;
  text-align: center;
}
.dbg-thumb img { max-width: 100%; max-height: 84px; object-fit: contain; margin: 0 auto; }
.dbg-thumb .meta { color: #5f6d82; margin-top: 4px; }

/* ---------- 拖动坐标提示 ---------- */
#dbg-coord {
  position: fixed;
  z-index: 999999;
  display: none;
  padding: 3px 8px;
  font-family: var(--mono, monospace);
  font-size: 11px;
  color: #03050c;
  background: #4de2ff;
  white-space: nowrap;
  pointer-events: none;
}
#dbg-coord.on { display: block; }

/* ---------- 快捷键说明浮层 ---------- */
#dbg-help {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(3, 5, 12, 0.8);
}
#dbg-help.on { display: flex; }
#dbg-help .box {
  width: min(560px, 90vw);
  padding: 18px 22px;
  background: #070c16;
  border: 1px solid rgba(96, 214, 255, 0.35);
  font-family: var(--mono, monospace);
  font-size: 11px;
  color: #dbe8f8;
  line-height: 2;
}
#dbg-help h4 { color: #4de2ff; font-weight: normal; letter-spacing: 2px; margin-bottom: 10px; }
#dbg-help table { width: 100%; border-collapse: collapse; }
#dbg-help td { padding: 2px 0; vertical-align: top; }
#dbg-help td:first-child { color: #4de2ff; width: 190px; white-space: nowrap; }
#dbg-help td:last-child { color: #9fb0c6; }

/* 选中信息 */
.dbg-selbar {
  padding: 8px 12px;
  border-bottom: 1px solid rgba(96, 214, 255, 0.14);
  flex-shrink: 0;
}
.dbg-selbar .path {
  color: #ff9ec7;
  word-break: break-all;
  line-height: 1.5;
  max-height: 46px;
  overflow-y: auto;
}
.dbg-selbar .path.empty { color: #5f6d82; }
.dbg-selbar .ops { display: flex; gap: 6px; margin-top: 7px; }

/* 快速定位 */
.dbg-jump {
  padding: 8px 12px;
  border-bottom: 1px solid rgba(96, 214, 255, 0.14);
  flex-shrink: 0;
}
.dbg-jump select {
  width: 100%;
  font-family: inherit; font-size: 11px;
  color: #dbe8f8; background: #0b1220;
  border: 1px solid rgba(96, 214, 255, 0.2);
  padding: 5px 6px; outline: none;
}
.dbg-jump select:focus { border-color: #4de2ff; }

/* 标签页 */
.dbg-tabs { display: flex; flex-shrink: 0; border-bottom: 1px solid rgba(96, 214, 255, 0.2); }
.dbg-tabs button {
  flex: 1;
  padding: 8px 0;
  font-family: inherit; font-size: 11px; letter-spacing: 1px;
  color: #7e8fa8; background: none; border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
}
.dbg-tabs button:hover { color: #bfe9ff; }
.dbg-tabs button.on { color: #4de2ff; border-bottom-color: #4de2ff; }

/* 表单区 */
.dbg-body { flex: 1; overflow-y: auto; padding: 10px 12px 20px; }
.dbg-sec { display: none; }
.dbg-sec.on { display: block; }

.dbg-row { margin-bottom: 9px; }
.dbg-row > label {
  display: block;
  color: #7e8fa8;
  margin-bottom: 3px;
  letter-spacing: 1px;
}
.dbg-row .line { display: flex; align-items: center; gap: 6px; }
.dbg-row input[type="text"],
.dbg-row input[type="number"],
.dbg-row select,
.dbg-row textarea {
  width: 100%;
  font-family: inherit; font-size: 11px;
  color: #dbe8f8; background: #0b1220;
  border: 1px solid rgba(96, 214, 255, 0.2);
  padding: 5px 7px; outline: none;
}
.dbg-row textarea { resize: vertical; min-height: 58px; line-height: 1.5; }
.dbg-row input:focus, .dbg-row select:focus, .dbg-row textarea:focus { border-color: #4de2ff; }
.dbg-row input[type="range"] { flex: 1; accent-color: #4de2ff; }
.dbg-row input[type="color"] {
  width: 34px; height: 26px; padding: 0; background: none;
  border: 1px solid rgba(96, 214, 255, 0.2); cursor: pointer; flex-shrink: 0;
}
.dbg-row .num { color: #4de2ff; min-width: 52px; text-align: right; flex-shrink: 0; }
.dbg-row .unit { color: #5f6d82; flex-shrink: 0; }

/* 小按钮 */
.dbg-btn {
  font-family: inherit; font-size: 11px; letter-spacing: 1px;
  color: #bfe9ff;
  background: rgba(77, 226, 255, 0.08);
  border: 1px solid rgba(96, 214, 255, 0.25);
  padding: 6px 10px; cursor: pointer;
}
.dbg-btn:hover { color: #fff; border-color: #4de2ff; background: rgba(77, 226, 255, 0.16); }
.dbg-btn.sm { padding: 4px 8px; flex: 1; }
.dbg-btn.wide { display: block; width: 100%; }
.dbg-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.dbg-btn:disabled:hover { color: #bfe9ff; border-color: rgba(96, 214, 255, 0.25); background: rgba(77, 226, 255, 0.08); }
.dbg-btn.primary { color: #03050c; background: #4de2ff; border-color: #4de2ff; font-weight: 700; }
.dbg-btn.primary:hover { background: #8ef0ff; border-color: #8ef0ff; color: #03050c; }
.dbg-btn.danger { color: #ff8fae; border-color: rgba(255, 95, 162, 0.4); background: rgba(255, 95, 162, 0.08); }
.dbg-btn.danger:hover { color: #fff; border-color: #ff5fa2; background: rgba(255, 95, 162, 0.18); }

.dbg-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.dbg-grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }

.dbg-tip {
  color: #5f6d82;
  line-height: 1.6;
  padding: 6px 0 2px;
  border-top: 1px dashed rgba(96, 214, 255, 0.14);
  margin-top: 4px;
}

/* 底部操作条 */
.dbg-foot {
  flex-shrink: 0;
  padding: 9px 12px;
  border-top: 1px solid rgba(96, 214, 255, 0.2);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.dbg-foot .status { color: #5f6d82; text-align: center; letter-spacing: 1px; }
.dbg-foot .status.ok { color: #4de2ff; }

/* ---------- 导出弹层 ---------- */
#dbg-export {
  position: fixed;
  inset: 0;
  z-index: 1000000;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(3, 5, 12, 0.86);
}
#dbg-export.on { display: flex; }
#dbg-export .box {
  width: min(820px, 92vw);
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  background: #070c16;
  border: 1px solid rgba(96, 214, 255, 0.35);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7);
  font-family: var(--mono, monospace);
  font-size: 11px;
  color: #dbe8f8;
}
#dbg-export .box > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(96, 214, 255, 0.2);
  color: #4de2ff;
  letter-spacing: 2px;
}
#dbg-export .box > header button {
  font-family: inherit; font-size: 12px; color: #7e8fa8;
  background: none; border: 1px solid rgba(96, 214, 255, 0.2);
  padding: 3px 9px; cursor: pointer;
}
#dbg-export .box > header button:hover { color: #4de2ff; border-color: #4de2ff; }
#dbg-export .tabs { display: flex; border-bottom: 1px solid rgba(96, 214, 255, 0.16); }
#dbg-export .tabs button {
  flex: 1; padding: 8px 0;
  font-family: inherit; font-size: 11px; letter-spacing: 1px;
  color: #7e8fa8; background: none; border: none;
  border-bottom: 2px solid transparent; cursor: pointer;
}
#dbg-export .tabs button.on { color: #4de2ff; border-bottom-color: #4de2ff; }
#dbg-export .howto {
  padding: 9px 14px;
  color: #8fa0b8;
  line-height: 1.7;
  border-bottom: 1px solid rgba(96, 214, 255, 0.12);
}
#dbg-export .howto b { color: #4de2ff; font-weight: normal; }
#dbg-export pre {
  flex: 1;
  margin: 0;
  overflow: auto;
  padding: 12px 14px;
  color: #b7e6ff;
  white-space: pre;
  line-height: 1.55;
  tab-size: 2;
}
#dbg-export footer {
  display: flex; gap: 8px; align-items: center;
  padding: 10px 14px;
  border-top: 1px solid rgba(96, 214, 255, 0.2);
}
#dbg-export footer .spacer { flex: 1; }
#dbg-export footer .msg { color: #4de2ff; }
