:root {
  --bg: #ffffff;
  --fg: #2c2c2c;
  --bar-bg: #f7f7f7;
  --bar-border: #e6e6e6;
  --muted: #9a9a9a;
  --accent: #07c160;
  --title-fg: #1a1a1a;
}

body.theme-dark {
  --bg: #1e1e1e;
  --fg: #d4d4d4;
  --bar-bg: #252526;
  --bar-border: #333;
  --muted: #777;
  --accent: #07c160;
  --title-fg: #e8e8e8;
}

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

/* ===== 顶部工具条 ===== */
.topbar {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background: var(--bar-bg);
  border-bottom: 1px solid var(--bar-border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-left { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  background: transparent;
  border: none;
  color: var(--fg);
  font-size: 14px;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.icon-btn:hover { background: rgba(125,125,125,0.12); }

.doc-title {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--title-fg);
  font-size: 15px;
  font-weight: 600;
  padding: 6px 4px;
}
.doc-title::placeholder { color: var(--muted); font-weight: 500; }

.save-state {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.save-state.saving { color: #e0a800; }
.save-state.saved { color: var(--accent); }
.save-state.error { color: #e53935; }

/* ===== 编辑器区域：Typora 风格留白 ===== */
.editor-wrap {
  height: calc(100% - 48px);
  overflow: auto;
}
#vditor {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 16px 120px;
  height: 100%;
  box-sizing: border-box;
}

/* ===== 加载遮罩 ===== */
.loading-mask {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--muted);
  z-index: 50;
}
.loading-mask.hidden { display: none; }
.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--bar-border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
