/* 参考桌面Word双行功能区；界面尺寸不改变文档排版。 */
.ribbon {
  --ribbon-icon-large: 32px;
  --ribbon-icon-small: 18px;
  --ribbon-icon-chevron: 10px;
  margin: 0 0 4px;
  border-inline: 0;
  border-radius: 0;
  background: #fdfdfd;
}
.home-ribbon {
  padding: 7px 22px 4px 8px;
  gap: 0;
}
.home-ribbon .ribbon-group {
  padding-inline: 10px;
  border-color: #d9d9d9;
}
.home-ribbon .group-label {
  font-size: 12px;
  color: #555;
  bottom: 0;
}
.home-ribbon .group-content {
  align-items: flex-start;
  gap: 2px;
}
.home-ribbon .clipboard-group {
  width: 144px;
  padding-inline: 3px 8px;
}
.home-ribbon .large-tool {
  min-width: 46px;
  padding: 3px 2px;
  gap: 1px;
  font-size: 13px;
}
.home-ribbon .large-tool > svg:first-child {
  width: 32px;
  height: 32px;
  color: #b47827;
}
.home-ribbon .small-chevron {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
}
.home-ribbon .stack-tools button {
  min-height: 24px;
  height: 24px;
  padding: 1px 4px;
  gap: 5px;
  font-size: 13px;
}
.home-ribbon svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.home-ribbon .font-row {
  min-height: 34px;
  gap: 2px;
  flex-shrink: 0;
}
.home-ribbon .font-row button {
  width: 28px;
  min-width: 28px;
  min-height: 28px;
  height: 28px;
  padding: 3px;
  border-radius: 3px;
}
.home-ribbon .font-group {
  width: 344px;
}
.home-ribbon #font-family {
  width: 146px;
  height: 28px;
  font-size: 13px;
}
.home-ribbon #font-size {
  width: 49px;
  height: 28px;
  font-size: 13px;
  padding-inline: 4px;
}
.home-ribbon .format-row {
  gap: 3px;
}
.home-ribbon .tool-separator {
  height: 22px;
  margin-inline: 2px;
  flex-shrink: 0;
}
.home-ribbon .paragraph-group {
  width: 320px;
  min-width: 320px;
}
.home-ribbon .paragraph-group .font-row {
  gap: 3px;
}
.home-ribbon .paragraph-group .font-row > button {
  width: 28px;
  min-width: 28px;
}
.home-ribbon .color-label {
  width: 34px;
  height: 28px;
  margin-inline-start: 2px;
}
.home-ribbon .color-label svg {
  width: 20px;
  height: 20px;
}
.home-ribbon .color-label input {
  width: 22px;
  bottom: 0;
  height: 4px;
}
.home-ribbon .dialog-launcher {
  width: 16px;
  height: 16px;
  min-height: 16px;
  bottom: -1px;
  right: 2px;
}
.home-ribbon .dialog-launcher svg {
  width: 12px;
  height: 12px;
}
.home-ribbon .brush-icon {
  color: #bf7b2f;
}
.home-ribbon .text-effect-icon {
  color: #3186bc;
}
.home-ribbon .highlight-icon {
  color: #a28d00;
}
.home-ribbon .clear-format-icon {
  color: #9d4c9d;
}
.home-ribbon .replace-icon {
  color: #378ebc;
}
.home-ribbon .styles-group {
  flex: 1 1 680px;
  width: 680px;
  min-width: 190px;
  padding-inline: 8px;
}
.home-ribbon .style-gallery {
  display: flex;
  width: 100%;
  height: 72px;
  gap: 0;
  padding: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  border: 1px solid #dfdfdf;
  background: #fff;
}
.home-ribbon .style-gallery .style-preview {
  flex: 1 0 108px;
  width: 108px;
  min-width: 108px;
  height: 68px;
  padding: 4px 9px;
  margin: 1px;
  opacity: 1;
  border: 1px solid transparent;
  border-radius: 0;
  color: #333;
}
.home-ribbon .style-gallery .style-normal {
  border-color: #a4a4a4;
  box-shadow: inset 0 0 0 2px #e8e8e8;
}
.home-ribbon .style-gallery span {
  font-size: 17px;
  font-family: "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}
.home-ribbon .style-gallery .style-heading-one span {
  font-size: 25px;
  font-weight: 700;
}
.home-ribbon .style-gallery .style-heading-two span {
  font-size: 23px;
}
.home-ribbon .style-gallery .style-title span {
  font-size: 23px;
  font-weight: 400;
}
.home-ribbon .style-gallery .style-subtitle span {
  font-size: 21px;
  font-weight: 600;
}
.home-ribbon .editing-group {
  width: 92px;
  min-width: 92px;
  padding-inline: 7px 0;
}
.ribbon-selection-menu {
  position: fixed;
  z-index: 60;
  min-width: 176px;
  padding: 4px;
  background: #fff;
  border: 1px solid #bfc3c9;
  border-radius: 3px;
  box-shadow: 0 4px 14px #0002;
}
.list-split {
  display: inline-flex;
  align-items: stretch;
  gap: 0;
  flex: 0 0 auto;
}
.font-row .list-split > button {
  border-radius: 0;
  margin: 0;
}
.font-row .list-split .list-arrow {
  width: 16px;
  min-width: 16px;
  padding: 0 2px;
}
.list-arrow svg {
  width: 10px;
  height: 10px;
}
.list-menu {
  position: fixed;
  z-index: 180;
  width: min(338px, calc(100vw - 16px));
  padding: 8px;
  border: 1px solid #aeb9ca;
  border-radius: 0;
  background: #fff;
  color: #263348;
  overflow: auto;
  overscroll-behavior: contain;
  box-sizing: border-box;
}
.list-menu[hidden] {
  display: none;
}
.list-menu-title {
  padding: 2px 4px 8px;
  font-size: 13px;
  font-weight: 600;
}
.list-gallery {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}
.list-tile {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  height: 79px;
  min-width: 0;
  padding: 9px 7px;
  border: 1px solid #c5cbd4;
  background: #fff;
  color: inherit;
  border-radius: 0;
  cursor: pointer;
}
.list-tile:hover,
.list-tile:focus-visible {
  border-color: #648bdb;
  background: #f0f5ff;
  outline: none;
}
.list-tile[aria-checked="true"] {
  border-color: #315bc9;
  background: #e7efff;
}
.list-none {
  align-self: center;
  font-size: 14px;
}
.list-preview-line {
  display: flex;
  gap: 5px;
  align-items: center;
  min-height: 12px;
  line-height: 1;
  width: 100%;
  box-sizing: border-box;
}
.list-preview-marker {
  flex: 0 0 auto;
  font-size: 12px;
  max-width: 75%;
  overflow: hidden;
  white-space: nowrap;
}
.list-preview-rule {
  display: block;
  flex: 1;
  min-width: 5px;
  border-top: 1px solid #a7b0bd;
}
.list-menu-actions {
  border-top: 1px solid #dce2eb;
  margin-top: 8px;
  padding-top: 4px;
}
.list-menu-actions button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 7px 8px;
  font: inherit;
  font-size: 13px;
  color: inherit;
}
.list-menu-actions button:hover:not(:disabled),
.list-menu-actions button:focus-visible {
  background: #e7efff;
  outline: 1px solid #7299e7;
}
.list-menu-actions button:disabled {
  color: #9ba3b1;
}
.list-dialog {
  box-shadow: none;
  width: min(500px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  box-sizing: border-box;
  border: 1px solid #aab6c9;
  border-radius: 0;
  padding: 18px;
  color: #263348;
  background: #fff;
}
.list-dialog::backdrop {
  background: rgb(25 40 60 / 18%);
}
.list-dialog h2 {
  margin: 0 0 15px;
  font-size: 16px;
}
.list-dialog-body {
  display: grid;
  gap: 10px 14px;
}
.list-definition {
  grid-template-columns: 1fr 1fr;
}
.list-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  min-width: 0;
}
.list-field input,
.list-field select {
  border: 1px solid #b8c2d2;
  border-radius: 0;
  height: 30px;
  padding: 3px 6px;
  width: 100%;
  box-sizing: border-box;
  background: white;
  color: inherit;
  font: inherit;
  font-size: 13px;
}
.list-field input:focus,
.list-field select:focus {
  outline: 1px solid #315bc9;
  border-color: #315bc9;
}
.list-dialog .font-family-combobox input {
  padding-right: 28px;
}
.list-color-row {
  display: flex;
  gap: 5px;
  align-items: center;
}
.list-color-row input[type="color"] {
  flex: 0 0 30px;
  width: 30px;
  padding: 2px;
  cursor: pointer;
}
.list-color-row button {
  flex: 0 0 38px;
  padding: 0;
  height: 30px;
  border: 1px solid #b8c2d2;
  border-radius: 0;
  background: #fff;
  font-size: 12px;
}
.list-definition-preview {
  grid-column: 1 / -1;
  display: grid;
  gap: 9px;
  padding: 14px 22px;
  background: #f8faff;
  border: 1px solid #dce2eb;
}
.list-definition-preview .list-preview-marker {
  font-size: 14px;
}
.list-error {
  font-size: 12px;
  color: #b22830;
  margin: 8px 0;
  min-height: 16px;
}
.list-dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.list-dialog-footer button {
  border: 1px solid #aab6c9;
  border-radius: 0;
  background: white;
  min-width: 72px;
  padding: 6px 14px;
  font: inherit;
  font-size: 13px;
}
.list-dialog-footer .primary {
  background: #315bc9;
  border-color: #315bc9;
  color: white;
}
@media (max-width: 420px) {
  .list-dialog {
    padding: 12px;
  }
  .list-definition {
    gap: 8px;
  }
}
.ribbon-selection-menu button {
  display: flex;
  width: 100%;
  justify-content: flex-start;
  gap: 10px;
  min-height: 32px;
  padding: 5px 8px;
  font-size: 13px;
}
.ribbon-selection-menu svg {
  width: 18px;
  height: 18px;
}
@media (max-width: 1150px) {
  .home-ribbon .styles-group {
    flex-basis: 230px;
  }
}
@media (max-width: 900px) {
  .home-ribbon .styles-group {
    flex: 0 0 224px;
  }
}
@media (forced-colors: active) {
  .home-ribbon .style-gallery .style-normal {
    border-color: CanvasText;
  }
  .ribbon-selection-menu {
    border-color: CanvasText;
  }
}

/* 插入区保持与开始区相同高度；仅功能区横向滚动，不撑宽正文。 */
.insert-ribbon,
.layout-ribbon,
.view-ribbon,
.picture-ribbon {
  padding: 7px 22px 4px 6px;
  gap: 0;
}
.insert-ribbon .ribbon-group,
.layout-ribbon .ribbon-group,
.view-ribbon .ribbon-group,
.picture-ribbon .ribbon-group {
  padding-inline: 9px;
  border-color: #d9d9d9;
}
.insert-ribbon .group-content,
.layout-ribbon .group-content,
.view-ribbon .group-content,
.picture-ribbon .group-content {
  align-items: flex-start;
  gap: 2px;
}
.insert-ribbon .group-label,
.layout-ribbon .group-label,
.view-ribbon .group-label,
.picture-ribbon .group-label {
  bottom: 0;
  font-size: 12px;
  color: #555;
}
.insert-ribbon .large-tool,
.layout-ribbon .large-tool,
.view-ribbon .large-tool,
.picture-ribbon .large-tool {
  /* 固定图标、文字、箭头三行，避免有箭头的按钮整体居中后上移。 */
  display: grid;
  grid-template-rows: var(--ribbon-icon-large) 19px var(--ribbon-icon-chevron);
  justify-items: center;
  align-content: start;
  min-width: 48px;
  padding: 2px 5px;
  gap: 3px;
  font-size: 13px;
  border-radius: 3px;
}
.insert-ribbon .large-tool > svg:first-child,
.layout-ribbon .large-tool > svg:first-child,
.view-ribbon .large-tool > svg:first-child,
.picture-ribbon .large-tool > svg:first-child {
  width: var(--ribbon-icon-large);
  height: var(--ribbon-icon-large);
  flex-shrink: 0;
  color: #397bb5;
}
.insert-ribbon .large-tool > span,
.layout-ribbon .large-tool > span,
.view-ribbon .large-tool > span,
.picture-ribbon .large-tool > span {
  white-space: nowrap;
  line-height: 19px;
}
.insert-ribbon .large-tool:disabled,
.layout-ribbon .large-tool:disabled,
.view-ribbon .large-tool:disabled,
.picture-ribbon .large-tool:disabled {
  opacity: 0.62;
}
.insert-ribbon .large-tool:disabled > svg:first-child,
.layout-ribbon .large-tool:disabled > svg:first-child,
.view-ribbon .large-tool:disabled > svg:first-child,
.picture-ribbon .large-tool:disabled > svg:first-child {
  color: #60666d;
}
.insert-ribbon .small-chevron,
.layout-ribbon .small-chevron,
.picture-ribbon .small-chevron {
  width: var(--ribbon-icon-chevron);
  height: var(--ribbon-icon-chevron);
  color: #444;
  flex-shrink: 0;
}
.insert-ribbon .insert-text-tools {
  gap: 0;
  padding-inline-start: 4px;
}
.insert-ribbon .stack-tools button,
.layout-ribbon .stack-tools button {
  display: grid;
  grid-template-columns: var(--ribbon-icon-small) max-content auto;
  justify-content: start;
  align-items: center;
  height: 24px;
  min-height: 24px;
  padding: 1px 4px;
  gap: 4px;
  font-size: 13px;
  line-height: 20px;
}
.insert-ribbon .stack-tools svg:not(.small-chevron),
.layout-ribbon .stack-tools svg:not(.small-chevron) {
  width: var(--ribbon-icon-small);
  height: var(--ribbon-icon-small);
  flex-shrink: 0;
}
/* 图标、文字和箭头各占一行，有无菜单均保持相同的视觉基线。 */
.insert-ribbon .large-tool > svg:first-child,
.layout-ribbon .large-tool > svg:first-child {
  grid-row: 1;
  display: block;
}
.insert-ribbon .large-tool > span,
.layout-ribbon .large-tool > span {
  grid-row: 2;
}
.insert-ribbon .large-tool > .small-chevron,
.layout-ribbon .large-tool > .small-chevron {
  grid-row: 3;
}
.shape-gallery {
  width: 412px;
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - 16px);
  padding: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  border-radius: 2px;
  color: #373737;
}
.shape-gallery-section + .shape-gallery-section {
  border-top: 1px solid #dedede;
}
.shape-gallery-title {
  margin: 0;
  padding: 9px 12px 6px;
  font-size: 13px;
  font-weight: 600;
  line-height: 19px;
  color: #222;
}
.shape-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(28px, 1fr));
  gap: 1px;
  padding: 2px 7px 9px;
}
.shape-gallery-grid button {
  justify-content: center;
  width: 100%;
  min-width: 0;
  height: 28px;
  min-height: 28px;
  padding: 3px;
  border-radius: 1px;
  gap: 0;
  scroll-margin-block: 8px;
}
.shape-gallery-grid svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}
.shape-gallery button[aria-disabled="true"] {
  /* UI 预览仍保持清晰线条；可被键盘定位、读取名称，但不会执行编辑。 */
  cursor: default;
  opacity: 1;
}
.shape-gallery-grid button:hover,
.shape-gallery-grid button:focus-visible {
  color: #185abd;
  background: #e5effa;
  border-color: #8bb3df;
}
.shape-gallery-grid button:focus-visible {
  outline-offset: -2px;
}
.shape-gallery-empty {
  margin: 0;
  padding: 1px 12px 9px;
  font-size: 12px;
  color: #777;
}
.shape-gallery-footer {
  padding: 3px 5px 7px;
  border-top: 1px solid #dedede;
}
.shape-gallery-footer button {
  min-height: 34px;
  padding: 4px 7px;
  gap: 8px;
}
.shape-gallery-footer svg {
  width: 22px;
  height: 22px;
  color: #397bb5;
}
.shape-gallery-footer > span {
  display: block;
  padding-inline: 7px;
  color: #68717b;
  font-size: 11px;
  line-height: 1.5;
}
@media (forced-colors: active) {
  .insert-ribbon .large-tool:disabled,
  .insert-ribbon .large-tool:disabled > svg:first-child {
    color: GrayText;
    opacity: 1;
  }
}

/* 布局选项卡：三行紧凑控件和分组宽度独立于文档页面尺寸。 */
.layout-ribbon .ribbon-group {
  padding-inline: 8px;
}
.layout-ribbon .large-tool {
  min-width: 61px;
  padding-inline: 4px;
}
.layout-ribbon .large-tool > span {
  font-size: 13px;
}
.layout-ribbon .stack-tools {
  gap: 0;
}
.layout-ribbon .stack-tools button:disabled {
  opacity: 0.62;
}
.layout-ribbon .stack-tools .small-chevron {
  width: var(--ribbon-icon-chevron);
  height: var(--ribbon-icon-chevron);
  margin-inline-start: auto;
}
.layout-ribbon .dialog-launcher {
  position: absolute;
  right: 2px;
  bottom: 0;
  width: 16px;
  min-width: 16px;
  height: 16px;
  min-height: 16px;
  padding: 1px;
}
.layout-ribbon .dialog-launcher svg {
  width: 12px;
  height: 12px;
}
.layout-ribbon .layout-paragraph-group {
  padding-inline: 10px;
}
.layout-paragraph-group .group-content {
  gap: 14px;
}
.layout-field-column {
  display: grid;
  grid-template-rows: 16px 25px 25px;
  gap: 3px;
}
.layout-field-heading {
  font-size: 12px;
  color: #52647b;
  line-height: 16px;
  font-weight: 500;
}
.layout-field {
  display: grid;
  grid-template-columns: var(--ribbon-icon-small) max-content 104px;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  white-space: nowrap;
}
.layout-field > svg {
  width: var(--ribbon-icon-small);
  height: var(--ribbon-icon-small);
  color: #52647b;
}
.layout-value {
  display: flex;
  align-items: center;
  height: 25px;
  min-width: 0;
  overflow: hidden;
  border: 1px solid #bdcadb;
  border-radius: 3px;
  background: #fff;
}
.layout-value input {
  width: 100%;
  min-width: 0;
  height: 23px;
  min-height: 23px;
  padding: 1px 6px;
  border: 0;
  background: transparent;
  font-size: 12px;
  color: #304761;
  cursor: text;
  outline: none;
  box-shadow: none;
  font-variant-numeric: tabular-nums;
}
.layout-value > .layout-unit {
  flex: none;
  padding-inline: 0 4px;
  font-size: 11px;
  color: #718197;
}
.layout-value:focus-within {
  border-color: #477fbd;
  outline: 1px solid #b8d2ef;
  outline-offset: 0;
}
.layout-value input:focus-visible {
  outline: none;
  box-shadow: none;
}
.layout-value:has(input:disabled) {
  background: #f2f4f7;
  border-color: #dde3eb;
}
.layout-value > .layout-spin-buttons {
  flex: 0 0 17px;
  display: grid;
  align-self: stretch;
  grid-template-rows: 1fr 1fr;
  border-left: 1px solid #d9e2ee;
}
.layout-ribbon .layout-spin-buttons button {
  display: grid;
  place-items: center;
  width: 100%;
  min-width: 0;
  height: auto;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #f7f9fc;
  color: #61758e;
  touch-action: none;
}
.layout-spin-buttons button + button {
  border-top: 1px solid #e1e7f0;
}
.layout-ribbon .layout-spin-buttons button:hover:not(:disabled) {
  background: #e6f0fc;
  color: #235eaa;
}
.layout-ribbon .layout-spin-buttons button:active:not(:disabled) {
  background: #d7e7fa;
}
.layout-spin-buttons button span {
  width: 5px;
  height: 5px;
  border: solid currentColor;
  border-width: 1px 1px 0 0;
  transform: translateY(1px) rotate(-45deg);
}
.layout-spin-buttons button[data-spin="-1"] span {
  transform: translateY(-1px) rotate(135deg);
}
@media (forced-colors: active) {
  .layout-value {
    border-color: CanvasText;
  }
  .layout-ribbon .large-tool:disabled,
  .layout-ribbon .large-tool:disabled > svg:first-child {
    color: GrayText;
    opacity: 1;
  }
}

/* 视图选项卡使用双行标题；当前模式、可用命令和未实现入口清晰区分。 */
.view-ribbon .ribbon-group,
.picture-ribbon .ribbon-group {
  padding-inline: 10px;
}
.view-ribbon .large-tool,
.picture-ribbon .large-tool {
  grid-template-rows: 32px 32px;
  min-width: 58px;
  padding-inline: 6px;
}
.view-ribbon .large-tool > span,
.picture-ribbon .large-tool > span {
  text-align: center;
  line-height: 16px;
}
.view-ribbon .large-tool[aria-pressed="true"],
.picture-ribbon .large-tool[aria-pressed="true"] {
  border-color: #9b9fa5;
  background: #eceef1;
  color: #242424;
  opacity: 1;
}
.view-ribbon .large-tool[aria-pressed="true"] > svg:first-child,
.picture-ribbon .large-tool[aria-pressed="true"] > svg:first-child {
  color: #3b4047;
}
.view-ribbon .stack-tools button,
.picture-ribbon .stack-tools button {
  height: 24px;
  min-height: 24px;
  padding: 2px 4px;
  gap: 5px;
  font-size: 13px;
}
.view-ribbon .stack-tools svg,
.picture-ribbon .stack-tools svg {
  width: 19px;
  height: 19px;
}
.view-ribbon .stack-tools button:disabled,
.picture-ribbon .stack-tools button:disabled {
  opacity: 0.62;
}
.view-ribbon .view-checkboxes {
  gap: 0;
  height: 72px;
}
.view-ribbon .view-checkboxes label {
  height: 24px;
  gap: 7px;
  font-size: 13px;
  padding-inline: 2px 5px;
}
.view-ribbon .view-checkboxes input {
  width: 16px;
  height: 16px;
  margin: 0;
}
.view-ribbon .view-crop-controls {
  display: grid;
  grid-template-rows: repeat(3, 24px);
  grid-auto-flow: column;
  column-gap: 10px;
}
.view-checkboxes label:has(input:disabled) {
  color: #999;
}
.zoom-dialog {
  width: min(390px, calc(100vw - 32px));
}
.zoom-dialog .zoom-value-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-block: 18px 12px;
}
.zoom-dialog #view-zoom-value {
  width: 112px;
}
.zoom-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-block: 12px;
}
.zoom-presets button {
  min-width: 50px;
  background: #f4f6f9;
  border-color: #d4d8df;
}
@media (forced-colors: active) {
  .view-ribbon .large-tool[aria-pressed="true"],
  .picture-ribbon .large-tool[aria-pressed="true"] {
    border-color: Highlight;
    background: Canvas;
    color: CanvasText;
  }
  .view-ribbon .large-tool[aria-pressed="true"] > svg:first-child,
  .picture-ribbon .large-tool[aria-pressed="true"] > svg:first-child {
    color: CanvasText;
  }
  .view-ribbon .large-tool:disabled:not([aria-pressed="true"]),
  .view-ribbon .large-tool:disabled:not([aria-pressed="true"]) > svg:first-child,
  .picture-ribbon .large-tool:disabled:not([aria-pressed="true"]) > svg:first-child {
    opacity: 1;
    color: GrayText;
  }
}

/* 上下文标签统一使用主题蓝；选中下划线沿用公共标签规则。 */
.ribbon-tabs .contextual-tab {
  color: var(--accent);
}
/* 图片格式独立呈现；仅横向滚动功能区，避免挤压正文或触发文档排版。 */
.picture-ribbon .stack-tools button {
  min-height: 24px;
  height: 24px;
  padding: 2px 4px;
  white-space: nowrap;
}
.picture-ribbon .stack-tools svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.picture-ribbon .large-tool {
  min-width: 50px;
  max-width: 67px;
  grid-template-rows: 32px auto;
}
.picture-ribbon .large-tool > span {
  white-space: normal;
  text-align: center;
  line-height: 17px;
}
.picture-ribbon .large-tool[aria-haspopup="menu"] {
  grid-template-rows: 32px 17px 16px;
  gap: 1px;
}
.picture-ribbon .large-tool[aria-haspopup="menu"] > span {
  white-space: nowrap;
  line-height: 17px;
}
.picture-ribbon .large-tool > .small-chevron {
  width: 16px;
  height: 16px;
}
.picture-ribbon .large-tool[aria-expanded="true"] {
  background: #d7e4f6;
  border-color: #9db9e2;
}
@media (forced-colors: active) {
  .picture-ribbon .large-tool[aria-expanded="true"] {
    background: Canvas;
    border-color: Highlight;
  }
}
.picture-style-gallery {
  display: flex;
  align-items: center;
  height: 68px;
  gap: 6px;
  padding: 0 8px;
  border: 1px solid #ddd;
  border-radius: 3px;
}
.picture-style-preview {
  width: 48px;
  height: 46px;
  padding: 4px;
}
.picture-style-preview svg {
  width: 38px;
  height: 30px;
  color: #397bb5;
  background: #eef7ef;
  border: 2px solid #ccc;
}
.picture-style-1 svg {
  border-radius: 6px;
  opacity: 0.7;
}
.picture-style-2 svg {
  border-radius: 8px;
}
.picture-style-3 svg {
  box-shadow: 2px 3px 2px #888;
}
.picture-style-4 svg {
  border: 3px solid #333;
}
.picture-size-fields {
  display: grid;
  grid-template-rows: repeat(3, 24px);
  gap: 0;
  font-size: 12px;
}
.picture-size-fields > label {
  display: flex;
  align-items: center;
  gap: 6px;
}
.picture-size-fields input[type="number"] {
  height: 24px;
  min-height: 24px;
  width: 104px;
  padding: 1px 5px;
}
.picture-size-options {
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.picture-size-options label {
  display: flex;
  align-items: center;
  gap: 3px;
}
.picture-size-options input {
  margin: 0;
}
.picture-size-options select,
.picture-size-options button {
  height: 23px;
  min-height: 23px;
  padding: 1px 4px;
  font-size: 12px;
}
#picture-alt-dialog,
#shape-text-dialog {
  width: min(440px, calc(100vw - 32px));
}
#picture-alt-dialog textarea,
#shape-text-dialog textarea {
  display: block;
  width: 100%;
  margin-block: 8px 16px;
  resize: vertical;
  padding: 8px;
  font: inherit;
}
#shape-text-dialog .shape-text-content {
  padding: 20px;
}

/* 形状上下文保持固定功能区高度；窄窗口只滚动此面板，不扩展整个页面。 */
.shape-ribbon {
  padding: 7px 22px 4px 8px;
  gap: 0;
}
.shape-ribbon-content {
  display: flex;
  align-items: stretch;
  position: relative;
}
.shape-ribbon .ribbon-group {
  padding-inline: 10px;
  border-color: #d9d9d9;
}
.shape-ribbon .group-content {
  align-items: flex-start;
  gap: 4px;
}
.shape-ribbon .group-label {
  bottom: 0;
  font-size: 12px;
  color: #555;
}
.shape-ribbon button {
  font-size: 13px;
  white-space: nowrap;
}
.shape-ribbon svg {
  width: 19px;
  height: 19px;
  flex-shrink: 0;
}
.shape-ribbon .stack-tools button {
  height: 24px;
  min-height: 24px;
  padding: 2px 4px;
  gap: 5px;
}
.shape-ribbon .large-tool {
  min-width: 48px;
  grid-template-rows: 32px auto;
  padding: 1px 3px;
  font-size: 13px;
}
.shape-ribbon .large-tool > svg:first-child {
  width: 32px;
  height: 32px;
  color: #397bb5;
}
.shape-ribbon .large-tool > span {
  line-height: 17px;
  text-align: center;
}
.shape-ribbon .large-tool:disabled > svg:first-child {
  color: #73777e;
}
.shape-quick-gallery {
  display: grid;
  grid-template-columns: repeat(4, 27px);
  grid-template-rows: repeat(3, 23px);
  border: 1px solid #d3d6da;
  padding: 0 3px;
  border-radius: 2px;
}
.shape-quick-gallery button {
  min-width: 0;
  min-height: 0;
  width: 27px;
  height: 23px;
  border: 0;
  padding: 2px 3px;
  border-radius: 2px;
  color: #484c51;
}
.shape-quick-gallery svg {
  width: 21px;
  height: 19px;
}
.shape-insert-actions {
  min-width: 92px;
}
.shape-style-gallery {
  display: flex;
  align-items: center;
  height: 71px;
  gap: 3px;
  padding: 4px;
  border: 1px solid #d3d6da;
  border-radius: 2px;
}
.shape-style-preview {
  width: 57px;
  height: 62px;
  min-height: 0;
  padding: 5px;
  border-radius: 2px;
}
.shape-style-preview span {
  display: grid;
  place-items: center;
  width: 44px;
  height: 49px;
  border: 1px solid #70ad47;
  border-radius: 10px;
  font-size: 13px;
  color: #242424;
  background: white;
}
.shape-style-dark span {
  background: #171717;
  color: white;
  border-color: #171717;
}
/* 静态图标方向放在同源样式表，兼容禁止内联样式的 CSP。 */
.picture-rotate-clockwise {
  transform: scaleX(-1);
}
.shape-style-blue span {
  background: var(--shape-default-fill);
  color: white;
  border: 2px solid var(--shape-default-stroke);
}
.shape-style-preview[aria-pressed="true"] {
  background: #e6e9ec;
  border-color: #9b9fa5;
}
.shape-paint-fields {
  display: grid;
  grid-template-rows: repeat(3, 24px);
}
.shape-paint-row {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 24px;
}
.shape-paint-row > button {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  min-height: 24px;
  padding: 1px 3px;
}
.shape-color-control {
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  font-size: 13px;
}
.shape-color-control input[type="color"] {
  width: 25px;
  height: 21px;
  min-height: 0;
  padding: 1px;
  border: 1px solid #c8cbd0;
  border-radius: 2px;
  cursor: pointer;
}
.shape-plain-option {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  white-space: nowrap;
  color: #555;
}
.shape-plain-option input {
  margin: 0;
  width: 13px;
  height: 13px;
}
.shape-line-width {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  white-space: nowrap;
}
.shape-line-width input {
  width: 46px;
  height: 22px;
  padding: 1px 3px;
}
.shape-wordart-gallery {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 70px;
  border: 1px solid #ddd;
  padding: 3px;
}
.shape-wordart-gallery button {
  display: block;
  width: 48px;
  height: 59px;
  border: 0;
  border-radius: 0;
  background: #f7f3f8;
  color: #777;
  padding: 0;
  font:
    bold 42px Calibri,
    sans-serif;
}
.shape-wordart-gallery button:nth-child(2) {
  color: #aaa;
}
.shape-wordart-gallery button:nth-child(3) {
  color: #eee;
  -webkit-text-stroke: 1px #aaa;
}
.shape-wrap-control {
  display: grid;
  grid-template-rows: 32px 18px 22px;
  justify-items: center;
  align-items: center;
  gap: 0;
  font-size: 13px;
}
.shape-wrap-control > svg {
  width: 32px;
  height: 32px;
  color: #397bb5;
}
.shape-wrap-control select {
  width: 112px;
  height: 22px;
  font-size: 11px;
  padding: 0 2px;
}
.shape-size-fields {
  display: grid;
  grid-template-rows: repeat(3, 24px);
  gap: 0;
}
.shape-size-fields > label {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  font-size: 12px;
}
.shape-size-fields input[type="number"] {
  height: 24px;
  min-height: 24px;
  width: 85px;
  padding: 1px 4px;
}
.shape-size-options {
  display: flex;
  align-items: center;
  gap: 4px;
}
.shape-size-options select,
.shape-size-options button {
  font-size: 11px;
  height: 23px;
  min-height: 23px;
  padding: 1px 4px;
}
.shape-size-options button {
  display: flex;
  align-items: center;
  gap: 2px;
}
.shape-size-options svg {
  width: 13px;
  height: 13px;
}
.shape-context-note {
  position: absolute;
  width: 1px;
  height: 1px;
  clip-path: inset(50%);
  overflow: hidden;
  font-size: 10px;
  color: #7a8088;
  white-space: nowrap;
  line-height: 12px;
}
.shape-angle-field {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px;
  padding: 6px;
  border-top: 1px solid #e1e3e6;
  white-space: nowrap;
  font-size: 13px;
}
.shape-angle-field input {
  width: 86px;
  height: 27px;
  padding: 2px 5px;
}
@media (forced-colors: active) {
  .shape-style-preview[aria-pressed="true"] {
    outline: 2px solid Highlight;
  }
  .shape-style-preview span {
    forced-color-adjust: none;
  }
  .shape-ribbon button:disabled,
  .shape-ribbon button:disabled > svg {
    color: GrayText;
    opacity: 1;
  }
}

.cover-gallery {
  position: fixed;
  z-index: 1500;
  width: 380px;
  max-width: calc(100vw - 16px);
  border: 1px solid #bac6d5;
  padding: 12px;
  background: #fff;
  color: #202733;
}
.cover-gallery-title {
  font-size: 13px;
  margin-bottom: 10px;
}
.cover-gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.cover-gallery-grid > button {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-width: 0;
  gap: 4px;
}
.cover-gallery button {
  border-radius: 0;
  border: 1px solid transparent;
  background: transparent;
  padding: 6px;
  font-size: 12px;
  color: inherit;
  cursor: pointer;
}
.cover-gallery button:hover,
.cover-gallery button:focus-visible {
  background: #edf3fc;
  border-color: #185abd;
}
.cover-thumbnail {
  height: 130px;
  border: 1px solid #adb8c6;
  display: flex;
  flex-direction: column;
  background: #fff;
  padding: 26px 8px 12px;
  text-align: left;
  margin-bottom: 6px;
  font-size: 10px;
}
.cover-thumbnail strong {
  font-size: 11px;
}
.cover-thumbnail i {
  font-size: 8px;
  font-style: normal;
  margin-top: 8px;
}
.cover-thumbnail small {
  margin-top: auto;
  font-size: 7px;
}
.cover-classic {
  text-align: center;
}
.cover-band strong {
  background: #e7effa;
  color: #185abd;
  padding: 5px;
}
.cover-minimal strong {
  border-bottom: 1px solid #888;
  padding-bottom: 5px;
}
#remove-cover {
  margin-top: 8px;
  width: 100%;
  text-align: left;
  border-top: 1px solid #dbe1ea;
}
.cover-dialog {
  border-radius: 0;
  box-shadow: none;
}
.cover-dialog input {
  border-radius: 0;
  max-width: 70%;
  border: 1px solid #a9b6c7;
  padding: 5px;
}
.cover-dialog button {
  border-radius: 0;
}
.cover-dialog p {
  font-size: 12px;
  color: #526174;
  line-height: 1.6;
}
.cover-dialog #cover-error {
  color: #a4262c;
}

/* Editable size picker: fixed-width control, native scrolling, no document preview work. */
.home-ribbon .font-size-combobox {
  position: relative;
  display: inline-flex;
  flex: 0 0 60px;
  height: 28px;
}
.home-ribbon .font-size-combobox #font-size {
  width: 60px;
  padding-inline: 5px 18px;
  border-radius: 0;
  font-variant-numeric: tabular-nums;
}
.home-ribbon .font-row .font-size-toggle {
  position: absolute;
  inset-inline-end: 1px;
  top: 1px;
  width: 17px;
  min-width: 17px;
  height: 26px;
  min-height: 26px;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: #5c6675;
}
.font-size-toggle::before {
  content: "";
  border-inline: 3px solid transparent;
  border-top: 4px solid currentColor;
}
.font-size-combobox:has(input:disabled) .font-size-toggle {
  pointer-events: none;
  opacity: 0.5;
}
.font-size-options {
  position: fixed;
  z-index: 1500;
  width: 120px;
  margin: 0;
  padding: 3px 0;
  border: 1px solid #a8b4c7;
  border-radius: 0;
  background: #fff;
  color: #303844;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  font-size: 13px;
  line-height: 22px;
  font-variant-numeric: tabular-nums;
}
.font-size-options [role="option"] {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 28px;
  padding: 3px 9px;
  cursor: pointer;
}
.font-size-options [role="option"] span {
  color: #6b7380;
  font-size: 11px;
}
.font-size-options [role="option"]:hover {
  background: #edf3fc;
}
.font-size-options [aria-selected="true"] {
  background: #dce9fb;
  color: #185abd;
}
.font-size-options .size-presets-divider {
  border-top: 1px solid #e2e6ec;
}
@media (forced-colors: active) {
  .font-size-options [aria-selected="true"] {
    forced-color-adjust: none;
    background: Highlight;
    color: HighlightText;
  }
  .font-size-options [aria-selected="true"] span {
    color: inherit;
  }
}
.font-size-options::-webkit-scrollbar {
  width: 11px;
}
.font-size-options::-webkit-scrollbar-track {
  background: #f3f4f6;
}
.font-size-options::-webkit-scrollbar-thumb {
  background: #a9afb8;
  border: 3px solid #f3f4f6;
  border-radius: 0;
}
.font-size-options::-webkit-scrollbar-thumb:hover {
  background: #7c8796;
}
.page-setup-menu {
  position: fixed;
  z-index: 60;
  width: min(280px, calc(100vw - 16px));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px;
  background: #fff;
  border: 1px solid #bfc3c9;
  border-radius: 0;
  box-shadow: none;
}
.page-setup-menu button {
  display: block;
  width: 100%;
  text-align: start;
  padding: 8px 10px;
  border-radius: 0;
  white-space: normal;
}
.page-setup-menu button[aria-checked="true"] {
  background: #e4eefc;
  color: #185abd;
}
.page-setup-menu small {
  display: block;
  color: #66717f;
  font-size: 11px;
  margin-top: 3px;
}
.page-setup-dialog {
  width: min(540px, calc(100vw - 24px));
  border-radius: 0;
  box-shadow: none;
}
.page-setup-body {
  display: grid;
  grid-template-columns: 1fr 150px;
  align-items: center;
  gap: 16px;
}
.page-setup-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.page-setup-dialog .page-setup-fields label {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-content: stretch;
  min-width: 0;
  margin: 0;
  gap: 4px;
}
.page-setup-dialog .page-setup-fields label input:not([type="checkbox"]),
.page-setup-dialog .page-setup-fields select {
  width: 100%;
  min-width: 0;
  border-radius: 0;
}
.page-setup-body canvas {
  width: 140px;
  height: 160px;
  background: #f4f6fa;
}
.page-setup-scope {
  color: #646e7c;
  font-size: 12px;
  line-height: 1.6;
}
.page-setup-error {
  color: #a62c2c;
  font-size: 12px;
}
@media (max-width: 520px) {
  .page-setup-body {
    grid-template-columns: 1fr;
  }
  .page-setup-body canvas {
    display: none;
  }
}

.page-setup-dialog .page-setup-scope,
.page-setup-dialog .page-setup-error {
  margin: 0;
  padding: 4px 20px 8px;
}
.line-numbering-dialog {
  width: min(420px, calc(100vw - 24px));
}
.line-numbering-dialog .page-setup-fields {
  padding: 16px 20px;
}

/* 页眉页脚共享功能区高度，编辑层不进入正文流。 */
.header-footer-ribbon {
  padding: 7px 22px 4px 6px;
}
.header-footer-ribbon .stack-tools {
  gap: 1px;
}
.header-footer-ribbon .stack-tools label {
  height: 23px;
}
.header-footer-ribbon .stack-tools input[type="number"],
.header-footer-ribbon select {
  height: 23px;
}
.header-footer-ribbon label {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  font-size: 12px;
}
.header-footer-ribbon input[type="number"] {
  width: 70px;
  min-width: 0;
  height: 26px;
}
.header-footer-ribbon input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: #185abd;
}
.header-footer-ribbon .large-tool svg {
  width: 32px;
  height: 32px;
}
.header-footer-ribbon #hf-font {
  width: 108px;
  height: 23px;
  border: 1px solid #c7cdd5;
  padding: 2px 5px;
}
.header-footer-ribbon #hf-color {
  width: 36px;
  height: 22px;
  padding: 1px;
  border: 1px solid #c7cdd5;
  background: transparent;
}
.hf-format-buttons {
  display: flex;
  gap: 2px;
}
.hf-format-buttons button {
  min-width: 26px;
  height: 23px;
  padding: 1px 6px;
}
.hf-format-buttons button[aria-pressed="true"] {
  background: #e3edfb;
  color: #185abd;
}
.hf-format-hint {
  font-size: 11px;
  color: #687583;
  padding: 4px 0;
}
.header-footer-editor {
  position: absolute;
  z-index: 22;
  cursor: text;
  touch-action: none;
}
.hf-picture-selection {
  position: absolute;
  box-sizing: border-box;
  border: 1px solid #2774c8;
  cursor: move;
  outline: none;
  z-index: 3;
  touch-action: none;
}
.hf-picture-selection:focus-visible {
  outline: 1px solid #2774c8;
  outline-offset: 3px;
}
.hf-picture-selection button {
  position: absolute;
  width: 9px;
  height: 9px;
  padding: 0;
  min-width: 0;
  min-height: 0;
  line-height: 0;
  box-sizing: border-box;
  border: 1px solid #2774c8;
  border-radius: 50%;
  background: white;
  transform: translate(-50%, -50%) scale(var(--hf-handle-scale, 1));
  box-shadow: none;
}
.hf-picture-selection [data-hf-picture-handle="nw"] {
  left: 0;
  top: 0;
  cursor: nwse-resize;
}
.hf-picture-selection [data-hf-picture-handle="n"] {
  left: 50%;
  top: 0;
  cursor: ns-resize;
}
.hf-picture-selection [data-hf-picture-handle="ne"] {
  left: 100%;
  top: 0;
  cursor: nesw-resize;
}
.hf-picture-selection [data-hf-picture-handle="e"] {
  left: 100%;
  top: 50%;
  cursor: ew-resize;
}
.hf-picture-selection [data-hf-picture-handle="se"] {
  left: 100%;
  top: 100%;
  cursor: nwse-resize;
}
.hf-picture-selection [data-hf-picture-handle="s"] {
  left: 50%;
  top: 100%;
  cursor: ns-resize;
}
.hf-picture-selection [data-hf-picture-handle="sw"] {
  left: 0;
  top: 100%;
  cursor: nesw-resize;
}
.hf-picture-selection [data-hf-picture-handle="w"] {
  left: 0;
  top: 50%;
  cursor: ew-resize;
}
.hf-picture-selection [data-hf-picture-handle="rotate"] {
  left: 50%;
  top: calc(-24px * var(--hf-handle-scale, 1));
  cursor: grab;
}
.hf-picture-selection::before {
  content: "";
  position: absolute;
  left: 50%;
  top: calc(-20px * var(--hf-handle-scale, 1));
  height: calc(20px * var(--hf-handle-scale, 1));
  border-left: 1px solid #2774c8;
}
.hf-picture-ghost {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  opacity: 0.8;
  outline: 1px dashed #2774c8;
  object-fit: fill;
}
#hf-picture-tools input[type="number"] {
  width: 58px;
}
.header-footer-ribbon:has(#hf-picture-tools:not([hidden])) .ribbon-group:has(#hf-align) {
  display: none;
}
.hf-text-surface,
.hf-selection-surface {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
#header-footer-input {
  /* The native input bridge anchors IME and clipboard; all visible text is painted on the page. */
  position: absolute;
  display: block;
  box-sizing: border-box;
  width: 1px;
  min-width: 0;
  min-height: 0;
  resize: none;
  padding: 0;
  border: 0;
  outline: none;
  box-shadow: none;
  border-radius: 0;
  overflow: hidden;
  opacity: 0.01;
  pointer-events: none;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  font-size: 16px;
}
.hf-boundary {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px dashed #999;
  pointer-events: none;
}
[data-kind="header"] > .hf-boundary {
  top: 100%;
}
[data-kind="footer"] > .hf-boundary {
  top: 0;
}
.hf-region-label,
.hf-linked-label {
  position: absolute;
  padding: 1px 5px;
  line-height: 18px;
  font-size: 12px;
  color: #555;
  background: #f0f0f0;
  border: 1px solid #aaa;
  white-space: nowrap;
}
.hf-region-label {
  left: 6px;
}
.hf-linked-label {
  right: 6px;
}
[data-kind="header"] .hf-region-label,
[data-kind="header"] .hf-linked-label {
  top: 0;
}
[data-kind="footer"] .hf-region-label,
[data-kind="footer"] .hf-linked-label {
  bottom: 1px;
}
.hf-margin-mark {
  position: absolute;
  height: 16px;
  border-left: 1px solid #b6b6b6;
}
/* Page crop marks already provide these corner strokes; avoid doubling their weight. */
#pages:not(.crop-marks-hidden) .hf-crop-aligned .hf-margin-mark {
  visibility: hidden;
}
[data-kind="header"] .hf-margin-mark {
  bottom: 0;
}
[data-kind="footer"] .hf-margin-mark {
  top: 0;
}
.hf-description {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
/* Keep all editing guides out of print, including contextual labels and the input bridge. */
@media print {
  .header-footer-editor {
    display: none;
  }
}
.header-footer-mode .document-image,
.header-footer-mode .document-shape {
  opacity: 0.4;
}
.header-footer-mode.hf-hide-body .document-image,
.header-footer-mode.hf-hide-body .document-shape {
  opacity: 0;
}
