* { box-sizing: border-box; }
:root {
  --bg: #f4f5f7;
  --fg: #1f2328;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --border: #e5e7eb;
  --danger: #dc2626;
}

body {
  margin: 0;
  font-family: -apple-system, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--fg);
  font-size: 15px;
  line-height: 1.6;
}

header {
  padding: 24px 32px 8px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}
header h1 { margin: 0; font-size: 20px; }
header .sub { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.bar {
  display: flex;
  gap: 8px;
  padding: 16px 32px;
  align-items: center;
  background: #fff;
  border-bottom: 1px solid var(--border);
}
.bar input[type="text"] {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  outline: none;
}
.bar input[type="text"]:focus { border-color: var(--accent); }

button {
  padding: 8px 16px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  color: var(--fg);
  transition: background .1s, border-color .1s, color .1s;
}
button:hover { background: #f3f4f6; }
button.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
button.primary:hover { background: var(--accent-dark); }

.status { color: var(--muted); font-size: 13px; }
.status.err { color: var(--danger); }
.status.ok  { color: #059669; }

.progress {
  padding: 12px 32px 16px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}
.progress-bar {
  position: relative;
  height: 6px;
  background: #eef2f7;
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #60a5fa);
  border-radius: 3px;
  transition: width .35s cubic-bezier(.4, 0, .2, 1);
}
.progress-text {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.progress-text .pct { font-variant-numeric: tabular-nums; color: var(--fg); font-weight: 500; }

/* ===== 文档编辑区 ===== */
.doc-wrap {
  max-width: 780px;
  margin: 32px auto 32px;
  padding: 0 20px;
}

.doc-head {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px 10px 0 0;
  border-bottom: none;
  padding: 28px 56px 16px;
}
.doc-title-input {
  width: 100%;
  border: none;
  outline: none;
  font-size: 26px;
  font-weight: 600;
  color: #111;
  padding: 0;
  margin: 0 0 10px;
  font-family: inherit;
}
.doc-title-input::placeholder { color: #c9c9c9; }
.doc-meta-input {
  width: 100%;
  border: none;
  outline: none;
  font-size: 13px;
  color: var(--muted);
  padding: 0;
  margin: 0;
  font-family: inherit;
}
.doc-meta-input::placeholder { color: #c9c9c9; }

.doc {
  background: #fff;
  border: 1px solid var(--border);
  border-top: 1px solid #eee;
  border-radius: 0 0 10px 10px;
  padding: 20px 56px 48px;
  font-size: 16px;
  line-height: 1.85;
  color: #222;
  outline: none;
  min-height: 400px;
}
.doc:focus-within { }

.doc p, .doc div, .doc section {
  margin: 0 0 1em;
}
.doc p:last-child { margin-bottom: 0; }

.doc .img-line {
  text-align: center;
  margin: 1.2em 0;
}

/* 图片包裹：用 contenteditable=false 让它作为原子块 */
.doc .img-wrap {
  position: relative;
  display: inline-block;
  max-width: 100%;
  line-height: 0;
  cursor: grab;
  user-select: none;
  border-radius: 4px;
  transition: outline-color .1s;
  outline: 2px solid transparent;
  outline-offset: 2px;
}
.doc .img-wrap:hover { outline-color: #bfdbfe; }
.doc .img-wrap.selected { outline-color: var(--accent); outline-width: 3px; }
.doc .img-wrap.dragging { opacity: .4; cursor: grabbing; }
.doc .img-wrap img {
  max-width: 100%;
  max-height: 560px;
  height: auto;
  border-radius: 4px;
  display: block;
  background: #f3f4f6;
  -webkit-user-drag: none;
}
.doc .img-wrap .img-del {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: rgba(17, 24, 39, .72);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s, background .15s;
  padding: 0;
}
.doc .img-wrap:hover .img-del,
.doc .img-wrap.selected .img-del { opacity: 1; }
.doc .img-wrap .img-del:hover { background: var(--danger); }

/* 拖拽时的蓝色插入线 */
.doc .drop-indicator {
  height: 3px;
  background: var(--accent);
  border-radius: 2px;
  margin: 6px 0;
  pointer-events: none;
}

.doc-actions {
  position: sticky;
  bottom: 16px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding: 12px 20px;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(15, 23, 42, .08);
}
.doc-actions .tip {
  flex: 1;
  color: var(--muted);
  font-size: 12px;
}
