/* Admin layout. Colors come from the x-theme tokens only. */
:root { --admin-side: 248px; --admin-topbar: 60px; --admin-gap: 20px; --admin-radius: 14px; }

/* Shell: the sidebar and the workspace. */
.shell { display: grid; grid-template-columns: var(--admin-side) minmax(0, 1fr); min-height: 100vh;
  background: color-mix(in srgb, var(--x-color-text) 3%, var(--x-color-bg)); }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px; padding: 18px 12px;
  border-right: 1px solid var(--x-color-border); background: var(--x-color-surface); }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: var(--x-color-text); }
.brand-text { display: grid; min-width: 0; }
.nav { display: grid; gap: 14px; min-height: 0; overflow-y: auto; }
/* A group of the menu: a small title over its items. */
.nav-group { display: grid; gap: 2px; }
.nav-group-title { padding: 0 10px 2px; color: var(--x-color-text-muted); font-size: var(--x-font-size-xs, 0.75rem);
  font-weight: var(--x-font-weight-semibold); letter-spacing: 0.04em; text-transform: uppercase; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 10px; color: var(--x-color-text);
  font-size: var(--x-font-size-sm); font-weight: var(--x-font-weight-medium); }
.nav-link:hover { background: var(--x-color-surface-hover); }
.nav-link[aria-current=page] { color: var(--x-color-primary); background: color-mix(in srgb, var(--x-color-primary) 12%, transparent); font-weight: var(--x-font-weight-semibold); }
.nav-link:focus-visible { outline: 2px solid var(--x-color-focus-ring); outline-offset: 2px; }
/* The count of new items sits at the right edge of its menu item. */
.nav-count { margin-left: auto; display: inline-flex; }
.nav-count:empty { display: none; }
.side-foot { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 14px 8px 0; border-top: 1px solid var(--x-color-border); }
.operator { display: grid; flex: 1; min-width: 0; }
.side-foot .form-wrapper { width: auto; }

.workspace { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 32px; min-height: var(--admin-topbar); box-sizing: border-box; border-bottom: 1px solid var(--x-color-border);
  background: color-mix(in srgb, var(--x-color-bg) 88%, transparent); backdrop-filter: blur(10px); }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.crumb { color: var(--x-color-text-muted); font-size: var(--x-font-size-sm); }
.crumb:hover { color: var(--x-color-text); }
.crumb[aria-current=page] { color: var(--x-color-text); font-size: var(--x-font-size-lg, 1.125rem); font-weight: var(--x-font-weight-semibold); }
/* A long title ends with an ellipsis; its title attribute keeps the full text. */
.crumb[aria-current=page] { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumb-separator { --x-typography-color: var(--x-color-text-muted); }
.topbar-link { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border: 1px solid var(--x-color-border);
  border-radius: 10px; color: var(--x-color-text); background: var(--x-color-surface); font-size: var(--x-font-size-sm);
  font-weight: var(--x-font-weight-semibold); white-space: nowrap; }
.topbar-link:hover { background: var(--x-color-surface-hover); }
.admin-main { display: grid; gap: var(--admin-gap); align-content: start; width: 100%; max-width: 1280px; padding: 28px 32px 48px; }
.admin-main > div:not(.page-head) { display: grid; gap: var(--admin-gap); min-width: 0; }

/* Page head: status and actions. The top bar names the page. */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 24px; }
.page-note { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; color: var(--x-color-text-muted); }
.status-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.page-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 8px; flex: none; }
.page-actions .form-wrapper { width: auto; }
/* The publish control: the publish button and the chevron with «Снять с публикации», joined into one control. */
.publish-split { display: inline-flex; align-items: center; }
.publish-split .form-wrapper { width: auto; }
.publish-split.has-more #publish-button::part(button) { border-start-end-radius: 0; border-end-end-radius: 0; }
.publish-more { --x-dropdown-trigger-bg: var(--x-color-primary); --x-dropdown-trigger-bg-hover: var(--x-color-primary-hover);
  --x-dropdown-trigger-bg-active: var(--x-color-primary-active); --x-dropdown-trigger-color: white;
  --x-dropdown-trigger-border: 0; --x-dropdown-trigger-padding: 0 10px; --x-dropdown-trigger-height: 2.5rem;
  --x-dropdown-panel-min-width: 220px; }
/* The chevron part: at least 36 px wide, the full height, a divider of 1 px, the icon as large as the label. The icon is
   white, as the label of the primary x-button in both themes. */
.publish-more::part(trigger) { min-width: 36px; justify-content: center; border-start-start-radius: 0; border-end-start-radius: 0;
  border-inline-start: 1px solid color-mix(in srgb, white 30%, transparent); }
.publish-more::part(trigger-label) { display: none; }
:is(.publish-more, .publish-state)::part(chevron) { color: inherit; font-size: 1.25rem; line-height: 1; }
/* Published with no changes: one secondary dropdown that tells the state and holds «Снять с публикации». */
.publish-state { --x-dropdown-trigger-bg: var(--x-color-surface); --x-dropdown-trigger-bg-hover: var(--x-color-surface-hover);
  --x-dropdown-trigger-bg-active: var(--x-color-surface-active); --x-dropdown-trigger-color: var(--x-color-text);
  --x-dropdown-trigger-border: 1px solid var(--x-color-border); --x-dropdown-trigger-height: 2.5rem;
  --x-dropdown-trigger-font-weight: var(--x-font-weight-semibold); --x-dropdown-panel-min-width: 220px; }
/* Delete stands at the right end of the status row, away from «Опубликовать»: it is rare and cannot be undone. */
.page-note-aside { margin-inline-start: auto; display: flex; align-items: center; gap: 12px; }
.delete-action { --x-button-ghost-fg: var(--x-color-danger); }
/* An off «Удалить…» stays the red ghost link at the off opacity, not a grey plate. */
.delete-action[disabled]::part(button) { background: transparent; border-color: transparent; color: var(--x-color-danger); opacity: var(--x-opacity-disabled); }
.confirm-text { display: grid; gap: 8px; }
/* A wide screen fixes the page actions in the right part of the sticky top bar: they stay in view and take no row.
   The crumbs keep the space that the actions leave; 2 actions take up to 360 px, 3 up to 720 px, 4 up to 860 px. */
@media (min-width: 1101px) {
  /* The actions leave the head, so the empty head takes no row and no gap. */
  .page-head { display: contents; }
  .page-actions { position: fixed; top: 0; right: 32px; z-index: 6; height: var(--admin-topbar); flex-wrap: nowrap; }
  .workspace:has(.page-actions > *) .crumbs { max-width: calc(100% - 360px); flex-wrap: nowrap; overflow: hidden; white-space: nowrap; }
  .workspace:has(.page-actions > :nth-child(3)) .crumbs { max-width: calc(100% - 720px); }
  .workspace:has(.page-actions > :nth-child(4)) .crumbs { max-width: calc(100% - 860px); }
}
/* The save row of a long editor card sticks to the bottom of the screen while the card is in view. */
x-card .inline-actions:has(#save-button) { position: sticky; bottom: 0; z-index: 2; padding: 12px 0;
  background: var(--x-color-surface); box-shadow: 0 -1px 0 var(--x-color-border); }
.side-site { margin-top: 6px; color: var(--x-color-text-muted); }
.action-link.ghost { border-color: transparent; background: transparent; color: var(--x-color-text-muted); }
.action-link.ghost:hover { background: var(--x-color-surface-hover); color: var(--x-color-text); }
.inline-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }

#editor-feedback:empty { display: none; }
#editor-feedback { display: grid; gap: 12px; }
#editor-feedback { border-radius: 12px; }
#editor-feedback:focus { outline: 2px solid var(--x-color-focus-ring); outline-offset: 2px; }

/* Cards and columns. */
x-card { --x-card-radius: var(--admin-radius); }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.card-head > div { display: grid; gap: 2px; }
.editor-columns { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: var(--admin-gap); align-items: start; }
.editor-fields { display: grid; gap: 20px; }
/* A wrapper of the fields of one part of the entry page. It adds no box, so the fields keep the gap of the list. */
.form-part { display: contents; }
.editor-card .card-head { justify-content: flex-start; }
/* Page editor: the page card and the block cards. One card is open. */
.block-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.block-list .block-card { scroll-margin-top: 84px; }
.block-card.open .card-head { justify-content: flex-start; }
.block-card-link { display: flex; align-items: center; gap: 12px; min-width: 0; color: var(--x-color-text); text-decoration: none; }
.block-card-link:hover .block-card-title > :first-child { color: var(--x-color-primary); }
.block-card-title { display: grid; gap: 2px; min-width: 0; }
.block-card .inline-actions { margin-top: 20px; }
/* The sections end the card: the save bar keeps only its own room under them. */
.block-card:has(.form-groups) .inline-actions:has(#save-button) { margin-top: 4px; padding-bottom: 0; }
.block-card-row { display: flex; align-items: center; gap: 12px; }
.block-card-row > .block-card-link { flex: 1; }
.block-card-head, .card-head > .block-card-head { display: flex; align-items: center; gap: 10px; }
.block-tools, .card-head > .block-tools { display: flex; flex-wrap: wrap; gap: 2px; }
.block-card.hidden-block:not(.open) { opacity: .7; }
.block-add { display: flex; justify-content: center; margin: -4px 0; }
.block-add x-button { opacity: .55; }
.block-add x-button:hover, .block-add x-button:focus-within { opacity: 1; }
/* The question before an unsaved editor leaves: the three answers in one row, the save answer last. */
#editor-leave { --x-modal-width-md: min(520px, 94vw); }
#editor-leave .inline-actions { justify-content: flex-end; }
/* The chooser takes the height of the drawer: a new type under the pointer changes the text, never the size. */
.block-chooser { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 24px; height: calc(100dvh - 120px); }
.block-choice-list { display: grid; align-content: start; gap: 14px; min-height: 0; overflow-y: auto; scrollbar-gutter: stable;
  padding: 2px 8px 2px 2px; }
.block-choice-group { display: grid; gap: 2px; }
.block-choice-group > x-typography { color: var(--x-color-text-muted); padding: 0 12px 2px; }
.block-choice { width: 100%; }
.block-choice::part(button) { justify-content: flex-start; width: 100%; }
.block-choice-detail { display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; gap: 12px; min-height: 0; }
.block-choice-hint { min-height: 0; overflow-y: auto; scrollbar-gutter: stable; }
.block-choice-detail[hidden] { display: none; }
.block-choice-detail > x-button { justify-self: start; }
.wf { display: block; width: 100%; height: auto; border: 1px solid var(--x-color-border); border-radius: var(--x-radius-md); background: var(--x-color-bg); }
.wf-text { fill: color-mix(in srgb, var(--x-color-text) 16%, transparent); }
.wf-strong { fill: color-mix(in srgb, var(--x-color-text) 38%, transparent); }
.wf-head { fill: color-mix(in srgb, var(--x-color-text) 62%, transparent); }
.wf-on { fill: color-mix(in srgb, var(--x-color-bg) 78%, transparent); }
.wf-img { fill: color-mix(in srgb, var(--x-color-text) 9%, transparent); }
.wf-shade { fill: color-mix(in srgb, var(--x-color-text) 55%, transparent); }
.wf-cross { fill: none; stroke: color-mix(in srgb, var(--x-color-text) 8%, transparent); stroke-width: 1; }
.wf-box { fill: none; stroke: color-mix(in srgb, var(--x-color-text) 24%, transparent); stroke-width: 1; }
.wf-accent { fill: var(--x-color-primary); }
.wf-dark { fill: color-mix(in srgb, var(--x-color-text) 86%, transparent); }
.wf-rule { stroke: color-mix(in srgb, var(--x-color-text) 16%, transparent); stroke-width: 1; }
.wf-rule-strong { stroke: color-mix(in srgb, var(--x-color-text) 62%, transparent); stroke-width: 1.5; }
.wf-mark { stroke: color-mix(in srgb, var(--x-color-text) 62%, transparent); stroke-width: 1.5; stroke-linecap: round; }
@media (max-width: 720px) {
  .block-chooser { grid-template-columns: minmax(0, 1fr); }
  .block-chooser { height: auto; }
  .block-choice-list { max-height: 36vh; }
}
/* List fields: a bordered list of rows. An inline row is one line; a collapsed row opens its fields below it. */
.list-field { display: grid; gap: 8px; }
.list-rows { display: grid; border: 1px solid var(--x-color-border); border-radius: 12px; overflow: hidden; }
.list-rows:empty { display: none; }
.list-row + .list-row { border-top: 1px solid var(--x-color-border); }
.list-row.dragging { background: var(--x-color-surface-hover); }
.list-grip { cursor: grab; touch-action: none; color: var(--x-color-text-muted); }
.list-row.dragging .list-grip { cursor: grabbing; }
.list-row-inline { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 6px 8px; }
.list-row-inline .list-row-fields { display: grid; grid-template-columns: minmax(80px, 2fr) minmax(0, 5fr); gap: 8px; }
.list-row-inline .list-row-fields:has(> :only-child) { grid-template-columns: minmax(0, 1fr); }
/* The label of an inline field stays for the screen reader; the placeholder shows it on the screen. */
.list-row-inline x-form-field::part(label) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.list-row-collapsed .list-row-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 4px; padding: 4px 8px; }
.list-row-toggle { min-width: 0; }
.list-row-toggle { display: block; }
.list-row-toggle::part(button) { width: 100%; justify-content: flex-start; height: auto; min-height: 48px; padding-block: 6px; }
/* The head of a section and the line of a row: the text takes the width, the icons stay at the edges. */
:is(.list-row-toggle, .form-group-head)::part(inner) { width: 100%; gap: 12px; }
:is(.list-row-toggle, .form-group-head)::part(label) { display: grid; flex: 1; min-width: 0; justify-content: stretch;
  gap: 2px; text-align: start; line-height: 1.3; }
.list-row-menu::part(chevron) { display: none; }
.list-row-toggle::part(icon-start) { inline-size: auto; block-size: auto; }
.list-row-inline x-form-field { display: block; min-width: 0; }
.list-row-thumb { display: block; flex: none; width: 48px; height: 36px; border-radius: 6px; overflow: hidden; background: var(--x-color-surface-hover); }
.list-row-thumb { display: grid; place-items: center; }
.list-row-thumb > * { grid-area: 1 / 1; }
.list-row-thumb x-image { display: block; width: 100%; height: 100%; }
.list-row-thumb:not(.empty) > x-icon { visibility: hidden; }
.list-row-thumb.empty { background: transparent; border: 1px dashed var(--x-color-border); color: var(--x-color-text-muted); }
.list-row-detail.missing { --x-typography-color: var(--x-color-warning); }
/* One line of text: the summary of a section and the title and detail of a row end with an ellipsis. */
:is(.list-row-title, .list-row-detail, .form-group-summary) { display: block; min-width: 0; }
:is(.list-row-title, .list-row-detail, .form-group-summary)::part(container) { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
:is(.list-row-detail, .form-group-summary) { --x-typography-color: var(--x-color-text-muted); }
.list-row-detail:empty { display: none; }
.list-row-collapsed.open > .list-row-head { background: var(--x-color-surface-hover); }
.list-row-body { display: grid; gap: 14px; padding: 12px 16px 16px 52px; background: var(--x-color-surface-hover); }
.list-row-body[hidden] { display: none; }
.list-row-menu { --x-dropdown-trigger-border: 0; --x-dropdown-trigger-bg: transparent; --x-dropdown-panel-min-width: 160px; }
.list-row-menu-items, .more-menu-items { display: grid; gap: 2px; }
:is(.list-row-menu-items, .more-menu-items) x-button::part(button) { width: 100%; justify-content: flex-start; }
/* A disabled item (the first row has no «Выше») stays a plain line: the ghost button gives it a grey plate. */
:is(.list-row-menu-items, .more-menu-items) x-button[disabled]::part(button) { background: transparent; border-color: transparent; color: var(--x-color-text); opacity: .35; }
.list-add { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }

/* Block form: one section per group. The head shows the part icon, the title and the summary of a closed section. */
.form-groups { display: grid; border: 1px solid var(--x-color-border); border-radius: 12px; overflow: hidden; }
.form-group + .form-group { border-top: 1px solid var(--x-color-border); }
.form-group-head { display: block; }
.form-group-head::part(button) { width: 100%; justify-content: flex-start; gap: 12px; height: auto; min-height: 56px;
  padding: 10px 16px; border-radius: 0; }
.form-group-icon { display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 8px;
  background: var(--x-color-surface-hover); color: var(--x-color-text-muted); }
.form-group.open .form-group-icon { background: color-mix(in srgb, var(--x-color-primary) 14%, transparent); color: var(--x-color-primary); }
.form-group.open .form-group-summary { display: none; }
.form-group-title::part(container) { font-weight: 600; }
.form-group-chevron { flex: none; color: var(--x-color-text-muted); transition: transform .15s; }
.form-group.open .form-group-chevron { transform: rotate(180deg); }
.form-group-body { display: grid; gap: 16px; padding: 4px 16px 20px 64px; }
.form-group-body[hidden] { display: none; }
.field-pair { display: grid; gap: 6px; }
.field-pair-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 12px; align-items: end; }
x-typography.field-pair-warning { --x-typography-color: var(--x-color-warning); }
.field-pair-warning[hidden] { display: none; }
.one-of { display: grid; gap: 14px; }
.one-of-option { display: grid; gap: 14px; }
.one-of-option[hidden], .one-of x-alert[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) { .form-group-chevron { transition: none; } }
@media (max-width: 720px) {
  .form-group-body { padding-left: 16px; }
  .list-row-body { padding-left: 16px; }
  .field-pair-row, .list-row-inline .list-row-fields { grid-template-columns: minmax(0, 1fr); }
}
.table-card { overflow-x: auto; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 20px 0 0; padding-top: 16px; border-top: 1px solid var(--x-color-border); }
.facts dd { margin: 0; min-width: 0; }
.usage-list { margin: 0; padding-inline-start: 1.1em; display: grid; gap: 4px; }

/* Page and catalog editors: the editor and the live preview side by side. The handle moves the border; --split is its place. */
.admin-main.wide { max-width: none; }
.editor-split { --split: 50%; display: grid; grid-template-columns: minmax(360px, var(--split)) 16px minmax(320px, 1fr); column-gap: 4px;
  align-items: start; }
.editor-split > [data-editor-root] { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--admin-gap); min-width: 0; }
.editor-split .block-card .card-head { flex-wrap: wrap; }
.split-handle { position: sticky; top: 84px; height: calc(100vh - 104px); display: flex; justify-content: center; cursor: col-resize;
  touch-action: none; border-radius: 8px; }
.split-handle::before { content: ""; width: 4px; height: 100%; border-radius: 2px; background: var(--x-color-border); transition: background .15s; }
.split-handle:hover::before, .split-handle:focus-visible::before, .editor-split.resizing .split-handle::before { background: var(--x-color-primary); }
.split-handle:focus-visible { outline: none; }
.editor-split.resizing { cursor: col-resize; user-select: none; }
/* The frame does not take the pointer while the handle moves, so the drag does not stop over it. */
.editor-split.resizing iframe { pointer-events: none; }
.preview-pane { position: sticky; top: 84px; height: calc(100vh - 104px); display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.preview-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.preview-devices { display: flex; gap: 4px; margin-left: auto; }
.preview-viewport { position: relative; flex: 1; min-height: 0; overflow: hidden; border: 1px solid var(--x-color-border);
  border-radius: var(--admin-radius); background: color-mix(in srgb, var(--x-color-text) 6%, var(--x-color-bg)); }
/* preview.js sets the width of the device, the scale and the height that fills the viewport. */
#preview-frame { position: absolute; top: 0; left: var(--frame-left, 0); width: var(--frame-width, 1440px); height: var(--frame-height, 100%);
  border: 0; background: var(--x-color-bg); transform: scale(var(--frame-scale, 1)); transform-origin: 0 0; }

/* Media picker field. */
.media-field { display: grid; gap: 8px; }
.media-pick { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding: 12px; border: 1px dashed var(--x-color-border); border-radius: 12px; }
.media-selection { display: block; width: 132px; flex: none; border-radius: 8px; overflow: hidden; }
.media-pick-info { display: grid; flex: 1; min-width: 160px; }
/* A light logo stands on a dark ground in both themes: the text colour of the light theme, the page colour of the dark one. */
.media-field-dark .media-selection { --x-image-bg: light-dark(var(--x-color-text), var(--x-color-bg)); background: var(--x-image-bg); padding: 10px; box-sizing: border-box; }
.media-picker { display: grid; gap: 16px; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.pick-card x-image { display: block; margin-bottom: 6px; border-radius: 8px; overflow: hidden; }
.pick-card x-button { width: 100%; margin-top: 6px; }
.picker-foot { display: flex; justify-content: flex-end; gap: 8px; }
.search-row { display: flex; align-items: flex-end; gap: 8px; }
.search-row x-form-field { flex: 1; }

/* Media library. */
.upload-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: var(--admin-gap); align-items: start; }
.upload-drop, .upload-fields { display: grid; gap: 12px; }
.upload-fields x-button { justify-self: start; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.toolbar .form-wrapper { flex: 1; max-width: 520px; }
#media-results { display: grid; gap: 24px; scroll-margin-top: 84px; }
/* The pager of the media: «← Назад» at the left, the page number in the middle, «Дальше →» at the right. */
.pager.media-pager { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; }
.media-pager > :first-child { justify-self: start; }
.media-pager > :last-child { justify-self: end; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.media-link { display: block; height: 100%; color: inherit; border-radius: var(--admin-radius); }
.media-link:focus-visible { outline: 2px solid var(--x-color-focus-ring); outline-offset: 3px; }
.media-card { height: 100%; }
.media-card x-image { display: block; margin-bottom: 10px; border-radius: 10px; overflow: hidden; }
.media-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
/* A document has a sheet with its type in place of a thumbnail. */
.media-file-tile { display: flex; align-items: center; justify-content: center; aspect-ratio: 4 / 3; margin-bottom: 10px;
  border-radius: 10px; background: var(--x-color-surface-hover, color-mix(in srgb, var(--x-color-text) 5%, transparent)); }
.media-file-sheet { display: flex; align-items: flex-end; justify-content: center; width: 56px; height: 68px; padding-bottom: 8px;
  box-sizing: border-box; border: 1.5px solid var(--x-color-border); border-radius: 8px; background: var(--x-color-surface);
  font-family: ui-monospace, monospace; font-size: 12px; font-weight: 600; color: var(--x-color-text); }
.media-meta x-typography { min-width: 0; }
.empty-card::part(base) { display: grid; justify-items: center; gap: 10px; text-align: center; }
.pager { display: flex; justify-content: center; }
.image-card x-image { display: block; border-radius: 10px; overflow: hidden; }
.media-detail-image { max-height: 600px; }
/* A list thumbnail sits on a solid neutral: a white logo and a dark logo both read on it in both themes. A small
   image keeps its size with 12 px around it. The checkerboard means «transparent» and stays in the media card. */
x-image.thumb::part(frame), .media-selection::part(frame) {
  background: color-mix(in srgb, var(--x-color-text) 30%, var(--x-color-surface)); }
x-image.thumb.small::part(image) { box-sizing: border-box; padding: 12px; }
.media-detail-image::part(frame) { background: repeating-conic-gradient(color-mix(in srgb, var(--x-color-text) 45%, var(--x-color-surface)) 0 25%, var(--x-color-surface) 0 50%) 0 0 / 16px 16px; }
/* A tall image keeps its full height: a narrower box, not a clipped one. */
.media-detail-image.portrait { max-height: none; width: min(100%, 400px); margin-inline: auto; }

/* Settings. */
.settings-aside { position: sticky; top: 84px; display: grid; gap: var(--admin-gap); }
.snippet { display: grid; gap: 2px; padding: 14px; margin-bottom: 10px; border: 1px solid var(--x-color-border); border-radius: 10px; }
.snippet x-typography[variant=subtitle1] { --x-typography-color: var(--x-color-primary); }
/* The page card: the tabs, the link card preview and the list of automatic structured data. */
.page-fields { display: grid; gap: 16px; }
.link-card { display: grid; max-width: 440px; overflow: hidden; border: 1px solid var(--x-color-border); border-radius: 10px; background: var(--x-color-surface); }
.link-card-image { display: block; width: 100%; }
.link-card-empty { display: grid; place-items: center; aspect-ratio: 1.91 / 1; padding: 12px; text-align: center;
  background: color-mix(in srgb, var(--x-color-text) 6%, transparent); }
.link-card-text { display: grid; gap: 2px; padding: 10px 14px 12px; }
.markup-list { display: grid; gap: 6px; margin: 0; padding-left: 20px; }
.pair-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
#settings-contacts { display: grid; gap: 0; }
#settings-contacts .card-head { margin-bottom: 8px; }
.contact-card { display: grid; gap: 12px; padding: 16px 0; }
.contact-card ~ .contact-card { border-top: 1px solid var(--x-color-border); }
.contact-fields { display: grid; grid-template-columns: 180px minmax(0, 1fr) minmax(0, 1.5fr); gap: 12px; align-items: start; }
.contact-kind { display: grid; gap: 4px; }
.contact-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.contact-placement { display: flex; flex-wrap: wrap; align-items: center; gap: 20px; }
.checkbox-label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.checkbox-label x-typography { --x-typography-color: var(--x-color-text); }
.checkbox-label x-checkbox[error] { outline: 2px solid var(--x-color-danger); outline-offset: 3px; }
.contact-ops { display: flex; gap: 2px; }
.empty-note { padding: 16px 0; }
x-tabs { display: block; }

/* Login. */
.login-shell { display: grid; place-items: center; min-height: 100vh; padding: 16px;
  background: color-mix(in srgb, var(--x-color-primary) 6%, var(--x-color-bg)); }
.login-card { display: block; width: 100%; max-width: 420px; }
.login-card::part(base) { display: grid; gap: 20px; }
.login-brand { display: flex; align-items: center; gap: 12px; }
.login-brand > div { display: grid; }

@media (max-width: 1100px) {
  .editor-columns { grid-template-columns: minmax(0, 1fr); }
  .settings-aside { position: static; }
  .editor-split { grid-template-columns: minmax(0, 1fr); gap: var(--admin-gap); }
  .split-handle { display: none; }
  .preview-pane { position: static; height: 75vh; }
}
@media (max-width: 860px) {
  .page-actions { justify-content: flex-start; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 16px;
    border-right: 0; border-bottom: 1px solid var(--x-color-border); }
  .brand { padding: 0; }
  .brand-text x-typography[variant=caption] { display: none; }
  .nav { display: flex; order: 3; width: 100%; overflow-x: auto; gap: 4px; }
  .nav-link { white-space: nowrap; }
  .nav-group { display: contents; }
  .nav-group-title { display: none; }
  .side-foot { margin: 0 0 0 auto; padding: 0; border: 0; }
  .operator { display: none; }
  .topbar { position: static; padding: 10px 16px; }
  .admin-main { padding: 20px 16px 40px; }
  .upload-grid { grid-template-columns: minmax(0, 1fr); }
  .contact-fields, .pair-fields { grid-template-columns: minmax(0, 1fr); }
  .media-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}
@media (max-width: 520px) {
  .topbar-link { padding: 6px 8px; }
  .page-actions { width: 100%; }
}

/* Component tokens. */
.brand x-avatar, .login-brand x-avatar { --x-avatar-bg: var(--x-color-primary); --x-avatar-color: var(--x-color-bg); }
.table-card x-table { --x-table-border-color: transparent; }
.table-card x-table-cell { --x-table-cell-padding: 10px 16px; }
.table-card x-table-cell[type=header] { --x-table-cell-header-bg: color-mix(in srgb, var(--x-color-text) 4%, var(--x-color-surface));
  --x-table-cell-header-color: var(--x-color-text-muted); --x-table-cell-font-size: var(--x-font-size-sm); }
x-tabs { --x-tabs-gap: 4px; }
.settings-aside .facts { margin: 0; padding: 0; border: 0; }
.media-link:hover x-card { --x-card-border-color: var(--x-color-primary); }

/* Catalog. */
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
.row-actions .form-wrapper { width: auto; }
.catalog-row.level-1 x-table-cell:first-child { padding-left: 24px; }
.catalog-row.level-2 x-table-cell:first-child { padding-left: 48px; }
.catalog-name { display: flex; align-items: center; gap: 8px; }
.catalog-name x-icon { color: var(--x-color-text-muted); flex: none; }
.catalog-group x-table-cell { --x-table-cell-padding: 10px 20px 4px; }
/* The label of a select matches the label of x-form-field: the same line and gap, so a select and a field in one row align. */
.select-field { display: grid; gap: 4px; }
.select-field > x-typography.field-label { line-height: normal; font-weight: 500; }
/* In the tile grid of a hero the fact is its own cell: the corner of the fact does not apply. */
[data-form-group="media"]:has([data-one-of-option="tiles"]:not([hidden])) ~ [data-form-group="fact"] .select-field:has(#field-fact-corner) { display: none; }
.price-fields { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.2fr); gap: 12px;
  align-items: start; padding: 0; margin: 0; border: 0; }
.price-fields > x-typography { grid-column: 1 / -1; }
/* A BareDOM host sets its own display, so the `hidden` attribute needs this rule to hide it. */
[hidden] { display: none !important; }
.gallery-field { display: grid; gap: 12px; padding-top: 8px; border-top: 1px solid var(--x-color-border); }
.gallery-rows { display: grid; gap: 10px; }
.gallery-row { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto auto; gap: 12px; align-items: center; }
.seo-fields { display: grid; gap: 12px; padding-top: 8px; border-top: 1px solid var(--x-color-border); }
@media (max-width: 860px) {
  .price-fields { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

/* Image editor: the tools above the stage, Cropper.js draws inside the stage. */
/* The stage takes the free width; the settings keep a fixed column, so a tab change does not move the image. */
.image-editor { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 12px 20px; align-items: start; }
.image-editor-main { display: grid; gap: 10px; min-width: 0; }
.image-editor-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.image-editor-tools #image-editor-compare { margin-inline-start: auto; }
.image-editor-stage { position: relative; height: max(320px, calc(100dvh - 250px)); background: var(--x-color-surface-hover); border-radius: 8px; overflow: hidden; }
.image-editor-stage img { display: block; max-width: 100%; }
/* image-editor.js sets --image-editor-filter: a quick browser preview of the colour settings. */
.image-editor-stage .cropper-canvas img, .image-editor-stage .cropper-view-box img { filter: var(--image-editor-filter, none); }
#image-editor-result { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; object-fit: contain;
  background: var(--x-color-surface-hover); }
#image-editor-result[hidden] { display: none; }
#image-editor-result.is-loading { opacity: .55; transition: opacity .2s; }
#image-editor-wait { position: absolute; inset: 0; display: grid; place-items: center; background: var(--x-color-surface-hover); }
#image-editor-wait[hidden] { display: none; }
.image-editor-panel { display: grid; gap: 14px; height: max(320px, calc(100dvh - 250px)); grid-template-rows: auto minmax(0, 1fr); }
.image-editor-fields { display: grid; gap: 12px; align-content: start; overflow-y: auto; scrollbar-gutter: stable; padding-inline-end: 12px; }
.image-editor-fields[hidden] { display: none; }
.image-editor-setting { display: grid; gap: 4px; }
/* The reset button has its own column: a hidden button keeps the width of the slider. */
.image-editor-slider { display: grid; grid-template-columns: minmax(0, 1fr) 32px; align-items: end; gap: 4px; }
.image-editor-tabs-row { display: flex; align-items: center; justify-content: space-between; gap: 4px; min-width: 0; }
.image-editor-tabs-row x-tabs { flex: 1 1 auto; min-width: 0; }
.image-editor-reset-all { visibility: hidden; }
.image-editor-panel:has(#image-editor-tab-color:not([hidden])) .image-editor-reset-all { visibility: visible; }
.image-editor-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; width: 100%; }
@media (max-width: 860px) {
  .image-editor { grid-template-columns: minmax(0, 1fr); }
  .image-editor-panel { height: auto; }
}
#image-editor-feedback { grid-column: 1 / -1; }
#image-editor-feedback:empty { display: none; }
/* x-slider has its own colours; the theme tokens make it follow the light and the dark theme. */
x-slider { --x-slider-fill-color: var(--x-color-primary); --x-slider-thumb-color: var(--x-color-surface);
  --x-slider-thumb-border: 2px solid var(--x-color-primary); --x-slider-focus-ring: var(--x-color-focus-ring);
  --x-slider-track-color: var(--x-color-border); --x-slider-label-color: var(--x-color-text);
  --x-slider-value-color: var(--x-color-text-muted); }

/* The login form uses native fields so that a password manager can save and fill them.
   The rules repeat the look of x-form-field and x-button through the BareDOM theme tokens. */
.login-form { display: grid; gap: 16px; }
.login-field { display: grid; gap: 6px; }
.login-field label { color: var(--x-color-text); font-size: var(--x-font-size-sm, 0.875rem); font-weight: 500; }
.login-field input { box-sizing: border-box; width: 100%; padding: 0.5rem 0.75rem; border: 1px solid var(--x-color-border);
  border-radius: var(--x-radius-md, 6px); background: var(--x-color-surface); color: var(--x-color-text); font: inherit; }
.login-field input:focus-visible { outline: 2px solid var(--x-color-primary); outline-offset: 1px; }
.login-submit { justify-self: start; padding: 0.55rem 1.1rem; border: 0; border-radius: var(--x-radius-md, 6px);
  background: var(--x-color-primary); color: var(--x-color-bg); font: inherit; font-weight: 600; cursor: pointer; }
.login-submit:hover { filter: brightness(1.08); }
.login-submit:focus-visible { outline: 2px solid var(--x-color-primary); outline-offset: 2px; }

/* An unsaved open card blocks the block operations (page-editor.js). The buttons look unavailable, so a click
   that does nothing is not a surprise. */
html[data-editor-busy="true"] :is([data-block-op], [data-block-add]) { opacity: .45; cursor: not-allowed; }

/* The main point of the image editor. The layer covers the stage and takes the clicks; image-editor.js sets
   --mark-x and --mark-y in pixels of the stage. The mark is white with a dark edge on purpose: it stands on a
   photo, not on the theme. */
.image-editor-point { position: absolute; inset: 0; z-index: 2; cursor: crosshair; touch-action: none; }
.image-editor-point[hidden] { display: none; }
.image-editor-point:focus-visible { outline: 2px solid var(--x-color-primary); outline-offset: -2px; }
.image-editor-mark { position: absolute; left: var(--mark-x, 50%); top: var(--mark-y, 50%); width: 56px; height: 56px;
  transform: translate(-50%, -50%); pointer-events: none; }
.image-editor-mark::before { content: ""; position: absolute; inset: 12px; border: 2px solid white; border-radius: 50%;
  box-shadow: 0 0 0 1px color-mix(in srgb, black 35%, transparent), inset 0 0 0 1px color-mix(in srgb, black 35%, transparent); }
.image-editor-mark::after { content: ""; position: absolute; inset: 0; filter: drop-shadow(0 0 1px color-mix(in srgb, black 60%, transparent));
  background: linear-gradient(white, white) center / 2px 100% no-repeat, linear-gradient(white, white) center / 100% 2px no-repeat; }
.image-editor-modes { display: flex; flex-wrap: wrap; gap: 4px; }
.image-editor-mode { display: grid; gap: 6px; }
.image-editor-mode[hidden] { display: none; }
.image-editor-mode .inline-actions { justify-content: space-between; }
.image-editor-slots-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; margin-top: 6px; }
/* The previews show the photo in the real places of the site, at their ratios. */
.image-editor-slots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 10px; align-items: start; }
.image-editor-slot { display: grid; gap: 4px; min-width: 0; }
.image-editor-slot.wide { grid-column: 1 / -1; }
.image-editor-slot x-image { --x-image-radius: 6px; }

/* The section «Блоки»: the guide list and the guide card of a block type. */
.guide-list { display: grid; gap: 28px; }
.guide-group { display: grid; gap: 12px; }
.guide-group > x-typography { color: var(--x-color-text-muted); }
.guide-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--admin-gap); }
@media (min-width: 800px) { .guide-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1200px) { .guide-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.guide-tile { display: block; color: inherit; text-decoration: none; border-radius: var(--x-radius-md); }
.guide-tile x-card { height: 100%; }
.guide-tile:hover x-card { --x-card-border-color: var(--x-color-primary); }
.guide-tile .wf { max-width: 240px; margin-bottom: 12px; }
.guide-purpose { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden;
  margin: 6px 0 10px; color: var(--x-color-text-muted); }
.guide-badges { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.guide-card { display: grid; gap: 16px; }
.guide-card > .action-link { justify-self: start; }
.guide-card-columns { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: var(--admin-gap); align-items: start; }
.guide-aside { position: sticky; top: 84px; display: grid; gap: 8px; }
.guide-aside .wf { max-width: 240px; }
.guide-aside > x-typography[variant="overline"] { margin-top: 8px; color: var(--x-color-text-muted); }
.guide-card form, .guide-card x-form { display: grid; gap: 20px; }
.guide-field { display: grid; gap: 6px; }
.guide-default { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.guide-default [hidden] { display: none; }
.guide-default-text { color: var(--x-color-text-muted); flex: 1 1 240px; }
.guide-variants { display: grid; gap: 16px; padding-top: 8px; border-top: 1px solid var(--x-color-border); }
.guide-variants > x-typography { color: var(--x-color-text-muted); }
.guide-variant-group { display: grid; gap: 14px; }
.block-choice-hint { display: grid; gap: 10px; align-content: start; }
.block-choice-hint .muted, .muted { color: var(--x-color-text-muted); }
.place-warning { margin-bottom: 12px; }
@media (max-width: 900px) {
  .guide-card-columns { grid-template-columns: minmax(0, 1fr); }
  .guide-aside { position: static; }
}
.guide-card > .action-link { padding-left: 0; }
.block-choice-detail > .wf { max-width: 360px; justify-self: center; }

/* Recipes: the tab «Заготовки страниц», the recipe card and the choice of «Новая страница». */
#blocks-tabs { margin-bottom: 16px; }
.recipe-purpose, .recipe-note { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 1; line-clamp: 1; overflow: hidden; }
.recipe-purpose { color: var(--x-color-text-muted); }
.recipe-card { display: grid; gap: 16px; }
.recipe-card > .action-link { justify-self: start; padding-left: 0; }
.recipe-card-columns { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--admin-gap); align-items: start; }
@media (min-width: 1200px) { .recipe-card-columns { grid-template-columns: minmax(0, 1fr) 200px; } }
.recipe-card .block-list > x-typography[variant="overline"] { margin-top: 12px; color: var(--x-color-text-muted); }
.recipe-slot-closed { display: grid; gap: 8px; }
.recipe-slot-wf { flex: none; width: 80px; }
.recipe-note { color: var(--x-color-text-muted); }
.recipe-slot x-text-area { display: block; margin-bottom: 16px; }
.recipe-starter { display: grid; gap: 8px; }
.recipe-starter > x-typography[variant="caption"] { color: var(--x-color-text-muted); }
.recipe-outline { display: none; }
@media (min-width: 1200px) {
  .recipe-outline { position: sticky; top: 84px; display: grid; gap: 4px; }
  .recipe-outline > x-typography { color: var(--x-color-text-muted); margin-bottom: 4px; }
}
.recipe-outline-item { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: var(--x-radius-md);
  color: var(--x-color-text); text-decoration: none; }
.recipe-outline-item:hover, .recipe-outline-item[aria-current="true"] { background: var(--x-color-surface-hover); }
.recipe-outline-wf { flex: none; width: 40px; }
/* A disabled tool stays a ghost icon. The open slot keeps its tools at the right edge, as the closed row does. */
.block-tools x-button[disabled]::part(button) { background: transparent; border-color: transparent; color: var(--x-color-text); opacity: .35; }
.block-tools x-button[disabled] x-icon { color: var(--x-color-text); }
.recipe-slot.open .card-head { justify-content: space-between; }
.recipe-outline-wf .wf, .recipe-preview-wf .wf { border-radius: 4px; }
.recipe-starter > .editor-fields { margin-top: 8px; }
/* The row menu opens below the last row; the recipe table has few columns and needs no inner scroll. */
.table-card.recipe-table { overflow: visible; }
.recipe-group { display: grid; gap: 8px; }
.recipe-group + .recipe-group { margin-top: 24px; }
.recipe-row .row-title + x-typography { display: block; color: var(--x-color-text-muted); }
/* «Новая страница», step 1: the recipe list at the left, the sticky preview at the right. The preview starts 132 px
   from the top, so its height leaves that space and its button row stays in view on the first paint. The signal pageStep
   toggles .is-off; the server sets it for the first paint. */
.is-off { display: none !important; }
.recipe-step-title { display: block; margin-bottom: 16px; }
.recipe-pick { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 899px) { .recipe-pick { grid-template-columns: minmax(0, 1fr); } }
.recipe-pick-list { display: grid; gap: 20px; }
.recipe-pick-group { display: grid; gap: 4px; }
.recipe-pick-eyebrow { display: block; margin: 0 0 4px 12px; font-size: 12px; font-weight: 700; text-transform: uppercase;
  color: var(--x-color-text-muted); }
.recipe-pick-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto 14px; align-items: center; gap: 12px;
  min-height: 56px; padding: 0 12px; border: 1.5px solid transparent; border-radius: 12px; color: var(--x-color-text);
  text-decoration: none; }
.recipe-pick-row:hover { background: var(--x-color-surface-hover); }
.recipe-pick-row[aria-current="true"] { border-color: var(--x-color-primary);
  background: color-mix(in srgb, var(--x-color-primary) 10%, var(--x-color-surface)); }
.recipe-pick-text { display: grid; min-width: 0; }
.recipe-pick-name { font-size: 15px; font-weight: 600; }
.recipe-pick-purpose { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 1; line-clamp: 1; overflow: hidden;
  font-size: 13px; color: var(--x-color-text-muted); }
.recipe-pick-side { font-size: 13px; white-space: nowrap; color: var(--x-color-text-muted); }
.recipe-pick-mark { color: var(--x-color-text-muted); }
.recipe-preview { position: sticky; top: 76px; display: flex; flex-direction: column; overflow: hidden;
  max-height: calc(100dvh - 132px - 24px); border: 1px solid var(--x-color-border); border-radius: 16px; background: var(--x-color-surface); }
.recipe-preview-body { display: grid; align-content: start; gap: 12px; flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 28px 28px 16px; }
.recipe-preview-name { font-size: 24px; font-weight: 700; }
.recipe-preview-purpose { font-size: 15px; }
.recipe-preview-body > .recipe-pick-eyebrow { margin: 8px 0 0; }
.recipe-preview-blocks { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.recipe-preview-block { display: grid; grid-template-columns: 20px 96px minmax(0, 1fr); align-items: center; gap: 12px; }
.recipe-preview-n { font-family: var(--x-font-family-mono, monospace); font-size: 13px; color: var(--x-color-text-muted); }
.recipe-preview-wf { display: block; width: 96px; }
.recipe-preview-wf .wf { display: block; width: 96px; height: 56px; border-radius: 8px; }
.recipe-preview-text { display: grid; gap: 2px; min-width: 0; }
.recipe-preview-note { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
  font-size: 13px; color: var(--x-color-text-muted); }
.recipe-preview-foot { flex: none; display: grid; justify-items: end; gap: 8px; padding: 16px 28px 24px; border-top: 1px solid var(--x-color-border); }
.recipe-preview-foot > x-typography { justify-self: stretch; text-align: right; color: var(--x-color-text-muted); }
@media (max-width: 899px) { .recipe-preview { position: static; max-height: none; } }
/* Step 2: the chosen recipe above the fields. */
.recipe-summary x-alert { flex-basis: 100%; }
/* «Далее» is the main action of step 1: a primary link, white label as on the primary x-button. */
.action-link.recipe-next { border-color: var(--x-color-primary); background: var(--x-color-primary); color: white; text-decoration: none; }
.action-link.recipe-next:hover { background: var(--x-color-primary-hover); }
.recipe-preview-foot > .action-link:not(.recipe-next) { text-decoration: none; }
/* The icon of a recipe: the wireframe of its first block in a 40 px box; no blocks gives a dashed box with «+». */
.recipe-icon { display: grid; place-items: center; box-sizing: border-box; width: 40px; height: 40px; overflow: hidden;
  border: 1px solid var(--x-color-border); border-radius: 8px; background: var(--x-color-surface); }
.recipe-icon .wf { display: block; width: 100%; height: 100%; }
.recipe-icon.empty { border: 1.5px dashed var(--x-color-border); font-size: 20px; color: var(--x-color-text-muted); }
/* Step 2: the chosen recipe as a row above the fields. */
.recipe-summary { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 4px 12px;
  padding: 12px 16px; border-radius: 10px; background: var(--x-color-surface-hover); }
.recipe-summary-text { display: grid; min-width: 0; }
.recipe-summary x-alert { grid-column: 1 / -1; }

/* The page «Доступ агентов». */
.token-rights { display: flex; flex-wrap: nowrap; gap: 6px; white-space: nowrap; }
/* Only the text of a cell keeps one line; the confirm modals inside the actions cell wrap as usual. */
.token-row > x-table-cell:nth-child(n+3) > x-typography { white-space: nowrap; }
.danger-ghost { --x-button-ghost-fg: var(--x-color-danger); }
/* A destructive action of the page head: a secondary button with the danger text. */
.danger-secondary { --x-button-secondary-fg: var(--x-color-danger); }
.token-row.is-new { animation: token-new 2s ease-out; }
@keyframes token-new { from { background: color-mix(in srgb, var(--x-color-primary) 14%, transparent); } to { background: transparent; } }
.token-server-note { grid-column: span 2; }
.token-server x-typography { color: var(--x-color-text-muted); }
.token-revoked-list { margin-top: 20px; }
.token-revoked-list > summary { display: flex; align-items: center; gap: 8px; cursor: pointer; margin-bottom: 12px; color: var(--x-color-text-muted); }
.token-revoked-list > summary::before { content: "▸"; }
.token-revoked-list[open] > summary::before { content: "▾"; }
.token-revoked-list > summary::-webkit-details-marker { display: none; }
.token-revoked-list > summary { list-style: none; }
.token-revoked { opacity: 0.55; }
.token-empty::part(body) { display: grid; justify-items: start; gap: 16px; }
.token-form, .token-issued { display: grid; gap: 18px; }
.token-form-rights { display: grid; gap: 8px; }
.token-copy { display: grid; gap: 6px; }
.token-copy-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px; background: var(--x-color-surface-hover); }
.token-value { font-family: var(--x-font-family-mono, ui-monospace, monospace); font-size: 14px; word-break: break-all; }
.token-copy-all { width: 100%; }
.token-copy-all::part(button) { width: 100%; }
@media (max-width: 900px) {
  .token-row { display: grid; gap: 6px; padding: 12px 0; }
  .token-server-note { grid-column: auto; }
}

/* The screen «Оформление»: the groups of the theme form, the palette and the contrast tables, the knobs. */
.theme-fields { display: grid; gap: 28px; }
.theme-group { display: grid; gap: 10px; }
.theme-palette, .theme-contrast { display: grid; gap: 6px; }
.theme-row { display: grid; grid-template-columns: minmax(0, 1fr) 112px 112px; gap: 10px; align-items: center; }
.theme-row [role="cell"] { display: flex; justify-content: center; }
.theme-row [role="rowheader"] { overflow-wrap: normal; hyphens: auto; }
.theme-knob { display: grid; gap: 6px; }
.theme-options { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.radio-label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.radio-label x-typography { --x-typography-color: var(--x-color-text); }
/* A closed color picker is its button: the container of x-color-picker keeps 240 px otherwise. The open panel keeps
   its width. The palette cells stand at the right of the card, so their panels open from the right edge of the
   button; each panel stays on the screen. */
.theme-fields x-color-picker::part(container) { width: auto; }
.theme-fields x-color-picker::part(panel) { width: min(240px, calc(100vw - 32px)); }
.theme-row x-color-picker::part(panel),
.theme-single x-color-picker::part(panel) { left: auto; right: 0; }
@media (max-width: 600px) {
  .theme-row { grid-template-columns: minmax(0, 1fr) 76px 76px; gap: 6px; }
  /* The light column stands in the middle of the phone screen: its panel opens centered on the button. */
  .theme-row [role="cell"]:nth-child(2) x-color-picker::part(panel) { left: 50%; right: auto; transform: translateX(-50%); }
}
.theme-reset { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 20px; }
/* A color cell: the picker, then its reset button. A hidden button keeps its place, so the pickers stay in line. */
.theme-cell { display: inline-grid; grid-template-columns: auto 32px; align-items: center; gap: 2px; }
.theme-cell x-button[hidden] { display: inline-block !important; visibility: hidden; }
.theme-single { display: grid; grid-template-columns: minmax(0, 1fr) 112px; gap: 10px; align-items: center; }
.theme-single .theme-cell { justify-self: center; }
.theme-field-head { display: flex; align-items: center; gap: 4px; min-height: 32px; }
/* The ready themes: a card per theme with its swatch strip. */
.theme-presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.theme-preset { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 6px 8px; padding: 10px 12px;
  border: 1px solid var(--x-color-border); border-radius: var(--x-radius-md, 8px); cursor: pointer; }
.theme-preset:has(x-radio[checked]) { border-color: var(--x-color-primary); }
.theme-preset .theme-swatch { grid-column: 1 / -1; grid-row: 1; width: 100%; height: 20px; border-radius: 4px;
  outline: 1px solid var(--x-color-border); }
@media (max-width: 600px) {
  .theme-single { grid-template-columns: minmax(0, 1fr) 76px; }
  .theme-presets { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* The uploaded fonts: a row per font with its check and its removal, then the upload form. */
#theme-own-fonts { margin-top: 16px; }
.theme-own-font { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid var(--x-color-border); }
.theme-own-add { display: grid; gap: 12px; margin-top: 8px; }
.theme-own-add x-button { justify-self: start; }

/* The screen «Поиск»: the switch and the index state in one card, then the query log. */
.search-state { display: block; margin-bottom: 20px; }
.search-switch { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.search-index { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--x-color-border); }
.search-index-body { display: grid; gap: 8px; }
.search-log { display: grid; gap: 12px; }
/* The filter of the log: a segmented control of two states, as small as a row tool. */
.search-log-filter { display: inline-flex; justify-self: start; gap: 2px; padding: 3px; border: 1px solid var(--x-color-border);
  border-radius: var(--x-radius-md); background: var(--x-color-surface); }
.search-log-filter .action-link { min-height: var(--x-button-height-sm, 2rem); border-color: transparent; background: transparent;
  color: var(--x-color-text-muted); font-size: var(--x-font-size-sm); }
.search-log-filter .action-link[aria-current="page"] { color: var(--x-color-primary);
  background: color-mix(in srgb, var(--x-color-primary) 12%, transparent); }
.search-log .pager { gap: 24px; }

/* Forms: the field cards of the form editor. See docs/specs/009-forms.md, W3. */
#form-fields-editor { display: grid; gap: 0; }
.form-field-card { display: grid; gap: 12px; padding: 16px 0; }
.form-field-card ~ .form-field-card { border-top: 1px solid var(--x-color-border); }
.form-field-main { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 12px; align-items: start; }
.form-field-fixed { display: grid; gap: 4px; padding-top: 26px; }
.form-field-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.form-field-flags { display: flex; flex-wrap: wrap; align-items: center; gap: 20px; }
.form-field-add { padding-top: 12px; }
.form-usage { display: flex; flex-wrap: wrap; gap: 4px 12px; }
@media (max-width: 720px) { .form-field-main { grid-template-columns: minmax(0, 1fr); } .form-field-fixed { padding-top: 0; } }
.form-bot, .form-test { display: grid; gap: 8px; justify-items: start; }
.form-test-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.form-test-list li { display: flex; align-items: center; gap: 8px; }

/* Requests: the table, and the card in a drawer. See docs/specs/009-forms.md, W8. */
.requests-body { display: grid; gap: var(--admin-gap); align-items: start; }
#requests-list { display: grid; gap: 12px; min-width: 0; }
.admin-main > div:is(.requests-toolbar, .list-toolbar) { display: flex; flex-wrap: wrap; justify-content: flex-start; align-items: end; gap: 12px; }
.requests-toolbar .requests-export { margin-left: auto; }
:is(.requests-toolbar, .list-toolbar) > x-form-field { flex: 1 1 220px; max-width: 300px; }
.requests-filters { display: flex; flex-wrap: wrap; align-items: end; gap: 8px 12px; }
.requests-filters x-select { width: 170px; }
.list-toolbar x-select { width: 190px; }
#requests-list .pager { gap: 24px; }
.request-row.is-open { background: var(--x-color-surface-hover, var(--x-color-bg)); }
.request-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.request-values { display: grid; gap: 2px; margin: 16px 0; }
.request-values dt { color: var(--x-color-text-muted); font-size: 13px; }
.request-values dt:not(:first-child) { margin-top: 10px; }
.request-values dd { margin: 0; overflow-wrap: anywhere; white-space: pre-line; }
.request-files { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; white-space: normal; }
.request-file-size { color: var(--x-color-text-muted); }
.request-status { display: flex; align-items: end; gap: 12px; margin-bottom: 16px; }
.request-card-foot { display: flex; justify-content: flex-end; margin-top: 16px; }
.request-drawer-foot { display: flex; align-items: end; gap: 12px; }
.request-drawer-foot > :first-child { flex: 1; }
.request-drawer-foot .request-status { margin: 0; }
.requests-options .request-status { flex-wrap: wrap; }
.request-status .select-field { flex: 1; }
.request-status-cell { display: flex; flex-wrap: wrap; gap: 4px; }
.request-deliveries { display: grid; gap: 8px; margin-bottom: 16px; }
.request-delivery-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.request-delivery { display: grid; gap: 4px; justify-items: start; }
.request-delivery-head { display: flex; align-items: center; gap: 8px; overflow-wrap: anywhere; }
.requests-options-body { display: grid; gap: 12px; }
.requests-options .request-status { margin-bottom: 0; }

/* Requests: the part «Откуда пришёл». See docs/specs/010-attribution.md, W5. */
.request-attribution { display: grid; gap: 8px; margin-bottom: 16px; }
.request-attribution .request-values { margin: 0; }
.request-touches > summary { display: flex; align-items: center; gap: 8px; cursor: pointer; list-style: none; color: var(--x-color-text-muted); }
.request-touches > summary::-webkit-details-marker { display: none; }
.request-touches > summary::before { content: "▸"; }
.request-touches[open] > summary::before { content: "▾"; }
.request-touch-list { display: grid; gap: 10px; margin: 10px 0 0; padding-left: 20px; }
.request-touch-list li { display: grid; gap: 2px; overflow-wrap: anywhere; }
/* The export of the screen «Заявки» and the screen «Партнёры». See docs/specs/010-attribution.md, W6–W8. */
.requests-export .action-link { display: inline-flex; align-items: center; gap: 6px; }
.partner-name { display: grid; gap: 2px; }
.partner-code { font-family: var(--x-font-family-mono, ui-monospace, monospace); font-size: 14px; }
.partner-link { display: flex; align-items: center; gap: 10px; min-width: 0; }
.partner-row.is-inactive > x-table-cell:not(:last-child) { opacity: 0.55; }
.partner-row.is-new { animation: token-new 2s ease-out; }
.link-builder-body { display: grid; gap: 12px; }
.link-builder-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; align-items: start; }
.link-builder-fields > div { display: grid; gap: 4px; }
/* The saved links, the parameters of an entrance and the link filter. See docs/specs/010-attribution.md, W9–W11. */
.saved-links { margin-top: 24px; }
.saved-links { display: grid; gap: 12px; }
.saved-link-row.is-new { animation: token-new 2s ease-out; }
.entry-params-body { display: grid; gap: 12px; }
.entry-params-group { display: grid; gap: 8px; margin-bottom: 16px; }
.entry-params-names { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.entry-params-names .checkbox-label x-typography { font-family: var(--x-font-family-mono, ui-monospace, monospace); }
.requests-link-filter { display: flex; align-items: center; gap: 12px; min-height: 42px; }
/* A long link in a row: one line with an ellipsis. The title shows the full link; «Копировать» copies the full link. */
.url-value { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--x-font-family-mono, ui-monospace, monospace); font-size: 13px; }
/* A tool of a row that is off stays a faint icon, not a grey plate. */
.row-actions x-button[disabled] { --x-button-fg-disabled: var(--x-color-text-muted); }
.row-actions x-button[disabled]::part(button) { background: transparent; border-color: transparent; opacity: 0.35; }
/* An off «Отменить изменения» stays a faint ghost button, not a grey plate beside «Сохранить». */
#discard-button[disabled]::part(button) { background: transparent; border-color: transparent; }
/* An empty list: the text and the next step under it. */
.empty-state-action { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.empty-state-action .form-wrapper { width: auto; }
/* The status line of an editor: a dot in the colour of the state before one text. Green: saved and on the site.
   Amber: saved, but the site shows another version. Red: the input is not saved. Grey: a save is on its way. */
.status-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--x-color-text-muted); }
.status-line:has(#dirty-status[data-state=saved][data-publish=published]) .status-dot { background: var(--x-color-success); }
.status-line:has(#dirty-status[data-state=saved]:is([data-publish=changed], [data-publish=unpublished])) .status-dot { background: var(--x-color-warning); }
.status-line:has(#dirty-status[data-state=dirty]) .status-dot { background: var(--x-color-danger); }
#dirty-status[data-state=dirty] { --x-typography-color: var(--x-color-text); }
/* «Сбросить» of a toolbar: a quiet link at the end of the filters, so the row keeps one line. */
.action-link.toolbar-reset { min-height: 42px; padding: 0 8px; border-color: transparent; background: transparent; color: var(--x-color-primary); }
.action-link.toolbar-reset:hover { background: var(--x-color-surface-hover); }
/* The slot of «Сбросить» adds no box: the link is one more item of the toolbar row. */
.toolbar-reset-slot { display: contents; }
/* The menu «⋯» of a catalog row opens past the edge of the table card. */
.table-card:has(.list-row-menu) { overflow: visible; }

/* The screen «Чат на сайте»: the groups of the rule editor and the button pairs. See docs/specs/011-chat.md, W7. */
.chat-rule-group { display: grid; gap: 14px; padding-top: 20px; border-top: 1px solid var(--x-color-border); }
.chat-buttons { display: grid; gap: 12px; }
/* A button takes two rows: the text and the action, then the page and its section. */
.chat-button-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: start; }
.chat-button-fields + .chat-button-fields { padding-top: 12px; border-top: 1px solid var(--x-color-border); }
@media (max-width: 720px) { .chat-button-fields { grid-template-columns: 1fr; } }
.chat-days { display: flex; flex-wrap: wrap; gap: 8px 18px; }
/* The screen «Чаты»: the thread of the card. The visitor is on the left, the site on the right. */
/* The newest line comes first in the source and last on the screen, so the scroll starts at the end without JS. */
.chat-thread { list-style: none; margin: 16px 0; padding: 12px; display: flex; flex-direction: column-reverse; gap: 10px; max-height: 420px;
  overflow-y: auto; border: 1px solid var(--x-color-border); border-radius: 12px; background: var(--x-color-bg); }
.chat-line { max-width: 80%; padding: 8px 12px; border-radius: 12px; background: var(--x-color-surface); align-self: flex-start; }
.chat-line-manager, .chat-line-robot { align-self: flex-end; background: var(--x-color-primary-subtle, var(--x-color-surface)); }
.chat-line-system { align-self: center; max-width: none; padding: 2px 8px; background: transparent; }
.chat-line-text { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--x-color-text); }
.chat-line-system .chat-line-head { display: none; }
.chat-line-system .chat-line-text { margin: 0; font-size: 13px; color: var(--x-color-text-muted); }
.chat-requests { display: flex; gap: 12px; margin: 8px 0 0; }
.chat-path { margin: 8px 0; padding-left: 20px; }
/* The card of a chat or a request is a drawer on the right side. The chat thread takes the height of the drawer, so
   the newest message and the reply field stay in view; the path and «Откуда пришёл» are below the thread. */
.card-drawer { --x-drawer-size: min(600px, 100vw); --x-drawer-header-padding: 20px 24px 12px; --x-drawer-body-padding: 0 24px 16px;
  --x-drawer-footer-padding: 12px 24px 16px; }
.chat-drawer .chat-thread { max-height: calc(100dvh - 330px); min-height: 200px; }
.card-drawer-head .request-card-head { align-items: center; }
.card-drawer-head .request-card-head h2 { margin: 0; }
/* A drawer of a form, a list or a tool (layout/drawer). A short question before an action stays an x-modal. */
.panel-drawer { --x-drawer-header-padding: 16px 24px; --x-drawer-body-padding: 20px 24px; --x-drawer-footer-padding: 12px 24px 16px; }
.drawer-md { --x-drawer-size: min(520px, 100vw); }
.drawer-lg { --x-drawer-size: min(760px, 100vw); }
.drawer-xl { --x-drawer-size: min(1200px, 100vw); }
.panel-drawer:not(:has(> [slot="footer"]))::part(footer) { display: none; }
.drawer-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; }
.drawer-header > :first-child { margin: 0; }
/* The buttons of a form in a drawer stay at the bottom of the panel while the form scrolls. */
.panel-drawer .drawer-actions { position: sticky; bottom: -20px; z-index: 1; margin-bottom: -20px; padding: 12px 0 20px;
  border-top: 1px solid var(--x-color-border); background: var(--x-drawer-bg, var(--x-color-bg)); }
/* x-drawer moves a closed panel off the screen only, so Tab still reaches its fields. The delay keeps the panel
   visible while it slides out. */
x-drawer:not([open]) { visibility: hidden; transition: visibility 0s linear 0.3s; }
x-drawer[open] { visibility: visible; transition: none; }
.drawer-close { flex: none; width: 40px; min-height: 40px; padding: 0; justify-content: center; }
.chat-path-fold > summary { display: flex; align-items: center; gap: 8px; cursor: pointer; list-style: none; }
.chat-path-fold > summary::-webkit-details-marker { display: none; }
.chat-path-fold > summary::before { content: "▸"; color: var(--x-color-text-muted); }
.chat-path-fold[open] > summary::before { content: "▾"; }
.chat-path-fold > summary h3 { margin: 0; }
