.htmx-indicator {
    opacity: 0;
    transition: opacity 200ms ease-in;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    opacity: 1;
}

/* Native <dialog> used as the modal container */
dialog.card {
    position: fixed;
    margin: auto;
    margin-bottom: auto !important;
    padding: 0;
    max-width: none;
    min-width: 600px;
    border: 1px solid var(--aw-border-strong);
    background-color: var(--aw-surface);
    color: var(--bulma-text);
    box-shadow: 0 40px 100px -40px rgba(0, 0, 0, 0.9);
}

dialog.card::backdrop {
    background: rgba(2, 4, 8, 0.7);
    backdrop-filter: blur(4px);
}

dialog.card[open] {
    animation: modal-in 150ms ease-out;
}

@keyframes modal-in {
    from {
        transform: scale(0.96);
        opacity: 0;
    }
}

/* Bulma's box-sizing: inherit doesn't reach the box a <details> wraps its
   content in, so everything inside one fell back to content-box (selects and
   inputs overflowed their columns by their padding) */
::details-content {
    box-sizing: inherit;
}

.modal-close {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 1;
}

html,
body {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

body {
    display: grid;
    grid-template-rows: 1fr 24px;
    grid-template-columns: auto 1fr;
}

main {
    grid-row: 1 / 2;
    grid-column: 2 / 3;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

footer {
    grid-row: 2 / 3;
    grid-column: 2 / 3;
}

/* Bulma's .footer padding (3rem 1.5rem 6rem) overflows the 24px grid row */
footer.footer {
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    border-top: 1px solid var(--aw-border);
}

.sidebar {
    width: 16rem;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--aw-border);
    background-color: rgba(255, 255, 255, 0.012);
    grid-row: 1 / 3;
}

.sidebar nav {
    flex-grow: 1;
}

.sidebar-brand {
    padding: 1.25rem;
    border-bottom: 1px solid var(--aw-border);
}

.sidebar-brand-link {
    display: inline-flex;
    text-decoration: none;
}

.login-brand {
    margin-bottom: 1.5rem;
}

.login-brand .wordmark {
    font-size: 1.6rem;
}

.sidebar-footer {
    border-top: 1px solid var(--aw-border);
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 0.25rem;
}

.sidebar-user-meta {
    min-width: 0;
    line-height: 1.2;
}

.sidebar-logout {
    border-top: 1px solid var(--aw-border);
    padding-top: 0.5rem;
}

.sidebar-logout .sidebar-item {
    background: none;
    border: 0;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    color: var(--aw-muted);
    width: 100%;
    padding: 0.5em 0.75em;
    border-radius: 8px;
    transition:
        color 0.2s,
        background-color 0.2s;
}

.sidebar-logout .sidebar-item:hover {
    background-color: rgba(251, 113, 133, 0.12);
    color: var(--aw-red);
}

.avatar-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 10px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--aw-ink);
    background: linear-gradient(135deg, var(--aw-cyan), var(--aw-copper));
    box-shadow: 0 10px 28px -14px rgba(46, 230, 255, 0.6);
}

.connector-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    overflow: hidden;
}

.connector-icon img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 0.25rem;
}

.connector-card {
    height: 100%;
    text-align: left;
    cursor: pointer;
    border: 1px solid transparent;
    padding: 0;
    transition:
        border-color 0.25s,
        transform 0.25s,
        box-shadow 0.25s;
}

.connector-card:hover {
    border-color: rgba(46, 230, 255, 0.35);
    transform: translateY(-2px);
    box-shadow: 0 24px 50px -30px rgba(46, 230, 255, 0.4);
}

.table-wrap {
    border: 1px solid var(--aw-border);
    border-radius: var(--bulma-radius-large);
    background-color: rgba(255, 255, 255, 0.015);
    overflow-x: auto;
}

.truncate {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.icon svg {
    width: 1em;
    height: 1em;
}

/* Full-page forms taller than the viewport (main itself does not scroll) */
.page-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

/* ---- Flow editors (Views/VirtualTools/_Editor.cshtml, Views/Workflows/Edit.cshtml) ----
   Grid: header / alerts / tabs, then the Flow tab's step list | side panel.
   The editor's <form> is display: contents so its sections are grid items
   alongside the step panel and access panel, which live outside it. */
.flow-editor {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(18rem, 1fr) minmax(0, 1.4fr);
    /* max-content, not auto: .tabs is a scroll container, so an auto row
       would collapse to 0 when the content overflows the grid's height */
    grid-template-rows: max-content max-content max-content minmax(0, 1fr);
    grid-template-areas:
        "header header"
        "alerts alerts"
        "tabs tabs"
        "list pane";
    column-gap: 1.5rem;
}

.flow-form {
    display: contents;
}

/* Which sections show: data-tab and data-pane on .flow-editor */
.flow-col,
.flow-pane,
.flow-details,
.flow-access {
    display: none;
}

.flow-editor[data-tab="flow"] .flow-col,
.flow-editor[data-tab="flow"][data-pane="empty"] [data-flow-pane="empty"],
.flow-editor[data-tab="flow"][data-pane="input"] [data-flow-pane="input"],
.flow-editor[data-tab="flow"][data-pane="output"] [data-flow-pane="output"],
.flow-editor[data-tab="flow"][data-pane="node"] [data-flow-pane="node"],
.flow-editor[data-tab="details"] .flow-details,
.flow-editor[data-tab="access"] .flow-access {
    display: block;
}

/* ---- Shared editor chrome (virtual tool and route editors) ----
   The editor root carries data-dirty; grids name their areas header, alerts,
   tabs, list and pane. */
.editor-unsaved {
    display: none;
}

[data-dirty="true"] .editor-unsaved {
    display: inline-flex;
}

/* "Save to apply" notes (data-editor-changed, toggled by editor.js) */
[data-editor-changed][hidden] {
    display: none !important;
}

.editor-header {
    grid-area: header;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1rem;
    margin-bottom: 1rem;
}

.editor-header-main {
    min-width: 0;
}

.editor-back {
    display: inline-block;
    margin-bottom: 0.35rem;
    color: var(--aw-muted);
}

.editor-back:hover {
    color: var(--aw-text);
}

.editor-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35rem 0.75rem;
    min-width: 0;
}

.editor-heading-name {
    padding: 0;
    background: none;
    color: var(--aw-muted);
    font-size: 0.8rem;
}

.editor-heading-name:empty {
    display: none;
}

.editor-header-actions {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: 0.5rem;
}

.editor-menu {
    position: relative;
}

.editor-menu > summary {
    list-style: none;
}

.editor-menu > summary::-webkit-details-marker {
    display: none;
}

.editor-menu-items {
    position: absolute;
    top: calc(100% + 0.35rem);
    right: 0;
    z-index: 20;
    min-width: 13rem;
    padding: 0.35rem;
    border: 1px solid var(--aw-border-strong);
    border-radius: var(--bulma-radius);
    background-color: var(--aw-surface-2);
    box-shadow: 0 20px 40px -20px rgba(0, 0, 0, 0.8);
}

.editor-menu-item {
    display: block;
    padding: 0.45rem 0.65rem;
    border-radius: 6px;
    font-size: 0.875rem;
}

button.editor-menu-item {
    width: 100%;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.editor-menu-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.editor-menu-item.has-text-danger:hover {
    background-color: rgba(251, 113, 133, 0.12);
}

.editor-alerts {
    grid-area: alerts;
}

.editor-alerts .validation-summary-valid {
    display: none;
}

.editor-alerts .notification {
    margin-bottom: 1rem !important;
}

.flow-tabs {
    grid-area: tabs;
    margin-bottom: 1.25rem !important;
}

/* Flow tab: step list */
.flow-col {
    grid-area: list;
    overflow-y: auto;
    padding: 0.25rem 0.5rem 1.5rem 0.25rem;
}

.flow-step-card {
    position: relative;
}

.flow-card {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 0.9rem 0.75rem 2rem;
    border: 1px solid var(--aw-border-strong);
    border-radius: var(--bulma-radius-large);
    background-color: var(--aw-surface);
    color: var(--aw-text);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition:
        border-color 0.15s,
        box-shadow 0.15s,
        background-color 0.15s;
}

.flow-card:hover {
    border-color: rgba(46, 230, 255, 0.4);
}

.flow-card:focus-visible {
    outline: 2px solid var(--aw-cyan);
    outline-offset: 2px;
}

.flow-card.has-problem {
    border-color: rgba(251, 113, 133, 0.55);
}

.flow-card.is-selected {
    border-color: var(--aw-cyan);
    background-color: var(--aw-surface-2);
    box-shadow:
        0 0 0 1px var(--aw-cyan),
        0 16px 40px -24px rgba(46, 230, 255, 0.6);
}

.flow-card-io {
    border-style: dashed;
    background-color: transparent;
}

.flow-card-badge {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 8px;
    background-color: rgba(46, 230, 255, 0.12);
    color: var(--aw-cyan);
    font-size: 0.8rem;
    font-weight: 700;
}

.flow-card.is-form .flow-card-badge {
    background-color: rgba(240, 163, 94, 0.14);
    color: var(--aw-copper);
}

.flow-badge-io {
    background-color: rgba(255, 255, 255, 0.06);
    color: var(--aw-muted);
}

.flow-badge-io svg {
    width: 1rem;
    height: 1rem;
}

.flow-card-body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}

.flow-card-title {
    overflow: hidden;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.flow-card-sub {
    color: var(--aw-muted);
    font-size: 0.8rem;
    overflow-wrap: anywhere;
}

.flow-card-io .flow-card-sub {
    font-family: var(--aw-mono);
    font-size: 0.75rem;
}

.flow-card-uses {
    color: var(--aw-dim);
    font-size: 0.75rem;
}

.flow-card-problem {
    color: var(--aw-red);
    font-size: 0.75rem;
    font-weight: 600;
}

.flow-card-problem::before {
    content: "⚠ ";
}

.flow-card-type {
    flex: 0 0 auto;
}

.flow-card.is-form .flow-card-type {
    color: var(--aw-copper);
}

.flow-handle {
    position: absolute;
    top: 50%;
    left: 0.45rem;
    z-index: 1;
    width: 1.1rem;
    height: 1.1rem;
    transform: translateY(-50%);
    color: var(--aw-dim);
    cursor: grab;
}

.flow-handle:hover {
    color: var(--aw-text);
}

.flow-handle svg {
    width: 100%;
    height: 100%;
}

.flow-step.sortable-ghost .flow-card {
    opacity: 0.4;
}

/* Connectors between cards, with the "+" insert points on them */
.flow-gap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 1.75rem;
}

.flow-gap::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 2px;
    transform: translateX(-50%);
    background-color: var(--aw-border-strong);
}

.flow-insert {
    position: relative;
    z-index: 1;
    width: 1.4rem;
    height: 1.4rem;
    padding: 0;
    border: 1px dashed var(--aw-cyan);
    border-radius: 999px;
    background-color: var(--aw-bg);
    color: var(--aw-cyan);
    font: inherit;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
}

.flow-gap:hover .flow-insert,
.flow-insert:focus-visible,
.flow-insert.is-selected {
    opacity: 1;
}

.flow-insert.is-selected {
    border-style: solid;
}

@media (hover: none) {
    .flow-insert {
        opacity: 0.6;
    }
}

.flow-gap-add {
    height: auto;
    padding-top: 0.6rem;
}

.flow-gap-add::before {
    bottom: auto;
    height: 0.6rem;
}

/* Connector tool descriptions can be long; keep the step editor compact */
.flow-tool-description {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
}

.flow-add.button {
    position: relative;
    z-index: 1;
    border: 1px dashed rgba(46, 230, 255, 0.4);
    background-color: var(--aw-bg);
    color: var(--aw-cyan);
}

.flow-add.button:hover,
.flow-add.is-selected {
    border-color: var(--aw-cyan);
    color: var(--aw-cyan-hover);
}

.flow-add.is-selected {
    border-style: solid;
}

/* Flow tab: side panel */
/* Side panel (both editors) */
.editor-panel {
    grid-area: pane;
    align-self: start;
    max-height: 100%;
    overflow-y: auto;
    padding: 1.25rem;
    border: 1px solid var(--aw-border);
    border-radius: var(--bulma-radius-large);
    background-color: var(--aw-surface);
}

.flow-pane-empty {
    border-style: dashed;
    background-color: transparent;
}

.flow-empty {
    padding: 1.5rem 1rem;
    text-align: center;
}

.editor-pane-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.editor-pane-head-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.editor-kicker {
    margin-bottom: 0.15rem;
    color: var(--aw-muted);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* Step editor actions stay in view while its inputs scroll */
.editor-pane-foot {
    position: sticky;
    bottom: 0;
    margin: 1.25rem -1.25rem -1.25rem;
    padding: 0.9rem 1.25rem;
    border-top: 1px solid var(--aw-border);
    background-color: var(--aw-surface);
}

.flow-schema.textarea {
    min-height: 22rem;
}

/* Details and Access tabs */
.flow-details,
.flow-access {
    grid-row: 4;
    grid-column: 1 / -1;
    max-width: 56rem;
    overflow-y: auto;
    padding: 0.25rem 0.25rem 2rem;
}

.flow-details fieldset {
    border: 0;
    margin: 0;
    padding: 0;
}

.flow-hints {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
    gap: 0.75rem;
}

.flow-hint.checkbox {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.75rem;
    border: 1px solid var(--aw-border);
    border-radius: var(--bulma-radius);
    line-height: 1.35;
}

.flow-hint input {
    margin-top: 0.2rem;
}

.flow-hint:has(input:checked) {
    border-color: rgba(46, 230, 255, 0.45);
    background-color: rgba(46, 230, 255, 0.05);
}

/* Narrow: stack the step list above the side panel and scroll as a page */
@media (max-width: 1199px) {
    .flow-editor {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: none;
        grid-auto-rows: max-content;
        grid-template-areas:
            "header"
            "alerts"
            "tabs"
            "list"
            "pane";
        align-content: start;
        overflow-y: auto;
    }

    .flow-col,
    .flow-pane,
    .flow-details,
    .flow-access {
        max-height: none;
        overflow: visible;
    }

    .flow-details,
    .flow-access {
        grid-column: 1;
    }

    .flow-pane {
        margin-bottom: 1.5rem;
        scroll-margin-top: 1rem;
    }

    .editor-header {
        flex-wrap: wrap;
    }
}

/* Elicitation form builder */
.form-builder-field.has-errors {
    box-shadow: 0 0 0 1px var(--aw-red);
}

.form-builder-handle {
    cursor: grab;
}

.form-builder-field.sortable-ghost {
    opacity: 0.4;
}

/* Virtual tool node editor: tool input mappings */
.node-inputs-table td {
    vertical-align: top;
}

.node-inputs-table .node-input-name {
    width: 38%;
    overflow-wrap: anywhere;
}

/* ---- Route editor (Views/Routes/Edit.cshtml) ----
   Grid: header / alerts / tabs, then the Configuration tab's route form (list)
   | preview (pane), or the Debugger tab across both columns. */
.rt-editor {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(20rem, 1.15fr) minmax(0, 1fr);
    /* max-content: see .flow-editor */
    grid-template-rows: max-content max-content max-content minmax(0, 1fr);
    grid-template-areas:
        "header header"
        "alerts alerts"
        "tabs tabs"
        "list pane";
    column-gap: 1.5rem;
}

.rt-tabs {
    grid-area: tabs;
    margin-bottom: 1.25rem !important;
}

.rt-debugger {
    display: none;
    grid-row: 4;
    grid-column: 1 / -1;
    min-height: 0;
    flex-direction: column;
}

.rt-editor[data-tab="debugger"] .rt-config,
.rt-editor[data-tab="debugger"] .rt-preview {
    display: none;
}

.rt-editor[data-tab="debugger"] .rt-debugger {
    display: flex;
}

.rt-heading {
    font-family: var(--aw-mono);
    letter-spacing: -0.01em;
    overflow-wrap: anywhere;
}

.rt-disabled {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.rt-config {
    grid-area: list;
    min-height: 0;
    overflow-y: auto;
    padding: 0.25rem 0.5rem 2rem 0.25rem;
}

/* Sections and checkbox option cards (shared: route and server editors) */
.editor-section + .editor-section {
    margin-top: 1.75rem;
}

.editor-section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

/* Bulma sizes buttons in em (2.5em), so the smaller font would shrink the addon
   below the 1rem input beside it; pin the height to the input's. */
.rt-url-base.button.is-static {
    font-family: var(--aw-mono);
    font-size: 0.8rem;
    height: 2.5rem;
}

.editor-none {
    color: var(--aw-muted);
    font-size: 0.875rem;
}

.editor-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.editor-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--aw-border-strong);
    border-radius: var(--bulma-radius-large);
    background-color: var(--aw-surface);
    cursor: pointer;
    transition:
        border-color 0.15s,
        background-color 0.15s;
}

.editor-option:hover {
    border-color: rgba(46, 230, 255, 0.4);
}

.editor-option:has(input:checked) {
    border-color: rgba(46, 230, 255, 0.55);
    background-color: rgba(46, 230, 255, 0.05);
}

.editor-option:has(input:focus-visible) {
    outline: 2px solid var(--aw-cyan);
    outline-offset: 2px;
}

.editor-option[hidden] {
    display: none;
}

.editor-option input {
    flex: 0 0 auto;
}

.editor-option-icons {
    display: inline-flex;
    flex: 0 0 auto;
}

.editor-option-icons:empty {
    display: none;
}

.editor-option-icons img {
    width: 1.5rem;
    height: 1.5rem;
    padding: 2px;
    border: 1px solid var(--aw-border-strong);
    border-radius: 6px;
    background-color: var(--aw-bg);
    object-fit: contain;
}

.editor-option-icons img + img {
    margin-left: -0.4rem;
}

.editor-option-body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
}

.editor-option-title {
    overflow: hidden;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.editor-option-sub {
    overflow: hidden;
    color: var(--aw-muted);
    font-size: 0.8rem;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.editor-option-sub code {
    padding: 0;
    background: none;
    color: inherit;
    font-size: 0.75rem;
}

.editor-option-link {
    flex: 0 0 auto;
    color: var(--aw-muted);
    font-size: 0.8rem;
}

.editor-option-link:hover {
    color: var(--aw-cyan);
}

/* Preview panel */
.rt-unsaved-note {
    display: none;
    margin-bottom: 0.75rem;
    color: var(--aw-copper);
    font-size: 0.75rem;
}

.rt-editor[data-dirty="true"] .rt-unsaved-note {
    display: block;
}

.rt-preview-summary {
    margin-bottom: 1rem;
    padding: 0.6rem 0.8rem;
    border-radius: var(--bulma-radius);
    background-color: rgba(255, 255, 255, 0.03);
    font-size: 0.875rem;
}

.rt-node {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-height: 2.75rem;
    padding: 0.45rem 0.75rem;
    border: 1px solid var(--aw-border-strong);
    border-radius: var(--bulma-radius);
    background-color: var(--aw-bg-2);
}

.rt-node-root {
    border-style: dashed;
    background-color: transparent;
}

.rt-node-sm {
    min-height: 2.25rem;
    padding: 0.3rem 0.65rem;
}

.rt-node-badge,
.rt-node-icon {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 7px;
    background-color: rgba(255, 255, 255, 0.06);
    color: var(--aw-muted);
}

.rt-node-badge svg {
    width: 0.95rem;
    height: 0.95rem;
}

.rt-node-badge.is-server {
    background-color: rgba(46, 230, 255, 0.12);
    color: var(--aw-cyan);
}

.rt-node-badge.is-virtual {
    background-color: rgba(139, 140, 255, 0.14);
    color: var(--aw-violet);
}

.rt-node-badge.is-workflow {
    background-color: rgba(240, 163, 94, 0.14);
    color: var(--aw-copper);
}

.rt-node-icon {
    width: 1.35rem;
    height: 1.35rem;
    background: none;
}

.rt-node-icon img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 4px;
}

.rt-node-body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
    line-height: 1.3;
}

.rt-node-title {
    overflow: hidden;
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.rt-node-sm .rt-node-title {
    font-weight: 500;
    font-size: 0.825rem;
}

.rt-node-sub {
    color: var(--aw-muted);
    font-size: 0.75rem;
}

.rt-node-sub code {
    padding: 0;
    background: none;
    color: inherit;
    font-size: 0.75rem;
    overflow-wrap: anywhere;
}

/* Tree connectors: a vertical rail per branch, an elbow into each node */
.rt-branch {
    --rt-mid: 1.375rem;
    margin: 0 0 0 0.8rem;
    padding: 0 0 0 1.1rem;
    list-style: none;
}

.rt-branch .rt-branch {
    --rt-mid: 1.125rem;
}

.rt-branch > li {
    position: relative;
    padding-top: 0.55rem;
}

.rt-branch > li::before,
.rt-branch > li::after {
    content: "";
    position: absolute;
    left: -1.1rem;
    background-color: var(--aw-border-strong);
}

.rt-branch > li::before {
    top: calc(0.55rem + var(--rt-mid));
    width: 1.1rem;
    height: 2px;
}

.rt-branch > li::after {
    top: 0;
    bottom: 0;
    width: 2px;
}

.rt-branch > li:last-child::after {
    bottom: auto;
    height: calc(0.55rem + var(--rt-mid) + 2px);
}

.rt-branch > li.is-denied > .rt-node {
    opacity: 0.45;
    border-style: dashed;
}

.rt-branch > li.is-denied > .rt-branch {
    opacity: 0.45;
}

/* Debugger tab (ts/mcp-debugger/debugger.ts): head, notes, status,
   then tools | traffic log, each scrolling on its own. */
.rt-dbg-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem 1.5rem;
    margin-bottom: 1rem;
}

.rt-dbg-head > div:first-child {
    flex: 1 1 24rem;
    min-width: 0;
}

.rt-dbg-head .help {
    max-width: 52rem;
}

.rt-dbg-actions {
    flex: 0 1 auto;
    margin-bottom: 0 !important;
}

.rt-dbg-unsaved {
    display: none;
}

.rt-editor[data-dirty="true"] .rt-dbg-unsaved {
    display: block;
}

.rt-debugger .notification {
    margin-bottom: 0.75rem !important;
    padding: 0.6rem 0.9rem;
}

.rt-dbg-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
}

.rt-dbg-status::before {
    content: "";
    flex: none;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background-color: var(--aw-dim);
}

.rt-debugger[data-phase="busy"] .rt-dbg-status::before {
    background-color: var(--aw-cyan);
    animation: rt-dbg-pulse 1s ease-in-out infinite alternate;
}

.rt-debugger[data-phase="connected"] .rt-dbg-status::before {
    background-color: var(--aw-green);
}

.rt-debugger[data-phase="expired"] .rt-dbg-status::before {
    background-color: var(--aw-copper);
}

.rt-debugger[data-phase="error"] .rt-dbg-status {
    color: var(--aw-red);
}

.rt-debugger[data-phase="error"] .rt-dbg-status::before {
    background-color: var(--aw-red);
}

@keyframes rt-dbg-pulse {
    from {
        opacity: 0.35;
    }

    to {
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .rt-debugger[data-phase="busy"] .rt-dbg-status::before {
        animation: none;
    }
}

.rt-dbg-session {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: 0.2rem 1rem;
    margin-bottom: 1rem;
    padding: 0.6rem 0.8rem;
    border-radius: var(--bulma-radius);
    background-color: rgba(255, 255, 255, 0.03);
    font-size: 0.8rem;
}

.rt-dbg-session dt {
    color: var(--aw-muted);
}

.rt-dbg-session dd {
    margin: 0;
    font-family: var(--aw-mono);
    overflow-wrap: anywhere;
}

.rt-dbg-body {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
    gap: 1.5rem;
}

.rt-dbg-body > .editor-panel {
    grid-area: auto;
    align-self: stretch;
    min-height: 0;
    max-height: none;
}

.rt-dbg-filter.input {
    max-width: 14rem;
}

.rt-dbg-tool-list,
.rt-dbg-log-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.rt-dbg-tool + .rt-dbg-tool {
    margin-top: 0.5rem;
}

.rt-dbg-tool[hidden] {
    display: none;
}

.rt-dbg-tool > details {
    border: 1px solid var(--aw-border);
    border-radius: var(--bulma-radius);
}

.rt-dbg-tool > details[open] {
    border-color: var(--aw-border-strong);
}

.rt-dbg-tool.is-rejected > details {
    border-style: dashed;
}

.rt-dbg-tool summary {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.6rem 0.8rem;
    cursor: pointer;
    list-style: none;
}

.rt-dbg-tool summary::-webkit-details-marker {
    display: none;
}

.rt-dbg-tool-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
}

.rt-dbg-tool-name {
    padding: 0;
    background: none;
    color: var(--aw-cyan);
    font-size: 0.85rem;
    overflow-wrap: anywhere;
}

.rt-dbg-tool-title {
    color: var(--aw-text);
    font-size: 0.85rem;
    font-weight: 600;
}

.rt-dbg-tool-desc {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--aw-muted);
    font-size: 0.8rem;
}

.rt-dbg-tool details[open] .rt-dbg-tool-desc {
    display: none;
}

.rt-dbg-tool-body {
    padding: 0 0.8rem 0.8rem;
}

.rt-dbg-pre {
    margin-bottom: 0.75rem;
    font-size: 0.8rem;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.rt-dbg-code {
    margin-bottom: 0.5rem;
    padding: 0.6rem 0.75rem;
    max-height: 24rem;
    overflow: auto;
    border-radius: var(--bulma-radius);
    background-color: var(--aw-code-bg);
    font-size: 0.75rem;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* Tool card: call panel (ts/mcp-debugger/tool-card.ts) and schemas */
.rt-dbg-call {
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    border-radius: var(--bulma-radius);
    background-color: rgba(255, 255, 255, 0.03);
}

.rt-dbg-args.textarea {
    /* Bulma's textarea is content-box with min-width: 100%, so its padding
       would overflow the panel. */
    box-sizing: border-box;
    min-height: 4.5rem;
    font-family: var(--aw-mono);
    font-size: 0.75rem;
}

.rt-dbg-call-status {
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
}

.rt-dbg-call-status:empty {
    display: none;
}

.rt-dbg-call-status[data-state="busy"],
.rt-dbg-call-status[data-state="input"] {
    color: var(--aw-cyan);
}

.rt-dbg-call-status[data-state="ok"] {
    color: var(--aw-green);
}

.rt-dbg-call-status[data-state="error"] {
    color: var(--aw-red);
}

.rt-dbg-call-output .editor-kicker {
    margin-top: 0.5rem;
}

.rt-dbg-image {
    display: block;
    max-width: 100%;
    margin-bottom: 0.5rem;
    border-radius: var(--bulma-radius);
}

.rt-dbg-raw > summary,
.rt-dbg-schema > summary {
    cursor: pointer;
    color: var(--aw-muted);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.rt-dbg-schema + .rt-dbg-schema {
    margin-top: 0.4rem;
}

.rt-dbg-schema[open] > summary,
.rt-dbg-raw[open] > summary {
    margin-bottom: 0.4rem;
}

/* Input requests (ts/mcp-debugger/elicitation.ts) */
.rt-dbg-input {
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    border: 1px solid rgba(46, 230, 255, 0.35);
    border-radius: var(--bulma-radius);
    background-color: rgba(46, 230, 255, 0.04);
}

.rt-dbg-input-card + .rt-dbg-input-card {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--aw-border);
}

.rt-dbg-elicit .field {
    margin-bottom: 0.6rem;
}

.rt-dbg-url {
    padding: 0.5rem 0.6rem;
    border-radius: var(--bulma-radius);
    background-color: var(--aw-code-bg);
    color: var(--aw-muted);
    font-family: var(--aw-mono);
    font-size: 0.75rem;
    overflow-wrap: anywhere;
}

.rt-dbg-url strong {
    color: var(--aw-text);
}

.rt-dbg-entry,
.rt-dbg-note {
    border-bottom: 1px solid var(--aw-border);
    font-size: 0.8rem;
}

.rt-dbg-entry summary,
.rt-dbg-note {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    padding: 0.4rem 0.25rem;
}

.rt-dbg-entry summary {
    cursor: pointer;
}

.rt-dbg-time {
    flex: none;
    color: var(--aw-dim);
    font-family: var(--aw-mono);
    font-size: 0.7rem;
}

.rt-dbg-method {
    flex: none;
    min-width: 3.25rem;
    font-family: var(--aw-mono);
    font-weight: 600;
}

.rt-dbg-label {
    flex: none;
    font-weight: 600;
}

.rt-dbg-path {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    color: var(--aw-muted);
    font-family: var(--aw-mono);
    font-size: 0.75rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rt-dbg-code-tag {
    flex: none;
    font-family: var(--aw-mono);
    font-weight: 600;
}

.rt-dbg-ms {
    flex: none;
    min-width: 3.5rem;
    color: var(--aw-dim);
    font-size: 0.7rem;
    text-align: right;
}

.rt-dbg-entry[data-state="pending"] .rt-dbg-code-tag {
    color: var(--aw-cyan);
}

.rt-dbg-entry[data-state="ok"] .rt-dbg-code-tag {
    color: var(--aw-green);
}

.rt-dbg-entry[data-state="warn"] .rt-dbg-code-tag {
    color: var(--aw-copper);
}

.rt-dbg-entry[data-state="error"] .rt-dbg-code-tag {
    color: var(--aw-red);
}

.rt-dbg-entry-body {
    padding: 0.25rem 0.25rem 0.75rem;
}

.rt-dbg-events {
    margin: 0;
    list-style: none;
}

.rt-dbg-note {
    color: var(--aw-muted);
}

.rt-dbg-note[data-level="warn"] {
    color: var(--aw-copper);
}

.rt-dbg-note[data-level="error"] {
    color: var(--aw-red);
}

.rt-dbg-note > span:last-child {
    min-width: 0;
    overflow-wrap: anywhere;
}

@media (max-width: 1199px) {
    .rt-editor {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: none;
        grid-auto-rows: max-content;
        grid-template-areas:
            "header"
            "alerts"
            "tabs"
            "list"
            "pane";
        align-content: start;
        overflow-y: auto;
    }

    .rt-config,
    .rt-preview,
    .rt-dbg-tools,
    .rt-dbg-log {
        max-height: none;
        overflow: visible;
    }

    .rt-debugger {
        grid-row: auto;
        grid-column: 1;
        padding-bottom: 1.5rem;
    }

    .rt-dbg-body {
        grid-template-columns: minmax(0, 1fr);
    }

    .rt-preview {
        margin-bottom: 1.5rem;
    }

    .editor-header {
        flex-wrap: wrap;
    }
}

/* ---- Server editor (Views/Servers/Edit.cshtml) ----
   Grid: header / alerts / tabs / body. The Tools tab body is its own grid:
   tool list (list) | tool details (pane). */
.sv-editor {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    /* max-content: see .flow-editor */
    grid-template-rows: max-content max-content max-content minmax(0, 1fr);
    grid-template-areas:
        "header"
        "alerts"
        "tabs"
        "body";
}

.sv-tabs {
    grid-area: tabs;
    margin-bottom: 1.25rem !important;
}

.sv-tools,
.sv-details,
.sv-access {
    display: none;
    grid-area: body;
    min-height: 0;
}

.sv-editor[data-tab="tools"] .sv-tools {
    display: grid;
}

.sv-editor[data-tab="details"] .sv-details,
.sv-editor[data-tab="access"] .sv-access {
    display: block;
}

.sv-details,
.sv-access {
    max-width: 56rem;
    overflow-y: auto;
    padding: 0.25rem 0.25rem 2rem;
}

.sv-tools {
    grid-template-columns: minmax(22rem, 1.1fr) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    grid-template-areas: "list pane";
    column-gap: 1.5rem;
}

.sv-tools-col {
    grid-area: list;
    min-height: 0;
    overflow-y: auto;
    padding: 0 0.5rem 2rem 0.25rem;
}

/* Filters stay in view while the (often long) list scrolls */
.sv-filters {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0 0.5rem;
    background-color: var(--aw-bg);
}

.sv-filter-search {
    flex: 1 1 12rem;
}

.editor-segmented {
    display: inline-flex;
    overflow: hidden;
    border: 1px solid var(--aw-border-strong);
    border-radius: 8px;
}

.editor-segmented label {
    position: relative;
    padding: 0.3rem 0.7rem;
    color: var(--aw-muted);
    font-size: 0.8rem;
    cursor: pointer;
}

.editor-segmented label + label {
    border-left: 1px solid var(--aw-border-strong);
}

.editor-segmented input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.editor-segmented label:has(input:checked) {
    background-color: rgba(46, 230, 255, 0.12);
    color: var(--aw-cyan);
}

.editor-segmented label:has(input:focus-visible) {
    outline: 2px solid var(--aw-cyan);
    outline-offset: -2px;
}

.editor-empty {
    padding: 2rem 1rem;
    border: 1px dashed var(--aw-border-strong);
    border-radius: var(--bulma-radius-large);
    color: var(--aw-muted);
    text-align: center;
}

.sv-group + .sv-group {
    margin-top: 1.25rem;
}

.sv-group-head {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--aw-border-strong);
    border-radius: var(--bulma-radius-large) var(--bulma-radius-large) 0 0;
    background-color: var(--aw-surface-2);
}

.sv-group-head .editor-option-sub {
    white-space: normal;
}

.sv-group-actions {
    flex: 0 0 auto;
}

.sv-group-note {
    padding: 0.75rem;
    border: 1px solid var(--aw-border-strong);
    border-top: 0;
    border-radius: 0 0 var(--bulma-radius-large) var(--bulma-radius-large);
    color: var(--aw-muted);
    font-size: 0.8rem;
}

.sv-tool-list {
    margin: 0;
    padding: 0;
    border: 1px solid var(--aw-border-strong);
    border-top: 0;
    border-radius: 0 0 var(--bulma-radius-large) var(--bulma-radius-large);
    list-style: none;
}

.sv-tool {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    padding: 0.5rem 0.75rem;
    border-top: 1px solid var(--aw-border);
}

.sv-tool:first-child {
    border-top: 0;
}

.sv-tool:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

.sv-tool.is-selected {
    background-color: rgba(46, 230, 255, 0.07);
    box-shadow: inset 2px 0 0 var(--aw-cyan);
}

.sv-tool-toggle {
    flex: 0 0 auto;
    margin-top: 0.3rem;
}

.sv-tool-main {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.sv-tool-main:focus-visible {
    outline: 2px solid var(--aw-cyan);
    outline-offset: 2px;
    border-radius: 4px;
}

.sv-tool-title {
    overflow: hidden;
    font-weight: 600;
    font-size: 0.875rem;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.sv-tool:not(.is-enabled) .sv-tool-title {
    color: var(--aw-muted);
}

.sv-tool-name {
    padding: 0;
    background: none;
    color: var(--aw-dim);
    font-size: 0.72rem;
}

.sv-tool-desc {
    overflow: hidden;
    color: var(--aw-dim);
    font-size: 0.78rem;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* Tool details panel */
.sv-detail-pane {
    grid-area: pane;
}

.sv-detail-empty {
    padding: 1.5rem 1rem;
    color: var(--aw-muted);
    font-size: 0.875rem;
    text-align: center;
}

.sv-detail-title {
    min-width: 0;
    overflow-wrap: anywhere;
}

.sv-detail-toggle {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 0.5rem;
}

.sv-detail-desc {
    color: var(--aw-text);
    font-size: 0.875rem;
}

.sv-schema-table {
    width: 100%;
    font-size: 0.8rem;
}

.sv-schema-table td {
    padding: 0.45rem 0.5rem 0.45rem 0;
    border-top: 1px solid var(--aw-border);
    vertical-align: top;
}

.sv-schema-name {
    width: 40%;
    overflow-wrap: anywhere;
}

.sv-schema-name code {
    padding: 0;
    background: none;
    font-size: 0.78rem;
}

.sv-schema-type {
    display: block;
    color: var(--aw-dim);
    font-size: 0.72rem;
}

.sv-schema-desc {
    display: -webkit-box;
    overflow: hidden;
    color: var(--aw-muted);
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
}

.sv-json {
    margin-top: 0.6rem;
    font-size: 0.8rem;
}

.sv-json summary {
    color: var(--aw-muted);
    cursor: pointer;
}

.sv-json pre {
    max-height: 24rem;
    margin-top: 0.5rem;
    overflow: auto;
    font-size: 0.75rem;
}

@media (max-width: 1199px) {
    .sv-editor {
        grid-template-rows: none;
        grid-auto-rows: max-content;
        align-content: start;
        overflow-y: auto;
    }

    /* Details above the list: a server can have hundreds of tools */
    .sv-tools {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: none;
        grid-template-areas:
            "pane"
            "list";
        row-gap: 1.5rem;
    }

    .sv-tools-col,
    .sv-detail-pane,
    .sv-details,
    .sv-access {
        max-height: none;
        overflow: visible;
    }

    .sv-detail-pane {
        scroll-margin-top: 1rem;
    }

    .sv-filters {
        position: static;
    }
}

/* ---- Identity provider editor (Views/IdentityProviders/Edit.cshtml) ----
   Grid: header / alerts / tabs, then the form (list) | setup panel (pane)
   on the Sign-in and Directory tabs, or the usage list across both. */
.ip-editor {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(18rem, 1fr);
    /* max-content: see .flow-editor */
    grid-template-rows: max-content max-content max-content minmax(0, 1fr);
    grid-template-areas:
        "header header"
        "alerts alerts"
        "tabs tabs"
        "list pane";
    column-gap: 1.5rem;
}

.ip-tabs {
    grid-area: tabs;
    margin-bottom: 1.25rem !important;
}

.ip-main {
    grid-area: list;
    min-height: 0;
    max-width: 52rem;
    overflow-y: auto;
    padding: 0.25rem 0.5rem 2rem 0.25rem;
}

.ip-signin,
.ip-directory,
.ip-usage,
.ip-test-dirty-note {
    display: none;
}

.ip-editor[data-tab="signin"] .ip-signin,
.ip-editor[data-tab="directory"] .ip-directory,
.ip-editor[data-tab="usage"] .ip-usage {
    display: block;
}

.ip-editor[data-tab="usage"] .ip-main,
.ip-editor[data-tab="usage"] .ip-setup {
    display: none;
}

.ip-editor[data-dirty="true"] .ip-test-dirty-note {
    display: inline;
    margin-left: 0.5rem;
    color: var(--aw-copper);
    font-size: 0.75rem;
}

.ip-usage {
    grid-row: 4;
    grid-column: 1 / -1;
    max-width: 52rem;
    overflow-y: auto;
    padding: 0.25rem 0.25rem 2rem;
}

a.editor-option {
    color: inherit;
}

/* Stored secrets: "Set" with a Replace disclosure */
.editor-secret > summary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 2.5em;
    list-style: none;
    cursor: pointer;
}

.editor-secret > summary::-webkit-details-marker {
    display: none;
}

.editor-secret-replace {
    color: var(--aw-cyan);
    font-size: 0.875rem;
}

.editor-secret[open] .editor-secret-replace {
    display: none;
}

.editor-switch.checkbox {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    line-height: 1.35;
}

.editor-switch input {
    margin-top: 0.25rem;
}

/* Setup panel */
.editor-check-heading {
    margin: 1rem 0 0.4rem;
    color: var(--aw-muted);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.editor-checklist {
    margin: 0;
    padding: 0;
    list-style: none;
}

.editor-check {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.4rem 0;
    border-top: 1px solid var(--aw-border);
}

.editor-check:first-child {
    border-top: 0;
}

.editor-check-icon {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    margin-top: 0.1rem;
    border-radius: 999px;
    background-color: rgba(255, 255, 255, 0.06);
    color: var(--aw-muted);
    font-size: 0.7rem;
    font-weight: 700;
}

.editor-check-icon svg {
    width: 0.75rem;
    height: 0.75rem;
}

.editor-check.is-ok .editor-check-icon {
    background-color: rgba(74, 222, 128, 0.14);
    color: var(--aw-green);
}

.editor-check.is-warning .editor-check-icon {
    background-color: rgba(240, 163, 94, 0.16);
    color: var(--aw-copper);
}

.editor-check.is-missing .editor-check-icon {
    background-color: rgba(251, 113, 133, 0.16);
    color: var(--aw-red);
}

.editor-check-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.3;
}

.editor-check-label {
    font-size: 0.85rem;
    font-weight: 600;
}

.editor-check-detail {
    color: var(--aw-muted);
    font-size: 0.78rem;
    overflow-wrap: anywhere;
}

.editor-check.is-missing .editor-check-detail {
    color: var(--aw-red);
}

@media (max-width: 1199px) {
    .ip-editor {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: none;
        grid-auto-rows: max-content;
        grid-template-areas:
            "header"
            "alerts"
            "tabs"
            "list"
            "pane";
        align-content: start;
        overflow-y: auto;
    }

    .ip-main,
    .ip-setup,
    .ip-usage {
        max-height: none;
        overflow: visible;
    }

    .ip-setup {
        margin-bottom: 1.5rem;
    }

    .ip-usage {
        grid-row: auto;
        grid-column: 1;
    }
}

/* ---- Connection editor (Views/Connections/Edit.cshtml) ----
   Grid: header / alerts / tabs, then the form (list) | connector panel (pane)
   on the Credentials tab; Used by and Authorizations span both columns. */
.cn-editor {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(18rem, 1fr);
    /* max-content: see .flow-editor */
    grid-template-rows: max-content max-content max-content minmax(0, 1fr);
    grid-template-areas:
        "header header"
        "alerts alerts"
        "tabs tabs"
        "list pane";
    column-gap: 1.5rem;
}

.cn-tabs {
    grid-area: tabs;
    margin-bottom: 1.25rem !important;
}

.cn-heading-icon img {
    width: 1.75rem;
    height: 1.75rem;
}

.cn-main {
    grid-area: list;
    min-height: 0;
    max-width: 52rem;
    overflow-y: auto;
    padding: 0.25rem 0.5rem 2rem 0.25rem;
}

.cn-usage,
.cn-auths {
    display: none;
    grid-row: 4;
    grid-column: 1 / -1;
    max-width: 60rem;
    overflow-y: auto;
    padding: 0.25rem 0.25rem 2rem;
}

.cn-editor[data-tab="usage"] .cn-usage,
.cn-editor[data-tab="authorizations"] .cn-auths {
    display: block;
}

.cn-editor:not([data-tab="credentials"]) .cn-main,
.cn-editor:not([data-tab="credentials"]) .cn-panel {
    display: none;
}

.cn-scheme-name {
    padding: 0;
    background: none;
    font-size: 0.75rem;
}

.cn-facts {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: 0.35rem 0.75rem;
    margin: 0;
    font-size: 0.8rem;
}

.cn-facts dt {
    color: var(--aw-muted);
}

.cn-facts dd {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
}

.cn-facts code {
    padding: 0;
    background: none;
    font-size: 0.75rem;
}

/* Scope tags can be long URLs (Google's): wrap them inside the panel. */
.cn-facts .tag,
.cn-scopes .tag {
    max-width: 100%;
    height: auto;
    white-space: normal;
    overflow-wrap: anywhere;
}

.cn-auth-issuer {
    display: block;
    color: var(--aw-dim);
    font-size: 0.75rem;
}

.cn-auth-scopes {
    max-width: 16rem;
    overflow: hidden;
    color: var(--aw-muted);
    font-size: 0.8rem;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.cn-auth-table td {
    vertical-align: middle;
}

@media (max-width: 1199px) {
    .cn-editor {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: none;
        grid-auto-rows: max-content;
        grid-template-areas:
            "header"
            "alerts"
            "tabs"
            "list"
            "pane";
        align-content: start;
        overflow-y: auto;
    }

    .cn-main,
    .cn-panel,
    .cn-usage,
    .cn-auths {
        max-height: none;
        overflow: visible;
    }

    .cn-panel {
        margin-bottom: 1.5rem;
    }

    .cn-usage,
    .cn-auths {
        grid-row: auto;
        grid-column: 1;
    }
}

/* API key "Kept in" switch (Views/Connections/_ApiKeySource.cshtml): shows the
   appwire key field or the secret store reference, following the radio. */
.cn-key-source {
    margin-bottom: 0.75rem;
}

.cn-key-store {
    display: none;
}

.cn-key-source:has(input[name="ApiKeySource"][value="store"]:checked) .cn-key-store {
    display: block;
}

.cn-key-source:has(input[name="ApiKeySource"][value="store"]:checked) .cn-key-local {
    display: none;
}

/* OAuth "Scopes" switch (Views/Connections/Edit.cshtml): shows the automatic
   scopes or the custom checkboxes, following the radio. */
.cn-scopes-custom {
    display: none;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.cn-scopes:has(input[name="ScopeMode"][value="custom"]:checked) .cn-scopes-custom {
    display: block;
}

.cn-scopes:has(input[name="ScopeMode"][value="custom"]:checked) .cn-scopes-automatic {
    display: none;
}

.cn-scope-list {
    max-height: 16rem;
    overflow-y: auto;
    border: 1px solid var(--aw-border);
    border-radius: 6px;
}

.cn-scope {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
}

.cn-scope + .cn-scope {
    border-top: 1px solid var(--aw-border);
}

.cn-scope code {
    padding: 0;
    background: none;
    font-size: 0.75rem;
    overflow-wrap: anywhere;
}

.cn-scope-description {
    display: block;
    color: var(--aw-muted);
}

/* SCIM "Authentication" switch (Views/IdentityProviders/Edit.cshtml): shows the
   bearer token field or the client credentials fields, following the radio. */
.ip-scim-client {
    display: none;
}

.ip-scim-auth:has(input[name="ScimAuthMode"][value="client_credentials"]:checked) .ip-scim-client {
    display: block;
}

.ip-scim-auth:has(input[name="ScimAuthMode"][value="client_credentials"]:checked) .ip-scim-bearer {
    display: none;
}

/* ---- Secret store editor (Views/SecretStores/Edit.cshtml) ----
   Grid: header / alerts / tabs, then the form (list) | setup panel (pane)
   on the Settings tab; Used by spans both columns. */
.ss-editor {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(18rem, 1fr);
    /* max-content: see .flow-editor */
    grid-template-rows: max-content max-content max-content minmax(0, 1fr);
    grid-template-areas:
        "header header"
        "alerts alerts"
        "tabs tabs"
        "list pane";
    column-gap: 1.5rem;
}

.ss-tabs {
    grid-area: tabs;
    margin-bottom: 1.25rem !important;
}

.ss-main {
    grid-area: list;
    min-height: 0;
    max-width: 52rem;
    overflow-y: auto;
    padding: 0.25rem 0.5rem 2rem 0.25rem;
}

.ss-usage,
.ss-test-dirty-note {
    display: none;
}

.ss-usage {
    grid-row: 4;
    grid-column: 1 / -1;
    max-width: 52rem;
    overflow-y: auto;
    padding: 0.25rem 0.25rem 2rem;
}

.ss-editor[data-tab="usage"] .ss-usage {
    display: block;
}

.ss-editor[data-tab="usage"] .ss-main,
.ss-editor[data-tab="usage"] .ss-setup {
    display: none;
}

.ss-editor[data-dirty="true"] .ss-test-dirty-note {
    display: inline;
    margin-left: 0.5rem;
    color: var(--aw-copper);
    font-size: 0.75rem;
}

.ss-snippet {
    padding: 0.75rem;
    border: 1px solid var(--aw-border-strong);
    border-radius: 8px;
    font-size: 0.75rem;
    white-space: pre;
    overflow-x: auto;
}

@media (max-width: 1199px) {
    .ss-editor {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: none;
        grid-auto-rows: max-content;
        grid-template-areas:
            "header"
            "alerts"
            "tabs"
            "list"
            "pane";
        align-content: start;
        overflow-y: auto;
    }

    .ss-main,
    .ss-setup,
    .ss-usage {
        max-height: none;
        overflow: visible;
    }

    .ss-setup {
        margin-bottom: 1.5rem;
    }

    .ss-usage {
        grid-row: auto;
        grid-column: 1;
    }
}

/* ---- Usage dashboard (Views/ToolUsage/Index.cshtml, ts/tool-usage.ts) ----
   Header, KPI strip, calls-per-day chart, tools table | connectors, live feed. */
.usage {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    padding-bottom: 1.5rem;
}

.usage .card,
.usage .box {
    margin-bottom: 0;
}

.usage-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
}

.usage-header .buttons {
    margin-bottom: 0;
}

.usage-empty {
    padding: 2rem 1.5rem;
    text-align: center;
}

.usage-kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
}

.usage-kpi {
    padding: 1rem 1.25rem;
    border: 1px solid var(--aw-border);
    border-radius: var(--bulma-radius-large);
    background-color: var(--aw-bg-2);
}

.usage-kpi-label {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--aw-dim);
}

.usage-kpi-value {
    margin: 0.25rem 0 0.125rem;
    font-size: 1.75rem;
    font-weight: 600;
    line-height: 1.2;
    color: var(--aw-text);
    font-variant-numeric: tabular-nums;
}

.usage-kpi.is-danger .usage-kpi-value {
    color: var(--aw-red);
}

.usage-kpi-unit {
    margin-left: 0.25rem;
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--aw-muted);
}

.usage-kpi-sub {
    font-size: 0.8125rem;
    color: var(--aw-muted);
}

.usage-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--aw-border);
}

.usage-card-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--aw-text);
}

.usage-card-meta {
    font-size: 0.8125rem;
    color: var(--aw-dim);
    font-variant-numeric: tabular-nums;
}

.usage-legend {
    display: flex;
    gap: 1rem;
    font-size: 0.8125rem;
    color: var(--aw-muted);
}

.usage-legend li {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.usage-swatch {
    width: 0.625rem;
    height: 0.625rem;
    border-radius: 2px;
}

.usage-swatch.is-success {
    background-color: var(--aw-cyan);
}

.usage-swatch.is-error {
    background-color: var(--aw-red);
}

.usage-chart {
    position: relative;
    height: 240px;
    padding: 1rem 1.25rem 0.75rem;
}

.usage-split {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    align-items: start;
    gap: 1.25rem;
}

.usage-table-scroll {
    max-height: 26rem;
    overflow: auto;
}

.usage-table.table {
    margin-bottom: 0;
    background-color: transparent;
}

.usage-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background-color: var(--aw-bg-2);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}

.usage-table th:first-child,
.usage-table td:first-child {
    padding-left: 1.25rem;
}

.usage-table th:last-child,
.usage-table td:last-child {
    padding-right: 1.25rem;
}

.usage-table td {
    vertical-align: middle;
}

.usage-table th button {
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    color: inherit;
    cursor: pointer;
}

.usage-table th button:hover {
    color: var(--aw-text);
}

.usage-table th button::after {
    display: inline-block;
    width: 1em;
    margin-left: 0.125rem;
    content: "";
}

.usage-table th[aria-sort="none"] button:hover::after {
    content: "↕";
    opacity: 0.5;
}

.usage-table th[aria-sort="ascending"] button::after {
    content: "↑";
}

.usage-table th[aria-sort="descending"] button::after {
    content: "↓";
}

.usage-table th[aria-sort="ascending"],
.usage-table th[aria-sort="descending"] {
    color: var(--aw-text);
}

.usage-num {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.usage-tool-name {
    font-family: var(--aw-mono);
    font-size: 0.8125rem;
    color: var(--aw-text);
    overflow-wrap: anywhere;
}

.usage-tool-connector {
    display: block;
    font-size: 0.75rem;
    color: var(--aw-dim);
}

.usage-meter {
    display: block;
    height: 3px;
    border-radius: 2px;
    background-color: rgba(255, 255, 255, 0.06);
    overflow: hidden;
}

.usage-meter > span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background-color: var(--aw-cyan);
}

.usage-table .usage-meter {
    width: 4rem;
    margin: 0.25rem 0 0 auto;
}

.usage-connectors {
    max-height: 26rem;
    overflow-y: auto;
}

.usage-connectors li {
    display: grid;
    grid-template-columns: 1.5rem minmax(0, 1fr) auto;
    grid-template-areas:
        "icon name count"
        ". meter meter"
        ". errors errors";
    align-items: center;
    column-gap: 0.75rem;
    row-gap: 0.375rem;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--aw-border);
}

.usage-connectors li:last-child {
    border-bottom: 0;
}

.usage-connector-icon {
    grid-area: icon;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 0.25rem;
    background-color: var(--aw-surface-2);
    overflow: hidden;
}

.usage-connector-icon img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.usage-connector-name {
    grid-area: name;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: var(--aw-text);
}

.usage-connectors .usage-num {
    grid-area: count;
    color: var(--aw-muted);
}

.usage-connectors .usage-meter {
    grid-area: meter;
}

.usage-connector-errors {
    grid-area: errors;
    font-size: 0.75rem;
    color: var(--aw-red);
}

.usage-status {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
    white-space: nowrap;
}

.usage-status::before {
    width: 0.375rem;
    height: 0.375rem;
    border-radius: 50%;
    content: "";
}

.usage-status.is-success {
    color: var(--aw-muted);
}

.usage-status.is-success::before {
    background-color: var(--aw-green);
}

.usage-status.is-error {
    color: var(--aw-red);
}

.usage-status.is-error::before {
    background-color: var(--aw-red);
}

.usage-live-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background-color: var(--aw-dim);
}

[data-usage-live][data-state="open"] .usage-live-dot {
    background-color: var(--aw-green);
    animation: usage-pulse 2s ease-out infinite;
}

[data-usage-live][data-state="error"] .usage-live-dot {
    background-color: var(--aw-copper);
}

@keyframes usage-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.5);
    }

    70%,
    100% {
        box-shadow: 0 0 0 0.375rem rgba(74, 222, 128, 0);
    }
}

[data-usage-live] tbody tr:not(.usage-live-empty) {
    animation: usage-row-in 1.5s var(--aw-ease);
}

@keyframes usage-row-in {
    from {
        background-color: rgba(46, 230, 255, 0.12);
    }
}

.usage-table td.usage-live-time {
    color: var(--aw-dim);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.usage-table .usage-live-empty td {
    padding: 2rem 1.25rem;
    text-align: center;
    color: var(--aw-dim);
}

.usage-live-empty:not(:only-child) {
    display: none;
}

@media (prefers-reduced-motion: reduce) {
    [data-usage-live][data-state="open"] .usage-live-dot,
    [data-usage-live] tbody tr {
        animation: none;
    }
}

@media (max-width: 1099px) {
    .usage-split {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 768px) {
    .usage-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Token usage: OAuth expiry cell (status tag + relative time, absolute timestamp below) */
.tu-expiry {
    white-space: nowrap;
}

.tu-expiry-at {
    display: block;
    margin-top: 0.15rem;
}

/* Audit log: one row per change, with its changed fields listed */
.audit-when {
    white-space: nowrap;
}

.audit-entity,
.audit-value {
    overflow-wrap: break-word;
    word-break: break-word;
}

.audit-changes li + li {
    margin-top: 0.15rem;
}

/* Schema upload: problems found in an uploaded OpenAPI schema (bulleted, with nested details) */
.upload-issues {
    list-style: disc;
    margin-left: 1.25rem;
}

.upload-issues ul {
    list-style: circle;
    margin-left: 1.25rem;
    margin-top: 0.15rem;
    overflow-wrap: anywhere;
}

/* New connection form: warnings from importing a custom connector's schema */
.connector-warnings summary {
    cursor: pointer;
    font-weight: 600;
}

/* ---- Custom connector editor (Views/CustomConnectors/Edit.cshtml) ----
   Grid: header / alerts / tabs, then the details (list) | connector panel
   (pane) on the Details tab; Tools, Used by and History span both columns. */
.cc-editor {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(18rem, 1fr);
    /* max-content: see .flow-editor */
    grid-template-rows: max-content max-content max-content minmax(0, 1fr);
    grid-template-areas:
        "header header"
        "alerts alerts"
        "tabs tabs"
        "list pane";
    column-gap: 1.5rem;
}

.cc-tabs {
    grid-area: tabs;
    margin-bottom: 1.25rem !important;
}

.cc-main {
    grid-area: list;
    min-height: 0;
    max-width: 52rem;
    overflow-y: auto;
    padding: 0.25rem 0.5rem 2rem 0.25rem;
}

.cc-panel {
    overflow-y: auto;
}

.cc-tools,
.cc-usage,
.cc-history {
    display: none;
    grid-row: 4;
    grid-column: 1 / -1;
    min-height: 0;
    overflow-y: auto;
    padding: 0.25rem 0.25rem 2rem;
}

.cc-usage {
    max-width: 52rem;
}

.cc-editor[data-tab="tools"] .cc-tools,
.cc-editor[data-tab="usage"] .cc-usage,
.cc-editor[data-tab="history"] .cc-history {
    display: block;
}

.cc-editor:is([data-tab="tools"], [data-tab="usage"], [data-tab="history"]) :is(.cc-main, .cc-panel) {
    display: none;
}

.cc-list {
    font-size: 0.8125rem;
    overflow-wrap: anywhere;
}

.cc-list li + li {
    margin-top: 0.25rem;
}

/* Review page: change lists and the impact box */
.cc-change + .cc-change {
    margin-top: 0.75rem;
}

.cc-change summary {
    cursor: pointer;
}

.cc-impact {
    border: 1px solid var(--aw-copper);
}

@media (max-width: 1199px) {
    .cc-editor {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: none;
        grid-auto-rows: max-content;
        grid-template-areas:
            "header"
            "alerts"
            "tabs"
            "list"
            "pane";
        align-content: start;
        overflow-y: auto;
    }

    .cc-main,
    .cc-panel,
    .cc-tools,
    .cc-usage,
    .cc-history {
        max-height: none;
        overflow: visible;
    }

    .cc-panel {
        margin-bottom: 1.5rem;
    }

    .cc-tools,
    .cc-usage,
    .cc-history {
        grid-row: auto;
        grid-column: 1;
    }
}

/* ---- Workflow editor (Views/Workflows/Edit.cshtml) ----
   The flow editor's grid (.flow-editor: Flow, Details and Access tabs) with
   three more tabs across both columns: Runs, History and JSON. */
.flow-editor .wf-runs,
.flow-editor .wf-history,
.flow-editor .wf-json {
    display: none;
    grid-row: 4;
    grid-column: 1 / -1;
    min-height: 0;
    overflow-y: auto;
    padding: 0.25rem 0.25rem 2rem;
}

.flow-editor[data-tab="runs"] .wf-runs,
.flow-editor[data-tab="history"] .wf-history,
.flow-editor[data-tab="json"] .wf-json {
    display: block;
}

.wf-json {
    max-width: 72rem;
}

/* The tool switcher above the cards, when a document has several workflows */
.wf-switcher {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.wf-switcher .select {
    flex: 1 1 12rem;
}

.wf-add-tool {
    margin-top: 1.25rem;
    text-align: center;
}

.wf-card-warning {
    color: var(--aw-copper);
    font-size: 0.75rem;
}

.wf-card-warning::before {
    content: "⚠ ";
}

/* Step and Input/Output panels: the head and the actions stay put while the
   fields between them scroll. Only while shown: the pane is display: none
   otherwise (see .flow-editor[data-tab]). Below 1200px the page scrolls. */
.flow-editor[data-tab="flow"][data-pane="node"] .wf-node-pane {
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

.wf-node-pane > #flow-node-editor,
.wf-pane-form {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.wf-pane-form > .editor-pane-head {
    padding: 1.25rem 1.25rem 0;
}

.wf-pane-body {
    min-height: 0;
    overflow-y: auto;
    padding: 0 1.25rem 1.25rem;
}

.wf-pane-form > .editor-pane-foot {
    position: static;
    margin: 0;
}

/* Step panel: the chosen operation, the picker's results, collapsed sections */
.wf-picked {
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--aw-border);
    border-radius: var(--bulma-radius);
}

.wf-picked-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.wf-operation-results {
    max-height: 20rem;
    overflow-y: auto;
    margin-top: 0.5rem;
}

.wf-section {
    margin-top: 1rem;
    border-top: 1px solid var(--aw-border);
    padding-top: 0.75rem;
}

.wf-section > summary {
    cursor: pointer;
    font-weight: 600;
}

.wf-section[open] > summary {
    margin-bottom: 0.75rem;
}

.wf-unmodelled {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
}

.wf-outputs-table td {
    vertical-align: top;
}

.wf-document-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.wf-document.textarea {
    font-size: 0.8125rem;
    line-height: 1.45;
    tab-size: 2;
    white-space: pre;
    min-height: 28rem;
}

.wf-problems ul {
    list-style: none;
    margin: 0;
}

.wf-problems li + li {
    margin-top: 0.35rem;
}

.wf-pointer {
    margin-right: 0.35rem;
}

.wf-operation-list {
    list-style: none;
    margin: 0;
}

.wf-operation {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--bulma-border-weak);
}

.wf-operation-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow-wrap: anywhere;
}

.wf-operation-title {
    font-weight: 500;
    font-size: 0.875rem;
}

.wf-source pre {
    max-height: 24rem;
    overflow: auto;
}

@media (max-width: 1199px) {
    .flow-editor .wf-runs,
    .flow-editor .wf-history,
    .flow-editor .wf-json {
        grid-column: 1;
        max-height: none;
        overflow: visible;
    }
}
