/* ==========================================================================
   内容编辑台 —— 工具界面，跟站点同一套字体与配色，但更密、更功能化。
   ========================================================================== */
:root {
  --paper: #fff;
  --bg: #F4F5F3;
  --ink: #171717;
  --ink-2: #333;
  --ink-3: #8A8A8A;
  --rule: #E4E6E2;
  --rule-2: #EFF0EE;
  --accent: #1E3F35;
  --accent-2: #2C8A6E;
  --warn: #B3382C;
  --r: 3px;
  --serif: "Source Han Serif SC", "Noto Serif SC", "Songti SC", "SimSun", Georgia, serif;
  --sans: "PingFang SC", "HarmonyOS Sans SC", "Source Han Sans SC", "Noto Sans SC", "Segoe UI", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, monospace;
}
* { box-sizing: border-box; }
/* hidden 属性必须真的隐藏 —— 否则 .modal{display:grid} 这类规则会把它盖掉，
   于是透明的遮罩层永远压在页面上，整页点不动。 */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }

/* 按钮 */
button {
  border: 1px solid var(--rule);
  background: #fff;
  padding: 7px 14px;
  border-radius: var(--r);
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
  white-space: nowrap;
}
button:hover { border-color: #C9CEC8; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 500; }
button.primary:hover { background: #16302A; }
button.ghost { background: transparent; }
button.sm { padding: 5px 11px; font-size: 13px; }
button.icon { padding: 5px 9px; line-height: 1; color: var(--ink-3); }
button:disabled { opacity: .45; cursor: default; }

/* 登录 ------------------------------------------------------------------ */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--bg);
  padding: 24px;
}
.login-box {
  width: 100%;
  max-width: 360px;
  background: #fff;
  border: 1px solid var(--rule);
  padding: 34px 30px 30px;
  display: grid;
  gap: 12px;
}
.login-eyebrow { margin: 0; font-size: 11px; letter-spacing: .18em; color: var(--ink-3); }
.login-box h1 { margin: 0; font-family: var(--serif); font-size: 26px; letter-spacing: .06em; font-weight: 600; }
.login-hint { margin: 0 0 8px; font-size: 13px; color: var(--ink-3); }
.login-box input {
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: 10px 12px;
  outline: none;
}
.login-box input:focus { border-color: var(--accent); }
.login-err { margin: 0; min-height: 18px; font-size: 12.5px; color: var(--warn); }

/* 顶栏 ------------------------------------------------------------------ */
.app { display: flex; flex-direction: column; height: 100vh; }
.bar {
  flex: 0 0 auto;
  height: 54px;
  background: #fff;
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 16px;
}
.bar-l { display: flex; align-items: center; gap: 9px; }
.bar-l .dot { width: 8px; height: 8px; background: var(--accent); border-radius: 2px; }
.bar-l b { font-size: 14px; letter-spacing: .04em; }
.bar-sub { font-size: 12px; color: var(--ink-3); letter-spacing: .06em; }
.bar-r { display: flex; align-items: center; gap: 8px; }
.status { font-size: 12px; color: var(--ink-3); margin-right: 4px; letter-spacing: .04em; }
.status.dirty { color: var(--warn); }
.status.busy { color: var(--accent-2); }

/* 布局 ------------------------------------------------------------------ */
.layout {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 208px minmax(0, 1fr) 440px;
}

/* 左侧页面栏 */
.rail {
  background: #fff;
  border-right: 1px solid var(--rule);
  padding: 14px 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
}
.rail-t {
  margin: 12px 16px 6px;
  font-size: 10.5px;
  letter-spacing: .18em;
  color: var(--ink-3);
}
.rail-t:first-child { margin-top: 0; }
.rail-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 16px;
  cursor: pointer;
  border-left: 3px solid transparent;
  font-size: 13.5px;
  color: var(--ink-2);
}
.rail-item:hover { background: #FAFBFA; }
.rail-item.on { background: #F1F4F2; border-left-color: var(--accent); color: var(--ink); font-weight: 500; }
/* 项目页（挂在品牌线下面）：缩进一格，用 ↳ 代替编号 */
.rail-item.sub { padding-left: 26px; font-size: 12.5px; color: var(--ink-3); }
.rail-item.sub.on { color: var(--ink); }
.rail-item i { font-style: normal; font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.rail-foot { margin-top: auto; padding: 14px 16px 4px; display: grid; gap: 8px; font-size: 12.5px; }
.rail-foot a { color: var(--ink-3); }
.rail-foot a:hover { color: var(--accent); }

/* 中间区块列表 */
.list { min-width: 0; overflow: auto; padding: 20px 22px 80px; position: relative; }
.list-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.list-head h2 { margin: 0; font-family: var(--serif); font-size: 22px; letter-spacing: .04em; font-weight: 600; }
.muted { color: var(--ink-3); font-size: 12.5px; margin: 3px 0 0; }
.blocks { display: grid; gap: 8px; }

.blk {
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: var(--r);
  display: grid;
  grid-template-columns: 30px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 10px 6px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.blk:hover { border-color: #C9CEC8; }
.blk.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.blk .grip { text-align: center; color: var(--ink-3); font-family: var(--mono); font-size: 11px; user-select: none; }
.blk .mid { min-width: 0; }
.blk .tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .06em;
  color: #fff;
  background: var(--accent);
  padding: 1px 5px;
  border-radius: 2px;
  vertical-align: 1px;
}
.blk .ttl { font-size: 13.5px; font-weight: 500; margin-left: 7px; }
.blk .sum {
  display: block;
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.blk .mini { display: flex; gap: 3px; opacity: .75; }
.blk:hover .mini { opacity: 1; }
.blk .mini button {
  padding: 3px 6px;
  font-size: 11px;
  border-color: transparent;
  background: transparent;
  color: var(--ink-3);
  line-height: 1;
}
.blk .mini button:hover { background: #F4F5F3; color: var(--ink); }
.blk .mini button.del:hover { color: var(--warn); }

/* 添加区块 */
.add-tip {
  position: fixed;
  inset: 0;
  background: rgba(23, 23, 23, .32);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 30;
}
.add-panel { background: #fff; border-radius: var(--r); width: 100%; max-width: 620px; padding: 18px 20px 22px; box-shadow: 0 20px 60px rgba(0,0,0,.18); }
.add-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.type-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.type {
  text-align: left;
  padding: 11px 12px;
  border: 1px solid var(--rule);
  background: #fff;
  border-radius: var(--r);
  display: grid;
  gap: 2px;
}
.type:hover { border-color: var(--accent); }
.type b { font-size: 13px; font-weight: 600; }
.type small { font-size: 11px; color: var(--ink-3); line-height: 1.45; }

/* 右侧编辑面板 */
.editor {
  background: #fff;
  border-left: 1px solid var(--rule);
  overflow: auto;
  padding: 18px 20px 90px;
}
.ed-empty { color: var(--ink-3); font-size: 13px; line-height: 1.8; padding-top: 12px; }
.ed-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 16px;
}
.ed-head h3 { margin: 0; font-family: var(--serif); font-size: 18px; letter-spacing: .04em; font-weight: 600; }
.ed-head .hint { margin: 4px 0 0; font-size: 12px; color: var(--ink-3); }

.fld { margin-bottom: 15px; }
.fld > label { display: block; font-size: 12px; color: var(--ink-2); letter-spacing: .03em; margin-bottom: 5px; }
.fld input[type=text], .fld input[type=password], .fld textarea, .fld select {
  width: 100%;
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: 8px 10px;
  outline: none;
  background: #fff;
  line-height: 1.6;
  resize: vertical;
}
.fld select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, #8A8A8A 50%), linear-gradient(135deg, #8A8A8A 50%, transparent 50%); background-position: calc(100% - 16px) calc(50% + 1px), calc(100% - 11px) calc(50% + 1px); background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
.fld input:focus, .fld textarea:focus, .fld select:focus { border-color: var(--accent); }
.fld .sub { font-size: 11px; color: var(--ink-3); margin-top: 4px; }

/* 图片字段 */
.imgfld { display: grid; gap: 8px; }
.imgfld .prev {
  width: 100%;
  aspect-ratio: 3 / 2;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  object-fit: cover;
  display: block;
}
.imgfld .prev.empty { display: grid; place-items: center; color: var(--ink-3); font-size: 12px; }
.imgfld .row { display: flex; gap: 6px; }

/* 列表字段 */
.listfld { display: grid; gap: 8px; }
.item {
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: 10px 12px 4px;
  background: #FCFDFC;
}
.item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.item-head b { font-size: 12px; color: var(--accent); letter-spacing: .04em; }
.item-head .mini { display: flex; gap: 2px; }
.item-head button {
  padding: 2px 6px;
  font-size: 11px;
  border-color: transparent;
  background: transparent;
  color: var(--ink-3);
  line-height: 1;
}
.item-head button:hover { background: #F0F2F0; color: var(--ink); }
.item-head button.del:hover { color: var(--warn); }
.addrow {
  border: 1px dashed #CBD2CB;
  background: transparent;
  color: var(--ink-3);
  padding: 7px;
  border-radius: var(--r);
  font-size: 12.5px;
  width: 100%;
}
.addrow:hover { border-color: var(--accent); color: var(--accent); }

/* 弹窗 */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(23, 23, 23, .42);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 60;
}
.modal-box {
  background: #fff;
  border-radius: var(--r);
  width: 100%;
  max-width: 860px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 70px rgba(0,0,0,.22);
}
.modal-box.narrow { max-width: 460px; }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--rule);
  gap: 12px;
}
.modal-tools { display: flex; align-items: center; gap: 8px; }
.upload {
  font-size: 13px;
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: 6px 13px;
  cursor: pointer;
}
.upload:hover { border-color: var(--accent); color: var(--accent); }
.modal-grid {
  padding: 16px;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.pick {
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: 0;
  overflow: hidden;
  background: #fff;
  text-align: left;
}
.pick:hover { border-color: var(--accent); }
.pick img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; display: block; background: var(--bg); }
.pick span { display: block; font-size: 10.5px; color: var(--ink-3); padding: 5px 7px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.bk-list { padding: 10px 16px 16px; overflow: auto; display: grid; gap: 6px; }
.bk {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border: 1px solid var(--rule);
  border-radius: var(--r);
  font-size: 13px;
}
.bk small { color: var(--ink-3); font-family: var(--mono); font-size: 11px; }

/* 提示 */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: #171717;
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--r);
  font-size: 13px;
  z-index: 90;
  max-width: 80vw;
  box-shadow: 0 10px 30px rgba(0,0,0,.2);
}
.toast.err { background: var(--warn); }

/* 模式切换 -------------------------------------------------------------- */
.modes {
  display: flex;
  margin-left: 14px;
  border: 1px solid var(--rule);
  border-radius: var(--r);
  overflow: hidden;
}
.modes button {
  border: 0;
  border-radius: 0;
  background: #fff;
  padding: 5px 14px;
  font-size: 12.5px;
  color: var(--ink-3);
}
.modes button.on { background: var(--accent); color: #fff; font-weight: 500; }
.modes button.on:hover { background: #16302A; }

/* 画布 ------------------------------------------------------------------ */
.canvas {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: #EBEDE9;
}
.cv-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 14px;
  background: #fff;
  border-bottom: 1px solid var(--rule);
}
.cv-title { font-family: var(--serif); font-size: 15px; font-weight: 600; letter-spacing: .04em; }
.cv-bar .seg { display: flex; border: 1px solid var(--rule); border-radius: var(--r); overflow: hidden; }
.cv-bar .seg button { border: 0; border-radius: 0; background: #fff; padding: 4px 12px; font-size: 12.5px; color: var(--ink-3); }
.cv-bar .seg button.on { background: #F1F4F2; color: var(--ink); font-weight: 500; }
.cv-hint { margin-left: auto; font-size: 12px; color: var(--ink-3); }

.cv-stage { flex: 1 1 auto; min-height: 0; overflow: hidden; padding: 16px; position: relative; display: flex; }
.cv-frame {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0 auto;
  background: #fff;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,.10), 0 14px 40px rgba(0,0,0,.08);
  transition: max-width .18s ease;
}
.cv-frame iframe { display: block; width: 100%; height: 100%; border: 0; background: #fff; }

/* 选区浮动工具条 */
.cv-tools {
  position: absolute;
  z-index: 9;
  display: flex;
  align-items: center;
  gap: 1px;
  background: var(--accent);
  color: #fff;
  border-radius: 3px;
  padding: 2px 4px;
  font-size: 11.5px;
  box-shadow: 0 6px 18px rgba(0,0,0,.22);
  pointer-events: auto;
}
.cv-tools b { font-weight: 500; padding: 0 8px 0 5px; letter-spacing: .05em; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cv-tools button {
  background: transparent;
  border: 0;
  color: #fff;
  opacity: .82;
  padding: 3px 7px;
  font-size: 11.5px;
  border-radius: 2px;
  line-height: 1.4;
}
.cv-tools button:hover { background: rgba(255,255,255,.18); opacity: 1; }
.cv-tools button.del:hover { background: var(--warn); }

.add-note { margin: 12px 0 0; font-size: 11.5px; color: var(--ink-3); }

body.mode-canvas .layout { grid-template-columns: 216px minmax(0, 1fr) 412px; }

@media (max-width: 1100px) {
  .layout { grid-template-columns: 172px minmax(0, 1fr) 380px; }
  body.mode-canvas .layout { grid-template-columns: 196px minmax(0, 1fr) 380px; }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .rail { flex-direction: row; align-items: center; overflow-x: auto; padding: 8px; border-right: 0; border-bottom: 1px solid var(--rule); }
  .rail-t, .rail-foot { display: none; }
  .rail-item { border-left: 0; border-bottom: 2px solid transparent; white-space: nowrap; }
  .rail-item.on { border-left: 0; border-bottom-color: var(--accent); }
  .editor {
    position: fixed;
    inset: 54px 0 0 auto;
    width: min(460px, 100vw);
    border-left: 1px solid var(--rule);
    z-index: 40;
    box-shadow: -10px 0 40px rgba(0,0,0,.12);
    display: none;
  }
  .editor.open { display: block; }
  .type-grid { grid-template-columns: repeat(2, 1fr); }
  .bar-sub { display: none; }
  .status { display: none; }
}

/* 左栏「本页区块」：一条一块，悬停出上移/下移/删 ------------------------ */
.rail-cnt {
  display: inline-block; margin-left: 4px; padding: 0 5px;
  background: #EDEFEC; border-radius: 8px; font-family: var(--mono);
  font-size: 10.5px; color: var(--ink-3); letter-spacing: 0;
}
.rail-blocks { display: grid; gap: 2px; margin-bottom: 4px; max-height: 46vh; overflow: auto; }
.rail-blk {
  position: relative; display: flex; align-items: center; gap: 7px;
  padding: 7px 8px 7px 10px; border-left: 2px solid transparent; border-radius: 0 3px 3px 0;
  cursor: pointer;
}
.rail-blk:hover { background: #FAFBFA; }
.rail-blk.on { background: #F1F4F2; border-left-color: var(--accent); }
.rail-blk > i {
  font-style: normal; font-family: var(--mono); font-size: 10.5px;
  color: var(--ink-3); flex: none; letter-spacing: .04em;
}
.rail-blk-tx { min-width: 0; display: grid; }
.rail-blk-tx b {
  font-size: 12.5px; font-weight: 500; color: var(--ink-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rail-blk.on .rail-blk-tx b { color: var(--ink); }
.rail-blk-tx em {
  font-style: normal; font-size: 11px; line-height: 1.5; color: var(--ink-4);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rail-blk-ops {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  display: none; gap: 1px; padding: 2px; border-radius: 3px;
  background: rgba(255, 255, 255, .96); box-shadow: 0 1px 4px rgba(0, 0, 0, .1);
}
.rail-blk:hover .rail-blk-ops, .rail-blk.on .rail-blk-ops { display: flex; }
.rail-blk-ops button {
  width: 20px; height: 20px; padding: 0; border: 0; border-radius: 2px;
  background: transparent; color: var(--ink-3); font-size: 12px; line-height: 1;
  cursor: pointer; font-family: var(--sans);
}
.rail-blk-ops button:hover { background: #EDEFEC; color: var(--ink); }
.rail-blk-ops button.del:hover { background: #FBEAEA; color: #B3352C; }
