/* ========== 全局变量 & 重置 ========== */
:root {
  --bg: #F2F2F7;
  --card-bg: #FFFFFF;
  --text-primary: #1C1C1E;
  --text-secondary: #8E8E93;
  --text-tertiary: #AEAEB2;
  --accent: #007AFF;
  --accent-light: rgba(0, 122, 255, 0.08);
  --separator: rgba(60, 60, 67, 0.1);
  --navbar-bg: rgba(249, 249, 249, 0.94);
  --shadow-card: 0 2px 16px rgba(0, 0, 0, 0.06);
  --radius-card: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --navbar-h: 44px;
  --statusbar-h: 0px;
  --bottom-bar-h: 56px;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Roboto', 'Noto Sans SC', 'Inter', 'Helvetica Neue', sans-serif;
}

@supports (padding-top: env(safe-area-inset-top)) {
  :root {
    --statusbar-h: env(safe-area-inset-top);
  }
}

/* Dark Mode（通过 body.dark-mode 类切换） */
body.dark-mode {
  --bg: #000000;
  --card-bg: #1C1C1E;
  --text-primary: #F5F5F7;
  --text-secondary: #98989D;
  --text-tertiary: #636366;
  --separator: rgba(255, 255, 255, 0.08);
  --navbar-bg: rgba(28, 28, 30, 0.94);
  --accent-light: rgba(0, 122, 255, 0.15);
}

body.dark-mode .block-card {
  background: #2C2C2E !important;
  box-shadow: 4px 4px 12px #111, -4px -4px 12px #3a3a3c !important;
}

body.dark-mode .block-code {
  background: #2C2C2E !important;
}

body.dark-mode .skeleton-line,
body.dark-mode .skeleton-block {
  background: linear-gradient(90deg, #2C2C2E 25%, #3A3A3C 50%, #2C2C2E 75%) !important;
  background-size: 200% 100%;
}

body.dark-mode .block-image-wrap {
  background: #2C2C2E !important;
}

body.dark-mode .block-note {
  background: rgba(0, 122, 255, 0.12);
  border-left-color: #0A84FF;
}

body.dark-mode .block-quote {
  background: rgba(255, 255, 255, 0.04);
  border-left-color: #636366;
}

body.dark-mode .reading-progress {
  background: linear-gradient(90deg, #0A84FF 0%, #64D2FF 40%, #30D158 100%);
  box-shadow: 0 0 12px rgba(10, 132, 255, 0.5);
}

body.dark-mode .back-to-top {
  background: #2C2C2E;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}

body.dark-mode .share-sheet {
  background: #2C2C2E;
}

body.dark-mode .toc-sidebar {
  background: #1C1C1E;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.4);
}

body.dark-mode .doc-list-search-wrap input {
  color: #F5F5F7;
}

body.dark-mode .block-collapse {
  background: #1C1C1E;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

body.dark-mode .collapse-header:active {
  background: rgba(255, 255, 255, 0.04);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
  transition: background-color .35s ease, color .35s ease;
}

/* 主题切换时全局过渡 */
body.theme-transitioning,
body.theme-transitioning *:not(.reading-progress):not(.theme-switch__container):not(.theme-switch__clouds):not(.theme-switch__circle-container):not(.theme-switch__sun-moon-container):not(.theme-switch__moon),
body.theme-transitioning *::before,
body.theme-transitioning *::after {
  transition: background-color .35s ease,
    background .35s ease,
    color .35s ease,
    border-color .35s ease,
    box-shadow .35s ease,
    fill .35s ease,
    stroke .35s ease !important;
}

/* ========== 阅读进度条 ========== */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2.5px;
  width: 0%;
  background: linear-gradient(90deg, #007AFF 0%, #5AC8FA 40%, #34C759 100%);
  z-index: 1100;
  transition: width 0.15s linear;
  border-radius: 0 2px 2px 0;
  box-shadow: 0 0 8px rgba(0, 122, 255, 0.35);
}

/* ========== iOS 状态栏 ========== */
.ios-status-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--statusbar-h);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 20px 4px;
  font-size: 12px;
  font-weight: 600;
  z-index: 1000;
  color: var(--text-primary);
  background: var(--navbar-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: background-color .35s ease, color .35s ease;
}

.status-icons {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* ========== 导航栏 ========== */
.ios-navbar {
  position: fixed;
  top: var(--statusbar-h);
  left: 0;
  right: 0;
  height: var(--navbar-h);
  background: var(--navbar-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--separator);
  z-index: 999;
  transition: background .35s ease, border-color .35s ease, transform .3s, box-shadow .35s ease;
}

.ios-navbar.navbar-hidden {
  transform: translateY(-100%);
}

.navbar-content {
  max-width: 800px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}

.nav-back-btn {
  background: none;
  border: none;
  color: var(--accent);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  padding: 4px;
  min-width: 44px;
  min-height: 44px;
  -webkit-touch-callout: none;
}

.nav-back-btn span {
  font-size: 9px;
  font-weight: 500;
  line-height: 1;
}

.nav-back-btn:active {
  opacity: 0.5;
}

.nav-back-btn svg {
  stroke: var(--accent);
}

.navbar-title {
  font-size: 17px;
  font-weight: 600;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0;
  transition: opacity .3s;
}

.navbar-title.visible {
  opacity: 1;
}

.navbar-actions {
  display: flex;
  gap: 8px;
}

.nav-action-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 4px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 10px;
  transition: background .2s, opacity .2s;
  -webkit-touch-callout: none;
}

.nav-action-btn span {
  font-size: 9px;
  font-weight: 500;
  line-height: 1;
}

.nav-action-btn:active {
  opacity: .5;
  background: var(--accent-light);
}

/* ========== 主内容 ========== */
.doc-container {
  max-width: 800px;
  margin: 0 auto;
  padding-top: calc(var(--statusbar-h) + var(--navbar-h) + 16px);
  padding-bottom: calc(var(--bottom-bar-h) + var(--safe-bottom) + 24px);
  padding-left: 20px;
  padding-right: 20px;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ========== 文档头部 ========== */
.doc-header {
  margin-bottom: 28px;
}

.doc-title {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.5px;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.doc-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 12px;
}

.doc-date {
  font-size: 13px;
  color: var(--text-tertiary);
}

/* ========== 文档块样式 ========== */
.doc-block {
  margin-bottom: 20px;
  animation: fadeInUp .4s ease both;
}

.doc-block:nth-child(2) {
  animation-delay: .05s;
}

.doc-block:nth-child(3) {
  animation-delay: .1s;
}

.doc-block:nth-child(4) {
  animation-delay: .15s;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

/* 段落 */
.block-paragraph {
  font-size: 16px;
  line-height: 1.75;
  color: var(--text-primary);
  word-break: break-word;
}

/* 强制显示加粗（覆盖任何全局默认重置），且不改变字体颜色 */
strong, b {
  font-weight: bold !important;
  color: inherit !important;
}

/* 标题 */
.block-heading-1 {
  font-size: 24px;
  font-weight: 700;
  margin: 32px 0 12px;
  color: var(--text-primary);
}

.block-heading-2 {
  font-size: 20px;
  font-weight: 600;
  margin: 28px 0 10px;
  color: var(--text-primary);
}

.block-heading-3 {
  font-size: 17px;
  font-weight: 600;
  margin: 24px 0 8px;
  color: var(--text-primary);
}

/* 注释小字 */
.block-note {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  padding: 12px 16px;
  background: var(--accent-light);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
}

/* 分割线 */
.block-divider {
  height: 1px;
  background: var(--separator);
  margin: 24px 0;
  border: none;
}

/* 引用块 */
.block-quote {
  padding: 14px 18px;
  background: rgba(142, 142, 147, 0.06);
  border-left: 3px solid var(--text-tertiary);
  border-radius: 0 10px 10px 0;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-secondary);
  font-style: italic;
}

/* 内容卡片（neumorphism风格） */
.block-card {
  border-radius: 20px;
  background: #e8e8ed;
  box-shadow: 8px 8px 20px #c8c8cc, -8px -8px 20px #ffffff;
  padding: 20px;
  transition: transform .25s ease, box-shadow .25s ease;
}

.block-card:active {
  transform: scale(0.98);
}

/* 高质量行内文字链接 (仅段落内生效) */
.inline-textlink {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--accent);
  text-decoration: none;
  font-weight: bold !important;
  padding: 2px 6px;
  margin: 0 2px;
  background: rgba(0, 122, 255, 0.08);
  border-radius: 6px;
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
  vertical-align: baseline;
  word-break: break-all;
}
.inline-textlink:hover {
  background: rgba(0, 122, 255, 0.16);
  transform: translateY(-1px);
}
.inline-textlink:active {
  transform: translateY(0) scale(0.96);
  background: rgba(0, 122, 255, 0.22);
}
.inline-textlink-text {
  display: inline;
}
.inline-textlink-icon {
  opacity: 0.8;
  flex-shrink: 0;
  margin-bottom: 1px;
}

/* 独立组件的外部链接（旧版及大链接块） */
.block-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.06);
  border: 0.5px solid var(--separator);
  text-decoration: none;
  color: inherit;
  transition: transform .2s, box-shadow .2s;
  -webkit-touch-callout: none;
}

.block-link:active {
  transform: scale(0.98);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.block-link-icon {
  flex-shrink: 0;
  color: var(--accent);
}

.block-link-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.block-link-text {
  font-size: 15px;
  font-weight: 500;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.block-link-url {
  font-size: 12px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.block-link-arrow {
  flex-shrink: 0;
  color: var(--text-tertiary);
}

/* 文字链接跳转 */
.block-textlink {
  display: inline;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.75;
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
  transition: opacity .2s;
  word-break: break-word;
}

.block-textlink:hover,
.block-textlink:active {
  opacity: 0.7;
}

/* 图片 */
.block-image-wrap {
  border-radius: 12px;
  overflow: hidden;
  background: #E5E5EA;
  cursor: pointer;
  transition: transform .25s ease, box-shadow .25s ease;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.block-image-wrap:active {
  transform: scale(0.97);
}

.block-image-wrap img {
  width: 100%;
  display: block;
  object-fit: cover;
}

.block-image-caption {
  font-size: 12px;
  color: var(--text-tertiary);
  text-align: center;
  padding: 6px 0 0;
}

/* 图片两列网格 */
.image-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.image-grid-item {
  display: flex;
  flex-direction: column;
}

.image-grid .block-image-wrap {
  border-radius: 10px;
  aspect-ratio: 4 / 3;
}

.image-grid .block-image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-grid .block-image-caption {
  font-size: 11px;
  padding: 4px 2px 0;
}

/* 折叠块 */
.block-collapse {
  background: var(--card-bg);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.collapse-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  cursor: pointer;
  user-select: none;
  transition: background .2s;
  min-height: 52px;
}

.collapse-header:active {
  background: rgba(0, 0, 0, 0.03);
}

.collapse-arrow {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  transition: transform .3s cubic-bezier(.4, 0, .2, 1);
  color: var(--text-tertiary);
}

.collapse-header.open .collapse-arrow {
  transform: rotate(90deg);
}

.collapse-title {
  font-size: 16px;
  font-weight: 600;
  flex: 1;
}

.collapse-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .3s ease-out;
}

.collapse-body.open {
  grid-template-rows: 1fr;
}

.collapse-body-inner {
  min-height: 0;
  overflow: hidden;
  padding: 0 18px;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-secondary);
}

.collapse-body-inner::after {
  content: "";
  display: block;
  height: 18px;
}

/* 列表 */
.block-list {
  padding-left: 24px;
  margin: 8px 0;
}

.block-list li {
  font-size: 15px;
  line-height: 1.8;
  color: var(--text-primary);
}

.block-list.ordered {
  list-style: decimal;
}

.block-list.unordered {
  list-style: disc;
}

/* 代码块 */
.block-code {
  background: #1C1C1E;
  border-radius: 12px;
  padding: 16px 18px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  font-family: 'SF Mono', 'Menlo', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.6;
  color: #F5F5F7;
}

/* ========== 加载骨架屏 ========== */
.loading-skeleton {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.skeleton-line {
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(90deg, #E5E5EA 25%, #F2F2F7 50%, #E5E5EA 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

.skeleton-title {
  height: 24px;
  width: 60%;
}

.skeleton-long {
  width: 100%;
}

.skeleton-medium {
  width: 75%;
}

.skeleton-short {
  width: 40%;
}

.skeleton-block {
  height: 120px;
  border-radius: 12px;
  background: linear-gradient(90deg, #E5E5EA 25%, #F2F2F7 50%, #E5E5EA 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

/* ========== 底部文档操作按钮 ========== */
.doc-actions-bottom {
  display: flex;
  justify-content: center;
  gap: 50px;
  margin: 40px 0 30px;
}

.action-circle-btn {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--text-secondary);
  cursor: pointer;
  -webkit-touch-callout: none;
  transition: color .2s;
}

.action-circle-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--card-bg);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .25s cubic-bezier(.4, 0, .2, 1);
  border: 1px solid var(--separator);
}

.action-circle-icon svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  fill: none;
  transition: all .2s;
}

.action-circle-btn span {
  font-size: 13px;
  font-weight: 500;
}

.action-circle-btn:active .action-circle-icon {
  transform: scale(0.92);
  background: var(--accent-light);
}

.action-circle-btn.active {
  color: var(--accent);
}

.action-circle-btn.active .action-circle-icon {
  border-color: var(--accent);
  background: var(--accent-light);
}

.action-circle-btn.active svg {
  fill: var(--accent);
  fill-opacity: 0.15;
}

/* ========== 点赞计数标签 ========== */
.like-count-label {
  display: flex;
  justify-content: center;
  margin: -10px 0 20px;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity .4s ease, transform .4s ease;
  pointer-events: none;
}

.like-count-label.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.like-count-label span {
  display: inline-block;
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 20px;
  border: 0.5px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  letter-spacing: 0.3px;
}

body.dark-mode .like-count-label span {
  background: rgba(44, 44, 46, 0.65);
  border-color: rgba(255, 255, 255, 0.06);
}

/* ========== 爱心弹幕特效 ========== */
.heart-burst-particle {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  font-size: 20px;
  opacity: 0;
  animation: heartBurst 1s ease-out forwards;
  will-change: transform, opacity;
}

@keyframes heartBurst {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(0.5) rotate(var(--rot));
  }
  30% {
    opacity: 1;
    transform: translate(var(--tx30), var(--ty30)) scale(1) rotate(var(--rot));
  }
  100% {
    opacity: 0;
    transform: translate(var(--tx), var(--ty)) scale(0.6) rotate(var(--rot));
  }
}

/* ========== 左侧文档列表侧边栏 ========== */
.doc-list-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 1200;
  opacity: 0;
  pointer-events: none;
  transition: opacity .35s cubic-bezier(.4, 0, .2, 1);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.doc-list-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.doc-list-sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: 250px;
  max-width: 70vw;
  background: var(--card-bg);
  border-radius: 0 20px 20px 0;
  z-index: 1201;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform .4s cubic-bezier(.32, .72, 0, 1);
  will-change: transform;
  box-shadow: 4px 0 32px rgba(0, 0, 0, 0.12);
}

.doc-list-sidebar.open {
  transform: translateX(0);
}

.doc-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(var(--safe-top) + 16px) 20px 12px;
  border-bottom: 0.5px solid var(--separator);
  flex-shrink: 0;
}

.doc-list-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.doc-list-close {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 8px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background .2s;
}

.doc-list-close:active {
  background: var(--accent-light);
}

.doc-list-search {
  padding: 12px 20px 8px;
  flex-shrink: 0;
}

.doc-list-search-wrap {
  display: flex;
  align-items: center;
  background: var(--bg);
  border-radius: 10px;
  padding: 0 12px;
  height: 36px;
  transition: box-shadow .25s;
}

.doc-list-search-wrap:focus-within {
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.2);
}

.doc-list-search-icon {
  flex-shrink: 0;
  color: var(--text-tertiary);
  margin-right: 8px;
}

.doc-list-search-wrap input {
  flex: 1;
  border: none;
  background: none;
  outline: none;
  font-size: 15px;
  color: var(--text-primary);
  font-family: inherit;
  height: 100%;
}

.doc-list-search-wrap input::placeholder {
  color: var(--text-tertiary);
}

.doc-list-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding: 8px 0;
}

.doc-list-item {
  display: flex;
  flex-direction: column;
  padding: 14px 20px;
  cursor: pointer;
  transition: background .18s ease, transform .18s ease;
  border-bottom: 0.5px solid var(--separator);
  position: relative;
  -webkit-touch-callout: none;
  user-select: none;
}

.doc-list-item:active {
  background: var(--accent-light);
  transform: scale(0.98);
}

.doc-list-item.active {
  background: var(--accent-light);
}

.doc-list-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}

.doc-list-item-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: color .2s;
}

.doc-list-item.active .doc-list-item-title {
  color: var(--accent);
}

.doc-list-item-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.doc-list-item-time {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.doc-list-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-tertiary);
  font-size: 14px;
  text-align: center;
  gap: 8px;
}

.doc-list-empty svg {
  opacity: 0.4;
}

.doc-list-loading {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.doc-list-skeleton {
  height: 60px;
  border-radius: 12px;
  background: linear-gradient(90deg, var(--bg) 25%, var(--separator) 50%, var(--bg) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

.doc-list-skeleton.short {
  width: 70%;
}

/* Dark Mode */
body.dark-mode .doc-list-sidebar {
  background: #1C1C1E;
}

body.dark-mode .doc-list-search-wrap {
  background: #2C2C2E;
}

/* Android */
body.is-android .doc-list-sidebar {
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
  border-radius: 0;
}

body.is-android .doc-list-close {
  border-radius: 12px;
}

body.is-android .doc-list-search-wrap {
  border-radius: 8px;
}

body.is-android .doc-list-item:active {
  background: rgba(0, 0, 0, 0.04);
}

/* Desktop */
@media (min-width: 768px) {
  .doc-list-sidebar {
    width: 320px;
    border-radius: 0 20px 20px 0;
  }
}

/* ========== 目录侧边栏 ========== */
.toc-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 1100;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s;
}

.toc-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.toc-sidebar {
  position: fixed;
  top: 0;
  right: -100%;
  bottom: 0;
  width: 240px;
  max-width: 65vw;
  background: var(--card-bg);
  border-radius: 20px 0 0 20px;
  z-index: 1101;
  transition: right .35s cubic-bezier(.4, 0, .2, 1);
  display: flex;
  flex-direction: column;
  padding-top: calc(var(--safe-top) + 12px);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.1);
}

.toc-sidebar.open {
  right: 0;
}

.toc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 0.5px solid var(--separator);
}

.toc-header h3 {
  font-size: 18px;
  font-weight: 700;
}

.toc-close-btn {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 8px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toc-list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
  -webkit-overflow-scrolling: touch;
}

.toc-item {
  padding: 12px 16px;
  font-size: 15px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background .2s;
  border-left: 3px solid transparent;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.toc-item:active {
  background: var(--accent-light);
}

.toc-item.active {
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}

.toc-item.level-2 {
  padding-left: 28px;
  font-size: 14px;
}

.toc-item.level-3 {
  padding-left: 40px;
  font-size: 13px;
  color: var(--text-secondary);
}


/* ========== 分享菜单 ========== */
.share-sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 2100;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s;
}

.share-sheet-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.share-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card-bg);
  border-radius: 16px 16px 0 0;
  z-index: 2101;
  padding: 12px 20px calc(var(--safe-bottom) + 20px);
  transform: translateY(100%);
  transition: transform .35s cubic-bezier(.4, 0, .2, 1);
}

.share-sheet.open {
  transform: translateY(0);
}

.share-sheet-handle {
  width: 36px;
  height: 5px;
  border-radius: 3px;
  background: var(--text-tertiary);
  margin: 0 auto 16px;
}

.share-sheet-title {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 20px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.share-sheet-grid {
  display: flex;
  justify-content: center;
  gap: 60px;
  padding-bottom: 16px;
  border-bottom: 0.5px solid var(--separator);
}

.share-sheet-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  -webkit-touch-callout: none;
}

.share-sheet-item:active {
  opacity: 0.5;
}

.share-sheet-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.share-sheet-icon.copy {
  background: linear-gradient(135deg, #007AFF, #5856D6);
}

.share-sheet-icon.wechat {
  background: #07C160;
}

.share-sheet-icon.safari {
  background: linear-gradient(135deg, #5AC8FA, #007AFF);
}

.share-sheet-icon.more {
  background: var(--text-tertiary);
}

.share-sheet-label {
  font-size: 11px;
  color: var(--text-secondary);
}

.share-sheet-cancel {
  display: block;
  width: 100%;
  padding: 14px;
  margin-top: 12px;
  background: none;
  border: none;
  font-size: 17px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  border-radius: 12px;
  transition: background .2s;
}

.share-sheet-cancel:active {
  background: var(--accent-light);
}

/* ========== 回到顶部按钮 ========== */
.back-to-top {
  position: fixed;
  bottom: calc(var(--bottom-bar-h) + var(--safe-bottom) + 16px);
  right: 16px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--card-bg);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
  border: 0.5px solid var(--separator);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8);
  transition: opacity .3s, transform .3s;
  z-index: 997;
  color: var(--accent);
}

.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

.back-to-top:active {
  transform: scale(0.9);
}

/* ========== 桌面端优化 (≥768px) ========== */
@media (min-width: 768px) {
  .ios-status-bar {
    display: none;
  }

  :root {
    --statusbar-h: 0px;
  }

  .doc-container {
    padding-top: calc(var(--navbar-h) + 32px);
    padding-left: 40px;
    padding-right: 40px;
  }

  .doc-title {
    font-size: 36px;
  }

  .block-heading-1 {
    font-size: 28px;
  }

  .block-heading-2 {
    font-size: 22px;
  }

  .ios-bottom-bar {
    display: none;
  }

  .back-to-top {
    bottom: 32px;
    right: 32px;
  }

  .doc-container {
    padding-bottom: 60px;
  }

  .toc-sidebar {
    width: 340px;
    border-radius: 16px 0 0 16px;
  }

  .share-sheet {
    max-width: 420px;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
    border-radius: 16px 16px 0 0;
  }

  .share-sheet.open {
    transform: translateX(-50%) translateY(0);
  }
}

/* ========== 大屏桌面端 - 永久侧边栏 (≥1024px) ========== */
@media (min-width: 1024px) {

  /* 侧边栏永久显示 */
  .doc-list-sidebar {
    transform: translateX(0) !important;
    width: 300px;
    border-radius: 0;
    box-shadow: 1px 0 0 var(--separator);
    z-index: 100;
  }

  .doc-list-sidebar .doc-list-header {
    padding-top: calc(var(--navbar-h) + 16px);
  }

  .doc-list-overlay {
    display: none !important;
  }

  .doc-list-close {
    display: none;
  }

  /* 导航栏左侧菜单按钮 - 桌面端隐藏 */
  #navMenuBtn {
    display: none;
  }

  /* 导航栏偏移 */
  .ios-navbar {
    left: 300px;
  }

  /* 主内容区域偏移 */
  .doc-container {
    margin-left: 300px;
    max-width: 900px;
    padding-left: 48px;
    padding-right: 48px;
  }

  /* 回到顶部按钮 */
  .back-to-top {
    right: calc(50% - 450px - 60px);
  }

  /* 目录侧边栏 */
  .toc-sidebar {
    width: 320px;
  }
}

/* ========== 超大屏桌面 (≥1400px) ========== */
@media (min-width: 1400px) {
  .doc-list-sidebar {
    width: 340px;
  }

  .ios-navbar {
    left: 340px;
  }

  .doc-container {
    margin-left: 340px;
    max-width: 960px;
    padding-left: 56px;
    padding-right: 56px;
  }

  .doc-title {
    font-size: 40px;
    letter-spacing: -0.8px;
  }

  .block-heading-1 {
    font-size: 30px;
  }

  .block-heading-2 {
    font-size: 24px;
  }

  .block-paragraph {
    font-size: 17px;
    line-height: 1.8;
  }

  .block-code {
    font-size: 14px;
  }

  .block-note {
    font-size: 14px;
    padding: 14px 20px;
  }

  .block-quote {
    font-size: 16px;
    padding: 16px 22px;
  }

  .block-card {
    padding: 24px;
    border-radius: 20px;
  }
}

/* ========== 移动端精细调优 ========== */
@media (max-width: 767px) {

  /* 更紧凑的移动布局 */
  .doc-container {
    padding-left: 18px;
    padding-right: 18px;
  }

  .doc-title {
    font-size: 26px;
    letter-spacing: -0.3px;
  }

  .doc-subtitle {
    font-size: 14px;
  }

  /* 增强触控体验 */
  .block-collapse {
    border-radius: 14px;
  }

  .collapse-header {
    padding: 14px 16px;
  }

  .block-note {
    padding: 10px 14px;
    font-size: 13px;
  }

  .block-quote {
    padding: 12px 16px;
    font-size: 14px;
  }

  .block-code {
    padding: 14px 16px;
    font-size: 12px;
    border-radius: 10px;
  }

  .block-card {
    padding: 16px;
    border-radius: 16px;
  }

  /* 图片在移动端圆角稍小 */
  .block-image-wrap {
    border-radius: 12px;
  }

  /* 底部工具栏增大触控区域 */
  .bottom-action {
    padding: 8px 16px;
    min-width: 56px;
  }

  /* 阅读进度条移动端更明显 */
  .reading-progress {
    height: 3px;
  }
}

/* ========== 极小屏幕（SE/5s等） ========== */
@media (max-width: 375px) {
  .doc-title {
    font-size: 22px;
  }

  .doc-container {
    padding-left: 16px;
    padding-right: 16px;
  }

  .block-heading-1 {
    font-size: 20px;
  }

  .block-heading-2 {
    font-size: 18px;
  }

  .block-heading-3 {
    font-size: 16px;
  }

  .block-paragraph {
    font-size: 15px;
  }

  .share-sheet-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .bottom-action span {
    font-size: 9px;
  }
}

/* ========== 横屏模式 ========== */
@media (max-height: 500px) and (orientation: landscape) {
  .ios-status-bar {
    display: none;
  }

  :root {
    --statusbar-h: 0px;
    --navbar-h: 40px;
    --bottom-bar-h: 48px;
  }

  .doc-container {
    padding-left: calc(var(--safe-left) + 20px);
    padding-right: calc(var(--safe-right) + 20px);
  }

  .ios-bottom-bar {
    height: calc(var(--bottom-bar-h) + var(--safe-bottom));
  }

  .bottom-action span {
    display: none;
  }

  .bottom-action svg {
    width: 20px;
    height: 20px;
  }
}

/* ========== 触控优化 ========== */
@media (hover: none) and (pointer: coarse) {

  /* 移动设备上的触控反馈 */
  .doc-list-item:active,
  .block-collapse:active,
  .block-card:active {
    transition-duration: 0.05s;
  }
}

/* ========== 减少动画偏好 ========== */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }

  .doc-block {
    animation: none !important;
  }

  .reading-progress {
    transition: none !important;
  }
}

/* ========================================================
   Android 平台适配
   body.is-android 由 JS 运行时添加
   ======================================================== */

/* Android: 隐藏 iOS 模拟状态栏 */
body.is-android .ios-status-bar {
  display: none !important;
}

body.is-android {
  --statusbar-h: 0px;
}

/* Android: 导航栏 —— Material 风格，阴影替代底线 */
body.is-android .ios-navbar {
  background: var(--card-bg);
  backdrop-filter: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  border-bottom: none;
  transition: background-color .35s ease, box-shadow .35s ease, transform .3s;
}

body.is-android .nav-back-btn {
  color: var(--text-primary);
}

body.is-android .nav-back-btn svg {
  stroke: var(--text-primary);
}

/* Android: 底部工具栏 —— Material 阴影+不透明 */
body.is-android .ios-bottom-bar {
  background: var(--card-bg);
  backdrop-filter: none;
  box-shadow: 0 -1px 4px rgba(0, 0, 0, 0.08);
  border-top: none;
}

/* Android: 内容卡片 —— Material 阴影替代 Neumorphism */
body.is-android .block-card {
  background: var(--card-bg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  border: 1px solid var(--separator);
  border-radius: 16px;
}

/* Android: 折叠块圆角稍小 */
body.is-android .block-collapse {
  border-radius: 12px;
}

/* Android: 图片圆角稍小 */
body.is-android .block-image-wrap {
  border-radius: 12px;
}

/* Android: 目录侧边栏 —— Material 不透明 + 阴影 */
body.is-android .toc-sidebar {
  box-shadow: -2px 0 16px rgba(0, 0, 0, 0.15);
  border-radius: 0;
  padding-top: 12px;
}

/* Android: 分享面板 —— Material 底部表风格 */
body.is-android .share-sheet {
  border-radius: 20px 20px 0 0;
}

body.is-android .share-sheet-icon {
  border-radius: 50%;
}

/* Android: 回到顶部按钮 —— 圆形FAB */
body.is-android .back-to-top {
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
  border: none;
}

/* Android: 底部按钮点击增加水波纹区域 */
body.is-android .bottom-action {
  border-radius: 12px;
  position: relative;
  overflow: hidden;
}

/* Android: 代码块圆角 */
body.is-android .block-code {
  border-radius: 8px;
}

/* Android Dark Mode 微调 */
body.dark-mode.is-android .ios-navbar {
  background: #1C1C1E;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

body.dark-mode.is-android .ios-bottom-bar {
  background: #1C1C1E;
  box-shadow: 0 -1px 4px rgba(0, 0, 0, 0.3);
}

body.dark-mode.is-android .block-card {
  background: #2C2C2E;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  border-color: rgba(255, 255, 255, 0.06);
}

/* ========================================================
   Desktop 平台
   body.is-desktop 由 JS 运行时添加
   ======================================================== */
body.is-desktop .ios-status-bar {
  display: none !important;
}

body.is-desktop {
  --statusbar-h: 0px;
}

body.is-desktop .ios-bottom-bar {
  display: none;
}

body.is-desktop .doc-container {
  padding-bottom: 60px;
}

/* 桌面端侧边栏暗色模式 */
@media (min-width: 1024px) {
  body.dark-mode .doc-list-sidebar {
    box-shadow: 1px 0 0 rgba(255, 255, 255, 0.06);
    background: #1C1C1E;
  }

  body.dark-mode .doc-list-item:hover {
    background: rgba(255, 255, 255, 0.04);
  }
}

/* 桌面端悬停效果（仅限非触摸设备） */
@media (hover: hover) and (pointer: fine) {
  .doc-list-item:hover {
    background: var(--accent-light);
  }

  .doc-list-item:hover .doc-list-item-title {
    color: var(--accent);
  }

  .nav-action-btn:hover {
    background: var(--accent-light);
  }

  .toc-item:hover {
    background: var(--accent-light);
  }
}

/* ========== 主题切换开关 ========== */
.theme-switch {
  --toggle-size: 10px;
  --container-width: 5.625em;
  --container-height: 2.5em;
  --container-radius: 6.25em;
  --container-light-bg: #3D7EAE;
  --container-night-bg: #1D1F2C;
  --circle-container-diameter: 3.375em;
  --sun-moon-diameter: 2.125em;
  --sun-bg: #ECCA2F;
  --moon-bg: #C4C9D1;
  --spot-color: #959DB1;
  --circle-container-offset: calc((var(--circle-container-diameter) - var(--container-height)) / 2 * -1);
  --stars-color: #fff;
  --clouds-color: #F3FDFF;
  --back-clouds-color: #AACADF;
  --transition: .5s cubic-bezier(0, -0.02, 0.4, 1.25);
  --circle-transition: .3s cubic-bezier(0, -0.02, 0.35, 1.17);
  display: flex;
  align-items: center;
}

.theme-switch,
.theme-switch *,
.theme-switch *::before,
.theme-switch *::after {
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-size: var(--toggle-size);
}

.theme-switch__container {
  width: var(--container-width);
  height: var(--container-height);
  background-color: var(--container-light-bg);
  border-radius: var(--container-radius);
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0em -0.062em 0.062em rgba(0, 0, 0, 0.25), 0em 0.062em 0.125em rgba(255, 255, 255, 0.94);
  transition: var(--transition);
  position: relative;
}

.theme-switch__container::before {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 0;
  box-shadow: 0em 0.05em 0.187em rgba(0, 0, 0, 0.25) inset, 0em 0.05em 0.187em rgba(0, 0, 0, 0.25) inset;
  border-radius: var(--container-radius);
}

.theme-switch__checkbox {
  display: none;
}

.theme-switch__circle-container {
  width: var(--circle-container-diameter);
  height: var(--circle-container-diameter);
  background-color: rgba(255, 255, 255, 0.1);
  position: absolute;
  left: var(--circle-container-offset);
  top: var(--circle-container-offset);
  border-radius: var(--container-radius);
  box-shadow: inset 0 0 0 3.375em rgba(255, 255, 255, 0.1), inset 0 0 0 3.375em rgba(255, 255, 255, 0.1), 0 0 0 0.625em rgba(255, 255, 255, 0.1), 0 0 0 1.25em rgba(255, 255, 255, 0.1);
  display: flex;
  transition: var(--circle-transition);
  pointer-events: none;
}

.theme-switch__sun-moon-container {
  pointer-events: auto;
  position: relative;
  z-index: 2;
  width: var(--sun-moon-diameter);
  height: var(--sun-moon-diameter);
  margin: auto;
  border-radius: var(--container-radius);
  background-color: var(--sun-bg);
  box-shadow: 0.062em 0.062em 0.062em 0em rgba(254, 255, 239, 0.61) inset, 0em -0.062em 0.062em 0em #a1872a inset;
  filter: drop-shadow(0.062em 0.125em 0.125em rgba(0, 0, 0, 0.25)) drop-shadow(0em 0.062em 0.125em rgba(0, 0, 0, 0.25));
  overflow: hidden;
  transition: var(--transition);
}

.theme-switch__moon {
  transform: translateX(100%);
  width: 100%;
  height: 100%;
  background-color: var(--moon-bg);
  border-radius: inherit;
  box-shadow: 0.062em 0.062em 0.062em 0em rgba(254, 255, 239, 0.61) inset, 0em -0.062em 0.062em 0em #969696 inset;
  transition: var(--transition);
  position: relative;
}

.theme-switch__spot {
  position: absolute;
  top: 0.75em;
  left: 0.312em;
  width: 0.75em;
  height: 0.75em;
  border-radius: var(--container-radius);
  background-color: var(--spot-color);
  box-shadow: 0em 0.0312em 0.062em rgba(0, 0, 0, 0.25) inset;
}

.theme-switch__spot:nth-of-type(2) {
  width: 0.375em;
  height: 0.375em;
  top: 0.937em;
  left: 1.375em;
}

.theme-switch__spot:nth-last-of-type(3) {
  width: 0.25em;
  height: 0.25em;
  top: 0.312em;
  left: 0.812em;
}

.theme-switch__clouds {
  width: 1.25em;
  height: 1.25em;
  background-color: var(--clouds-color);
  border-radius: var(--container-radius);
  position: absolute;
  bottom: -0.625em;
  left: 0.312em;
  box-shadow: 0.937em 0.312em var(--clouds-color), -0.312em -0.312em var(--back-clouds-color), 1.437em 0.375em var(--clouds-color), 0.5em -0.125em var(--back-clouds-color), 2.187em 0 var(--clouds-color), 1.25em -0.062em var(--back-clouds-color), 2.937em 0.312em var(--clouds-color), 2em -0.312em var(--back-clouds-color), 3.625em -0.062em var(--clouds-color), 2.625em 0em var(--back-clouds-color), 4.5em -0.312em var(--clouds-color), 3.375em -0.437em var(--back-clouds-color), 4.625em -1.75em 0 0.437em var(--clouds-color), 4em -0.625em var(--back-clouds-color), 4.125em -2.125em 0 0.437em var(--back-clouds-color);
  transition: .5s cubic-bezier(0, -0.02, 0.4, 1.25);
}

.theme-switch__stars-container {
  position: absolute;
  color: var(--stars-color);
  top: -100%;
  left: 0.312em;
  width: 2.75em;
  height: auto;
  transition: var(--transition);
}

/* Checked = Dark */
.theme-switch__checkbox:checked+.theme-switch__container {
  background-color: var(--container-night-bg);
}

.theme-switch__checkbox:checked+.theme-switch__container .theme-switch__circle-container {
  left: calc(100% - var(--circle-container-offset) - var(--circle-container-diameter));
}

.theme-switch__checkbox:checked+.theme-switch__container .theme-switch__circle-container:hover {
  left: calc(100% - var(--circle-container-offset) - var(--circle-container-diameter) - 0.187em);
}

.theme-switch__circle-container:hover {
  left: calc(var(--circle-container-offset) + 0.187em);
}

.theme-switch__checkbox:checked+.theme-switch__container .theme-switch__moon {
  transform: translate(0);
}

.theme-switch__checkbox:checked+.theme-switch__container .theme-switch__clouds {
  bottom: -4.062em;
}

.theme-switch__checkbox:checked+.theme-switch__container .theme-switch__stars-container {
  top: 50%;
  transform: translateY(-50%);
}

/* 主题切换开关在导航栏中的位置 */
.navbar-theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* 侧边栏文档总数标签 */
.doc-list-count-label {
  text-align: center;
  padding: 24px 0 32px;
  font-size: 13px;
  color: var(--text-tertiary);
  opacity: 0;
  font-weight: 400;
  letter-spacing: 0.5px;
  animation: docCountFadeIn 0.5s ease 0.4s forwards;
}

@keyframes docCountFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 0.6; transform: translateY(0); }
}

/* ========== 图片预览 Overlay ========== */
.img-preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  transition: background 0.3s ease, backdrop-filter 0.3s ease, -webkit-backdrop-filter 0.3s ease;
  will-change: background, backdrop-filter;
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
}

.img-preview-overlay.open {
  background: rgba(30, 30, 30, 0.65);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
}

.img-preview-overlay.closing {
  background: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
}

.img-preview-main {
  max-width: 92vw;
  max-height: 88vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 4px;
  transform-origin: center center;
  transform: scale(0.85);
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              opacity 0.3s ease;
  will-change: transform, opacity;
  pointer-events: auto;
  -webkit-user-drag: none;
}

.img-preview-overlay.open .img-preview-main {
  transform: scale(1);
  opacity: 1;
}

.img-preview-overlay.closing .img-preview-main {
  transform: translateY(40px) scale(0.95) !important;
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.55, 0, 1, 0.45),
              opacity 0.25s ease !important;
}

/* 移动端适配 */
@media (max-width: 768px) {
  .img-preview-main {
    max-width: 100vw;
    max-height: 92vh;
    border-radius: 0;
  }
}

/* Dark mode 兼容 (overlay 自带暗色不受影响) */
body.dark-mode .img-preview-overlay {
  /* 已经是暗色背景，无需额外调整 */
}

/* ========== 浏览器打开引导 ========== */
.browser-guide-overlay {
  position: fixed;
  inset: 0;
  z-index: 20000;
  background: rgba(0, 0, 0, 0);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 16px 0;
  opacity: 0;
  transition: background 0.3s ease, opacity 0.3s ease;
  pointer-events: none;
}

.browser-guide-overlay.show {
  background: rgba(0, 0, 0, 0.65);
  opacity: 1;
  pointer-events: auto;
}

.browser-guide-overlay.hiding {
  background: rgba(0, 0, 0, 0);
  opacity: 0;
  pointer-events: none;
}

/* 箭头指向右上角 */
.browser-guide-arrow {
  margin-right: 16px;
  margin-bottom: 8px;
  animation: guideArrowBounce 1.2s ease-in-out infinite;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.3));
}

@keyframes guideArrowBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

/* 提示卡片 */
.browser-guide-card {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 16px;
  padding: 24px;
  max-width: 320px;
  width: 100%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
  transform: translateY(-8px);
  animation: guideCardIn 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes guideCardIn {
  from { transform: translateY(-16px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

.browser-guide-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #007AFF, #5856D6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.browser-guide-text {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.browser-guide-title {
  font-size: 17px;
  font-weight: 700;
  color: #1C1C1E;
  margin: 0;
}

.browser-guide-desc {
  font-size: 14px;
  color: #636366;
  line-height: 1.6;
  margin: 0;
}

.browser-guide-desc strong {
  font-size: 18px;
  color: #1C1C1E;
  vertical-align: -1px;
}

.browser-guide-close {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 12px;
  background: #007AFF;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.browser-guide-close:active {
  background: #0056CC;
  transform: scale(0.97);
}

/* 暗色模式 */
body.dark-mode .browser-guide-card {
  background: rgba(44, 44, 46, 0.95);
}

body.dark-mode .browser-guide-title {
  color: #F2F2F7;
}

body.dark-mode .browser-guide-desc {
  color: #98989D;
}

body.dark-mode .browser-guide-desc strong {
  color: #F2F2F7;
}

body.dark-mode .inline-textlink {
  background: rgba(10, 132, 255, 0.15);
}
body.dark-mode .inline-textlink:hover {
  background: rgba(10, 132, 255, 0.25);
}