/* 样式控件共享功能区高度；目录滚动独立于正文，不改变页面几何。 */
.styles-dialog,
.styles-pane,
.styles-menu {
  --styles-accent: #2f67ae;
  --styles-soft: #edf3fb;
  --styles-border: #d8e0ea;
}
.home-ribbon .styles-gallery-shell {
  display: flex;
  height: 72px;
  min-width: 0;
  width: 100%;
  border: 1px solid #d4d8de;
  background: #fff;
}
.home-ribbon .styles-gallery-shell .style-gallery {
  flex: 1;
  width: auto;
  height: 70px;
  min-width: 0;
  border: 0;
  overflow: hidden;
}
.home-ribbon .style-gallery .style-preview {
  flex: 1 0 78px;
  width: 96px;
  min-width: 78px;
  height: 66px;
  margin: 1px;
  padding: 4px 6px;
  box-shadow: none;
}
.home-ribbon .styles-expand {
  align-self: stretch;
  flex: 0 0 21px;
  width: 21px;
  min-width: 21px;
  height: auto;
  padding: 0;
  border: 0;
  border-left: 1px solid #d4d8de;
  border-radius: 0;
  background: #fafbfc;
}
.home-ribbon .styles-expand svg {
  width: 12px;
  height: 12px;
}
.style-preview {
  background: #fff;
  border: 1px solid transparent;
  border-radius: 0;
  color: #27313f;
  cursor: pointer;
  min-width: 0;
}
.style-sample {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.home-ribbon .style-gallery .style-sample,
.styles-expanded-gallery .style-sample,
.styles-pane-list.show-preview .style-sample {
  display: block;
  font-family: var(--style-font), "Microsoft YaHei", sans-serif;
  font-size: var(--style-size);
  font-weight: var(--style-weight);
  font-style: var(--style-slant);
  color: var(--style-color);
}
.home-ribbon .style-gallery .style-preview[aria-pressed="true"],
.styles-expanded-gallery .style-preview[aria-checked="true"] {
  border-color: #7595c2;
  background: #f5f8fc;
  box-shadow: none;
}
.style-preview:hover:not(:disabled),
.styles-pane-item:hover:not(:disabled) {
  border-color: #a7bedc;
  background: #edf3fb;
}
.style-preview:focus-visible,
.styles-pane-item:focus-visible {
  outline: 2px solid #477dbb;
  outline-offset: -2px;
}
.styles-menu {
  width: min(840px, calc(100vw - 16px));
  padding: 0;
  border: 1px solid #b8c0cb;
  border-radius: 3px;
  background: #fff;
  box-shadow: none;
  overflow: auto;
  overscroll-behavior: contain;
}
.styles-expanded-gallery {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  padding: 4px;
  gap: 2px;
}
.styles-menu .styles-expanded-gallery button {
  justify-content: center;
  width: 100%;
  height: 63px;
  min-width: 0;
  padding: 5px 6px;
  border: 1px solid transparent;
  border-radius: 0;
}
.styles-menu-actions {
  border-top: 1px solid #e3e9f1;
  padding: 5px;
  background: #fafbfd;
}
.styles-menu-actions button {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 11px;
  min-height: 35px;
  padding: 6px 10px;
  border-radius: 3px;
  text-align: left;
}
.styles-menu-actions svg {
  color: var(--styles-accent);
  flex: none;
}
.styles-pane {
  flex: 0 0 270px;
  width: 270px;
  min-width: 220px;
  max-width: 35vw;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-left: 1px solid #d9dfe7;
  background: #fafbfc;
  padding: 0;
}
.styles-pane[hidden] {
  display: none;
}
.styles-pane .sidebar-title {
  flex: none;
  margin: 0;
  padding: 10px 12px 8px;
  font-size: 14px;
  font-weight: 600;
  color: #263b56;
}
.styles-pane-heading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.styles-pane-heading svg,
.styles-clear svg {
  width: 18px;
  height: 18px;
  color: var(--styles-accent);
}
.styles-pane .sidebar-title button {
  width: 28px;
  height: 28px;
  padding: 5px;
  color: #758397;
}
.styles-pane .sidebar-title button svg {
  width: 16px;
  height: 16px;
}
.styles-pane .styles-clear {
  flex: none;
  justify-content: flex-start;
  height: 32px;
  text-align: left;
  margin: 0 10px 3px;
  padding: 5px 10px;
  border: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  color: #303b4b;
}
.styles-pane-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  padding: 0 8px 5px;
}
.styles-pane-item {
  width: 100%;
  min-height: 30px;
  padding: 5px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  content-visibility: auto;
  contain-intrinsic-size: auto 32px;
}
.styles-pane-item .style-sample {
  font-size: 13px;
  flex: 1;
}
.styles-pane-item .style-type {
  flex: none;
  width: 24px;
  text-align: right;
  font:
    italic 14px Georgia,
    serif;
  color: #697588;
}
.styles-pane-item[aria-pressed="true"] {
  border-color: #afc5e2;
  background: var(--styles-soft);
}
.styles-pane-list:not(.show-preview) .styles-pane-item[aria-pressed="true"] .style-sample {
  color: #235a9e;
  font-weight: 600;
}
.styles-pane-list.show-preview .styles-pane-item {
  min-height: 38px;
}
.styles-pane-options {
  flex: none;
  display: grid;
  gap: 7px;
  padding: 9px 13px;
  border-top: 1px solid #e3e6eb;
  font-size: 12px;
}
.styles-pane-options label {
  display: flex;
  align-items: center;
  gap: 6px;
}
.styles-pane-options input {
  margin: 0;
  accent-color: #356eb4;
}
.styles-pane-footer {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 11px;
  border-top: 1px solid #e3e9f1;
  background: #fff;
}
.styles-pane-footer button {
  border: 1px solid var(--styles-border);
  background: #fff;
  border-radius: 3px;
  padding: 5px;
  min-width: 30px;
  height: 30px;
  color: var(--styles-accent);
}
.styles-pane-footer button svg {
  width: 18px;
  height: 18px;
}
.styles-pane-footer .styles-options-button {
  margin-left: auto;
  font: inherit;
  font-size: 12px;
  gap: 5px;
  padding-inline: 9px;
}
.styles-dialog {
  /* 与段落、引用和插入窗口一致：清除 dialog UA 的居中 inset/margin，
     让 FloatingDialog 写入的 left/top 成为唯一位置来源，避免点击后跳位。 */
  position: fixed;
  inset: auto;
  margin: 0;
  z-index: 1100;
  width: min(420px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 1px solid #b7c5d7;
  border-radius: 5px;
  box-shadow: none;
  color: #263347;
  background: #fff;
}
.styles-dialog[open] {
  display: flex;
  flex-direction: column;
}
.styles-dialog [hidden] {
  display: none;
}
.styles-dialog::backdrop {
  background: rgb(30 45 66 / 13%);
}
.styles-dialog header {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 54px;
  gap: 12px;
  padding: 10px 13px 10px 16px;
  border-bottom: 1px solid #e5ebf3;
  background: #fafcfe;
  cursor: move;
  user-select: none;
  touch-action: none;
}
.styles-dialog-heading,
.styles-dialog-controls {
  display: flex;
  align-items: center;
}
.styles-dialog-heading {
  min-width: 0;
  gap: 10px;
}
.styles-dialog-badge {
  display: grid;
  place-items: center;
  flex: none;
  width: 30px;
  height: 30px;
  border: 1px solid #e0e9f6;
  border-radius: 4px;
  background: var(--styles-soft);
  color: var(--styles-accent);
}
.styles-dialog-badge svg {
  width: 21px;
  height: 21px;
}
.styles-dialog-controls {
  flex: none;
  gap: 3px;
}
.styles-dialog-grip {
  width: 16px;
  height: 20px;
  color: #a7b5c6;
}
.styles-dialog.is-dragging {
  user-select: none;
}
.styles-dialog.is-dragging header {
  cursor: grabbing;
}
.styles-dialog header:focus-visible {
  outline: 1px solid #8aaedc;
  outline-offset: -3px;
}
.styles-dialog h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.styles-dialog header button {
  width: 28px;
  height: 28px;
  min-height: 28px;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  color: #6d7e94;
  padding: 5px;
}
.styles-dialog header button svg {
  width: 16px;
  height: 16px;
}
.styles-dialog-body {
  min-height: 0;
  padding: 16px 18px 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
#styles-dialog-description {
  margin: 0 0 16px;
  color: #6b7c91;
  font-size: 12px;
  line-height: 1.6;
}
.styles-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 7px;
  font-size: 13px;
  color: #43566e;
  margin: 0 0 14px;
}
.styles-field:last-child {
  margin-bottom: 0;
}
.styles-field > span {
  min-width: 0;
  overflow-wrap: anywhere;
}
.styles-field input:not([type="checkbox"]),
.styles-field select {
  min-width: 0;
  width: 100%;
  height: 34px;
  border: 1px solid #b9c8da;
  border-radius: 4px;
  padding: 5px 10px;
  background: #fff;
  color: #263b56;
  font: inherit;
}
.styles-field input::placeholder {
  color: #8c9aab;
}
.styles-field-check {
  grid-template-columns: minmax(0, 1fr) 16px;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  margin-bottom: 7px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  background: #fafcfe;
}
.styles-field-check input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--styles-accent);
}
.styles-dialog input:focus,
.styles-dialog select:focus {
  outline: 2px solid #dde9f8;
  outline-offset: 1px;
  border-color: #638fc7;
}
.styles-dialog .styles-empty {
  padding: 18px 12px;
  margin: 0;
  border: 1px dashed #d5dfeb;
  border-radius: 4px;
  background: #fafcfe;
  color: #718299;
  text-align: center;
  font-size: 12px;
  line-height: 1.7;
}
.styles-dialog dl {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr);
  gap: 12px 16px;
  margin: 0;
  padding: 14px;
  border: 1px solid #e2e8f1;
  border-radius: 4px;
  background: #fafcfe;
  font-size: 13px;
}
.styles-dialog dt {
  color: #73839a;
}
.styles-dialog dd {
  margin: 0;
  overflow-wrap: anywhere;
  color: #304761;
}
.styles-dialog footer {
  flex: none;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 11px 16px;
  border-top: 1px solid #e5ebf3;
  background: #f8fafc;
}
.styles-dialog footer button {
  min-width: 74px;
  height: 32px;
  padding: 5px 14px;
  gap: 6px;
  border: 1px solid #c9d5e4;
  border-radius: 4px;
  background: #fff;
  color: #415873;
  font-size: 13px;
  font-weight: 500;
}
.styles-dialog footer button svg {
  width: 15px;
  height: 15px;
}
.styles-dialog footer .primary {
  min-width: 84px;
  background: var(--styles-accent);
  color: white;
  border-color: var(--styles-accent);
}
.styles-dialog button:hover:not(:disabled),
.styles-pane-footer button:hover:not(:disabled) {
  background: var(--styles-soft);
  border-color: #b3c9e5;
  color: #235b9e;
}
.styles-dialog footer .primary:hover:not(:disabled) {
  background: #245b9d;
  border-color: #245b9d;
  color: white;
}
.styles-dialog :is(button, input, select):focus-visible {
  outline: 2px solid #94b5df;
  outline-offset: 2px;
}
/* 仅过渡颜色，不动画窗口尺寸和坐标，避免影响拖动命中与输入性能。 */
.styles-dialog button,
.styles-field input,
.styles-field select,
.styles-pane-footer button {
  transition:
    background-color 120ms ease,
    border-color 120ms ease,
    color 120ms ease;
}
#styles-dialog-error {
  padding: 8px 10px;
  margin: 12px 0 0;
  border: 1px solid #efd4d7;
  border-radius: 4px;
  color: #9e3944;
  background: #fff7f8;
  font-size: 12px;
  line-height: 1.6;
}
@media (max-width: 1100px) {
  .styles-expanded-gallery {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .home-ribbon .styles-group {
    display: flex;
  }
}
@media (max-width: 760px) {
  .styles-pane {
    position: absolute;
    z-index: 7;
    right: 0;
    top: 0;
    bottom: 0;
    max-width: 80vw;
    width: 250px;
  }
  .styles-expanded-gallery {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (forced-colors: active) {
  .style-preview,
  .styles-pane-item {
    forced-color-adjust: auto;
  }
  .style-sample {
    color: CanvasText !important;
  }
  .style-preview[aria-pressed="true"],
  .style-preview[aria-checked="true"],
  .styles-pane-item[aria-pressed="true"] {
    outline: 1px solid Highlight;
  }
  .styles-dialog :is(button, input, select):focus-visible {
    outline-color: Highlight;
  }
}
@media (prefers-reduced-motion: reduce) {
  .styles-dialog button,
  .styles-field input,
  .styles-field select,
  .styles-pane-footer button {
    transition: none;
  }
}
