/* Emlog 风格文章阅读页 */
body.em-article-body,
body:has(.em-page) {
  margin: 0 !important;
  padding: 0 !important;
  background: #f3f4f6 !important;
  overflow-x: hidden;
}
html[data-theme="dark"] body.em-article-body,
html[data-theme="dark"] body:has(.em-page) { background: #0c0c0c !important; }
.em-page {
  --em-text: #2a2a2a;
  --em-muted: #919191;
  --em-line: #ececec;
  --em-soft: #f5f6f8;
  --em-blue: #2f8fff;
  --em-pink: #ff5a7a;
  --em-gold: #e8b86d;
  --em-bg: transparent;
  --em-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", "Segoe UI", sans-serif;
  min-height: 100dvh;
  margin: 0;
  background: transparent;
  color: var(--em-text);
  font-family: var(--em-sans);
  font-weight: 400;
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
html[data-theme="dark"] .em-page {
  --em-text: #e6e6e6;
  --em-muted: #8a8a8a;
  --em-line: #2a2a2a;
  --em-soft: #1c1c1c;
  --em-bg: transparent;
}

.em-top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 50px;
  padding: 0 12px;
  background: #ffffff;
  border-bottom: 1px solid rgba(0,0,0,.06);
}
/* 非触屏可用轻模糊；iOS 上 backdrop-filter 易掉帧，默认实底 */
@media (hover: hover) and (pointer: fine) {
  .em-top {
    background: rgba(255,255,255,.92);
    backdrop-filter: saturate(1.1) blur(8px);
    -webkit-backdrop-filter: saturate(1.1) blur(8px);
  }
}
html[data-theme="dark"] .em-top {
  background: #111111;
  border-bottom-color: rgba(255,255,255,.08);
}
@media (hover: hover) and (pointer: fine) {
  html[data-theme="dark"] .em-top { background: rgba(17,17,17,.92); }
}
.em-top-btn {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #5a5a5a;
  display: grid;
  place-items: center;
  text-decoration: none;
  font-size: 1.25rem;
  flex-shrink: 0;
  cursor: pointer;
}
html[data-theme="dark"] .em-top-btn { color: #bbb; }
.em-top-btn:active { background: var(--em-soft); }
.em-top-brand {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-weight: 600;
  font-size: .95rem;
  letter-spacing: .04em;
  color: var(--em-text);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.em-top-right {
  display: flex;
  align-items: center;
  gap: 0;
  flex-shrink: 0;
}

.em-wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 12px 56px;
}

.em-panel {
  margin: 0 0 14px;
  padding: 14px 12px 16px;
  background: #fff;
  border: 1px solid #e0e2e6;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
}
html[data-theme="dark"] .em-panel {
  background: #161616;
  border-color: #333;
  box-shadow: none;
}

.em-head {
  margin: 0 0 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--em-line);
  text-align: center;
}

.em-title {
  margin: 0 0 6px;
  font-size: 1.12rem;
  font-weight: 700;
  line-height: 1.3;
  color: #141414;
  text-align: center;
}
html[data-theme="dark"] .em-title { color: #f2f2f2; }

.em-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  margin: 0;
  color: var(--em-muted);
  font-size: .68rem;
  line-height: 1.35;
  text-align: center;
}
.em-meta > span {
  display: inline;
  white-space: nowrap;
}
.em-meta > span + span::before {
  content: "·";
  margin: 0 5px;
  opacity: .4;
}

.em-cover {
  margin: 0 0 10px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--em-soft);
}
.em-cover img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 180px;
  object-fit: cover;
}

.em-summary { display: none; }

/*
 * 正文：尽量贴近后台 wangEditor 默认排版
 * 对齐 / 字号 / 颜色以编辑器内联样式为准，前台不抢
 */
.em-body {
  font-family: var(--em-sans);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
  color: #333;
  overflow-wrap: anywhere;
  word-break: break-word;
}
html[data-theme="dark"] .em-body { color: #ddd; }

.em-body > *:first-child { margin-top: 0; }
.em-body > *:last-child { margin-bottom: 0; }

.em-body p {
  margin: .75em 0;
}
.em-body p:empty,
.em-body p:has(> br:only-child) { display: none; }

.em-body h1,
.em-body h2,
.em-body h3,
.em-body h4,
.em-body h5 {
  margin: 1.1em 0 .55em;
  font-weight: 700;
  line-height: 1.4;
  color: inherit;
}
.em-body h1 { font-size: 2em; }
.em-body h2 { font-size: 1.5em; }
.em-body h3 { font-size: 1.17em; }
.em-body h4 { font-size: 1em; }
.em-body h5 { font-size: .83em; }

.em-body a {
  color: #1890ff;
  text-decoration: none;
}
.em-body a:hover { text-decoration: underline; }

.em-body ul,
.em-body ol {
  margin: .75em 0;
  padding-left: 1.5em;
}
.em-body li { margin: .25em 0; }

.em-body blockquote {
  margin: .75em 0;
  padding: 8px 12px;
  border-left: 4px solid #ccc;
  background: #f5f5f5;
  color: #666;
}
html[data-theme="dark"] .em-body blockquote {
  background: #1a1a1a;
  border-left-color: #555;
  color: #aaa;
}

.em-body hr {
  border: 0;
  height: 1px;
  background: #e8e8e8;
  margin: 1.2em 0;
}
.em-body pre {
  margin: .75em 0;
  padding: 12px 14px;
  border-radius: 4px;
  background: #f6f8fa;
  color: #333;
  overflow-x: auto;
  font-size: .9em;
  line-height: 1.5;
}
html[data-theme="dark"] .em-body pre {
  background: #1e1e1e;
  color: #eaeaea;
}
.em-body code,
.em-body pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.em-body :not(pre) > code {
  padding: .1em .35em;
  border-radius: 3px;
  background: rgba(0,0,0,.06);
  font-size: .9em;
}
html[data-theme="dark"] .em-body :not(pre) > code {
  background: rgba(255,255,255,.08);
}

.em-body table {
  width: 100%;
  border-collapse: collapse;
  margin: .75em 0;
  font-size: .95em;
}
.em-body .table-scroll {
  overflow-x: auto;
  margin: .75em 0;
}
.em-body th,
.em-body td {
  border: 1px solid #ddd;
  padding: 8px 10px;
}
.em-body th { background: #fafafa; }
html[data-theme="dark"] .em-body th { background: #1a1a1a; }
html[data-theme="dark"] .em-body th,
html[data-theme="dark"] .em-body td { border-color: #333; }

html[data-theme="dark"] .em-body .link-card,
html[data-theme="dark"] .em-body .copy-block,
html[data-theme="dark"] .em-body .alert-block {
  background: #1a1a1a;
  border-color: #2a2a2a;
}
html[data-theme="dark"] .em-tip-close { background: #222; color: #bbb; }

/* 图片：与编辑器一致，最大不超过内容宽；对齐跟随段落 */
.em-body .article-img,
.em-body figure.article-img,
.em-body figure {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: .5em 0;
  padding: 0;
  border: 0;
  background: transparent;
  line-height: 0;
}
.em-body p[style*="text-align: center"] .article-img,
.em-body p[style*="text-align:center"] .article-img,
.em-body p[style*="text-align: center"] > img,
.em-body p[style*="text-align:center"] > img,
.em-body [style*="text-align: center"] > .article-img,
.em-body [style*="text-align:center"] > .article-img {
  margin-left: auto;
  margin-right: auto;
}
.em-body p[style*="text-align: right"] .article-img,
.em-body p[style*="text-align:right"] .article-img,
.em-body p[style*="text-align: right"] > img,
.em-body p[style*="text-align:right"] > img {
  margin-left: auto;
  margin-right: 0;
}
.em-body img,
.em-body .article-pic,
.em-body p > img,
.em-body > img {
  display: inline-block;
  max-width: 100%;
  height: auto;
  margin: .25em 0;
  border: 0;
  border-radius: 0;
  vertical-align: middle;
  cursor: zoom-in;
  box-sizing: border-box;
  content-visibility: auto;
  contain-intrinsic-size: 300px;
}
.em-body .article-img img,
.em-body figure img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0;
  cursor: zoom-in;
  box-sizing: border-box;
}
.em-body p:has(> img:only-child) {
  line-height: 0;
}
.em-body figcaption {
  margin-top: 6px;
  color: #999;
  font-size: .85em;
  line-height: 1.4;
}

/* 图片放大层 */
.em-zoom-mask {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,.82);
  align-items: center;
  justify-content: center;
  padding: 16px;
  cursor: zoom-out;
}
.em-zoom-mask.show { display: flex; }
.em-zoom-mask img {
  max-width: min(100%, 960px);
  max-height: 90dvh;
  width: auto;
  height: auto;
  border-radius: 8px;
  object-fit: contain;
  box-shadow: 0 8px 32px rgba(0,0,0,.35);
  cursor: zoom-out;
}

.em-body .alert-block {
  display: flex;
  gap: 10px;
  margin: 0 0 1em;
  padding: 10px 12px;
  border-radius: 10px;
}
.em-body .link-card {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 0 0 1em;
  padding: 12px;
  border: 1px solid var(--em-line);
  border-radius: 12px;
  background: var(--em-soft);
}
.em-body .link-card-btn {
  color: var(--em-blue);
  text-decoration: none;
  font-weight: 650;
  font-size: .85rem;
  flex-shrink: 0;
}
.em-body .copy-block {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 0 0 1em;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--em-soft);
  border: 1px solid var(--em-line);
}
.em-body .copy-btn {
  border: 0;
  border-radius: 999px;
  padding: 6px 12px;
  background: var(--em-blue);
  color: #fff;
  cursor: pointer;
  font-size: .8rem;
}

/* 正文框内底部：打赏 / 点赞 / 上下篇 */
.em-foot {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--em-line);
}
.em-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 0 0 12px;
}
.em-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 96px;
  height: 36px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: .85rem;
  font-weight: 650;
  cursor: pointer;
  text-decoration: none;
  transition: transform .12s, filter .12s;
}
.em-btn:active { transform: scale(.97); }
.em-btn-tip {
  background: linear-gradient(180deg, #f0c987, #e0a85a);
  color: #5a3a10;
  border-color: #e0b56a;
  box-shadow: 0 4px 12px rgba(224, 168, 90, .28);
}
.em-btn-like {
  background: #fff;
  color: #666;
  border-color: #ddd;
}
html[data-theme="dark"] .em-btn-like {
  background: #1a1a1a;
  border-color: #333;
  color: #ccc;
}
.em-btn-like.is-on {
  color: var(--em-pink);
  border-color: #ffc0cb;
  background: #fff5f7;
}
html[data-theme="dark"] .em-btn-like.is-on {
  background: #2a151a;
  border-color: #5a3038;
}

/* 上下篇 */
.em-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0;
  padding-top: 12px;
  border-top: 1px solid var(--em-line);
}
.em-copyright {
  margin: 8px 0 0;
  padding: 10px 4px 4px;
  text-align: center;
  color: var(--em-muted);
  font-size: .78rem;
  line-height: 1.6;
}
.em-copyright a {
  color: inherit;
  text-decoration: none;
}
.em-copyright a:hover { text-decoration: underline; }
.em-comments.em-panel { margin-top: 14px; }
.em-nav a,
.em-nav span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 36px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--em-soft);
  color: #666;
  text-decoration: none;
  font-size: .8rem;
  font-weight: 600;
  overflow: hidden;
}
html[data-theme="dark"] .em-nav a,
html[data-theme="dark"] .em-nav span { color: #aaa; }
.em-nav a:active { filter: brightness(.97); }
.em-nav > span { opacity: .45; cursor: default; }
.em-nav-label { flex-shrink: 0; }
.em-nav-title {
  max-width: 7em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
  opacity: .72;
  font-size: .8rem;
}

/* 评论 */
.em-comments { margin-top: 8px; }
.em-comments-title {
  margin: 0 0 14px;
  font-size: 1.15rem;
  font-weight: 750;
  color: #222;
}
.em-comments-title small {
  font-weight: 600;
  font-size: .85rem;
  color: var(--em-muted);
  margin-left: 4px;
}
html[data-theme="dark"] .em-comments-title { color: #eee; }
.em-flash {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: .9rem;
}
.em-flash-ok { background: #ecfdf5; color: #047857; }
.em-flash-err { background: #fff1f2; color: #e11d48; }
html[data-theme="dark"] .em-flash-ok { background: #0f2a1f; color: #6ee7b7; }
html[data-theme="dark"] .em-flash-err { background: #2a151a; color: #fda4af; }

.em-comment-form textarea {
  display: block;
  width: 100%;
  min-height: 110px;
  box-sizing: border-box;
  padding: 12px 14px;
  border: 1px solid #e6e6e6;
  border-radius: 12px;
  background: #fff;
  color: var(--em-text);
  font: inherit;
  font-size: 16px; /* 避免 iOS 聚焦放大 */
  line-height: 1.6;
  resize: vertical;
  outline: 0;
}
html[data-theme="dark"] .em-comment-form textarea {
  background: #1a1a1a;
  border-color: #333;
}
.em-comment-form textarea:focus {
  border-color: #b7d9ff;
  box-shadow: 0 0 0 3px rgba(59,158,255,.15);
}
.em-comment-fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 12px;
}
@media (min-width: 520px) {
  .em-comment-fields { grid-template-columns: 1fr 1fr 1fr; }
}
.em-comment-fields input {
  height: 40px;
  padding: 0 12px;
  border: 1px solid #e6e6e6;
  border-radius: 10px;
  background: #fff;
  color: var(--em-text);
  font: inherit;
  font-size: 16px; /* 避免 iOS 聚焦放大 */
  outline: 0;
  box-sizing: border-box;
  width: 100%;
}
html[data-theme="dark"] .em-comment-fields input {
  background: #1a1a1a;
  border-color: #333;
}
.em-comment-fields input:focus {
  border-color: #b7d9ff;
  box-shadow: 0 0 0 3px rgba(59,158,255,.12);
}
.em-comment-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
}
.em-comment-submit {
  height: 40px;
  padding: 0 22px;
  border: 0;
  border-radius: 999px;
  background: var(--em-pink);
  color: #fff;
  font-size: .92rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(255,90,122,.28);
}
.em-comment-submit:active { transform: scale(.97); }
.em-private-switch {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--em-muted);
  font-size: .85rem;
  cursor: pointer;
  user-select: none;
}
.em-private-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.em-switch-ui {
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: #ddd;
  position: relative;
  transition: background .18s;
  flex-shrink: 0;
}
.em-switch-ui::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.18);
  transition: transform .18s;
}
.em-private-switch input:checked + .em-switch-ui {
  background: var(--em-pink);
}
.em-private-switch input:checked + .em-switch-ui::after {
  transform: translateX(16px);
}
html[data-theme="dark"] .em-switch-ui { background: #444; }

.em-comment-list { margin-top: 28px; }
.em-comment-item {
  padding: 14px 0;
  border-bottom: 1px solid var(--em-line);
}
.em-comment-item:last-child { border-bottom: 0; }
.em-comment-hd {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  color: var(--em-muted);
  font-size: .8rem;
}
.em-comment-name {
  font-weight: 700;
  color: #444;
  font-size: .88rem;
  text-decoration: none;
}
a.em-comment-name:hover { color: var(--em-blue); }
html[data-theme="dark"] .em-comment-name { color: #ddd; }
.em-comment-body {
  font-size: .95rem;
  line-height: 1.7;
  color: #444;
  white-space: pre-wrap;
}
html[data-theme="dark"] .em-comment-body { color: #ccc; }
.em-comment-empty {
  padding: 24px 0;
  text-align: center;
  color: var(--em-muted);
  font-size: .9rem;
}

.em-locked {
  text-align: center;
  padding: 48px 16px 40px;
  color: var(--em-muted);
  background: var(--em-soft);
  border-radius: 16px;
}
.em-locked > i {
  display: block;
  font-size: 1.8rem;
  margin-bottom: 10px;
  color: var(--em-blue);
  opacity: .7;
}
.em-locked-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--em-text);
  margin-bottom: 6px;
}
.em-locked-hint {
  margin: 0 0 10px;
  font-size: .9rem;
  line-height: 1.6;
}
.em-locked-err {
  margin: 0 0 12px;
  color: #e11d48;
  font-size: .88rem;
}
.em-unlock-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 280px;
  margin: 16px auto 0;
}
.em-unlock-input {
  width: 100%;
  height: 42px;
  box-sizing: border-box;
  padding: 0 14px;
  border: 1px solid #e0e0e0;
  border-radius: 999px;
  background: #fff;
  font: inherit;
  font-size: 16px; /* ≥16px 避免 iOS 聚焦放大 */
  outline: 0;
  -webkit-appearance: none;
  appearance: none;
}
html[data-theme="dark"] .em-unlock-input {
  background: #121212;
  border-color: #333;
  color: #eee;
}
.em-unlock-input:focus {
  border-color: #b7d9ff;
  box-shadow: 0 0 0 3px rgba(59,158,255,.15);
}
.em-unlock-btn {
  width: 100%;
  height: 42px;
  border: 0;
  border-radius: 999px;
  background: var(--em-blue);
  color: #fff;
  font-weight: 700;
  font-size: .95rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.em-unlock-btn:active { transform: scale(.98); }

.em-totop {
  position: fixed;
  right: 16px;
  bottom: 24px;
  z-index: 40;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,.92);
  color: #555;
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity .2s, transform .2s;
}
.em-totop.show {
  opacity: 1;
  pointer-events: auto;
  transform: none;
}
html[data-theme="dark"] .em-totop {
  background: rgba(30,30,30,.92);
  color: #ddd;
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
}

.em-tip-mask {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0,0,0,.4);
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.em-tip-mask.show { display: flex; }
.em-tip-box {
  width: 280px;
  background: #fff;
  border-radius: 16px;
  padding: 22px 18px;
  text-align: center;
}
html[data-theme="dark"] .em-tip-box { background: #1a1a1a; }
.em-tip-box h3 { margin: 0 0 8px; font-size: 1.05rem; }
.em-tip-box p { margin: 0 0 14px; color: var(--em-muted); font-size: .88rem; line-height: 1.5; }
.em-tip-box img {
  width: 180px;
  height: 180px;
  object-fit: contain;
  margin: 0 auto 12px;
  display: block;
  border-radius: 8px;
  background: #fafafa;
}
.em-tip-close {
  border: 0;
  border-radius: 999px;
  height: 38px;
  padding: 0 20px;
  background: var(--em-soft);
  color: #666;
  cursor: pointer;
  font-weight: 650;
}

@media (min-width: 768px) {
  .em-wrap { padding: 14px 24px 64px; }
  .em-title { font-size: 1.22rem; }
}
