/* UI pack host (js/ui-packs.js). Every rule needs html[data-ui-pack] or the pack
 * root, so without a pack nothing here applies and the default UI is untouched.
 * The look is a light, Fluent-2-like ribbon; a pack may retune it with --ui-ribbon-*
 * tokens or its own scoped CSS. Document content is never styled here. */

/* ---- the default UI stays in the DOM, hidden by one root attribute ---- */
html[data-ui-pack] { --ribbon-h: var(--ui-pack-top-h, 164px) !important; }
html[data-ui-pack] :is(#ribbon, #statusbar, #editor-rail) { display: none !important; }
html[data-ui-pack] body.udoc-editor-shell { --editor-rail-width: 0px; }

#ui-pack-chrome {
  display: contents;
  --uip-font: "Segoe UI Variable Text", "Segoe UI", "微软雅黑", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
  --uip-bg: var(--ui-ribbon-bg, #f3f3f3);
  --uip-panel: var(--ui-ribbon-panel, #ffffff);
  --uip-ink: var(--ui-ribbon-ink, #242424);
  --uip-ink-2: var(--ui-ribbon-ink-2, #424242);
  --uip-ink-3: var(--ui-ribbon-ink-3, #616161);
  --uip-line: var(--ui-ribbon-line, #e0e0e0);
  --uip-stroke: var(--ui-ribbon-stroke, #d1d1d1);
  --uip-hover: var(--ui-ribbon-hover, #f0f0f0);
  --uip-press: var(--ui-ribbon-press, #e0e0e0);
  --uip-checked: var(--ui-ribbon-checked, #e8e8e8);
  --uip-accent: var(--ui-ribbon-accent, #0f6cbd);
  --uip-accent-weak: var(--ui-ribbon-accent-weak, #ebf3fc);
  --uip-radius: var(--ui-ribbon-radius, 4px);
  --uip-shadow: var(--ui-ribbon-shadow, 0 0 2px rgba(0, 0, 0, .12), 0 1px 2px rgba(0, 0, 0, .14));
  --uip-row: 24px;
}
:where(#ui-pack-chrome) :is(.uip-top, .uip-status, .uip-backstage, .uip-popup) {
  box-sizing: border-box;
  font: 12px/1.3 var(--uip-font);
  color: var(--uip-ink);
  -webkit-user-select: none; user-select: none;
}
:where(#ui-pack-chrome) :is(.uip-top, .uip-status, .uip-backstage, .uip-popup) * { box-sizing: border-box; }
:where(#ui-pack-chrome) input { -webkit-user-select: text; user-select: text; }
:where(#ui-pack-chrome) button { font: inherit; color: inherit; }
:where(#ui-pack-chrome) [hidden] { display: none !important; }

/* ---- icons ---- */
:where(#ui-pack-chrome) .uip-ic { position: relative; display: inline-grid; place-items: center; flex: none; width: 20px; height: 20px; }
:where(#ui-pack-chrome) .uip-ic svg { width: 100%; height: 100%; fill: currentColor; }
/* Outline icons of feature commands (fill="none", stroke="currentColor") stay outlines. */
:where(#ui-pack-chrome) .uip-ic svg[fill="none"] { fill: none; }
:where(#ui-pack-chrome) .uip-ic-letter { border-radius: 4px; background: var(--uip-press); font-size: 11px; font-weight: 600; }
:where(#ui-pack-chrome) .uip-chev { flex: none; width: 8px; height: 8px; margin: 0 1px; }
:where(#ui-pack-chrome) .uip-chev::before {
  content: ""; display: block; width: 5px; height: 5px; margin: 0 auto;
  border-right: 1.3px solid currentColor; border-bottom: 1.3px solid currentColor; transform: translateY(1px) rotate(45deg);
}

/* ---- top chrome: title bar, tabs, ribbon panel ---- */
:where(#ui-pack-chrome) .uip-top {
  position: fixed; inset: 0 0 auto 0; z-index: 40;
  display: flex; flex-direction: column;
  background: var(--uip-bg);
  border-bottom: 1px solid var(--uip-line);
}
:where(#ui-pack-chrome) .uip-titlebar { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; align-items: center; gap: 6px; height: 34px; padding: 0 8px 0 10px; }
:where(#ui-pack-chrome) .uip-app img { display: block; width: 18px; height: 18px; }
:where(#ui-pack-chrome) .uip-qat { display: flex; align-items: center; gap: 1px; padding-left: 4px; }
:where(#ui-pack-chrome) .uip-title { display: flex; align-items: center; justify-content: center; min-width: 0; color: var(--uip-ink-2); font-size: 12.5px; }
:where(#ui-pack-chrome) .uip-docname {
  min-width: 40px; max-width: 46vw; width: auto; field-sizing: content; height: 24px; padding: 0 6px;
  border: 1px solid transparent; border-radius: var(--uip-radius); background: transparent;
  color: var(--uip-ink); font: 600 12.5px var(--uip-font); text-align: center; text-overflow: ellipsis;
}
:where(#ui-pack-chrome) .uip-docname:hover { border-color: var(--uip-stroke); }
:where(#ui-pack-chrome) .uip-docname:focus { outline: none; border-color: var(--uip-stroke); border-bottom-color: var(--uip-accent); background: #fff; text-align: left; }
:where(#ui-pack-chrome) .uip-appname { flex: none; white-space: pre; }
:where(#ui-pack-chrome) .uip-titlebar-end { display: flex; align-items: center; gap: 4px; }
:where(#ui-pack-chrome) .uip-account {
  display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 50%;
  background: var(--uip-accent-weak); color: var(--uip-accent); font-weight: 600; cursor: pointer;
}
:where(#ui-pack-chrome) .uip-account:hover { background: var(--uip-press); }

:where(#ui-pack-chrome) .uip-tabs { display: flex; align-items: stretch; gap: 2px; height: 34px; padding: 0 8px; overflow-x: auto; scrollbar-width: none; }
:where(#ui-pack-chrome) .uip-tabs::-webkit-scrollbar { display: none; }
:where(#ui-pack-chrome) .uip-tab {
  position: relative; flex: none; padding: 0 10px; border: 0; border-radius: var(--uip-radius); background: transparent;
  color: var(--uip-ink-2); font-size: 13.5px; line-height: 34px; white-space: nowrap; cursor: pointer;
}
:where(#ui-pack-chrome) .uip-tab:hover { background: var(--uip-hover); color: var(--uip-ink); }
:where(#ui-pack-chrome) .uip-tab[aria-selected="true"] { color: var(--uip-ink); font-weight: 600; }
:where(#ui-pack-chrome) .uip-tab[aria-selected="true"]::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: 3px; height: 3px; border-radius: 2px; background: var(--uip-accent);
}
:where(#ui-pack-chrome) .uip-tab-file { color: var(--uip-ink); font-weight: 600; }
:where(#ui-pack-chrome) .uip-tab-context { color: var(--uip-accent); }
:where(#ui-pack-chrome) .uip-tab-context[aria-selected="true"] { color: var(--uip-accent); }
:where(#ui-pack-chrome) .uip-tab:focus-visible, :where(#ui-pack-chrome) button:focus-visible, :where(#ui-pack-chrome) input:focus-visible {
  outline: 2px solid var(--uip-accent); outline-offset: -2px;
}
:where(#ui-pack-chrome) .uip-tabs-fill { flex: 1; }
:where(#ui-pack-chrome) :is(.uip-pin, .uip-exit-reading) {
  flex: none; align-self: center; display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 8px;
  border: 0; border-radius: var(--uip-radius); background: transparent; cursor: pointer;
}
:where(#ui-pack-chrome) .uip-pin { width: 28px; padding: 0; justify-content: center; }
:where(#ui-pack-chrome) .uip-pin .uip-chev { transform: rotate(180deg); }
:where(#ui-pack-chrome.uip-collapsed) .uip-pin .uip-chev { transform: none; }
:where(#ui-pack-chrome) :is(.uip-pin, .uip-exit-reading):hover { background: var(--uip-hover); }
:where(#ui-pack-chrome) .uip-exit-reading { color: var(--uip-accent); font-weight: 600; }

/* ---- layout extras (docs/ui-pack.md): one tab row, File menu, command search, tab-row commands, toned tabs ---- */
:where(#ui-pack-chrome) .uip-tabrow { display: flex; align-items: center; gap: 4px; height: 36px; padding: 0 6px 0 8px; }
:where(#ui-pack-chrome) .uip-tabrow > .uip-tabs { flex: 1 1 auto; min-width: 0; height: 100%; padding: 0; }
:where(#ui-pack-chrome) .uip-tabrow > :is(.uip-tab-file, .uip-qat, .uip-search, .uip-tabs-end, .uip-pin) { flex: none; }
:where(#ui-pack-chrome) .uip-tab-file:has(> .uip-label) { display: inline-flex; align-items: center; gap: 4px; }
:where(#ui-pack-chrome) .uip-tabrow > .uip-tab-file { height: 28px; line-height: 28px; }
:where(#ui-pack-chrome) .uip-tab-file .uip-ic { width: 18px; height: 18px; }
:where(#ui-pack-chrome) .uip-tab-file[aria-expanded="true"] { background: var(--uip-press); }
:where(#ui-pack-chrome) :is(.uip-tabs-after, .uip-tabs-end) { display: flex; flex: none; align-items: center; gap: 4px; }
:where(#ui-pack-chrome) .uip-bar-sep { flex: none; width: 1px; height: 16px; margin: 0 3px; background: var(--uip-line); }
:where(#ui-pack-chrome) .uip-search {
  display: flex; flex: none; align-items: center; gap: 4px; width: 200px; height: 26px; padding: 0 8px;
  border: 1px solid var(--uip-stroke); border-radius: var(--uip-radius); background: #fff; color: var(--uip-ink-3);
}
:where(#ui-pack-chrome) .uip-search:focus-within { border-color: var(--uip-accent); }
:where(#ui-pack-chrome) .uip-search .uip-ic { width: 16px; height: 16px; }
:where(#ui-pack-chrome) .uip-search-input { flex: 1; min-width: 0; height: 100%; padding: 0; border: 0; background: transparent; color: var(--uip-ink); font: 12px var(--uip-font); outline: none; }
:where(#ui-pack-chrome) .uip-search-input::placeholder { color: var(--uip-ink-3); }
:where(#ui-pack-chrome) .uip-tab-toned { color: var(--uip-tab-tone); }
:where(#ui-pack-chrome) .uip-tab-toned[aria-selected="true"] { color: var(--uip-tab-tone); }
:where(#ui-pack-chrome) .uip-tab-toned[aria-selected="true"]::after { background: var(--uip-tab-tone); }

:where(#ui-pack-chrome) .uip-panel {
  margin: 0 8px 8px; border-radius: 8px; background: var(--uip-panel); box-shadow: var(--uip-shadow);
  overflow: hidden;
}
:where(#ui-pack-chrome) .uip-tabpanel { display: flex; align-items: stretch; min-width: max-content; height: 98px; padding: 4px 4px 0; }
:where(#ui-pack-chrome.uip-collapsed) .uip-panel { display: none; }
:where(#ui-pack-chrome.uip-collapsed.uip-floating) .uip-panel {
  display: block; position: absolute; left: 0; right: 0; top: 100%; z-index: 41; margin: 2px 8px 0;
  box-shadow: 0 8px 16px rgba(0, 0, 0, .14), 0 0 2px rgba(0, 0, 0, .12);
}
:where(#ui-pack-chrome.uip-reading) :is(.uip-tab, .uip-panel, .uip-pin) { display: none; }

/* ---- groups ---- */
:where(#ui-pack-chrome) .uip-group { position: relative; display: flex; flex-direction: column; flex: none; padding: 0 4px; }
:where(#ui-pack-chrome) .uip-group + .uip-group::before {
  content: ""; position: absolute; left: 0; top: 6px; bottom: 8px; width: 1px; background: var(--uip-line);
}
:where(#ui-pack-chrome) .uip-group-body {
  flex: 1; display: grid; grid-auto-flow: column; grid-template-rows: repeat(3, var(--uip-row));
  align-content: start; align-items: center; justify-items: start; column-gap: 2px; row-gap: 1px; padding: 0 2px;
}
:where(#ui-pack-chrome) .uip-group-body > .uip-span { grid-row: 1 / span 3; align-self: start; }
:where(#ui-pack-chrome) .uip-group-label {
  position: relative; display: flex; align-items: center; justify-content: center; height: 20px; padding: 0 16px;
  color: var(--uip-ink-3); font-size: 11.5px; white-space: nowrap;
}
:where(#ui-pack-chrome) .uip-launcher {
  position: absolute; right: 0; bottom: 2px; width: 16px; height: 16px; padding: 0; border: 0; border-radius: 3px;
  background: transparent; color: var(--uip-ink-3); cursor: pointer;
}
:where(#ui-pack-chrome) .uip-launcher::before {
  content: ""; position: absolute; left: 4px; top: 4px; width: 7px; height: 7px;
  border-right: 1.2px solid currentColor; border-bottom: 1.2px solid currentColor;
}
:where(#ui-pack-chrome) .uip-launcher::after {
  content: ""; position: absolute; left: 4px; top: 7px; width: 8px; height: 1.2px; background: currentColor; transform: rotate(45deg); transform-origin: 0 0;
}
:where(#ui-pack-chrome) .uip-launcher:hover { background: var(--uip-hover); color: var(--uip-ink); }
/* groupLabels: false — no caption row; the launcher sits in the group's bottom corner */
:where(#ui-pack-chrome) .uip-group > .uip-launcher { right: 1px; bottom: 1px; }
:where(#ui-pack-chrome) .uip-row { display: flex; align-items: center; gap: 1px; height: var(--uip-row); }
:where(#ui-pack-chrome) .uip-sep { width: 1px; height: 64px; margin: 4px 3px; background: var(--uip-line); }

/* ---- buttons ---- */
:where(#ui-pack-chrome) .uip-btn, :where(#ui-pack-chrome) .uip-split-arrow {
  display: inline-flex; align-items: center; gap: 4px; border: 1px solid transparent; border-radius: var(--uip-radius);
  background: transparent; color: var(--uip-ink); cursor: pointer; white-space: nowrap;
}
:where(#ui-pack-chrome) .uip-btn:hover:not(:disabled), :where(#ui-pack-chrome) .uip-split-arrow:hover:not(:disabled) { background: var(--uip-hover); }
:where(#ui-pack-chrome) .uip-btn:active:not(:disabled), :where(#ui-pack-chrome) .uip-split-arrow:active:not(:disabled) { background: var(--uip-press); }
:where(#ui-pack-chrome) .uip-btn:disabled, :where(#ui-pack-chrome) .uip-split-arrow:disabled { color: var(--uip-ink-3); opacity: .45; cursor: default; }
:where(#ui-pack-chrome) .uip-btn[aria-pressed="true"], :where(#ui-pack-chrome) .uip-btn.is-on { background: var(--uip-checked); border-color: var(--uip-stroke); }
:where(#ui-pack-chrome) .uip-btn[aria-pressed="mixed"] { background: linear-gradient(135deg, var(--uip-checked) 50%, transparent 50%); }
:where(#ui-pack-chrome) .uip-btn[aria-pressed="true"] .uip-ic, :where(#ui-pack-chrome) .uip-btn.is-on .uip-ic { color: var(--uip-accent); }
:where(#ui-pack-chrome) .uip-btn[aria-expanded="true"], :where(#ui-pack-chrome) .uip-split-arrow[aria-expanded="true"] { background: var(--uip-press); }
:where(#ui-pack-chrome) .uip-small { height: var(--uip-row); padding: 0 5px 0 3px; }
:where(#ui-pack-chrome) .uip-small.uip-compact { min-width: 28px; justify-content: center; padding: 0 3px; }
:where(#ui-pack-chrome) .uip-large {
  flex-direction: column; justify-content: flex-start; gap: 3px; min-width: 46px; max-width: 80px;
  height: calc(var(--uip-row) * 3 + 2px); padding: 4px 4px 2px;
}
:where(#ui-pack-chrome) .uip-large > .uip-ic { width: 32px; height: 32px; }
:where(#ui-pack-chrome) .uip-label { line-height: 14px; }
:where(#ui-pack-chrome) .uip-large .uip-label {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
  white-space: normal; text-align: center; overflow-wrap: anywhere;
}
:where(#ui-pack-chrome) .uip-large.uip-dropdown { padding-bottom: 0; }
:where(#ui-pack-chrome) .uip-large.uip-dropdown .uip-chev { margin-top: -2px; }
:where(#ui-pack-chrome) .uip-small.uip-dropdown .uip-chev { margin-left: 1px; }

/* split buttons: paste, colors */
:where(#ui-pack-chrome) .uip-split { display: inline-flex; border-radius: var(--uip-radius); }
:where(#ui-pack-chrome) .uip-split.uip-large { flex-direction: column; width: 52px; height: calc(var(--uip-row) * 3 + 2px); }
:where(#ui-pack-chrome) .uip-split.uip-large > .uip-btn { flex: none; height: 42px; min-width: 0; width: 100%; padding: 4px 0 0; border-radius: var(--uip-radius) var(--uip-radius) 0 0; }
:where(#ui-pack-chrome) .uip-split.uip-large > .uip-split-arrow {
  flex: 1; flex-direction: column; justify-content: flex-start; gap: 0; width: 100%; padding: 2px 0 0; border-radius: 0 0 var(--uip-radius) var(--uip-radius);
}
:where(#ui-pack-chrome) .uip-split.uip-small > .uip-btn { border-radius: var(--uip-radius) 0 0 var(--uip-radius); padding-right: 2px; }
:where(#ui-pack-chrome) .uip-split.uip-small > .uip-split-arrow { height: var(--uip-row); width: 14px; padding: 0; justify-content: center; border-radius: 0 var(--uip-radius) var(--uip-radius) 0; }
:where(#ui-pack-chrome) .uip-split:hover > :is(.uip-btn, .uip-split-arrow):not(:disabled) { border-color: var(--uip-line); }
:where(#ui-pack-chrome) .uip-color .uip-swatch { position: absolute; left: 1px; right: 1px; bottom: 0; height: 4px; border-radius: 1px; box-shadow: inset 0 0 0 .5px rgba(0, 0, 0, .25); }
:where(#ui-pack-chrome) .uip-color .uip-ic svg { height: 85%; margin-top: -3px; }
:where(#ui-pack-chrome) .uip-color.uip-large .uip-swatch { height: 5px; }

/* combo boxes: font, size */
:where(#ui-pack-chrome) .uip-combo {
  display: inline-flex; align-items: stretch; height: var(--uip-row); border: 1px solid var(--uip-stroke); border-bottom-color: #616161;
  border-radius: var(--uip-radius); background: #fff; overflow: hidden;
}
:where(#ui-pack-chrome) .uip-combo:focus-within { border-bottom: 2px solid var(--uip-accent); }
:where(#ui-pack-chrome) .uip-combo-input { min-width: 0; height: 100%; padding: 0 6px; border: 0; background: transparent; color: var(--uip-ink); font: 12px var(--uip-font); outline: none; }
:where(#ui-pack-chrome) .uip-combo-font .uip-combo-input { width: 132px; }
:where(#ui-pack-chrome) .uip-combo-size .uip-combo-input { width: 40px; }
:where(#ui-pack-chrome) .uip-combo-arrow { display: grid; place-items: center; width: 18px; padding: 0; border: 0; background: transparent; cursor: pointer; }
:where(#ui-pack-chrome) .uip-combo-arrow:hover:not(:disabled) { background: var(--uip-hover); }
:where(#ui-pack-chrome) .uip-combo :disabled { opacity: .5; cursor: default; }
:where(#ui-pack-chrome) .uip-row > .uip-combo + .uip-combo { margin-left: 4px; }
:where(#ui-pack-chrome) .uip-row > .uip-combo:last-of-type { margin-right: 4px; }

/* spinners: angle, width, height */
:where(#ui-pack-chrome) .uip-spin { display: inline-flex; align-items: center; gap: 4px; height: var(--uip-row); color: var(--uip-ink-2); }
:where(#ui-pack-chrome) .uip-spin-label { min-width: 26px; }
:where(#ui-pack-chrome) .uip-spin-input {
  width: 56px; height: 22px; padding: 0 6px; border: 1px solid var(--uip-stroke); border-bottom-color: #616161; border-radius: var(--uip-radius);
  background: #fff; color: var(--uip-ink); font: 12px var(--uip-font); text-align: right;
}
:where(#ui-pack-chrome) .uip-spin-input:focus { outline: none; border-bottom: 2px solid var(--uip-accent); }
:where(#ui-pack-chrome) .uip-spin-input:disabled { opacity: .5; }

/* galleries: styles, table styles */
:where(#ui-pack-chrome) .uip-gallery {
  display: flex; align-items: stretch; height: calc(var(--uip-row) * 3 + 2px);
  border: 1px solid var(--uip-line); border-radius: var(--uip-radius); background: #fff;
}
:where(#ui-pack-chrome) .uip-gallery-items { display: flex; gap: 2px; padding: 3px; max-width: 420px; overflow: hidden; }
:where(#ui-pack-chrome) .uip-gallery-more { width: 18px; padding: 0; border: 0; border-left: 1px solid var(--uip-line); background: transparent; cursor: pointer; }
:where(#ui-pack-chrome) .uip-gallery-more:hover { background: var(--uip-hover); }
:where(#ui-pack-chrome) .uip-gallery.is-disabled { opacity: .5; }
:where(#ui-pack-chrome) .uip-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: space-between; flex: none; width: 72px; height: 100%;
  padding: 4px 2px 3px; border: 1px solid transparent; border-radius: var(--uip-radius); background: transparent; cursor: pointer;
}
:where(#ui-pack-chrome) .uip-tile:hover:not(:disabled) { background: var(--uip-hover); border-color: var(--uip-line); }
:where(#ui-pack-chrome) .uip-tile[aria-selected="true"] { border-color: var(--uip-accent); background: var(--uip-accent-weak); }
:where(#ui-pack-chrome) .uip-tile-label { max-width: 100%; overflow: hidden; color: var(--uip-ink-2); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
:where(#ui-pack-chrome) .uip-tile-preview { display: block; max-width: 100%; overflow: hidden; color: var(--uip-ink); line-height: 1.1; white-space: nowrap; }
:where(#ui-pack-chrome) .uip-gallery-styles .uip-tile-preview { font: 14px "Times New Roman", "宋体", serif; }
:where(#ui-pack-chrome) [data-preview="h1"] { font: 600 17px var(--uip-font) !important; color: #1f3864 !important; }
:where(#ui-pack-chrome) [data-preview="h2"] { font: 600 15px var(--uip-font) !important; color: #2f5496 !important; }
:where(#ui-pack-chrome) [data-preview="h3"] { font: 600 13px var(--uip-font) !important; color: #1f3763 !important; }
:where(#ui-pack-chrome) [data-preview="quote"] { font-style: italic !important; color: var(--uip-ink-2) !important; border-left: 2px solid var(--uip-stroke); padding-left: 4px; }
:where(#ui-pack-chrome) [data-preview="code"] { font: 12px "Cascadia Mono", Consolas, monospace !important; background: #f5f5f5; padding: 0 3px; border-radius: 2px; }
/* table style previews: a 3×3 grid of cells */
:where(#ui-pack-chrome) .uip-gallery-tableStyles .uip-tile { width: 54px; }
:where(#ui-pack-chrome) .uip-gallery-tableStyles .uip-tile-preview { display: grid; grid-template-columns: repeat(3, 12px); grid-auto-rows: 7px; gap: 1px; padding: 1px; background: #b4b4b4; }
:where(#ui-pack-chrome) .uip-gallery-tableStyles .uip-tile-preview i { background: #fff; }
:where(#ui-pack-chrome) [data-preview="header"] i:nth-child(-n+3), :where(#ui-pack-chrome) [data-preview="accent"] i:nth-child(-n+3) { background: #4472c4; }
:where(#ui-pack-chrome) [data-preview="banded"] i:nth-child(n+4):nth-child(-n+6) { background: #dbe5f1; }
:where(#ui-pack-chrome) [data-preview="accent"] i:nth-child(n+7) { background: #dbe5f1; }

/* ---- popups ---- */
:where(#ui-pack-chrome) .uip-popup {
  position: fixed; z-index: 1100; min-width: 168px; max-width: min(420px, 96vw); max-height: min(70vh, 560px); overflow: auto;
  padding: 4px; border-radius: 8px; background: #fff;
  box-shadow: 0 8px 16px rgba(0, 0, 0, .14), 0 0 2px rgba(0, 0, 0, .12);
}
:where(#ui-pack-chrome) .uip-popup hr { height: 1px; margin: 4px 0; border: 0; background: var(--uip-line); }
:where(#ui-pack-chrome) .uip-option {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 32px; padding: 4px 10px 4px 8px;
  border: 0; border-radius: var(--uip-radius); background: transparent; color: var(--uip-ink); text-align: left; cursor: pointer;
}
:where(#ui-pack-chrome) .uip-option:hover:not(:disabled), :where(#ui-pack-chrome) .uip-option:focus-visible { background: var(--uip-hover); outline: none; }
:where(#ui-pack-chrome) .uip-option[aria-checked="true"] { background: var(--uip-accent-weak); }
:where(#ui-pack-chrome) .uip-option[aria-checked="true"]::after { content: "\2713"; margin-left: auto; color: var(--uip-accent); font-weight: 600; }
:where(#ui-pack-chrome) .uip-option:disabled { cursor: default; color: var(--uip-ink-3); }
:where(#ui-pack-chrome) .uip-option-text { display: flex; flex-direction: column; min-width: 0; }
:where(#ui-pack-chrome) .uip-option-label { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
:where(#ui-pack-chrome) .uip-option-text small { overflow: hidden; color: var(--uip-ink-3); font-size: 11.5px; text-overflow: ellipsis; white-space: nowrap; }
:where(#ui-pack-chrome) .uip-option-group { padding: 8px 10px 2px; color: var(--uip-ink-3); font-size: 11.5px; font-weight: 600; }
:where(#ui-pack-chrome) .uip-option-note { margin: 0; padding: 8px 10px; color: var(--uip-ink-3); font-size: 12px; }
:where(#ui-pack-chrome) .uip-popup-font { width: 280px; }
:where(#ui-pack-chrome) .uip-popup-font .uip-option-label { font-size: 14px; }
:where(#ui-pack-chrome) .uip-popup-size { min-width: 120px; }
:where(#ui-pack-chrome) .uip-option-key { margin-left: auto; padding-left: 16px; color: var(--uip-ink-3); font-size: 11.5px; }
:where(#ui-pack-chrome) .uip-file-menu { min-width: 220px; }
:where(#ui-pack-chrome) .uip-search-popup { min-width: 240px; }
:where(#ui-pack-chrome) .uip-search-popup .uip-option.is-active { background: var(--uip-accent-weak); }
:where(#ui-pack-chrome) .uip-gallery-popup { display: grid; grid-template-columns: repeat(4, auto); gap: 2px; }
:where(#ui-pack-chrome) .uip-gallery-popup .uip-tile { height: 64px; }

/* ---- status bar ---- */
:where(#ui-pack-chrome) .uip-status {
  position: relative; z-index: 2; display: flex; align-items: center; justify-content: space-between; flex: 0 0 28px; height: 28px;
  padding: 0 10px; border-top: 1px solid var(--uip-line); background: var(--uip-bg); color: var(--uip-ink-2); white-space: nowrap; overflow: hidden;
}
:where(#ui-pack-chrome) :is(.uip-status-start, .uip-status-end) { display: flex; align-items: center; gap: 2px; min-width: 0; }
:where(#ui-pack-chrome) .uip-status-item { height: 24px; padding: 0 8px; border: 0; border-radius: var(--uip-radius); background: transparent; cursor: pointer; }
:where(#ui-pack-chrome) .uip-status-item:hover { background: var(--uip-hover); color: var(--uip-ink); }
:where(#ui-pack-chrome) .uip-status-item.is-on { color: var(--uip-accent); }
/* Fixed status slots (owner 2026-11-12): sized for the longest text, counts in 1k / 1m / 1b. */
:where(#ui-pack-chrome) .uip-status-item { font-variant-numeric: tabular-nums; white-space: nowrap; text-align: left; }
:where(#ui-pack-chrome) .uip-status-item[data-ui-cmd="pageInfo"] { min-width: calc(11.6em + 16px); }
:where(#ui-pack-chrome) .uip-status-item[data-ui-cmd="wordCount"] { min-width: calc(7.2em + 16px); }
:where(#ui-pack-chrome) .uip-status-item[data-ui-cmd="statusProofing"] { min-width: calc(7em + 16px); }
:where(#ui-pack-chrome) .uip-status-item[data-ui-cmd="statusAccessibility"] { min-width: calc(12.3em + 16px); }
:where(#ui-pack-chrome) .uip-status-sep { flex: none; width: 1px; height: 14px; margin: 0 4px; background: var(--uip-line); }
:where(#ui-pack-chrome) .uip-status-views { display: flex; gap: 1px; margin-right: 8px; }
:where(#ui-pack-chrome) .uip-status-icon {
  display: grid; place-items: center; width: 26px; height: 24px; padding: 0; border: 0; border-radius: var(--uip-radius); background: transparent; cursor: pointer;
}
:where(#ui-pack-chrome) .uip-status-icon .uip-ic { width: 18px; height: 18px; }
:where(#ui-pack-chrome) .uip-status-icon:hover { background: var(--uip-hover); color: var(--uip-ink); }
:where(#ui-pack-chrome) .uip-status-icon[aria-pressed="true"] { background: var(--uip-checked); color: var(--uip-accent); }
:where(#ui-pack-chrome) .uip-status-zoom { display: flex; align-items: center; gap: 2px; }
:where(#ui-pack-chrome) :is(.uip-minus, .uip-plus) { position: relative; display: block; width: 10px; height: 10px; }
:where(#ui-pack-chrome) :is(.uip-minus, .uip-plus)::before { content: ""; position: absolute; left: 0; right: 0; top: 4.4px; height: 1.2px; background: currentColor; }
:where(#ui-pack-chrome) .uip-plus::after { content: ""; position: absolute; top: 0; bottom: 0; left: 4.4px; width: 1.2px; background: currentColor; }
:where(#ui-pack-chrome) .uip-zoom-slider { width: 110px; height: 16px; margin: 0 2px; accent-color: var(--uip-ink-3); }
:where(#ui-pack-chrome) .uip-zoom-value { min-width: 44px; height: 24px; padding: 0 6px; border: 0; border-radius: var(--uip-radius); background: transparent; text-align: right; cursor: pointer; }
:where(#ui-pack-chrome) .uip-zoom-value:hover { background: var(--uip-hover); }

/* ---- backstage (File) ---- */
:where(#ui-pack-chrome) .uip-backstage { position: fixed; inset: 0; z-index: 1200; display: flex; background: #fff; }
/* The File menu's list is the product colour with white labels and icons, as a classic File menu;
   it never shows a scrollbar (owner 2026-11-09) and its labels end in an ellipsis. */
:where(#ui-pack-chrome) .uip-bs-nav {
  display: flex; flex-direction: column; gap: 2px; width: 200px; flex: none; padding: 10px 8px;
  background: var(--ui-backstage-nav, var(--uip-accent)); color: #fff; overflow: hidden auto; scrollbar-width: none;
}
:where(#ui-pack-chrome) .uip-bs-nav::-webkit-scrollbar { display: none; }
:where(#ui-pack-chrome) .uip-bs-nav :is(.uip-bs-item, .uip-bs-back) { color: #fff; }
:where(#ui-pack-chrome) .uip-bs-nav .uip-bs-item > span:not(.uip-ic) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
:where(#ui-pack-chrome) .uip-bs-nav .uip-ic svg [fill-opacity] { display: none; }
:where(#ui-pack-chrome) .uip-bs-nav .uip-ic svg [fill]:not([fill="none"]) { fill: currentColor; }
:where(#ui-pack-chrome) .uip-bs-sep { flex: none; width: calc(100% - 16px); height: 1px; margin: 6px 8px; border: 0; background: rgba(255, 255, 255, .3); }
:where(#ui-pack-chrome) .uip-bs-back {
  display: grid; place-items: center; width: 36px; height: 36px; margin: 0 0 10px 2px; padding: 0; border: 0; border-radius: 50%;
  background: transparent; cursor: pointer;
}
:where(#ui-pack-chrome) .uip-bs-back:hover { background: rgba(255, 255, 255, .16); }
:where(#ui-pack-chrome) .uip-bs-item {
  position: relative; display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 12px; border: 0; border-radius: 6px;
  background: transparent; font-size: 14px; text-align: left; cursor: pointer;
}
:where(#ui-pack-chrome) .uip-bs-item:hover:not(:disabled) { background: rgba(255, 255, 255, .16); }
:where(#ui-pack-chrome) .uip-bs-item:disabled { opacity: .45; cursor: default; }
:where(#ui-pack-chrome) .uip-bs-item[aria-current="true"] { background: rgba(255, 255, 255, .24); font-weight: 600; }
:where(#ui-pack-chrome) .uip-bs-foot { margin-top: auto; }
:where(#ui-pack-chrome) .uip-bs-foot ~ .uip-bs-foot { margin-top: 0; }
:where(#ui-pack-chrome) .uip-bs-main { flex: 1; min-width: 0; overflow-y: auto; padding: 28px 44px 40px; }
:where(#ui-pack-chrome) .uip-bs-main h1 { margin: 0 0 20px; font-size: 28px; font-weight: 600; }
:where(#ui-pack-chrome) .uip-bs-main h2 { margin: 28px 0 10px; font-size: 16px; font-weight: 600; }
:where(#ui-pack-chrome) .uip-bs-lead { margin: -8px 0 18px; color: var(--uip-ink-2); font-size: 13px; }
:where(#ui-pack-chrome) .uip-bs-tiles { display: flex; flex-wrap: wrap; gap: 12px; }
:where(#ui-pack-chrome) .uip-bs-cloud { display: flex; height: max(360px, calc(100vh - 300px)); margin-top: 20px; max-width: 1100px; }
:where(#ui-pack-chrome) .uip-bs-tile {
  flex-direction: column; justify-content: center; gap: 10px; width: 148px; min-height: 112px; padding: 12px;
  border: 1px solid var(--uip-line); border-radius: 8px; background: #fff; text-align: center;
}
:where(#ui-pack-chrome) .uip-bs-tile:hover:not(:disabled) { border-color: var(--uip-stroke); background: var(--uip-hover); }
:where(#ui-pack-chrome) .uip-bs-tile .uip-ic { width: 32px; height: 32px; color: var(--uip-accent); }
:where(#ui-pack-chrome) .uip-bs-tile .uip-option-text { align-items: center; }
:where(#ui-pack-chrome) .uip-bs-tile .uip-option-label { white-space: normal; }
:where(#ui-pack-chrome) .uip-bs-list { display: flex; flex-direction: column; gap: 2px; max-width: 760px; }
:where(#ui-pack-chrome) .uip-bs-row { min-height: 44px; }
:where(#ui-pack-chrome) .uip-bs-info { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 6px 16px; margin: 24px 0 0; color: var(--uip-ink-2); font-size: 13px; }
:where(#ui-pack-chrome) .uip-bs-info dd { margin: 0; color: var(--uip-ink); }

@media (max-width: 760px) {
  :where(#ui-pack-chrome) .uip-titlebar { grid-template-columns: auto minmax(0, 1fr) auto; }
  :where(#ui-pack-chrome) .uip-app { display: none; }
  :where(#ui-pack-chrome) .uip-appname { display: none; }
  :where(#ui-pack-chrome) .uip-panel { margin: 0 4px 6px; }
  :where(#ui-pack-chrome) .uip-bs-nav { width: 64px; }
  :where(#ui-pack-chrome) .uip-bs-item > span:not(.uip-ic) { display: none; }
  :where(#ui-pack-chrome) .uip-bs-main { padding: 20px 18px; }
}
@media print { :where(#ui-pack-chrome) :is(.uip-top, .uip-status, .uip-backstage, .uip-popup) { display: none !important; } }

/* ---- UI 风格 lives in the 界面主题 dialog (js/ui-themes.js), styled by its rules ---- */
#udoc-theme-dialog .udoc-pack-notice.is-error { background: rgba(255, 59, 48, .10); color: var(--ui-danger); }

/* ---- symbol picker grid (cmd.grid) ---- */
:where(#ui-pack-chrome) .uip-option-grid { display: grid; grid-template-columns: repeat(12, 30px); gap: 1px; max-height: 260px; overflow: auto; }
:where(#ui-pack-chrome) .uip-option-grid .uip-option { justify-content: center; height: 30px; min-height: 0; padding: 0; }
:where(#ui-pack-chrome) .uip-option-grid .uip-option-label { font-size: 16px; }
:where(#ui-pack-chrome) .uip-option-grid .uip-option[aria-checked="true"]::after { content: none; }

/* ---- font settings dialog (js/doc-features.js) ---- */
#udoc-font-dialog { width: min(520px, 94vw); margin: auto; padding: 0; border: 0; border-radius: var(--ui-r-sheet); background: var(--ui-bg); box-shadow: var(--ui-sheet-shadow); font: 13px/1.45 var(--ui-sheet-font); color: var(--ui-ink); }
#udoc-font-dialog::backdrop { background: var(--ui-scrim); }
#udoc-font-dialog header { display: flex; align-items: center; height: 48px; padding: 0 20px; }
#udoc-font-dialog h2 { margin: 0; font-size: 15px; font-weight: 600; }
#udoc-font-dialog .ufd-advanced { margin: 12px 20px 0; }
#udoc-font-dialog .ufd-advanced .ufd-grid { padding: 8px 0 0; }
#udoc-font-dialog .ufd-advanced summary { cursor: pointer; color: var(--ui-ink-2); font-size: 12px; }
#udoc-font-dialog .ufd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; padding: 0 20px; }
#udoc-font-dialog .ufd-grid label { display: flex; flex-direction: column; gap: 4px; color: var(--ui-ink-2); font-size: 12px; }
#udoc-font-dialog .ufd-grid label:has(input[type="color"]) { flex-direction: row; flex-wrap: wrap; align-items: center; }
#udoc-font-dialog select, #udoc-font-dialog input[type="number"] { height: 30px; padding: 0 8px; border: .5px solid var(--ui-line); border-radius: 7px; background: var(--ui-surface); color: var(--ui-ink); font: inherit; }
#udoc-font-dialog input[type="color"] { width: 44px; height: 28px; padding: 0; border: .5px solid var(--ui-line); border-radius: 6px; background: none; }
#udoc-font-dialog fieldset { display: grid; grid-template-columns: repeat(3, auto); gap: 6px 12px; margin: 14px 20px 0; padding: 8px 12px 10px; border: .5px solid var(--ui-line); border-radius: 9px; }
#udoc-font-dialog legend { padding: 0 4px; color: var(--ui-ink-2); font-size: 12px; }
#udoc-font-dialog fieldset label { display: flex; align-items: center; gap: 5px; }
#udoc-font-dialog .ufd-preview { margin: 14px 20px 0; padding: 14px; border: .5px solid var(--ui-line); border-radius: 9px; text-align: center; font-size: 16px; }
#udoc-font-dialog footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px 16px; }
#udoc-font-dialog footer button { height: 32px; padding: 0 18px; border: .5px solid var(--ui-line); border-radius: 8px; background: var(--ui-bg); color: var(--ui-ink); font: inherit; }
#udoc-font-dialog footer .ufd-primary { border-color: transparent; background: var(--ui-accent); color: var(--ui-accent-ink); }

/* ---- document view options (js/doc-features.js): dark pages, document grid; never printed ---- */
@media screen {
  html[data-udoc-dark-pages] #pages .page { filter: invert(.9) hue-rotate(180deg); }
  html[data-udoc-dark-pages] #pages .page :is(img, video, canvas, iframe, picture) { filter: invert(1) hue-rotate(180deg); }
  html[data-udoc-doc-grid] #pages .page-content {
    background-image: linear-gradient(to bottom, rgba(0, 120, 215, .22) 1px, transparent 1px),
      linear-gradient(to right, rgba(0, 120, 215, .12) 1px, transparent 1px);
    background-size: 100% 1.6em, 1em 100%;
  }
}

/* ---- narrower windows: the inline gallery shows fewer tiles so the last Home groups stay in view ---- */
@media (max-width: 1440px) { :where(#ui-pack-chrome) .uip-gallery-items { max-width: 286px; } }

/* ---- fitting (js/ui-packs.js fitRibbon): no ribbon scrolls sideways; groups shrink from the right.
   uip-fit-1: large buttons become small ones, three to a column. uip-fit-2: small buttons keep only their
   icons. uip-fit-3: the group is one button that opens the whole group below it. ---- */
:where(#ui-pack-chrome) .uip-fit-toggle { display: none; }
:where(#ui-pack-chrome) .uip-group.uip-fit-1:not(.uip-fit-3) > .uip-group-body > .uip-span:is(.uip-large, .uip-split) { grid-row: auto; align-self: center; }
:where(#ui-pack-chrome) .uip-group.uip-fit-1:not(.uip-fit-3) > .uip-group-body > .uip-large,
:where(#ui-pack-chrome) .uip-group.uip-fit-1:not(.uip-fit-3) > .uip-group-body > .uip-split.uip-large > .uip-btn {
  flex-direction: row; justify-content: flex-start; gap: 4px; min-width: 0; max-width: none; width: auto; height: var(--uip-row); padding: 0 5px 0 3px;
}
:where(#ui-pack-chrome) .uip-group.uip-fit-1:not(.uip-fit-3) > .uip-group-body .uip-large > .uip-ic { width: 20px; height: 20px; }
:where(#ui-pack-chrome) .uip-group.uip-fit-1:not(.uip-fit-3) > .uip-group-body .uip-large .uip-label { display: block; white-space: nowrap; text-align: left; }
:where(#ui-pack-chrome) .uip-group.uip-fit-1:not(.uip-fit-3) > .uip-group-body .uip-large.uip-dropdown .uip-chev { margin-top: 0; }
:where(#ui-pack-chrome) .uip-group.uip-fit-1:not(.uip-fit-3) > .uip-group-body > .uip-split.uip-large { flex-direction: row; width: auto; height: var(--uip-row); }
:where(#ui-pack-chrome) .uip-group.uip-fit-1:not(.uip-fit-3) > .uip-group-body > .uip-split.uip-large > .uip-btn { flex: none; padding: 0 1px 0 3px; border-radius: var(--uip-radius) 0 0 var(--uip-radius); }
:where(#ui-pack-chrome) .uip-group.uip-fit-1:not(.uip-fit-3) > .uip-group-body > .uip-split.uip-large > .uip-split-arrow {
  flex: none; flex-direction: row; gap: 2px; width: auto; height: var(--uip-row); padding: 0 3px 0 1px; border-radius: 0 var(--uip-radius) var(--uip-radius) 0;
}
:where(#ui-pack-chrome) .uip-group.uip-fit-1:not(.uip-fit-3) .uip-gallery-items { max-width: 220px; }
:where(#ui-pack-chrome) .uip-group.uip-fit-2:not(.uip-fit-3) > .uip-group-body :is(.uip-small, .uip-large):not(.uip-compact) > .uip-label,
:where(#ui-pack-chrome) .uip-group.uip-fit-2:not(.uip-fit-3) > .uip-group-body .uip-split.uip-large > .uip-split-arrow > .uip-label { display: none; }
:where(#ui-pack-chrome) .uip-group.uip-fit-2:not(.uip-fit-3) .uip-gallery-items { max-width: 150px; }
:where(#ui-pack-chrome) .uip-group.uip-fit-3 > .uip-fit-toggle { display: inline-flex; max-width: 76px; margin-top: 0; }
:where(#ui-pack-chrome) .uip-group.uip-fit-3 > :is(.uip-group-label, .uip-launcher) { display: none; }
:where(#ui-pack-chrome) .uip-group.uip-fit-3:not(.uip-fit-open) > .uip-group-body { display: none; }
:where(#ui-pack-chrome) .uip-group.uip-fit-3.uip-fit-open > .uip-group-body {
  position: fixed; z-index: 1090; flex: none; height: auto; padding: 6px 8px; border: 1px solid var(--uip-line); border-radius: 8px;
  background: var(--uip-panel); box-shadow: 0 8px 16px rgba(0, 0, 0, .14), 0 0 2px rgba(0, 0, 0, .12);
}

/* The last separator of the File menu goes down with the account and options below it. */
:where(#ui-pack-chrome) .uip-bs-nav > .uip-bs-sep:last-of-type { margin-top: auto; }
:where(#ui-pack-chrome) .uip-bs-nav > .uip-bs-sep:last-of-type ~ .uip-bs-foot { margin-top: 0; }

/* Menus and File pages that are taller than the window scroll without a scrollbar (owner 2026-11-09: no 滑杆 anywhere). */
:where(#ui-pack-chrome) :is(.uip-popup, .uip-bs-main) { scrollbar-width: none; }
:where(#ui-pack-chrome) :is(.uip-popup, .uip-bs-main)::-webkit-scrollbar { display: none; }
