:root {
  --blue: #0052d9;
  --blue-dark: #003896;
  --ink: #1a1a1a;
  --muted: #888;
  --line: #eee;
  --bg: #f5f7fa;
  --card: #fff;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Arial, sans-serif; }
body { padding-top: var(--safe-top); padding-bottom: var(--safe-bottom); }
button { font-family: inherit; border: none; cursor: pointer; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; background: linear-gradient(135deg, var(--blue), var(--blue-dark));
  color: #fff; box-shadow: 0 2px 12px rgba(0, 82, 217, .25);
}
.brand-logo { width: 44px; height: 44px; border-radius: 10px; background: #fff; flex: none; }
.brand-text { flex: 1; min-width: 0; }
.brand-text h1 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: 1px; }
.brand-text p { margin: 2px 0 0; font-size: 11px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.install-btn {
  flex: none; padding: 7px 12px; border-radius: 18px; font-size: 12px; font-weight: 600;
  color: var(--blue); background: #fff;
}
.admin-entry {
  flex: none; padding: 7px 12px; border-radius: 18px; font-size: 12px; font-weight: 600;
  color: #fff; background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.5);
}

.catbar { position: sticky; top: 68px; z-index: 15; background: var(--card); border-bottom: 1px solid var(--line); }
.cat-scroll { display: flex; gap: 8px; padding: 10px 16px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.cat-scroll::-webkit-scrollbar { display: none; }
.cat {
  flex: none; padding: 6px 16px; border-radius: 16px; font-size: 13px; white-space: nowrap;
  color: #555; background: #f2f4f7; transition: .15s;
}
.cat.active { color: #fff; background: var(--blue); font-weight: 600; }

.view { padding: 12px; }
.pull-tip { text-align: center; color: var(--muted); font-size: 12px; height: 0; overflow: hidden; transition: height .2s; }
.pull-tip.show { height: 28px; line-height: 28px; }

.list { display: flex; flex-direction: column; gap: 12px; }
.card {
  display: flex; gap: 12px; padding: 14px; background: var(--card); border-radius: 14px;
  box-shadow: 0 2px 10px rgba(0,0,0,.04); text-decoration: none; color: inherit;
}
.card:active { transform: scale(.99); }
.card-cover { width: 96px; height: 76px; border-radius: 10px; object-fit: cover; flex: none; background: #eef1f6; }
.card-cover.ph { display: flex; align-items: center; justify-content: center; color: #c8d0dc; font-size: 24px; }
.card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.card-title { font-size: 16px; font-weight: 700; line-height: 1.4; margin: 0 0 6px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-summary { font-size: 12px; color: var(--muted); line-height: 1.5; margin: 0 0 8px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { margin-top: auto; display: flex; gap: 10px; font-size: 11px; color: #aaa; }
.cat-tag { color: var(--blue); background: #eaf1ff; padding: 1px 7px; border-radius: 8px; }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty img { width: 80px; height: 80px; margin: 0 auto 16px; opacity: .5; border-radius: 18px; }
.empty p { font-size: 16px; color: #555; margin: 0 0 6px; }
.empty span { font-size: 12px; }
.loading, .more { text-align: center; color: var(--muted); font-size: 12px; padding: 16px; }

.back-btn { position: sticky; top: 12px; z-index: 10; margin: 0 0 12px;
  padding: 8px 14px; border-radius: 18px; background: rgba(255,255,255,.92); color: var(--blue);
  font-size: 14px; font-weight: 600; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.article { background: var(--card); border-radius: 14px; padding: 20px 18px 40px; box-shadow: 0 2px 10px rgba(0,0,0,.04); }
.article h1 { font-size: 24px; line-height: 1.4; margin: 0 0 12px; }
.article-meta { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12px; color: var(--muted);
  margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.article-meta .author { color: var(--blue); font-weight: 600; }
.para { font-family: SimSun, "宋体", serif; font-size: 16px; line-height: 1.9; margin: 0 0 14px;
  text-align: justify; text-align-last: left; text-justify: inter-ideograph;
  word-break: normal; line-break: strict; }
.para-h1 { font-family: SimHei, "黑体", sans-serif; font-size: 18px; font-weight: 700; line-height: 1.5; margin-top: 26px; }
.para-h2 { font-family: SimHei, "黑体", sans-serif; font-size: 17px; font-weight: 700; line-height: 1.5; margin-top: 22px; }
.para-h3 { font-family: SimHei, "黑体", sans-serif; font-size: 16px; font-weight: 600; line-height: 1.5; margin-top: 18px; }
.para-quote { color: #666; border-left: 4px solid var(--blue); padding-left: 14px; font-style: italic; }
.para-align-center { text-align: center; }
.para-align-right { text-align: right; }
.para-align-left { text-align: left; }
.rich-sup { font-size: .68em; vertical-align: super; }
.rich-sub { font-size: .68em; vertical-align: sub; }
.para-align-justify { text-align: justify; }
.para-list { padding-left: 20px; }
.para-olist { padding-left: 20px; }
/* 列表符号/序号由渲染层 .list-prefix 生成，不落库；两端视觉一致 */
.list-prefix { color: var(--blue); font-weight: 600; margin-right: 6px; }
.article-hr { border: none; border-top: 1px solid #e5e5e5; margin: 20px 0; }
.table-wrap { overflow-x: auto; margin: 0 0 14px; }
.rich-table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 1.6; background: #fff; }
.rich-table td { border: 1px solid #d9e0ea; padding: 7px 10px; }
.rich-table tr:first-child td { background: #f0f4fb; font-weight: 600; }
.strong { font-weight: 700; color: var(--blue-dark); }
.article-img { width: 100%; border-radius: 10px; margin: 8px 0 18px; }
.img-caption { text-align: center; font-size: 12px; color: var(--muted); margin: -10px 0 18px; }
.article-foot { margin-top: 30px; padding-top: 18px; border-top: 1px solid var(--line);
  text-align: center; color: #bbb; font-size: 11px; }

/* 正文底部分享栏：微信好友 / 朋友圈 / 导出长图 */
.share-bar { display: flex; margin: 12px 0 24px; padding: 14px 6px; background: var(--card);
  border-radius: 14px; box-shadow: 0 2px 10px rgba(0,0,0,.04); }
.share-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: transparent; font-size: 12px; color: #555; }
.share-item:active { opacity: .6; }
.share-ico { width: 46px; height: 46px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 18px; font-weight: 700; color: #fff; }
.share-ico.wechat { background: #07c160; }
.share-ico.moments { background: #2ba245; }
.share-ico.poster { background: var(--blue); }
.share-sheet { text-align: left; }
.poster-mask { align-items: center; justify-content: center; }
.poster-sheet { width: min(520px, 94vw); max-height: 92vh; display: flex; flex-direction: column; text-align: left; }
.poster-tip { font-size: 12px; color: var(--muted); margin: 0 0 10px; }
.poster-sharetext { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; padding: 8px 10px;
  background: #f2f5fa; border-radius: 8px; }
.poster-sharetext[hidden] { display: none; }
.poster-sharetext .pst-text { flex: 1; font-size: 12px; color: var(--ink); line-height: 1.5;
  word-break: break-all; max-height: 56px; overflow: hidden; }
.poster-sharetext .pst-copy { flex-shrink: 0; border: 1px solid var(--brand); color: var(--brand);
  background: transparent; border-radius: 6px; padding: 5px 12px; font-size: 12px; }
.poster-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: #eceff4; border-radius: 10px; margin-bottom: 14px; }
.poster-scroll img { display: block; width: 100%; height: auto; }

.sheet-mask { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.45);
  display: flex; align-items: flex-end; }
.sheet { width: 100%; background: #fff; border-radius: 20px 20px 0 0; padding: 24px 20px calc(24px + var(--safe-bottom)); }
.sheet-logo { width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 14px; }
.sheet h2 { text-align: center; font-size: 18px; margin: 0 0 18px; }
.steps { font-size: 14px; line-height: 1.9; color: #444; margin-bottom: 20px; }
.steps .st { padding: 10px 12px; background: #f5f7fa; border-radius: 10px; margin-bottom: 8px; }
.steps .st b { color: var(--blue); }
.sheet-actions { display: flex; flex-direction: column; gap: 10px; }
.btn-primary { padding: 13px; border-radius: 24px; font-size: 15px; font-weight: 600; color: #fff; background: var(--blue); }
.btn-ghost { padding: 13px; border-radius: 24px; font-size: 15px; color: #666; background: #f2f4f7; }

.toast { position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%); z-index: 80;
  padding: 10px 18px; border-radius: 20px; background: rgba(0,0,0,.8); color: #fff; font-size: 13px; }

/* ---------- 管理 / 编辑器 ---------- */
.admin-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.admin-head .back-btn { position: static; margin: 0; }
.admin-user { flex: 1; text-align: center; font-size: 13px; color: var(--muted); }
.logout-btn, .save-btn {
  flex: none; padding: 8px 14px; border-radius: 18px; font-size: 13px; font-weight: 600;
  color: var(--blue); background: #eaf1ff;
}
.save-btn { color: #fff; background: var(--blue); }
.new-note-btn { width: 100%; margin-bottom: 14px; }
.admin-list { display: flex; flex-direction: column; gap: 10px; }
.admin-item { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--card);
  border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,.04); }
.admin-item-body { flex: 1; min-width: 0; }
.admin-item-title { font-size: 15px; font-weight: 600; margin: 0 0 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-item-meta { font-size: 11px; color: var(--muted); }
.admin-item-btn { flex: none; padding: 6px 12px; border-radius: 14px; font-size: 12px;
  color: var(--blue); background: #eaf1ff; }
.admin-item-btn.del { color: #e34d59; background: #ffecec; }

/* ===== 编辑器（与小程序「写记事」页同版式） ===== */
.editor-view { background: #f5f7fb; padding-bottom: 0; }
.ed-nav { display: flex; align-items: center; background: var(--blue);
  padding: 12px 14px calc(12px + env(safe-area-inset-top, 0px)); margin: -14px -14px 0; }
.ed-nav-back { color: #fff; font-size: 26px; line-height: 1; padding: 0 10px 4px 0;
  background: transparent; }
.ed-nav-title { flex: 1; text-align: center; color: #fff; font-size: 16px; font-weight: 600; margin-right: 32px; }
.ed-nav-right { width: 0; }
.editor-form { background: transparent; border-radius: 0; padding: 4px 4px 110px; box-shadow: none; }
.ed-card { background: #fff; border-radius: 14px; box-shadow: 0 2px 10px rgba(0,0,0,.05); margin: 10px 4px 0; }
.ed-title-input { display: block; width: 100%; border: none; outline: none; background: transparent;
  font-size: 20px; font-weight: 700; color: var(--ink); padding: 18px 16px; }
.ed-title-input::placeholder { color: #b8c0cc; font-weight: 700; }
.ed-body-card { padding: 6px 10px 12px; }
.ed-meta-row { display: flex; align-items: center; gap: 8px; padding: 4px 8px 12px; font-size: 13px; }
.ed-now { color: var(--blue); font-weight: 600; }
.ed-sep { width: 1px; height: 12px; background: #d4dae3; }
.ed-loc { color: #9aa3b0; }
.ed-loc-pos { color: var(--ink); max-width: 55%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ed-toolbar { display: block; padding: 4px 4px 4px; border-bottom: 1px solid #eef1f6; }
.ed-tool-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-bottom: 5px; }
.ed-tool-row:last-child { margin-bottom: 0; }
.ed-tb-sep { width: 1px; height: 14px; background: #e3e8ef; margin: 0 2px; flex: none; }
.ed-fmt { min-width: 30px; justify-content: center; font-size: 14px; }
.ed-act { min-width: 30px; justify-content: center; font-size: 15px; }
.bg-a { font-weight: 800; background: #ffff00; padding: 0 2px; border-radius: 2px; }
.ed-pill { padding: 4px 7px; border-radius: 14px; font-size: 12px; color: var(--ink);
  background: #f0f2f6; border: 1px solid transparent; display: inline-flex; align-items: center; gap: 2px; white-space: nowrap; }
.ed-pill b { font-weight: 800; }
.color-a { font-weight: 800; color: #e34d59; border-bottom: 3px solid #e34d59; line-height: 1; }
.al { display: inline-block; width: 12px; height: 9px; position: relative; }
.al::before { content: ''; position: absolute; left: 0; right: 0; top: 3px; height: 2px; background: currentColor; }
.al::after { content: ''; position: absolute; width: 7px; height: 2px; background: currentColor; top: 0; }
.al-left::after { left: 0; }
.al-right::after { right: 0; }
.ed-pop { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 10px 4px; border-bottom: 1px solid #eef1f6; }
.ed-pop-label { font-size: 12px; color: var(--muted); }
.ed-swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px #d8dee8; }
.ed-pop-item { padding: 7px 14px; border-radius: 16px; font-size: 13px; color: var(--ink); background: #f0f2f6; }
.ed-hint { font-size: 11px; line-height: 1.6; color: #999; padding: 8px 4px 2px; }
.ed-files { display: flex; flex-direction: column; gap: 6px; padding: 6px; }
.ed-file-chip { display: flex; align-items: center; gap: 8px; background: #f5f7fa; border: 1px solid #e5eaf2; border-radius: 10px; padding: 7px 10px; position: relative; }
.ed-file-ico { flex: none; font-size: 10px; font-weight: 800; color: #fff; background: #4a90d9; border-radius: 6px; padding: 4px 6px; min-width: 14px; text-align: center; }
.ed-file-ico.ed-file-video { background: #e0564a; }
.ed-file-name { font-size: 12px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; padding-right: 18px; }
.ed-file-chip .ed-img-del { position: static; flex: none; }
.article-video-wrap { margin: 10px 0; }
.article-video { display: block; width: 100%; max-height: 480px; border-radius: 10px; background: #000; }
.file-caption { font-size: 12px; color: var(--muted); margin-top: 6px; text-align: center; }
.file-card { display: flex; align-items: center; gap: 12px; margin: 10px 0; padding: 12px 14px; background: #f5f7fa; border: 1px solid #e5eaf2; border-radius: 12px; text-decoration: none; }
.file-card:active { background: #eef1f6; }
.file-card-ico { flex: none; font-size: 11px; font-weight: 800; color: #fff; background: #4a90d9; border-radius: 8px; padding: 10px 8px; min-width: 30px; text-align: center; }
.file-card-info { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.file-card-name { font-size: 14px; color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-card-size { font-size: 11px; color: var(--muted); }
.ed-content-input { display: block; width: 100%; min-height: 260px; border: none; outline: none; background: transparent;
  font-family: SimSun, "宋体", serif; font-size: 16px; line-height: 1.8; color: var(--ink); padding: 8px 6px; overflow-wrap: anywhere;
  white-space: pre-wrap; word-break: break-word; caret-color: var(--blue); }
.ed-content-input:empty:before { content: attr(data-placeholder); color: #b8c0cc; pointer-events: none; }
.ed-content-input p, .ed-content-input div { margin: 0 0 4px; }
.ed-content-input h1 { font-family: SimHei, "黑体", sans-serif; font-size: 18px; line-height: 1.45; font-weight: 800; margin: 10px 0 6px; }
.ed-content-input h2 { font-family: SimHei, "黑体", sans-serif; font-size: 17px; line-height: 1.5; font-weight: 800; margin: 8px 0 5px; }
.ed-content-input h3 { font-family: SimHei, "黑体", sans-serif; font-size: 16px; line-height: 1.55; font-weight: 700; margin: 6px 0 4px; }
.ed-content-input .ed-quote { margin: 8px 0; padding: 6px 0 6px 12px; border-left: 4px solid var(--blue); color: #666; font-style: italic; }
.ed-content-input ul.ed-list, .ed-content-input ol.ed-list { margin: 6px 0; padding-left: 24px; }
.ed-content-input ul.ed-list { list-style: disc; }
.ed-content-input ol.ed-list { list-style: decimal; }
.ed-content-input ul.ed-list li, .ed-content-input ol.ed-list li { margin: 2px 0; }
.ed-content-input hr.ed-hr { border: none; border-top: 1px solid #e0e0e0; margin: 14px 0; }
.ed-content-input img.ed-inline-img { display: block; max-width: 100%; border-radius: 8px; margin: 8px 0 12px; }
.ed-content-input .ed-media-chip { display: inline-block; padding: 2px 10px; margin: 2px 0; border-radius: 12px;
  background: #eef4ff; color: var(--blue); font-size: 13px; }
.ed-content-input table.rich-table { margin: 8px 0 12px; }
/* Word 式可编辑表格：单元格有边框、最小高度，点击即可输入文字 */
.ed-content-input table.ed-editable-table { table-layout: fixed; border-collapse: collapse; width: 100%; }
.ed-content-input table.ed-editable-table td { border: 1px solid #9fb4cf; min-width: 40px; min-height: 30px;
  padding: 6px 8px; vertical-align: top; line-height: 1.6; cursor: text; }
.ed-content-input table.ed-editable-table tr:first-child td { background: #fff; font-weight: 400; }
.ed-content-input table.ed-editable-table td:focus { outline: 2px solid var(--blue); outline-offset: -2px; background: #f3f8ff; }
.table-field-row { display: flex; gap: 14px; margin-bottom: 18px; }
.table-field { flex: 1; font-size: 13px; color: var(--ink); }
.table-field .field-input { margin-top: 6px; text-align: center; font-size: 18px; font-weight: 600; }
.ed-content-input sup, .ed-content-input sub { font-size: 0.75em; }
.ed-images { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 6px; }
.ed-img-thumb { position: relative; width: 72px; height: 72px; border-radius: 8px; overflow: hidden; background: #eef1f6; }
.ed-img-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ed-img-thumb .ed-img-del { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px;
  border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; font-size: 13px; line-height: 20px; text-align: center; }
.ed-img-thumb .ed-img-no { position: absolute; bottom: 0; left: 0; padding: 1px 6px; background: var(--blue); color: #fff; font-size: 10px; }
.ed-cat-row { display: flex; align-items: center; justify-content: space-between; margin: 10px 4px;
  padding: 14px 16px; background: var(--card); border-radius: 14px; box-shadow: 0 2px 10px rgba(0,0,0,.04); }
.ed-cat-label { font-size: 14px; font-weight: 600; color: var(--ink); }
.ed-cat-select { border: none; outline: none; background: transparent; font-size: 14px;
  color: var(--blue); text-align: right; direction: rtl; max-width: 60%; }
.ed-cat-select option { direction: ltr; }
.ed-actions { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  display: flex; gap: 12px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  background: #fff; box-shadow: 0 -2px 12px rgba(0,0,0,.06); }
.ed-btn-preview { flex: 1; padding: 13px; border-radius: 24px; font-size: 16px; font-weight: 600;
  color: var(--ink); background: #eef1f6; }
.ed-btn-save { flex: 1; padding: 13px; border-radius: 24px; font-size: 16px; font-weight: 600;
  color: #fff; background: var(--blue); }
.ed-btn-preview:disabled, .ed-btn-save:disabled { opacity: .6; }

/* 预览弹窗 */
.preview-sheet { width: min(640px, 92vw); max-height: 84vh; display: flex; flex-direction: column; text-align: left; }
.preview-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.preview-head-title { font-size: 16px; font-weight: 700; color: var(--ink); }
.preview-close { padding: 6px 14px; border-radius: 16px; font-size: 13px; color: var(--blue); background: #eaf1ff; }
.preview-body { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.preview-body h1 { font-size: 20px; margin: 0 0 10px; color: var(--ink); }

.login-sheet { text-align: center; }
.field-input { width: 100%; padding: 10px 12px; border: 1px solid #e2e6ec; border-radius: 10px;
  font-size: 15px; background: #fff; color: var(--ink); outline: none; }
.field-input:focus { border-color: var(--blue); }
.login-tip { font-size: 13px; color: var(--muted); margin: -8px 0 16px; }
.login-sheet .field-input { margin-bottom: 16px; text-align: center; }
.upload-mask { position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center; }
.upload-box { padding: 18px 26px; border-radius: 14px; background: #fff; font-size: 15px; color: var(--blue); font-weight: 600; }

/* 写文章悬浮按钮（与小程序列表页一致） */
.fab {
  position: fixed; right: 20px; bottom: calc(28px + var(--safe-bottom)); z-index: 30;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--blue); color: #fff; font-size: 28px; line-height: 56px; text-align: center;
  padding: 0; box-shadow: 0 6px 18px rgba(0, 82, 217, .4);
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s;
}
.fab:active { transform: scale(.92); }
