/* 桌游站站内文档弹窗（许愿中心 / Bug 报修中心）— 版式照搬腾讯文档：白纸黑字、原字号、分隔线、4 列表格；所有人可编辑 */

#modal-doc { align-items: center; }
#modal-doc .hd-card {
  width: 100%; max-width: 860px; max-height: min(92vh, 1000px);
  display: flex; flex-direction: column;
  padding: 0; overflow: hidden;
  background: #f3f4f6;
}
#modal-doc svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
#modal-doc [hidden] { display: none !important; }
#modal-doc .hd-card:not(.is-editing) .hd-edit-only { display: none !important; }
#modal-doc .hd-card.is-editing .hd-view-only,
#modal-doc .hd-card.is-preview .hd-view-only { display: none !important; }
#modal-doc .hd-card.is-preview .hd-btn-hist { display: inline-flex !important; }

/* 顶栏 */
#modal-doc .hd-bar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 8px;
  padding: 10px 12px 10px 18px;
  background: #fff; border-bottom: 1px solid #e6e8eb;
}
#modal-doc .hd-bar-ico { font-size: 20px; line-height: 1; flex: 0 0 auto; }
#modal-doc .hd-bar-txt { flex: 1; min-width: 0; }
#modal-doc .hd-bar-title { font-size: 15px; font-weight: 700; color: #1f2329; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#modal-doc .hd-bar-meta { margin-top: 1px; font-size: 12px; color: #8f959e; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#modal-doc .hd-tbtn {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 5px;
  height: 34px; padding: 0 12px;
  border: 1px solid #dee0e3; border-radius: 9px; background: #fff; color: #1f2329;
  font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
  transition: background .15s, border-color .15s;
}
#modal-doc .hd-tbtn svg { width: 16px; height: 16px; }
#modal-doc .hd-tbtn:hover { background: #f5f6f7; }
#modal-doc .hd-tbtn-primary { background: #3370ff; border-color: #3370ff; color: #fff; }
#modal-doc .hd-tbtn-primary:hover { background: #2b62e0; }
#modal-doc .hd-tbtn:disabled { opacity: .6; cursor: default; }
#modal-doc .hd-close {
  flex: 0 0 auto; width: 34px; height: 34px; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: transparent; color: #646a73; cursor: pointer;
}
#modal-doc .hd-close:hover { background: #f0f1f3; color: #1f2329; }
#modal-doc .hd-close-sm { width: 28px; height: 28px; }
#modal-doc .hd-close-sm svg { width: 15px; height: 15px; }

/* 编辑工具栏（仿腾讯文档） */
#modal-doc .hd-tools {
  flex: 0 0 auto; display: flex; align-items: center; gap: 2px;
  padding: 6px 12px; background: #fff; border-bottom: 1px solid #e6e8eb;
  overflow-x: auto; scrollbar-width: none;
}
#modal-doc .hd-tools::-webkit-scrollbar { display: none; }
#modal-doc .hd-tool {
  flex: 0 0 auto; min-width: 32px; height: 32px; padding: 0 7px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 6px; background: transparent; color: #1f2329;
  font: inherit; font-size: 13px; cursor: pointer;
}
#modal-doc .hd-tool:hover { background: #f0f1f3; }
#modal-doc .hd-tool:active { background: #e4e6e9; }
#modal-doc .hd-tool-b { font-weight: 800; font-size: 15px; }
#modal-doc .hd-tool-i { font-style: italic; font-family: Georgia, serif; font-size: 15px; }
#modal-doc .hd-tool-u { text-decoration: underline; font-size: 15px; }
#modal-doc .hd-tool-s { text-decoration: line-through; font-size: 15px; }
#modal-doc .hd-tool-sep { flex: 0 0 auto; width: 1px; height: 18px; margin: 0 6px; background: #dee0e3; }

/* 提示条（冲突 / 预览 / 草稿） */
#modal-doc .hd-notice {
  flex: 0 0 auto; display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  padding: 10px 18px; background: #fff7e6; border-bottom: 1px solid #ffe2b3; color: #8a5300;
  font-size: 13px;
}
#modal-doc .hd-notice-t { flex: 1 1 220px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
#modal-doc .hd-notice-t span { font-size: 12px; opacity: .85; }
#modal-doc .hd-notice-btn {
  flex: 0 0 auto; height: 30px; padding: 0 12px;
  border: 1px solid #f0c27a; border-radius: 8px; background: #fff; color: #8a5300;
  font: inherit; font-size: 12.5px; font-weight: 700; cursor: pointer;
}
#modal-doc .hd-notice-btn:hover { background: #fff0d6; }

/* 主体：纸面 + 历史侧栏 */
#modal-doc .hd-body { flex: 1 1 auto; min-height: 0; display: flex; }
#modal-doc .hd-scroll {
  flex: 1 1 auto; min-width: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 24px;
  scrollbar-width: thin; scrollbar-color: #c3c7cd transparent;
}
#modal-doc .hd-page {
  max-width: 774px; margin: 0 auto; box-sizing: border-box; min-height: 100%;
  padding: 48px 64px 56px;
  background: #fff; color: #000;
  border-radius: 4px; box-shadow: 0 1px 4px rgba(0, 0, 0, .08);
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px; line-height: 1.75; text-align: justify;
  word-break: break-word; outline: none;
  transition: box-shadow .2s;
}
#modal-doc .is-editing .hd-page { box-shadow: 0 0 0 2px #3370ff, 0 1px 4px rgba(0, 0, 0, .08); cursor: text; }
#modal-doc .is-preview .hd-page { box-shadow: 0 0 0 2px #f0a020, 0 1px 4px rgba(0, 0, 0, .08); }
#modal-doc .hd-page p, #modal-doc .hd-page h1, #modal-doc .hd-page h2,
#modal-doc .hd-page h3, #modal-doc .hd-page h4 { margin: 0; font-weight: normal; }
#modal-doc .hd-page b, #modal-doc .hd-page strong { font-weight: 700; }
/* 标题默认字号与原文一致（18 / 16 / 14pt），新加的标题也用它 */
#modal-doc .hd-page h1 { font-size: 25.2px; font-weight: 700; line-height: 1.5; margin: 0 0 10px; }
#modal-doc .hd-page h2 { font-size: 22.4px; font-weight: 700; line-height: 1.5; margin: 14px 0 8px; }
#modal-doc .hd-page h3 { font-size: 19.6px; font-weight: 700; line-height: 1.5; margin: 12px 0 6px; }
#modal-doc .hd-page h4 { font-size: 16.8px; font-weight: 700; line-height: 1.5; }
#modal-doc .hd-page p { padding: 1px 0; }
/* 原文的分隔线是带 1pt 黑色下边框的空段落 */
#modal-doc .hd-page .hd-hr { height: 1.2em; border-bottom: 1.33px solid #000; margin-bottom: 1em; padding: 0; }
#modal-doc .hd-loading { text-align: center; color: #8f959e; padding: 40px 0 !important; }

/* 表格：原文 4 列、无边框、单元格加粗，列宽 128.6 / 128.6 / 139.2 / 156.7 */
#modal-doc .hd-table {
  display: grid;
  grid-template-columns: minmax(0, 128.6fr) minmax(0, 128.6fr) minmax(0, 139.2fr) minmax(0, 156.7fr);
  margin: 4px 0;
}
#modal-doc .hd-cell {
  min-width: 0; min-height: 1.85em; padding: 2px 4px 2px 10px;
  font-weight: 700; font-size: var(--hd-fs, 14px); line-height: 1.85;
  display: flex; align-items: center;
}
#modal-doc .is-editing .hd-table { outline: 1px dashed #c3d4ff; outline-offset: 2px; }
#modal-doc .is-editing .hd-cell { box-shadow: inset 0 0 0 1px #eef1f6; }
#modal-doc .is-editing .hd-cell:focus-within,
#modal-doc .is-editing .hd-cell:hover { box-shadow: inset 0 0 0 1px #c3d4ff; }

/* 历史侧栏 */
#modal-doc .hd-hist {
  flex: 0 0 280px; display: flex; flex-direction: column; min-height: 0;
  background: #fff; border-left: 1px solid #e6e8eb;
}
#modal-doc .hd-hist-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 10px 4px 16px; font-size: 14px; color: #1f2329; }
#modal-doc .hd-hist-tip { padding: 0 16px 10px; font-size: 12px; color: #8f959e; line-height: 1.5; border-bottom: 1px solid #f0f1f3; }
#modal-doc .hd-hist-list { flex: 1; min-height: 0; overflow-y: auto; padding: 6px; scrollbar-width: thin; }
#modal-doc .hd-hist-row {
  width: 100%; display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "rev ts" "by by";
  gap: 2px 8px; padding: 9px 10px; margin-bottom: 2px;
  border: 0; border-radius: 8px; background: transparent; text-align: left; font: inherit; cursor: pointer; color: #1f2329;
}
#modal-doc .hd-hist-row:hover { background: #f5f6f7; }
#modal-doc .hd-hist-row.on { background: #fff4e0; }
#modal-doc .hd-hist-row.cur .hd-hist-ts { color: #3370ff; font-weight: 700; }
#modal-doc .hd-hist-rev { grid-area: rev; font-size: 13px; font-weight: 700; }
#modal-doc .hd-hist-ts { grid-area: ts; justify-self: end; font-size: 12px; color: #8f959e; }
#modal-doc .hd-hist-by { grid-area: by; font-size: 12px; color: #646a73; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#modal-doc .hd-hist-empty { padding: 30px 10px; text-align: center; font-size: 13px; color: #8f959e; }

/* 底部 */
#modal-doc .hd-foot {
  flex: 0 0 auto; padding: 10px 18px;
  background: #fff; border-top: 1px solid #e6e8eb;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
#modal-doc .hd-foot-tip { font-size: 12.5px; color: #8f959e; }
#modal-doc .hd-cta {
  min-width: 160px; height: 40px; padding: 0 22px;
  border: 0; border-radius: 10px;
  background: var(--brand, #4c3fd3); color: #fff;
  font: inherit; font-size: 14.5px; font-weight: 700; cursor: pointer;
  transition: filter .15s, transform .12s;
}
#modal-doc .hd-cta:hover { filter: brightness(1.08); }
#modal-doc .hd-cta:active { transform: scale(.98); }

@media (max-width: 900px) {
  #modal-doc .hd-page { padding: 36px 36px 44px; }
  #modal-doc .hd-hist { flex-basis: 240px; }
}

/* 手机：贴底抽屉；表格改 2 列，原文第 4 列的缩小字号只在 4 列时用；历史改成盖在纸面上的抽屉 */
@media (max-width: 640px) {
  #modal-doc { align-items: flex-end; padding: 0 !important; overflow: hidden; }
  #modal-doc .hd-card { max-height: 94dvh; height: 94dvh; margin: auto 0 0 !important; padding-bottom: 0 !important; }
  #modal-doc .hd-bar { padding: 10px 8px 10px 14px; gap: 6px; }
  #modal-doc .hd-tbtn { padding: 0 9px; }
  #modal-doc .hd-tbtn span { font-size: 13px; }
  #modal-doc .hd-tools { padding: 4px 8px; }
  #modal-doc .hd-scroll { padding: 10px; }
  #modal-doc .hd-page { padding: 22px 16px 28px; font-size: 14px; }
  #modal-doc .hd-page h1 { font-size: 21px !important; }
  #modal-doc .hd-page h2 { font-size: 19px !important; }
  #modal-doc .hd-page h3 { font-size: 17px !important; }
  #modal-doc .hd-table { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  #modal-doc .hd-cell { font-size: 13px; padding-left: 4px; }
  #modal-doc .hd-card:not(.is-editing) .hd-cell.hd-empty { display: none; }
  #modal-doc .hd-body { position: relative; }
  #modal-doc .hd-hist { position: absolute; inset: 0 0 0 auto; width: min(300px, 86vw); z-index: 2; box-shadow: -12px 0 30px -12px rgba(0, 0, 0, .25); }
  #modal-doc .hd-foot { padding: 8px 14px calc(8px + env(safe-area-inset-bottom, 0px)); }
  #modal-doc .hd-foot-tip { display: none; }
  #modal-doc .hd-cta { width: 100%; }
}

/* ---------- 站长「一键已修复」按钮（2026-10-31，只在页面上，不存进文档） ---------- */
.hd-fixbar { margin: 2px 0 8px; }
.hd-fixbtn {
  display: inline-flex; align-items: center; gap: 4px; height: 30px; padding: 0 12px;
  border: 1px solid #b9e2c9; border-radius: 999px; background: #eaf7ef; color: #1f8f5c;
  font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
}
.hd-fixbtn:hover { background: #1f8f5c; border-color: #1f8f5c; color: #fff; }
@media (prefers-color-scheme: dark) {
  .hd-fixbtn { background: rgba(31, 143, 92, .18); border-color: rgba(31, 143, 92, .45); color: #7fd8a9; }
}

/* 站内弹窗打开的链接（2026-10-31） */
.hd-linkpop { align-items: center; justify-content: center; }
.hd-linkpop-card { display: flex; flex-direction: column; width: min(1040px, 96vw); height: min(88vh, 920px); border-radius: 16px; overflow: hidden; background: #fff; box-shadow: 0 30px 80px -30px rgba(20, 16, 50, .6); }
.hd-linkpop-bar { display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; border-bottom: 1px solid #ece8e1; background: #fbfaf7; }
.hd-linkpop-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; color: #1d1b29; }
.hd-linkpop-out { flex: none; font-size: 13px; color: #4c3fd3; text-decoration: none; }
.hd-linkpop-frame { flex: 1; width: 100%; border: 0; background: #fff; }
@media (max-width: 640px) { .hd-linkpop-card { width: 100vw; height: 92dvh; border-radius: 16px 16px 0 0; margin-top: auto; } }

/* 文档格子只占一行，放不下显示省略号（2026-10-31，编辑时不限制） */
#modal-doc .hd-card:not(.is-editing) .hd-cell { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* 所有文档格子同一个字号（电脑 14px / 手机 13px），不管格子自己带的字号 */
#modal-doc .hd-card:not(.is-editing) .hd-cell { font-size: 14px !important; }
@media (max-width: 640px) { #modal-doc .hd-card:not(.is-editing) .hd-cell { font-size: 13px !important; } }
