/* nkdgpt.md-pad 编辑器样式（浅色主题，办公舒适） */
:root {
  --bg: #f6f7f9;
  --bg-soft: #ffffff;
  --bg-elev: #eef0f3;
  --bg-hover: #e5e8ec;
  --border: #d0d7de;
  --border-strong: #afb8c1;
  --text: #1f2328;
  --text-dim: #59636e;
  --accent: #0969da;
  --accent-soft: #ddf4ff;
  --primary: #1f883d;
  --primary-hover: #1a7f37;
  --danger: #cf222e;
  --code-bg: #f6f8fa;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

/* 深色主题覆盖 */
body.theme-dark {
  --bg: #0d1117;
  --bg-soft: #161b22;
  --bg-elev: #21262d;
  --bg-hover: #2a313c;
  --border: #30363d;
  --border-strong: #484f58;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --accent: #58a6ff;
  --accent-soft: #1f6feb33;
  --primary: #238636;
  --primary-hover: #2ea043;
  --danger: #f85149;
  --code-bg: #161b22;
}
body.theme-dark {
  /* 覆盖 Vditor 内部使用的 CSS 变量 */
  --vditor-background: var(--bg-soft);
  --vditor-panel-background: var(--bg);
  --vditor-text-color: var(--text);
  --vditor-border-color: var(--border);
  --vditor-icon-color: var(--text-dim);
  --vditor-icon-hover-color: var(--text);
  --vditor-toolbar-background: var(--bg);
  --vditor-toolbar-color: var(--text);
  --vditor-toolbar-icon-color: var(--text-dim);
  --vditor-toolbar-icon-hover-color: var(--text);
  --vditor-toolbar-active-color: var(--accent);
  --vditor-panel-color: var(--text);
  --vditor-panel-hover-color: var(--accent);
  --vditor-code-background: var(--code-bg);
  --vditor-blockquote-background: var(--accent-soft);
  --vditor-table-background: var(--bg-soft);
  --vditor-table-border-color: var(--border);
  --vditor-link-color: var(--accent);
}
body.theme-dark .vditor,
body.theme-dark .vditor-toolbar,
body.theme-dark .vditor-content,
body.theme-dark .vditor-wysiwyg {
  background: var(--bg-soft) !important;
  color: var(--text) !important;
}
body.theme-dark .vditor-wysiwyg table th,
body.theme-dark .vditor-wysiwyg table td { border-color: var(--border) !important; }
body.theme-dark .vditor-wysiwyg code,
body.theme-dark .vditor-wysiwyg pre { background: var(--code-bg) !important; }
body.theme-dark .vditor-wysiwyg blockquote { background: var(--accent-soft) !important; color: var(--text-dim) !important; }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Microsoft YaHei", sans-serif;
  display: flex;
  flex-direction: column;
}

/* ---------- topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(0,0,0,.02);
}
.brand { font-weight: 600; font-size: 16px; color: var(--text); }
.brand .sub { font-weight: 400; color: var(--text-dim); font-size: 13px; margin-left: 4px; }
.actions { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }
.actions button {
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.actions button:hover:not(:disabled) { background: var(--bg-hover); }
.actions button:disabled { opacity: .5; cursor: not-allowed; }
.actions button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.actions button.primary:hover { background: var(--primary-hover); }

/* 带 SVG 图标的按钮 */
.btn-icon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-icon svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.btn-icon .btn-label {
  font-size: 13px;
  line-height: 1;
}
.btn-icon svg.icon-moon { display: none; }
body.theme-dark .btn-icon svg.icon-sun { display: none; }
body.theme-dark .btn-icon svg.icon-moon { display: inline-block; }

/* ---------- vditor container ---------- */
#vditor {
  flex: 1;
  min-height: 0;
  display: flex;
}

/* Vditor 浅色主题微调：去边框 + 让编辑区背景融入 */
.vditor {
  flex: 1 !important;
  border: none !important;
  border-radius: 0 !important;
  background: var(--bg-soft) !important;
  box-shadow: none !important;
}
.vditor-toolbar {
  background: var(--bg) !important;
  border-bottom: 1px solid var(--border) !important;
}
.vditor-content {
  background: var(--bg-soft) !important;
}
.vditor-wysiwyg {
  background: var(--bg-soft) !important;
}

/* 表格浅色 */
.vditor-wysiwyg table {
  border-collapse: collapse;
}
.vditor-wysiwyg table th,
.vditor-wysiwyg table td {
  border: 1px solid var(--border);
}

/* ---------- status ---------- */
.status {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 16px;
  font-size: 12px;
  color: var(--text-dim);
  background: var(--bg-soft);
  border-top: 1px solid var(--border);
}
.status .spacer { flex: 1; }
#share-link a { color: var(--accent); margin: 0 4px; }
#share-link a:hover { text-decoration: underline; }
#status.error { color: var(--danger); }
#status.ok { color: var(--primary); }

/* ---------- modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 24px;
  min-width: 320px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .15);
}
.modal-card.wide { min-width: 480px; max-width: 720px; }
.modal-card h3 { margin: 0 0 14px; font-size: 16px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}
.modal-actions button {
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
}
.modal-actions button:hover { background: var(--bg-hover); }
#history-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 50vh;
  overflow-y: auto;
}
#history-list li {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
#history-list li:hover { background: var(--bg-hover); }
#history-list a { color: var(--accent); text-decoration: none; flex: 1; word-break: break-all; min-width: 0; }
#history-list a:hover { text-decoration: underline; }
#history-list .meta { color: var(--text-dim); font-size: 12px; flex-shrink: 0; }
#history-list button {
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 10px;
  font-size: 12px;
  cursor: pointer;
  flex-shrink: 0;
}
#history-list button:hover { background: var(--bg-hover); }
#history-list button[data-action="delete"] {
  color: var(--danger);
  border-color: var(--danger);
  background: transparent;
}
#history-list button[data-action="delete"]:hover {
  background: var(--danger);
  color: #fff;
}
#history-list button[data-action="delete"] svg {
  width: 12px;
  height: 12px;
  vertical-align: -1px;
  margin-right: 2px;
}
.modal-actions .spacer { flex: 1; }
.modal-actions button.danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.modal-actions button.danger svg {
  width: 14px;
  height: 14px;
}
.modal-actions button.danger:hover {
  background: var(--danger);
  color: #fff;
}
.modal-card h3 .count {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 400;
  margin-left: 6px;
}

/* ---------- 图片悬浮删除按钮 ---------- */
.img-delete-btn {
  position: absolute;
  z-index: 999;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: var(--danger);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .25);
  transition: transform .12s;
}
.img-delete-btn:hover { transform: scale(1.15); background: #b91c1c; }
.img-delete-btn::before { content: "×"; font-weight: 700; }