/* ==========================================================================
   TEMM Nexus 0.6.0 — Product UI foundation (Phase A) + shell (Phase B)
   --------------------------------------------------------------------------
   Loaded AFTER Filament's sheet, nexus.css and cp.css (see AdminPanelProvider),
   so these declarations are the newest layer of the product language.

   What lives here:
     1. Foundation tokens (spacing 48, container widths, refined light canvas)
     2. Typography hierarchy (page title / section / card / body / secondary /
        eyebrow / technical)
     3. The product container — ~1440px centered shell with per-page opt-outs
     4. Action hierarchy helpers (one primary per view; quiet danger)
     5. Phase A components: error, empty state, disclosure, technical values
     6. Phase B shell: project tab bar, settings hub
     7. RTL behavior for everything above

   Light is the DEFAULT experience (panel `defaultThemeMode(Light)`); the
   dark scheme remains fully supported for users who choose it via the
   theme switcher — every token below has a :root.dark counterpart.

   Bump FOUNDATION_CSS_VERSION in ControlPlaneChrome when this file changes.
   ========================================================================== */

/* ── 1. Foundation tokens ───────────────────────────────────────────────── */
:root {
    /* Spacing scale: 4 / 8 / 12 / 16 / 24 / 32 / 48. */
    --nx-space-12: 48px;

    /* Container widths. */
    --nx-shell-max: 90rem;      /* ~1440px page shell */
    --nx-content-max: 60rem;    /* ~960px reading/forms column */

    /* Product typography scale. */
    --nx-text-page: 1.75rem;    /* 28px page title */
    --nx-text-section: 1.25rem; /* 20px section title */
    --nx-text-card: 0.9375rem;  /* 15px card title */
    --nx-text-body: 0.875rem;   /* 14px body */
    --nx-text-secondary: 0.8125rem; /* 13px secondary */
    --nx-text-eyebrow: 0.6875rem;   /* 11px eyebrow/label */

    /* Light-first canvas (matches nexus.css light theme; refined here). */
    --nx-canvas: #f6f6f8;
}

html.dark {
    --nx-canvas: #0b0b0e;
}

/* ── 2. Typography hierarchy ────────────────────────────────────────────── */

/* Page titles: Filament header component, tuned once for the product. */
.fi-header-heading {
    font-size: var(--nx-text-page);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
    color: var(--nx-text);
}

.fi-header-subheading {
    color: var(--nx-text-muted);
    font-size: var(--nx-text-body);
    line-height: 1.55;
}

/* Section and card titles inside product pages. */
.nx-section__title,
.fi-section-header-heading {
    font-size: var(--nx-text-section);
    font-weight: 650;
    letter-spacing: -0.01em;
    color: var(--nx-text);
}

.fi-section-header-description,
.nx-section__description {
    color: var(--nx-text-muted);
    font-size: var(--nx-text-secondary);
    line-height: 1.55;
}

/* Eyebrow / overline labels (scope chips, card eyebrows). */
.nx-eyebrow {
    font-size: var(--nx-text-eyebrow);
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--nx-text-subtle);
}

/* Long paragraph copy must never dominate a card: clamp helper. */
.nx-prose-quiet {
    color: var(--nx-text-muted);
    font-size: var(--nx-text-secondary);
    line-height: 1.55;
}

/* ── 3. The product container ───────────────────────────────────────────── */

/* Normal product screens: ~1440px centered shell. Set via the panel
   `maxContentWidth('nx-width-shell')` so the class lands on main.fi-main.
   Wide surfaces (ERD, record browsers, SQL editor, topology, diffs) opt out
   per page by overriding getMaxContentWidth() — the shell is never full-bleed
   just because one table is. */
.fi-main.nx-width-shell {
    max-width: var(--nx-shell-max);
}

/* Comfortable gutters at every breakpoint; Filament supplies the base padding. */

/* ── 4. Action hierarchy ────────────────────────────────────────────────── */

/* Buttons: consistent radius + quiet borders; Filament colors carry intent. */
.fi-btn {
    border-radius: var(--nx-radius-sm);
}

/* Danger is deliberate: outline until the user is already in a confirm flow.
   Never the visually dominant action on an empty/unavailable/error state. */
.fi-btn.fi-color-danger:not(.fi-accent-color):not([aria-current]) {
    background: transparent;
    color: var(--nx-danger);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--nx-danger) 45%, transparent);
}

.fi-btn.fi-color-danger:hover {
    background: var(--nx-danger-soft);
}

/* Link-styled tertiary actions. */
.fi-link-btn {
    border-radius: var(--nx-radius-sm);
}

/* ── 5. Phase A components ──────────────────────────────────────────────── */

/* 5a. Error pattern: what failed → what to do → Technical details ▸. */
.nx-error {
    display: flex;
    gap: var(--nx-space-3);
    align-items: flex-start;
    padding: var(--nx-space-4);
    border: 1px solid color-mix(in srgb, var(--nx-danger) 35%, transparent);
    border-radius: var(--nx-radius);
    background: var(--nx-danger-soft);
}

.nx-error__icon {
    color: var(--nx-danger);
    display: inline-flex;
    margin-top: 2px;
}

.nx-error__content {
    display: grid;
    gap: var(--nx-space-2);
    min-width: 0;
}

.nx-error__title {
    font-weight: 650;
    font-size: var(--nx-text-card);
    color: var(--nx-text);
}

.nx-error__body {
    color: var(--nx-text-muted);
    font-size: var(--nx-text-body);
    line-height: 1.55;
}

.nx-error__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--nx-space-3);
    align-items: center;
    margin-top: var(--nx-space-1);
}

/* Quiet secondary button used by foundation components. */
.nx-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--nx-space-2);
    border-radius: var(--nx-radius-sm);
    border: 1px solid var(--nx-border-strong);
    background: var(--nx-surface-raised);
    color: var(--nx-text);
    font-size: var(--nx-text-body);
    font-weight: 550;
    padding: 6px 14px;
    cursor: pointer;
    transition: background-color 120ms ease, border-color 120ms ease;
}

.nx-btn:hover {
    border-color: var(--nx-accent);
    color: var(--nx-accent);
}

.nx-btn--secondary {
    /* reserved for future variants */
}

/* 5b. Empty states: icon → title → one sentence → actions. */
.nx-emptystate {
    display: grid;
    justify-items: center;
    text-align: center;
    gap: var(--nx-space-2);
    padding: var(--nx-space-12) var(--nx-space-6);
    border: 1px dashed var(--nx-border-strong);
    border-radius: var(--nx-radius);
    background: var(--nx-surface);
}

.nx-emptystate--compact {
    padding: var(--nx-space-8) var(--nx-space-4);
}

.nx-emptystate__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: var(--nx-radius-full);
    background: var(--nx-surface-sunken);
    color: var(--nx-text-subtle);
    margin-bottom: var(--nx-space-1);
}

.nx-emptystate__title {
    font-size: var(--nx-text-card);
    font-weight: 650;
    color: var(--nx-text);
}

.nx-emptystate__body {
    color: var(--nx-text-muted);
    font-size: var(--nx-text-secondary);
    line-height: 1.55;
    max-width: 42ch;
}

.nx-emptystate__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--nx-space-3);
    margin-top: var(--nx-space-3);
}

/* 5c. Progressive disclosure: quiet by default, content on demand. */
.nx-details {
    border: 1px solid var(--nx-border);
    border-radius: var(--nx-radius);
    background: var(--nx-surface);
}

.nx-details--inline {
    border: 0;
    background: transparent;
    padding: 0;
}

.nx-details__summary {
    display: inline-flex;
    align-items: center;
    gap: var(--nx-space-2);
    padding: var(--nx-space-3) var(--nx-space-4);
    font-size: var(--nx-text-secondary);
    font-weight: 600;
    color: var(--nx-text-muted);
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.nx-details--inline .nx-details__summary {
    padding: 0;
    color: var(--nx-accent);
}

.nx-details__summary::-webkit-details-marker {
    display: none;
}

.nx-details__summary:hover {
    color: var(--nx-text);
}

.nx-details--inline .nx-details__summary:hover {
    color: var(--nx-accent-hover);
}

.nx-details__chev {
    transition: transform 120ms ease;
}

.nx-details[open] > .nx-details__summary .nx-details__chev {
    transform: rotate(90deg);
}

.nx-details__body {
    padding: 0 var(--nx-space-4) var(--nx-space-4);
    color: var(--nx-text-muted);
    font-size: var(--nx-text-secondary);
    line-height: 1.55;
    overflow-wrap: anywhere;
}

.nx-details--inline .nx-details__body {
    padding: var(--nx-space-3) 0 0;
}

/* 5d. Technical values: monospace, reserved tone, ALWAYS LTR. */
.nx-tech-wrap {
    display: inline-flex;
    align-items: center;
    gap: var(--nx-space-2);
    max-width: 100%;
    min-width: 0;
}

.nx-tech {
    font-family: var(--nx-mono, ui-monospace, 'Cascadia Code', Consolas, monospace);
    font-size: 0.8125em;
    background: var(--nx-surface-sunken);
    border: 1px solid var(--nx-border);
    border-radius: var(--nx-radius-sm);
    padding: 1px 6px;
    color: var(--nx-text);
    unicode-bidi: isolate;
    direction: ltr;
    overflow-wrap: anywhere;
}

.nx-tech__copy {
    border: 0;
    background: transparent;
    color: var(--nx-text-subtle);
    font-size: 0.75rem;
    cursor: pointer;
    padding: 0;
}

.nx-tech__copy:hover {
    color: var(--nx-accent);
}

/* ── 6. Phase B shell ───────────────────────────────────────────────────── */

/* 6c. Home command center (Phase C): continue row, all-clear line, system line. */
.nx-continue {
    display: flex;
    align-items: center;
    gap: var(--nx-space-4);
    padding: var(--nx-space-4) var(--nx-space-5);
    border: 1px solid var(--nx-border);
    border-inline-start: 3px solid var(--nx-accent);
    border-radius: var(--nx-radius);
    background: var(--nx-surface);
}

.nx-continue__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--nx-radius-full);
    background: color-mix(in srgb, var(--nx-accent) 12%, transparent);
    color: var(--nx-accent);
    flex-shrink: 0;
}

.nx-continue__text {
    display: grid;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.nx-continue__text strong {
    font-size: var(--nx-text-card);
    font-weight: 650;
    color: var(--nx-text);
}

.nx-continue__text p {
    color: var(--nx-text-muted);
    font-size: var(--nx-text-secondary);
}

.nx-allclear {
    display: inline-flex;
    align-items: center;
    gap: var(--nx-space-2);
    padding: var(--nx-space-2) 0;
    color: var(--nx-text-muted);
    font-size: var(--nx-text-body);
}

.nx-allclear svg {
    color: var(--nx-success);
}

.nx-systemline {
    display: flex;
    align-items: center;
    gap: var(--nx-space-2);
    margin-top: var(--nx-space-8);
    padding-top: var(--nx-space-4);
    border-top: 1px solid var(--nx-border);
    color: var(--nx-text-subtle);
    font-size: var(--nx-text-secondary);
}

.nx-systemline svg {
    color: var(--nx-success);
}

.nx-systemline--degraded svg {
    color: var(--nx-warning);
}

.nx-section__more {
    display: inline-block;
    margin-top: var(--nx-space-3);
    font-size: var(--nx-text-secondary);
}

html[dir='rtl'] .nx-continue {
    border-inline-start: 1px solid var(--nx-border);
    border-inline-end: 3px solid var(--nx-accent);
}

/* ── 6. Phase B shell (tab bars, hub) ───────────────────────────────────── */

/* 6a. Project context: primary tabs + secondary row. Rendered at CONTENT_START
   on project-scoped pages. The platform sidebar stays quiet; the project gets
   its own contextual navigation. */
.nx-tabs {
    margin: 0 0 var(--nx-space-5);
    padding: 0;
}

.nx-tabs__primary {
    display: flex;
    gap: var(--nx-space-1);
    border-bottom: 1px solid var(--nx-border);
    overflow-x: auto;
    scrollbar-width: none;
    padding: 0 var(--nx-space-1);
}

.nx-tabs__primary::-webkit-scrollbar {
    display: none;
}

/* Environment switcher: the one context control in the tab row. */
.nx-tabs__env {
    position: relative;
    margin-inline-start: auto;
    display: inline-flex;
    align-items: center;
}

.nx-tabs__env-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--nx-space-2);
    padding: 6px 12px;
    font-size: var(--nx-text-secondary);
    font-weight: 600;
    color: var(--nx-text-muted);
    border: 1px solid var(--nx-border);
    border-radius: var(--nx-radius-full);
    cursor: pointer;
    list-style: none;
    user-select: none;
    white-space: nowrap;
}

.nx-tabs__env-btn::-webkit-details-marker {
    display: none;
}

.nx-tabs__env-btn:hover {
    color: var(--nx-text);
    border-color: var(--nx-border-strong);
}

.nx-tabs__env-menu {
    position: absolute;
    inset-inline-end: 0;
    top: calc(100% + 6px);
    z-index: 40;
    min-width: 220px;
    display: grid;
    padding: var(--nx-space-2);
    gap: 2px;
    background: var(--nx-surface-raised);
    border: 1px solid var(--nx-border);
    border-radius: var(--nx-radius);
    box-shadow: var(--nx-elev-2);
}

.nx-tabs__env-menu > a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--nx-space-3);
    padding: var(--nx-space-2) var(--nx-space-3);
    border-radius: var(--nx-radius-sm);
    font-size: var(--nx-text-body);
    color: var(--nx-text);
    text-decoration: none;
}

.nx-tabs__env-menu > a:hover {
    background: var(--nx-surface-sunken);
}

.nx-tabs__env-menu > a[aria-current='true'] {
    color: var(--nx-accent);
    background: color-mix(in srgb, var(--nx-accent) 10%, transparent);
}

.nx-tabs__tab {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: var(--nx-space-2);
    padding: 10px 14px;
    font-size: var(--nx-text-body);
    font-weight: 550;
    color: var(--nx-text-muted);
    text-decoration: none;
    white-space: nowrap;
    border-radius: var(--nx-radius-sm) var(--nx-radius-sm) 0 0;
    transition: color 120ms ease, background-color 120ms ease;
}

.nx-tabs__tab:hover {
    color: var(--nx-text);
    background: var(--nx-surface-sunken);
}

.nx-tabs__tab[aria-current='page'] {
    color: var(--nx-accent);
    font-weight: 650;
}

.nx-tabs__tab[aria-current='page']::after {
    content: '';
    position: absolute;
    inset-inline: 8px;
    bottom: -1px;
    height: 2px;
    border-radius: var(--nx-radius-full);
    background: var(--nx-accent);
}

.nx-tabs__secondary {
    display: flex;
    flex-wrap: wrap;
    gap: var(--nx-space-2);
    padding: var(--nx-space-3) 0 0;
}

.nx-tabs__subtab {
    display: inline-flex;
    align-items: center;
    padding: 5px 12px;
    font-size: var(--nx-text-secondary);
    font-weight: 550;
    color: var(--nx-text-muted);
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: var(--nx-radius-full);
    transition: color 120ms ease, background-color 120ms ease, border-color 120ms ease;
}

.nx-tabs__subtab:hover {
    color: var(--nx-text);
    background: var(--nx-surface-sunken);
}

.nx-tabs__subtab[aria-current='page'] {
    color: var(--nx-accent);
    background: color-mix(in srgb, var(--nx-accent) 12%, transparent);
    border-color: color-mix(in srgb, var(--nx-accent) 30%, transparent);
}

/* 6b. Settings hub: a map of configuration, not a pile of cards. */
.nx-hub {
    display: grid;
    gap: var(--nx-space-8);
}

.nx-hub__section-title {
    font-size: var(--nx-text-section);
    font-weight: 650;
    letter-spacing: -0.01em;
    color: var(--nx-text);
    margin-bottom: var(--nx-space-2);
}

.nx-hub__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--nx-space-4);
}

.nx-hub-card {
    display: flex;
    flex-direction: column;
    gap: var(--nx-space-2);
    padding: var(--nx-space-5);
    border: 1px solid var(--nx-border);
    border-radius: var(--nx-radius);
    background: var(--nx-surface);
    text-decoration: none;
    transition: border-color 120ms ease, transform 120ms ease;
}

a.nx-hub-card:hover {
    border-color: color-mix(in srgb, var(--nx-accent) 45%, var(--nx-border));
}

.nx-hub-card__title {
    display: flex;
    align-items: center;
    gap: var(--nx-space-2);
    font-size: var(--nx-text-card);
    font-weight: 650;
    color: var(--nx-text);
}

.nx-hub-card__title svg {
    color: var(--nx-accent);
}

.nx-hub-card__desc {
    color: var(--nx-text-muted);
    font-size: var(--nx-text-secondary);
    line-height: 1.55;
}

.nx-hub-card__links {
    display: grid;
    gap: var(--nx-space-2);
    margin-top: var(--nx-space-2);
}

.nx-hub-card__link {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--nx-space-3);
    padding: var(--nx-space-2) var(--nx-space-3);
    border-radius: var(--nx-radius-sm);
    color: var(--nx-text);
    font-size: var(--nx-text-body);
    font-weight: 550;
    text-decoration: none;
}

.nx-hub-card__link:hover {
    background: var(--nx-surface-sunken);
    color: var(--nx-accent);
}

.nx-hub-card__link small {
    color: var(--nx-text-subtle);
    font-weight: 450;
}

/* ── 7. RTL behavior ────────────────────────────────────────────────────── */

html[dir='rtl'] .nx-details__chev {
    transform: scaleX(-1);
}

html[dir='rtl'] .nx-details[open] > .nx-details__summary .nx-details__chev {
    transform: scaleX(-1) rotate(90deg);
}

/* Tab bars scroll horizontally in narrow viewports regardless of direction. */
html[dir='rtl'] .nx-tabs__primary {
    padding: 0;
}

/* Arabic typography for foundation components (mirrors nexus.css C.8). */
html[dir='rtl'] .nx-error__title,
html[dir='rtl'] .nx-emptystate__title,
html[dir='rtl'] .nx-tabs__tab,
html[dir='rtl'] .nx-hub-card__title,
html[dir='rtl'] .nx-details__summary {
    letter-spacing: 0;
}

/* ── 8. Motion & accessibility ──────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    .nx-tabs__tab,
    .nx-tabs__subtab,
    .nx-hub-card,
    .nx-btn,
    .nx-details__chev {
        transition: none;
    }
}

.nx-error:focus-within,
.nx-details summary:focus-visible {
    outline: 2px solid var(--nx-accent);
    outline-offset: 2px;
    border-radius: var(--nx-radius-sm);
}

/* ── 9. Phase D — Projects index (§D1/§D14) ─────────────────────────────── */

/* Quiet summary line under the page title: counts, never KPI cards. */
.nx-projects-summary {
    margin: 0 0 var(--nx-space-4);
    color: var(--nx-text-secondary);
    font-size: var(--nx-text-body);
}

/* Filter bar: a handful of chips + tools. One row, quiet borders. */
.nx-filterbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--nx-space-3);
    margin-bottom: var(--nx-space-5);
}

.nx-filterbar__groups {
    display: flex;
    flex-wrap: wrap;
    gap: var(--nx-space-1);
}

.nx-filterbar__chip {
    padding: 6px 14px;
    border: 1px solid transparent;
    border-radius: var(--nx-radius-full);
    color: var(--nx-text-secondary);
    font-size: var(--nx-text-secondary);
    text-decoration: none;
    transition: background-color 120ms ease, color 120ms ease;
}

.nx-filterbar__chip:hover {
    color: var(--nx-text);
    background: var(--nx-surface-raised);
}

.nx-filterbar__chip.is-active {
    background: var(--nx-accent-soft, var(--nx-surface-raised));
    border-color: var(--nx-accent);
    color: var(--nx-accent);
    font-weight: 600;
}

.nx-filterbar__tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--nx-space-2);
}

.nx-filterbar__search input {
    min-width: 200px;
    padding: 7px 12px;
    border: 1px solid var(--nx-border);
    border-radius: var(--nx-radius-sm);
    background: var(--nx-surface);
    color: var(--nx-text);
    font-size: var(--nx-text-secondary);
}

.nx-filterbar__search input:focus-visible {
    outline: 2px solid var(--nx-accent);
    outline-offset: 1px;
}

.nx-filterbar__select {
    padding: 7px 10px;
    border: 1px solid var(--nx-border);
    border-radius: var(--nx-radius-sm);
    background: var(--nx-surface);
    color: var(--nx-text);
    font-size: var(--nx-text-secondary);
}

.nx-filterbar__select.is-placeholder {
    color: var(--nx-text-muted);
}

/* View mode toggle: two quiet buttons, active carries the accent. */
.nx-filterbar__modes {
    display: inline-flex;
    border: 1px solid var(--nx-border);
    border-radius: var(--nx-radius-sm);
    overflow: hidden;
}

.nx-filterbar__modes button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border: 0;
    background: var(--nx-surface);
    color: var(--nx-text-secondary);
    font-size: var(--nx-text-secondary);
    cursor: pointer;
}

.nx-filterbar__modes button + button {
    border-inline-start: 1px solid var(--nx-border);
}

.nx-filterbar__modes button.is-active {
    background: var(--nx-surface-raised);
    color: var(--nx-text);
    font-weight: 600;
}

/* The one action on a card, bottom-aligned — a card IS a link. */
.nx-card__open {
    margin-top: auto;
    color: var(--nx-accent);
    font-size: var(--nx-text-secondary);
    font-weight: 600;
}

/* Attention-first: a needs-attention card carries a quiet accent edge,
   not a louder shadow (§D15 — minimal border, no badge overload). */
.nx-card--attention {
    border-inline-start: 3px solid var(--nx-warning);
}

.nx-card--attention:has(.nx-status--danger) {
    border-inline-start-color: var(--nx-danger);
}

/* Compact view (§D1): calm rows, never the technical table again. */
.nx-projects-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--nx-text-body);
}

.nx-projects-table th {
    padding: 8px 12px;
    border-bottom: 1px solid var(--nx-border-strong);
    color: var(--nx-text-secondary);
    font-size: var(--nx-text-eyebrow);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-align: start;
    white-space: nowrap;
}

.nx-projects-table td {
    padding: 12px;
    border-bottom: 1px solid var(--nx-border);
    vertical-align: middle;
}

.nx-projects-table tbody tr:hover {
    background: var(--nx-surface-raised);
}

.nx-projects-table__name {
    color: var(--nx-text);
    font-weight: 600;
    text-decoration: none;
}

.nx-projects-table__name:hover {
    color: var(--nx-accent);
}

/* Pagination: quiet, centered, never a widget wall. */
.nx-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--nx-space-3);
    margin-top: var(--nx-space-5);
}

.nx-pagination button {
    padding: 6px 12px;
    border: 1px solid var(--nx-border);
    border-radius: var(--nx-radius-sm);
    background: var(--nx-surface);
    color: var(--nx-text-secondary);
    font-size: var(--nx-text-secondary);
    cursor: pointer;
}

.nx-pagination button:disabled {
    opacity: 0.45;
    cursor: default;
}

.nx-pagination__status {
    color: var(--nx-text-secondary);
    font-size: var(--nx-text-secondary);
}

/* At 1366 the filter bar keeps one visual row without crowding the grid. */
@media (max-width: 1440px) {
    .nx-filterbar__search input {
        min-width: 160px;
    }
}

/* ==========================================================================
   Phase F — Nexus AI chat-first experience (0.6.0)
   --------------------------------------------------------------------------
   The chat + composer lead the page. The tool inventory lives behind the
   capabilities disclosure; user / assistant / tool activity / proposed
   action / error are five DIFFERENT visual objects (§F12), kept quiet.
   ========================================================================== */

/* ── Header row: context banner + thread actions ────────────────────────── */
.nx-ai-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--nx-space-2, 8px);
    flex-wrap: wrap;
    margin-block-end: 12px;
}

.nx-ai-head .nx-scope-banner {
    flex: 1 1 320px;
    margin-block-end: 0;
}

.nx-ai-head__actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Secondary quiet button (next to .nx-btn / .nx-btn--secondary). */
.nx-btn--quiet {
    background: transparent;
    border: 1px solid var(--nx-border, rgba(0, 0, 0, 0.12));
    color: var(--nx-text-muted, #555);
    box-shadow: none;
}

.nx-btn--quiet:hover {
    background: var(--nx-neutral-soft, rgba(0, 0, 0, 0.04));
}

html.dark .nx-btn--quiet {
    border-color: rgba(255, 255, 255, 0.14);
    color: var(--nx-text-muted, #a1a1aa);
}

html.dark .nx-btn--quiet:hover {
    background: rgba(255, 255, 255, 0.06);
}

/* ── Conversation history (§F11) — opened on demand, never a sidebar ───── */
.nx-ai-history {
    border: 1px solid var(--nx-border, rgba(0, 0, 0, 0.1));
    border-radius: 10px;
    background: var(--nx-surface, #fff);
    padding: 12px;
    margin-block-end: 12px;
}

.nx-ai-history__search {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--nx-border, rgba(0, 0, 0, 0.12));
    border-radius: 8px;
    background: var(--nx-canvas, #f6f6f8);
    font-size: var(--nx-text-body, 0.875rem);
    margin-block-end: 8px;
}

.nx-ai-history__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 2px;
}

.nx-ai-history__row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 8px 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
    text-align: start;
    font-size: var(--nx-text-body, 0.875rem);
    color: var(--nx-text, #111);
}

.nx-ai-history__row:hover {
    background: var(--nx-neutral-soft, rgba(0, 0, 0, 0.04));
}

.nx-ai-history__title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nx-ai-history__when {
    flex: 0 0 auto;
    font-size: var(--nx-text-secondary, 0.8125rem);
    color: var(--nx-text-muted, #777);
}

.nx-ai-history__empty {
    color: var(--nx-text-muted, #777);
    font-size: var(--nx-text-secondary, 0.8125rem);
    padding: 8px 10px;
}

.nx-ai-history__pager {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-block-start: 8px;
}

/* ── The conversation itself (§F1) ──────────────────────────────────────── */
.nx-ai-main .nx-chat {
    min-height: 200px;
}

/* Message hierarchy (§F12): a user turn is a quiet bubble aligned to the
   speaker side; an assistant turn is plain product text on the canvas. */
.nx-chat__turn--user {
    max-width: min(72%, 640px);
    margin-inline-start: auto;
    background: var(--nx-neutral-soft, rgba(0, 0, 0, 0.045));
    border: 1px solid var(--nx-border, rgba(0, 0, 0, 0.08));
    border-radius: 12px;
    padding: 10px 14px;
}

html.dark .nx-chat__turn--user {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.12);
}

.nx-chat__who {
    display: block;
    font-size: var(--nx-text-eyebrow, 0.6875rem);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--nx-text-muted, #888);
    margin-block-end: 4px;
}

.nx-chat__turn--user .nx-chat__who {
    text-align: end;
}

/* Markdown-presented answers (§F14): scannable, never rewritten content. */
.nx-prose {
    font-size: var(--nx-text-body, 0.875rem);
    line-height: 1.65;
    color: var(--nx-text, #1a1a1a);
    overflow-wrap: anywhere;
}

.nx-prose > :first-child { margin-block-start: 0; }
.nx-prose > :last-child { margin-block-end: 0; }

.nx-prose h1,
.nx-prose h2,
.nx-prose h3 {
    font-size: var(--nx-text-card, 0.9375rem);
    font-weight: 650;
    margin-block: 0.9em 0.35em;
    line-height: 1.35;
}

.nx-prose p { margin-block: 0.45em; }

.nx-prose ul,
.nx-prose ol {
    margin-block: 0.45em;
    padding-inline-start: 1.4em;
    display: grid;
    gap: 0.2em;
}

.nx-prose code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.9em;
    background: var(--nx-neutral-soft, rgba(0, 0, 0, 0.06));
    border-radius: 4px;
    padding: 0.1em 0.35em;
    direction: ltr;
    unicode-bidi: isolate;
}

html.dark .nx-prose code {
    background: rgba(255, 255, 255, 0.08);
}

.nx-prose pre {
    background: var(--nx-neutral-soft, rgba(0, 0, 0, 0.06));
    border: 1px solid var(--nx-border, rgba(0, 0, 0, 0.08));
    border-radius: 8px;
    padding: 10px 12px;
    overflow-x: auto;
    direction: ltr;
    text-align: start;
}

html.dark .nx-prose pre {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.12);
}

.nx-prose pre code {
    background: transparent;
    padding: 0;
}

.nx-prose a {
    text-decoration: underline;
    text-underline-offset: 2px;
}

.nx-prose table {
    border-collapse: collapse;
    font-size: var(--nx-text-secondary, 0.8125rem);
}

.nx-prose th,
.nx-prose td {
    border: 1px solid var(--nx-border, rgba(0, 0, 0, 0.1));
    padding: 4px 8px;
    text-align: start;
}

/* Grounding indicator (§F15): quiet, honest provenance. */
.nx-grounding {
    margin-block-start: 8px;
    padding-block-start: 8px;
    border-block-start: 1px dashed var(--nx-border, rgba(0, 0, 0, 0.12));
    font-size: var(--nx-text-secondary, 0.8125rem);
    color: var(--nx-text-muted, #777);
}

.nx-grounding span {
    font-weight: 600;
    margin-inline-end: 4px;
}

/* Welcome / empty conversation state (§F3). */
.nx-welcome {
    display: grid;
    justify-items: center;
    text-align: center;
    gap: 6px;
    padding: 40px 16px 32px;
    max-width: 620px;
    margin-inline: auto;
}

.nx-welcome__glyph {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 999px;
    background: var(--nx-primary-soft, rgba(79, 70, 229, 0.1));
    color: var(--nx-primary, #4f46e5);
    margin-block-end: 6px;
}

.nx-welcome__title {
    font-size: var(--nx-text-section, 1.25rem);
    font-weight: 650;
    color: var(--nx-text, #1a1a1a);
    margin: 0;
}

.nx-welcome__body {
    font-size: var(--nx-text-body, 0.875rem);
    color: var(--nx-text-muted, #777);
    margin: 0;
}

.nx-welcome__prompts {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-block-start: 14px;
}

.nx-prompt-chip {
    border: 1px solid var(--nx-border, rgba(0, 0, 0, 0.12));
    background: var(--nx-surface, #fff);
    color: var(--nx-text, #1a1a1a);
    border-radius: 999px;
    padding: 7px 14px;
    font-size: var(--nx-text-secondary, 0.8125rem);
    cursor: pointer;
}

.nx-prompt-chip:hover {
    border-color: var(--nx-primary, #4f46e5);
    color: var(--nx-primary, #4f46e5);
}

html.dark .nx-prompt-chip {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.14);
}

/* Thinking state (§F13): honest in-progress signal, no fake streaming. */
.nx-thinking {
    display: none;
    align-items: center;
    gap: 6px;
    font-size: var(--nx-text-secondary, 0.8125rem);
    color: var(--nx-text-muted, #777);
}

/* Thinking state (§F13): honest in-progress signal, no fake streaming. */
.nx-thinking {
    display: none;
    align-items: center;
    gap: 6px;
    font-size: var(--nx-text-secondary, 0.8125rem);
    color: var(--nx-text-muted, #777);
}

.nx-thinking[wire\:loading],
.nx-thinking.wire-loading {
    display: inline-flex;
}

.nx-thinking__dot {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: var(--nx-primary, #4f46e5);
    animation: nx-thinking-pulse 1s ease-in-out infinite;
}

@keyframes nx-thinking-pulse {
    0%, 100% { opacity: 0.25; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1); }
}

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

/* ── Capabilities disclosure (§F4) — below the fold, human language ────── */
.nx-capabilities {
    list-style: none;
    margin: 12px 0 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 10px;
}

.nx-capability {
    border: 1px solid var(--nx-border, rgba(0, 0, 0, 0.1));
    border-radius: 10px;
    padding: 12px;
    background: var(--nx-surface, #fff);
}

html.dark .nx-capability {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.1);
}

.nx-capability__head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.nx-capability__head > svg {
    color: var(--nx-primary, #4f46e5);
    flex: 0 0 auto;
}

.nx-capability__name {
    font-weight: 600;
    font-size: var(--nx-text-body, 0.875rem);
    color: var(--nx-text, #1a1a1a);
}

.nx-capability__description {
    margin: 6px 0 0;
    font-size: var(--nx-text-secondary, 0.8125rem);
    color: var(--nx-text-muted, #777);
    line-height: 1.5;
}

.nx-tag--action {
    background: var(--nx-warning-soft, rgba(180, 83, 9, 0.12));
    color: var(--nx-warning, #b45309);
}

/* Technical details inside the disclosure: internal tool names only here. */
.nx-technical-tools {
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* Safe-action card refinements (§F6, §F7). */
.nx-action-card__reason {
    margin: 6px 0 0;
    font-size: var(--nx-text-secondary, 0.8125rem);
    color: var(--nx-text-muted, #777);
}

.nx-action-card__tech {
    margin-block-start: 10px;
}

/* History + capabilities respond cleanly down to 1366×768 and below (§F20). */
@media (max-width: 900px) {
    .nx-chat__turn--user {
        max-width: 88%;
    }

    .nx-capabilities {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   Phase G — Developer Agent workbench (0.6.0)
   --------------------------------------------------------------------------
   STATUS-FIRST: task identity + human state + next step lead; diff summary,
   tests, the decision card and a human activity timeline follow. Everything
   Level-3/4 lives inside Technical details. Logical properties throughout
   for full RTL mirroring.
   ========================================================================== */

/* Quiet runtime state (§G4). */
.nx-agent-head {
    display: flex;
    justify-content: flex-end;
    margin-block-end: 8px;
}

.nx-agent-runtime {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: var(--nx-text-secondary, 0.8125rem);
    color: var(--nx-text-muted, #777);
    border: 1px solid var(--nx-border, rgba(0, 0, 0, 0.1));
    border-radius: 999px;
    padding: 4px 12px;
    background: var(--nx-surface, #fff);
}

html.dark .nx-agent-runtime {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.12);
}

.nx-agent-runtime__dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--nx-text-muted, #999);
    flex: 0 0 auto;
}

.nx-agent-runtime--ok .nx-agent-runtime__dot { background: var(--nx-success, #047857); }
.nx-agent-runtime--down .nx-agent-runtime__dot { background: var(--nx-danger, #b91c1c); }

.nx-agent-runtime__version {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.92em;
}

/* Task history (§G20). */
.nx-agent-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-block-end: 10px;
}

.nx-agent-filter {
    border: 1px solid var(--nx-border, rgba(0, 0, 0, 0.12));
    background: transparent;
    color: var(--nx-text-muted, #666);
    border-radius: 999px;
    padding: 4px 12px;
    font-size: var(--nx-text-secondary, 0.8125rem);
    cursor: pointer;
}

.nx-agent-filter--on {
    background: var(--nx-primary-soft, rgba(79, 70, 229, 0.1));
    border-color: var(--nx-primary, #4f46e5);
    color: var(--nx-primary, #4f46e5);
    font-weight: 600;
}

.nx-agent-tasklist {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 4px;
}

.nx-agent-task {
    display: grid;
    gap: 2px;
    width: 100%;
    text-align: start;
    border: 1px solid transparent;
    background: transparent;
    border-radius: 8px;
    padding: 8px 10px;
    cursor: pointer;
    font-size: var(--nx-text-body, 0.875rem);
    color: var(--nx-text, #1a1a1a);
}

.nx-agent-task:hover { background: var(--nx-neutral-soft, rgba(0, 0, 0, 0.04)); }
.nx-agent-task--on {
    background: var(--nx-primary-soft, rgba(79, 70, 229, 0.08));
    border-color: var(--nx-primary, #4f46e5);
}

.nx-agent-task__title {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nx-agent-task__dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: var(--nx-warning, #b45309);
    margin-inline-end: 6px;
    vertical-align: middle;
}

.nx-agent-task__meta {
    font-size: var(--nx-text-secondary, 0.8125rem);
    color: var(--nx-text-muted, #777);
}

/* Human state chip (§G5) — one dictionary, five tones. */
.nx-agent-state {
    display: inline-block;
    border-radius: 999px;
    padding: 2px 10px;
    font-size: var(--nx-text-secondary, 0.8125rem);
    font-weight: 600;
    background: var(--nx-neutral-soft, rgba(0, 0, 0, 0.06));
    color: var(--nx-text-muted, #555);
    white-space: nowrap;
}

.nx-agent-state--info { background: var(--nx-info-soft, rgba(2, 132, 199, 0.1)); color: var(--nx-info, #0369a1); }
.nx-agent-state--success { background: var(--nx-success-soft, rgba(4, 120, 87, 0.1)); color: var(--nx-success, #047857); }
.nx-agent-state--attention { background: var(--nx-warning-soft, rgba(180, 83, 9, 0.12)); color: var(--nx-warning, #b45309); }
.nx-agent-state--warning { background: var(--nx-warning-soft, rgba(180, 83, 9, 0.12)); color: var(--nx-warning, #b45309); }
.nx-agent-state--danger { background: var(--nx-danger-soft, rgba(185, 28, 28, 0.1)); color: var(--nx-danger, #b91c1c); }

.nx-agent-state--lg {
    font-size: var(--nx-text-body, 0.875rem);
    padding: 5px 14px;
    flex: 0 0 auto;
}

/* Task detail header (§G1). */
.nx-agent-detail__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.nx-agent-nextstep {
    margin: 8px 0 0;
    font-size: var(--nx-text-body, 0.875rem);
    color: var(--nx-text, #333);
}

.nx-agent-prompt {
    white-space: pre-wrap;
    font-size: var(--nx-text-body, 0.875rem);
    margin: 0;
}

/* Failed task error (§G18) — reuses the Phase A nx-error pattern. */
.nx-agent-error { margin-block-start: 12px; }

/* What changed (§G7): summary → files → diff. */
.nx-agent-diff-summary {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
    font-size: var(--nx-text-body, 0.875rem);
    margin: 0 0 8px;
}

.nx-agent-diffstat { font-weight: 700; }
.nx-agent-diffstat--add { color: var(--nx-success, #047857); }
.nx-agent-diffstat--del { color: var(--nx-danger, #b91c1c); }

.nx-agent-files {
    list-style: none;
    margin: 0 0 8px;
    padding: 0;
    display: grid;
    gap: 2px;
    font-size: var(--nx-text-secondary, 0.8125rem);
}

.nx-agent-diffcode {
    max-height: 420px;
    overflow: auto;
    font-size: 0.8125rem;
    line-height: 1.5;
}

/* Tests (§G9): verdict first, real checks below. */
.nx-agent-checks {
    list-style: none;
    margin: 8px 0;
    padding: 0;
    display: grid;
    gap: 4px;
}

.nx-agent-check {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-size: var(--nx-text-secondary, 0.8125rem);
    border: 1px solid var(--nx-border, rgba(0, 0, 0, 0.08));
    border-radius: 8px;
    padding: 6px 10px;
}

.nx-agent-check--fail {
    border-color: var(--nx-danger, #b91c1c);
    background: var(--nx-danger-soft, rgba(185, 28, 28, 0.05));
}

.nx-agent-check__verdict { font-weight: 700; flex: 0 0 auto; }
.nx-agent-check__name {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    overflow-wrap: anywhere;
}
.nx-agent-check__meta {
    margin-inline-start: auto;
    color: var(--nx-text-muted, #888);
    flex: 0 0 auto;
}

/* Decision card (§G10) — the dominant state when review is needed. */
.nx-agent-decision {
    border-inline-start: 3px solid var(--nx-warning, #b45309);
}

.nx-agent-decision__impact {
    font-size: var(--nx-text-body, 0.875rem);
    margin: 4px 0;
}

.nx-agent-reject-note { margin-block-start: 10px; }

/* Cancel (§G17). */
.nx-agent-cancel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* Activity timeline (§G6). */
.nx-agent-timeline__time {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.8em;
    color: var(--nx-text-muted, #999);
    margin-inline-end: 8px;
}

/* 1366×768 (§G29): identity, state, summary, tests and decision visible
   without scrolling through logs — the grid keeps cards compact. */
@media (max-width: 1440px) {
    .nx-agent-detail__head { align-items: center; }
}
