/* ============================================================================
   Meshdy Design System — Components v1.0.0
   ----------------------------------------------------------------------------
   Requires: tokens/meshdy-tokens.css loaded first.
   Every value here resolves to a semantic or component token. No literal hex,
   no magic numbers. If you need a value that does not exist as a token, add the
   token first (see references/06-governance.md, contribution flow).

   Prefix: .mds-*     Theme: inherits [data-theme] from any ancestor.
   Accessibility is baked in, not optional — see the a11y notes per component.
   ========================================================================== */

/* ── Base ─────────────────────────────────────────────────────────────── */
.mds {
  font-family: var(--font-family-body);
  font-size: var(--type-body-size);
  line-height: var(--type-body-line);
  color: var(--text-primary);
  background: var(--bg-canvas);
}
.mds *,
.mds *::before,
.mds *::after { box-sizing: border-box; }

/* Focus is never removed, only restyled. Applies to every interactive part. */
.mds :focus-visible,
.mds-btn:focus-visible,
.mds-input:focus-visible,
.mds-tab:focus-visible,
.mds-navitem:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: var(--focus-offset);
}

/* Screen-reader-only text. Used wherever colour alone would carry meaning. */
.mds-sr {
  position: absolute; width: 1px; height: 1px; padding: 0;
  margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  border: 0;
}

/* ── 1. Button ────────────────────────────────────────────────────────────
   Variants: primary · secondary · ghost · danger
   Sizes:    sm 32 / md 40 / lg 48   (target padding keeps hit area >= 44)
   a11y:     real <button>; icon-only needs aria-label; loading sets
             aria-busy="true" and keeps the label in the DOM.
   Rule:     ONE primary per screen. Label is a verb naming what happens. */
.mds-btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--space-2);
  height: var(--button-height-md);
  padding: 0 var(--button-padding-x-md);
  border: 1px solid transparent;
  border-radius: var(--button-radius);
  font-family: var(--font-family-body);
  font-size: var(--button-font-size);
  font-weight: var(--font-weight-semibold);
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--duration-fast) var(--easing-standard),
              border-color var(--duration-fast) var(--easing-standard),
              color var(--duration-fast) var(--easing-standard);
}
.mds-btn--sm { height: var(--button-height-sm); padding: 0 var(--space-3); font-size: var(--type-caption-size); }
.mds-btn--lg { height: var(--button-height-lg); padding: 0 var(--space-5); font-size: var(--type-body-size); }
.mds-btn--block { width: 100%; }

.mds-btn--primary { background: var(--button-bg-primary); color: var(--button-text-primary); }
.mds-btn--primary:hover:not(:disabled) { background: var(--button-bg-primary-hover); }
.mds-btn--primary:active:not(:disabled) { background: var(--action-primary-active); }

.mds-btn--secondary {
  background: var(--bg-surface); color: var(--text-primary);
  border-color: var(--border-strong);
}
.mds-btn--secondary:hover:not(:disabled) { background: var(--bg-sunken); }

.mds-btn--ghost { background: transparent; color: var(--text-link); }
.mds-btn--ghost:hover:not(:disabled) { background: var(--action-secondary); }

.mds-btn--danger { background: var(--state-risk); color: var(--text-on-action); }
.mds-btn--danger:hover:not(:disabled) { filter: brightness(0.92); }

.mds-btn:disabled,
.mds-btn[aria-disabled="true"] {
  background: var(--action-disabled); color: var(--text-muted);
  border-color: transparent; cursor: not-allowed;
}
.mds-btn[aria-busy="true"] { position: relative; color: transparent; }
.mds-btn[aria-busy="true"]::after {
  content: ""; position: absolute; width: 15px; height: 15px;
  border: 2px solid currentColor; border-top-color: transparent;
  border-radius: var(--radius-pill);
  animation: mds-spin var(--duration-deliberate) linear infinite;
  color: var(--button-text-primary);
}
.mds-btn--secondary[aria-busy="true"]::after,
.mds-btn--ghost[aria-busy="true"]::after { color: var(--text-primary); }
@keyframes mds-spin { to { transform: rotate(360deg); } }

/* Icon-only keeps a 44px hit area even at sm */
.mds-btn--icon { width: var(--button-height-md); padding: 0; }
.mds-btn--icon.mds-btn--sm { width: var(--button-height-sm); padding: 0; }
.mds-btn--icon::before {
  content: ""; position: absolute; min-width: var(--touch-min);
  min-height: var(--touch-min);
}
.mds-btn--icon { position: relative; }
.mds-btn svg { width: 16px; height: 16px; flex: 0 0 auto; }

/* ── 2. Input ─────────────────────────────────────────────────────────────
   Variants: text · number · currency · search
   a11y:     always paired with <label for>; error uses aria-invalid +
             aria-describedby pointing at .mds-field__msg (not colour alone).
   Rule:     currency uses the mono family and locale formatting (C2). */
.mds-field { display: block; }
.mds-field__label {
  display: block; margin-bottom: var(--space-1-5);
  font-family: var(--font-family-body);
  font-size: var(--type-label-size);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}
.mds-field__hint,
.mds-field__msg {
  margin-top: var(--space-1-5);
  font-size: var(--type-caption-size);
  color: var(--text-secondary);
}
.mds-field__msg--error { color: var(--state-risk); display: flex; gap: var(--space-1-5); }
.mds-field__msg--error::before { content: "!"; font-weight: var(--font-weight-bold); }
.mds-field__req { color: var(--state-risk); margin-left: 2px; }

.mds-input {
  width: 100%; height: var(--input-height);
  padding: 0 var(--space-3);
  background: var(--input-bg); color: var(--text-primary);
  border: 1px solid var(--input-border);
  border-radius: var(--input-radius);
  font-family: var(--font-family-body); font-size: var(--type-body-size);
  transition: border-color var(--duration-fast) var(--easing-standard);
}
.mds-input::placeholder { color: var(--input-placeholder); }
.mds-input:hover:not(:disabled) { border-color: var(--border-strong); }
.mds-input:focus { border-color: var(--input-border-focus); }
.mds-input[aria-invalid="true"] { border-color: var(--state-risk); }
.mds-input:disabled { background: var(--bg-sunken); color: var(--text-muted); cursor: not-allowed; }
textarea.mds-input { height: auto; min-height: 96px; padding: var(--space-2-5) var(--space-3); resize: vertical; }
.mds-input--currency,
.mds-input--numeric { font-family: var(--font-family-mono); text-align: right; font-variant-numeric: tabular-nums; }

.mds-inputgroup { position: relative; display: flex; align-items: center; }
.mds-inputgroup__prefix,
.mds-inputgroup__suffix {
  position: absolute; color: var(--text-muted);
  font-family: var(--font-family-mono); font-size: var(--type-caption-size);
  pointer-events: none;
}
.mds-inputgroup__prefix { left: var(--space-3); }
.mds-inputgroup__suffix { right: var(--space-3); }
.mds-inputgroup__prefix ~ .mds-input { padding-left: var(--space-8); }
.mds-inputgroup__suffix ~ .mds-input { padding-right: var(--space-10); }

/* ── 3. Select ────────────────────────────────────────────────────────────
   Rule: platform and market lists are long, so default to searchable.
   a11y: native <select> for short lists; a combobox needs role="combobox",
         aria-expanded, aria-controls and full keyboard support. */
.mds-select {
  width: 100%; height: var(--input-height);
  padding: 0 var(--space-9) 0 var(--space-3);
  background: var(--input-bg) no-repeat right var(--space-3) center;
  background-image: linear-gradient(45deg, transparent 49%, var(--text-secondary) 50%),
                    linear-gradient(-45deg, transparent 49%, var(--text-secondary) 50%);
  background-size: 6px 6px, 6px 6px;
  background-position: right 16px top 52%, right 11px top 52%;
  color: var(--text-primary);
  border: 1px solid var(--input-border);
  border-radius: var(--input-radius);
  font-family: var(--font-family-body); font-size: var(--type-body-size);
  appearance: none; cursor: pointer;
}
.mds-select:focus { border-color: var(--input-border-focus); }
.mds-select:disabled { background-color: var(--bg-sunken); color: var(--text-muted); cursor: not-allowed; }

/* ── 4. Checkbox / Radio ──────────────────────────────────────────────────
   a11y: 20px visual box inside a 44px hit target. Label is clickable.
         Indeterminate state must also be exposed via el.indeterminate. */
.mds-check {
  display: inline-flex; align-items: flex-start; gap: var(--space-2-5);
  min-height: var(--touch-min); padding: var(--space-2-5) 0;
  cursor: pointer; font-size: var(--type-body-size);
}
.mds-check input {
  appearance: none; flex: 0 0 auto; width: 20px; height: 20px; margin: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  cursor: pointer; position: relative;
  transition: background var(--duration-fast) var(--easing-standard);
}
.mds-check input[type="radio"] { border-radius: var(--radius-pill); }
.mds-check input:checked { background: var(--action-primary); border-color: var(--action-primary); }
.mds-check input[type="checkbox"]:checked::after {
  content: ""; position: absolute; left: 5px; top: 1px;
  width: 7px; height: 12px;
  border: solid var(--text-on-action); border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.mds-check input[type="checkbox"]:indeterminate {
  background: var(--action-primary); border-color: var(--action-primary);
}
.mds-check input[type="checkbox"]:indeterminate::after {
  content: ""; position: absolute; left: 3px; top: 8px;
  width: 12px; height: 2px; background: var(--text-on-action);
}
.mds-check input[type="radio"]:checked::after {
  content: ""; position: absolute; left: 5px; top: 5px;
  width: 8px; height: 8px; border-radius: var(--radius-pill);
  background: var(--text-on-action);
}
.mds-check input:disabled { background: var(--bg-sunken); border-color: var(--border-default); cursor: not-allowed; }
.mds-check input:disabled ~ span { color: var(--text-muted); }

.mds-switch { display: inline-flex; align-items: center; gap: var(--space-2-5); min-height: var(--touch-min); cursor: pointer; }
.mds-switch input { appearance: none; width: 40px; height: 22px; margin: 0; border-radius: var(--radius-pill);
  background: var(--node-idle); position: relative; cursor: pointer;
  transition: background var(--duration-base) var(--easing-standard); }
.mds-switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px;
  border-radius: var(--radius-pill); background: var(--bg-surface);
  transition: transform var(--duration-base) var(--easing-spring); }
.mds-switch input:checked { background: var(--action-primary); }
.mds-switch input:checked::after { transform: translateX(18px); }

/* ── 5. Card ──────────────────────────────────────────────────────────────
   Variants: default · interactive · capability (Meshdy product block)
   Rule: the capability block reads independent but visibly of one system. */
.mds-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  padding: var(--card-padding);
  box-shadow: var(--card-shadow);
}
.mds-card--flat { box-shadow: none; }
.mds-card--interactive { cursor: pointer; transition: box-shadow var(--duration-base) var(--easing-standard),
  border-color var(--duration-base) var(--easing-standard); }
.mds-card--interactive:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.mds-card__head { display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--space-3); margin-bottom: var(--space-3); }
.mds-card__title { font-family: var(--font-family-display); font-size: var(--type-h4-size);
  font-weight: var(--font-weight-bold); letter-spacing: var(--type-h4-tracking); margin: 0; }
.mds-card__body { color: var(--text-secondary); font-size: var(--type-body-sm-size); }

/* Capability block — one per Meshdy product module */
.mds-capability {
  position: relative; overflow: hidden;
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: var(--card-radius); padding: var(--card-padding);
}
.mds-capability::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: linear-gradient(180deg, var(--action-primary), var(--node-active));
}
.mds-capability__icon { color: var(--node-active); margin-bottom: var(--space-3); display: block; }
.mds-capability__icon svg { width: 24px; height: 24px; }
.mds-capability__name { font-family: var(--font-family-display); font-weight: var(--font-weight-bold);
  font-size: var(--type-h4-size); margin: 0 0 var(--space-1-5); }
.mds-capability__desc { margin: 0; font-size: var(--type-body-sm-size); color: var(--text-secondary); }

/* ── 6. Table ─────────────────────────────────────────────────────────────
   Variants: default · compact · numeric columns
   a11y: <caption> or aria-label; <th scope>; sortable headers use
         aria-sort and a real <button> inside the <th>.
   Rule: money is mono, right-aligned, tabular figures, unit in the header. */
.mds-tablewrap { overflow-x: auto; border: 1px solid var(--border-default);
  border-radius: var(--radius-lg); background: var(--bg-surface); }
.mds-table { width: 100%; border-collapse: collapse; font-size: var(--type-body-sm-size); }
.mds-table caption { text-align: left; padding: var(--space-4) var(--space-4) 0;
  font-size: var(--type-caption-size); color: var(--text-secondary); }
.mds-table th {
  position: sticky; top: 0; z-index: var(--z-index-raised);
  text-align: left; padding: var(--space-3) var(--space-4);
  background: var(--table-header-bg); color: var(--text-secondary);
  font-family: var(--font-family-body); font-size: var(--type-overline-size);
  font-weight: var(--font-weight-semibold);
  letter-spacing: var(--type-overline-tracking); text-transform: uppercase;
  border-bottom: 1px solid var(--table-border); white-space: nowrap;
}
.mds-table td { padding: 0 var(--space-4); height: var(--table-row-height);
  border-bottom: 1px solid var(--table-border); vertical-align: middle; }
.mds-table tbody tr:last-child td { border-bottom: 0; }
.mds-table tbody tr:hover { background: var(--bg-sunken); }
.mds-table--compact td { height: 36px; }
.mds-table .num, .mds-table th.num { text-align: right;
  font-family: var(--table-numeric-font); font-variant-numeric: tabular-nums; }
.mds-table__sort { background: none; border: 0; padding: 0; cursor: pointer;
  font: inherit; color: inherit; letter-spacing: inherit; text-transform: inherit;
  display: inline-flex; gap: var(--space-1-5); align-items: center; }
.mds-table__sort::after { content: "↕"; opacity: .45; }
.mds-table th[aria-sort="ascending"] .mds-table__sort::after { content: "↑"; opacity: 1; }
.mds-table th[aria-sort="descending"] .mds-table__sort::after { content: "↓"; opacity: 1; }

/* ── 7. Badge / Status pill ───────────────────────────────────────────────
   States: live · pending · attention · suspended · closed · info
   a11y RULE: colour is never the only carrier. The label text is mandatory;
              the dot is decoration and is aria-hidden. */
.mds-badge {
  display: inline-flex; align-items: center; gap: var(--space-1-5);
  padding: 3px var(--badge-padding-x);
  border-radius: var(--badge-radius);
  font-size: var(--badge-font-size); font-weight: var(--font-weight-medium);
  line-height: 1.4; white-space: nowrap;
}
.mds-badge__dot { width: 6px; height: 6px; border-radius: var(--radius-pill);
  background: currentColor; flex: 0 0 auto; }
.mds-badge--live      { background: var(--state-success-bg); color: var(--state-success); }
.mds-badge--pending   { background: var(--state-info-bg);    color: var(--state-info); }
.mds-badge--attention { background: var(--state-warning-bg); color: var(--state-warning); }
.mds-badge--suspended { background: var(--state-risk-bg);    color: var(--state-risk); }
.mds-badge--closed    { background: var(--bg-sunken);        color: var(--text-muted); }
.mds-badge--outline   { background: transparent; border: 1px solid currentColor; }

/* ── 8. Metric tile ───────────────────────────────────────────────────────
   a11y: delta carries an arrow glyph AND a sign, never colour alone.
   Rule: currency always states its unit. */
.mds-metric { background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: var(--card-radius); padding: var(--space-5); }
.mds-metric__label { margin: 0 0 var(--space-1-5);
  font-size: var(--type-overline-size); letter-spacing: var(--type-overline-tracking);
  text-transform: uppercase; color: var(--text-muted); }
.mds-metric__value { font-family: var(--font-family-display);
  font-size: var(--type-data-lg-size); font-weight: var(--font-weight-extrabold);
  letter-spacing: var(--type-data-lg-tracking); line-height: 1.05; margin: 0;
  font-variant-numeric: tabular-nums; }
.mds-metric__unit { font-family: var(--font-family-body); font-size: var(--type-caption-size);
  font-weight: var(--font-weight-medium); color: var(--text-muted); margin-left: var(--space-2);
  letter-spacing: 0; }
.mds-metric__delta { display: inline-flex; align-items: center; gap: 4px;
  margin-top: var(--space-2); font-size: var(--type-caption-size);
  font-weight: var(--font-weight-semibold); font-family: var(--font-family-mono); }
.mds-metric__delta--up   { color: var(--state-success); }
.mds-metric__delta--down { color: var(--state-risk); }
.mds-metric__delta--flat { color: var(--text-muted); }
.mds-metric__delta--up::before   { content: "↑"; }
.mds-metric__delta--down::before { content: "↓"; }
.mds-metric__delta--flat::before { content: "→"; }

/* ── 9. Nav sidebar ───────────────────────────────────────────────────────
   a11y: <nav aria-label>; current page uses aria-current="page".
         Collapsed mode keeps accessible names via aria-label on each item. */
.mds-nav { display: flex; flex-direction: column; gap: var(--space-1);
  padding: var(--space-4); background: var(--bg-shell);
  border-right: 1px solid var(--border-default); min-width: 236px; }
.mds-nav--collapsed { min-width: 0; width: 68px; align-items: center; }
.mds-nav__group { margin: var(--space-4) 0 var(--space-1);
  font-size: var(--type-overline-size); letter-spacing: var(--type-overline-tracking);
  text-transform: uppercase; color: var(--text-muted); padding: 0 var(--space-2); }
.mds-nav--collapsed .mds-nav__group { display: none; }
.mds-navitem {
  display: flex; align-items: center; gap: var(--space-2-5);
  min-height: var(--touch-min); padding: 0 var(--space-3);
  border-radius: var(--radius-md); border: 0; background: none; width: 100%;
  color: var(--text-secondary); font: inherit; font-size: var(--type-body-sm-size);
  font-weight: var(--font-weight-medium); text-align: left; text-decoration: none;
  cursor: pointer;
  transition: background var(--duration-fast) var(--easing-standard);
}
.mds-navitem svg { width: 20px; height: 20px; flex: 0 0 auto; }
/* The rail sits on --bg-shell, which is DARKER than the canvas. So its states lift
   toward white rather than sinking toward grey — a selected item is a white pill with
   a Fiber Blue marker, matching the white cards it navigates to. */
.mds-navitem:hover { background: color-mix(in srgb, var(--bg-surface) 55%, transparent);
  color: var(--text-primary); }
.mds-navitem[aria-current="page"] { position: relative; background: var(--bg-surface);
  color: var(--text-link); font-weight: var(--font-weight-semibold);
  box-shadow: var(--shadow-xs); }
.mds-navitem[aria-current="page"]::before { content: ""; position: absolute;
  left: 0; top: 50%; transform: translateY(-50%); width: 3px; height: 20px;
  border-radius: 0 2px 2px 0; background: var(--action-primary); }
.mds-navitem[aria-current="page"] .mds-navitem__count { color: var(--text-link); }
.mds-navitem__count { margin-left: auto; font-family: var(--font-family-mono);
  font-size: var(--type-caption-size); color: var(--text-muted); }
.mds-nav--collapsed .mds-navitem { justify-content: center; padding: 0; width: var(--touch-min); }
.mds-nav--collapsed .mds-navitem span:not(.mds-sr),
.mds-nav--collapsed .mds-navitem__count { display: none; }

/* ── 10. Tabs ─────────────────────────────────────────────────────────────
   a11y: role="tablist" / "tab" / "tabpanel"; arrow-key navigation;
         aria-selected and tabindex managed by JS.
   Rule: never use tabs for a sequential flow — use a stepper. */
.mds-tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border-default); }
.mds-tab {
  display: inline-flex; align-items: center; gap: var(--space-2);
  min-height: var(--touch-min); padding: 0 var(--space-3);
  background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--text-secondary); font: inherit; font-size: var(--type-body-sm-size);
  font-weight: var(--font-weight-medium); cursor: pointer;
}
.mds-tab:hover { color: var(--text-primary); }
.mds-tab[aria-selected="true"] { color: var(--text-link); border-bottom-color: var(--action-primary);
  font-weight: var(--font-weight-semibold); }
.mds-tab__count { font-family: var(--font-family-mono); font-size: var(--type-caption-size);
  color: var(--text-muted); }

/* ── 11. Dialog ───────────────────────────────────────────────────────────
   Variants: default · confirm · destructive
   a11y: native <dialog> or role="dialog" aria-modal="true"; focus trapped;
         Esc closes; focus returns to the trigger.
   RULE (C3): any action that moves money or changes account state must pass
              through a confirm dialog — AI proposes, a person decides. */
.mds-dialog {
  width: min(var(--dialog-max-width), calc(100vw - var(--space-8)));
  padding: 0; border: 1px solid var(--border-default);
  border-radius: var(--dialog-radius); box-shadow: var(--dialog-shadow);
  background: var(--bg-surface); color: var(--text-primary);
}
.mds-dialog::backdrop { background: color-mix(in srgb, var(--color-brand-ocean-ink) 62%, transparent); }
.mds-dialog__head { padding: var(--space-6) var(--space-6) 0; }
.mds-dialog__title { font-family: var(--font-family-display); font-size: var(--type-h3-size);
  font-weight: var(--font-weight-bold); letter-spacing: var(--type-h3-tracking); margin: 0; }
.mds-dialog__body { padding: var(--space-3) var(--space-6) var(--space-6);
  color: var(--text-secondary); font-size: var(--type-body-size); }
.mds-dialog__foot { display: flex; justify-content: flex-end; gap: var(--space-2-5);
  padding: var(--space-4) var(--space-6); border-top: 1px solid var(--border-subtle);
  background: var(--bg-sunken); border-radius: 0 0 var(--dialog-radius) var(--dialog-radius); }
.mds-dialog--destructive .mds-dialog__title { color: var(--state-risk); }

/* ── 12. Drawer ───────────────────────────────────────────────────────────
   Rule: use for account/transaction detail so list context is not lost. */
.mds-drawer {
  position: fixed; inset: 0 0 0 auto; width: min(480px, 100vw);
  background: var(--bg-surface); border-left: 1px solid var(--border-default);
  box-shadow: var(--shadow-xl); z-index: var(--z-index-drawer);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--duration-slow) var(--easing-enter);
}
.mds-drawer[data-open="true"] { transform: translateX(0); }
.mds-drawer--bottom { inset: auto 0 0 0; width: auto; max-height: 86vh;
  border-left: 0; border-top: 1px solid var(--border-default);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0; transform: translateY(100%); }
.mds-drawer--bottom[data-open="true"] { transform: translateY(0); }
.mds-drawer__head { display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3); padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border-subtle); }
.mds-drawer__body { padding: var(--space-6); overflow-y: auto; flex: 1; }

/* ── 13. Toast ────────────────────────────────────────────────────────────
   a11y: container is aria-live="polite" (assertive for errors), role="status".
   RULE: the toast name mirrors the button that caused it —
         "Connect platform" -> "Platform connected", never "Success". */
.mds-toaster { position: fixed; left: 50%; bottom: var(--space-6);
  transform: translateX(-50%); display: flex; flex-direction: column;
  gap: var(--space-2); z-index: var(--z-index-toast); }
.mds-toast {
  display: flex; align-items: flex-start; gap: var(--space-2-5);
  min-width: 280px; max-width: 420px;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-inverse); color: var(--text-inverse);
  border-radius: var(--toast-radius); box-shadow: var(--toast-shadow);
  font-size: var(--type-body-sm-size);
}
.mds-toast__icon { flex: 0 0 auto; font-weight: var(--font-weight-bold); }
.mds-toast--success .mds-toast__icon { color: var(--state-success); }
.mds-toast--warning .mds-toast__icon { color: var(--state-warning); }
.mds-toast--error   .mds-toast__icon { color: var(--state-risk); }
.mds-toast__close { margin-left: auto; background: none; border: 0; cursor: pointer;
  color: inherit; opacity: .7; font-size: 16px; line-height: 1; padding: 0 0 0 var(--space-2); }

/* ── 14. Empty / Loading / Error states ───────────────────────────────────
   RULE: every data region ships all three. Empty is an invitation to act;
         error follows what happened -> why -> what to do next. */
.mds-state { display: grid; place-items: center; text-align: center;
  padding: var(--space-12) var(--space-6); gap: var(--space-2); }
.mds-state__icon { color: var(--node-idle); }
.mds-state__icon svg { width: 32px; height: 32px; }
.mds-state__title { font-family: var(--font-family-display);
  font-size: var(--type-h4-size); font-weight: var(--font-weight-bold);
  margin: var(--space-2) 0 0; }
.mds-state__body { margin: 0; max-width: 44ch; color: var(--text-secondary);
  font-size: var(--type-body-sm-size); }
.mds-state__action { margin-top: var(--space-4); }
.mds-state--error .mds-state__icon { color: var(--state-risk); }

.mds-skeleton { background: linear-gradient(90deg,
  var(--bg-sunken) 25%, var(--border-subtle) 37%, var(--bg-sunken) 63%);
  background-size: 400% 100%; border-radius: var(--radius-sm);
  animation: mds-shimmer 1.4s var(--easing-linear) infinite; height: 1em; }
@keyframes mds-shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* ── Layout helpers ──────────────────────────────────────────────────────── */
.mds-stack  { display: flex; flex-direction: column; gap: var(--space-4); }
.mds-row    { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.mds-grid   { display: grid; gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.mds-divider { border: 0; border-top: 1px solid var(--border-subtle); margin: var(--space-5) 0; }

/* ── Reduced motion — cross-cutting C1 ───────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .mds-btn[aria-busy="true"]::after,
  .mds-skeleton { animation: none; }
  .mds-drawer { transition: none; }
}
