/* Risk Builder / advisor panel screens (ADR-0007, HQU-188–191).
   Structure and rhythm only — colour, chips and cards come from the shared surfaces
   (.panel, .status-chip .tone-*, .empty-state, .step-indicator). */

.adv-page { display: flex; flex-direction: column; gap: 1.25rem; }

/* ── Standing promise + disclaimer (on every screen) ───────────────────────── */
.adv-promise {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--accent-muted);
    background: var(--accent-subtle);
    border-radius: var(--radius-md);
    color: var(--fg-default);
    font-size: var(--text-sm);
}
.adv-promise .mud-icon-root { color: var(--accent-fg); font-size: var(--text-lg); }

.adv-disclaimer {
    color: var(--fg-muted);
    font-size: var(--text-xs);
    line-height: 1.5;
    padding-top: 0.25rem;
    border-top: 1px solid var(--border-muted);
}

.adv-lead { color: var(--fg-muted); font-size: var(--text-sm); line-height: 1.6; }

/* ── Convene: scope picker + seat roster ───────────────────────────────────── */
.adv-scope { display: flex; flex-direction: column; gap: 0.9rem; }
.adv-field-label { font-size: var(--text-sm); font-weight: 600; color: var(--fg-default); }
.adv-field-hint { font-size: var(--text-xs); color: var(--fg-muted); margin-top: 0.15rem; }

.adv-seats { display: flex; flex-direction: column; gap: 0.5rem; }
.adv-seat {
    display: flex; align-items: flex-start; gap: 0.75rem;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--border-muted);
    border-radius: var(--radius-md);
    background: var(--canvas-subtle);
}
.adv-seat-num {
    flex: 0 0 auto; width: 1.4rem; height: 1.4rem;
    display: grid; place-items: center;
    border-radius: var(--radius-pill);
    background: var(--canvas-inset); color: var(--fg-muted);
    font-size: var(--text-xs); font-weight: 600;
}
.adv-seat-body { flex: 1 1 auto; min-width: 0; }
.adv-seat-name { font-weight: 600; font-size: var(--text-sm); color: var(--fg-default); }
.adv-seat-desc { font-size: var(--text-xs); color: var(--fg-muted); margin-top: 0.1rem; }

/* ── Run stream: the relay column ──────────────────────────────────────────── */
.adv-relay { display: flex; flex-direction: column; gap: 0.9rem; }
.adv-reasoning { font-size: var(--text-sm); line-height: 1.6; color: var(--fg-default); }
/* Markdig renders blocks (p/ul/ol/…); tame their outer margins so model text sits tight in the
   reasoning, handoffs, step rationales and reviewer findings alike. */
.adv-reasoning .md-view > :first-child,
.adv-handoff-body .md-view > :first-child,
.adv-step-rationale .md-view > :first-child,
.adv-finding-body .md-view > :first-child { margin-top: 0; }
.adv-reasoning .md-view > :last-child,
.adv-handoff-body .md-view > :last-child,
.adv-step-rationale .md-view > :last-child,
.adv-finding-body .md-view > :last-child { margin-bottom: 0; }

/* The step-jump link now follows a rendered block, so give it a little air as its own line. */
.adv-finding-body .adv-finding-link { display: inline-block; margin-top: 0.25rem; }

.adv-events { display: flex; flex-direction: column; gap: 0.35rem; margin-top: 0.6rem; }
.adv-tool {
    display: flex; align-items: center; gap: 0.5rem;
    font-size: var(--text-xs); color: var(--fg-muted);
}
.adv-tool .mud-icon-root { font-size: var(--text-md); }
.adv-tool--write { color: var(--fg-default); }

.adv-chip {
    display: inline-flex; align-items: center; gap: 0.3rem;
    padding: 0.05rem 0.45rem;
    border-radius: var(--radius-pill);
    font-size: var(--text-2xs); font-weight: 600;
    background: var(--canvas-inset); color: var(--fg-muted);
}
.adv-chip--tool { background: var(--accent-subtle); color: var(--accent-fg); }

/* The handoff, rendered between seats as its own object — the reason the run is sequential. */
.adv-handoff {
    position: relative;
    margin: 0.2rem 0 0.2rem 1.4rem;
    padding: 0.7rem 0.9rem;
    border-left: 2px solid var(--accent-muted);
    background: var(--canvas-subtle);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}
.adv-handoff-label {
    font-size: var(--text-2xs); font-weight: 700; letter-spacing: 0.04em;
    text-transform: uppercase; color: var(--accent-fg); margin-bottom: 0.3rem;
    display: flex; align-items: center; gap: 0.35rem;
}
.adv-handoff-body { font-size: var(--text-sm); line-height: 1.55; color: var(--fg-default); }

/* ── Review: findings + step groups ────────────────────────────────────────── */
.adv-findings { display: flex; flex-direction: column; gap: 0.5rem; }
.adv-finding {
    display: flex; gap: 0.6rem; align-items: flex-start;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border-muted);
    border-left-width: 3px;
    border-radius: var(--radius-md);
    background: var(--canvas-subtle);
}
.adv-finding--orphan, .adv-finding--undefended { border-left-color: var(--danger-emphasis); }
.adv-finding--gap { border-left-color: var(--attention-emphasis); }
.adv-finding--duplicate, .adv-finding--padding { border-left-color: var(--fg-subtle); }
.adv-finding--workload { border-left-color: var(--accent-emphasis); }
.adv-finding-body { flex: 1 1 auto; font-size: var(--text-sm); line-height: 1.5; color: var(--fg-default); }
.adv-finding-link { font-size: var(--text-xs); color: var(--accent-fg); cursor: pointer; }

.adv-group { display: flex; flex-direction: column; gap: 0.4rem; }
.adv-step {
    display: flex; gap: 0.6rem; align-items: flex-start;
    padding: 0.6rem 0.7rem;
    border: 1px solid var(--border-muted);
    border-radius: var(--radius-md);
}
.adv-step--rejected { opacity: 0.55; }
.adv-step--flagged { border-color: var(--attention-emphasis); }
.adv-step-ord {
    flex: 0 0 auto; width: 1.5rem; height: 1.5rem;
    display: grid; place-items: center;
    border-radius: var(--radius-sm);
    background: var(--canvas-inset); color: var(--fg-muted);
    font-size: var(--text-2xs); font-weight: 700;
}
.adv-step-main { flex: 1 1 auto; min-width: 0; }
.adv-step-head { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.adv-step-name { font-weight: 600; font-size: var(--text-sm); color: var(--fg-default); }
.adv-step-rationale { font-size: var(--text-xs); color: var(--fg-muted); margin-top: 0.2rem; line-height: 1.5; }
.adv-step-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 0.25rem; }
.adv-group-more { font-size: var(--text-xs); color: var(--fg-muted); padding: 0.3rem 0.2rem; }

/* Generic arguments renderer — one shape for every tool (the payoff of capturing tool calls). */
.adv-args { display: flex; flex-direction: column; gap: 0.25rem; margin-top: 0.5rem;
            padding: 0.5rem 0.6rem; background: var(--canvas-inset); border-radius: var(--radius-sm); }
.adv-arg { display: flex; gap: 0.5rem; font-size: var(--text-xs); align-items: baseline; }
.adv-arg-key { flex: 0 0 auto; min-width: 8rem; color: var(--fg-muted); font-weight: 600; }
.adv-arg-val { flex: 1 1 auto; min-width: 0; color: var(--fg-default); white-space: pre-wrap; word-break: break-word; }
.adv-arg-nested { margin-left: 0.6rem; border-left: 1px solid var(--border-muted); padding-left: 0.5rem; }
.adv-arg-item { padding: 0.15rem 0; }
.adv-ref { color: var(--accent-fg); font-size: var(--text-2xs);
           background: var(--accent-subtle); padding: 0.02rem 0.35rem; border-radius: var(--radius-pill); }

/* ── Commit: segmented bar + step ledger ───────────────────────────────────── */
.adv-segbar { display: flex; height: 0.55rem; border-radius: var(--radius-pill); overflow: hidden;
              background: var(--canvas-inset); }
.adv-segbar-seg { height: 100%; }
.adv-segbar-seg--committed { background: var(--success-emphasis); }
.adv-segbar-seg--failed { background: var(--danger-emphasis); }
.adv-segbar-seg--skipped { background: var(--fg-subtle); }
.adv-seg-legend { display: flex; gap: 1rem; font-size: var(--text-xs); color: var(--fg-muted); margin-top: 0.4rem; }
.adv-seg-legend b { color: var(--fg-default); }

.adv-fail-card {
    padding: 0.8rem 0.9rem;
    border: 1px solid var(--danger-muted);
    background: var(--danger-subtle);
    border-radius: var(--radius-md);
    display: flex; flex-direction: column; gap: 0.4rem;
}
.adv-fail-title { font-weight: 600; font-size: var(--text-sm); color: var(--danger-fg); }
.adv-fail-error { font-size: var(--text-xs);
                  color: var(--fg-default); white-space: pre-wrap; word-break: break-word; }
.adv-fail-why { font-size: var(--text-xs); color: var(--fg-muted); line-height: 1.5; }

.adv-ledger { display: flex; flex-direction: column; }
.adv-ledger-row {
    display: flex; gap: 0.6rem; align-items: center;
    padding: 0.5rem 0.2rem;
    border-bottom: 1px solid var(--border-muted);
    font-size: var(--text-sm);
}
.adv-ledger-row:last-child { border-bottom: none; }
.adv-ledger-ord { flex: 0 0 auto; width: 1.5rem; height: 1.5rem; display: grid; place-items: center;
                  border-radius: var(--radius-sm); background: var(--canvas-inset); color: var(--fg-muted);
                  font-size: var(--text-2xs); font-weight: 700; }
.adv-ledger-main { flex: 1 1 auto; min-width: 0; }
.adv-ledger-name { color: var(--fg-default); }
.adv-ledger-note { font-size: var(--text-xs); color: var(--fg-muted); margin-top: 0.1rem; }
.adv-ledger-id { font-size: var(--text-xs); color: var(--success-fg); }

.adv-actions { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.adv-spend { font-size: var(--text-xs); color: var(--fg-muted); }

/* ── ADR-0008: one conversation document ──────────────────────────────────── */
.adv-conversation {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(20rem, 0.75fr);
    min-height: calc(100vh - 10rem);
    border: 1px solid var(--border-muted);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--canvas-default);
}

.adv-thread-pane,
.adv-plan-pane { min-width: 0; padding: 1rem; }
.adv-thread-pane { display: flex; flex-direction: column; gap: 1rem; }
.adv-plan-pane {
    display: flex; flex-direction: column; gap: 0.8rem;
    border-left: 1px solid var(--border-muted);
    background: var(--canvas-subtle);
}
.adv-pane-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.adv-pane-head h2 { margin: 0; font-size: var(--text-lg); color: var(--fg-default); }
.adv-pane-head p { margin: 0.15rem 0 0; color: var(--fg-muted); font-size: var(--text-xs); }
.adv-total-spend { flex: 0 0 auto; font-size: var(--text-xs); color: var(--fg-muted); }

.adv-context {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.65rem 0.75rem; border: 1px solid var(--accent-muted);
    border-radius: var(--radius-md); background: var(--accent-subtle);
    color: var(--fg-default); font-size: var(--text-sm);
}
.adv-context .mud-icon-root { color: var(--accent-fg); }
.adv-opening-form, .adv-composer { display: flex; flex-direction: column; gap: 0.65rem; }
.adv-opening-form { margin-top: auto; }
.adv-composer { padding-top: 0.85rem; border-top: 1px solid var(--border-muted); }
.adv-compose-row { display: flex; align-items: center; gap: 0.65rem; }
.adv-advisor-select { flex: 1 1 auto; min-width: 10rem; }

.adv-thread { display: flex; flex-direction: column; gap: 0.8rem; flex: 1 1 auto; }
.adv-message { max-width: 88%; display: flex; flex-direction: column; gap: 0.45rem; }
.adv-message--operator {
    align-self: flex-end; padding: 0.7rem 0.85rem;
    background: var(--accent-subtle); border: 1px solid var(--accent-muted);
    border-radius: var(--radius-md) var(--radius-sm) var(--radius-md) var(--radius-md);
}
.adv-message--advisor {
    align-self: flex-start; padding: 0.7rem 0;
    border-bottom: 1px solid var(--border-muted);
}
.adv-message--live { width: 88%; }
.adv-message-meta { display: flex; justify-content: space-between; gap: 1rem; font-size: var(--text-2xs); color: var(--fg-muted); }
.adv-message-meta > :first-child { font-weight: 700; color: var(--fg-default); }
.adv-message-body { font-size: var(--text-sm); line-height: 1.55; color: var(--fg-default); }
.adv-message-body .md-view > :first-child { margin-top: 0; }
.adv-message-body .md-view > :last-child { margin-bottom: 0; }

.adv-arrival {
    display: flex; gap: 0.55rem; align-items: flex-start;
    padding: 0.55rem 0.65rem; border-left: 3px solid var(--accent-emphasis);
    background: var(--accent-subtle); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: var(--text-xs); color: var(--fg-default);
}
.adv-arrival .mud-icon-root { color: var(--accent-fg); font-size: var(--text-md); }
.adv-arrival div { display: flex; flex-direction: column; gap: 0.1rem; }
.adv-arrival span { color: var(--fg-muted); }
.adv-arrival--live { align-self: flex-start; max-width: 88%; }

.adv-options { display: grid; gap: 0.45rem; margin-top: 0.25rem; }
.adv-options button {
    display: flex; flex-direction: column; gap: 0.15rem; text-align: left;
    padding: 0.6rem 0.7rem; border: 1px solid var(--border-default);
    border-radius: var(--radius-md); background: var(--canvas-default); color: var(--fg-default);
    cursor: pointer;
}
.adv-options button:hover:not(:disabled) { border-color: var(--accent-emphasis); background: var(--accent-subtle); }
.adv-options button:disabled { opacity: 0.55; cursor: default; }
.adv-options strong { font-size: var(--text-sm); }
.adv-options span { font-size: var(--text-xs); color: var(--fg-muted); }
.adv-live-tools { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.adv-live-tools span { display: inline-flex; gap: 0.25rem; align-items: center; font-size: var(--text-2xs); color: var(--fg-muted); }
.adv-live-tools .mud-icon-root { font-size: var(--text-sm); }

.adv-plan-pane--empty { justify-content: center; align-items: center; text-align: center; color: var(--fg-muted); }
.adv-plan-pane--empty > .mud-icon-root { font-size: 2rem; color: var(--accent-fg); }
.adv-plan-pane--empty h2 { margin: 0.25rem 0 0; font-size: var(--text-lg); color: var(--fg-default); }
.adv-plan-pane--empty p { max-width: 24rem; margin: 0; font-size: var(--text-sm); line-height: 1.5; }
.adv-plan-empty { display: grid; place-items: center; gap: 0.4rem; padding: 2rem; color: var(--fg-muted); }
.adv-plan-empty p { margin: 0; font-size: var(--text-sm); }
.adv-plan-list { display: flex; flex-direction: column; gap: 0.6rem; }
.adv-plan-card {
    display: flex; flex-direction: column; gap: 0.5rem;
    padding: 0.7rem; border: 1px solid var(--border-muted);
    border-radius: var(--radius-md); background: var(--canvas-default);
}
.adv-plan-card--rejected { opacity: 0.6; }
.adv-plan-card--failed { border-color: var(--danger-muted); }
.adv-plan-card--committed { border-color: var(--success-muted); }
.adv-plan-card .adv-step-head { align-items: flex-start; }
.adv-plan-card .adv-step-main { display: flex; flex-direction: column; align-items: flex-start; gap: 0.2rem; }
.adv-step-critique {
    display: flex; gap: 0.45rem; padding: 0.55rem;
    border-left: 3px solid var(--warning-emphasis);
    background: var(--warning-subtle); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: var(--text-xs); color: var(--fg-default);
}
.adv-step-critique .mud-icon-root { font-size: var(--text-md); color: var(--warning-fg); }
.adv-step-critique .md-view > :first-child { margin-top: 0.15rem; }
.adv-step-critique .md-view > :last-child { margin-bottom: 0; }
.adv-plan-critiques { display: grid; gap: 0.5rem; margin-bottom: 0.75rem; }
.adv-json {
    margin: 0; padding: 0.6rem; overflow: auto; max-height: 18rem;
    border-radius: var(--radius-sm); background: var(--canvas-inset);
    color: var(--fg-default);  font-size: var(--text-2xs);
}
.adv-edit-error, .adv-step-error { color: var(--danger-fg); font-size: var(--text-xs); }
.adv-commit-box {
    position: sticky; bottom: 0; display: flex; flex-direction: column; align-items: stretch; gap: 0.45rem;
    margin-top: auto; padding-top: 0.8rem; border-top: 1px solid var(--border-muted);
    background: var(--canvas-subtle);
}
.adv-commit-box > span { color: var(--fg-muted); font-size: var(--text-xs); text-align: center; }
.adv-commit-done { display: flex; justify-content: center; align-items: center; gap: 0.4rem; color: var(--success-fg); font-size: var(--text-sm); font-weight: 600; }
.adv-mobile-switch { display: none; }

@media (max-width: 800px) {
    .adv-mobile-switch {
        display: grid; grid-template-columns: 1fr 1fr; gap: 0.25rem;
        padding: 0.25rem; margin-bottom: 0.65rem; border-radius: var(--radius-md);
        background: var(--canvas-inset);
    }
    .adv-mobile-switch button {
        display: flex; justify-content: center; gap: 0.35rem;
        padding: 0.5rem; border: 0; border-radius: var(--radius-sm);
        background: transparent; color: var(--fg-muted); font-size: var(--text-sm); cursor: pointer;
    }
    .adv-mobile-switch button.active { background: var(--canvas-default); color: var(--fg-default); font-weight: 600; }
    .adv-mobile-switch span { color: var(--fg-muted); }
    .adv-conversation { display: block; min-height: 0; }
    .adv-conversation .adv-plan-pane { border-left: 0; }
    .adv-conversation.adv-show-thread .adv-plan-pane,
    .adv-conversation.adv-show-plan .adv-thread-pane { display: none; }
    .adv-conversation--opening .adv-plan-pane { display: none; }
    .adv-message, .adv-message--live { max-width: 96%; width: auto; }
    .adv-compose-row { align-items: stretch; flex-direction: column; }
}
