/* ============================================================================
 * word-editor.css — Word 风格在线编辑器
 *   目标：贴近 Microsoft Word 的 Ribbon + 纸张工作区视觉；
 *   配色沿用主题变量（主色 #6672c8，浅色扁平，无渐变无 emoji）。
 * ==========================================================================*/

.we-app {
  display: flex; flex-direction: column; height: calc(100vh - 56px);
  min-height: 620px; background: var(--bg); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r); overflow: hidden;
  font-family: var(--font-ui-cn);
}

/* ---------- 标题栏 ---------- */
.we-titlebar {
  display: flex; align-items: center; gap: 10px; flex: 0 0 38px;
  padding: 0 12px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.we-titlebar .we-logo {
  width: 22px; height: 22px; border-radius: 4px; background: var(--brand);
  color: #fff; font: 700 13px/22px var(--font-latin); text-align: center; flex: none;
}
.we-docname {
  border: 1px solid transparent; background: transparent; border-radius: 4px;
  font-size: 13px; font-weight: 600; color: var(--ink); padding: 3px 6px; width: 230px;
}
.we-docname:hover { border-color: var(--line); }
.we-docname:focus { outline: none; border-color: var(--brand); background: var(--surface); }
.we-save-state { font-size: 11px; color: var(--ink-3); min-width: 76px; }
.we-save-state.dirty { color: var(--warn); }
.we-titlebar .spacer { flex: 1; }

.we-mini {
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2);
  border-radius: 5px; padding: 4px 9px; font-size: 12px; cursor: pointer; white-space: nowrap;
}
.we-mini:hover { background: var(--brand-l); border-color: var(--brand-bd); color: var(--brand-d); }
.we-mini.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.we-mini.primary:hover { background: var(--brand-d); }
.we-mini:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- Ribbon ---------- */
.we-ribbon { flex: none; background: var(--surface); border-bottom: 1px solid var(--line-2); }
.we-tabs { display: flex; align-items: stretch; height: 32px; padding: 0 8px; background: var(--surface-3); }
.we-tab {
  border: 0; background: transparent; color: var(--ink-2); padding: 0 13px;
  font-size: 12px; cursor: pointer; border-bottom: 2px solid transparent;
}
.we-tab:hover { color: var(--brand-d); background: var(--surface); }
.we-tab.on { color: var(--brand-d); font-weight: 600; background: var(--surface); border-bottom-color: var(--brand); }
.we-rtabs { display: flex; align-items: center; gap: 4px; padding: 6px 10px; min-height: 66px; overflow-x: auto; }
.we-rtabs::-webkit-scrollbar { height: 5px; }
.we-rtabs::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 3px; }
.we-rgroup { display: flex; align-items: stretch; gap: 2px; padding-right: 10px; margin-right: 6px; border-right: 1px solid var(--line); flex: none; }
.we-rgroup:last-child { border-right: 0; }
.we-rb {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 36px; height: 52px; padding: 3px 5px; gap: 3px; border: 1px solid transparent;
  background: transparent; border-radius: 5px; cursor: pointer; color: var(--ink-2); font-size: 10px;
  white-space: nowrap; line-height: 1.1;
}
.we-rb:hover { background: var(--brand-l); border-color: var(--brand-bd); color: var(--brand-d); }
.we-rb.on { background: var(--brand-l); border-color: var(--brand); color: var(--brand-d); }
.we-rb .ic { font: 600 15px/1 var(--font-latin); color: var(--brand); }
.we-rb .ic.sub { font-size: 11px; }
.we-rb.wide { min-width: 60px; }
.we-rb.tall .ic { font-size: 18px; }
.we-rsel { align-self: center; height: 25px; border: 1px solid var(--line-2); border-radius: 4px;
  background: var(--surface); color: var(--ink); font-size: 12px; padding: 0 4px; max-width: 128px; }
.we-rsel:focus { outline: none; border-color: var(--brand); }
.we-rlab { align-self: center; font-size: 10px; color: var(--ink-3); writing-mode: horizontal-tb; max-width: 42px; text-align: center; }
.we-rstack { display: flex; flex-direction: column; justify-content: center; gap: 3px; }
.we-rstack .we-rb { height: 24px; min-width: 30px; flex-direction: row; gap: 4px; padding: 2px 5px; }

/* 颜色下拉格 */
.we-swatches { display: grid; grid-template-columns: repeat(8, 16px); gap: 3px; padding: 8px; }
.we-sw { width: 16px; height: 16px; border: 1px solid var(--line-2); border-radius: 3px; cursor: pointer; }
.we-sw:hover { outline: 2px solid var(--brand); }

/* ---------- 工作区 ---------- */
.we-workspace { flex: 1; overflow: auto; padding: 18px 12px 34px; background: #eceef4; }
.we-page-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.we-page {
  width: 794px; min-height: 1123px; background: #fff; box-shadow: var(--sh-2);
  border: 1px solid #dfe2ea; padding: 76px 90px 70px; box-sizing: border-box;
  outline: none; color: #111; font-family: "Times New Roman", "宋体", serif;
  font-size: 14pt; line-height: 1.6; word-wrap: break-word;
}
.we-page:focus { box-shadow: 0 0 0 2px var(--brand-bd), var(--sh-2); }
.we-page h1 { font-family: "黑体", sans-serif; font-size: 22pt; text-align: center; margin: 0 0 18px; line-height: 1.4; }
.we-page h2 { font-family: "黑体", sans-serif; font-size: 16pt; margin: 18px 0 10px; }
.we-page h3 { font-family: "黑体", sans-serif; font-size: 14pt; margin: 14px 0 8px; }
.we-page p { margin: 0 0 8px; }
.we-page blockquote { margin: 8px 0; padding: 4px 12px; border-left: 3px solid var(--brand-bd); color: var(--ink-2); }
.we-page table { border-collapse: collapse; width: 100%; margin: 10px 0; }
.we-page td, .we-page th { border: 1px solid #333; padding: 4px 8px; min-width: 40px; }
.we-page img { max-width: 100%; }
.we-page hr { border: 0; border-top: 1px solid #999; margin: 20px 0; }
.we-page .we-pb { page-break-after: always; border-top: 1px dashed var(--brand-bd); height: 0; margin: 18px 0; }
.we-ruler {
  width: 794px; height: 20px; margin-bottom: 3px; position: relative;
  background: repeating-linear-gradient(90deg, #fff 0, #fff 9px, transparent 9px, transparent 10px);
  border: 1px solid var(--line); border-radius: 3px 3px 0 0;
}
.we-ruler span { position: absolute; top: 2px; font: 9px var(--font-latin); color: var(--ink-3); }

/* 公式对象 */
.we-math {
  display: inline-block; padding: 1px 4px; margin: 0 1px; border-radius: 3px;
  border: 1px solid transparent; cursor: pointer; vertical-align: baseline;
}
.we-math:hover { border-color: var(--brand-bd); background: var(--brand-l); }
.we-math.sel { border-color: var(--brand); background: var(--brand-l); }
.we-math[data-display="1"] { display: block; text-align: center; margin: 8px 0; }
.we-math-src { font: 12px/1.4 var(--mono); color: var(--brand-d); background: var(--brand-l);
  border: 1px dashed var(--brand-bd); border-radius: 3px; padding: 1px 4px; }

/* ---------- 状态栏 ---------- */
.we-status {
  flex: 0 0 27px; display: flex; align-items: center; gap: 14px; padding: 0 12px;
  background: var(--brand-l); border-top: 1px solid var(--brand-bd); font-size: 11px; color: var(--ink-2);
}
.we-status .spacer { flex: 1; }
.we-status b { color: var(--brand-d); font-weight: 600; }
.we-zoom { display: flex; align-items: center; gap: 6px; }
.we-zoom input { width: 92px; }

/* ---------- 弹层面板 ---------- */
.we-pop {
  position: fixed; z-index: 900; background: var(--surface); border: 1px solid var(--line-2);
  border-radius: var(--r); box-shadow: var(--sh-3); padding: 10px; font-size: 12px;
}
.we-pop h4 { margin: 0 0 8px; font-size: 12px; color: var(--brand-d); }
.we-pop .we-row { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.we-pop input[type=text], .we-pop input[type=number], .we-pop select {
  border: 1px solid var(--line-2); border-radius: 4px; padding: 4px 6px; font-size: 12px; background: var(--surface); color: var(--ink);
}
.we-pop input:focus, .we-pop select:focus { outline: none; border-color: var(--brand); }
.we-grid-btns { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; max-height: 230px; overflow: auto; }
.we-grid-btns button { border: 1px solid var(--line); background: var(--surface-2); border-radius: 4px;
  padding: 5px 2px; cursor: pointer; font: 13px var(--font-latin); color: var(--ink); }
.we-grid-btns button:hover { background: var(--brand-l); border-color: var(--brand); }

/* 帮助 / 公式说明 */
.we-help { max-height: 66vh; overflow: auto; padding-right: 4px; }
.we-help h3 { font-size: 14px; color: var(--brand-d); margin: 14px 0 6px; }
.we-help h3:first-child { margin-top: 0; }
.we-help p, .we-help li { font-size: 12px; line-height: 1.7; color: var(--ink-2); }
.we-help table { border-collapse: collapse; width: 100%; margin: 6px 0 10px; }
.we-help td, .we-help th { border: 1px solid var(--line); padding: 4px 7px; font-size: 11px; text-align: left; }
.we-help th { background: var(--surface-3); color: var(--ink); }
.we-help code { background: var(--surface-3); border-radius: 3px; padding: 1px 4px; font: 11px var(--mono); color: var(--brand-d); }
.we-help .tip { background: var(--brand-l); border-left: 3px solid var(--brand); padding: 7px 10px; border-radius: 4px; }

/* 字体面板 */
.we-font-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; max-height: 300px; overflow: auto; }
.we-font-item { display: flex; align-items: center; justify-content: space-between; gap: 6px;
  border: 1px solid var(--line); border-radius: 4px; padding: 5px 7px; font-size: 12px; background: var(--surface); }
.we-font-item .avail { font-size: 10px; color: var(--ink-3); }
.we-font-item .avail.yes { color: var(--ok); }
.we-font-item a { color: var(--brand); text-decoration: none; font-size: 10px; }
.we-font-item a:hover { text-decoration: underline; }

/* 空提示 */
.we-empty { padding: 40px; text-align: center; color: var(--ink-3); font-size: 13px; }

@media (max-width: 980px) {
  .we-page { width: 100%; min-height: 900px; padding: 40px 30px; }
  .we-ruler { width: 100%; }
  .we-workspace { padding: 10px; }
}
