/* ==========================================================================
   МастерБот — shared components. Loaded by every page: the landing, help,
   legal, 404 and the server-rendered app pages (src/brand.js BRAND_HEAD_STYLE).
   Rules here use var(--token) only — no colour, font name or radius literal
   (test/theme-tokens.test.js). Everything is a .mb-* class, so it never
   collides with the app pages' own selectors; element rules are limited to
   the page body, selection and the focus ring.
   ========================================================================== */

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background-color: var(--color-ground);
  color: var(--color-ink);
  font-family: var(--font-sans);
  font-size: var(--size-body);
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
}

b, strong { font-weight: var(--weight-semibold); }

::selection { background: var(--color-selection); }

/* One focus ring everywhere; on the dark block it turns light. */
:focus-visible {
  outline: var(--focus-ring-width) solid var(--color-focus);
  outline-offset: var(--focus-ring-offset);
}
.mb-dark :focus-visible { outline-color: var(--color-focus-on-dark); }

.mb-shell {
  box-sizing: content-box;
  max-width: var(--page-max);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

.mb-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- header: logo lockup + nav ---------- */

.mb-header > .mb-shell {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4) var(--space-8);
  padding-top: 22px;
  padding-bottom: 22px;
}

.mb-lockup {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  min-height: var(--tap-min);
  color: var(--color-ink);
  text-decoration: none;
}

/* The mark is brand artwork (fixed colours in the SVG), 46 × 47 like the board. */
.mb-mark { flex: none; display: block; width: 46px; height: 47px; }
.mb-mark svg { display: block; width: 100%; height: 100%; }

.mb-lockup-text { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; min-width: 0; }

/* The wordmark is outlined paths that take the ink colour (currentColor). */
.mb-wordmark { display: block; line-height: 0; color: var(--color-ink); }
.mb-wordmark-svg { display: block; width: auto; height: 26px; max-width: none; }

.mb-descriptor {
  font-size: var(--size-caption);
  line-height: 1.2;
  color: var(--color-muted);
}

.mb-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-7);
}

.mb-nav a:not(.mb-btn) {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap-min);
  font-size: var(--size-ui);
  color: var(--color-ink);
  text-decoration: none;
}
.mb-nav a:not(.mb-btn):hover { color: var(--color-link-hover); text-decoration: underline; text-underline-offset: 4px; }
.mb-nav a[aria-current="page"] { font-weight: var(--weight-semibold); box-shadow: inset 0 calc(-1 * var(--bar-width) + 1px) 0 var(--color-accent); }

/* ---------- buttons: primary / secondary / quiet, plus sizes and on-dark ---------- */

.mb-btn {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--control-height);
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--color-ink);
  font-family: var(--font-sans);
  font-size: var(--size-ui);
  font-weight: var(--weight-semibold);
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.mb-btn--primary { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-on-primary); }
.mb-btn--primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); color: var(--color-on-primary); }
.mb-btn--primary:active { background: var(--color-primary-active); border-color: var(--color-primary-active); }

.mb-btn--secondary { background: var(--color-surface); border-color: var(--color-ink); color: var(--color-ink); }
.mb-btn--secondary:hover { background: var(--color-panel); color: var(--color-ink); }
.mb-btn--secondary:active { background: var(--color-line); }

/* Quiet = a link-styled action (also the app header's «Помощь», class mb-btn-link). */
.mb-btn--quiet,
.mb-btn-link {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap-min);
  padding: 0 2px;
  border: 0;
  background: transparent;
  color: var(--color-link);
  font-family: var(--font-sans);
  font-size: var(--size-ui);
  font-weight: var(--weight-medium);
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
}
.mb-btn--quiet:hover,
.mb-btn-link:hover { color: var(--color-link-hover); }

.mb-btn--sm { min-height: 46px; padding: 0 20px; border-radius: var(--radius-button-sm); }
.mb-btn--lg { min-height: var(--button-height); padding: 0 28px; border-radius: var(--radius-button); font-size: var(--size-button-lg); }
.mb-btn--block { display: flex; width: 100%; }

/* On the dark block: the white button and the outlined one. */
.mb-btn--on-dark { background: var(--color-on-dark); border-color: var(--color-on-dark); color: var(--color-dark); }
.mb-btn--on-dark:hover { background: var(--color-on-dark-text); border-color: var(--color-on-dark-text); color: var(--color-dark); }
.mb-btn--outline-on-dark { background: transparent; border-color: var(--color-on-dark-line); color: var(--color-on-dark); }
.mb-btn--outline-on-dark:hover { border-color: var(--color-on-dark); color: var(--color-on-dark); }

/* Disabled: a flat panel, not a faded orange that still looks pressable. */
.mb-btn:disabled,
.mb-btn[aria-disabled="true"],
.mb-btn.is-disabled {
  background: var(--color-panel);
  border-color: var(--color-line);
  color: var(--color-muted);
  cursor: not-allowed;
}

/* ---------- form controls ---------- */

.mb-field { display: flex; flex-direction: column; gap: var(--space-2); }
.mb-label { font-size: var(--size-ui); font-weight: var(--weight-semibold); color: var(--color-ink); }
.mb-label small { font-size: inherit; font-weight: var(--weight-regular); color: var(--color-muted); }
.mb-hint { margin: 0; font-size: var(--size-small); line-height: 1.45; color: var(--color-muted); }

.mb-input {
  box-sizing: border-box;
  width: 100%;
  min-height: var(--control-height);
  padding: 0 14px;
  border: 1px solid var(--color-control-border);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  color: var(--color-ink);
  font-family: var(--font-sans);
  font-size: var(--size-ui);
  line-height: 1.45;
}
textarea.mb-input { padding: 12px 14px; resize: vertical; }
.mb-input::placeholder { color: var(--color-muted); opacity: 1; }
.mb-input:hover { border-color: var(--color-ink); }
.mb-input[aria-invalid="true"] { border-color: var(--color-error); border-width: var(--selected-width); }
.mb-input:disabled { background: var(--color-panel); color: var(--color-muted); }
.mb-check { width: 20px; height: 20px; accent-color: var(--color-primary); }

/* ---------- cards, tags, chips ---------- */

.mb-card {
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-card);
  padding: 18px;
}
.mb-card--raised { box-shadow: var(--shadow-card); }
.mb-card--selected { border: var(--selected-width) solid var(--color-accent); }

/* Tag = a non-interactive pill: highlight by default, status variants. */
.mb-tag {
  display: inline-block;
  padding: 4px 12px;
  border-radius: var(--radius-tag);
  background: var(--color-highlight);
  color: var(--color-on-highlight);
  font-size: var(--size-small);
  font-weight: var(--weight-medium);
  line-height: 1.4;
}
.mb-tag--muted { background: var(--color-panel); color: var(--color-text); }
.mb-tag--success { background: var(--color-success-bg); color: var(--color-success); }
.mb-tag--warning { background: var(--color-warning-bg); color: var(--color-warning); }
.mb-tag--error { background: var(--color-error-bg); color: var(--color-error); }

/* Chip = a selectable pill (aria-pressed). Selected: 2 px accent border on the highlight. */
.mb-chip {
  box-sizing: border-box;
  min-height: var(--tap-min);
  padding: 0 14px;
  border: 1px solid var(--color-control-border);
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  color: var(--color-ink);
  font-family: var(--font-sans);
  font-size: var(--size-small);
  font-weight: var(--weight-medium);
  line-height: 1.2;
  cursor: pointer;
}
.mb-chip:hover { border-color: var(--color-ink); }
.mb-chip[aria-pressed="true"],
.mb-chip.is-selected {
  padding: 0 13px;
  border: var(--selected-width) solid var(--color-accent);
  background: var(--color-highlight);
  font-weight: var(--weight-semibold);
}

/* ---------- step bars (wizard steps, help contents, landing steps) ---------- */

.mb-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: var(--space-3);
  font-size: var(--size-small);
  line-height: 1.3;
}
.mb-steps > li {
  flex: 1 1 0;
  min-width: 0;
  padding-top: 10px;
  border-top: var(--bar-width) solid var(--color-line);
  color: var(--color-muted);
}
.mb-steps .mb-steps-n { margin-right: 6px; }
.mb-steps > li[aria-current="step"],
.mb-steps > li.is-done { border-top-color: var(--color-accent); color: var(--color-ink); }
.mb-steps > li[aria-current="step"] { font-weight: var(--weight-semibold); }
.mb-steps > li[aria-current="step"] > .mb-steps-n { color: var(--color-primary); }

/* A section that opens with the accent bar (help contents, document sections). */
.mb-barred { padding-top: var(--space-4); border-top: var(--bar-width) solid var(--color-accent); }

/* ---------- tables and definition lists ---------- */

.mb-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-card);
  overflow: hidden;
  font-size: var(--size-ui);
  line-height: 1.35;
}
.mb-table th {
  padding: 10px 16px;
  background: var(--color-panel);
  color: var(--color-muted);
  font-size: var(--size-caption);
  font-weight: var(--weight-semibold);
  text-align: left;
}
.mb-table td { padding: 12px 16px; border-top: 1px solid var(--color-line-subtle); color: var(--color-ink); }
.mb-table .num { text-align: right; font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; white-space: nowrap; }

.mb-dl {
  margin: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-card);
  line-height: 1.45;
}
.mb-dl > div { display: flex; flex-wrap: wrap; gap: 2px var(--space-4); padding: 11px 16px; border-top: 1px solid var(--color-line-subtle); }
.mb-dl > div:first-child { border-top: 0; }
.mb-dl dt { flex: 0 0 180px; color: var(--color-muted); }
.mb-dl dd { flex: 1 1 240px; margin: 0; font-weight: var(--weight-semibold); color: var(--color-ink); }

/* ---------- the data card (tabs + numbered rows), as in the landing demo ---------- */

.mb-datacard {
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.mb-tabs { display: flex; background: var(--color-panel); border-bottom: 1px solid var(--color-line); }
.mb-tab {
  flex: 1 1 0;
  min-width: 0;
  min-height: 46px;
  padding: 0 8px;
  border: 0;
  border-right: 1px solid var(--color-line);
  background: var(--color-panel);
  color: var(--color-muted);
  font-family: var(--font-sans);
  font-size: var(--size-caption);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.mb-tab:last-child { border-right: 0; }
.mb-tab[aria-pressed="true"],
.mb-tab[aria-selected="true"] {
  background: var(--color-surface);
  color: var(--color-ink);
  font-weight: var(--weight-semibold);
  box-shadow: inset 0 -3px 0 var(--color-accent);
}
.mb-rows { margin: 0; padding: 0; list-style: none; }
.mb-row {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 10px;
  padding: 13px 16px 13px 0;
  border-bottom: 1px solid var(--color-line-subtle);
  font-size: var(--size-ui);
  line-height: 1.3;
  background: var(--color-surface);
  transition: background-color 250ms ease, box-shadow 250ms ease;
}
.mb-row-n { text-align: right; font-size: var(--size-micro); color: var(--color-faint); font-variant-numeric: tabular-nums; }
.mb-row-value { font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; white-space: nowrap; }
.mb-row.is-hit { background: var(--color-highlight); box-shadow: inset var(--bar-width) 0 0 var(--color-accent); }
.mb-datacard-note { margin: 0; padding: 12px 16px; border-top: 1px solid var(--color-line-subtle); font-size: var(--size-caption); line-height: 1.4; color: var(--color-muted); }

/* ---------- chat: panel, bubbles, source line, typing ---------- */

.mb-chat {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 10px;
  padding: 18px;
  background: var(--color-chat-panel);
  border-radius: var(--radius-card);
}
.mb-bubble {
  max-width: 88%;
  padding: 10px 14px;
  font-size: var(--size-ui);
  line-height: var(--leading-snug);
  overflow-wrap: anywhere;
}
.mb-bubble--client {
  align-self: flex-end;
  background: var(--color-bubble-client);
  color: var(--color-on-bubble-client);
  border-radius: var(--radius-bubble) var(--radius-bubble) var(--radius-bubble-tail) var(--radius-bubble);
}
.mb-bubble--agent {
  align-self: flex-start;
  max-width: 92%;
  background: var(--color-bubble-agent);
  color: var(--color-on-bubble-agent);
  border-radius: var(--radius-bubble) var(--radius-bubble) var(--radius-bubble) var(--radius-bubble-tail);
}
.mb-chat-source {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin: 0;
  font-size: var(--size-caption);
  line-height: var(--leading-snug);
  color: var(--color-text);
}
.mb-dot { flex: none; width: 10px; height: 10px; margin-top: 4px; border-radius: var(--radius-round); background: var(--color-accent); }
.mb-dot--none { background: var(--color-faint); }
.mb-typing { display: inline-flex; align-items: center; gap: 5px; padding: 14px 16px; background: var(--color-bubble-agent); border-radius: var(--radius-bubble) var(--radius-bubble) var(--radius-bubble) var(--radius-bubble-tail); }
.mb-typing > span { width: 7px; height: 7px; border-radius: var(--radius-round); background: var(--color-accent); }
.mb-typing > span:nth-child(2) { opacity: 0.55; }
.mb-typing > span:nth-child(3) { opacity: 0.25; }

/* ---------- notices ---------- */

.mb-notice {
  margin: 0;
  padding: 14px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-card);
  font-size: var(--size-ui);
  line-height: 1.45;
}
.mb-notice--success { background: var(--color-success-bg); border-color: var(--color-success-border); color: var(--color-success); }
.mb-notice--warning { background: var(--color-warning-bg); border-color: var(--color-warning-border); color: var(--color-warning); }
.mb-notice--error { background: var(--color-error-bg); border-color: var(--color-error-border); color: var(--color-error); }
.mb-notice--highlight { background: var(--color-highlight); color: var(--color-ink); font-weight: var(--weight-medium); }
.mb-notice--quiet { background: var(--color-surface); border-color: var(--color-line); color: var(--color-text); font-size: var(--size-small); }

/* ---------- dark block ---------- */

.mb-dark { background: var(--color-dark); color: var(--color-on-dark); }
.mb-dark p, .mb-dark li { color: var(--color-on-dark-text); }
.mb-dark a:not(.mb-btn) { color: var(--color-on-dark); }
.mb-dashes { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: var(--space-3); }
.mb-dashes > li { position: relative; padding-left: 20px; }
.mb-dashes > li::before { content: ""; position: absolute; left: 0; top: 0.7em; width: 10px; height: 2px; background: var(--color-on-dark-line); }

/* ---------- footer ---------- */

.mb-footer {
  border-top: 1px solid var(--color-line);
  font-size: var(--size-small);
  color: var(--color-muted);
}
.mb-footer--flush { border-top: 0; }
.mb-footer > .mb-shell {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px var(--space-8);
  padding-top: 22px;
  padding-bottom: 30px;
}
.mb-footer nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0 var(--space-5); }
.mb-footer a { color: var(--color-text); text-underline-offset: 3px; }
.mb-footer a:hover { color: var(--color-link-hover); }
.mb-footer nav a { display: inline-flex; align-items: center; min-height: var(--tap-min); }
.mb-footer .mb-support a { color: var(--color-text); }

.mb-social { display: flex; align-items: center; gap: 2px; }
.mb-social-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap-min);
  height: var(--tap-min);
  border-radius: var(--radius-round);
  color: var(--color-primary);
  text-decoration: none;
}
.mb-social-link svg { display: block; fill: currentColor; }
.mb-footer .mb-social-link { color: var(--color-primary); }
.mb-footer .mb-social-link:hover { color: var(--color-primary-active); background: var(--color-panel); }

/* ---------- app chrome: the header and footer of the server-rendered pages ---------- */

.wiz-header { background: var(--color-ground); }
.wiz-footer .mb-foot-copy { margin-right: auto; }
/* The branded start screen (a demo link sent in a chat) opens on a larger lockup. */
.wiz-header--brand > .mb-shell { padding-top: var(--space-8); padding-bottom: var(--space-6); }
.wiz-header--brand .mb-mark { width: 64px; height: 65px; }
.wiz-header--brand .mb-wordmark-svg { height: 36px; }
.wiz-header--brand .mb-descriptor { font-size: var(--size-small); }
/* «Помощь» is a word on wide screens and a round «?» button on the phone. */
.wiz-help-round {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap-min);
  height: var(--tap-min);
  border: 1px solid var(--color-control-border);
  border-radius: var(--radius-round);
  background: var(--color-surface);
  color: var(--color-ink);
  font-weight: var(--weight-semibold);
  text-decoration: none;
}
.wiz-help { text-decoration: none; }
.wiz-help > .mb-only-wide { text-decoration: underline; text-underline-offset: 4px; }

/* ---------- app components (wizard first; launch, editor and billing reuse them) ---------- */

/* Two more button fills: dark (a secondary action that must still read as a button — «Отправить»
   in the chat, «Применить» in a row editor) and danger (the one destructive confirmation). */
.mb-btn--dark { background: var(--color-dark); border-color: var(--color-dark); color: var(--color-on-dark); }
.mb-btn--dark:hover { background: var(--color-text); border-color: var(--color-text); color: var(--color-on-dark); }
.mb-btn--danger { background: var(--color-error); border-color: var(--color-error); color: var(--color-on-primary); }
.mb-btn--danger:hover { background: var(--color-primary-active); border-color: var(--color-primary-active); color: var(--color-on-primary); }

/* Wizard step bars: a done step is a link back (✓ in the primary colour), the bar keeps a full
   tap target. Markup: ol.mb-steps > li[.is-done|aria-current] > (a|span.mb-steps-n + label). */
.mb-steps > li > a {
  display: flex;
  align-items: flex-start;
  min-height: var(--tap-min);
  margin-top: -10px;
  padding-top: 10px;
  color: var(--color-ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.mb-steps > li > a:hover { color: var(--color-link-hover); }
.mb-steps > li.is-done .mb-steps-n { color: var(--color-primary); text-decoration: none; }

/* File drop zone: the label wraps a hidden file input, so a click anywhere opens the picker. */
.mb-dropzone {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-10) var(--space-6);
  border: var(--selected-width) dashed var(--color-accent);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  text-align: center;
  cursor: pointer;
}
.mb-dropzone.is-over { background: var(--color-highlight); }
.mb-dropzone.is-error { border-color: var(--color-error); }
.mb-dropzone-icon { display: block; width: var(--space-8); height: var(--space-8); color: var(--color-primary); }
.mb-dropzone-title { font-size: var(--size-lead); font-weight: var(--weight-semibold); color: var(--color-ink); }
.mb-dropzone-meta { font-size: var(--size-small); color: var(--color-muted); }
.mb-dropzone-note { max-width: 30em; font-size: var(--size-caption); line-height: var(--leading-snug); color: var(--color-muted); }
.mb-dropzone-error { max-width: 30em; font-size: var(--size-caption); line-height: var(--leading-snug); font-weight: var(--weight-semibold); color: var(--color-error); }
.mb-dropzone-error:empty { display: none; }

/* Numbered steps under accent bars (the submitted page, the branded start screen). */
.mb-numbered {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-5) var(--space-8);
}
.mb-numbered > li {
  min-width: 0;
  padding-top: var(--space-4);
  border-top: var(--bar-width) solid var(--color-accent);
  font-size: var(--size-ui);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
  color: var(--color-ink);
}
.mb-numbered-n {
  display: block;
  margin-bottom: var(--space-2);
  font-size: var(--size-numeral);
  line-height: 1;
  font-weight: var(--weight-semibold);
  color: var(--color-primary);
  font-variant-numeric: tabular-nums;
}

/* A card with a panel head (title + tag) and rows: prices, «Условия и контакты», «Что обычно мешает». */
.mb-listcard {
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-card);
  overflow: hidden;
}
.mb-listcard-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-3);
  padding: 12px 16px;
  background: var(--color-panel);
  border-bottom: 1px solid var(--color-line);
}
.mb-listcard-head > h2,
.mb-listcard-head > h3 { margin: 0; font-size: var(--size-ui); font-weight: var(--weight-semibold); line-height: 1.3; color: var(--color-ink); }
.mb-listcard-foot {
  margin: 0;
  padding: 12px 16px;
  border-top: 1px solid var(--color-line-subtle);
  font-size: var(--size-caption);
  line-height: 1.5;
  color: var(--color-text);
}
.mb-listcard > .mb-dl { border: 0; border-radius: 0; background: transparent; }
.mb-dl--plain dd { font-weight: var(--weight-regular); }
.mb-dl--end dd { text-align: right; font-weight: var(--weight-semibold); }

/* Disclosure rows: a summary line (title, status, «Настроить»/«Свернуть») that opens a body. */
.mb-disclosure {
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-card);
}
.mb-disclosure > details + details { border-top: 1px solid var(--color-line-subtle); }
.mb-disclosure summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  grid-template-areas: "title status action";
  align-items: center;
  gap: 2px var(--space-4);
  min-height: var(--button-height);
  padding: 6px 16px;
  list-style: none;
  cursor: pointer;
}
.mb-disclosure summary::-webkit-details-marker { display: none; }
.mb-disclosure-title { grid-area: title; min-width: 0; font-weight: var(--weight-semibold); color: var(--color-ink); }
.mb-disclosure-status { grid-area: status; font-size: var(--size-caption); font-weight: var(--weight-regular); color: var(--color-muted); }
.mb-disclosure-action { grid-area: action; display: inline-flex; align-items: center; min-height: var(--tap-min); font-size: var(--size-small); font-weight: var(--weight-medium); color: var(--color-link); text-decoration: underline; text-underline-offset: 4px; }
.mb-disclosure summary:hover .mb-disclosure-action { color: var(--color-link-hover); }
.mb-disclosure details[open] .mb-when-closed,
.mb-disclosure details:not([open]) .mb-when-open { display: none; }
.mb-disclosure-body { padding: 0 16px 16px; }

/* Sticky action bar at the end of a long step: sticks to the bottom while the page scrolls, rests
   above the footer at the end. On the phone it stays in the flow (stacked buttons are too tall to pin). */
.mb-actionbar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  margin-top: var(--space-12);
  background: var(--color-surface);
  border-top: 1px solid var(--color-line);
  box-shadow: var(--shadow-bar);
}
.mb-actionbar > .mb-shell {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3) var(--space-4);
  padding-top: var(--space-4);
  padding-bottom: var(--space-4);
}
.mb-actionbar-note { margin: 0; font-size: var(--size-small); color: var(--color-muted); }
.mb-actionbar-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-left: auto; }

.mb-spinner {
  display: block;
  box-sizing: border-box;
  width: var(--space-12);
  height: var(--space-12);
  border: var(--bar-width) solid var(--color-line);
  border-top-color: var(--color-accent);
  border-radius: var(--radius-round);
  animation: mb-spin 0.9s linear infinite;
}
@keyframes mb-spin { to { transform: rotate(360deg); } }

/* An agent bubble with the brand mark as its avatar (the wizard chat). */
.mb-avatar { flex: none; display: block; width: 24px; height: 25px; }
.mb-avatar svg { display: block; width: 100%; height: 100%; }

/* ---------- phone ---------- */

/* Two copies of a line where the boards word it differently on the phone. */
@media (min-width: 761px) {
  .mb-only-phone { display: none !important; }
}

@media (max-width: 760px) {
  .mb-only-wide { display: none !important; }
  .mb-header > .mb-shell { flex-wrap: nowrap; gap: var(--space-3); padding-top: 14px; padding-bottom: 14px; }
  .mb-lockup { gap: 10px; }
  .mb-mark { width: 36px; height: 37px; }
  .mb-lockup-text { gap: 4px; }
  .mb-wordmark-svg { height: 21px; }
  .mb-descriptor { font-size: 12px; }
  .mb-nav { flex-wrap: nowrap; gap: var(--space-4); }
  .mb-nav a:not(.mb-btn) { justify-content: center; min-width: var(--tap-min); }
  .mb-footer { font-size: var(--size-caption); }
  /* On a phone the footer is one centred column on every page (landing, help, legal, app). */
  .mb-footer > .mb-shell { flex-direction: column; align-items: center; gap: var(--space-1); padding-top: 14px; padding-bottom: 26px; text-align: center; }
  .mb-footer nav { justify-content: center; gap: 0 18px; }
  .mb-footer .mb-social { justify-content: center; }
  .wiz-footer .mb-foot-copy { margin-right: 0; }
  .mb-row { grid-template-columns: 24px minmax(0, 1fr) auto; gap: var(--space-2); padding: 12px 14px 12px 0; font-size: var(--size-small); }
  .mb-dl > div { display: block; padding: 10px 14px; }
  .mb-dl dt { font-size: var(--size-caption); }
  .mb-dl dd { margin-top: 2px; }
  .mb-dl--end dd { text-align: left; }
  .wiz-header--brand > .mb-shell { padding-top: var(--space-5); padding-bottom: var(--space-3); }
  .wiz-header--brand .mb-mark { width: 46px; height: 47px; }
  .wiz-header--brand .mb-wordmark-svg { height: 26px; }
  .wiz-header--brand .mb-descriptor { font-size: var(--size-caption); }
  .mb-steps { gap: var(--space-1); font-size: var(--size-micro); }
  .mb-steps .mb-steps-n { margin-right: 4px; }
  .mb-dropzone { padding: var(--space-6) var(--space-5); }
  .mb-numbered { grid-template-columns: 1fr; gap: var(--space-3); }
  .mb-numbered > li { display: flex; align-items: center; gap: var(--space-4); padding-top: var(--space-3); }
  .mb-numbered-n { flex: none; min-width: var(--space-6); margin: 0; font-size: var(--size-h2-sm); }
  .mb-disclosure summary { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "title action" "status action"; padding-top: 10px; padding-bottom: 10px; }
  .mb-disclosure-status { justify-self: start; }
  .mb-actionbar { position: static; margin-top: var(--space-10); box-shadow: none; }
  .mb-actionbar > .mb-shell { flex-direction: column; align-items: stretch; }
  .mb-actionbar-actions { flex-direction: column-reverse; margin-left: 0; }
  .mb-actionbar-actions > .mb-btn { width: 100%; }
}

@media (max-width: 360px) {
  .mb-descriptor { display: none; }
  /* Four step labels do not fit one line each at 320 px: the number goes above its label. */
  .mb-steps > li > a { display: block; }
  .mb-steps .mb-steps-n { display: block; margin-right: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .mb-row, .mb-btn { transition: none; }
  .mb-spinner { animation-duration: 3s; }
}
