/* ============================================================
   文章页与富文本编辑器
   ============================================================ */
.article-shell {
  max-width: 900px;
  margin: 0 auto;
}

.article-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.article-head-main { flex: 1; min-width: 0; }
.article-kicker {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--ink-faint);
}
.article-title {
  font-family: var(--font-serif);
  font-size: clamp(24px, 3.6vw, 34px);
  font-weight: 600;
  line-height: 1.32;
  letter-spacing: 0.005em;
  color: var(--ink);
  overflow-wrap: anywhere;
  cursor: default;
}
.article-title[data-editable="true"] {
  cursor: text;
  border-radius: var(--radius-xs);
  outline: none;
}
.article-title[data-editable="true"]:hover { background: var(--accent-wash); }
.article-title[data-editable="true"]:focus {
  background: var(--accent-wash);
  box-shadow: 0 0 0 3px rgba(176, 137, 104, 0.16);
}

.article-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------------- 阅读区 ---------------- */
.reader-pane {
  position: relative;
  padding: clamp(26px, 4.4vw, 52px) clamp(22px, 5vw, 60px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  min-height: 220px;
}
.reader-pane::before {
  content: "";
  position: absolute;
  inset: 14px;
  border: 1px solid rgba(232, 222, 210, 0.6);
  border-radius: calc(var(--radius-lg) - 8px);
  pointer-events: none;
}

.prose {
  font-family: var(--font-serif);
  font-size: 16px;
  line-height: 1.95;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.prose > *:first-child { margin-top: 0 !important; }
.prose p { margin: 0 0 1.05em; }
.prose h1, .prose h2, .prose h3, .prose h4 {
  margin: 1.5em 0 0.6em;
  font-weight: 600;
  line-height: 1.4;
}
.prose h1 { font-size: 1.65em; }
.prose h2 { font-size: 1.38em; }
.prose h3 { font-size: 1.18em; }
.prose h4 { font-size: 1.04em; }
.prose ul, .prose ol { margin: 0 0 1.05em; padding-left: 1.5em; }
.prose li { margin: 0.25em 0; }
.prose blockquote {
  margin: 1.2em 0;
  padding: 0.4em 0 0.4em 1.1em;
  border-left: 3px solid var(--accent-soft);
  color: var(--ink-soft);
}
.prose pre {
  margin: 1.1em 0;
  padding: 15px 17px;
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-family: var(--font-ui);
  font-size: 13.5px;
  line-height: 1.7;
}
.prose code {
  padding: 0.1em 0.36em;
  background: var(--surface-sunken);
  border-radius: 4px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.9em;
}
.prose pre code { padding: 0; background: none; }
.prose img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.3em auto;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}
.prose a { color: var(--accent-deep); text-decoration: underline; text-underline-offset: 2px; }
.prose hr {
  margin: 2em 0;
  border: 0;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--line-strong), transparent);
}
.prose table {
  width: 100%;
  margin: 1.3em 0;
  border-collapse: collapse;
  font-size: 0.94em;
  font-family: var(--font-ui);
  table-layout: auto;
}
.prose th, .prose td {
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  text-align: left;
  vertical-align: top;
  min-width: 48px;
}
.prose th { background: var(--surface-alt); font-weight: 600; }
.prose tbody tr:nth-child(even) td { background: rgba(247, 241, 232, 0.5); }

.prose-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 48px 0;
  color: var(--ink-faint);
  font-family: var(--font-ui);
  font-size: 14px;
  text-align: center;
}

/* ---------------- 编辑态 ---------------- */
.editor-pane {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--accent-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: visible;
}
.editor-pane::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 0 0 3px rgba(176, 137, 104, 0.09);
  pointer-events: none;
}

.editor-toolbar {
  position: sticky;
  top: 76px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 8px 12px;
  flex-wrap: wrap;
  background: rgba(250, 244, 235, 0.96);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.tb-group { display: flex; align-items: center; gap: 4px; }
.tb-sep {
  width: 1px;
  height: 20px;
  margin: 0 4px;
  background: var(--line-strong);
}
.tb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 32px;
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--ink-soft);
  font-size: 13px;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease),
              border-color var(--dur) var(--ease);
}
.tb-btn:hover { background: var(--accent-wash); color: var(--ink); }
.tb-btn:active { background: var(--accent-soft); }
.tb-btn[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent-deep);
  border-color: var(--accent);
}
.tb-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.tb-btn.tb-icon { width: 32px; padding: 0; }
.font-btn, .size-btn { min-width: 68px; justify-content: space-between; }
.font-btn-label, .size-btn-label { font-size: 13px; }
.size-btn { min-width: 62px; }
.bg-btn.has-bg {
  background: var(--active-bg, var(--accent-wash));
  color: var(--ink);
  border-color: var(--line-strong);
}

/* 字色按钮：图标下方显示当前颜色条，未设置时用默认墨色 */
.fg-btn {
  position: relative;
  color: var(--ink-soft);
}
.fg-btn::after {
  content: "";
  position: absolute;
  left: 7px;
  right: 7px;
  bottom: 4px;
  height: 3px;
  border-radius: 2px;
  background: var(--active-fg, var(--ink));
  transition: background var(--dur) var(--ease);
}
.fg-btn.has-fg {
  border-color: var(--line-strong);
  background: var(--surface-alt);
}
.ai-btn {
  background: var(--accent-wash);
  color: var(--accent-deep);
  border-color: var(--accent-soft);
  font-weight: 600;
}
.ai-btn:hover { background: var(--accent-soft); color: var(--accent-deep); }
.tb-save { margin-left: 2px; }

.save-state {
  font-size: 12px;
  color: var(--ink-faint);
  white-space: nowrap;
  padding: 0 4px;
  transition: color var(--dur) var(--ease);
}
.save-state.dirty { color: var(--accent-deep); }
.save-state.dirty::before {
  content: "●";
  margin-right: 5px;
  font-size: 9px;
  vertical-align: 1px;
}

.editor-scroll {
  padding: clamp(22px, 4.2vw, 46px) clamp(20px, 5vw, 56px);
  min-height: 420px;
}
.editor-content {
  outline: none;
  min-height: 380px;
  font-family: var(--font-serif);
  font-size: 16px;
  line-height: 1.95;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.editor-content:empty::before {
  content: attr(data-placeholder);
  color: var(--ink-faint);
  pointer-events: none;
}
.editor-content p { margin: 0 0 1.05em; }
.editor-content img { max-width: 100%; height: auto; border-radius: var(--radius-sm); }
.editor-content table { width: 100%; border-collapse: collapse; margin: 1em 0; }
.editor-content th, .editor-content td {
  border: 1px solid var(--line-strong);
  padding: 8px 11px;
  vertical-align: top;
  min-width: 40px;
}
.editor-content th { background: var(--surface-alt); }
.editor-content blockquote {
  margin: 1em 0;
  padding-left: 1em;
  border-left: 3px solid var(--accent-soft);
  color: var(--ink-soft);
}
.editor-content:focus-visible { outline: none; }

/* 段落悬浮提示（新增块） */
.editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  background: var(--surface-alt);
  font-size: 11.5px;
  color: var(--ink-faint);
  flex-wrap: wrap;
}
.editor-hint kbd {
  display: inline-block;
  padding: 1px 5px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface);
  font-family: var(--font-ui);
  font-size: 10.5px;
  color: var(--ink-muted);
}

/* ---------------- 背景色面板 ---------------- */
.swatch-pop {
  position: fixed;
  z-index: 300;
  width: 208px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  animation: popIn 140ms var(--ease);
}
.swatch-title {
  margin-bottom: 9px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
}
.swatch-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.swatch {
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--swatch, var(--accent-soft));
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.7);
  transition: transform 140ms var(--ease), border-color 140ms var(--ease);
}
.swatch:hover { transform: scale(1.09); border-color: var(--accent); }
.swatch-remove {
  width: 100%;
  margin-top: 10px;
  padding: 6px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--ink-muted);
  font-size: 12px;
}
.swatch-remove:hover { background: var(--accent-wash); color: var(--ink); }

/* ---------------- 图片上传进度 ---------------- */
.upload-overlay {
  position: fixed;
  inset: 0;
  z-index: 140;
  display: grid;
  place-items: center;
  background: rgba(61, 55, 51, 0.18);
  backdrop-filter: blur(2px);
}
.upload-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: 13.5px;
  color: var(--ink-soft);
}

/* ---------------- 阅读元信息 ---------------- */
.reading-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 2px 0;
  margin-top: 20px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink-faint);
}
.reading-meta .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--line-strong); }

/* ---------------- 返回按钮 ---------------- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 16px;
  padding: 5px 10px 5px 4px;
  border-radius: var(--radius-xs);
  color: var(--ink-muted);
  font-size: 13px;
  text-decoration: none;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.back-link:hover { background: var(--accent-wash); color: var(--ink); }

/* ---------------- 状态切换 ---------------- */
.status-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 99px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-size: 12.5px;
  color: var(--ink-soft);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.status-toggle:hover { border-color: var(--accent); background: var(--accent-wash); }

@media (max-width: 720px) {
  .editor-toolbar { top: 66px; padding: 7px 8px; gap: 3px; }
  .font-btn, .size-btn { min-width: 56px; padding: 0 7px; }
  .editor-toolbar .save-state { display: none; }
  .editor-scroll { padding: 22px 18px; }
  .reader-pane { padding: 24px 20px; }
  .reader-pane::before { inset: 9px; }
  .article-actions { width: 100%; }
}
