/* ============================================================
   MiniForge · 编辑器
   ============================================================ */

.page-full {
  height: calc(100vh - 62px);
  overflow: hidden;
  padding: 0;
}
.page-full + .sitefoot { display: none; }

.ed {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr) 336px;
  height: calc(100vh - 62px);
  background: #eef0f4;
}

/* ---------- 侧栏通用 ---------- */
.ed-side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #fff;
  border-right: 1px solid var(--line);
}
.ed-side-right { border-right: none; border-left: 1px solid var(--line); }

.side-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.side-tab {
  flex: 1;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  transition: .15s;
}
.side-tab:hover { background: var(--line-2); }
.side-tab.on { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }

.side-pane { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; }
.side-pane[hidden] { display: none; }

.side-search { margin-bottom: 10px; }
.side-search input {
  width: 100%;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fbfcfd;
  font-size: 13px;
  outline: none;
}
.side-search input:focus { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px rgba(255, 82, 51, .1); }

.side-tip {
  margin: 12px 4px 6px;
  padding: 9px 11px;
  border-radius: 9px;
  background: #f8f9fb;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--ink-3);
}
.btn-block { width: 100%; margin-top: 10px; }

/* ---------- 组件库 ---------- */
.comp-group { margin-bottom: 12px; }
.comp-group-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  color: var(--ink-3);
  text-transform: uppercase;
  padding: 6px 4px;
}
.comp-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  transition: .14s;
}
.comp-item:hover { background: #fbfcfd; border-color: var(--line); }
.comp-item:hover .comp-add { opacity: 1; }
.comp-icon {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  flex-shrink: 0;
  border-radius: 8px;
  background: linear-gradient(140deg, #f8f9fb, #eef1f6);
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 600;
}
.comp-item:hover .comp-icon { background: var(--brand-soft); color: var(--brand-ink); }
.comp-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.comp-meta b { font-size: 13px; font-weight: 500; color: var(--ink); }
.comp-meta em {
  font-style: normal;
  font-size: 11px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.comp-add {
  opacity: 0;
  color: var(--brand);
  font-size: 15px;
  transition: .14s;
}

/* ---------- 页面列表 ---------- */
.page-item {
  display: flex;
  gap: 9px;
  padding: 9px 10px;
  border-radius: 9px;
  border: 1px solid transparent;
  margin-bottom: 4px;
}
.page-item:hover { background: #fbfcfd; border-color: var(--line); }
.page-item.on { background: var(--brand-soft); border-color: #ffd9cf; }
.page-dot { color: var(--brand); font-size: 12px; line-height: 1.5; }
.page-info { display: flex; flex-direction: column; min-width: 0; }
.page-info b { font-size: 13px; font-weight: 500; }
.page-info em { font-style: normal; font-size: 10.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- 中间 ---------- */
.ed-center { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.ed-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 56px;
  padding: 0 16px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.tb-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tb-back {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  border-radius: 8px;
  color: var(--ink-2);
  font-size: 16px;
}
.tb-back:hover { background: var(--line-2); }
.tb-title { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; gap: 2px; }
.tb-title b { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-title em { font-style: normal; font-size: 11px; color: var(--ink-3); }

/* 页面切换器 */
.tb-pagebar { display: flex; align-items: center; gap: 6px; }
#page-select {
  height: 21px;
  max-width: 190px;
  padding: 0 2px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-2);
  outline: none;
  cursor: pointer;
  transition: .14s;
}
#page-select:hover { background: var(--line-2); border-color: var(--line); color: var(--ink); }
#page-select:focus { border-color: var(--brand); background: #fff; }
.page-path {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 10px;
  color: #b0b7c3;
  white-space: nowrap;
}
.tb-mini {
  display: grid;
  place-items: center;
  width: 21px; height: 21px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1;
  flex-shrink: 0;
}
.tb-mini:hover { border-color: var(--brand); color: var(--brand); background: #fffaf9; }

.tb-right { display: flex; align-items: center; gap: 6px; }
.save-state { font-size: 11.5px; color: var(--ink-3); margin-right: 4px; }
.save-state.dirty { color: #d97706; }
.tb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  min-width: 32px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
  transition: .14s;
}
.tb-btn:hover { border-color: #d6dae1; background: #fbfcfd; }
.tb-btn-main { background: #14171c; border-color: #14171c; color: #fff; }
.tb-btn-main:hover { background: #262b33; border-color: #262b33; }
.tb-btn-accent {
  background: linear-gradient(180deg, #ff6a45, var(--brand));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 5px 14px -8px rgba(255, 82, 51, .9);
}
.tb-btn-accent:hover { background: linear-gradient(180deg, #ff7a56, #f5492a); border-color: transparent; }
.tb-btn[disabled] { opacity: .4; pointer-events: none; }

/* ---------- 画布 ---------- */
.ed-stage {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 24px;
  background:
    radial-gradient(circle at 1px 1px, #d9dee6 1px, transparent 0) 0 0 / 18px 18px,
    #eef0f4;
  display: grid;
  place-items: center;
}
.stage-inner { display: grid; place-items: center; }

.phone-frame {
  display: flex;
  flex-direction: column;
  width: 375px;
  height: min(772px, calc(100vh - 136px));
  min-height: 460px;
  border-radius: 30px;
  background: #fff;
  overflow: hidden;
  box-shadow: 0 0 0 8px #1b1f26, 0 0 0 9px #33383f, 0 30px 60px -24px rgba(16, 24, 40, .4);
}
.phone-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 44px;
  padding: 0 16px;
  font-size: 12px;
  flex-shrink: 0;
  position: relative;
}
.ptb-time { font-weight: 600; font-variant-numeric: tabular-nums; }
.ptb-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  font-weight: 600;
  max-width: 60%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ptb-dots { letter-spacing: 1px; opacity: .7; }

.canvas { flex: 1; overflow-y: auto; overflow-x: hidden; position: relative; }
.canvas::-webkit-scrollbar { width: 0; }

.phone-tabbar {
  display: flex;
  flex-shrink: 0;
  height: 52px;
  border-top: 1px solid #f0f1f4;
  background: #fff;
  padding-bottom: 4px;
}
.ptb-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 10px;
  color: #9aa0a6;
}
.ptb-item.on { color: var(--brand); }
.ptb-item i { font-style: normal; font-size: 16px; line-height: 1; }

/* ---------- 画布内组件节点 ---------- */
.mf-node { position: relative; }
.mf-node::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 1.5px solid transparent;
  pointer-events: none;
  transition: border-color .12s;
}
.mf-node:hover::after { border-color: rgba(255, 82, 51, .45); }
.mf-node.sel::after { border-color: var(--brand); border-width: 2px; }
.mf-node.sel { z-index: 3; }
.mf-node.dragging { opacity: .4; }
.mf-node.drop-before::before,
.mf-node.drop-after::before {
  content: '';
  position: absolute;
  left: 0; right: 0;
  height: 3px;
  background: var(--brand);
  border-radius: 3px;
  z-index: 5;
}
.mf-node.drop-before::before { top: -2px; }
.mf-node.drop-after::before { bottom: -2px; }

.node-bar {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 6;
  display: none;
  gap: 2px;
  padding: 3px;
  border-radius: 8px;
  background: rgba(20, 23, 28, .92);
  box-shadow: 0 6px 16px -8px rgba(0, 0, 0, .5);
}
.mf-node:hover .node-bar, .mf-node.sel .node-bar { display: flex; }
.node-bar button {
  display: grid;
  place-items: center;
  width: 24px; height: 24px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #fff;
  font-size: 12px;
  line-height: 1;
  opacity: .82;
}
.node-bar button:hover { background: rgba(255, 255, 255, .16); opacity: 1; }
.node-bar button.del:hover { background: #d92d20; }

.node-tag {
  position: absolute;
  left: 4px;
  top: 4px;
  z-index: 6;
  display: none;
  padding: 1px 7px;
  border-radius: 5px;
  background: var(--brand);
  color: #fff;
  font-size: 10px;
  font-weight: 500;
  pointer-events: none;
}
.mf-node.sel .node-tag { display: block; }

.canvas-empty {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  height: 100%;
  min-height: 320px;
  padding: 32px;
  text-align: center;
  color: #adb4c0;
  font-size: 12.5px;
  line-height: 1.7;
}
.canvas-empty .ce-icon {
  display: grid;
  place-items: center;
  width: 52px; height: 52px;
  border-radius: 16px;
  background: #fff;
  font-size: 22px;
  box-shadow: 0 8px 20px -12px rgba(16, 24, 40, .3);
}
.canvas-empty b { font-size: 13.5px; color: var(--ink-2); }
.ce-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-top: 10px;
  max-width: 250px;
}
.ce-btn {
  height: 28px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 11.5px;
  color: var(--ink-2);
  transition: .14s;
}
.ce-btn:hover { border-color: var(--brand); color: var(--brand-ink); background: #fffaf9; }
.ce-hint { font-size: 10.5px; color: #b0b7c3; margin-top: 8px; }

/* ---------- 属性面板 ---------- */
.pf-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 2px 12px;
  border-bottom: 1px solid var(--line-2);
  margin-bottom: 6px;
}
.pf-head .pf-icon {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-size: 14px;
  font-weight: 600;
}
.pf-head b { font-size: 13.5px; }
.pf-head em { display: block; font-style: normal; font-size: 11px; color: var(--ink-3); }

.pf-sec {
  margin: 16px 0 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--ink-3);
  text-transform: uppercase;
}

.pf-row { margin-bottom: 12px; }
.pf-row > label {
  display: block;
  font-size: 12px;
  color: var(--ink-2);
  margin-bottom: 5px;
}
.pf-row .pf-tip { font-size: 10.5px; color: var(--ink-3); margin-top: 4px; }

.pf-input, .pf-select, .pf-textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 12.5px;
  color: var(--ink);
  outline: none;
  transition: .14s;
}
.pf-input, .pf-select { height: 34px; padding: 0 10px; }
.pf-textarea { padding: 8px 10px; min-height: 74px; resize: vertical; line-height: 1.6; }
.pf-input:focus, .pf-select:focus, .pf-textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(255, 82, 51, .1);
}

.pf-color { display: flex; align-items: center; gap: 6px; }
.pf-color input[type=color] {
  width: 34px; height: 34px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}
.pf-color .pf-input { flex: 1; font-family: ui-monospace, Menlo, monospace; }
.pf-color .pf-clear {
  width: 34px; height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink-3);
  font-size: 12px;
}
.pf-color .pf-clear:hover { color: #d92d20; border-color: #f0c9c4; }

.pf-switch { display: flex; align-items: center; gap: 8px; }
.pf-switch input { display: none; }
.pf-switch .track {
  position: relative;
  width: 38px; height: 22px;
  border-radius: 999px;
  background: #dfe3ea;
  transition: .18s;
  cursor: pointer;
}
.pf-switch .track::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
  transition: .18s;
}
.pf-switch input:checked + .track { background: var(--brand); }
.pf-switch input:checked + .track::after { transform: translateX(16px); }

.pf-img { display: flex; gap: 8px; align-items: center; }
.pf-img .thumb {
  width: 56px; height: 46px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f8f9fb center/cover no-repeat;
  flex-shrink: 0;
}
.pf-img .col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.pf-img .col .pf-input { font-size: 11.5px; font-family: ui-monospace, Menlo, monospace; }
.pf-img .up {
  height: 26px;
  border: 1px dashed #d6dae1;
  border-radius: 7px;
  background: #fbfcfd;
  font-size: 11.5px;
  color: var(--ink-2);
}
.pf-img .up:hover { border-color: var(--brand); color: var(--brand-ink); background: #fffaf9; }

/* items 列表编辑器 */
.it-list { display: flex; flex-direction: column; gap: 8px; }
.it-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfd;
  overflow: hidden;
}
.it-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 8px;
  background: #fff;
  border-bottom: 1px solid transparent;
}
.it-head.open { border-bottom-color: var(--line); }
.it-title {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}
.it-title .idx {
  display: grid;
  place-items: center;
  width: 17px; height: 17px;
  border-radius: 5px;
  background: var(--line-2);
  font-size: 10px;
  color: var(--ink-3);
  flex-shrink: 0;
}
.it-ops { display: flex; gap: 2px; flex-shrink: 0; }
.it-ops button {
  width: 22px; height: 22px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--ink-3);
  font-size: 11px;
  line-height: 1;
}
.it-ops button:hover { background: var(--line-2); color: var(--ink); }
.it-ops button.rm:hover { background: #fff1f0; color: #d92d20; }
.it-body { padding: 10px 9px; display: none; }
.it-card.open .it-body { display: block; }
.it-body .pf-row:last-child { margin-bottom: 0; }
.it-add {
  height: 32px;
  border: 1px dashed #d6dae1;
  border-radius: 9px;
  background: #fff;
  font-size: 12px;
  color: var(--ink-2);
}
.it-add:hover { border-color: var(--brand); color: var(--brand-ink); background: #fffaf9; }

.pf-empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--ink-3);
  font-size: 12.5px;
  line-height: 1.8;
}
.pf-empty .big { font-size: 26px; display: block; margin-bottom: 8px; opacity: .5; }

.link-pick { display: flex; gap: 6px; }
.link-pick .pf-select { width: 112px; flex-shrink: 0; }

/* 主题编辑 */
.theme-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.theme-grid .pf-row { margin-bottom: 0; }
.theme-note { font-size: 11px; color: var(--ink-3); margin: 14px 0 4px; line-height: 1.6; }

@media (max-width: 1180px) {
  .ed { grid-template-columns: 232px minmax(0, 1fr) 300px; }
}
@media (max-width: 980px) {
  .ed { grid-template-columns: minmax(0, 1fr) 300px; }
  .ed-side-left { display: none; }
}
