/*
 * Mockarty Design System — Shared Components
 * =============================================
 * Reusable UI components shared across all Mockarty applications.
 * Depends on tokens.css being loaded first.
 */

/* ────────────────────────────────────────────────
   Icon System (Heroicons SVG)
   ──────────────────────────────────────────────── */

.icon {
    width: 1em;
    height: 1em;
    display: inline-block;
    vertical-align: -0.125em;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    flex-shrink: 0;
}
.icon-sm { width: 0.875em; height: 0.875em; }
.icon-lg { width: 1.25em; height: 1.25em; }
.icon-xl { width: 1.5em; height: 1.5em; }

/* Spinning animation (replaces fa-spin) */
.icon-spin {
    animation: icon-spin 1s linear infinite;
}
@keyframes icon-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Nav icon sizing */
.nav-link .icon {
    width: 18px;
    height: 18px;
}

/* ────────────────────────────────────────────────
   Global: hide icons inside text buttons (designer rule)
   Icons are only appropriate in nav, cards, sections,
   and dedicated icon-only buttons.

   Responsive text-button icon rule:
   - Text buttons (.btn) hide their leading icon on
     wide screens (≥768px) so the action label leads.
   - Icon reappears below 768px when label may wrap or
     get truncated, giving users a recognisable glyph.
   - Opt-out: add .icon-keep on the <svg> to always show.
   - Icon-only buttons are unaffected: the rule only fires
     when the button also carries a text child (span /
     [data-i18n]). A button holding just an .icon keeps it.
   ──────────────────────────────────────────────── */

@media (min-width: 768px) {
    .btn:has(span, [data-i18n]) > .icon:not(.icon-keep),
    .ct-run:has(span, [data-i18n]) > .icon:not(.icon-keep) {
        display: none;
    }
}

/* Hide icons from dropdown menu items (text-only menu) */
.user-menu-item > i {
    display: none;
}

/* ────────────────────────────────────────────────
   Icon-only circle button (small actions: import,
   export, copy, validate, fullscreen, etc.)
   ──────────────────────────────────────────────── */

.btn-icon-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--bg-secondary);
    color: var(--text-muted);
    cursor: pointer;
    font-size: var(--font-sm);
    transition: all var(--transition-fast);
    flex-shrink: 0;
}
.btn-icon-circle:hover {
    background: var(--hover-overlay-strong);
    color: var(--text-primary);
}
.btn-icon-circle:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.btn-icon-circle.sm {
    width: 26px;
    height: 26px;
    font-size: var(--font-xs);
}
.btn-icon-circle.xs {
    width: 20px;
    height: 20px;
    font-size: 10px;
}
/* Color modifiers */
button.btn-icon-circle.danger {
    /* A destructive action must be distinguishable before hover/focus. The
       semantic modifier is shared by all icon-only delete/reject controls. */
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
    color: var(--danger-text);
}
button.btn-icon-circle.danger:hover {
    background: var(--danger-bg);
    border-color: var(--danger-text);
    color: var(--danger-text);
}
button.btn-icon-circle.danger-solid {
    /* Prominent destructive actions (for example "clear all") must not
       disappear into a coloured toolbar. `--danger-text` is AA-safe in light
       mode, while `--bg-primary` keeps the glyph legible in both themes. */
    width: 34px;
    height: 34px;
    background: var(--danger-text);
    border: 1px solid var(--danger-text);
    color: var(--bg-primary);
}
button.btn-icon-circle.danger-solid:hover {
    background: var(--danger-color);
    border-color: var(--danger-color);
    color: var(--bg-primary);
}
button.btn-icon-circle.danger-solid:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring-danger, var(--focus-ring));
}
.btn-icon-circle.accent {
    color: var(--accent-color);
}
.btn-icon-circle.accent:hover {
    background: rgba(45, 140, 240, 0.12);
    color: var(--accent-color);
}
.btn-icon-circle.save,
.btn-icon-circle.primary-action {
    background: var(--accent-color);
    color: var(--accent-contrast);
    border: none;
    box-shadow: 0 1px 3px rgba(45, 140, 240, 0.3);
}
.btn-icon-circle.save:hover,
.btn-icon-circle.primary-action:hover {
    background: var(--accent-hover, #1a7ae0);
    color: var(--accent-contrast);
    box-shadow: 0 2px 6px rgba(45, 140, 240, 0.4);
    transform: scale(1.05);
}
.dark .btn-icon-circle.save,
.dark .btn-icon-circle.primary-action {
    background: var(--accent-color);
    color: var(--accent-contrast);
    box-shadow: 0 1px 4px rgba(45, 140, 240, 0.35);
}
.dark .btn-icon-circle.save:hover,
.dark .btn-icon-circle.primary-action:hover {
    background: var(--accent-hover, #5aadff);
    color: var(--accent-contrast);
    box-shadow: 0 2px 8px rgba(45, 140, 240, 0.5);
}
.dark .btn-icon-circle {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}
.dark .btn-icon-circle:hover {
    background: var(--hover-overlay-strong);
    color: var(--text-primary);
}

/* ────────────────────────────────────────────────
   Buttons
   ──────────────────────────────────────────────── */

.btn {
    height: var(--btn-h-md);
    padding: 0 var(--btn-pad-x-md);
    border: none;
    border-radius: var(--control-radius);
    font-size: var(--font-md);
    font-weight: var(--font-weight-medium);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    text-decoration: none;
    letter-spacing: 0.01em;
    white-space: nowrap;
    min-width: fit-content;
    flex-shrink: 0;
    line-height: 1;
    box-sizing: border-box;
}
/* Canonical hover/press feedback (moved from main.css during .btn dedup).
   The lift is a U6-restyle candidate — keep here as the single source. */
.btn:hover {
    transform: translateY(-1px);
}
.btn:active {
    transform: translateY(0);
}

/* Explicit medium size alias (so all canonical sizes are expressible). */
.btn-md {
    height: var(--btn-h-md);
    padding: 0 var(--btn-pad-x-md);
    font-size: var(--font-md);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent-color);
    /* On-accent text colour — white in light theme, near-black in dark theme
       (where the accent is a light blue). Keeps the brand blue fill in both
       themes while passing WCAG AA. Owner-approved 2026-06-17. */
    color: var(--accent-contrast);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    filter: brightness(0.95);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    /* Solid token, not the translucent overlay — overlay-as-background drops
       the resting fill, so on light theme the button looked bleached-white. */
    background: var(--bg-tertiary);
    border-color: var(--accent-color);
}

.dark .btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.dark .btn-secondary:hover:not(:disabled) {
    /* Solid token, not the translucent overlay (see the light-theme rule). */
    background: var(--bg-hover, var(--bg-secondary));
    color: var(--text-primary);
    border-color: var(--accent-color);
}

.btn-outline {
    background: transparent;
    color: var(--accent-color);
    border: 1px solid var(--accent-color);
}

.dark .btn-outline {
    border-color: var(--border-color);
    color: var(--text-primary);
}

.btn-success {
    background: var(--success-color);
    color: var(--on-bright-fill);
}

.btn-warning {
    background: var(--warning-color);
    color: var(--on-bright-fill);
}

.btn-warning:hover:not(:disabled) {
    opacity: 0.9;
}

.btn-danger {
    background: var(--danger-color);
    color: var(--on-bright-fill);
}

.btn-info {
    background: var(--info-color);
    color: var(--on-bright-fill);
}

.btn-info:hover:not(:disabled) {
    opacity: 0.9;
}

/* Ghost button with a destructive affordance: transparent at rest, turns red
   on hover. The canonical home for "Clear" / "Remove" icon-buttons that should
   read as quiet until you reach for them. One variant for the whole product
   (replaces per-feature ghost+danger reinventions like the old .utils-btn.ghost). */
.btn-ghost-danger {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
}
.btn-ghost-danger:hover:not(:disabled) {
    background: var(--danger-bg, rgba(239, 68, 68, 0.08));
    color: var(--danger-color);
    border-color: color-mix(in srgb, var(--danger-color) 35%, transparent);
}

/* Button sizes */

.btn-sm {
    height: var(--btn-h-sm);
    padding: 0 var(--btn-pad-x-sm);
    font-size: var(--font-sm);
}

.btn-xs {
    height: var(--btn-h-xs);
    padding: 0 var(--btn-pad-x-xs);
    font-size: var(--font-xs);
    gap: var(--space-1);
}

.btn-lg {
    height: var(--btn-h-lg);
    padding: 0 var(--btn-pad-x-lg);
    font-size: var(--font-lg);
}

/* ────────────────────────────────────────────────
   Form Elements
   ──────────────────────────────────────────────── */

.form-group {
    margin-bottom: var(--space-3);
}

/* Form-row canon — multiple fields side by side that STAY aligned even
   when one label wraps to two lines. The recurring bug: a 2-line label
   pushes its input lower than its single-line-label neighbours.
   Fix: a responsive grid that bottom-aligns the cells, so every input
   sits on the same line regardless of label height. Opt-in:
   <div class="form-row"><div class="form-group">…</div>…</div> */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 0 var(--space-4);
    align-items: end;
}
.form-row > .form-group {
    margin-bottom: var(--space-3);
    min-width: 0;
}

/* Subgrid alignment — OPT-IN via `.form-row.form-row--aligned` (owner 2026-06-30:
   "поля ввода пляшут друг относительно друга" — a 1-line label next to a 2-line
   label, OR one field with a <small> hint below and one without, left their inputs
   on different lines). The plain `.form-row` only bottom-aligns (align-items:end),
   which still misaligns the input when one cell has a hint below it. The `--aligned`
   modifier makes every cell share the same three row tracks — label / control / hint
   — so all labels, all inputs and all hints line up across the row. Additive +
   @supports-guarded, so it never affects the ~30 existing plain `.form-row` blocks
   (whose cells have varied structures); apply it only to a row whose cells are the
   regular label→control(→hint) shape. */
@supports (grid-template-rows: subgrid) {
    .form-row.form-row--aligned {
        align-items: stretch;
        grid-auto-rows: min-content;
    }
    .form-row.form-row--aligned > .form-group {
        display: grid;
        grid-template-rows: subgrid;
        grid-row: span 3; /* label · control · hint */
        align-content: start;
        row-gap: var(--space-1);
    }
}

.form-group label {
    display: block;
    margin-bottom: var(--space-1);
    font-weight: var(--font-weight-medium);
    font-size: var(--font-sm);
    color: var(--text-primary);
    letter-spacing: 0.01em;
}

/* Field hints / descriptions. Owner 2026-06: the explanatory <small> under a
   label was rendering at near-body weight/colour and blended with real
   content. Make every form hint muted + smaller so it clearly reads as
   secondary to the label. --text-muted is theme-aware (light: dark-gray,
   dark: light-gray) and distinct from --text-primary in both. Covers the
   bare <small> hints already in .form-group app-wide; .form-hint is the
   explicit class for hints outside a form-group. */
.form-group small,
.form-group .form-hint,
.form-hint {
    display: block;
    margin-top: var(--space-1);
    color: var(--text-muted);
    font-size: var(--font-xs);
    font-weight: var(--font-weight-normal);
    line-height: 1.45;
    letter-spacing: 0;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border-color);
    border-radius: var(--control-radius);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: var(--font-md);
    height: 36px;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-textarea {
    height: auto;
}

.form-input-sm {
    height: 32px;
    padding: 0.25rem 0.5rem;
    font-size: var(--font-sm);
}

input[type="file"].form-input {
    height: auto;
    min-height: 36px;
    padding: 6px var(--space-3);
    display: flex;
    align-items: center;
    line-height: normal;
}

/* Native file-picker button. Unstyled, browsers render it with a white/
   light-grey background → looks broken (white blob) in dark theme. Theme it
   through tokens so EVERY <input type=file> across the app matches the
   secondary-control look in both themes from this ONE rule — no per-screen
   styling needed. The standard ::file-selector-button and the legacy
   ::-webkit-file-upload-button are kept in SEPARATE rules on purpose: an
   unknown pseudo-element invalidates the whole selector list, so combining
   them would drop the rule in some engines. */
input[type="file"]::file-selector-button {
    margin-right: 0.6rem;
    padding: 0.3rem 0.7rem;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm, 6px);
    font: inherit;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}
input[type="file"]::file-selector-button:hover {
    border-color: var(--accent-color);
}
input[type="file"]::-webkit-file-upload-button {
    margin-right: 0.6rem;
    padding: 0.3rem 0.7rem;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm, 6px);
    font: inherit;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}
input[type="file"]::-webkit-file-upload-button:hover {
    border-color: var(--accent-color);
}

/* Native radio tint and checkbox fallback (including forced-colors mode). */
input[type="checkbox"],
input[type="radio"] {
    accent-color: var(--accent-color);
    cursor: pointer;
}

/* Checkbox baseline. Native inputs keep their semantics and keyboard behaviour;
   slider switches keep their own hidden-input/track presentation. Low specificity
   lets dense tables and page-specific layouts retain their dimensions. */
:where(input[type="checkbox"]):not(:where([role="switch"], .mk-toggle input, .toggle-switch input, .trash-switch__input, .tcm-step-onfail__input)) {
    appearance: none;
    -webkit-appearance: none;
    display: inline-grid;
    place-content: center;
    vertical-align: middle;
    flex: 0 0 auto;
    width: var(--space-4);
    height: var(--space-4);
    margin: 0;
    padding: 0;
    border: 1px solid var(--text-muted);
    border-radius: var(--radius-xs);
    background: var(--bg-primary);
}
:where(input[type="checkbox"]):not(:where([role="switch"], .mk-toggle input, .toggle-switch input, .trash-switch__input, .tcm-step-onfail__input))::before {
    content: "";
    width: 0.3rem;
    height: 0.55rem;
    border: solid var(--accent-contrast);
    border-width: 0 2px 2px 0;
    transform: translateY(-1px) rotate(45deg);
    visibility: hidden;
}
:is(input[type="checkbox"]:checked, input[type="checkbox"]:indeterminate):not(:where([role="switch"], .mk-toggle input, .toggle-switch input, .trash-switch__input, .tcm-step-onfail__input)) {
    background: var(--accent-color);
    border-color: var(--accent-color);
}
:where(input[type="checkbox"]:checked, input[type="checkbox"]:indeterminate)::before { visibility: visible; }
:where(input[type="checkbox"]:indeterminate)::before {
    width: var(--space-2);
    height: 0;
    border-width: 0 0 2px;
    transform: none;
}
:where(input[type="checkbox"]:focus-visible) { outline: none; box-shadow: var(--focus-ring); }
input[type="checkbox"]:disabled { cursor: not-allowed; opacity: 0.55; }
label:has(> input[type="checkbox"]:disabled) { cursor: not-allowed; }
label:has(> input[type="checkbox"]:disabled) > span { color: var(--text-muted); }
:where(label:has(> input[type="checkbox"])):not(:where(.mk-toggle, .toggle-switch, .trash-switch, .tcm-step-onfail)) {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    vertical-align: middle;
    line-height: var(--leading-normal);
    cursor: pointer;
}
@media (forced-colors: active) {
    :where(input[type="checkbox"]):not(:where([role="switch"], .mk-toggle input, .toggle-switch input, .trash-switch__input, .tcm-step-onfail__input)) { appearance: auto; -webkit-appearance: auto; }
    :where(input[type="checkbox"])::before { content: none; }
    input[type="checkbox"]:focus-visible { outline: 2px solid Highlight !important; outline-offset: 2px; box-shadow: none !important; }
    .mk-toggle input:focus-visible + .mk-toggle__slider,
    .toggle-switch input:focus-visible + .toggle-slider,
    .trash-switch__input:focus-visible + .trash-switch__slider,
    .tcm-step-onfail__input:focus-visible + .tcm-step-onfail__track {
        outline: 2px solid Highlight !important;
        outline-offset: 2px;
    }
}

/* Chrome/WebKit autofill paints its own opaque background (white/yellow) on
   suggested values, ignoring our tokens — the systemic "поле стало белым в
   тёмной теме когда сработал браузерный автокомплит" bug. The background is
   un-overridable directly; the canonical workaround is a huge inset
   box-shadow in our surface colour + transition delay for the UA repaint.
   -webkit-text-fill-color keeps the typed text themed too. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
textarea:-webkit-autofill,
select:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 1000px var(--bg-secondary) inset;
    box-shadow: 0 0 0 1000px var(--bg-secondary) inset;
    -webkit-text-fill-color: var(--text-primary);
    caret-color: var(--text-primary);
    transition: background-color 9999s ease-out;
}

/* Keep the focus ring visible on an autofilled field: compose it with the
   surface-fill shadow (a bare override would drop one or the other). */
input:-webkit-autofill:focus,
textarea:-webkit-autofill:focus,
select:-webkit-autofill:focus {
    -webkit-box-shadow: var(--focus-ring), 0 0 0 1000px var(--bg-secondary) inset;
    box-shadow: var(--focus-ring), 0 0 0 1000px var(--bg-secondary) inset;
    -webkit-text-fill-color: var(--text-primary);
    caret-color: var(--text-primary);
    transition: background-color 9999s ease-out;
}

.form-select,
select.form-input {
    line-height: normal;
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    background-image: var(--select-chevron);
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px;
    padding-right: 2.5rem;
}

/* ────────────────────────────────────────────────
   Suggestion dropdown for <input list> (datalist-affordance.js)
   A native datalist has NO visible affordance and opens the browser's own
   unstyled popup. Both halves are replaced here so the field looks and behaves
   like the rest of the product.
   ──────────────────────────────────────────────── */

/* The wrapper must not decide how wide the field is — it inherits whatever the
   page already decided (the script pins an explicit width when wrapping would
   have changed it). */
.dl-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    flex: 0 1 auto;
}

/* A field that filled its container must keep filling it. Measuring at wrap
   time cannot tell: a field inside a closed tab has zero width, so the
   measurement said "nothing changed" and the field came back shrink-wrapped
   when the tab opened. The class is set from the field's own computed width
   BEFORE wrapping, and a px width is never frozen (it would stop the field
   shrinking at 375px). */
.dl-wrap.dl-wrap--stretch {
    display: flex;
    width: 100%;
    flex: 1 1 auto;
}

.dl-wrap > input {
    width: 100%;
    padding-right: 2.25rem;
}

/* Opt-in progressive enhancement for governed <select> controls. The source
   select stays in the DOM as the stable-value authority and no-JS fallback;
   once the searchable control is mounted it is visually hidden, not removed. */
.dl-select-wrap {
    min-width: 10rem;
}

.dl-select-wrap--compact {
    width: auto;
    min-width: 10rem;
    max-width: 18rem;
    flex: 0 1 auto;
}

.dl-select-native {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.dl-select-input {
    min-width: 0;
    cursor: text;
}

.dl-toggle {
    position: absolute;
    right: 0.35rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}

.dl-toggle:hover { color: var(--text-primary); background: var(--hover-overlay); }
.dl-toggle:disabled { opacity: var(--disabled-opacity); cursor: not-allowed; }
.dl-toggle .icon { width: 14px; height: 14px; }

.dl-pop {
    /* fixed, not absolute: the box hangs off <body> but anchors a field that may
       sit inside a position:fixed modal, and its z-index must clear the modal —
       an absolute box at --z-dropdown rendered UNDER one, which is worse than
       the native list it replaced. */
    position: fixed;
    z-index: calc(var(--z-modal, 10000) + 10);
    max-height: 260px;
    overflow-y: auto;
    padding: 4px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md, 8px);
    background: var(--bg-primary);
    box-shadow: var(--shadow-3);
}

.dl-pop__item {
    display: flex;
    align-items: baseline;
    gap: 8px;
    width: 100%;
    padding: 6px 10px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-primary);
    font-size: 0.85rem;
    text-align: left;
    cursor: pointer;
}

.dl-pop__item:hover,
.dl-pop__item.is-active { background: var(--hover-overlay-strong); }
.dl-pop__item.is-active { outline: 1px solid var(--accent-color); outline-offset: -1px; }
.dl-pop__item.is-selected { font-weight: var(--font-weight-semibold); }
.dl-pop__label { color: var(--text-secondary); font-size: 0.78rem; }
.dl-pop__empty { padding: 8px 10px; color: var(--text-secondary); font-size: 0.8rem; }
.dl-pop__check { width: var(--space-4); height: var(--space-4); margin-left: auto; color: var(--accent-color); }
.dl-pop__status {
    padding: var(--space-2) var(--space-3);
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: var(--font-size-xs);
}

/* Native selects outside legacy forms used to retain the browser's light
   control surface. Give every ordinary one-line select the same themed shell;
   multi-select lists intentionally keep their native listbox affordance. */
select:not([multiple]):not([size]) {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    min-height: 36px;
    /* A one-line select centres its own text, and the browser does it inside
       the CONTENT box. Vertical padding therefore fights the centring: once a
       page also pins a height, the content box shrinks below the line box and
       the glyphs sink out of view — the user sees their tops and nothing else
       (owner 2026-08-14: «в дропдаунах текст съехал вниз»). Zero block padding
       plus min-height gives the same visual size with no arithmetic to get
       wrong, and line-height:normal stops a page pinning one that cannot fit. */
    line-height: normal;
    padding: 0 2.5rem 0 var(--space-3);
    border: 1px solid var(--border-color);
    border-radius: var(--control-radius);
    background-color: var(--bg-primary);
    background-image: var(--select-chevron);
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px;
    color: var(--text-primary);
    cursor: pointer;
}
select:not([multiple]):not([size]):focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: var(--focus-ring);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent-color);
}

.dark .form-input::placeholder,
.dark .form-textarea::placeholder {
    color: var(--text-muted);
    opacity: 0.8;
}

/* ────────────────────────────────────────────────
   Required-field validation state
   Used by MockartyValidation + mock-constructor's
   validateRequiredFields() + chaos profile form.
   Single class so dark/light themes pick up the
   correct danger color via --danger-color token.
   ──────────────────────────────────────────────── */
.form-input.field-error,
.form-textarea.field-error,
.form-select.field-error,
select.field-error,
input.field-error,
textarea.field-error {
    border-color: var(--danger-color);
    box-shadow: 0 0 0 1px var(--danger-color);
}

.form-input.field-error:focus,
.form-textarea.field-error:focus,
.form-select.field-error:focus,
select.field-error:focus,
input.field-error:focus,
textarea.field-error:focus {
    border-color: var(--danger-color);
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.25);
}

.mv-field-hint {
    color: var(--danger-text);
    font-size: var(--font-xs, 0.75rem);
    margin-top: 0.2rem;
    line-height: 1.3;
}

/* ────────────────────────────────────────────────
   Badges
   ──────────────────────────────────────────────── */

.badge {
    display: inline-flex;
    align-items: center;
    padding: var(--badge-pad-y) var(--badge-pad-x);
    border-radius: var(--badge-radius);
    font-size: var(--badge-font);
    font-weight: var(--badge-weight);
    white-space: nowrap;
    letter-spacing: 0.02em;
}

/* Tag shape — rectangular label for protocol/method/type (HTTP, GET, …).
   Bespoke method/protocol badges share this box; colour stays per-context. */
.badge-tag {
    display: inline-flex;
    align-items: center;
    padding: var(--badge-tag-pad-y) var(--badge-tag-pad-x);
    border-radius: var(--badge-tag-radius);
    font-size: var(--badge-font);
    font-weight: var(--font-weight-semibold);
    white-space: nowrap;
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-text);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-text);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-text);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-info {
    background: rgba(6, 182, 212, 0.1);
    color: var(--info-text);
    border: 1px solid rgba(6, 182, 212, 0.2);
}

/* ────────────────────────────────────────────────
   Protocol Badges
   ──────────────────────────────────────────────── */

.protocol-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.4rem;
    border-radius: 0.25rem;
    font-size: 0.7rem;
    font-weight: var(--font-weight-semibold);
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

/* Method badges (GET/POST/…, grpc, soap, kafka, …) — shared by the mock list
   (viewer), the generator previews and the constructor pickers. Lived in the
   page-scoped viewer.css until 2026-08: every non-mocks page (generator, …)
   silently rendered them unstyled. Same tag-shape canon as .protocol-badge. */
.mock-item .mock-method,
.mock-method {
    display: inline-block;
    padding: var(--badge-tag-pad-y) var(--badge-tag-pad-x);
    border-radius: var(--badge-tag-radius);
    font-size: var(--badge-font);
    font-weight: var(--font-weight-semibold);
    margin-right: var(--space-2);
    white-space: nowrap;
}

/* Method badges carry white text, so each background must clear WCAG AA (4.5:1)
   against white. The Bootstrap-era values did not: #28a745 → 3.13, #007bff →
   3.98, #17a2b8 → 3.04. Darkened to the nearest hue-preserving shade that
   passes (measured, not eyeballed): 5.86 / 5.84 / 5.36. */
.method-get { background: #1a7431; color: white; }
.method-post { background: #0b5ed7; color: white; }
.method-put { background: #ffc107; color: #212529; }
.method-delete { background: #b02a37; color: white; }
.method-patch { background: #6610f2; color: white; }
.method-head { background: #0e7490; color: white; }
.method-options { background: #4b5563; color: white; }
.method-trace { background: var(--severity-high); color: var(--on-bright-fill); }
.method-grpc { background: #6f42c1; color: white; }
.method-mcp { background: var(--severity-high); color: var(--on-bright-fill); }
/* Non-HTTP operations reuse the protocol token palette (white-on-token is the
   established .protocol-badge pairing). */
.method-soap { background: var(--protocol-soap); color: var(--on-bright-fill); }
.method-socket { background: var(--protocol-socket); color: white; }
.method-kafka { background: var(--protocol-kafka); color: white; }
.method-rabbitmq { background: var(--protocol-rabbitmq); color: var(--on-bright-fill); }
.method-nats { background: var(--protocol-nats); color: white; }
.method-query,
.method-mutation,
.method-subscription { background: var(--protocol-graphql); color: white; }

/* Dark theme: keep dark text on the light yellow PUT background */
.dark .method-put {
    color: #1a202c;
}

.protocol-badge-http { background: var(--protocol-http); }
.protocol-badge-grpc { background: var(--protocol-grpc); }
.protocol-badge-mcp { background: var(--protocol-mcp); }
.protocol-badge-soap { background: var(--protocol-soap); }
.protocol-badge-graphql { background: var(--protocol-graphql); }
.protocol-badge-sse { background: var(--protocol-sse); }
.protocol-badge-socket { background: var(--protocol-socket); }
.protocol-badge-kafka { background: var(--protocol-kafka); }
.protocol-badge-rabbitmq { background: var(--protocol-rabbitmq); }
.protocol-badge-nats { background: var(--protocol-nats); }
.protocol-badge-smtp { background: var(--protocol-smtp); }
.protocol-badge-s3 { background: var(--protocol-s3); }
.protocol-badge-unknown { background: #666; }

/* ────────────────────────────────────────────────
   Empty state
   Canonical centred placeholder ("Nothing here yet — do X").
   Historically this rule lived in viewer.css which was loaded
   globally; when viewer.css became page-scoped (PERF-FE-1) every
   other page (admin webhooks, generator, settings, …) silently
   lost the centring. The component belongs to the design system —
   page CSS may still tune padding, never alignment.
   ──────────────────────────────────────────────── */

.empty-state {
    text-align: center;
    padding: var(--space-8);
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: var(--space-4);
    opacity: 0.5;
}

.empty-state > svg.icon {
    display: block;
    width: 2rem;
    height: 2rem;
    margin: 0 auto var(--space-2);
    opacity: 0.6;
}

.empty-state h3 {
    margin-bottom: var(--space-2);
    color: var(--text-primary);
}

.empty-state p {
    margin: 0;
}

/* ────────────────────────────────────────────────
   Modal
   ──────────────────────────────────────────────── */

.modal {
    display: none;
    position: fixed;
    z-index: var(--z-modal);
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
}

.modal-content {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-modal);
    /* Width scale = the shared --modal-w-* tokens (tokens.css) so legacy
       .modal-content modals stay in lock-step with MockartyModal. Guarded by
       TestUIKitModalWidthScale — do not hardcode pixel widths here. */
    max-width: var(--modal-w-md);
    margin: 10vh auto;
    padding: 0;
    box-shadow: var(--shadow-4);
}
.modal-content.modal-xs { max-width: var(--modal-w-xs); }
.modal-content.modal-sm { max-width: var(--modal-w-sm); }
.modal-content.modal-lg { max-width: var(--modal-w-lg); }
.modal-content.modal-xl { max-width: var(--modal-w-xl); }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: var(--font-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    /* Titles interpolate user-controlled names (namespace, mock, plan).
       A long unbreakable name blows the flex min-content width up past
       the modal box, so the header overflows the clipped .modal-content
       and the modal reads as a "window onto another modal". Let long
       tokens wrap instead. */
    min-width: 0;
    overflow-wrap: anywhere;
}

.modal-body {
    padding: var(--space-5);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--border-color);
    /* Owner 2026-09-02: footers with three or four long (RU) labels pushed
       buttons past the dialog edge. Footers wrap; a button never exceeds
       the footer width; long labels wrap inside the button instead of
       overflowing it. Same rules for the MockartyModal footer (main.css)
       and the legacy .modal-actions rows. */
    flex-wrap: wrap;
    min-width: 0;
}
.modal-footer .btn,
.mockarty-modal-footer .btn,
.modal-actions .btn {
    max-width: 100%;
    min-width: 0;
    white-space: normal;
    height: auto;
    min-height: var(--btn-h-md);
    text-align: center;
    line-height: 1.25;
}
.modal-actions,
.mockarty-modal-footer { flex-wrap: wrap; min-width: 0; }
/* Text inside any dialog wraps at the box, never scrolls the page sideways:
   ids, URLs, digests and stack traces are the usual offenders. */
.modal-body,
.mockarty-modal-body,
.modal-content,
.mockarty-modal-message,
.mockarty-modal-title {
    min-width: 0;
    overflow-wrap: anywhere;
}

/* Caret-drift fix — GLOBAL, every CodeMirror in the app (owner UAT 2026-06-24:
   "курсор печати на ~2 буквы левее"). The app runs under a global
   html{zoom:var(--ui-scale)=0.93}. CodeMirror v5 positions its caret with
   getBoundingClientRect (visual/zoomed px) but lays text out in unscaled px, so
   under any non-1 zoom the caret drifts left, cumulatively worse along the line.
   `zoom` is multiplicative down the tree, so counter-zooming each editor by
   1/--ui-scale gives it a *net* zoom of 1.0 → measurements correct, no drift.
   We shrink the font by the same factor so the visual size is unchanged: `1em`
   is the inherited size, so calc(1em * --ui-scale) preserves it for any instance
   that doesn't pin its own font-size. No-op on desktop (--ui-scale=1). */
.CodeMirror {
    zoom: calc(1 / var(--ui-scale, 1));
    font-size: calc(1em * var(--ui-scale, 1));
}

/* The autocomplete popup needs the SAME counter-zoom (owner UAT 2026-07-01:
   "подсказки появляются поверх строки, закрывая ввод"). show-hint.js appends
   .CodeMirror-hints to <body> — OUTSIDE the editor's counter-zoomed subtree —
   and positions it with cursorCoords() px measured in the editor's net-1.0
   space. body renders at --ui-scale (0.93), so the popup's left/top were
   scaled down and it landed up-left of the caret, covering the typed line.
   Counter-zooming the popup restores net zoom 1.0 → left/top land exactly at
   the caret (below the line, aligned with the token start via alignWithWord).
   font-size shrinks by the same factor so the visual size is unchanged.
   No-op on desktop (--ui-scale=1). */
.CodeMirror-hints {
    zoom: calc(1 / var(--ui-scale, 1));
    font-size: calc(1em * var(--ui-scale, 1));
}

.modal-close {
    background: var(--bg-secondary);
    border: none;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    font-size: 1rem;
    cursor: pointer;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}
.modal-close:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.modal-danger .modal-header h3 i {
    color: var(--danger-text);
}

/* ────────────────────────────────────────────────
   Alerts
   ──────────────────────────────────────────────── */

.alert {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    font-size: var(--font-sm);
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-text);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-text);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert-warning {
    background: var(--warning-bg);
    color: var(--warning-fg);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.alert-info {
    background: rgba(6, 182, 212, 0.1);
    color: var(--info-text);
    border: 1px solid rgba(6, 182, 212, 0.2);
}

/* ────────────────────────────────────────────────
   Utility Classes
   ──────────────────────────────────────────────── */

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.text-danger { color: var(--danger-text); }
.text-success { color: var(--success-text); }
.text-warning { color: var(--warning-text); }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent-color); }

.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }

.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }

.d-flex { display: flex; }
.d-inline-flex { display: inline-flex; }
.flex-column { flex-direction: column; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }

/* ────────────────────────────────────────────────
   Tab Badge (e.g. "plugin" on gRPC tab)
   ──────────────────────────────────────────────── */

.tab-badge {
    font-size: var(--font-xs);
    font-weight: var(--font-weight-semibold);
    padding: 1px 5px;
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    color: var(--text-muted);
    margin-left: 0.25rem;
    letter-spacing: 0.02em;
    text-transform: lowercase;
}
.dark .tab-badge {
    background: var(--bg-tertiary);
    color: var(--text-muted);
}

/* ────────────────────────────────────────────────
   Scrollbar (dark theme)
   ──────────────────────────────────────────────── */

/* ────────────────────────────────────────────────
   Table Responsive Wrapper
   ──────────────────────────────────────────────── */

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-responsive table {
    min-width: 600px;
}

/* ────────────────────────────────────────────────
   Scrollbars — auto-hide (both themes)
   ──────────────────────────────────────────────────
   The thumb is transparent by default and only paints while the scrolled
   element is actively scrolling (.mk-scrolling, toggled by
   scrollbar-autohide.js) or hovered. Fading the THUMB only (track stays a
   constant-width transparent gutter) means zero layout shift. Elements that
   intentionally hide their scrollbar (.sidebar-nav, tab strips) keep their
   more-specific rules. */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background-color: transparent;
    border-radius: var(--radius-md);
    border: 2px solid transparent;
    background-clip: padding-box;
    transition: background-color 0.25s ease;
}
:hover::-webkit-scrollbar-thumb,
.mk-scrolling::-webkit-scrollbar-thumb {
    background-color: var(--scrollbar-thumb);
}
::-webkit-scrollbar-thumb:hover {
    background-color: var(--scrollbar-thumb-hover);
}
/* Firefox best-effort (no per-state pseudo + no :hover targeting the bar):
   thin and transparent at rest, thumb painted only while actively scrolling
   (.mk-scrolling, JS-toggled). Not inherited down via * to avoid the whole
   hovered ancestor chain forcing it on. */
* {
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
}
.mk-scrolling {
    scrollbar-color: var(--scrollbar-thumb) transparent;
}

/* ────────────────────────────────────────────────
   AI Split Button (.ai-btn-group)
   ──────────────────────────────────────────────── */

.ai-btn-group {
    display: inline-flex;
    align-items: stretch;
    border-radius: var(--radius-md);
    overflow: visible;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    vertical-align: middle;
}

.ai-btn-group .ai-btn-action {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.65rem;
    font-size: var(--font-sm);
    font-weight: var(--font-weight-medium);
    color: var(--text-primary);
    background: transparent;
    border: none;
    border-radius: var(--radius-md) 0 0 var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
    white-space: nowrap;
    line-height: 1.4;
}

.ai-btn-group .ai-btn-action:hover:not(:disabled) {
    background: var(--hover-overlay);
    color: var(--text-primary);
}

/* When the action is the ONLY button in the group (no paired settings gear —
   e.g. a robot dropdown trigger whose per-action gears live inside its menu),
   round both sides instead of leaving the right corners square. */
.ai-btn-group .ai-btn-action:only-child {
    border-radius: var(--radius-md);
}

.ai-btn-group .ai-btn-action:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ai-btn-group .ai-btn-action .fa-robot,
.ai-btn-group .ai-btn-action .fa-stethoscope,
.ai-btn-group .ai-btn-action .fa-magic {
    color: var(--accent-color);
}

.ai-btn-group .ai-btn-settings-wrap {
    position: relative;
    display: inline-flex;
    align-items: stretch;
}

.ai-btn-group .ai-btn-settings {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.3rem 0.45rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-left: 1px solid var(--border-color);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.ai-btn-group .ai-btn-settings:hover {
    background: var(--hover-overlay);
    color: var(--text-primary);
}

.ai-btn-group .ai-btn-settings-wrap .ai-profile-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 280px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    z-index: var(--z-dropdown);
    padding: 0.5rem;
    margin-top: 2px;
}

.ai-btn-group .ai-btn-settings-wrap .ai-profile-dropdown.show {
    display: block;
}

.ai-btn-group .ai-btn-settings-wrap .ai-profile-dropdown label {
    display: block;
    font-size: var(--font-xs);
    font-weight: var(--font-weight-medium);
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.ai-btn-group .ai-btn-settings-wrap .ai-profile-dropdown select {
    width: 100%;
    font-size: var(--font-xs);
    padding: 0.25rem 0.4rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-primary);
    height: 28px;
}

.ai-btn-group .ai-btn-settings-wrap .ai-profile-dropdown .ai-custom-prompt {
    width: 100%;
    font-size: var(--font-xs);
    padding: 0.25rem 0.4rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-primary);
    resize: vertical;
    min-height: 48px;
    overflow: hidden;
    font-family: inherit;
}

/* Dark theme adjustments */
.dark .ai-btn-group {
    border-color: var(--border-color);
    background: var(--bg-tertiary);
}

.dark .ai-btn-group .ai-btn-action:hover:not(:disabled) {
    background: var(--hover-overlay);
}

.dark .ai-btn-group .ai-btn-settings:hover {
    background: var(--hover-overlay);
}

.dark .ai-btn-group .ai-btn-settings-wrap .ai-profile-dropdown {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

/* Size variants */
.ai-btn-group.ai-btn-group-sm .ai-btn-action {
    padding: 0.2rem 0.5rem;
    font-size: var(--font-xs);
    gap: 0.25rem;
}

.ai-btn-group.ai-btn-group-sm .ai-btn-settings {
    padding: 0.2rem 0.35rem;
    font-size: 0.65rem;
}

/* ────────────────────────────────────────────────
   Header Icon Buttons (import/export/ai compact)
   ──────────────────────────────────────────────── */

.btn-icon-xs {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}
.btn-icon-xs:hover {
    background: var(--hover-overlay-strong);
    color: var(--text-primary);
}
.dark .btn-icon-xs {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-color: var(--border-color);
}

/* ────────────────────────────────────────────────
   AI Settings Modal
   ──────────────────────────────────────────────── */

.ai-settings-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal-content);
    backdrop-filter: blur(3px);
    animation: fadeIn 0.15s ease;
}
.ai-settings-modal {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-modal);
    width: 520px;
    max-width: 92vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.2s ease;
}
.ai-settings-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}
.ai-settings-modal .modal-header h3 {
    margin: 0;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.ai-settings-modal .modal-header h3 i { color: var(--accent-color); }
.ai-settings-modal .modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1;
}
.ai-settings-modal .modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border-color);
}
.ai-settings-modal .setting-group {
    margin-bottom: 1rem;
}
.ai-settings-modal .setting-group:last-child {
    margin-bottom: 0;
}
.ai-settings-modal .setting-label {
    display: block;
    font-size: var(--font-xs);
    font-weight: var(--font-weight-semibold);
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.ai-settings-modal select,
.ai-settings-modal textarea {
    width: 100%;
    font-size: var(--font-sm);
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: inherit;
}
.ai-settings-modal textarea {
    min-height: 64px;
    resize: vertical;
}
.ai-settings-modal textarea::placeholder {
    color: var(--text-muted);
    font-size: var(--font-xs);
}
.ai-settings-modal .mcp-tools-section {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.5rem;
    max-height: 280px;
    overflow-y: auto;
    background: var(--bg-secondary);
}
.ai-settings-modal .mcp-tool-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.25rem;
    font-size: var(--font-xs);
    border-radius: var(--radius-sm);
}
.ai-settings-modal .mcp-tool-item:hover {
    background: var(--hover-overlay);
}
.ai-settings-modal .mcp-tool-item label {
    flex: 1;
    cursor: pointer;
    color: var(--text-primary);
}
.ai-settings-modal .mcp-tool-item .tool-desc {
    color: var(--text-muted);
    font-size: 0.7rem;
    display: block;
    margin-top: 1px;
}
.ai-settings-modal .mcp-tool-server-header:hover {
    background: var(--hover-overlay);
    border-radius: var(--radius-sm);
}
.ai-settings-modal .mcp-tool-server-tools label:hover {
    background: var(--hover-overlay);
    border-radius: var(--radius-sm);
}
.dark .ai-settings-modal {
    background: var(--bg-secondary);
}

/* Header pair key-value inputs (AI settings + marketplace) */
.ai-header-pair input,
.mcp-header-pair input {
    transition: border-color 0.15s ease;
}
.ai-header-pair input:focus,
.mcp-header-pair input:focus {
    outline: none;
    border-color: var(--accent-color, #2d8cf0) !important;
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-color, #2d8cf0) 15%, transparent);
}
.dark .ai-header-pair input,
.dark .mcp-header-pair input {
    background: var(--bg-tertiary, #1e1e2e);
    border-color: var(--border-color);
    color: var(--text-primary);
}
.dark .ai-header-pair input::placeholder,
.dark .mcp-header-pair input::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}
.ai-add-header-btn:hover,
.mcp-add-header-btn:hover {
    background: color-mix(in srgb, var(--accent-color, #2d8cf0) 8%, transparent) !important;
    border-color: var(--accent-color, #2d8cf0) !important;
}

/* ────────────────────────────────────────────────
   Agent Tasks Panel (inside floating chat)
   ──────────────────────────────────────────────── */

.agent-tasks-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 14px;
    height: 14px;
    border-radius: 7px;
    /* Notification count badge: white numerals must stay legible on the red in
       BOTH themes. --danger-color is #ef4444 (light) / #f87171 (dark) — the dark
       value is a text-on-dark red, too light as a white-text background (2.77:1,
       fails WCAG). Pin a saturated red that carries white at ~4.8:1 either way. */
    background: #dc2626; /* ui-lint-ok: fixed attention-red for a white-text count badge, both themes */
    color: #fff;
    font-size: 9px;
    font-weight: var(--font-weight-bold);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    line-height: 1;
    pointer-events: none;
}

.agent-tasks-panel {
    position: fixed;
    background: var(--bg-primary);
    z-index: var(--z-modal-content);
    display: flex;
    flex-direction: column;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.agent-tasks-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.agent-tasks-panel-header h4 {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
}

.agent-tasks-panel-filters {
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.agent-tasks-panel-list {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.agent-task-item {
    display: flex;
    flex-direction: column;
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s;
}

.agent-task-item:hover {
    background: var(--hover-overlay);
}

/* Card header: status dot + title + action buttons */
.agent-task-item .task-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.agent-task-item .task-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.agent-task-item .task-status-dot.running { background: var(--accent-color); animation: pulse 1.5s infinite; }
.agent-task-item .task-status-dot.completed { background: var(--success-color, #28a745); }
.agent-task-item .task-status-dot.failed { background: var(--danger-color, #ef4444); }
.agent-task-item .task-status-dot.pending { background: var(--text-secondary); }
.agent-task-item .task-status-dot.cancelled { background: var(--warning-color, #f59e0b); }

.agent-task-item .task-title {
    flex: 1;
    min-width: 0;
    font-size: 0.8125rem;
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.agent-task-item .task-card-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
    opacity: 0.5;
    transition: opacity 0.15s;
}

.agent-task-item:hover .task-card-actions {
    opacity: 1;
}

/* Meta chips row */
.agent-task-item .task-meta {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    flex-wrap: wrap;
    margin-top: 4px;
    padding-left: 16px; /* align with title (past status dot) */
    cursor: pointer;
}

.task-meta-chip {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: 0.6875rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.task-meta-chip .icon {
    opacity: 0.6;
}

.task-meta-chip.chip-status-running { color: var(--accent-color); }
.task-meta-chip.chip-status-completed { color: var(--success-text, #22c55e); }
.task-meta-chip.chip-status-failed { color: var(--danger-text, #ef4444); }
.task-meta-chip.chip-status-cancelled { color: var(--warning-text, #f59e0b); }

/* Answer preview on card */
.task-card-preview {
    margin-top: 6px;
    padding: 6px 8px;
    padding-left: 16px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.4;
    max-height: 60px;
    overflow: hidden;
    cursor: pointer;
}

.task-card-preview p { margin: 0 0 4px; }
.task-card-preview p:last-child { margin-bottom: 0; }
.task-card-preview code { font-size: 0.7rem; }
.task-card-preview pre { display: none; }
.task-card-preview ul, .task-card-preview ol { margin: 2px 0; padding-left: 16px; }

/* xs size for btn-icon-circle */
.btn-icon-circle.xs {
    width: 22px;
    height: 22px;
    padding: 0;
}

.btn-icon-circle.xs .icon {
    width: 12px;
    height: 12px;
}

/* Token badge in step labels */
.task-step-tokens {
    font-size: 0.625rem;
    font-weight: var(--font-weight-normal);
    color: var(--text-secondary);
    opacity: 0.7;
    margin-left: 4px;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ─── Task Panel Detail View ─────────────────────────── */
.agent-tasks-detail-header {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    margin-bottom: 0.75rem;
}

.agent-tasks-detail-actions {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    margin-left: auto;
}


/* ─── Task Panel Detail Card ─────────────────────────── */
.task-detail-card {
    padding: 0.75rem 1rem;
}

.task-detail-title-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.task-detail-title {
    margin: 0;
    font-size: 0.875rem;
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.task-detail-chips {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.task-detail-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 6px;
    border-radius: var(--radius-pill);
    font-size: 0.6875rem;
    font-weight: var(--font-weight-semibold);
    background: var(--bg-tertiary, rgba(0,0,0,0.04));
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    white-space: nowrap;
}

.task-detail-chip .icon {
    width: 10px;
    height: 10px;
    opacity: 0.7;
}

.task-detail-chip.chip-status-running {
    color: var(--accent-color);
    border-color: rgba(45,140,240,0.3);
    background: rgba(45,140,240,0.06);
}

.task-detail-chip.chip-status-completed {
    color: var(--success-text, #22c55e);
    border-color: rgba(34,197,94,0.3);
    background: rgba(34,197,94,0.06);
}

.task-detail-chip.chip-status-failed {
    color: var(--danger-text, #ef4444);
    border-color: rgba(239,68,68,0.3);
    background: rgba(239,68,68,0.06);
}

.task-detail-chip.chip-status-cancelled {
    color: var(--warning-text, #f59e0b);
    border-color: rgba(245,158,11,0.3);
    background: rgba(245,158,11,0.06);
}

.dark .task-detail-chip {
    background: rgba(255,255,255,0.06);
}

.dark .task-detail-chip.chip-status-running {
    color: #64b5ff;
    border-color: rgba(100,181,255,0.25);
    background: rgba(100,181,255,0.1);
}

.dark .task-detail-chip.chip-status-completed {
    color: #4ade80;
    border-color: rgba(74,222,128,0.25);
    background: rgba(74,222,128,0.1);
}

.dark .task-detail-chip.chip-status-failed {
    color: #f87171;
    border-color: rgba(248,113,113,0.25);
    background: rgba(248,113,113,0.1);
}

.dark .task-detail-chip.chip-status-cancelled {
    color: #fbbf24;
    border-color: rgba(251,191,36,0.25);
    background: rgba(251,191,36,0.1);
}

/* ─── Task Panel Sections ─────────────────────────── */
.task-detail-section-label {
    font-size: 0.625rem;
    font-weight: var(--font-weight-bold);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.task-detail-prompt-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    margin-bottom: 0.75rem;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 80px;
    overflow-y: auto;
    color: var(--text-primary);
}

.task-detail-error-box {
    background: rgba(239,68,68,0.06);
    border: 1px solid rgba(239,68,68,0.2);
    border-left: 3px solid var(--danger-color, #ef4444);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    margin-bottom: 0.75rem;
    color: var(--danger-text, #ef4444);
    display: flex;
    align-items: flex-start;
    gap: 0.375rem;
}

.task-detail-error-box .icon {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    margin-top: 1px;
}

/* External-effect receipt seam: the generation marker makes uncertainty look
   like an execution boundary, not a generic warning banner. */
.task-receipts {
    display: grid;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.task-receipts-heading {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.task-receipts-heading .icon {
    width: 0.875rem;
    height: 0.875rem;
}

.task-receipt {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem;
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
}

.task-receipt-awaiting_reconcile {
    border-left-color: var(--warning-border);
    background: var(--warning-bg);
    color: var(--warning-text);
}

.task-receipt-failed {
    border-left-color: var(--danger-border);
    background: var(--danger-bg);
}

.task-receipt-done {
    border-left-color: var(--success-border);
    background: var(--success-bg);
}

.task-receipt-generation {
    display: grid;
    place-items: center;
    min-width: 2rem;
    min-height: 2rem;
    padding: 0.25rem;
    border: 1px solid currentColor;
    border-radius: var(--radius-pill);
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    font-weight: var(--font-weight-bold);
}

.task-receipt-body {
    min-width: 0;
}

.task-receipt-title {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    color: var(--text-primary);
    font-size: 0.75rem;
    font-weight: var(--font-weight-semibold);
}

.task-receipt-state {
    color: var(--text-secondary);
    font-size: 0.625rem;
    font-weight: var(--font-weight-medium);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.task-receipt p,
.task-receipts-more {
    margin: 0.25rem 0 0;
    color: var(--text-secondary);
    font-size: 0.6875rem;
    line-height: 1.4;
}

.task-receipt-reason {
    font-style: italic;
}

.task-receipt-result {
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    font-family: var(--font-mono);
}

.task-receipt-permission {
    max-width: 11rem;
    color: var(--text-secondary);
    font-size: 0.6875rem;
    line-height: 1.35;
    text-align: right;
}

.task-receipt-modal-intro {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    margin-bottom: 0.875rem;
    padding: 0.75rem;
    border: 1px solid var(--warning-border);
    border-radius: var(--radius-md);
    background: var(--warning-bg);
    color: var(--warning-text);
}

.task-receipt-modal-intro .icon {
    width: 1.125rem;
    height: 1.125rem;
    flex: 0 0 auto;
}

.task-receipt-modal-intro p {
    margin: 0;
    line-height: 1.45;
}

.task-receipt-modal-facts {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.875rem;
    padding: 0.5rem 0.625rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

.task-receipt-cancelled-note {
    margin: 0.75rem 0 0;
    padding: 0.625rem;
    border-left: 3px solid var(--info-border);
    background: var(--info-bg);
    color: var(--text-secondary);
    font-size: 0.75rem;
    line-height: 1.4;
}

@media (max-width: 480px) {
    .task-receipt {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .task-receipt-reconcile {
        grid-column: 1 / -1;
        width: 100%;
    }

    .task-receipt-permission {
        grid-column: 1 / -1;
        max-width: none;
        text-align: left;
    }

    .task-receipt-title {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.125rem;
    }
}

.dark .task-detail-error-box {
    background: rgba(248,113,113,0.06);
    border-color: rgba(248,113,113,0.2);
    border-left-color: #f87171;
    color: #f87171;
}

.task-detail-answer-box {
    background: rgba(16,185,129,0.04);
    border: 1px solid rgba(16,185,129,0.15);
    border-left: 3px solid var(--success-color, #10b981);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    margin-bottom: 0.75rem;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 150px;
    overflow-y: auto;
    color: var(--text-primary);
}

.dark .task-detail-answer-box {
    background: rgba(52,211,153,0.05);
    border-color: rgba(52,211,153,0.15);
    border-left-color: #34d399;
}

.task-detail-answer-label {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--success-text, #10b981);
}

.dark .task-detail-answer-label {
    color: #34d399;
}

/* ─── Task Panel Flow Steps (inline mini-trace) ─── */
.task-panel-step {
    display: flex;
    gap: 0.5rem;
    padding: 0.35rem 0;
    font-size: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.task-panel-step:last-child {
    border-bottom: none;
}

.task-panel-step-icon {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    margin-top: 2px;
}

.task-panel-step-body {
    flex: 1;
    min-width: 0;
}

.task-panel-step-label {
    color: var(--text-primary);
    font-weight: var(--font-weight-medium);
}

.task-panel-step-content {
    color: var(--text-secondary);
    word-break: break-word;
    max-height: 80px;
    overflow: hidden;
    font-size: 0.6875rem;
    line-height: 1.4;
}

.task-panel-step-content p { margin: 0 0 4px; }
.task-panel-step-content p:last-child { margin-bottom: 0; }
.task-panel-step-content pre {
    white-space: pre-wrap;
    font-family: var(--font-mono, monospace);
    font-size: 0.65rem;
    margin: 4px 0;
    padding: 4px 6px;
    background: rgba(0,0,0,0.04);
    border-radius: var(--radius-xs);
}
.dark .task-panel-step-content pre { background: rgba(255,255,255,0.06); }
.task-panel-step-content code { font-size: 0.65rem; }
.task-panel-step-content ul, .task-panel-step-content ol { margin: 2px 0; padding-left: 16px; }

/* Open Full View button at bottom of detail */
.task-detail-footer {
    padding: 0.75rem 0 0.25rem;
    text-align: center;
    border-top: 1px solid var(--border-color);
    margin-top: 0.75rem;
}

.task-detail-open-flow {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
}

/* ─── Flow Overlay (inside chat widget) ───────────── */
.task-flow-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    z-index: var(--z-modal-content);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* In docked mode, overlay fills the docked panel instead of viewport */
.floating-chat-widget.docked-right .task-flow-overlay {
    position: absolute;
}

.task-flow-overlay-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.task-flow-overlay-header h4 {
    margin: 0;
    font-size: 0.875rem;
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.task-flow-overlay-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.task-flow-overlay-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-top: 1px solid var(--border-color);
}

.task-flow-overlay-footer:empty { display: none; }

/* ─── Waiting Spinner (task running, no steps) ─── */
.task-panel-waiting {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-secondary);
}

.task-panel-waiting .icon {
    width: 24px;
    height: 24px;
    opacity: 0.5;
}

.task-panel-waiting p {
    margin: 0.5rem 0 0;
    font-size: 0.8rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
   FLOW TRACE — Shared between chat widget overlay and agent-tasks page
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Flow Summary Chips ────────────────────────────────────────────────── */
.flow-summary-chips {
    display: flex;
    align-items: center;
    gap: var(--space-2, 0.5rem);
    flex-wrap: wrap;
}

.flow-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1, 0.25rem);
    padding: 2px var(--space-2, 0.5rem);
    border-radius: var(--radius-pill);
    font-size: var(--font-xs, 0.75rem);
    font-weight: var(--font-weight-semibold);
    font-family: var(--font-mono, monospace);
    background: var(--bg-tertiary, rgba(0,0,0,0.04));
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.flow-chip .icon {
    width: 0.85em;
    height: 0.85em;
    opacity: 0.7;
}

.flow-chip.chip-agent {
    color: var(--accent-color);
    border-color: rgba(45,140,240,0.3);
    background: rgba(45,140,240,0.06);
}

.flow-chip.chip-tokens {
    color: var(--warning-text);
    border-color: rgba(245,158,11,0.3);
    background: rgba(245,158,11,0.06);
}

.flow-chip.chip-model {
    color: var(--info-text, #06b6d4);
    border-color: rgba(6,182,212,0.3);
    background: rgba(6,182,212,0.06);
}

.flow-chip.chip-duration {
    color: var(--text-secondary);
}

.dark .flow-chip.chip-agent {
    color: #64b5ff;
    border-color: rgba(100,181,255,0.25);
    background: rgba(100,181,255,0.08);
}

.dark .flow-chip.chip-tokens {
    color: #fbbf24;
    border-color: rgba(251,191,36,0.25);
    background: rgba(251,191,36,0.08);
}

.dark .flow-chip.chip-model {
    color: #22d3ee;
    border-color: rgba(34,211,238,0.25);
    background: rgba(34,211,238,0.08);
}

/* ─── Flow Error Banner ──────────────────────────────────────────────────── */
.flow-error-banner {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2, 0.5rem);
    padding: var(--space-3, 0.75rem) var(--space-4, 1rem);
    margin-bottom: var(--space-4, 1rem);
    border-radius: var(--radius-md, 8px);
    background: rgba(239,68,68,0.06);
    border: 1px solid rgba(239,68,68,0.2);
    border-left: 3px solid var(--danger-color, #ef4444);
    color: var(--danger-text, #ef4444);
    font-size: var(--font-sm, 0.875rem);
    line-height: 1.45;
}

.flow-error-banner .icon {
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.dark .flow-error-banner {
    background: rgba(248,113,113,0.06);
    border-color: rgba(248,113,113,0.2);
    border-left-color: #f87171;
    color: #f87171;
}

/* ─── Flow Prompt Section ────────────────────────────────────────────────── */
.flow-prompt-section {
    margin-bottom: var(--space-5, 1.5rem);
}

.flow-section-label {
    font-size: var(--font-xs, 0.75rem);
    font-weight: var(--font-weight-bold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted, var(--text-secondary));
    margin-bottom: var(--space-1, 0.25rem);
}

.flow-prompt-text {
    font-size: var(--font-sm, 0.875rem);
    color: var(--text-primary);
    line-height: 1.5;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm, 6px);
    padding: var(--space-2, 0.5rem) var(--space-3, 0.75rem);
    max-height: 80px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ─── Flow Answer Section ───────────────────────────────────────────────── */
.flow-answer-section {
    margin-bottom: var(--space-5, 1.5rem);
    padding: var(--space-3, 0.75rem);
    background: rgba(16,185,129,0.04);
    border: 1px solid rgba(16,185,129,0.15);
    border-left: 3px solid var(--success-color, #10b981);
    border-radius: var(--radius-md, 8px);
}

.flow-answer-section .flow-section-label {
    display: flex;
    align-items: center;
    gap: var(--space-1, 0.25rem);
    color: var(--success-text, #10b981);
}

.flow-answer-section .flow-section-label .icon {
    width: 0.85em;
    height: 0.85em;
}

.flow-answer-text {
    font-size: var(--font-sm, 0.875rem);
    color: var(--text-primary);
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 200px;
    overflow-y: auto;
}

.flow-result-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1, 0.25rem);
    margin-top: var(--space-2, 0.5rem);
    font-size: var(--font-sm, 0.875rem);
    font-weight: var(--font-weight-semibold);
    color: var(--accent-color);
    text-decoration: none;
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-sm, 6px);
    background: rgba(45,140,240,0.08);
    border: 1px solid rgba(45,140,240,0.2);
    transition: all 0.15s;
}

.flow-result-link:hover {
    background: rgba(45,140,240,0.15);
    border-color: rgba(45,140,240,0.35);
}

.flow-result-link .icon {
    width: 0.85em;
    height: 0.85em;
}

.dark .flow-answer-section {
    background: rgba(52,211,153,0.05);
    border-color: rgba(52,211,153,0.15);
    border-left-color: #34d399;
}

.dark .flow-answer-section .flow-section-label {
    color: #34d399;
}

.dark .flow-result-link {
    color: #64b5ff;
    background: rgba(100,181,255,0.08);
    border-color: rgba(100,181,255,0.2);
}

.dark .flow-result-link:hover {
    background: rgba(100,181,255,0.15);
    border-color: rgba(100,181,255,0.35);
}

/* ─── Flow Rerun Banner ─────────────────────────────────────────────────── */
.flow-rerun-banner {
    display: flex;
    align-items: center;
    gap: var(--space-2, 0.5rem);
    padding: var(--space-2, 0.5rem) var(--space-3, 0.75rem);
    margin-bottom: var(--space-3, 0.75rem);
    border-radius: var(--radius-md, 8px);
    background: rgba(59,130,246,0.06);
    border: 1px solid rgba(59,130,246,0.2);
    border-left: 3px solid var(--info-color, #3b82f6);
    color: var(--info-text, #3b82f6);
    font-size: var(--font-sm, 0.875rem);
    font-weight: var(--font-weight-medium);
}
.flow-rerun-banner .icon {
    flex-shrink: 0;
    width: 1rem;
    height: 1rem;
}
.dark .flow-rerun-banner {
    background: rgba(96,165,250,0.08);
    border-color: rgba(96,165,250,0.2);
    border-left-color: #60a5fa;
    color: #60a5fa;
}
.flow-rerun-parent-link {
    color: inherit;
    opacity: 0.8;
    font-weight: var(--font-weight-normal);
}
.flow-rerun-parent-link:hover {
    opacity: 1;
}

/* ─── Inherited Steps (from rerun parent) ───────────────────────────────── */
.flow-inherited-label {
    color: var(--text-secondary) !important;
    opacity: 0.7;
}
.flow-inherited-trace {
    opacity: 0.45;
    pointer-events: none;
    position: relative;
}
.flow-inherited-trace::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

/* ─── Rerun Divider ─────────────────────────────────────────────────────── */
.flow-rerun-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0.75rem 0;
    font-size: var(--font-xs, 0.75rem);
    font-weight: var(--font-weight-semibold);
    color: var(--accent-color, #2d8cf0);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.flow-rerun-divider::before,
.flow-rerun-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--accent-color, #2d8cf0);
    opacity: 0.3;
}
.flow-rerun-divider span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    white-space: nowrap;
}
.flow-rerun-divider .icon {
    width: 0.75rem;
    height: 0.75rem;
}

/* ─── Flow Trace Timeline ───────────────────────────────────────────────── */
.flow-trace {
    position: relative;
}

.flow-trace-empty {
    text-align: center;
    padding: var(--space-6, 2rem) var(--space-4, 1rem);
    color: var(--text-muted, var(--text-secondary));
    font-size: var(--font-sm, 0.875rem);
}

.flow-trace-empty .icon {
    width: 2rem;
    height: 2rem;
    display: block;
    margin: 0 auto 0.5rem;
    opacity: 0.3;
}

/* ─── Flow Node ──────────────────────────────────────────────────────────── */
.flow-node {
    position: relative;
    padding-left: 2.25rem;
    padding-bottom: 0.15rem;
}

.flow-node:last-child {
    padding-bottom: 0;
}

/* Vertical connector line */
.flow-node::before {
    content: '';
    position: absolute;
    left: 0.75rem;
    top: 1.35rem;
    bottom: -0.15rem;
    width: 1.5px;
    background: var(--border-color);
}

.flow-node:last-child::before {
    display: none;
}

/* Node dot */
.flow-node-dot {
    position: absolute;
    left: 0.25rem;
    top: 0.3rem;
    width: 1.15rem;
    height: 1.15rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    border: 2px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-muted, var(--text-secondary));
    transition: border-color 0.15s, color 0.15s;
}

.flow-node-dot .icon {
    width: 0.6em;
    height: 0.6em;
}

/* Node type colors — light theme */
.flow-node.node-routing .flow-node-dot { border-color: var(--accent-color); color: var(--accent-color); background: rgba(45,140,240,0.06); }
.flow-node.node-thought .flow-node-dot { border-color: var(--info-color, #06b6d4); color: var(--info-text, #06b6d4); background: rgba(6,182,212,0.06); }
.flow-node.node-tool_call .flow-node-dot { border-color: var(--warning-color, #f59e0b); color: var(--warning-text, #f59e0b); background: rgba(245,158,11,0.06); }
.flow-node.node-tool_result .flow-node-dot { border-color: var(--success-color, #10b981); color: var(--success-text, #10b981); background: rgba(16,185,129,0.06); }
.flow-node.node-decision .flow-node-dot { border-color: var(--success-color, #10b981); color: var(--success-text, #10b981); background: rgba(16,185,129,0.06); }
.flow-node.node-error .flow-node-dot { border-color: var(--danger-color, #ef4444); color: var(--danger-text, #ef4444); background: rgba(239,68,68,0.06); }
.flow-node.node-delegation .flow-node-dot { border-color: #8b5cf6; color: #8b5cf6; background: rgba(139,92,246,0.06); }
.flow-node.node-delegation_result .flow-node-dot { border-color: #a78bfa; color: #a78bfa; background: rgba(167,139,250,0.06); }

/* Node type colors — dark theme */
.dark .flow-node.node-routing .flow-node-dot { border-color: #64b5ff; color: #64b5ff; background: rgba(100,181,255,0.1); }
.dark .flow-node.node-thought .flow-node-dot { border-color: #22d3ee; color: #22d3ee; background: rgba(34,211,238,0.1); }
.dark .flow-node.node-tool_call .flow-node-dot { border-color: #fbbf24; color: #fbbf24; background: rgba(251,191,36,0.1); }
.dark .flow-node.node-tool_result .flow-node-dot { border-color: #34d399; color: #34d399; background: rgba(52,211,153,0.1); }
.dark .flow-node.node-decision .flow-node-dot { border-color: #34d399; color: #34d399; background: rgba(52,211,153,0.1); }
.dark .flow-node.node-error .flow-node-dot { border-color: #f87171; color: #f87171; background: rgba(248,113,113,0.1); }
.dark .flow-node.node-delegation .flow-node-dot { border-color: #a78bfa; color: #a78bfa; background: rgba(167,139,250,0.1); }
.dark .flow-node.node-delegation_result .flow-node-dot { border-color: #c4b5fd; color: #c4b5fd; background: rgba(196,181,253,0.1); }

/* ─── Flow Node Card ─────────────────────────────────────────────────────── */
.flow-node-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md, 8px);
    overflow: hidden;
    margin-bottom: var(--space-2, 0.5rem);
    transition: border-color var(--transition-fast, 0.15s);
}

.flow-node.node-error .flow-node-card { border-left: 3px solid var(--danger-color, #ef4444); }
.dark .flow-node.node-error .flow-node-card { border-left-color: #f87171; }
.flow-node.node-delegation .flow-node-card { border-left: 3px solid #8b5cf6; }
.dark .flow-node.node-delegation .flow-node-card { border-left-color: #a78bfa; }
.flow-node.node-routing .flow-node-card { border-left: 3px solid var(--accent-color); }
.dark .flow-node.node-routing .flow-node-card { border-left-color: #64b5ff; }
.flow-node.node-tool_result .flow-node-card { border-left: 2px solid var(--success-color, #10b981); }
.dark .flow-node.node-tool_result .flow-node-card { border-left-color: #34d399; }
.flow-node.has-delivery-warning .flow-node-card {
    border-left: 3px solid var(--warning-color);
}

/* Card header */
.flow-node-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-2, 0.5rem) var(--space-3, 0.75rem);
    cursor: pointer;
    user-select: none;
    transition: background var(--transition-fast, 0.15s);
    gap: var(--space-2, 0.5rem);
}

.flow-node-card-header:hover {
    background: var(--hover-overlay);
}

.flow-node-card-header-left {
    display: flex;
    align-items: center;
    gap: var(--space-2, 0.5rem);
    flex: 1;
    min-width: 0;
}

.flow-node-type-label {
    font-size: var(--font-xs, 0.75rem);
    font-weight: var(--font-weight-bold);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted, var(--text-secondary));
    white-space: nowrap;
}

/* Type label colors — light */
.flow-node.node-routing .flow-node-type-label { color: var(--accent-color); }
.flow-node.node-thought .flow-node-type-label { color: var(--info-text, #06b6d4); }
.flow-node.node-tool_call .flow-node-type-label { color: var(--warning-text, #f59e0b); }
.flow-node.node-tool_result .flow-node-type-label { color: var(--success-text, #10b981); }
.flow-node.node-decision .flow-node-type-label { color: var(--success-text, #10b981); }
.flow-node.node-error .flow-node-type-label { color: var(--danger-text, #ef4444); }
/* Delegation labels: the token carries an AA-safe violet per theme (light
   #9333ea ~4.9:1 on white, dark #c084fc) — the old raw #8b5cf6/#a78bfa had no
   light variant and failed WCAG AA on the white light-theme card. */
.flow-node.node-delegation .flow-node-type-label,
.flow-node.node-delegation_result .flow-node-type-label { color: var(--accent-purple); }

/* Type label colors — dark */
.dark .flow-node.node-routing .flow-node-type-label { color: #64b5ff; }
.dark .flow-node.node-thought .flow-node-type-label { color: #22d3ee; }
.dark .flow-node.node-tool_call .flow-node-type-label { color: #fbbf24; }
.dark .flow-node.node-tool_result .flow-node-type-label { color: #34d399; }
.dark .flow-node.node-decision .flow-node-type-label { color: #34d399; }
.dark .flow-node.node-error .flow-node-type-label { color: #f87171; }
/* delegation labels use var(--accent-purple), which already flips per theme */

.flow-node-name {
    font-size: var(--font-sm, 0.875rem);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.flow-node-card-header-right {
    display: flex;
    align-items: center;
    gap: var(--space-1, 0.25rem);
    flex-shrink: 0;
}

/* Micro-chips in card header */
.flow-micro-chip {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 1px var(--space-1, 0.25rem);
    border-radius: var(--radius-pill);
    font-size: var(--font-xs, 0.75rem);
    font-weight: var(--font-weight-semibold);
    font-family: var(--font-mono, monospace);
    background: var(--bg-tertiary, rgba(0,0,0,0.04));
    color: var(--text-muted, var(--text-secondary));
    white-space: nowrap;
}

.flow-micro-chip .icon { width: 0.7em; height: 0.7em; }
.flow-micro-chip.micro-agent { color: var(--accent-color); }
.flow-micro-chip.micro-duration { color: var(--text-secondary); }
.dark .flow-micro-chip.micro-agent { color: #64b5ff; }

.flow-delivery-warning-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 1px var(--space-1);
    border: 1px solid var(--warning-color);
    border-radius: var(--radius-pill);
    background: var(--warning-bg);
    color: var(--warning-text);
    font-size: var(--font-xs);
    font-weight: var(--font-weight-bold);
    max-width: 40vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.flow-delivery-warning-badge .icon {
    width: 0.8em;
    height: 0.8em;
}

/* Expand/collapse chevron */
.flow-chevron {
    width: 1em;
    height: 1em;
    transition: transform 0.2s ease;
    color: var(--text-muted, var(--text-secondary));
    flex-shrink: 0;
}

.flow-node-card.expanded .flow-chevron {
    transform: rotate(90deg);
}

/* Card body (collapsible) */
.flow-node-card-body {
    display: none;
    padding: 0 var(--space-3, 0.75rem) var(--space-2, 0.5rem);
    font-size: var(--font-sm, 0.875rem);
    color: var(--text-secondary);
    line-height: 1.55;
}

.flow-node-card.expanded .flow-node-card-body {
    display: block;
}

.flow-node-card-body pre {
    margin: 0;
    padding: var(--space-2, 0.5rem) var(--space-3, 0.75rem);
    background: var(--bg-tertiary, rgba(0,0,0,0.03));
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm, 6px);
    font-family: var(--font-mono, monospace);
    font-size: var(--font-xs, 0.75rem);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 260px;
    overflow-y: auto;
    color: var(--text-primary);
}

.flow-node-card-body .flow-content-text {
    padding: var(--space-1, 0.25rem) 0;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 200px;
    overflow-y: auto;
}

.flow-node.node-error .flow-node-card-body { color: var(--danger-text, #ef4444); }
.dark .flow-node.node-error .flow-node-card-body { color: #f87171; }

/* ─── Step Index Badge ───────────────────────────────────────────────────── */
.flow-step-index {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.1rem;
    height: 1.1rem;
    font-size: 0.625rem;
    font-weight: 800;
    font-family: var(--font-mono, monospace);
    color: var(--text-muted, var(--text-secondary));
    background: var(--bg-tertiary, rgba(0,0,0,0.04));
    border-radius: var(--radius-pill);
    padding: 0 3px;
    flex-shrink: 0;
}

/* ─── Parallel Tool Call Group ────────────────────────────────────────────── */
.flow-parallel-group {
    position: relative;
    margin-left: 2.25rem;
    margin-bottom: var(--space-2, 0.5rem);
    padding: var(--space-2, 0.5rem) 0 var(--space-2, 0.5rem) var(--space-3, 0.75rem);
    border-left: 2px dashed rgba(245,158,11,0.35);
    border-radius: 0 0 0 var(--radius-sm, 6px);
}

.flow-parallel-group::before {
    content: 'PARALLEL';
    position: absolute;
    top: -0.6rem;
    left: var(--space-2, 0.5rem);
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: var(--warning-text, #f59e0b);
    background: var(--bg-primary);
    padding: 0 var(--space-1, 0.25rem);
    text-transform: uppercase;
}

.flow-parallel-group .flow-node { padding-left: 0; padding-bottom: 0; }
.flow-parallel-group .flow-node::before { display: none; }
.flow-parallel-group .flow-node-dot { display: none; }
.flow-parallel-group .flow-node-card { margin-bottom: var(--space-1, 0.25rem); border-left: 2px solid rgba(245,158,11,0.3); }

.dark .flow-parallel-group { border-left-color: rgba(251,191,36,0.3); }
.dark .flow-parallel-group::before { color: #fbbf24; background: var(--bg-primary); }
.dark .flow-parallel-group .flow-node-card { border-left-color: rgba(251,191,36,0.25); }

/* ─── Tool Call → Result Nesting ─────────────────────────────────────────── */
.flow-node.node-tool_result.is-child,
.flow-node.node-delegation_result.is-child { padding-left: 3.75rem; }
.flow-node.node-tool_result.is-child::before,
.flow-node.node-delegation_result.is-child::before { left: 2.25rem; }
.flow-node.node-tool_result.is-child .flow-node-dot,
.flow-node.node-delegation_result.is-child .flow-node-dot { left: 1.75rem; }

/* ─── Re-run / Edit Buttons on Flow Nodes ────────────────────────────────── */
.flow-node-rerun-btn,
.flow-edit-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--radius-sm, 6px);
    background: transparent;
    color: var(--text-muted, var(--text-secondary));
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
}

.flow-node-card-header:hover .flow-node-rerun-btn,
.flow-node-card-header:hover .flow-edit-btn {
    display: inline-flex;
}

.flow-node-rerun-btn:hover {
    color: var(--accent-color);
    background: rgba(45,140,240,0.08);
    border-color: rgba(45,140,240,0.25);
}

.flow-edit-btn:hover {
    color: var(--warning-text, #f59e0b);
    background: rgba(245,158,11,0.08);
    border-color: rgba(245,158,11,0.25);
}

.flow-node-rerun-btn .icon,
.flow-edit-btn .icon { width: 0.7em; height: 0.7em; }

/* ─── Edit Mode ──────────────────────────────────────────────────────────── */
.flow-edit-indicator {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.6rem;
    font-weight: var(--font-weight-bold);
    color: var(--warning-text, #f59e0b);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 1px 5px;
    border-radius: var(--radius-pill);
    background: rgba(245,158,11,0.08);
    border: 1px solid rgba(245,158,11,0.2);
}

.flow-edit-area { margin-top: var(--space-2, 0.5rem); }

.flow-edit-area textarea {
    width: 100%;
    min-height: 80px;
    max-height: 260px;
    font-family: var(--font-mono, monospace);
    font-size: var(--font-xs, 0.75rem);
    padding: var(--space-2, 0.5rem);
    border: 1px solid var(--warning-color, #f59e0b);
    border-radius: var(--radius-sm, 6px);
    background: var(--bg-primary);
    color: var(--text-primary);
    resize: vertical;
    box-sizing: border-box;
}

.flow-edit-area textarea:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(245,158,11,0.2);
}

.flow-edit-actions {
    display: flex;
    align-items: center;
    gap: var(--space-1, 0.25rem);
    margin-top: var(--space-1, 0.25rem);
    justify-content: flex-end;
}

.flow-node-card.is-edited {
    border-color: var(--warning-color, #f59e0b);
    box-shadow: 0 0 0 1px rgba(245,158,11,0.15);
}

/* ─── Dark Theme Overrides for Flow Components ──────────────────────────── */
.dark .flow-step-index {
    background: rgba(255,255,255,0.08);
    color: var(--text-secondary);
    font-size: 0.625rem;
}
.dark .flow-edit-indicator {
    background: rgba(251,191,36,0.12);
    border-color: rgba(251,191,36,0.3);
    color: #fbbf24;
}
.dark .flow-node-card.is-edited {
    border-color: #fbbf24;
    box-shadow: 0 0 0 1px rgba(251,191,36,0.2);
}
.dark .flow-edit-area textarea {
    border-color: #fbbf24;
}
.dark .flow-edit-area textarea:focus {
    box-shadow: 0 0 0 2px rgba(251,191,36,0.3);
}
.dark .flow-micro-chip {
    background: rgba(255,255,255,0.06);
}
.dark .flow-node-rerun-btn:hover {
    background: rgba(100,181,255,0.12);
    color: #64b5ff;
    border-color: rgba(100,181,255,0.3);
}
.dark .flow-edit-btn:hover {
    background: rgba(251,191,36,0.12);
    color: #fbbf24;
    border-color: rgba(251,191,36,0.3);
}
.dark .task-flow-overlay-footer {
    border-top-color: rgba(255,255,255,0.1);
}

/* ─── Markdown inside flow content ──────────────────────────────────────── */
.flow-content-text h1, .flow-content-text h2, .flow-content-text h3,
.flow-answer-text h1, .flow-answer-text h2, .flow-answer-text h3 {
    margin: 0.5rem 0 0.25rem;
    font-size: var(--font-md, 0.875rem);
    font-weight: var(--font-weight-semibold);
}
.flow-content-text code, .flow-answer-text code {
    font-family: var(--font-mono, monospace);
    background: var(--bg-tertiary);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 0.85em;
}
.flow-content-text pre, .flow-answer-text pre {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.5rem;
    overflow-x: auto;
    font-size: var(--font-xs, 0.75rem);
}
.flow-content-text pre code, .flow-answer-text pre code {
    background: transparent;
    padding: 0;
}
.flow-content-text ul, .flow-content-text ol,
.flow-answer-text ul, .flow-answer-text ol {
    margin: 0.25rem 0;
    padding-left: 1.25rem;
}
.flow-content-text p, .flow-answer-text p {
    margin: 0.25rem 0;
}
.flow-content-text table, .flow-answer-text table {
    border-collapse: collapse;
    width: 100%;
    font-size: var(--font-xs, 0.75rem);
}
.flow-content-text th, .flow-content-text td,
.flow-answer-text th, .flow-answer-text td {
    border: 1px solid var(--border-color);
    padding: 0.25rem 0.5rem;
    text-align: left;
}

/* ─── Touch device: always show action buttons ──────────────────────────── */
@media (hover: none) {
    .flow-node-rerun-btn, .flow-edit-btn {
        display: inline-flex;
        opacity: 0.6;
    }
}

/* ─── Flow Node Entry Animation ──────────────────────────────────────────── */
@keyframes flowNodeSlideIn {
    0% { opacity: 0; transform: translateY(12px); }
    100% { opacity: 1; transform: translateY(0); }
}

.flow-node-enter { animation: flowNodeSlideIn 0.35s ease both; }
.flow-node-enter .flow-node-dot { animation: flowNodeSlideIn 0.25s 0.1s ease both, dotPulse 0.8s 0.3s ease both; }

@keyframes dotPulse {
    0% { box-shadow: 0 0 0 0 rgba(45,140,240,0.3); }
    70% { box-shadow: 0 0 0 6px rgba(45,140,240,0); }
    100% { box-shadow: 0 0 0 0 rgba(45,140,240,0); }
}

/* ════════════════════════════════════════════════
   RESPONSIVE — Mobile Adaptive Rules
   Centralized here so all pages benefit.
   ════════════════════════════════════════════════ */

/* ── Global text overflow protection ──────────── */
.btn span,
.nav-link span,
.badge,
.protocol-badge,
.tab-badge {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Tablet (≤1024px) ─────────────────────────── */
@media (max-width: 1024px) {
    .btn { font-size: var(--font-sm); }
    .btn-lg { font-size: var(--font-base); }
    .form-group label { font-size: var(--font-xs); }
}

/* ── Mobile (≤768px) ──────────────────────────── */
@media (max-width: 768px) {
    /* Buttons: shrink padding, hide text in sm buttons */
    .btn {
        padding: var(--space-1) var(--space-3);
        font-size: var(--font-sm);
    }
    .btn-sm {
        padding: var(--space-1) var(--space-2);
        font-size: var(--font-xs);
    }
    .btn-lg {
        padding: var(--space-2) var(--space-4);
        font-size: var(--font-base);
    }
    .btn-icon-circle {
        width: 28px;
        height: 28px;
    }
    .btn-icon-circle.sm {
        width: 24px;
        height: 24px;
    }

    /* Forms: full width, compact */
    .form-input, .form-select, .form-textarea {
        font-size: var(--font-sm);
        height: 34px;
    }
    .form-group { margin-bottom: var(--space-2); }

    /* Badges: smaller */
    .badge { font-size: 0.625rem; padding: 1px 0.35rem; }
    .protocol-badge { font-size: 0.6rem; padding: 0.1rem 0.3rem; }

    /* Modal: full-width on mobile */
    .modal-content {
        max-width: calc(100% - 1rem);
        margin: 1rem auto;
        max-height: calc(var(--vh100) - 2rem);
        overflow-y: auto;
    }

    /* Flow overlay: full-width on mobile */
    .task-flow-overlay {
        max-width: calc(100vw - 1rem);
        width: 100%;
    }
    .agent-tasks-panel {
        max-width: calc(100vw - 1rem);
        max-height: calc(var(--vh100) - 2rem);
    }
    .flow-node-header { flex-wrap: wrap; }
    .flow-micro-chip { font-size: 0.6rem; }

    /* Alerts: compact */
    .alert { font-size: var(--font-xs); padding: var(--space-2) var(--space-3); }

    /* Tabs: scrollable horizontally */
    .admin-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        gap: 0;
        scrollbar-width: none;
    }
    .admin-tabs::-webkit-scrollbar { display: none; }
    .admin-tab {
        font-size: var(--font-sm);
        padding: 0.5rem 0.75rem;
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* Table: horizontal scroll container */
    .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* ── Small phone (≤480px) ─────────────────────── */
@media (max-width: 480px) {
    /* Buttons with text: hide text, show only icon when present */
    .btn.btn-sm > span,
    .btn.btn-xs > span {
        display: none;
    }
    /* Re-show icons in small buttons on mobile (icon-only mode) */
    .btn.btn-sm:not(.btn-icon-circle):not(.btn-icon-xs):not(.btn-icon) > i,
    .btn.btn-xs:not(.btn-icon-circle):not(.btn-icon-xs):not(.btn-icon) > i {
        display: inline-flex;
    }

    .btn {
        padding: var(--space-1) var(--space-2);
        min-width: auto;
    }

    /* Compact spacing */
    .form-group label { font-size: var(--font-xs); margin-bottom: 0; }
    .form-input, .form-select { height: 32px; font-size: var(--font-xs); }

    /* Stack flex groups */
    .d-flex:not(.flex-column) { flex-wrap: wrap; }

    /* Modal footer: stack buttons */
    .modal-footer { flex-direction: column; }
    .modal-footer .btn { width: 100%; }
}

/* ════════════════════════════════════════════════
   Tab Strip — Unified underline-style tabs
   ════════════════════════════════════════════════
   Single source of truth for underline-style tab
   bars across Contracts, Chaos, Fuzzing, Utilities
   sub-tools, etc.  Page-specific classes (.ct-tabs,
   .cx-tabs, .fuzz-tabs, .utils-subtool-bar) inherit
   from these base styles.
   ──────────────────────────────────────────────── */

.tab-strip {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 1.25rem;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: thin;
}

.tab-strip::-webkit-scrollbar { height: 4px; }
.tab-strip::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 2px; }

.tab-item {
    padding: 0.6rem 1.25rem;
    font-size: 0.875rem;
    font-weight: var(--font-weight-medium);
    color: var(--text-secondary);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: color 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
    font-family: inherit;
    line-height: 1.25;
}

.tab-item:hover {
    color: var(--text-primary);
}

.tab-item:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
    border-radius: 2px;
}

.tab-item.tab-item--active,
.tab-item[aria-selected="true"] {
    color: var(--accent-color);
    border-bottom-color: var(--accent-color);
    font-weight: var(--font-weight-semibold);
}

.tab-item .tab-badge,
.tab-item > .tb {
    font-size: 0.7rem;
    padding: 1px 7px;
    border-radius: 10px;
    background: var(--bg-tertiary, var(--bg-secondary));
    color: var(--text-secondary);
    font-weight: var(--font-weight-semibold);
    margin-left: 0.15rem;
}

.tab-item.tab-item--active .tab-badge,
.tab-item.tab-item--active > .tb,
.tab-item[aria-selected="true"] .tab-badge,
.tab-item[aria-selected="true"] > .tb {
    background: var(--accent-color);
    color: var(--accent-contrast);
}

/* Page-specific aliases — keep legacy class names working without changing templates.
   All of these inherit from .tab-strip / .tab-item via matching rules.
   F.6 / F.7 / J.2 / J.3 / J.4: the active-state underline lives here and is
   the canonical rule for every tab bar in the app, so nested fuzz-source-tab
   and runs-tray tab are pulled into the same list to avoid style drift. */
.ct-tabs, .cx-tabs, .fuzz-tabs, .fuzz-source-tabs,
.admin-tabs, .tr-tabs, .ns-tabs, .backup-tabs,
.desktop-tabs, .utils-subtool-bar, .utils-cat-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 1.25rem;
    overflow-x: auto;
    flex-wrap: nowrap;
}

.ct-tab, .cx-tab, .fuzz-tab, .fuzz-source-tab,
.admin-tab, .tr-tab, .ns-tab, .backup-tab,
.desktop-tab, .utils-subtool-btn, .utils-cat-btn, .utils-tool-btn {
    padding: 0.6rem 1.25rem;
    font-size: 0.875rem;
    font-weight: var(--font-weight-medium);
    color: var(--text-secondary);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: color 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
    font-family: inherit;
    line-height: 1.25;
}

.ct-tab:hover, .cx-tab:hover, .fuzz-tab:hover, .fuzz-source-tab:hover,
.admin-tab:hover, .tr-tab:hover, .ns-tab:hover, .backup-tab:hover,
.desktop-tab:hover, .utils-subtool-btn:hover,
.utils-cat-btn:hover, .utils-tool-btn:hover {
    color: var(--text-primary);
}

.ct-tab.active,
.cx-tab.active,
.fuzz-tab.active,
.fuzz-source-tab.active,
.admin-tab.active,
.tr-tab.active,
.ns-tab.active,
.backup-tab.active,
.desktop-tab.active,
.utils-subtool-btn.active,
.utils-cat-btn.active,
.utils-tool-btn.active {
    color: var(--accent-color);
    border-bottom-color: var(--accent-color);
    box-shadow: inset 0 -2px 0 0 var(--accent-color);
    font-weight: var(--font-weight-semibold);
}

/* ════════════════════════════════════════════════
   Page-specific button aliases — collapse legacy
   class names into the canonical .btn family without
   changing every template. New code MUST use .btn /
   .btn-primary / .btn-secondary / .btn-danger directly.
   ──────────────────────────────────────────────── */
.ct-run {
    /* Aligned with .btn-sm so .ct-run sits next to .ct-src-btn (32px/13px)
       — owner UAT 2026-04-28 flagged inconsistent size+font on Contracts. */
    height: var(--btn-h-sm);
    padding: 0 var(--btn-pad-x-sm);
    background: var(--accent-color);
    color: var(--accent-contrast);
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: var(--font-sm);
    font-weight: var(--font-weight-medium);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    transition: all var(--transition-fast);
    white-space: nowrap;
    flex-shrink: 0;
    line-height: 1;
    box-sizing: border-box;
}
.ct-run:hover:not(:disabled) {
    background: var(--accent-hover);
    filter: brightness(0.95);
}
.ct-run:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ════════════════════════════════════════════════
   Icon-circle color modifiers — semantic actions
   without inline styles
   ──────────────────────────────────────────────── */
.btn-icon-circle.warning {
    color: var(--warning-text, #f59e0b);
}
.btn-icon-circle.warning:hover {
    background: rgba(245, 158, 11, 0.12);
    color: var(--warning-text, #f59e0b);
}
.btn-icon-circle.success {
    color: var(--success-text, #22c55e);
}
.btn-icon-circle.success:hover {
    background: rgba(34, 197, 94, 0.12);
    color: var(--success-text, #22c55e);
}

/* ════════════════════════════════════════════════
   Mosaic Logo — Loader & Breathing Animations
   ════════════════════════════════════════════════ */

@keyframes mosaicBreathe {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.12); }
}

.mosaic-loader {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.mosaic-m-icon {
    overflow: visible;
}

/* who-when.js — shared "who did what, when" attribution (GLOBAL-2). A compact
   inline line: icon + verb + resolved user + relative time. Token-themed for
   both light/dark. */
.whowhen {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: var(--font-xs, 0.75rem);
    color: var(--text-secondary, #6b7280);
    white-space: nowrap;
    line-height: 1.4;
}
.whowhen--compact { font-size: 0.7rem; }
.whowhen__icon {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
    color: var(--text-muted, #9ca3af);
}
.whowhen__verb { color: var(--text-muted, #9ca3af); }
.whowhen__user {
    color: var(--text-primary, #111827);
    font-weight: var(--font-weight-semibold);
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.whowhen__user--unknown { color: var(--text-muted, #9ca3af); font-weight: var(--font-weight-normal); font-style: italic; }
.whowhen__sep { color: var(--text-muted, #9ca3af); }
.whowhen__rel { color: var(--text-secondary, #6b7280); }

/* GLOBAL-2: provenance line under a mock detail title. */
.mock-detail__provenance { margin: 2px 0 14px; }
/* GLOBAL-2: provenance line under the prompt editor title. */
.prompt-editor__provenance { margin: -2px 0 10px; }
/* GLOBAL-2: provenance lines on security report / channel / webhook / schedule headers. */
.security-report__provenance { margin: 4px 0 10px; }
/* Risk badge beside a security report title. Tokens only — the band colours
   reuse the shared severity scale so light and dark themes stay consistent. */
.security-report__risk {
    display: inline-block;
    margin: 4px 0 10px 8px;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}
.security-report__risk--critical { color: var(--severity-critical, var(--text-primary)); border-color: currentColor; }
.security-report__risk--high     { color: var(--severity-high, var(--text-primary)); border-color: currentColor; }
.security-report__risk--medium   { color: var(--severity-medium, var(--text-secondary)); border-color: currentColor; }
.security-report__risk--low      { color: var(--severity-low, var(--text-secondary)); border-color: currentColor; }
.webhooks-settings__provenance { margin: 0 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border-color); }
.testplan-schedule__provenance { margin: -4px 0 12px; }

/* Desktop "About" panel — rendered in a MockartyModal body (desktop-only). */
.desktop-about { display: flex; flex-direction: column; gap: 0.55rem; }
.desktop-about .da-app { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.35rem; }
.desktop-about .da-app-name { font-size: 1.05rem; font-weight: var(--font-weight-semibold); color: var(--text-primary); }
.desktop-about .da-row { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; font-size: 0.875rem; }
.desktop-about .da-label { color: var(--text-secondary); flex-shrink: 0; }
.desktop-about .da-value { color: var(--text-primary); text-align: right; word-break: break-word; }
.desktop-about .da-value code { font-family: var(--font-mono, monospace); font-size: 0.8rem; }
.desktop-about .da-update-ok { color: var(--success-text); }
.desktop-about .da-update-available { color: var(--accent-color); font-weight: var(--font-weight-semibold); }
/* Update-flow states shared by the About widget and the desktop-admin pane:
   the last download/apply failure surfaced from /update/status, and the
   "install the new .dmg" hint when self-update is unavailable (macOS .app). */
.desktop-about .da-update-error, .desktop-admin .da-update-error { color: var(--danger-text); font-size: 0.8rem; margin-top: 0.3rem; }
.desktop-about .da-update-manual, .desktop-admin .da-update-manual { color: var(--text-secondary); font-size: 0.8rem; }

/* Desktop Control Panel page (/ui/desktop-admin, desktop-only). */
.desktop-admin { width: 100%; min-width: 0; margin: 0; padding: var(--space-4) var(--space-5) var(--space-6); }
.desktop-admin .da-head { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1.25rem; }
.desktop-admin .da-head-icon { width: 32px; height: 32px; color: var(--accent-color); flex-shrink: 0; }
.desktop-admin .da-title { margin: 0; font-size: 1.4rem; color: var(--text-primary); }
.desktop-admin .da-sub { margin: 0.15rem 0 0; font-size: 0.875rem; color: var(--text-secondary); }
.desktop-admin .da-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; }
.desktop-admin .da-card { background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: var(--radius-md, 10px); padding: 1.1rem 1.25rem; }
.desktop-admin .da-card-title { margin: 0 0 0.8rem; font-size: 1rem; color: var(--text-primary); }
.desktop-admin .da-row { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; font-size: 0.875rem; padding: 0.3rem 0; border-bottom: 1px solid var(--border-color-subtle); }
.desktop-admin .da-row:last-child { border-bottom: none; }
.desktop-admin .da-label { color: var(--text-secondary); flex-shrink: 0; }
.desktop-admin .da-value { color: var(--text-primary); text-align: right; word-break: break-word; }
.desktop-admin .da-value code { font-family: var(--font-mono, monospace); font-size: 0.8rem; }
.desktop-admin .da-actions { display: flex; gap: 0.5rem; margin-top: 0.9rem; flex-wrap: wrap; }
.desktop-admin .da-hint { margin: var(--space-3) 0 0; font-size: var(--font-size-sm); color: var(--text-secondary); line-height: 1.5; }
.desktop-admin .da-skel { color: var(--text-tertiary, var(--text-secondary)); font-size: 0.85rem; padding: 0.3rem 0; }
.desktop-admin .da-badge { display: inline-block; padding: 0.1rem 0.5rem; border-radius: var(--radius-pill); font-size: 0.75rem; background: var(--bg-tertiary); color: var(--text-secondary); }
.desktop-admin .da-badge-ok { background: color-mix(in srgb, var(--success-color) 18%, transparent); color: var(--success-text); }
.desktop-admin .da-badge-trial { background: color-mix(in srgb, var(--accent-color) 18%, transparent); color: var(--accent-color); }
.desktop-admin .da-badge-warn { background: color-mix(in srgb, var(--warning-color) 18%, transparent); color: var(--warning-text, var(--text-primary)); }
/* Light theme: the success/warning inks sit on a tint and land just under AA
   (4.45:1 measured 2026-09-04) — darken them towards the text ink. */
.light .desktop-admin .da-badge-ok { color: color-mix(in srgb, var(--success-text) 70%, var(--text-primary)); }
.light .desktop-admin .da-badge-warn { color: color-mix(in srgb, var(--warning-text, var(--text-primary)) 60%, var(--text-primary)); }
/* Offline device confirmation block inside the licence pane. */
.desktop-admin .da-activation { margin-top: 0.9rem; padding: 0.9rem; border: 1px solid var(--border-color); border-radius: var(--radius-md, 8px); background: var(--bg-secondary); }
.desktop-admin .da-activation-head { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.desktop-admin .da-activation-text { font-size: 0.85rem; color: var(--text-secondary); }
.desktop-admin .da-activation-step { margin-top: 0.7rem; }
.desktop-admin .da-activation-label { display: block; margin: 0.7rem 0 0.3rem; font-size: 0.78rem; font-weight: 500; color: var(--text-secondary); }
.desktop-admin .da-code-row { display: flex; gap: 0.5rem; align-items: flex-start; flex-wrap: wrap; margin-top: 0.5rem; }
.desktop-admin .da-code-row .da-hint { flex-basis: 100%; margin: 0; }
.desktop-admin .da-code { flex: 1 1 260px; min-width: 0; padding: 0.55rem 0.7rem; border: 1px dashed var(--border-color); border-radius: var(--radius-sm, 6px); background: var(--bg-primary); color: var(--text-primary); font-family: var(--font-mono, ui-monospace, monospace); font-size: 0.8rem; line-height: 1.5; word-break: break-all; user-select: all; }
.desktop-admin .da-code-input { width: 100%; font-family: var(--font-mono, ui-monospace, monospace); font-size: 0.8rem; word-break: break-all; }

/* Desktop: "+" namespace button next to the header selector + admin ns list. */
#namespaceAddBtn[hidden], #daNsCreateBtn[hidden], #daNsAnonymousHint[hidden] { display: none !important; }
.namespace-add-btn { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; margin-left: 0.35rem; padding: 0; border: 1px solid var(--border-color); border-radius: var(--radius-sm, 6px); background: var(--bg-secondary); color: var(--text-secondary); cursor: pointer; }
.namespace-add-btn:hover { background: var(--bg-tertiary); color: var(--accent-color); border-color: var(--accent-color); }
.namespace-add-btn .icon { width: 16px; height: 16px; }
.desktop-admin .da-list { display: flex; flex-direction: column; gap: 0.15rem; }
.desktop-admin .da-ns-row { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; padding: 0.35rem 0; border-bottom: 1px solid var(--border-color-subtle); color: var(--text-primary); }
.desktop-admin .da-ns-row:last-child { border-bottom: none; }
.desktop-admin .da-ns-icon { width: 16px; height: 16px; color: var(--text-secondary); flex-shrink: 0; }
.desktop-admin .da-ns-name { word-break: break-word; }

/* Desktop Control Panel — sub-nav + panes layout (D3 redesign). */
.desktop-admin .da-layout { display: flex; gap: var(--space-5); align-items: flex-start; }
.desktop-admin .da-nav { display: flex; flex-direction: column; gap: 2px; min-width: 210px; flex-shrink: 0; position: sticky; top: 1rem; }
.desktop-admin .da-nav-item { display: flex; align-items: center; gap: 0.6rem; padding: 0.55rem 0.75rem; border: none; background: transparent; border-radius: var(--radius-md, 8px); color: var(--text-secondary); font-size: 0.9rem; text-align: left; cursor: pointer; width: 100%; }
.desktop-admin .da-nav-item .icon { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.85; }
.desktop-admin .da-nav-item:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.desktop-admin .da-nav-item.active { background: color-mix(in srgb, var(--accent-color) 14%, transparent); color: var(--accent-text, var(--accent-color)); font-weight: var(--font-weight-semibold); }
.desktop-admin .da-content { flex: 1; min-width: 0; }
.desktop-admin .da-pane { display: none; border-left: 1px solid var(--border-color); padding: 0 0 var(--space-5) var(--space-5); }
.desktop-admin .da-pane.active { display: block; }
.desktop-admin .da-pane > .da-field, .desktop-admin .da-pane > .da-hint { max-width: 80ch; }
.desktop-admin #daPrivacyPosture { margin-top: var(--space-6); padding-top: var(--space-5); border-top: 1px solid var(--border-color); }
.desktop-admin .da-pane-title { margin: 0 0 var(--space-5); font-size: var(--font-lg); font-weight: var(--font-weight-semibold); color: var(--text-primary); }
.desktop-admin h4.da-pane-title { margin-top: var(--space-6); padding-top: var(--space-5); border-top: 1px solid var(--border-color); font-size: var(--font-size-md); }
.desktop-admin .da-field { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-5); }
.desktop-admin .da-field-label { font-size: var(--font-size-sm); font-weight: var(--font-weight-semibold); color: var(--text-primary); }
.desktop-admin .da-field-hint { margin: 0; font-size: var(--font-size-sm); color: var(--text-secondary); line-height: var(--leading-normal); }
.desktop-admin { font-family: var(--font-family-base); font-size: var(--font-size-md); line-height: var(--leading-normal); }
.desktop-admin .form-checkbox { display: flex; align-items: center; gap: var(--space-3); margin: var(--space-2) 0; font-size: var(--font-size-sm); font-weight: var(--font-weight-medium); color: var(--text-primary); }
.desktop-admin .form-checkbox input { align-self: flex-start; margin-top: 0.15em; }
.desktop-admin .form-label { display: block; margin: var(--space-3) 0 var(--space-1); font-size: var(--font-size-sm); font-weight: var(--font-weight-medium); }
.desktop-admin .form-input, .desktop-admin .form-textarea { max-width: 80ch; }
.desktop-admin .da-nav-item, .desktop-admin .da-seg-btn { font-family: inherit; line-height: var(--leading-normal); }
.desktop-admin .da-row, .desktop-admin .da-ns-row { padding: var(--space-3) 0; gap: var(--space-3); }
.desktop-admin .da-row .da-label { min-width: 0; flex-shrink: 1; overflow-wrap: anywhere; }
.desktop-admin .da-actions { gap: var(--space-2); margin-top: var(--space-4); }
.desktop-admin .da-actions .btn { white-space: normal; overflow-wrap: anywhere; }
.desktop-admin .da-seg-btn:focus-visible, .desktop-admin .da-nav-item:focus-visible { outline: none; box-shadow: inset var(--focus-ring); }
.desktop-admin .da-seg { display: inline-flex; border: 1px solid var(--border-color); border-radius: var(--radius-md, 8px); overflow: hidden; width: fit-content; }
.desktop-admin .da-seg-btn { padding: 0.4rem 1rem; border: none; background: var(--bg-primary); color: var(--text-secondary); font-size: 0.875rem; cursor: pointer; border-right: 1px solid var(--border-color); }
.desktop-admin .da-seg-btn:last-child { border-right: none; }
.desktop-admin .da-seg-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.desktop-admin .da-seg-btn.active { background: var(--accent-color); color: var(--accent-contrast); }
.desktop-admin .da-shared-status { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-4); padding: var(--space-3); border: 1px solid var(--border-color); border-radius: var(--radius-md); background: var(--bg-primary); color: var(--text-secondary); overflow-wrap: anywhere; }
.desktop-admin .da-shared-status strong { color: var(--text-primary); }
.desktop-admin .da-shared-status code, .desktop-admin .da-shared-status pre { font-family: var(--font-mono); }
.desktop-admin .da-shared-status pre { max-width: 100%; margin: 0; padding: var(--space-2); border-radius: var(--radius-sm); background: var(--bg-tertiary); color: var(--text-primary); white-space: pre-wrap; overflow-wrap: anywhere; }
.desktop-admin .da-shared-status[data-state="completed"] { border-color: var(--success-border); background: var(--success-bg); }
.desktop-admin .da-shared-status[data-state="failed"], .desktop-admin .da-shared-status[data-state="shared_revoked"], .desktop-admin .da-shared-status[data-state="shared_conflict"], .desktop-admin .da-shared-status[data-state="validation_failed"] { border-color: var(--danger-border); background: var(--danger-bg); }
.desktop-admin .da-shared-status[data-state="shared_unavailable"], .desktop-admin .da-shared-status[data-state="shared_backpressure"] { border-color: var(--warning-border); background: var(--warning-bg); color: var(--warning-text); }
@media (max-width: 720px) {
  .desktop-admin .da-layout { flex-direction: column; }
  .desktop-admin .da-content { width: 100%; }
  .desktop-admin .da-pane { border-left: 0; border-top: 1px solid var(--border-color); padding: var(--space-5) 0; }
  .desktop-admin .da-nav { flex-direction: row; flex-wrap: wrap; min-width: 0; position: static; width: 100%; }
  .desktop-admin .da-nav-item { flex: 1 1 calc(50% - var(--space-2)); }
  .desktop-admin .da-actions .btn { max-width: 100%; }
}

/* ────────────────────────────────────────────────
   Accessibility utilities (a11y-enhance.js, modal-a11y.js, skip link)
   ──────────────────────────────────────────────── */

/* Visually hidden but available to screen readers (WCAG-safe clip). */
.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Skip-to-content link — offscreen until focused (keyboard users). */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: var(--z-toast);
    padding: var(--space-2) var(--space-4);
    /* Highest-contrast token pair (inverts per theme) → always WCAG AA. */
    background: var(--text-primary);
    color: var(--bg-primary);
    border-radius: 0 0 var(--radius-md) 0;
    font-weight: var(--font-weight-semibold);
    text-decoration: none;
}
.skip-link:focus {
    left: 0;
    outline: 2px solid var(--accent-color);
    outline-offset: -4px;
}

/* ────────────────────────────────────────────────
   Text-overflow utilities (UI-kit)
   ──────────────────────────────────────────────────
   The recurring layout bug: long values (URLs, tokens, evidence,
   host names) have no width bound → they push out of their
   container and break the row. Apply one of these + keep the flex
   parent able to shrink (.min-w-0 on the flex child). Pair with a
   `title="<full value>"` so the truncated text stays discoverable.
   ──────────────────────────────────────────────── */

/* Single-line ellipsis. Needs a width constraint on an ancestor
   (a flex/grid track or explicit max-width) to clamp. */
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

/* Wrap anywhere — long unbroken strings (URLs/tokens) wrap inside
   the box instead of overflowing. Preferred for multi-line values. */
.break-any {
    overflow-wrap: anywhere;
    word-break: break-word;
    min-width: 0;
}

/* Classic cause of overflow: a flex child defaults to min-width:auto
   and refuses to shrink below its content, so .truncate never clamps.
   Add this to the flex/grid child that holds the long text. */
.min-w-0 { min-width: 0; }

/* ════════════════════════════════════════════════════════════════════════════
   UI PRIMITIVES — canonical design-system classes (PERF-FE-3)
   Use these everywhere instead of ad-hoc per-page copies.
   All colours come from tokens.css — never hardcoded.
   ════════════════════════════════════════════════════════════════════════════ */

/* ─── 1. Empty States ───────────────────────────────────────────────────────
   Usage:
     <div class="mk-empty-state">
       <div class="mk-empty-state__icon"><i class="..."></i></div>
       <div class="mk-empty-state__title">No items</div>
       <div class="mk-empty-state__subtitle">Add one to get started.</div>
       <div class="mk-empty-state__action"><button ...></button></div>
     </div>
   Modifiers: mk-empty-state--sm (compact), mk-empty-state--lg (wide/large icon)
   ─────────────────────────────────────────────────────────────────────────── */
.mk-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--space-6);
    color: var(--text-secondary);
    gap: var(--space-2);
}
.mk-empty-state--sm {
    padding: var(--space-4);
    font-size: var(--font-sm);
}
.mk-empty-state--lg {
    padding: 4rem var(--space-6);
}
.mk-empty-state__icon {
    font-size: 2rem;
    color: var(--text-muted);
    line-height: 1;
    margin-bottom: var(--space-1);
}
.mk-empty-state--lg .mk-empty-state__icon { font-size: 3rem; }
.mk-empty-state--sm .mk-empty-state__icon { font-size: 1.5rem; }
.mk-empty-state__title {
    font-size: var(--font-base);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    margin: 0;
}
.mk-empty-state--sm .mk-empty-state__title { font-size: var(--font-sm); }
.mk-empty-state__subtitle {
    font-size: var(--font-sm);
    color: var(--text-secondary);
    margin: 0;
}
.mk-empty-state__action {
    margin-top: var(--space-2);
}

/* ─── 2. Pagination ─────────────────────────────────────────────────────────
   Usage:
     <div class="mk-pagination">
       <button class="mk-pagination__btn" disabled>«</button>
       <span class="mk-pagination__label">Page 1 of 5</span>
       <button class="mk-pagination__btn">»</button>
     </div>
   ─────────────────────────────────────────────────────────────────────────── */
.mk-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    flex-wrap: wrap;
}
.mk-pagination__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 var(--space-2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: var(--font-sm);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    flex-shrink: 0;
}
.mk-pagination__btn:hover:not(:disabled) {
    background: var(--bg-secondary);
    border-color: var(--accent-color);
}
.mk-pagination__btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.mk-pagination__btn--active {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: var(--accent-contrast);
    font-weight: var(--font-weight-semibold);
}
.mk-pagination__btn:focus-visible {
    box-shadow: var(--focus-ring);
    outline: none;
}
.mk-pagination__label {
    font-size: var(--font-sm);
    color: var(--text-secondary);
    white-space: nowrap;
    padding: 0 var(--space-1);
}

/* ─── 3. Spinner ────────────────────────────────────────────────────────────
   CSS border-based spinner. Lightweight, no SVG required.
   Usage:
     <div class="mk-spinner" aria-hidden="true"></div>
     <div class="mk-spinner mk-spinner--sm" aria-hidden="true"></div>
     <div class="mk-spinner mk-spinner--lg" aria-hidden="true"></div>
   ─────────────────────────────────────────────────────────────────────────── */
@keyframes mk-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}
/* Global spinner → branded segmented ring (Mockarty blue tones), drop-in for
   the border box so every .mk-spinner across the app is on-brand at once. */
.mk-spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: conic-gradient(from 0deg,
        color-mix(in srgb, var(--accent-color) 14%, transparent) 0 45deg,
        color-mix(in srgb, var(--accent-color) 26%, transparent) 45deg 90deg,
        color-mix(in srgb, var(--accent-color) 40%, transparent) 90deg 135deg,
        color-mix(in srgb, var(--accent-color) 55%, transparent) 135deg 180deg,
        color-mix(in srgb, var(--accent-color) 68%, transparent) 180deg 225deg,
        color-mix(in srgb, var(--accent-color) 80%, transparent) 225deg 270deg,
        color-mix(in srgb, var(--accent-color) 92%, transparent) 270deg 315deg,
        var(--accent-color) 315deg 360deg);
    -webkit-mask: radial-gradient(farthest-side, #0000 calc(100% - 3px), #000 0);
    mask: radial-gradient(farthest-side, #0000 calc(100% - 3px), #000 0);
    animation: mk-spin 0.75s linear infinite;
    flex-shrink: 0;
}
.mk-spinner--xs { width: 14px; height: 14px; border-width: 2px; }
.mk-spinner--sm { width: 18px; height: 18px; border-width: 2px; }
.mk-spinner--lg { width: 36px; height: 36px; border-width: 4px; }

/* ─── 4. Toggle Switch ──────────────────────────────────────────────────────
   Canonical checkbox-based toggle. Replaces ad-hoc .toggle-switch copies.
   Usage:
     <label class="mk-toggle">
       <input type="checkbox" ...>
       <span class="mk-toggle__slider"></span>
     </label>
   Modifier: mk-toggle--sm (36×20px)
   ─────────────────────────────────────────────────────────────────────────── */
.mk-toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
    vertical-align: middle;
}
.mk-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}
.mk-toggle__slider {
    position: absolute;
    inset: 0;
    cursor: pointer;
    background: var(--border-color);
    border-radius: 24px;
    transition: background 0.25s;
}
.mk-toggle__slider::before {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: var(--bg-primary);
    border-radius: 50%;
    transition: transform 0.25s;
    box-shadow: var(--shadow-1);
}
.mk-toggle input:checked + .mk-toggle__slider {
    background: var(--accent-color);
}
.mk-toggle input:checked + .mk-toggle__slider::before {
    transform: translateX(20px);
}
.mk-toggle input:focus-visible + .mk-toggle__slider {
    box-shadow: var(--focus-ring);
}
.mk-toggle input:disabled + .mk-toggle__slider {
    opacity: 0.45;
    cursor: not-allowed;
}
/* Small variant */
.mk-toggle--sm { width: 36px; height: 20px; }
.mk-toggle--sm .mk-toggle__slider { border-radius: 20px; }
.mk-toggle--sm .mk-toggle__slider::before { width: 14px; height: 14px; }
.mk-toggle--sm input:checked + .mk-toggle__slider::before { transform: translateX(16px); }

/* ─── 5. Avatars ────────────────────────────────────────────────────────────
   Initials/image avatar chip. Canonical replacement for tcm-avatar and
   user-avatar-initials patterns.
   Usage:
     <span class="mk-avatar">AB</span>
     <span class="mk-avatar mk-avatar--sm">AB</span>
     <span class="mk-avatar mk-avatar--lg"><img src="..." alt=""></span>
     <span class="mk-avatar mk-avatar--muted">AB</span>
   ─────────────────────────────────────────────────────────────────────────── */
.mk-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: var(--font-xs);
    font-weight: var(--font-weight-semibold);
    color: var(--accent-contrast);
    background: var(--accent-color);
    text-transform: uppercase;
    overflow: hidden;
    flex-shrink: 0;
    user-select: none;
}
.mk-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.mk-avatar--xs { width: 18px; height: 18px; font-size: 8px; }
.mk-avatar--sm { width: 22px; height: 22px; font-size: 9px; }
.mk-avatar--24 { width: 24px; height: 24px; font-size: 10px; }
.mk-avatar--lg { width: 36px; height: 36px; font-size: var(--font-sm); }
.mk-avatar--32 { width: 32px; height: 32px; font-size: var(--font-sm); }
.mk-avatar--xl { width: 48px; height: 48px; font-size: var(--font-base); }
.mk-avatar--muted { background: var(--text-muted); }

/* Avatar cropper (components/avatar-cropper.js) — canvas crop modal body. */
.mk-avatar-cropper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
}
.mk-avatar-cropper__stage {
    max-width: 100%;
    line-height: 0;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-tertiary);
}
.mk-avatar-cropper__canvas {
    display: block;
    max-width: 100%;
    height: auto;
    cursor: grab;
    touch-action: none; /* pointer-event drag owns touch gestures */
}
.mk-avatar-cropper__canvas:active { cursor: grabbing; }
.mk-avatar-cropper__zoom-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    width: 100%;
    max-width: 320px;
    color: var(--text-muted);
}
.mk-avatar-cropper__zoom {
    flex: 1;
    accent-color: var(--accent-color);
}
.mk-avatar-cropper__zoom:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: var(--radius-md);
}
.mk-avatar-cropper__hint {
    margin: 0;
    font-size: var(--font-xs);
    color: var(--text-muted);
    text-align: center;
}
/* Inner element for the image↔initials toggle (legacy user-avatar pattern):
   fills + centers, inherits the avatar's accent bg + accent-contrast text. */
.mk-avatar__initials { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
/* Deterministic per-user initials colours (user-avatar.js hashes the login
   into mk-avatar--hue-N). Fixed identity hues by design — the same person
   keeps the same circle colour in BOTH themes, so these are intentionally
   not theme tokens. All shades hold >=4.5:1 contrast with white initials. */
.mk-avatar--hue-0 { background: #c0392b; color: #fff; } /* ui-lint-ok: fixed identity hue, WCAG AA vs #fff */
.mk-avatar--hue-1 { background: #b7550e; color: #fff; } /* ui-lint-ok: fixed identity hue, WCAG AA vs #fff */
.mk-avatar--hue-2 { background: #1e7e4d; color: #fff; } /* ui-lint-ok: fixed identity hue, WCAG AA vs #fff */
.mk-avatar--hue-3 { background: #1273a6; color: #fff; } /* ui-lint-ok: fixed identity hue, WCAG AA vs #fff */
.mk-avatar--hue-4 { background: #2e5fbf; color: #fff; } /* ui-lint-ok: fixed identity hue, WCAG AA vs #fff */
.mk-avatar--hue-5 { background: #6d3fbf; color: #fff; } /* ui-lint-ok: fixed identity hue, WCAG AA vs #fff */
.mk-avatar--hue-6 { background: #a6337a; color: #fff; } /* ui-lint-ok: fixed identity hue, WCAG AA vs #fff */
.mk-avatar--hue-7 { background: #4d6473; color: #fff; } /* ui-lint-ok: fixed identity hue, WCAG AA vs #fff */

/* =============================================================================
   Tabs (.tabs / .tab / .tab-content) — GLOBAL reusable component.
   Used by mock-detail, generator (openapi/soap/har/mcp/grpc/graphql source tabs),
   constructor, stores. The "globalize" refactor (d08476654) removed .tabs from
   constructor.css but never re-added it to the served global stylesheet
   (this file = internal/designsystem/css/components.css, go:embed'd + served at
   /ui/static/css/components.css), leaving .tabs undefined → host pages rendered
   tabs unstyled (children stacked vertically). Restored from history.
   ============================================================================= */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: var(--space-5);
}

.tab {
    padding: var(--space-3) var(--space-5);
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-weight: var(--font-weight-medium);
    transition: all var(--transition-base);
    border-bottom: 2px solid transparent;
}

.tab.active {
    color: var(--accent-text);
    border-bottom-color: var(--accent-color);
}

.tab:hover:not(.active) {
    color: var(--text-primary);
    background: var(--hover-overlay);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* ── Panel splitter (.cx-splitter) — shared 3-dot drag grip ─────────────────
   Inserted by panel-resize.js between two resizable panes (constructor,
   mocks/undefined viewer, recorder) or on a drawer edge (--edge). Base
   visuals live here because the splitter is a cross-page component; host-
   specific placement rules (grid order, flex width) stay in the host CSS. */
.cx-splitter {
    background: transparent;
    cursor: col-resize;
    position: relative;
    align-self: stretch;
    touch-action: none;
    z-index: 2;
}
/* Wider invisible grab zone than the thin gutter. */
.cx-splitter::before {
    content: '';
    position: absolute;
    left: -8px; right: -8px; top: 0; bottom: 0;
}
/* Centred vertical 3-dot grip (one dot + two via box-shadow). */
.cx-splitter::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 3px; height: 3px;
    border-radius: 50%;
    background: var(--text-muted, #94a3b8);
    box-shadow: 0 -7px 0 var(--text-muted, #94a3b8), 0 7px 0 var(--text-muted, #94a3b8);
    transition: background-color var(--transition-fast, .15s), box-shadow var(--transition-fast, .15s);
    pointer-events: none;
}
.cx-splitter:hover::after,
.cx-splitter:focus-visible::after,
.cx-splitter.is-dragging::after {
    background: var(--accent-color);
    box-shadow: 0 -7px 0 var(--accent-color), 0 7px 0 var(--accent-color);
}
.cx-splitter:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: -1px;
    border-radius: var(--radius-sm, 6px);
}
/* Edge mode: the grip hugs a drawer's left edge (recorder entry detail). */
.cx-splitter--edge {
    position: absolute;
    left: -3px;
    top: 0;
    bottom: 0;
    width: 6px;
    z-index: 5;
}

/* ============================================================================
 * Test-connection control (conn-test.js) — the ONE shared "Проверить
 * подключение" button + inline status pill used across every credential/
 * integration form. Compact, inline, token-driven, both themes.
 * ==========================================================================*/
.conn-test {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.conn-test__btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    white-space: nowrap;
}
.conn-test__btn .icon {
    width: 1rem;
    height: 1rem;
}
.conn-test__status {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.2;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm, 6px);
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
}
/* Single-line, ellipsised message — a long provider error truncates instead of
   wrapping and pushing the modal into a scroll. Full text is in the title. */
.conn-test__msg {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 24ch;
    min-width: 0;
}
.conn-test__status .conn-test__ico {
    width: 0.95rem;
    height: 0.95rem;
    flex-shrink: 0;
}
.conn-test__status.is-testing {
    color: var(--text-secondary);
    background: var(--bg-secondary);
}
.conn-test__status.is-ok {
    color: var(--success-text, #15803d);
    background: var(--success-bg, rgba(34, 197, 94, 0.12));
}
.conn-test__status.is-fail {
    color: var(--danger-text, #b91c1c);
    background: var(--danger-bg, rgba(239, 68, 68, 0.12));
}
.conn-test__detail {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    border: 1px solid currentColor;
    font-size: 0.65rem;
    cursor: help;
    flex-shrink: 0;
}
.conn-test__spin {
    width: 0.85rem;
    height: 0.85rem;
    border-radius: 50%;
    background: conic-gradient(from 0deg,
        color-mix(in srgb, var(--accent-color) 20%, transparent),
        var(--accent-color));
    -webkit-mask: radial-gradient(farthest-side, #0000 calc(100% - 2px), #000 0);
    mask: radial-gradient(farthest-side, #0000 calc(100% - 2px), #000 0);
    animation: conn-test-spin 0.7s linear infinite;
    flex-shrink: 0;
}
@keyframes conn-test-spin { to { transform: rotate(360deg); } }

/* ── iOS focus-zoom guard ──────────────────────────────────────────────
   iOS Safari zooms the page when a focused control's font-size is under
   16px — and never zooms back out, leaving the page "slightly enlarged"
   until the user pinches. The compact mobile form rules above (12-13px)
   trigger it on every field. iOS-only (@supports -webkit-touch-callout),
   so Android keeps the compact density. !important intentionally beats
   the later --font-xs compact overrides. */
@supports (-webkit-touch-callout: none) {
    @media (max-width: 768px) {
        input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
        select,
        textarea,
        .form-input,
        .form-select,
        .form-textarea {
            font-size: 16px !important;
        }
    }
}

/* ── Custom audio player (mkAudioHTML) ──────────────────────────────────────
   Voice notes, TTS agent replies, audio meetings — used by the discussions dock
   AND the in-call chat. A themed tap-to-play bar replacing native <audio
   controls>: consistent across browsers, correct on iOS, and the play tap is
   the user gesture iOS requires (autoplay is blocked). Both themes via tokens.
   The real <audio> is hidden with !important — it must beat the dock's legacy
   `.discussions-msg__attachment audio` sizing rule (higher specificity). */
.mk-audio {
    display: flex;
    align-items: center;
    gap: .55rem;
    margin-top: 4px;
    padding: .4rem .6rem;
    border-radius: var(--radius-pill);
    /* Branded deep-blue player: a faint accent-tinted surface + accent-tinted
       edge so voice/TTS notes read as a Mockarty element, not a generic bar
       (owner: «плеер в тёмно-синих, полностью вписаться в дизайн»). */
    background: linear-gradient(180deg, color-mix(in srgb, var(--accent-color) 6%, var(--bg-secondary)), var(--bg-secondary));
    border: 1px solid color-mix(in srgb, var(--accent-color) 20%, var(--border-color));
    box-shadow: 0 1px 2px color-mix(in srgb, var(--accent-color) 9%, transparent);
    max-width: 340px;
    min-width: 210px;
    box-sizing: border-box;
}
.mk-audio__el {
    display: none !important;
    height: 0 !important;
    width: 0 !important;
}
.mk-audio__play {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    padding: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* Glossy accent orb with a subtle top highlight + accent glow. The fill
       stays in accent territory so the icon uses --accent-contrast (theme-
       adaptive: dark icon on the light dark-theme accent, light icon on the
       deep light-theme accent) — Design-System Invariant #2, WCAG-AA both themes. */
    background: linear-gradient(150deg, color-mix(in srgb, var(--accent-color) 90%, #ffffff), var(--accent-color));
    color: var(--accent-contrast, #fff);
    box-shadow: 0 2px 7px color-mix(in srgb, var(--accent-color) 42%, transparent), inset 0 1px 0 color-mix(in srgb, #ffffff 28%, transparent);
    transition: transform .1s ease, box-shadow .12s ease;
}
.mk-audio__play:hover { transform: scale(1.05); box-shadow: 0 3px 10px color-mix(in srgb, var(--accent-color) 52%, transparent), inset 0 1px 0 color-mix(in srgb, #ffffff 30%, transparent); }
.mk-audio__play:active { transform: scale(0.97); }
.mk-audio__play:focus-visible { box-shadow: var(--focus-ring); outline: none; }
.mk-audio__ic { width: 20px; height: 20px; fill: currentColor; pointer-events: none; }
.mk-audio__ic--pause { display: none; }
.mk-audio.is-playing .mk-audio__ic--play { display: none; }
.mk-audio.is-playing .mk-audio__ic--pause { display: inline-block; }
/* Hospital-pulse progress (owner: «как пульс в больнице — слева и справа
   прямая линия, а не горы; и чтобы двигался»): the rail (::before) and the
   played fill are FLAT 2px baselines — dim vs accent-bright, clipped by
   progress — so both edges are always straight. While the note plays a single
   heartbeat (::after, masked to the QRS spike) sweeps the whole track like a
   monitor's write head, independent of progress so nothing tears. The layers
   live on ::before/::after/the fill, NOT on .mk-audio__track itself, so the
   focus ring stays a clean unmasked ring. */
.mk-audio__track {
    flex: 1 1 auto;
    min-width: 0;
    height: 14px;
    border-radius: var(--radius-xs);
    background: transparent;
    position: relative;
    cursor: pointer;
}
.mk-audio__track::before,
.mk-audio__fill {
    /* ui-lint-ok: the gradient is a mask alpha channel, not a rendered colour */
    -webkit-mask: linear-gradient(0deg, transparent calc(50% - 1px), #fff 0, #fff calc(50% + 1px), transparent 0);
    mask: linear-gradient(0deg, transparent calc(50% - 1px), #fff 0, #fff calc(50% + 1px), transparent 0);
}
.mk-audio__track::before {
    content: '';
    position: absolute;
    inset: 0;
    background: color-mix(in srgb, var(--accent-color) 22%, var(--border-color));
}
.mk-audio__track:focus-visible { box-shadow: var(--focus-ring); outline: none; }
.mk-audio__fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0%;
    /* Deep→bright blue gradient — the played part of the line lights up. */
    background: linear-gradient(90deg, color-mix(in srgb, var(--accent-color) 65%, #0a2a5a), var(--accent-color));
}
/* The travelling heartbeat: parked off-canvas at rest, sweeping when playing. */
.mk-audio__track::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--accent-color);
    --ekg-beat: 48px;
    /* ui-lint-ok: the stroke is a mask alpha channel, not a rendered colour */
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 16'%3E%3Cpath d='M0 8 H12 L16 2 L20 14 L24 8 H32 L35 5.5 L38 10 L41 8 H48' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat calc(var(--ekg-beat) * -1) 0 / var(--ekg-beat) 100%;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 16'%3E%3Cpath d='M0 8 H12 L16 2 L20 14 L24 8 H32 L35 5.5 L38 10 L41 8 H48' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat calc(var(--ekg-beat) * -1) 0 / var(--ekg-beat) 100%;
}
.mk-audio.is-playing .mk-audio__track::after {
    animation: mk-ekg-sweep 2.6s linear infinite;
}
@media (prefers-reduced-motion: reduce) {
    .mk-audio.is-playing .mk-audio__track::after { animation: none; }
}
.mk-audio__time {
    flex: 0 0 auto;
    font-size: .78rem;
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
    min-width: 2.6em;
    text-align: right;
}
/* Cyclic playback-speed badge (1× → 1.5× → 2×, persisted). */
.mk-audio__rate {
    flex: 0 0 auto;
    border: 1px solid color-mix(in srgb, var(--accent-color) 30%, var(--border-color));
    background: color-mix(in srgb, var(--accent-color) 10%, var(--bg-secondary));
    color: var(--accent-color);
    border-radius: var(--radius-pill);
    font-size: .72rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.4;
    padding: 2px 7px;
    min-width: 2.9em;
    cursor: pointer;
    transition: background-color .12s ease;
}
.mk-audio__rate:hover { background: color-mix(in srgb, var(--accent-color) 18%, var(--bg-secondary)); }
.mk-audio__rate:focus-visible { box-shadow: var(--focus-ring); outline: none; }
/* Volume cluster: mute toggle + a slider revealed on hover / keyboard focus. */
.mk-audio__vol {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
}
.mk-audio__mute {
    border: none;
    background: transparent;
    padding: 2px;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: color .12s ease;
}
.mk-audio__mute:hover { color: var(--accent-color); }
.mk-audio__mute:focus-visible { box-shadow: var(--focus-ring); outline: none; }
.mk-audio__mute .icon { width: 16px; height: 16px; pointer-events: none; }
.mk-audio__ic-muted { display: none; }
.mk-audio.is-muted .mk-audio__ic-vol { display: none; }
.mk-audio.is-muted .mk-audio__ic-muted { display: inline-block; }
.mk-audio.is-muted .mk-audio__mute { color: var(--danger-color); }
.mk-audio__vol-slider {
    width: 0;
    opacity: 0;
    margin: 0;
    height: 4px;
    accent-color: var(--accent-color);
    transition: width .15s ease, opacity .15s ease, margin .15s ease;
}
.mk-audio__vol:hover .mk-audio__vol-slider,
.mk-audio__vol:focus-within .mk-audio__vol-slider {
    width: 56px;
    opacity: 1;
    margin-left: 4px;
}
@media (max-width: 480px) {
    .mk-audio { max-width: 100%; width: 100%; }
}

/* ── Reusable button loading state (.btn.is-loading) ─────────────────────────
   Add .is-loading to any .btn to swap its label for a mini branded segmented
   loader (owner: «кнопки-в-действии в наших стилях»). White loader on filled
   primary buttons, brand-accent elsewhere. Uses the global mk-cloader-spin. */
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading > * { visibility: hidden; }
.btn.is-loading::after {
    content: '';
    position: absolute;
    inset: 0;
    margin: auto;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: conic-gradient(from 0deg, color-mix(in srgb, var(--mk-btn-l, var(--accent-color)) 22%, transparent), var(--mk-btn-l, var(--accent-color)));
    -webkit-mask: radial-gradient(farthest-side, #0000 calc(100% - 2px), #000 0);
    mask: radial-gradient(farthest-side, #0000 calc(100% - 2px), #000 0);
    animation: mk-cloader-spin 0.8s linear infinite;
}
.btn-primary.is-loading { --mk-btn-l: #ffffff; }
@media (prefers-reduced-motion: reduce) { .btn.is-loading::after { animation-duration: 2.4s; } }

/* ── Mock-created warnings ─────────────────────────────────────────────────
   Server-side notices shown in the "Mock created" modal: the mock exists, but
   something in it will not behave as written (a condition with no path, an
   extract expression with no request-bucket root). Tokened on both sides so it
   reads correctly in light and dark — --warning-bg/--warning-fg are the pair
   the token layer already defines for exactly this "attention, not failure"
   case. */
.mock-created-warnings {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--warning-color);
    border-radius: var(--radius-md, 0.375rem);
    background: var(--warning-bg);
    color: var(--warning-fg);
}

.mock-created-warnings__title {
    margin: 0 0 0.4rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--warning-fg);
}

.mock-created-warnings__list {
    margin: 0;
    padding-left: 1.1rem;
    font-size: 0.82rem;
    line-height: 1.45;
    color: var(--warning-fg);
}

.mock-created-warnings__list li + li {
    margin-top: 0.35rem;
}

/* ── mk-ekg — the "hospital pulse" oscilloscope ──────────────────────────
   A flat baseline with ONE heartbeat sweeping left→right, like a bedside
   monitor (owner: «как пульс в больнице — слева прямая линия, справа прямая,
   а не горы»). Two mask layers on one element: layer 1 is the beat (a QRS
   spike entering and leaving at line level), layer 2 a static 2px baseline
   the full width — so the edges are ALWAYS flat and the spike travels across.
   The colour comes from the element's background token, so it themes free.
   Per-context sizing: override width/height and set --ekg-beat to scale the
   spike (the sweep keyframe reads the same var, so the loop stays clean). */
.mk-ekg {
    display: inline-block;
    width: 48px;
    height: 14px;
    flex: 0 0 auto;
    background: var(--accent-color);
    --ekg-beat: 48px;
    /* ui-lint-ok: the strokes are mask alpha channels, not rendered colours */
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 16'%3E%3Cpath d='M0 8 H12 L16 2 L20 14 L24 8 H32 L35 5.5 L38 10 L41 8 H48' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"), linear-gradient(0deg, transparent calc(50% - 1px), #fff 0, #fff calc(50% + 1px), transparent 0);
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 16'%3E%3Cpath d='M0 8 H12 L16 2 L20 14 L24 8 H32 L35 5.5 L38 10 L41 8 H48' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"), linear-gradient(0deg, transparent calc(50% - 1px), #fff 0, #fff calc(50% + 1px), transparent 0);
    -webkit-mask-repeat: no-repeat, no-repeat;
    mask-repeat: no-repeat, no-repeat;
    -webkit-mask-size: var(--ekg-beat) 100%, 100% 100%;
    mask-size: var(--ekg-beat) 100%, 100% 100%;
    -webkit-mask-position: calc(var(--ekg-beat) * -1) 0, 0 0;
    mask-position: calc(var(--ekg-beat) * -1) 0, 0 0;
    animation: mk-ekg-sweep 2.3s linear infinite;
}

@keyframes mk-ekg-sweep {
    from {
        -webkit-mask-position: calc(var(--ekg-beat, 48px) * -1) 0, 0 0;
        mask-position: calc(var(--ekg-beat, 48px) * -1) 0, 0 0;
    }
    to {
        -webkit-mask-position: calc(100% + var(--ekg-beat, 48px)) 0, 0 0;
        mask-position: calc(100% + var(--ekg-beat, 48px)) 0, 0 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .mk-ekg { animation: none; }
}

/* ── mk-share-notch — Zoom-style top-center presenter bar ──────────────────
   Shown while YOU share your screen (share-pip.js builds it): full bar =
   blinking dot + label + mic + stop + collapse chevron; collapsed = a slim
   tab («челка») that expands on hover and pins open on click. Fixed to the
   viewport top-center so it reads instantly but never blocks content. */
.mk-share-notch {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10080; /* above the discussions dock (10060) and call chrome */
    display: flex;
    flex-direction: column;
    align-items: center;
}
.mk-share-notch__body {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    max-width: min(92vw, 680px);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-top: 0;
    border-radius: 0 0 14px 14px;
    box-shadow: var(--shadow-3);
    white-space: nowrap;
}
.mk-share-notch__lbl {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.mk-share-notch__dot {
    flex: 0 0 auto;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--danger-color);
    animation: mk-share-notch-blink 1.2s ease-in-out infinite;
}
@keyframes mk-share-notch-blink { 50% { opacity: 0.35; } }
.mk-share-notch__tab {
    display: none;
    align-items: center;
    gap: 6px;
    padding: 3px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-top: 0;
    border-radius: 0 0 10px 10px;
    box-shadow: var(--shadow-2);
    color: var(--text-secondary);
    cursor: pointer;
}
.mk-share-notch__tab .icon { width: 14px; height: 14px; }
/* Collapsed: only the tab; hovering (or keyboard focus) reveals the full bar
   so the share can be stopped without un-collapsing first. */
.mk-share-notch.is-collapsed .mk-share-notch__body { display: none; }
.mk-share-notch.is-collapsed .mk-share-notch__tab { display: inline-flex; }
.mk-share-notch.is-collapsed:hover .mk-share-notch__body,
.mk-share-notch.is-collapsed:focus-within .mk-share-notch__body { display: inline-flex; }
.mk-share-notch.is-collapsed:hover .mk-share-notch__tab { display: none; }
@media (prefers-reduced-motion: reduce) {
    .mk-share-notch__dot { animation: none; }
}

/* ── Skeleton loading system (.mk-skel) ─────────────────────────────────────
   ONE shimmer vocabulary for every page's loading state, so slow instances
   show calm placeholders instead of raw unstyled elements that later "snap"
   into place (owner 2026-08-03). Build a stack of shapes that mirrors the
   final layout:

     <div class="mk-skel-stack">
       <span class="mk-skel mk-skel--title"></span>
       <span class="mk-skel mk-skel--text"></span>
       <span class="mk-skel mk-skel--card"></span>
     </div>

   Tokens only — reads correctly in both themes; honours reduced motion. */
.mk-skel {
    display: block;
    border-radius: var(--radius-sm, 6px);
    background: color-mix(in srgb, var(--text-secondary) 12%, transparent);
    animation: mk-skel-pulse 1.4s ease-in-out infinite;
    min-height: 12px;
}
.mk-skel--title { height: 20px; width: 45%; }
.mk-skel--text { height: 12px; width: 90%; }
.mk-skel--text.short { width: 60%; }
.mk-skel--card { height: 64px; width: 100%; border-radius: var(--radius-md, 8px); }
.mk-skel--row { height: 34px; width: 100%; }
.mk-skel--avatar { height: 28px; width: 28px; border-radius: 50%; }
.mk-skel--btn { height: 28px; width: 90px; border-radius: var(--radius-pill, 999px); }
.mk-skel-stack { display: flex; flex-direction: column; gap: 10px; padding: 12px; }
.mk-skel-stack--row { flex-direction: row; align-items: center; }
@keyframes mk-skel-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .45; }
}
@media (prefers-reduced-motion: reduce) {
    .mk-skel { animation: none; }
}

/* --- Inline result blocks (webhook / callback test results) ------------------
   Shared by the mock constructor and the admin panel — both render the SAME
   result modal, so these live here (globally loaded) rather than in the
   page-scoped constructor.css, which the admin page never loads. */
/* Inline error block inside the webhook/callback test-result modal. Was three
   inline styles carrying a hardcoded rgba tint plus `var(--danger-*, #d32f2f)`
   fallbacks that diverged from the palette's red. --danger-bg / --danger-text
   are the tokens for a tinted error surface and are defined in both themes
   (--danger-text is contrast-checked against --danger-bg). */
.inline-error {
    padding: var(--space-4);
    background: var(--danger-bg);
    border: 1px solid var(--danger-color);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-4);
    color: var(--text-primary);
}
.inline-error-title { color: var(--danger-text); }

/* Same block in its ok / warning states (webhook test result). The tints were
   hardcoded rgba() with `var(--x, #hex)` fallbacks that diverged from the
   palette; --success-bg / --warning-bg carry the themed tint and
   --success-text / --warning-text are contrast-checked against them. */
.inline-status {
    padding: var(--space-4);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    margin-bottom: var(--space-4);
    color: var(--text-primary);
}
.inline-status.is-ok {
    background: var(--success-bg);
    border-color: var(--success-color);
}
.inline-status.is-warn {
    background: var(--warning-bg);
    border-color: var(--warning-color);
}
.inline-status.is-ok .inline-status-title { color: var(--success-text); }
.inline-status.is-warn .inline-status-title { color: var(--warning-text); }

/* Status line shared by the error and ok/warning boxes. */
.inline-note {
    margin-top: var(--space-2);
    margin-bottom: 0;
    color: var(--text-primary);
}



/* --- CodeMirror gutter -------------------------------------------------------
   The vendored codemirror.css hardcodes `.CodeMirror-linenumber { color: #999 }`,
   which measures 2.85:1 on the light editor surface — below AA. The constructor
   used to patch this per-page, so every other editor (API tester, utils, wiki…)
   kept the vendor grey. --text-muted is the token for de-emphasised text and is
   contrast-checked in both themes. */
.CodeMirror .CodeMirror-linenumber,
.CodeMirror-gutters .CodeMirror-linenumber {
    /* Higher specificity than the vendored `.CodeMirror-linenumber`, which is
       linked AFTER this sheet in layout.html and would otherwise win on an
       equal-specificity tie. */
    color: var(--text-muted);
}

/* ── Plugin UI panels (plugin-ui.js) ─────────────────────────────────────
   A plugin's sandboxed iframe panel opens in a full-screen overlay. Uses
   design tokens so it themes in light+dark with the rest of the app; the
   iframe content itself is the plugin's own (sandboxed) markup. */
.plugin-panel-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal, 1000);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--overlay-bg, rgba(0, 0, 0, 0.5));
    padding: 2rem;
}
.plugin-panel-shell {
    display: flex;
    flex-direction: column;
    width: min(1100px, 100%);
    height: min(90vh, 100%);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg, 12px);
    box-shadow: var(--shadow-4);
    overflow: hidden;
}
.plugin-panel-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}
.plugin-panel-title {
    font-weight: 600;
    color: var(--text-primary);
}
.plugin-panel-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0 0.25rem;
}
.plugin-panel-close:hover {
    color: var(--text-primary);
}
.plugin-panel-frame {
    flex: 1;
    width: 100%;
    border: none;
    background: var(--bg-primary);
}
/* ── plugin marketplace catalogue ─────────────────────────────────────────
   The registry renders as category sections of compact cards. Sections carry
   an icon + name + count; cards are a responsive grid that folds to one
   column on narrow screens. Token-driven throughout (both themes). */
.plugin-market-section { margin: 0 0 1.1rem; }
.plugin-market-section-head {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin: 0 0 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
}
.plugin-market-section-head .icon {
    width: 1.05em;
    height: 1.05em;
    color: var(--accent-color);
    flex-shrink: 0;
}
.plugin-market-count {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 0.7em;
    padding: 0 0.5em;
    line-height: 1.5;
}
.plugin-market-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 0.6rem;
}
.plugin-market-card {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.7rem 0.8rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    min-width: 0; /* let the grid shrink cards below content width */
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.plugin-market-card:hover {
    border-color: var(--accent-color);
    box-shadow: var(--shadow-1);
}
.plugin-market-card-title {
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.plugin-market-card-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.16em; /* reserve two lines so card feet align across the row */
}
.plugin-market-card-foot {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: auto;
    min-width: 0;
}
.plugin-market-card-foot .plugin-market-ver {
    flex-shrink: 0;
    white-space: nowrap;
}
.plugin-market-card-spacer { flex: 1; }
.plugin-market-installed {
    display: inline-flex;
    align-items: center;
    gap: 0.3em;
    font-size: 0.78rem;
    color: var(--success-text, var(--text-secondary));
    white-space: nowrap;
}
.plugin-market-installed .icon { width: 1em; height: 1em; }



/* marketplace branch (release-channel) picker */
.plugin-branch-pick { display: inline-flex; align-items: center; gap: 0.35rem; }
.plugin-branch-label { font-size: 0.75rem; color: var(--text-secondary); }
.plugin-branch-sel { padding: 0.15rem 0.4rem; font-size: 0.8rem; width: auto; }

/* marketplace source tabs: switch between named registries */
.plugin-source-tabs { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.plugin-source-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.35em;
    padding: 0.25rem 0.7rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 1em;
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease;
}
.plugin-source-tab:hover { color: var(--text-primary); border-color: var(--accent-color); }
.plugin-source-tab.is-active {
    color: var(--accent-contrast);
    background: var(--accent-color);
    border-color: var(--accent-color);
}
.plugin-source-tab.is-active .plugin-chip { color: inherit; background: transparent; border-color: currentColor; }
/* upgrade badge: v1.0.0 -> v2.0.0 */
.plugin-market-upgrade { color: var(--warning-text, var(--text-primary)); border-color: var(--warning-text, var(--border-color)); font-weight: 600; }

/* plugin-badge: a short "plugin" chip shown next to a plugin-contributed
   affordance (sidebar nav item, page-slot header) so it reads as an extension,
   not a built-in. Token-driven → correct in both themes. */
.plugin-badge {
    display: inline-flex;
    align-items: center;
    margin-left: 0.4em;
    padding: 0 0.4em;
    font-size: 0.68em;
    font-weight: 600;
    line-height: 1.5;
    letter-spacing: 0.02em;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 0.7em;
    white-space: nowrap;
    flex-shrink: 0;
}

/* plugin wiki-macro output: the host styles the statically-pinned data-macro
   span as a lozenge; the first token of data-macro-args picks the colour.
   Token-driven so both themes stay correct. */
span[data-macro] {
    display: inline-flex;
    align-items: center;
    padding: 0 0.5em;
    font-size: 0.78em;
    font-weight: 600;
    line-height: 1.6;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    vertical-align: baseline;
}
span[data-macro][data-macro-args^="green"] { color: var(--success-text, var(--text-primary)); border-color: var(--success-text, var(--border-color)); }
span[data-macro][data-macro-args^="red"] { color: var(--danger-text); border-color: var(--danger-text); }
span[data-macro][data-macro-args^="yellow"] { color: var(--warning-text, var(--text-primary)); border-color: var(--warning-text, var(--border-color)); }
span[data-macro][data-macro-args^="blue"] { color: var(--accent-color); border-color: var(--accent-color); }

/* plugin-tab-glyph: the small puzzle mark prefixing a plugin-contributed
   entity-tab label (mock / issue / TCM case) so it's visibly distinct from the
   built-in tabs. Sized to the label, muted, non-interactive. */
.plugin-tab-glyph {
    width: 0.85em;
    height: 0.85em;
    margin-right: 0.3em;
    opacity: 0.6;
    vertical-align: -1px;
    flex-shrink: 0;
    pointer-events: none;
}
/* page-slot: inline plugin panels embedded into a host page region. */
.plugin-slot-host:empty {
    display: none; /* no plugins → no gap */
}
.plugin-slot-panel {
    display: flex;
    flex-direction: column;
    margin: 0 0 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg, 12px);
    box-shadow: var(--shadow-1);
    overflow: hidden;
}
.plugin-slot-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.85rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-weight: 600;
}
.plugin-slot-frame {
    width: 100%;
    height: 360px;
    border: none;
    background: var(--bg-primary);
}
@media (max-width: 768px) {
    .plugin-slot-frame { height: 260px; }
    .plugin-panel-overlay { padding: 0.5rem; }
}
/* Admin plugin cards + settings form (extracted from inline styles). */
.plugin-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md, 8px);
    padding: 0.75rem 1rem;
    margin-bottom: 0.6rem;
    background: var(--bg-primary);
}
.plugin-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.plugin-card-title { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.plugin-card-title code { font-size: var(--font-xs, 0.72rem); color: var(--text-secondary); word-break: break-all; }
.plugin-card-desc { font-size: var(--font-sm, 0.82rem); color: var(--text-secondary); margin-top: 0.2rem; }
.plugin-card-meta { display: flex; gap: 0.35rem; flex-wrap: wrap; margin-top: 0.4rem; }
.plugin-chip {
    display: inline-block;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-pill, 999px);
    padding: 0.1rem 0.5rem;
    font-size: var(--font-xs, 0.72rem);
}
.plugin-settings-form { max-width: 520px; }
.plugin-settings-form .form-group { margin-bottom: 0.7rem; }
.plugin-settings-form label { display: block; font-size: var(--font-sm, 0.8rem); color: var(--text-secondary); margin-bottom: 0.25rem; }
.plugin-settings-form .field-hint { font-size: var(--font-xs, 0.72rem); color: var(--text-secondary); margin-top: 0.15rem; }
.plugin-settings-form .checkbox-row { display: flex; align-items: center; gap: 0.5rem; }
.plugin-settings-form .checkbox-row label { margin: 0; }
.plugin-health-ok { color: var(--success-text, var(--text-primary)); border-color: var(--success-text, var(--border-color)); }
.plugin-health-bad { color: var(--danger-text); border-color: var(--danger-text); font-weight: 600; }
.sidebar-plugin-nav {
    list-style: none;
    margin: 0;
    padding: 0;
}
/* Compact, reusable disclosure for explanatory copy that must remain
   available without permanently taking over working space. */
.compact-help {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-secondary);
}

.compact-help > summary {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    cursor: pointer;
    color: var(--text-primary);
    font-size: var(--font-sm);
    font-weight: var(--font-weight-medium);
}

.compact-help > summary .icon { color: var(--accent-text); }
.compact-help-body { padding: 0 var(--space-3) var(--space-3); font-size: var(--font-sm); line-height: 1.45; }

/* The action line inside a plain .empty-state (the mk- variant has its own).
   An empty state that only states a fact is a dead end when the reader is the
   person who can fix it. */
.empty-state__action {
    margin-top: 8px;
    font-size: 0.85rem;
}

.empty-state__action a { color: var(--accent-text); text-decoration: underline; }

/* ── Specialist execution contract (agent catalogue + direct invocation) ─────
   What a person needs before handing work to a specialist: what it may touch,
   which runner it needs, what it leaves behind, what it costs. The model got
   all of this from the agent_catalogue manifest; the person got a name in a
   dropdown. Tokens only — the severity of a side-effect class must read the
   same in both themes. */
.agent-contract {
    margin-top: 8px;
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    font-size: 0.8rem;
}
.agent-contract-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 4px;
}
.agent-contract-row:last-child { margin-bottom: 0; }
.agent-contract-label {
    color: var(--text-muted);
    flex: 0 0 auto;
}
.agent-contract-value { color: var(--text-primary); }
.agent-contract-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 8px;
    border-radius: var(--radius-pill);
    font-size: 0.72rem;
    font-weight: 600;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}
.agent-contract-chip .icon { width: 0.8rem; height: 0.8rem; }
.agent-contract-chip.is-read {
    background: var(--info-bg);
    color: var(--info-text);
    border-color: var(--info-border);
}
.agent-contract-chip.is-write {
    background: var(--warning-bg);
    color: var(--warning-text);
    border-color: var(--warning-border);
}
.agent-contract-chip.is-severe {
    background: var(--danger-bg);
    color: var(--danger-text);
    border-color: var(--danger-border);
}
.agent-contract-warning {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--border-color);
    color: var(--danger-text);
    font-weight: 600;
}
.agent-contract-warning .icon { width: 1rem; height: 1rem; flex-shrink: 0; }

/* ── Plugin entity links (linkkit / D6) ──────────────────────────────────────
   One look for the plugin-contributed "external links" block on EVERY entity
   card (issue, mock, test case, wiki page, dashboard, contract, scan,
   collection). Rendered by static/js/components/plugin-entity-links.js. */
.mel-section { display: flex; flex-direction: column; gap: 4px; }
/* The renderer sets `hidden` on the host when no plugin contributes a type, and
   again on a re-mount. An author `display` rule beats the UA mapping of the
   attribute, so without this the block stays visible (empty) the moment the
   class has been applied once. */
.mel-section[hidden] { display: none !important; }
.mel-head { display: inline-flex; align-items: center; gap: 6px; }
.mel-label {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--text-secondary);
}
.mel-add {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    padding: 0;
    line-height: 1;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
}
.mel-add:hover { background: var(--hover-bg); color: var(--text-primary); }
.mel-add:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.mel-list { display: flex; flex-wrap: wrap; gap: 4px; }
.mel-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    max-width: 100%;
    padding: 1px 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-pill);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.75rem;
    overflow-wrap: anywhere;
}
.mel-pill a { color: var(--accent-color); text-decoration: none; }
.mel-pill a:hover { text-decoration: underline; }
.mel-del {
    border: 0;
    padding: 0;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1;
}
.mel-del:hover { color: var(--danger-text); }
.mel-del:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.mel-empty { font-size: 0.75rem; color: var(--text-secondary); }
.mel-chip { position: relative; }
.mel-chip-count {
    margin-left: 3px;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-secondary);
}

/* ── Hand-off from a module to autonomy ─────────────────────────────────────
   The bar that says what a person is carrying over and which autonomy mode
   they are handing it to. Tokens only; the context line has to read as
   information, not as a warning. */
.handoff-context {
    margin-bottom: 10px;
    padding: 6px 10px;
    border-left: 3px solid var(--accent-color);
    background: var(--bg-secondary);
    border-radius: var(--radius-xs);
    font-size: 0.8rem;
    color: var(--text-secondary);
    overflow-wrap: anywhere;
}
.handoff-modes { flex-wrap: wrap; gap: 12px; margin: 4px 0 6px; }
.handoff-mode {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-primary);
    cursor: pointer;
}
.handoff-mode input { accent-color: var(--accent-color); }
.handoff-mode input:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: var(--radius-xs);
}
