/* AI 编辑 widget 样式（一期 MVP）。命名加前缀避免与 mdbook 主题冲突。 */
.okedit-fab {
  position: fixed; right: 20px; bottom: 20px; z-index: 9999;
  padding: 10px 16px; border: none; border-radius: 24px;
  background: #2563eb; color: #fff; font-size: 14px; cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,.25);
}
.okedit-fab:hover { background: #1d4ed8; }

/* 无编辑权限时的两个并排按钮（申请权限 + 重新检查） */
.okedit-fab-group {
  position: fixed; right: 20px; bottom: 20px; z-index: 9999;
  display: flex; align-items: center; gap: 8px;
}
.okedit-fab-group .okedit-fab { position: static; right: auto; bottom: auto; }
.okedit-fab-sub { background: #6b7280; font-size: 13px; padding: 8px 12px; }
.okedit-fab-sub:hover { background: #4b5563; }
.okedit-fab-sub:disabled { opacity: .6; cursor: default; }

.okedit-panel {
  position: fixed; z-index: 10000;
  background: #fff; color: #1f2937; box-shadow: 0 4px 24px rgba(0,0,0,.25);
  display: flex; flex-direction: column; font-size: 14px;
  border: 1px solid #e5e7eb; border-radius: 10px;
  overflow: hidden; resize: both;               /* 右下角可拖拽调整大小 */
  min-width: 340px; min-height: 300px; max-width: 96vw; max-height: 96vh;
}
.okedit-panel.hidden { display: none; }

.okedit-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid #e5e7eb; font-weight: 600;
  cursor: move; user-select: none; background: #f9fafb;
}
.okedit-close { background: none; border: none; font-size: 20px; cursor: pointer; color: #6b7280; }

.okedit-tools { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 14px; border-bottom: 1px solid #f0f0f0; }
.okedit-body { flex: 1; overflow: auto; padding: 12px 14px; }
.okedit-ft { padding: 10px 14px; border-top: 1px solid #e5e7eb; background: #fafafa; }

.okedit-row { margin-bottom: 10px; }
.okedit-row label { display: block; font-size: 12px; color: #6b7280; margin-bottom: 4px; }
.okedit-input, .okedit-textarea {
  width: 100%; box-sizing: border-box; padding: 8px; border: 1px solid #d1d5db;
  border-radius: 6px; font-size: 13px; font-family: inherit;
}
/* 自动扩充：禁用手动拖拽，由 JS 调整高度 */
.okedit-textarea { resize: none; overflow: hidden; min-height: 40px; line-height: 1.5; }
.okedit-manual {
  width: 100%; box-sizing: border-box; padding: 8px; border: 1px solid #d1d5db; border-radius: 6px;
  font-family: ui-monospace, Menlo, monospace; font-size: 12px; line-height: 1.55;
  height: 40vh; overflow: auto; resize: vertical; /* 框内独立滚动，可上下拖拽调高 */
}

.okedit-btn { padding: 7px 12px; border: none; border-radius: 6px; cursor: pointer; font-size: 13px; }
.okedit-btn.primary { background: #2563eb; color: #fff; }
.okedit-btn.ghost { background: #f3f4f6; color: #374151; }
.okedit-btn.danger { background: #fee2e2; color: #b91c1c; }
.okedit-btn.sm { padding: 4px 10px; font-size: 12px; }
.okedit-btn.active { outline: 2px solid #2563eb; }
.okedit-btn:disabled { opacity: .5; cursor: not-allowed; }
.okedit-btns { display: flex; gap: 8px; flex-wrap: wrap; }

.okedit-note { font-size: 12px; color: #6b7280; margin: 6px 0; }
.okedit-err { color: #b91c1c; font-size: 13px; margin: 6px 0; white-space: pre-wrap; }

.okedit-msg { padding: 6px 10px; border-radius: 8px; margin: 6px 0; white-space: pre-wrap; word-break: break-word; }
.okedit-msg.user { background: #eff6ff; }
.okedit-msg.ai { background: #f3f4f6; }
.okedit-msg.gen { background: #f3f4f6; border: 1px dashed #cbd5e1; font-family: ui-monospace, Menlo, monospace; font-size: 12px; max-height: 30vh; overflow: auto; }

.okedit-diff { font-family: ui-monospace, Menlo, monospace; font-size: 12px;
  border: 1px solid #e5e7eb; border-radius: 6px; overflow: auto; max-height: 42vh; }
.okedit-diff div { padding: 1px 8px; white-space: pre-wrap; word-break: break-all; }
.okedit-diff .add { background: #dcfce7; }
.okedit-diff .del { background: #fee2e2; }
.okedit-diff .ctx { color: #9ca3af; }

.okedit-preview { border: 1px solid #e5e7eb; border-radius: 6px; padding: 10px; max-height: 42vh; overflow: auto; }
.okedit-preview h1,.okedit-preview h2,.okedit-preview h3 { margin: .4em 0; }
.okedit-spin { color: #2563eb; }

/* 预览里的图片：等比缩放到面板宽度，加载失败时浏览器会显示 alt 文本 */
.okedit-img {
  display: block; max-width: 100%; height: auto; margin: 8px 0;
  border: 1px solid #e5e7eb; border-radius: 4px; background: #f9fafb;
  cursor: zoom-in;
}

/* 点图放大：全屏遮罩看原图 */
.okedit-lightbox {
  position: fixed; inset: 0; z-index: 10001; display: flex;
  align-items: center; justify-content: center; padding: 24px;
  background: rgba(0,0,0,.75); cursor: zoom-out;
}
.okedit-lightbox img { max-width: 96%; max-height: 96%; background: #fff; }

/* 附件上传区 */
.okedit-drop {
  margin-top: 6px; padding: 12px; text-align: center;
  border: 1px dashed #d1d5db; border-radius: 6px;
  font-size: 12px; color: #6b7280; background: #fafafa;
}
.okedit-drop.over { border-color: #2563eb; background: #eff6ff; color: #2563eb; }

.okedit-asset {
  display: flex; align-items: center; gap: 8px; margin-top: 6px;
  padding: 6px; border: 1px solid #e5e7eb; border-radius: 6px;
}
.okedit-asset img { width: 48px; height: 48px; object-fit: cover; border-radius: 4px; flex: none; }
.okedit-asset-meta { flex: 1; min-width: 0; font-size: 12px; word-break: break-all; }
.okedit-asset-meta > div:first-child { font-family: ui-monospace, Menlo, monospace; }

/* 图片拖到编辑框上时高亮 */
.okedit-manual.drop-over { border-color: #2563eb; background: #f8fbff; }

/* 提交说明确认表单 */
.okedit-commit-desc { min-height: 84px; resize: vertical; font-family: inherit; line-height: 1.5; }

/* 历史记录 */
.okedit-hist {
  padding: 8px; margin-bottom: 8px;
  border: 1px solid #e5e7eb; border-radius: 6px;
}
.okedit-hist > div:first-child { margin-bottom: 6px; word-break: break-word; }
.okedit-hist .okedit-diff { margin-top: 8px; max-height: 32vh; }

/* diff 里的元信息行与 hunk 头 */
.okedit-diff .meta { color: #9ca3af; }
.okedit-diff .hunk { background: #eef2ff; color: #4338ca; }

/* 有未提交草稿时的提示：悬浮按钮右上角小红点 + 工具栏按钮高亮 */
.okedit-fab.has-draft::after {
  content: ''; position: absolute; top: 6px; right: 10px;
  width: 8px; height: 8px; border-radius: 50%;
  background: #f97316; box-shadow: 0 0 0 2px #fff;
}
.okedit-btn.has-draft { background: #fff7ed; color: #c2410c; font-weight: 600; }

/* 草稿箱勾选 */
.okedit-draft-head {
  display: flex; align-items: flex-start; gap: 8px;
  margin-bottom: 6px; cursor: pointer; word-break: break-word;
}
.okedit-check { margin-top: 3px; flex: none; }
