/* ==========================================================================
   后台管理界面样式
   ========================================================================== */

:root {
  --font-sans: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --bg: #f6f6f4;
  --bg-elev: #ffffff;
  --bg-subtle: #f0f0ee;
  --bg-side: #1b1e23;
  --side-text: #c8ccd2;
  --side-text-dim: #7d848e;
  --side-active: #2a2f37;

  --text: #1a1c1e;
  --text-soft: #565b61;
  --text-mute: #868c93;
  --border: #e3e3e0;
  --border-strong: #cfcfca;

  --accent: #c2410c;
  --accent-hover: #9a3412;
  --accent-soft: #fbeee7;
  --accent-text: #ffffff;

  --ok: #15803d;
  --ok-soft: #e8f5ec;
  --warn: #a16207;
  --warn-soft: #fdf4e3;
  --danger: #b91c1c;
  --danger-soft: #fdeaea;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 3px rgba(16, 18, 20, 0.06), 0 4px 14px rgba(16, 18, 20, 0.05);
  --shadow-lg: 0 12px 44px rgba(16, 18, 20, 0.16);
}

html[data-theme="dark"] {
  --bg: #101216;
  --bg-elev: #181b20;
  --bg-subtle: #20242a;
  --bg-side: #0c0e11;
  --side-text: #b9bec6;
  --side-text-dim: #6f7681;
  --side-active: #1e232a;

  --text: #e7e9ea;
  --text-soft: #a4aab2;
  --text-mute: #7a818a;
  --border: #282c33;
  --border-strong: #3a3f47;

  --accent: #f97316;
  --accent-hover: #fb923c;
  --accent-soft: #2a1c12;
  --accent-text: #1a1c1e;

  --ok: #4ade80;
  --ok-soft: #12261a;
  --warn: #fbbf24;
  --warn-soft: #2a2110;
  --danger: #f87171;
  --danger-soft: #2a1414;
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
}

[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- 登录 / 初始化 ---------- */
.auth-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 32px;
}
/* 只给读屏和爬虫看，视觉上不占位 */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.auth-card h1,
.auth-card h2 { margin: 0 0 6px; font-size: 22px; }
.auth-sub { color: var(--text-soft); margin: 0 0 22px; font-size: 14px; }
.auth-note { color: var(--text-mute); font-size: 12.5px; margin: 16px 0 0; text-align: center; }

/* ---------- 表单元素 ---------- */
label { display: block; }
.field { margin-bottom: 14px; font-size: 13.5px; color: var(--text-soft); }

.input,
input[type="text"],
input[type="password"],
input[type="date"],
input[type="number"],
input[type="search"],
select,
textarea {
  width: 100%;
  margin-top: 5px;
  padding: 9px 11px;
  font-family: inherit;
  font-size: 14.5px;
  color: var(--text);
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
textarea { resize: vertical; line-height: 1.7; }
.textarea-sm { min-height: 68px; }

.input:focus,
select:focus,
textarea:focus {
  outline: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.select-sm { width: auto; min-width: 120px; }

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--text-soft);
  cursor: pointer;
}
.checkbox input { width: auto; margin: 0; accent-color: var(--accent); }

.hint { color: var(--text-mute); font-size: 12.5px; margin: 4px 0 12px; line-height: 1.6; }

/* 文章网址预览 */
.url-preview {
  margin-top: 5px;
  padding: 9px 11px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-soft);
  word-break: break-all;
}
.url-preview.set { color: var(--accent); }
.url-preview a { color: inherit; }
.form-error {
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13.5px;
  margin: 10px 0;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}
.btn:hover { background: var(--bg-subtle); border-color: var(--text-mute); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-danger { color: var(--danger); border-color: var(--border-strong); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }

.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

.icon-btn {
  border: 0;
  background: transparent;
  color: var(--text-soft);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}
.icon-btn:hover { background: var(--bg-subtle); color: var(--text); }

.mini-link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--side-text-dim);
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
}
.mini-link:hover { color: var(--accent); text-decoration: none; }

/* ---------- 应用布局 ---------- */
.app {
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  min-height: 100vh;
}

/* ---------- 侧栏 ---------- */
.sidebar {
  background: var(--bg-side);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 20px 18px 16px;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
}
.brand-dot { color: #f97316; font-size: 13px; }

.side-nav { display: flex; flex-direction: column; gap: 2px; padding: 0 10px; flex: 1; }
.side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--side-text);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
}
.side-link:hover { background: var(--side-active); color: #fff; }
.side-link.active { background: var(--side-active); color: #fff; font-weight: 600; }
.ico { font-size: 14px; width: 18px; text-align: center; }

.sidebar-foot { padding: 14px 14px 18px; display: flex; flex-direction: column; gap: 12px; }
.btn-build {
  width: 100%;
  background: #262b33;
  border-color: #363c46;
  color: #fff;
}
.btn-build:hover { background: #303742; border-color: #4a515c; }
.btn-build.busy { opacity: 0.7; cursor: wait; }

.user-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 12px;
  border-top: 1px solid #262b33;
}
.user-name { color: #fff; font-size: 13px; font-weight: 600; }
.user-actions { display: flex; gap: 12px; }

/* ---------- 主区域 ---------- */
.main { min-width: 0; padding: 26px 30px 60px; }
.page { display: none; }
.page.active { display: block; }

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}
.page-head h1,
.page-head h2 { margin: 0; font-size: 22px; }
.page-sub { color: var(--text-soft); font-size: 13.5px; margin: -8px 0 18px; }
.head-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* ---------- 统计条 ---------- */
.stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}
.stat {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  min-width: 92px;
}
.stat-num { font-size: 20px; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 12.5px; color: var(--text-mute); }

/* ---------- 表格 ---------- */
.table-wrap {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th {
  text-align: left;
  padding: 11px 14px;
  background: var(--bg-subtle);
  color: var(--text-soft);
  font-weight: 600;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: var(--bg-subtle); }

.row-title { font-weight: 600; color: var(--text); }
.row-title:hover { color: var(--accent); text-decoration: none; }
.row-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.col-date { width: 108px; color: var(--text-mute); font-variant-numeric: tabular-nums; white-space: nowrap; }
.col-cat { width: 110px; }
.col-status { width: 90px; }
.col-act { width: 130px; text-align: right; white-space: nowrap; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-published { background: var(--ok-soft); color: var(--ok); }
.badge-draft { background: var(--bg-subtle); color: var(--text-mute); }
.badge-scheduled { background: var(--warn-soft); color: var(--warn); }
.badge-noindex { background: var(--danger-soft); color: var(--danger); }

.chip {
  display: inline-block;
  background: var(--bg-subtle);
  color: var(--text-soft);
  border-radius: 100px;
  padding: 1px 8px;
  font-size: 11.5px;
}

.row-act {
  background: none;
  border: 0;
  color: var(--text-soft);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 5px;
}
.row-act:hover { background: var(--bg-subtle); color: var(--text); }
.row-act.danger:hover { background: var(--danger-soft); color: var(--danger); }

.empty {
  text-align: center;
  color: var(--text-mute);
  padding: 46px 20px;
  font-size: 14px;
}

/* ---------- 编辑器 ---------- */
.editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 316px;
  gap: 22px;
  align-items: start;
}
.editor-main { min-width: 0; }
.editor-side { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 22px; }

.title-input {
  width: 100%;
  border: 0;
  border-bottom: 2px solid var(--border);
  border-radius: 0;
  background: transparent;
  font-size: 24px;
  font-weight: 700;
  padding: 8px 2px 12px;
  margin: 0 0 12px;
  color: var(--text);
}
.title-input:focus { outline: 0; border-bottom-color: var(--accent); box-shadow: none; }
.title-input::placeholder { color: var(--text-mute); font-weight: 400; }

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  align-items: center;
  padding: 6px 8px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.editor-toolbar button {
  border: 0;
  background: transparent;
  color: var(--text-soft);
  font-family: inherit;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 5px;
  cursor: pointer;
}
.editor-toolbar button:hover { background: var(--bg-subtle); color: var(--text); }
.tb-sep { width: 1px; height: 18px; background: var(--border); margin: 0 5px; }
.tb-upload { color: var(--accent) !important; font-weight: 600; }

.editor-split {
  display: grid;
  grid-template-columns: 1fr;
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  overflow: hidden;
  background: var(--bg-elev);
}
.editor-split.split { grid-template-columns: 1fr 1fr; }

/* ---------- 图片加载失败提示条 ---------- */
.img-warn {
  border: 1px solid var(--danger);
  background: var(--danger-soft);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 10px;
}
.img-warn-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--danger);
  font-size: 13.5px;
}
.img-warn-count {
  background: var(--danger);
  color: #fff;
  border-radius: 100px;
  padding: 1px 9px;
  font-size: 12px;
  font-weight: 600;
}
.img-warn-spacer { flex: 1; }
.img-warn-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  max-height: 140px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.7;
  color: var(--text-soft);
  word-break: break-all;
}
.img-warn-list li {
  padding: 3px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--danger) 20%, transparent);
}
.img-warn-list li:last-child { border-bottom: 0; }
.img-warn-tip {
  margin: 10px 0 0;
  font-size: 12.5px;
  color: var(--text-soft);
  line-height: 1.6;
}

/* ---------- 编辑模式切换 ---------- */
.editor-modebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.mode-tabs {
  display: inline-flex;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}
.mode-tab {
  border: 0;
  background: transparent;
  color: var(--text-soft);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 6px 18px;
  border-radius: 5px;
  cursor: pointer;
  white-space: nowrap;
}
.mode-tab:hover { color: var(--text); }
.mode-tab.active {
  background: var(--bg-elev);
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.mode-hint {
  font-size: 12.5px;
  color: var(--text-mute);
  flex: 1;
  min-width: 180px;
  line-height: 1.5;
}

/* ---------- 富文本编辑区 ---------- */
.rich-input {
  min-height: 62vh;
  max-height: 78vh;
  overflow-y: auto;
  padding: 18px 22px;
  background: var(--bg-elev);
  outline: 0;
  caret-color: var(--accent);
}
.rich-input:focus { outline: 0; box-shadow: none; }
.rich-input:empty::before,
.rich-input.is-empty::before {
  content: attr(data-placeholder);
  color: var(--text-mute);
  pointer-events: none;
  display: block;
}
.rich-input img {
  max-width: 100%;
  height: auto;
}
/* 正在下载远程图片时的占位提示 */
.rich-input img[data-loading] {
  opacity: 0.35;
  outline: 2px dashed var(--accent);
  outline-offset: 2px;
}

.md-input {
  width: 100%;
  min-height: 62vh;
  border: 0;
  border-radius: 0;
  padding: 18px;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.75;
  resize: vertical;
  background: var(--bg-elev);
}
.md-input:focus { outline: 0; box-shadow: none; }

.md-preview {
  border-left: 1px solid var(--border);
  padding: 18px 22px;
  min-height: 62vh;
  max-height: 78vh;
  overflow-y: auto;
  background: var(--bg-elev);
}

.save-state { font-size: 13px; color: var(--text-mute); }
.save-state.dirty { color: var(--warn); }
.save-state.saved { color: var(--ok); }

/* ---------- 面板 ---------- */
.panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.panel-title {
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-mute);
  margin-bottom: 12px;
}
.panel-danger { border-color: var(--border); }

.tag-suggest { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.tag-suggest button {
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-soft);
  border-radius: 100px;
  padding: 2px 10px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}
.tag-suggest button:hover { border-color: var(--accent); color: var(--accent); }

.cover-row { display: flex; gap: 6px; }
.cover-row .input { margin-top: 5px; }
.cover-row .btn { margin-top: 5px; }
.cover-preview { margin-top: 10px; }
.cover-preview img {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  display: block;
}

/* ---------- 自检清单 ---------- */
.checks { list-style: none; padding: 0; margin: 0; font-size: 13.5px; }
.checks li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  color: var(--text-mute);
}
.checks li::before {
  content: "○";
  font-size: 12px;
  color: var(--text-mute);
}
.checks li.ok { color: var(--ok); }
.checks li.ok::before { content: "✓"; color: var(--ok); font-weight: 700; }
.checks li.bad { color: var(--danger); }
.checks li.bad::before { content: "!"; color: var(--danger); font-weight: 700; }

/* ---------- 媒体库 ---------- */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.media-item {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.media-thumb {
  aspect-ratio: 4 / 3;
  background: var(--bg-subtle);
  display: block;
  width: 100%;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.media-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-meta { padding: 8px 10px; }
.media-name {
  font-size: 12px;
  color: var(--text-soft);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.media-size { font-size: 11.5px; color: var(--text-mute); }
.media-actions { display: flex; gap: 4px; padding: 0 8px 8px; }
.media-actions button {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  border-radius: 5px;
  font-size: 11.5px;
  font-family: inherit;
  padding: 4px;
  cursor: pointer;
  color: var(--text-soft);
}
.media-actions button:hover { border-color: var(--accent); color: var(--accent); }
.media-actions button.danger:hover { border-color: var(--danger); color: var(--danger); }

/* ---------- 设置 / 构建 ---------- */
.settings-form .panel { margin-bottom: 16px; }
#panel-build, #panel-account { margin-bottom: 16px; }

.build-output {
  margin-top: 12px;
  padding: 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.65;
  max-height: 340px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
.build-output.err { color: var(--danger); }

.session-list { list-style: none; padding: 0; margin: 0; font-size: 13px; color: var(--text-soft); }
.session-list li { padding: 6px 0; border-bottom: 1px solid var(--border); }
.session-list li:last-child { border-bottom: 0; }

/* ---------- 弹层 ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(10, 12, 14, 0.5); }
.modal-panel {
  position: relative;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 880px;
  max-height: 84vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-body { padding: 18px; overflow-y: auto; }

/* ---------- 提示条 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 200;
  background: #1b1e23;
  color: #fff;
  padding: 11px 20px;
  border-radius: 100px;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  max-width: 90vw;
  text-align: center;
}
.toast.ok { background: #14532d; }
.toast.err { background: #7f1d1d; }

/* ---------- Markdown 预览排版 ---------- */
.prose { font-size: 15px; line-height: 1.8; }
.prose > *:first-child { margin-top: 0; }
.prose h1, .prose h2, .prose h3, .prose h4 { line-height: 1.4; margin: 1.6em 0 0.6em; }
.prose h2 { font-size: 20px; }
.prose h3 { font-size: 17px; }
.prose h4 { font-size: 15.5px; }
.prose p { margin: 0 0 1em; }
.prose ul, .prose ol { padding-left: 1.4em; margin: 0 0 1em; }
.prose li { margin-bottom: 0.3em; }
.prose blockquote {
  margin: 1.2em 0;
  padding: 2px 0 2px 14px;
  border-left: 3px solid var(--accent);
  color: var(--text-soft);
}
.prose img { max-width: 100%; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.prose pre {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  overflow-x: auto;
  font-size: 13px;
}
.prose code { font-size: 0.88em; }
.prose pre code { background: none; border: 0; padding: 0; }
.prose table { border-collapse: collapse; width: 100%; font-size: 13.5px; margin: 1.2em 0; }
.prose th, .prose td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; }
.prose th { background: var(--bg-subtle); }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 1.8em 0; }

/* ---------- 响应式 ---------- */
@media (max-width: 1100px) {
  .editor-layout { grid-template-columns: 1fr; }
  .editor-side { position: static; }
}

@media (max-width: 860px) {
  /* minmax(0,1fr) 是关键：否则网格子项不会收缩到内容宽度以下，
     侧栏里那排可横向滚动的导航会把整个页面撑出横向滚动条 */
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: column;
    min-width: 0;
  }
  .side-nav {
    flex-direction: row;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0 10px 10px;
    gap: 4px;
    min-width: 0;
    scrollbar-width: none;
  }
  .side-nav::-webkit-scrollbar { display: none; }
  .side-link { white-space: nowrap; width: auto; }
  .sidebar-foot {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }
  .btn-build { width: auto; }
  .user-row { border: 0; padding: 0; }
  .main { padding: 18px 16px 50px; min-width: 0; }
  .editor-split.split { grid-template-columns: 1fr; }
  .md-preview { border-left: 0; border-top: 1px solid var(--border); }
  .page-head { flex-direction: column; align-items: stretch; }
  .head-actions { justify-content: flex-start; }
  .title-input { font-size: 20px; }
  .md-input { min-height: 46vh; }

  /* 表格在窄屏改成卡片堆叠，避免右侧列被裁掉又没法滑动 */
  .table-wrap { overflow: visible; border: 0; background: transparent; }
  .data-table { display: block; }
  .data-table thead { display: none; }
  .data-table tbody,
  .data-table tr,
  .data-table td { display: block; width: 100%; }
  .data-table tr {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 10px;
  }
  .data-table tr:hover { background: var(--bg-elev); }
  .data-table td {
    border: 0;
    padding: 0 0 8px;
  }
  .data-table td:last-child { padding-bottom: 0; }
  .data-table .col-date,
  .data-table .col-cat { display: block; width: auto; }
  .data-table .col-cat:empty { display: none; }
  .col-act { width: auto !important; text-align: left; }
  .row-act { padding: 5px 10px; font-size: 13px; }
  .row-tags { margin-top: 6px; }
  .stat { flex: 1 1 88px; min-width: 0; }
  .stats-row { gap: 8px; }
}

@media (max-width: 520px) {
  .sidebar-head { padding: 16px 14px 12px; }
  .stat { flex: 1 1 72px; padding: 8px 12px; }
  .stat-num { font-size: 18px; }
  .stat-label { font-size: 11.5px; }
  .media-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
  .modal { padding: 0; }
  .modal-panel { max-height: 100vh; height: 100%; border-radius: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; }
}
