:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-soft: #f7f8fa;
  --text: #1f2329;
  --muted: #646a73;
  --border: #e5e6eb;
  --accent: #2f6bff;
  --accent-soft: #eaf1ff;
  --warning: #b54708;
  --warning-soft: #fff4e5;
  --danger: #d83931;
  --danger-soft: #ffece8;
  --info: #1456f0;
  --info-soft: #e8f0ff;
  --shadow: 0 1px 2px rgba(31, 35, 41, 0.04), 0 8px 24px rgba(31, 35, 41, 0.05);
  --radius: 14px;
  --max: 1080px;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
}

:root[data-theme="dark"] {
  --bg: #0f1218;
  --surface: #171b22;
  --surface-soft: #1e2430;
  --text: #e8eaed;
  --muted: #9aa0a6;
  --border: #2c3340;
  --accent: #6b93ff;
  --accent-soft: #1b2a4d;
  --warning: #f5b56a;
  --warning-soft: #3a2a16;
  --danger: #ff8a80;
  --danger-soft: #3a1d1c;
  --info: #8ab4ff;
  --info-soft: #1a2c4d;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.28), 0 12px 28px rgba(0, 0, 0, 0.28);
  background: var(--bg);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(900px 420px at 50% -120px, color-mix(in srgb, var(--accent) 10%, transparent), transparent 70%),
    var(--bg);
}

.app-shell {
  min-height: 100vh;
}

.app-header {
  height: 56px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.header-inner,
.tabs-inner,
.office-tabs-inner,
.office-meta,
.markdown-layout {
  max-width: var(--max);
}

.header-inner {
  padding: 0 20px;
}

.brand {
  gap: 10px;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--accent);
  font-size: 0;
  font-weight: 700;
  place-items: center;
  display: grid;
}
.brand-mark::after {
  content: "阅";
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

.brand strong {
  font-size: 0 !important;
  letter-spacing: 0;
}
.brand strong::after {
  content: "文档预览";
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.brand small {
  font-size: 0 !important;
}
.brand small::after {
  content: "本地审阅 · 不上传";
  font-size: 11px;
  color: var(--muted);
}

.header-button,
.icon-button {
  border-radius: 9px;
  border-color: var(--border);
  background: var(--surface);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.header-button {
  height: 34px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 550;
}

.icon-button {
  width: 34px;
  height: 34px;
}

.header-button:hover,
.icon-button:hover {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  color: var(--accent);
}

.document-tabs {
  top: 56px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border-bottom: 1px solid var(--border);
}

.document-tab {
  min-width: 128px;
  border-left-color: transparent;
}

.document-tab.active {
  background: var(--accent-soft);
}

.document-tab.active:after {
  height: 2px;
  background: var(--accent);
}

.home-page {
  max-width: 720px;
  padding: clamp(36px, 7vh, 68px) 20px 72px;
}

.welcome {
  max-width: 520px;
  margin: 0 auto 18px;
  text-align: center;
}

.product-kicker {
  display: inline-flex;
  align-items: center;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 5px 11px;
  letter-spacing: 0;
  font-size: 0;
  font-weight: 600;
}
.product-kicker::after {
  content: "本地文档预览";
  font-size: 12px;
  font-weight: 600;
}

.welcome h1 {
  display: none !important;
}

.welcome > p {
  font-size: 0;
  line-height: 0;
}
.welcome > p::after {
  content: "文件只在当前浏览器内解析，不会上传到服务器。";
  display: block;
  max-width: 420px;
  margin: 0 auto;
  font-size: 14px;
  line-height: 1.7;
  color: var(--muted);
}

.drop-zone {
  width: 100%;
  background: var(--surface);
  border: 1px dashed color-mix(in srgb, var(--muted) 36%, var(--border));
  border-radius: var(--radius);
  padding: 40px 24px 34px;
  box-shadow: var(--shadow);
  transform: none;
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.drop-zone:hover,
.drop-zone.dragging {
  background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface));
  border-color: var(--accent);
  border-style: solid;
  transform: none;
  box-shadow: 0 1px 2px rgba(47, 107, 255, 0.08), 0 14px 32px rgba(47, 107, 255, 0.08);
}

.drop-icon {
  width: 52px;
  height: 52px;
  margin-bottom: 14px;
  border-radius: 14px;
  background: var(--accent-soft);
  border: 0;
  color: var(--accent);
}

.drop-zone > strong {
  font-size: 17px;
  font-weight: 650;
  margin-bottom: 6px;
}

.drop-zone > span:not(.drop-icon, .file-types) {
  font-size: 13px;
  color: var(--muted);
}

.file-types {
  display: none !important;
}

.feature-row {
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 14px 0 0;
  background: transparent;
  border: 0;
  overflow: visible;
}

.feature-row div {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 14px 13px;
  box-shadow: none;
  gap: 4px;
}

.feature-row strong,
.feature-row span {
  font-size: 0;
  line-height: 0;
}

.feature-row strong::after {
  display: block;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.4;
  color: var(--text);
}
.feature-row span::after {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--muted);
}

.feature-row > div:nth-child(1) strong::after {
  content: "本地解析";
}
.feature-row > div:nth-child(1) span::after {
  content: "文件不出这台设备";
}
.feature-row > div:nth-child(2) strong::after {
  content: "即开即看";
}
.feature-row > div:nth-child(2) span::after {
  content: "无需安装任何插件";
}
.feature-row > div:nth-child(3) strong::after {
  content: "多文件切换";
}
.feature-row > div:nth-child(3) span::after {
  content: "标签页快速浏览";
}

.recent-section {
  margin-top: 28px;
}

.section-heading strong {
  font-size: 14px;
}
.section-heading span {
  color: var(--muted);
  font-size: 12px;
}
.section-heading button {
  color: var(--accent);
  font-weight: 600;
}

.recent-file,
.office-zip-item,
.office-page,
.canvas-page,
.markdown-page,
.toc,
.toast {
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.recent-file {
  border: 1px solid var(--border);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.recent-file:hover,
.office-zip-item:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface));
}

.file-mark {
  border-radius: 10px;
}

.markdown-body {
  padding: clamp(28px, 5vw, 48px);
  line-height: 1.8;
}

.markdown-body h1 {
  letter-spacing: -0.03em;
}

.markdown-body h2 {
  margin-top: 40px;
}

/* 避免 pre > code 继承行内 code 样式，把 Mermaid 源码衬成一行一块灰底红字 */
.markdown-body pre {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  overflow-x: auto;
  line-height: 1.55;
}
.markdown-body pre code {
  color: inherit;
  background: transparent !important;
  border: 0 !important;
  padding: 0 !important;
  border-radius: 0;
  font-size: 0.9em;
  display: block;
  white-space: pre;
  line-height: inherit;
}

.md-mermaid {
  margin: 18px 0 28px;
  overflow-x: auto;
  padding: 12px 10px 8px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
}
:root[data-theme="dark"] .md-mermaid {
  background: var(--surface);
}
.md-mermaid svg {
  display: block;
  max-width: none;
  height: auto;
  margin: 0 auto;
}
.md-mermaid .label,
.md-mermaid foreignObject,
.md-mermaid foreignObject div,
.md-mermaid foreignObject span {
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
}
.md-mermaid-error {
  padding: 8px 4px 12px;
  color: var(--muted);
}
.md-mermaid-error strong {
  display: block;
  margin-bottom: 6px;
  color: var(--danger);
  font-size: 13px;
}
.md-mermaid-error span {
  display: block;
  margin-bottom: 10px;
  font-size: 12px;
}
.md-mermaid-error pre {
  margin: 0;
  white-space: pre-wrap;
  font-size: 12px;
}

.markdown-layout:has(.md-mermaid),
.markdown-page:has(.md-mermaid) {
  max-width: min(1400px, calc(100% - 24px));
}

.markdown-body .md-table-wrap {
  overflow-x: auto;
  margin: 18px 0 28px;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.markdown-body table {
  display: table !important;
  width: 100%;
  margin: 0;
  border-collapse: collapse;
  font-size: 14px;
  line-height: 1.55;
}
.markdown-body .md-table-wrap table {
  margin: 0;
}
.markdown-body th,
.markdown-body td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  vertical-align: top;
  text-align: left;
}
.markdown-body thead th {
  background: var(--surface-soft);
  color: var(--text);
  font-weight: 650;
  white-space: nowrap;
}
.markdown-body tbody tr:nth-child(even) {
  background: var(--surface-soft);
}
.markdown-body tbody tr:nth-child(odd) {
  background: var(--surface);
}
.markdown-body td code,
.markdown-body th code {
  display: inline;
  white-space: nowrap;
}

.drop-overlay {
  inset: 10px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--accent-soft) 90%, transparent);
  border: 2px dashed var(--accent);
}

/* 办公预览打开后强制隐藏拖拽遮罩，避免被卡住挡住内容 */
html.is-office-previewing .drop-overlay {
  display: none !important;
}

.drop-overlay strong {
  font-size: 22px;
}

.drop-overlay span {
  font-size: 0;
  line-height: 0;
}
.drop-overlay span::after {
  content: "松开即可打开";
  display: block;
  margin-top: 8px;
  font-size: 14px;
  color: var(--muted);
}

.toast {
  border-radius: 10px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.zoom-controls .zoom-label {
  min-width: 48px;
  font-weight: 600;
}

.office-tab-kind {
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.office-stage {
  padding: 20px 16px 28px;
}

.office-ppt-nav button {
  border-radius: 9px;
}

.office-ppt-nav button:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  color: var(--accent);
}

.office-meta {
  background: transparent;
  border-bottom: 0;
  padding: 12px 16px 0;
}

.office-meta-actions .header-button {
  height: 32px;
  font-size: 12px;
}

.loading-state,
.office-loading {
  color: var(--muted);
}

@media (width <= 700px) {
  .app-header {
    height: 56px;
  }
  .home-page {
    padding: 24px 16px 110px;
  }
  .welcome h1 {
    display: none !important;
  }
  .drop-zone {
    padding: 30px 16px 26px;
  }
  .feature-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .header-inner {
    padding: 0 14px;
  }
}

html.is-mobile-picker .drop-zone > strong {
  font-size: 0;
  line-height: 0;
}
html.is-mobile-picker .drop-zone > strong::after {
  content: "点击选择文件";
  font-size: 17px;
  font-weight: 650;
  line-height: 1.4;
  color: var(--text);
}
html.is-mobile-picker .drop-zone > span:not(.drop-icon, .file-types) {
  display: none;
}

#office-mobile-bar {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 40;
  display: grid;
  gap: 8px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
#office-mobile-bar[hidden] {
  display: none !important;
}
.office-mobile-pick {
  appearance: none;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 650;
  padding: 14px 16px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(47, 107, 255, 0.28);
}
.office-mobile-pick-secondary {
  background: #07c160;
  box-shadow: 0 8px 24px rgba(7, 193, 96, 0.28);
}
.office-mobile-pick-ghost {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 550;
  padding: 12px 14px;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.office-mobile-tip {
  display: none !important;
}
html:not(.is-mobile-picker) #office-mobile-bar,
html.is-office-previewing #office-mobile-bar {
  display: none !important;
}

.office-link-sheet {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: end center;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  background: rgba(15, 18, 24, 0.45);
}
.office-link-sheet-card {
  width: min(100%, 420px);
  background: var(--surface);
  border-radius: 16px;
  padding: 18px 16px 14px;
  box-shadow: 0 16px 40px rgba(15, 18, 24, 0.2);
}
.office-link-sheet-title {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 650;
  color: var(--text);
}
.office-link-sheet-desc {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
}
.office-link-sheet-url {
  margin: 0 0 8px;
  padding: 12px;
  border-radius: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
  line-height: 1.5;
  word-break: break-all;
  user-select: text;
  -webkit-user-select: text;
}
.office-link-sheet-hint {
  margin: 0 0 14px;
  font-size: 12px;
  color: var(--muted);
}
.office-link-sheet-actions {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 8px;
}
.office-link-sheet-close,
.office-link-sheet-copy {
  appearance: none;
  border: 0;
  border-radius: 11px;
  font-size: 15px;
  font-weight: 600;
  padding: 12px 14px;
  cursor: pointer;
}
.office-link-sheet-close {
  background: var(--surface-soft);
  color: var(--text);
  border: 1px solid var(--border);
}
.office-link-sheet-copy {
  background: #07c160;
  color: #fff;
}
