/* A4 chrome color restore + Layout scoped Word-map fixes.
   Keep the app's expected blue titlebar and white tabbar/ribbon. */

.shell--a4-v2-chrome {
  --a4-blue: #4c6ef5;
  --a4-blue-strong: #3156e7;
  --a4-titlebar-bg: #4c6ef5;
  --a4-titlebar-color: #ffffff;
  --a4-tabbar-bg: #ffffff;
  --a4-tabbar-border: #dfe3ec;
  --a4-ribbon-bg: #f6f7fb;
  --a4-ribbon-surface-bg: #f6f7fb;
  --a4-ribbon-separator-color: #dfe3ec;
  --a4-ribbon-caption-color: #6f7580;
  --a4-ribbon-command-color: #1f2328;
  --a4-toolbar-word-control: #ffffff;
  --a4-toolbar-word-control-border: #cfd6e3;
  --a4-toolbar-word-text: #1f2328;
  --a4-toolbar-word-muted: #687386;
  --a4-toolbar-word-separator: #dfe3ec;
  --a4-toolbar-word-disabled: #8d97a8;
  --a4-toolbar-word-hover-bg: rgba(76, 110, 245, 0.08);
  --a4-toolbar-word-hover-border: rgba(76, 110, 245, 0.24);
  --a4-toolbar-word-field: #ffffff;
  --a4-toolbar-word-field-border: #c8d0db;
  --a4-toolbar-control: #ffffff;
  --a4-toolbar-control-border: #cfd6e3;
  --a4-toolbar-text: #1f2328;
  --a4-toolbar-disabled: #8d97a8;
  --a4-toolbar-hover-bg: rgba(76, 110, 245, 0.08);
  --a4-toolbar-hover-border: rgba(76, 110, 245, 0.24);
  --a4-toolbar-field: #ffffff;
  --a4-toolbar-field-border: #c8d0db;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon .shell-tabbar__tabs .shell-tab,
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon .shell-tabbar__tabs .shell-tab:not(.shell-tab--active),
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon .shell-tabbar__tabs .shell-tab--active,
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon
  .shell-tabbar__tabs
  .shell-tab.segmented-control__button--active {
  color: #1f2328 !important;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon .shell-titlebar {
  background: var(--a4-titlebar-bg) !important;
  color: #ffffff !important;
  border-bottom-color: rgba(255, 255, 255, 0.16) !important;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon .shell-tabbar {
  background: #ffffff !important;
  color: #1f2328 !important;
  border-bottom-color: #dfe3ec !important;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon .shell-ribbon {
  background: #f6f7fb !important;
  color: #1f2328 !important;
  border-bottom-color: #dfe3ec !important;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon .shell-titlebar,
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon .shell-titlebar__left,
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon .shell-titlebar__center,
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon .shell-titlebar__right,
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon .shell-titlebar button,
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon .shell-titlebar .shell-search,
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon .shell-titlebar input {
  color: #ffffff !important;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon .shell-titlebar .shell-pill-button {
  border-color: rgba(255, 255, 255, 0.5) !important;
  background: rgba(255, 255, 255, 0.14) !important;
  color: #ffffff !important;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon .shell-titlebar .shell-pill-button--accent {
  border-color: rgba(255, 255, 255, 0.7) !important;
  background: rgba(255, 255, 255, 0.18) !important;
  color: #ffffff !important;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-layout-tab
  .shell-ribbon__group--layout-breaks
  :is(
    .shell-ribbon__page-layout-button--breaks,
    .shell-ribbon__page-layout-button--line-numbers,
    .shell-ribbon__page-layout-button--hyphenation
  ):disabled {
  border-color: transparent !important;
  background: transparent !important;
  color: var(--a4-toolbar-word-text) !important;
  opacity: 1 !important;
}

/* References tab Word-parity: commands look enabled even while deferred;
   only the four buttons Word actually grays stay muted. */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-references-tab
  .shell-ribbon
  :is(
    .shell-ribbon__references-big,
    .shell-ribbon__references-tile,
    .shell-ribbon__references-line,
    .shell-ribbon__references-action
  ):disabled {
  color: var(--a4-toolbar-word-text) !important;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-references-tab
  .shell-ribbon
  .shell-ribbon__references-line--word-muted:disabled {
  color: var(--a4-toolbar-word-disabled) !important;
}

/* Footnotes «Следующая сноска ▾» split control (Figma frame 21809:82734,
   row 21809:83788): a label LightButton (next-footnote) + a separate 16px
   chevron LightButton acting as the dropdown disclosure. The disclosure menu
   holds the «Следующая концевая сноска» (next-endnote) command, folded out of
   the visible 2-row stack while keeping its id/handler. */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-references-tab
  .shell-ribbon
  .shell-ribbon__references-split {
  display: flex;
  align-items: center;
  gap: 6px;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-references-tab
  .shell-ribbon
  .shell-ribbon__references-split-main {
  width: max-content;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-references-tab
  .shell-ribbon
  .shell-ribbon__references-disclosure {
  position: relative;
  display: inline-flex;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-references-tab
  .shell-ribbon
  .shell-ribbon__references-split-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 22px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  list-style: none;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-references-tab
  .shell-ribbon
  .shell-ribbon__references-split-toggle::-webkit-details-marker {
  display: none;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-references-tab
  .shell-ribbon
  .shell-ribbon__references-split-toggle:hover {
  border-color: rgba(76, 110, 245, 0.28);
  background: rgba(76, 110, 245, 0.08);
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-references-tab
  .shell-ribbon
  .shell-ribbon__references-split-toggle .shell-ribbon__references-line-chevron {
  width: 12px;
  height: 16px;
  background: url("./assets/a4-v2/icons/top-dropdown.svg") center / 13px 13px no-repeat;
  opacity: 0.85;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-references-tab
  .shell-ribbon
  .shell-ribbon__references-disclosure[open] .shell-ribbon__references-split-toggle {
  border-color: rgba(76, 110, 245, 0.28);
  background: rgba(76, 110, 245, 0.08);
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-references-tab
  .shell-ribbon
  .shell-ribbon__references-disclosure-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  min-width: 180px;
  padding: 4px;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  background: #ffffff;
  box-shadow: 0 6px 18px rgba(33, 37, 41, 0.16);
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-references-tab
  .shell-ribbon
  .shell-ribbon__references-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 28px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: #343a40;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.45;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-references-tab
  .shell-ribbon
  .shell-ribbon__references-menu-item:hover:not(:disabled) {
  border-color: rgba(76, 110, 245, 0.28);
  background: rgba(76, 110, 245, 0.08);
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-references-tab
  .shell-ribbon
  .shell-ribbon__references-menu-item:disabled {
  color: var(--a4-toolbar-word-text);
  opacity: 1;
  cursor: default;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-references-tab
  .shell-ribbon
  .shell-ribbon__references-menu-item-icon {
  display: inline-flex;
  width: 20px;
  height: 20px;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-references-tab
  .shell-ribbon
  .shell-ribbon__references-menu-item-icon svg {
  display: block;
  width: 20px;
  height: 20px;
  overflow: visible;
}

/* Figma frame 21809:82734 ends the ribbon at the «Таблица ссылок»
   (references-authorities) group with NO trailing separator (the last line
   node, Line 20 at x=1301.5, sits to the LEFT of this group; nothing follows
   the group at x=1395.5). The base separator uses :not(:last-child)::after,
   but references-authorities has hidden review-* siblings after it in the DOM
   so it is not the DOM :last-child and wrongly renders a right-edge line.
   Suppress it, matching the View tab's view-macros::after treatment. */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-references-tab
  .shell-ribbon__group--references-authorities::after {
  display: none !important;
}

/* Review tab Word-parity: commands look enabled even while deferred;
   only the controls Word actually grays (comment nav, Block Authors)
   stay muted. */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-review-tab
  .shell-ribbon
  :is(
    .shell-ribbon__review-big,
    .shell-ribbon__review-line,
    .shell-ribbon__review-select,
    .shell-ribbon__review-showbox,
    .shell-ribbon__review-action
  ):disabled {
  color: var(--a4-toolbar-word-text) !important;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-review-tab
  .shell-ribbon
  :is(
    .shell-ribbon__review-line--word-muted,
    .shell-ribbon__review-big--word-muted
  ):disabled {
  color: var(--a4-toolbar-word-disabled) !important;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-review-tab
  .shell-ribbon
  :is(
    .shell-ribbon__review-line--word-muted,
    .shell-ribbon__review-big--word-muted
  ):disabled
  :is(.shell-ribbon__review-line-icon, .shell-ribbon__review-big-icon) {
  filter: grayscale(1);
  opacity: 0.55;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-review-tab
  .shell-ribbon
  .shell-ribbon__review-big--word-muted:disabled
  .shell-ribbon__review-big-label {
  color: var(--a4-toolbar-word-disabled) !important;
}

/* ─────────────────────────────────────────────────────────────────────────
   Вид (View) tab — Figma frame 21981:117051, 1:1 parity restyle.
   Tokens: text/icon = gray/gray-8 #343a40; accent = primary-color-filled
   #4c6ef5; band bg = gray/gray-light rgba(134,142,150,0.1); border #ced4da.
   Pattern mirrors the References/Review ports: 32px big tiles + 20px list
   lines + 16px checkboxes, 8px separator gutters both sides, caption-less.
   Glyphs come from view-sprite.svg (real Figma exports).
   ───────────────────────────────────────────────────────────────────────── */

/* Ribbon = horizontal flex, no caption rows, hidden horizontal scroll. */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab .shell-ribbon {
  display: flex !important;
  gap: 0 !important;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  padding: 0 10px !important;
  scrollbar-width: none;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon::-webkit-scrollbar {
  display: none;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon-scroll-button {
  display: none !important;
  visibility: hidden !important;
}

/* Caption-less band: drop any leftover caption rows. */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__caption {
  display: none !important;
}

/* Group shells. Each group = 8px left gutter (padding) + content, group
   widths span separator-to-separator so the right 8px gutter precedes the
   next group's separator (Figma 8px gutters both sides). */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__group--view-modes,
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__group--view-immersive,
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__group--view-switch-mode,
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__group--view-show,
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__group--view-zoom,
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__group--view-window,
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__group--view-switch-windows,
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__group--view-macros {
  display: flex !important;
  height: 72px !important;
  min-height: 72px !important;
  flex: 0 0 auto !important;
  margin: 0 !important;
  align-items: center !important;
  justify-content: flex-start !important;
  box-sizing: border-box !important;
  transform: none !important;
}

/* Group widths = content-driven with a uniform 8px gutter on BOTH sides
   (Figma frame 21981:117051 puts every group 8px after its left separator and
   8px before its right separator). Auto-sizing each group to content + 16px and
   letting them flow left-to-right yields IDENTICAL 8px gutters at every
   separator, which the fixed Figma-segment widths could not guarantee once the
   live font rendered each Cyrillic label a hair wider than the Figma metrics.
   First group (modes) takes its 8px-equivalent left gutter from the ribbon's
   own 10px pad-left, so it carries right-only padding. */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__group--view-modes,
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__group--view-immersive,
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__group--view-switch-mode,
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__group--view-show,
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__group--view-zoom,
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__group--view-window,
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__group--view-switch-windows,
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__group--view-macros {
  width: auto !important;
  flex-basis: auto !important;
  padding: 0 8px !important;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__group--view-modes {
  padding: 0 8px 0 0 !important;
}

/* Vertical separator at each group's right edge (suppressed on the last). */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__group:not(:last-child)::after {
  top: 1px;
  right: -1px;
  width: 1px;
  height: 70px;
  background: var(--a4-toolbar-word-separator);
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__group--view-macros::after {
  display: none !important;
}

/* Row = horizontal flex, vertically centred, 6px tile gap (Figma group gap). */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__row--view-modes,
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__row--view-immersive,
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__row--view-switch-mode,
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__row--view-zoom,
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__row--view-window,
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__row--view-switch-windows,
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__row--view-macros {
  display: flex !important;
  height: 66px !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 6px !important;
  transform: none !important;
}

/* ── Buttons: reset to the shared tile look ─────────────────────────────── */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  :is(
    .shell-ribbon__view-big,
    .shell-ribbon__view-line,
    .shell-ribbon__view-split-toggle
  ) {
  appearance: none;
  position: relative;
  box-sizing: border-box;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: #343a40;
  font: inherit;
  cursor: pointer;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  :is(
    .shell-ribbon__view-big,
    .shell-ribbon__view-line,
    .shell-ribbon__view-split-toggle
  ):hover:not(:disabled) {
  border-color: rgba(76, 110, 245, 0.28);
  background: rgba(76, 110, 245, 0.08);
}

/* Word-parity: View commands look enabled even while deferred (disabled). */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  :is(
    .shell-ribbon__view-big,
    .shell-ribbon__view-line,
    .shell-ribbon__view-split-toggle
  ):disabled {
  opacity: 1;
  color: #343a40 !important;
  cursor: default;
}

/* ── Big tiles (32px icon + centred ≤2-line label) ──────────────────────── */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__view-big {
  display: grid;
  height: 66px;
  align-items: start;
  justify-items: center;
  padding: 5px 0 0;
  grid-template-rows: 32px 22px;
  row-gap: 4px;
  min-width: 48px;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__view-big-icon {
  display: inline-flex;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  color: #343a40;
  line-height: 1;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__view-big-icon svg {
  display: block;
  width: 32px;
  height: 32px;
  overflow: visible;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__view-big-label {
  display: block;
  align-self: start;
  grid-row: 2;
  max-width: 104px;
  color: #343a40;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.05;
  text-align: center;
  white-space: nowrap;
  overflow-wrap: normal;
}

/* Macros glyph: the Figma copied_icon export already bakes its mirror, so the
   raw SVG renders in the final (dark doc left, red scroll right) orientation. */

/* Dropdown big tiles (Разделить ▾, Переключение окон ▾, Макросы ▾).
   Figma (Frame 3242) centres the 32px icon and drops the caret Vector right
   against the icon's right edge, vertically centred (x36→44, y≈14). The tile
   width is driven by its label (which can be wider than the icon), with the
   icon+caret unit centred over the label — so the tile box always contains all
   ink and the group auto-width measures the true widest element. */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__view-big--dropdown {
  position: relative;
  display: grid;
  grid-template-rows: 32px 22px;
  justify-items: center;
  min-width: 48px;
}

/* Figma Frame 3242 seats the 32px glyph left-of-centre (centre ≈x20 of 48) with
   the caret in the freed 36→44 lane, and centres the label in the 48px tile.
   We reproduce that by nudging the icon 6px left of the cell centre and pinning
   the caret to the icon's right edge; the label stays centred and drives width,
   so all ink stays inside the tile and clear of the separator. */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__view-big--dropdown .shell-ribbon__view-big-icon {
  grid-row: 1;
  grid-column: 1;
  position: relative;
  transform: translateX(-6px);
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__view-big--dropdown .shell-ribbon__mini-chevron {
  position: absolute;
  /* Pull the caret out of the grid (app.css base rule pins it to grid-column 2,
     which would make its absolute containing block a 0-width area at the tile's
     right edge — pushing ink past the separator). With grid-column/row auto the
     containing block is the tile padding box, so 50% is the true tile centre.
     The icon sits 6px left of centre, right edge at centre+10; seat the caret
     just past it. */
  grid-column: auto !important;
  grid-row: auto !important;
  left: 50%;
  margin-left: 11px;
  top: 13px;
  width: 10px;
  height: 16px;
  background: url("./assets/a4-v2/icons/top-dropdown.svg") center / 13px 13px no-repeat;
  opacity: 0.82;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__view-big--dropdown .shell-ribbon__view-big-label {
  grid-row: 2;
  grid-column: 1;
}

/* ── List stacks (Структура/Черновик; Одна страница/.../Ширина страницы) ── */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__view-stack {
  display: grid;
  width: max-content;
  align-content: center;
  justify-items: start;
  grid-auto-rows: 22px;
  gap: 18px;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__view-stack--zoom {
  gap: 2px;
}

/* List row = 20px icon + label (+ optional chevron lane). */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__view-line {
  display: grid;
  width: max-content;
  height: 22px;
  grid-template-columns: 20px auto;
  align-items: center;
  gap: 4px;
  padding: 0 2px;
  overflow: visible;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.45;
  text-align: left;
  white-space: nowrap;
  justify-self: start;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__view-line-icon {
  display: inline-flex;
  width: 20px;
  height: 20px;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__view-line-icon svg {
  display: block;
  width: 20px;
  height: 20px;
  overflow: visible;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__view-line span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Chevron lane to the right of a list-row label (Одна страница ▾).
   Figma (node 21981:117366): the caret sits ~2px after the label text, NOT in a
   reserved far-right lane. Use a tight 10px chevron column with a 2px gap so the
   caret hugs the word and the stack's right edge stays inside the 8px gutter. */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__view-line--dropdown {
  grid-template-columns: 20px max-content 10px;
  column-gap: 2px;
  padding-right: 0;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__view-line-chevron {
  width: 10px;
  height: 16px;
  background: url("./assets/a4-v2/icons/top-dropdown.svg") center / 12px 12px no-repeat;
  opacity: 0.85;
}

/* Структура split control: label LightButton + a small chevron toggle that
   carries the folded switch-modes command (Figma node 21986:132086).
   Figma places the caret ~2px after the Структура button, so use a 2px flex gap
   and a 14px toggle whose caret hugs the word — this keeps the modes content
   inside the 8px right gutter instead of touching the separator at x271. */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__view-split {
  display: flex;
  align-items: center;
  gap: 0;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__view-split-main {
  width: max-content;
  padding-right: 0;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__view-split-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 22px;
  padding: 0;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__view-split-toggle .shell-ribbon__view-line-chevron {
  width: 10px;
  height: 16px;
}

/* ── Show checkboxes (Линейка ✓, Линии сетки ✓, Область навигации) ──────── */
/* Size the stack to its widest row (Figma Checkbox instances are 126px wide for
   the same labels; the live font needs ~127px). Using max-content guarantees the
   "Область навигации" label is fully contained and that the show group's
   auto-width includes the whole checkbox ink — otherwise the row overflowed its
   own box and bled past the separator. */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__view-checks {
  display: grid;
  /* !important needed: app.css pins view-checks to 112px !important at the same
     4-class specificity, which clamps the container and made the long label bleed
     past the separator. */
  width: max-content !important;
  height: auto !important;
  align-content: center;
  justify-items: start;
  grid-auto-rows: 20px;
  gap: 2px !important;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__view-check {
  display: grid;
  width: max-content;
  grid-template-columns: 16px max-content !important;
  align-items: center;
  gap: 4px !important;
  height: 20px;
  margin: 0;
  color: #343a40;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__view-check-input {
  display: none;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__view-check-box {
  position: relative;
  display: inline-block;
  width: 16px;
  height: 16px;
  box-sizing: border-box;
  border: 1px solid #ced4da;
  border-radius: 4px;
  background: #ffffff;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__view-check--checked .shell-ribbon__view-check-box {
  border-color: #4c6ef5;
  background: #4c6ef5;
}

/* White check glyph (Figma check_24dp Vector). */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__view-check--checked .shell-ribbon__view-check-box::after {
  content: "";
  position: absolute;
  left: 4.6px;
  top: 1.8px;
  width: 4px;
  height: 8px;
  border: solid #ffffff;
  border-width: 0 1.6px 1.6px 0;
  transform: rotate(45deg);
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
  .shell-ribbon__view-check-label {
  color: #343a40;
}

/* ── Insert (Вставка) tab — Figma 21642:50783 1:1 parity ──────────────────
   The design frame is 1800px wide; the A4 window is 1510px → uniform ≈0.84
   width scale (labels 11px→9px, 12px→10px; tile widths ×0.84 with a floor of
   the real 9px label ink so nothing truncates). Icons (32px), the chevron
   vector (7.54×4.47, #868E96) and all colors/tokens are exact Figma values. */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-insert-tab
  .shell-ribbon__insert-action-label {
  display: block;
  overflow: visible;
  font-size: 9px;
  font-weight: 500;
  line-height: 1;
  color: #343a40;
  text-align: center;
  white-space: nowrap;
}

/* Формула + Дополнительные символы labels are 12px in the 1800px design
   (all others 11px) → 10px at window scale. */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-insert-tab
  .shell-ribbon__insert-action:is([aria-label^="Формула"], [aria-label^="Дополнительные символы"])
  .shell-ribbon__insert-action-label {
  font-size: 10px;
}

/* Tile model: flex column [icon row 32px][gap 4px][label], py-5px (Figma
   LightButton: h66, py-5, gap-4, icon row y5–37, label y41).
   Operator request 2026-07-02: every tile carries 2px l/r inner padding so the
   hover box doesn't hug the ink. The former 4px inter-tile row gap is folded
   into this padding (gap 0 + 2px+2px), so ink-to-ink spacing is unchanged —
   only the boxes are wider. Width table below is therefore ink width + 4px. */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-insert-tab
  .shell-ribbon__insert-action.shell-ribbon__insert-action--large {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: flex-start !important;
  overflow: visible !important;
  padding: 5px 2px !important;
  gap: 4px !important;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-insert-tab
  .shell-ribbon__insert-action.shell-ribbon__insert-action--large
  .shell-ribbon__insert-action-icon {
  position: relative;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-insert-tab
  .shell-ribbon__insert-action.shell-ribbon__insert-action--large
  .shell-ribbon__insert-action-label {
  position: static;
  grid-column: auto;
  grid-row: auto;
  width: 100%;
  flex: 1 1 auto;
  align-self: stretch;
}

/* Dropdown tiles (the 16 chevron tiles of Figma 21642:50783): the icon+chevron
   ENSEMBLE (32 + 7.5px) is centred in the tile — Figma puts the 32px icon at
   x4.23 of the 48px slot with the chevron vector at x36.23 (right edge of the
   icon, vertically centred on the icon row: y13.76 of the 32px row). We bias
   the icon 4px left of centre (margin-right 8px) and pin the chevron at the
   icon's right edge (50% + 12px), vertically centred on the icon row. */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-insert-tab
  .shell-ribbon__insert-action.shell-ribbon__insert-action--large:is(
    [aria-label^="Титульная страница"],
    [aria-label^="Таблица"],
    [aria-label^="Изображение"],
    [aria-label^="Фигуры"],
    [aria-label^="3D модели"],
    [aria-label^="SmartArt"],
    [aria-label^="Диаграмма"],
    [aria-label^="Снимок экрана"],
    [aria-label^="Мультимедиа"],
    [aria-label^="Верхний колонтитул"],
    [aria-label^="Нижний колонтитул"],
    [aria-label^="Номер страницы"],
    [aria-label^="Текстовое поле"],
    [aria-label^="WordArt"],
    [aria-label^="Буквица"],
    [aria-label^="Формула"]
  )
  .shell-ribbon__insert-action-icon {
  margin-right: 8px;
  margin-left: 0;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-insert-tab
  .shell-ribbon__insert-action.shell-ribbon__insert-action--large:is(
    [aria-label^="Титульная страница"],
    [aria-label^="Таблица"],
    [aria-label^="Изображение"],
    [aria-label^="Фигуры"],
    [aria-label^="3D модели"],
    [aria-label^="SmartArt"],
    [aria-label^="Диаграмма"],
    [aria-label^="Снимок экрана"],
    [aria-label^="Мультимедиа"],
    [aria-label^="Верхний колонтитул"],
    [aria-label^="Нижний колонтитул"],
    [aria-label^="Номер страницы"],
    [aria-label^="Текстовое поле"],
    [aria-label^="WordArt"],
    [aria-label^="Буквица"],
    [aria-label^="Формула"]
  )::after {
  content: "" !important;
  position: absolute !important;
  /* Icon row spans y5–37 (py-5 + 32px icon) → icon centre y21; the 4.47px
     glyph sits centred inside the 16px background tile of the 8×5 box. */
  top: 18.7px;
  left: calc(50% + 12px);
  width: 8px;
  height: 5px;
  background: url("./assets/a4-v2/icons/top-dropdown.svg") center / 16px 16px no-repeat !important;
  opacity: 1;
  pointer-events: none;
}

/* Legacy child indicator spans are replaced by the ::after chevron above. */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-insert-tab
  .shell-ribbon__insert-action.shell-ribbon__insert-action--large
  .shell-ribbon__insert-dropdown-indicator {
  display: none !important;
}

/* Ссылки: Figma shows THREE separate buttons (Ссылка / Закладка /
   Перекрестная ссылка) — the consolidated dropdown trigger stays in the DOM
   for its wiring/menu contract but is not part of the Figma surface. */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-insert-tab
  #editor-insert-links-button {
  display: none !important;
}

/* Формула icon: 20px glyph inside the standard 32px container (Figma). */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-insert-tab
  .shell-ribbon__insert-action[aria-label^="Формула"]
  .shell-ribbon__insert-action-icon
  svg {
  width: 20px;
  height: 20px;
}

/* Подпись не шире плитки: ширина из таблицы ниже — нижняя граница, плитка растёт
   по подписи. «Диаграмма» (9 px) шире 44 px и залезала на «Снимок экрана». */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-insert-tab
  .shell-ribbon__insert-action.shell-ribbon__insert-action--large {
  min-width: max-content !important;
}

/* ── Tile width table (single source of truth) — Figma width ×0.84, floor =
   9px label ink + 2px, then +4px for the 2px l/r tile padding (operator request
   2026-07-02). Groups hug content (width:auto); row gaps are 0 (folded into the
   tile padding) so these widths fully determine the band total: ends ≈1504 ≤ 1510. */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-insert-tab
  .shell-ribbon__group--insert-pages
  .shell-ribbon__insert-action[aria-label^="Титульная страница"] {
  width: 53px;
  min-width: 53px;
}
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-insert-tab
  .shell-ribbon__group--insert-pages
  .shell-ribbon__insert-action[aria-label^="Пустая страница"] {
  width: 49px;
  min-width: 49px;
}
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-insert-tab
  .shell-ribbon__group--insert-pages
  .shell-ribbon__insert-action[aria-label^="Разрыв страницы"] {
  width: 51px;
  min-width: 51px;
}
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-insert-tab
  .shell-ribbon__group--insert-tables
  .shell-ribbon__insert-action {
  width: 44px;
  min-width: 44px;
}
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-insert-tab
  .shell-ribbon__group--insert-illustrations
  .shell-ribbon__insert-action {
  width: 44px;
  min-width: 44px;
}
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-insert-tab
  .shell-ribbon__group--insert-illustrations
  .shell-ribbon__insert-action[aria-label^="Значки"] {
  width: 42px;
  min-width: 42px;
}
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-insert-tab
  .shell-ribbon__group--insert-illustrations
  .shell-ribbon__insert-action[aria-label^="SmartArt"] {
  width: 46px;
  min-width: 46px;
}
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-insert-tab
  .shell-ribbon__group--insert-illustrations
  .shell-ribbon__insert-action[aria-label^="Диаграмма"] {
  width: 60px;
  min-width: 60px;
}
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-insert-tab
  .shell-ribbon__group--insert-media
  .shell-ribbon__insert-action {
  width: 69px;
  min-width: 69px;
}
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-insert-tab
  .shell-ribbon__group--insert-links
  .shell-ribbon__insert-action[aria-label^="Ссылка"] {
  width: 42px;
  min-width: 42px;
}
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-insert-tab
  .shell-ribbon__group--insert-links
  .shell-ribbon__insert-action[aria-label^="Закладка"] {
  width: 49px;
  min-width: 49px;
}
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-insert-tab
  .shell-ribbon__group--insert-links
  .shell-ribbon__insert-action[aria-label^="Перекр"] {
  width: 73px;
  min-width: 73px;
}
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-insert-tab
  .shell-ribbon__group--insert-comments
  .shell-ribbon__insert-action {
  width: 63px;
  min-width: 63px;
}
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-insert-tab
  .shell-ribbon__group--insert-header-footer
  .shell-ribbon__insert-action--large {
  width: 58px;
  min-width: 58px;
}
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-insert-tab
  .shell-ribbon__group--insert-header-footer
  .shell-ribbon__insert-action--large[aria-label^="Номер страницы"] {
  width: 51px;
  min-width: 51px;
}
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-insert-tab
  .shell-ribbon__group--insert-text
  .shell-ribbon__insert-action--large {
  width: 51px;
  min-width: 51px;
}
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-insert-tab
  .shell-ribbon__group--insert-equation
  .shell-ribbon__insert-action {
  width: 52px;
  min-width: 52px;
}
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-insert-tab
  .shell-ribbon__group--insert-symbols {
  padding-right: 0 !important;
}
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-insert-tab
  .shell-ribbon__group--insert-symbols
  .shell-ribbon__insert-action {
  width: 94px;
  min-width: 94px;
}

/* Insert tab — override the home-ribbon master rule (#1f2328 !important)
   with Figma's gray/gray-8 token (#343a40) for all insert action buttons. */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-insert-tab
  .shell-ribbon
  .shell-ribbon__insert-action {
  color: #343a40 !important;
}

/* ─────────────────────────────────────────────────────────────────────────
   Рисование (Draw) tab — Figma frame 21989:118115, 1:1 parity restyle.
   Tokens: text/icon = gray/gray-8 #343a40; pen colours from Figma swatches
   (red #fa5252, gray #adb5bd, orange #fab005); card border #dee2e6; band bg
   gray/gray-light rgba(134,142,150,0.1). The home-ribbon master rule
   (`.shell-ribbon button { color: var(--a4-toolbar-word-text) !important }`,
   app.css:13419) forces every ribbon button to #1f2328 — re-assert the Figma
   ink/colours here (contract layer loads last) without touching any handler.
   ──────────────────────────────────────────────────────────────────────── */

/* Caption-less band tile labels/icons use gray/gray-8 (not the #1f2328 master). */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-draw-tab
  .shell-ribbon
  :is(.shell-ribbon__draw-command, .shell-ribbon__draw-add-button, .shell-ribbon__draw-trackpad-control) {
  color: #343a40 !important;
}

/* Произвольное выделение is a disabled (visual-only) tile — keep it full-ink,
   not the muted disabled colour the master rule would apply. */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-draw-tab
  .shell-ribbon
  .shell-ribbon__draw-command--lasso:disabled {
  color: #343a40 !important;
  opacity: 1 !important;
  cursor: default;
}

/* Pen-gallery ink: each pen's currentColor body uses its Figma swatch. */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-draw-tab
  .shell-ribbon
  .shell-ribbon__draw-pen--black {
  color: #343a40 !important;
}
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-draw-tab
  .shell-ribbon
  .shell-ribbon__draw-pen--red {
  color: #fa5252 !important;
}
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-draw-tab
  .shell-ribbon
  .shell-ribbon__draw-pen--pencil {
  color: #adb5bd !important;
}
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-draw-tab
  .shell-ribbon
  .shell-ribbon__draw-pen--yellow {
  color: #fab005 !important;
}

/* Pens recoloured via the pen-settings menu still win (keep the existing var). */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-draw-tab
  .shell-ribbon
  .shell-ribbon__draw-pen[data-editor-draw-pen-settings-color] {
  color: var(--editor-draw-pen-ribbon-color, currentColor) !important;
}

/* ======================================================================== */
/* Рассылки (Mailings) tab — Figma node 22009:140513 (frame 1600x73).        */
/* Caption-less band, modelled on the View tab: auto-width groups with 8px   */
/* gutters both sides, separator at each group's right edge, 32px big tiles   */
/* with ≤2-line centred labels, dropdown caret in a clean right lane, a       */
/* record-navigation input cluster and a two-row merge-range input stack.     */
/* All commands are visual/inert (disabled, no handlers).                     */
/* ======================================================================== */

/* Hide the mailings groups on every OTHER tab (they are new, so the master
   per-tab hide block in app.css does not enumerate them — without this they
   leak onto Home/Insert/etc.). Complements the show rule below. */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon:not(.shell--ribbon-mailings-tab)
  :is(
    .shell-ribbon__group--mailings-create,
    .shell-ribbon__group--mailings-start,
    .shell-ribbon__group--mailings-write,
    .shell-ribbon__group--mailings-preview,
    .shell-ribbon__group--mailings-finish,
    .shell-ribbon__group--mailings-merge
  ) {
  display: none !important;
}

/* Show only the mailings groups on this tab. */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  .shell-ribbon__group:not(.shell-ribbon__group--mailings-create):not(
    .shell-ribbon__group--mailings-start
  ):not(.shell-ribbon__group--mailings-write):not(
    .shell-ribbon__group--mailings-preview
  ):not(.shell-ribbon__group--mailings-finish):not(
    .shell-ribbon__group--mailings-merge
  ) {
  display: none !important;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  .shell-ribbon {
  display: flex !important;
  gap: 0 !important;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  padding: 0 10px !important;
  scrollbar-width: none;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  .shell-ribbon::-webkit-scrollbar {
  display: none;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  .shell-ribbon-scroll-button {
  display: none !important;
  visibility: hidden !important;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  .shell-ribbon__caption {
  display: none !important;
}

/* Group shells: auto width + uniform 8px gutter on both sides. */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  .shell-ribbon__group--mailings-create,
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  .shell-ribbon__group--mailings-start,
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  .shell-ribbon__group--mailings-write,
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  .shell-ribbon__group--mailings-preview,
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  .shell-ribbon__group--mailings-finish,
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  .shell-ribbon__group--mailings-merge {
  display: flex !important;
  height: 72px !important;
  min-height: 72px !important;
  flex: 0 0 auto !important;
  margin: 0 !important;
  align-items: center !important;
  justify-content: flex-start !important;
  box-sizing: border-box !important;
  width: auto !important;
  flex-basis: auto !important;
  padding: 0 8px !important;
  transform: none !important;
}

/* First group takes its left 8px-equivalent gutter from the ribbon's pad-left. */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  .shell-ribbon__group--mailings-create {
  padding: 0 8px 0 0 !important;
}

/* Vertical separator at each group's right edge (suppressed on the last). */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  .shell-ribbon__group:not(:last-child)::after {
  top: 1px;
  right: -1px;
  width: 1px;
  height: 70px;
  background: var(--a4-toolbar-word-separator);
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  .shell-ribbon__group--mailings-merge::after {
  display: none !important;
}

/* Rows = horizontal flex, vertically centred, 6px tile gap (Figma group gap). */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  .shell-ribbon__row--mailings-create,
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  .shell-ribbon__row--mailings-start,
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  .shell-ribbon__row--mailings-write,
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  .shell-ribbon__row--mailings-preview,
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  .shell-ribbon__row--mailings-merge {
  display: flex !important;
  height: 66px !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 6px !important;
  transform: none !important;
}

/* ── Buttons: shared tile reset ─────────────────────────────────────────── */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  :is(
    .shell-ribbon__mailings-big,
    .shell-ribbon__mailings-line,
    .shell-ribbon__mailings-nav,
    .shell-ribbon__mailings-input
  ) {
  appearance: none;
  position: relative;
  box-sizing: border-box;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: #343a40;
  font: inherit;
  cursor: pointer;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  :is(
    .shell-ribbon__mailings-big,
    .shell-ribbon__mailings-line,
    .shell-ribbon__mailings-nav
  ):hover:not(:disabled) {
  border-color: rgba(76, 110, 245, 0.28);
  background: rgba(76, 110, 245, 0.08);
}

/* Word-parity: commands look enabled even while deferred (disabled). */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  :is(
    .shell-ribbon__mailings-big,
    .shell-ribbon__mailings-line,
    .shell-ribbon__mailings-nav,
    .shell-ribbon__mailings-input
  ):disabled {
  opacity: 1;
  color: #343a40 !important;
  cursor: default;
}

/* ── Big tiles (32px icon + centred ≤2-line label) ──────────────────────── */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  .shell-ribbon__mailings-big {
  display: grid;
  height: 66px;
  align-items: start;
  justify-items: center;
  padding: 5px 0 0;
  grid-template-rows: 32px 22px;
  row-gap: 4px;
  min-width: 48px;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  .shell-ribbon__mailings-big-icon {
  display: inline-flex;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  color: #343a40;
  line-height: 1;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  .shell-ribbon__mailings-big-icon svg {
  display: block;
  width: 32px;
  height: 32px;
  overflow: visible;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  .shell-ribbon__mailings-big-label {
  display: block;
  align-self: start;
  grid-row: 2;
  max-width: 104px;
  color: #343a40;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.05;
  text-align: center;
  white-space: nowrap;
  overflow-wrap: normal;
}

/* Dropdown big tiles: 32px icon centred, caret in the freed right lane
   (Figma Frame 3242 puts the caret at x36→44, y≈14 of the 48px icon cell).
   Icon nudged 6px left of cell centre; caret pinned just past its right edge;
   label centred and driving the tile width. */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  .shell-ribbon__mailings-big--dropdown {
  position: relative;
  display: grid;
  grid-template-rows: 32px 22px;
  justify-items: center;
  min-width: 48px;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  .shell-ribbon__mailings-big--dropdown .shell-ribbon__mailings-big-icon {
  grid-row: 1;
  grid-column: 1;
  position: relative;
  transform: translateX(-6px);
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  .shell-ribbon__mailings-big--dropdown .shell-ribbon__mini-chevron {
  position: absolute;
  grid-column: auto !important;
  grid-row: auto !important;
  left: 50%;
  margin-left: 11px;
  top: 13px;
  width: 10px;
  height: 16px;
  background: url("./assets/a4-v2/icons/top-dropdown.svg") center / 13px 13px no-repeat;
  opacity: 0.82;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  .shell-ribbon__mailings-big--dropdown .shell-ribbon__mailings-big-label {
  grid-row: 2;
  grid-column: 1;
}

/* ── Preview group: big tile + nav cluster + Найти получателя list row ───── */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  .shell-ribbon__mailings-navstack {
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 10px;
  padding-left: 2px;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  .shell-ribbon__mailings-navrow {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 24px;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  .shell-ribbon__mailings-nav {
  display: inline-flex;
  width: 22px;
  height: 22px;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  .shell-ribbon__mailings-nav svg {
  display: block;
  width: 16px;
  height: 16px;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  .shell-ribbon__mailings-navfield {
  display: inline-block;
  width: 88px;
  height: 24px;
  box-sizing: border-box;
  border: 1px solid #ced4da;
  border-radius: 4px;
  background: #ffffff;
}

/* Столбик строк (Подобрать поля; Найти получателя + Поиск ошибок). */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  .shell-ribbon__mailings-navstack:has(.shell-ribbon__mailings-linestack) {
  gap: 4px;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  :is(.shell-ribbon__mailings-linestack, .shell-ribbon__mailings-navstack--lines) {
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 0;
}

/* List row (Найти получателя): 20px icon + label. */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  .shell-ribbon__mailings-line {
  display: grid;
  width: max-content;
  height: 22px;
  grid-template-columns: 20px auto;
  align-items: center;
  gap: 4px;
  padding: 0 2px;
  overflow: visible;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.45;
  text-align: left;
  white-space: nowrap;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  .shell-ribbon__mailings-line-icon {
  display: inline-flex;
  width: 20px;
  height: 20px;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  .shell-ribbon__mailings-line-icon svg {
  display: block;
  width: 20px;
  height: 20px;
  overflow: visible;
}

/* ── Finish group: two-row merge-range input stack ──────────────────────── */
.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  .shell-ribbon__mailings-mergestack {
  display: grid;
  align-content: center;
  gap: 10px;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  .shell-ribbon__mailings-mergerow {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 24px;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  .shell-ribbon__mailings-mergelabel {
  color: #343a40;
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  .shell-ribbon__mailings-mergedash {
  color: #343a40;
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  .shell-ribbon__mailings-input {
  display: inline-flex;
  width: 88px;
  height: 24px;
  align-items: center;
  justify-content: flex-end;
  box-sizing: border-box;
  border: 1px solid #ced4da !important;
  border-radius: 4px;
  background: #ffffff;
  padding: 0 2px 0 10px;
}

.shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-mailings-tab
  .shell-ribbon__mailings-input-chevron {
  width: 16px;
  height: 16px;
  background: url("./assets/a4-v2/icons/top-dropdown.svg") center / 13px 13px no-repeat;
  opacity: 0.82;
}

/* ======================================================================== */
/* Tab-bar width fix for the inserted Рассылки (Mailings) tab.               */
/* The base ribbon tab-bar (app.css) assigns FIXED per-position widths via    */
/* `.shell-tab:nth-child(1..8)`, tuned for the original 8 standard tabs.      */
/* Inserting Рассылки as the 7th DOM child shifted those positions, so the    */
/* nth-child widths landed on the wrong labels (Рассылки got Рецензирование's */
/* 132px slot; Рецензирование got Вид's 43px and truncated). Re-key the slot  */
/* widths to each tab's IDENTITY (data-ribbon-tab) so they are immune to the  */
/* position shift. Pure layout (no functional change); contract.css wins.     */
/*                                                                            */
/* Wide layout (>=1357px, the primary supported chrome — window min-width is  */
/* 1180px): pin each standard tab to its Figma slot width by identity.        */
@media (min-width: 1357px) {
  .shell--a4-v2-chrome .shell-tabbar__tabs .shell-tab[data-ribbon-tab="home"] {
    width: 73px !important;
  }
  .shell--a4-v2-chrome .shell-tabbar__tabs .shell-tab[data-ribbon-tab="insert"] {
    width: 72px !important;
  }
  .shell--a4-v2-chrome .shell-tabbar__tabs .shell-tab[data-ribbon-tab="draw"] {
    width: 91px !important;
  }
  .shell--a4-v2-chrome .shell-tabbar__tabs .shell-tab[data-ribbon-tab="design"] {
    width: 106px !important;
  }
  .shell--a4-v2-chrome .shell-tabbar__tabs .shell-tab[data-ribbon-tab="layout"] {
    width: 60px !important;
  }
  .shell--a4-v2-chrome
    .shell-tabbar__tabs
    .shell-tab[data-ribbon-tab="references"] {
    width: 70px !important;
  }
  .shell--a4-v2-chrome
    .shell-tabbar__tabs
    .shell-tab[data-ribbon-tab="mailings"] {
    width: 84px !important;
  }
  .shell--a4-v2-chrome .shell-tabbar__tabs .shell-tab[data-ribbon-tab="review"] {
    width: 132px !important;
  }
  .shell--a4-v2-chrome .shell-tabbar__tabs .shell-tab[data-ribbon-tab="view"] {
    width: 43px !important;
  }
}

/* Reachable narrow band (1180px window min-width .. 1356px): the existing     */
/* breakpoints collapse the right-hand pill actions to free space and cap the  */
/* tab container, but their position-based per-tab width / hide / overflow-    */
/* chevron rules were tuned for 8 tabs and now target the wrong (shifted)      */
/* positions. Let every standard tab size to its own content here so all nine  */
/* fit the capped container without truncation, and suppress the stale         */
/* position-shifted hide + ::before chevron artefacts so no wrong tab is       */
/* dropped or decorated. The hidden contextual tabs keep their own [hidden].   */
@media (max-width: 1356px) {
  .shell--a4-v2-chrome
    .shell-tabbar__tabs
    .shell-tab:not([hidden]):not(.shell-tab--contextual) {
    width: auto !important;
    flex: 0 0 auto !important;
    padding-right: 8px !important;
  }
  .shell--a4-v2-chrome
    .shell-tabbar__tabs
    .shell-tab:not([hidden]):not(.shell-tab--contextual)::before {
    content: none !important;
    display: none !important;
  }
}

/* View -> Window responsive continuity.
   At 1280px the content-sized View groups used to extend beyond the ribbon's
   right edge while the only recovery path (a hidden horizontal scrollbar)
   was not discoverable. Keep every command in the same group and on the same
   handler; only compact whitespace and type/icon metrics in the reachable
   narrow band. The controls continue to own their natural content width, so
   English and Russian labels remain complete instead of being ellipsized. */
@media (max-width: 1356px) {
  .shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
    .shell-ribbon {
    padding-right: 4px !important;
    padding-left: 4px !important;
  }

  .shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
    :is(
      .shell-ribbon__group--view-modes,
      .shell-ribbon__group--view-immersive,
      .shell-ribbon__group--view-switch-mode,
      .shell-ribbon__group--view-show,
      .shell-ribbon__group--view-zoom,
      .shell-ribbon__group--view-window,
      .shell-ribbon__group--view-switch-windows,
      .shell-ribbon__group--view-macros
    ) {
    padding-right: 4px !important;
    padding-left: 4px !important;
  }

  .shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
    .shell-ribbon__group--view-modes {
    padding-left: 0 !important;
  }

  .shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
    :is(
      .shell-ribbon__row--view-modes,
      .shell-ribbon__row--view-immersive,
      .shell-ribbon__row--view-switch-mode,
      .shell-ribbon__row--view-zoom,
      .shell-ribbon__row--view-window,
      .shell-ribbon__row--view-switch-windows,
      .shell-ribbon__row--view-macros
    ) {
    gap: 2px !important;
  }

  .shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
    .shell-ribbon__view-big {
    min-width: 44px;
  }

  .shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
    .shell-ribbon__view-big-label {
    max-width: 92px;
    font-size: 10px;
  }

  .shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
    .shell-ribbon__view-line {
    grid-template-columns: 18px auto;
    gap: 2px;
    padding-right: 1px;
    padding-left: 1px;
    font-size: 10px;
  }

  .shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
    .shell-ribbon__view-line--dropdown {
    grid-template-columns: 18px max-content 10px;
  }

  .shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
    .shell-ribbon__view-line-icon,
  .shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
    .shell-ribbon__view-line-icon svg {
    width: 18px;
    height: 18px;
  }

  .shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
    .shell-ribbon__view-check {
    grid-template-columns: 14px max-content !important;
    gap: 3px !important;
    font-size: 10px;
  }

  .shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
    .shell-ribbon__view-check-box {
    width: 14px;
    height: 14px;
  }

  .shell--a4-v2-chrome.shell--a4-v2-home-ribbon.shell--ribbon-view-tab
    .shell-ribbon__view-check--checked .shell-ribbon__view-check-box::after {
    left: 3.6px;
    top: 0.8px;
  }
}
