/* ═══════════════════════════════════════════════════════════════════════════
   COPILOT — the right-hand sidebar (js/copilot/shell.js)

   Slides over the page from the right at --copilot-w: one of two fixed
   widths, standard or wide (no free resizing). No veil: the page stays usable.
   ═══════════════════════════════════════════════════════════════════════════ */

.copilot-panel {
    --copilot-w: 640px;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: var(--copilot-w);
    height: calc(100vh / var(--ui-zoom, 1));
    z-index: 80; /* under drawers (90+) so a record opened from a reply sits on top */
    display: flex;
    flex-direction: column;
    background: var(--color-card);
    color: var(--color-foreground);
    border-left: 1px solid var(--color-border);
    box-shadow: -18px 0 48px -24px rgba(15, 23, 42, 0.35);
    transform: translateX(calc(100% + 24px));
    transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: transform;
}
.copilot-panel[data-state="open"] { transform: translateX(0); }
/* Standard ↔ wide is a step, not a drag; the width change animates. */
.copilot-panel { opacity: 0.4; transition: transform 0.42s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease, box-shadow 0.42s ease, width 0.22s ease; }
.copilot-panel[data-state="open"] { opacity: 1; box-shadow: -24px 0 64px -24px rgba(15, 23, 42, 0.42); }
.cp-icon-btn [hidden], .cp-icon-btn[hidden] { display: none; }

/* Opening: once the panel is moving, its parts arrive one after another
   (header, then the conversation, then the box to type in), and the
   starter questions come in as a short cascade. Plays on every open. */
@keyframes cp-arrive { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
@keyframes cp-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes cp-pop { 0% { opacity: 0; transform: translateY(10px) scale(0.92); } 70% { opacity: 1; transform: translateY(-1px) scale(1.02); } 100% { transform: none; } }
.copilot-panel[data-state="open"] > .cp-header   { animation: cp-arrive 0.42s cubic-bezier(0.16, 1, 0.3, 1) 0.06s both; }
.copilot-panel[data-state="open"] > .cp-context  { animation: cp-arrive 0.42s cubic-bezier(0.16, 1, 0.3, 1) 0.1s both; }
.copilot-panel[data-state="open"] > .cp-scroll   { animation: cp-arrive 0.46s cubic-bezier(0.16, 1, 0.3, 1) 0.12s both; }
.copilot-panel[data-state="open"] > .cp-composer { animation: cp-rise 0.46s cubic-bezier(0.16, 1, 0.3, 1) 0.18s both; }
.copilot-panel[data-state="open"] .cp-starters > * { animation: cp-rise 0.4s cubic-bezier(0.16, 1, 0.3, 1) both; }
.copilot-panel[data-state="open"] .cp-starters > :nth-child(1) { animation-delay: 0.2s; }
.copilot-panel[data-state="open"] .cp-starters > :nth-child(2) { animation-delay: 0.25s; }
.copilot-panel[data-state="open"] .cp-starters > :nth-child(3) { animation-delay: 0.3s; }
.copilot-panel[data-state="open"] .cp-starters > :nth-child(4) { animation-delay: 0.35s; }
.copilot-panel[data-state="open"] .cp-starters > :nth-child(n+5) { animation-delay: 0.4s; }
/* The minimized dock pops up where the panel went. */
.copilot-dock:not([hidden]) { animation: cp-pop 0.38s cubic-bezier(0.16, 1, 0.3, 1) both; }

@media (prefers-reduced-motion: reduce) {
    .copilot-panel { transition: none; opacity: 1; }
    .copilot-panel[data-state="open"] > *, .copilot-panel[data-state="open"] .cp-starters > *, .copilot-dock:not([hidden]) { animation: none; }
}

/* ── Header ── */
.cp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    height: 52px;
    padding: 0 12px 0 18px;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}
.cp-title {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.cp-mark {
    width: 28px;
    height: 28px;
    display: inline-flex;
    flex-shrink: 0;
}

/* ── Nuva, the mascot: a round face with a sprout (a renewal is new growth).
   Same drawing in the header, the top-bar button and the minimized dock. ── */
.nuva-mascot { display: block; width: 100%; height: 100%; overflow: visible; }
.nuva-mascot .nuva-stem { fill: none; stroke: #10b981; stroke-width: 1.6; stroke-linecap: round; }
.nuva-mascot .nuva-leaf { fill: #10b981; }
.dark .nuva-mascot .nuva-stem { stroke: #34d399; }
.dark .nuva-mascot .nuva-leaf { fill: #34d399; }
.nuva-mascot .nuva-eye {
    transform-box: fill-box;
    transform-origin: center;
    animation: nuva-blink 6s infinite;
}
@keyframes nuva-blink {
    0%, 93%, 100% { transform: scaleY(1); }
    95% { transform: scaleY(0.12); }
}
.nuva-launch-mark { display: inline-flex; width: 18px; height: 18px; flex-shrink: 0; }
@media (prefers-reduced-motion: reduce) {
    .nuva-mascot .nuva-eye { animation: none; }
}
.cp-name {
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.2;
}
.cp-sub {
    font-size: 0.6875rem;
    color: var(--color-muted-foreground);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cp-actions {
    display: flex;
    align-items: center;
    gap: 2px;
}
.cp-icon-btn {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--color-muted-foreground);
    transition: background-color 0.15s ease, color 0.15s ease;
}
.cp-icon-btn:hover { background: var(--color-muted); color: var(--color-foreground); }
.cp-icon-btn:focus-visible { outline: 2px solid var(--color-ring); outline-offset: 1px; }
.cp-icon-btn svg { width: 16px; height: 16px; }
.cp-icon-btn[hidden] { display: none; }

/* ── Context line under the header ("Viewing: Acme") ── */
.cp-context {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 18px;
    font-size: 0.75rem;
    color: var(--color-text-info);
    background: var(--color-background-info);
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}
.dark .cp-context { background: rgba(96, 165, 250, 0.08); color: #93c5fd; }
.cp-context svg { width: 13px; height: 13px; flex-shrink: 0; }
.cp-context-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-context button { color: inherit; opacity: 0.7; font-size: 0.75rem; }
.cp-context button:hover { opacity: 1; }
.cp-context.hidden { display: none; }

/* ── Conversation column — readable measure, centred in a wide panel ── */
.cp-scroll {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
}
.cp-column {
    max-width: 780px;
    margin: 0 auto;
    padding: 20px 20px 8px;
}
.cp-scroll::-webkit-scrollbar { width: 6px; }
.cp-scroll::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 6px; }

/* ── Composer — compact: one 32px row, a one-line footnote ── */
.cp-composer {
    flex-shrink: 0;
    border-top: 1px solid color-mix(in srgb, var(--color-border) 60%, transparent);
    background: var(--color-card);
}
.cp-composer-inner {
    max-width: 780px;
    margin: 0 auto;
    padding: 8px 16px 6px;
    position: relative;
}
.cp-input-box {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    padding: 4px 4px 4px 12px;
    border: 1px solid var(--color-input);
    border-radius: 12px;
    background: var(--color-background);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.cp-input-box:focus-within {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 14%, transparent);
}
.cp-input-box textarea {
    flex: 1;
    min-height: 32px;
    max-height: 140px;
    padding: 6px 0;
    border: 0;
    outline: none;
    resize: none;
    background: transparent;
    color: var(--color-foreground);
    font-size: 0.8125rem;
    line-height: 1.5;
}
.cp-input-box textarea::placeholder { color: var(--color-muted-foreground); opacity: 0.7; }
.cp-send {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #fff;
    background: var(--color-primary);
    transition: opacity 0.15s ease, transform 0.1s ease;
}
.cp-send:hover { opacity: 0.9; }
.cp-send:active { transform: scale(0.96); }
.cp-send:disabled { opacity: 0.4; cursor: default; }
.cp-send svg { width: 15px; height: 15px; }
.cp-footnote {
    margin-top: 4px;
    text-align: center;
    font-size: 0.625rem;
    line-height: 1.3;
    color: var(--color-muted-foreground);
    opacity: 0.7;
}

/* ── Minimized dock — brings the panel back exactly as it was ── */
.copilot-dock {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 79;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 16px 0 12px;
    border-radius: 9999px;
    border: 1px solid var(--color-border);
    background: var(--color-card);
    color: var(--color-foreground);
    font-size: 0.8125rem;
    font-weight: 500;
    box-shadow: 0 8px 24px -8px rgba(15, 23, 42, 0.35);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.copilot-dock[hidden] { display: none; }
.copilot-dock:hover { transform: translateY(-1px); box-shadow: 0 10px 28px -8px rgba(15, 23, 42, 0.45); }
.copilot-dock svg { width: 16px; height: 16px; color: #6366f1; }
.copilot-dock .nuva-mascot { width: 20px; height: 20px; }
.cp-dock-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: transparent;
}
.copilot-dock[data-activity="busy"] .cp-dock-dot {
    background: #f59e0b;
    animation: cp-pulse 1.4s ease-in-out infinite;
}
.copilot-dock[data-activity="unread"] .cp-dock-dot { background: #10b981; }
@keyframes cp-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

/* ── Welcome chips ── */
.ai-quick-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border-radius: 10px;
    font-size: 0.8125rem;
    font-weight: 500;
    border: 1px solid var(--color-border);
    background: var(--color-card);
    color: var(--color-foreground);
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease;
    text-align: left;
}
.ai-quick-chip:hover { border-color: var(--color-primary); color: var(--color-primary); }
#ai-welcome-block { padding-top: calc(12vh / var(--ui-zoom, 1)); }
#ai-welcome-block.hidden { display: none; }

/* ── Messages ── */
.cp-msg { margin-bottom: 22px; animation: cp-in 0.2s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes cp-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .cp-msg { animation: none; } }

.cp-msg-user { display: flex; justify-content: flex-end; }
.cp-user-bubble {
    max-width: 85%;
    padding: 9px 14px;
    border-radius: 16px 16px 4px 16px;
    background: var(--color-muted);
    color: var(--color-foreground);
    font-size: 0.875rem;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* Steps: live while the reply is written, one summary line afterwards */
.cp-steps {
    margin-bottom: 10px;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    background: var(--color-background);
    overflow: hidden;
}
.cp-steps[hidden] { display: none; }
.cp-steps-head {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 7px 10px;
    font-size: 0.75rem;
    color: var(--color-muted-foreground);
    text-align: left;
}
.cp-steps-head:hover { color: var(--color-foreground); }
.cp-steps-icon { width: 14px; height: 14px; flex-shrink: 0; }
.cp-steps-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-steps-chev { width: 14px; height: 14px; transition: transform 0.15s ease; }
.cp-steps[data-open="false"] .cp-steps-chev { transform: rotate(-90deg); }
.cp-steps[data-open="false"] .cp-steps-list { display: none; }
.cp-steps-list { margin: 0; padding: 2px 10px 8px; list-style: none; }
.cp-steps-list:empty { display: none; }
.cp-step {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 4px 0;
    font-size: 0.75rem;
}
.cp-step-icon { width: 13px; height: 13px; margin-top: 2px; flex-shrink: 0; }
.cp-step[data-status="done"] .cp-step-icon { color: var(--color-success); }
.cp-step[data-status="error"] .cp-step-icon { color: var(--color-error); }
.cp-step[data-status="running"] .cp-step-icon { color: var(--color-primary); }
.cp-step[data-status="retried"] .cp-step-icon { color: var(--color-warning); }
.cp-step-body { flex: 1; min-width: 0; }
.cp-step-label { color: var(--color-foreground); }
.cp-step-detail { color: var(--color-muted-foreground); margin-top: 1px; }
.cp-step-ms { color: var(--color-muted-foreground); font-variant-numeric: tabular-nums; flex-shrink: 0; }

/* The answer — no bubble: a reply reads like a page */
.prose-cp { font-size: 0.875rem; line-height: 1.65; color: var(--color-foreground); overflow-wrap: anywhere; }
.prose-cp:empty { display: none; }
.prose-cp > :first-child { margin-top: 0; }
.prose-cp > :last-child { margin-bottom: 0; }
.prose-cp p { margin: 0 0 0.65em; }
.prose-cp h1, .prose-cp h2, .prose-cp h3 { font-weight: 600; line-height: 1.3; margin: 1em 0 0.4em; }
.prose-cp h1 { font-size: 1.05rem; }
.prose-cp h2 { font-size: 1rem; }
.prose-cp h3 { font-size: 0.9rem; }
.prose-cp ul, .prose-cp ol { margin: 0.3em 0 0.7em; padding-left: 1.3em; }
.prose-cp ul { list-style: disc; }
.prose-cp ol { list-style: decimal; }
.prose-cp li { margin: 0.15em 0; }
.prose-cp strong { font-weight: 600; }
.prose-cp a { color: var(--color-primary); text-decoration: underline; text-underline-offset: 2px; }
.prose-cp code {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 0.8em;
    padding: 0.1em 0.35em;
    border-radius: 4px;
    background: var(--color-muted);
}
.prose-cp pre { padding: 10px 12px; border-radius: 8px; background: var(--color-muted); overflow-x: auto; margin: 0.5em 0; }
.prose-cp pre code { padding: 0; background: none; }
.prose-cp blockquote { margin: 0.5em 0; padding-left: 10px; border-left: 3px solid var(--color-border); color: var(--color-muted-foreground); }
.prose-cp table { width: 100%; border-collapse: collapse; margin: 0.6em 0; font-size: 0.8125rem; display: block; overflow-x: auto; }
.prose-cp th, .prose-cp td { padding: 6px 10px; border-bottom: 1px solid var(--color-border); text-align: left; white-space: nowrap; }
.prose-cp th { font-weight: 600; color: var(--color-muted-foreground); font-size: 0.75rem; }
.prose-cp.is-streaming > :last-child::after {
    content: "";
    display: inline-block;
    width: 7px;
    height: 1em;
    margin-left: 2px;
    vertical-align: -2px;
    background: var(--color-primary);
    opacity: 0.6;
    animation: cp-pulse 1s steps(2) infinite;
}

.cp-display:empty, .cp-msg-foot:empty { display: none; }
.cp-display { margin-top: 10px; display: flex; flex-direction: column; gap: 10px; }
.cp-msg-foot { margin-top: 8px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.cp-error { display: inline-flex; align-items: flex-start; gap: 6px; font-size: 0.8125rem; color: var(--color-error); }
.cp-error svg { width: 15px; height: 15px; margin-top: 2px; flex-shrink: 0; }
.cp-muted { font-size: 0.75rem; color: var(--color-muted-foreground); }
.cp-link-btn { font-size: 0.8125rem; color: var(--color-primary); text-decoration: underline; text-underline-offset: 2px; }

/* ── Cards (a proposed change, confirmed by the button) ── */
.cp-card {
    --tone: var(--color-primary);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    background: var(--color-card);
    overflow: hidden;
    max-width: 560px;
}
.cp-card[data-tone="violet"] { --tone: #7c3aed; }
.cp-card[data-tone="green"] { --tone: #059669; }
.cp-card[data-tone="orange"] { --tone: #ea580c; }
.cp-card[data-tone="cyan"] { --tone: #0891b2; }
.cp-card[data-tone="teal"] { --tone: #0d9488; }
.cp-card-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--color-foreground);
    border-bottom: 1px solid var(--color-border);
    background: var(--color-background);
}
.cp-card-head svg { width: 14px; height: 14px; color: var(--tone); }
.cp-card-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.cp-card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cp-card-label { font-size: 0.6875rem; color: var(--color-muted-foreground); margin-bottom: 2px; }
.cp-card-value { font-size: 0.8125rem; font-weight: 500; overflow-wrap: anywhere; }
.cp-card-pre {
    font-size: 0.8125rem;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    max-height: 200px;
    overflow-y: auto;
    padding: 8px 10px;
    border-radius: 8px;
    background: var(--color-background);
}
.cp-card-foot {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 10px 14px;
    border-top: 1px solid var(--color-border);
}
.cp-card-status { flex: 1; font-size: 0.75rem; color: var(--color-muted-foreground); }
.cp-card[data-state="error"] .cp-card-status { color: var(--color-error); }
.cp-card[data-state="done"] { border-color: color-mix(in srgb, var(--color-success) 40%, var(--color-border)); }
.cp-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 14px;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 500;
    border: 1px solid var(--color-border);
    background: var(--color-card);
    color: var(--color-foreground);
    transition: opacity 0.15s ease, background-color 0.15s ease;
}
.cp-btn svg { width: 14px; height: 14px; }
.cp-btn:disabled { opacity: 0.6; cursor: default; }
.cp-btn-primary { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-primary-foreground); }
.cp-btn-primary:hover:not(:disabled) { opacity: 0.9; }
.cp-card[data-state="done"] .cp-btn-primary { background: var(--color-success); border-color: var(--color-success); }

/* Send turns into Stop while a reply is being written */
.cp-send.is-stop { background: var(--color-foreground); color: var(--color-card); }

/* ── History (over the conversation) ── */
.cp-history {
    position: absolute;
    top: 52px;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 3;
    overflow-y: auto;
    background: var(--color-card);
    padding: 16px 20px;
}
.cp-history[hidden] { display: none; }
.cp-history-title { font-size: 0.75rem; font-weight: 600; color: var(--color-muted-foreground); margin: 0 auto 8px; max-width: 780px; }
.cp-history-list { list-style: none; margin: 0 auto; padding: 0; max-width: 780px; }
.cp-history-item { display: flex; align-items: center; gap: 4px; border-radius: 10px; }
.cp-history-item:hover, .cp-history-item.is-current { background: var(--color-muted); }
.cp-history-open { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; padding: 9px 12px; text-align: left; }
.cp-history-name { font-size: 0.8125rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-history-meta { font-size: 0.6875rem; color: var(--color-muted-foreground); }
.cp-history-del { opacity: 0; }
.cp-history-item:hover .cp-history-del, .cp-history-del:focus-visible { opacity: 1; }
.cp-history-empty { font-size: 0.8125rem; color: var(--color-muted-foreground); text-align: center; padding: 40px 0; }

/* ═══════════════════════════════════════════════════════════════════════════
   A2UI surfaces (js/copilot/a2ui/surface.js) — the Copilot catalog
   ═══════════════════════════════════════════════════════════════════════════ */
.cp-surface {
    /* Categorical series slots (fixed order) and reserved status tones. */
    --viz-1: #2a78d6; --viz-2: #eb6834; --viz-3: #1baf7a; --viz-4: #eda100;
    --viz-5: #e87ba4; --viz-6: #008300; --viz-7: #6250d6; --viz-8: #e34948;
    --viz-good: #0ca30c; --viz-warning: #fab219; --viz-critical: #d03b3b; --viz-neutral: #898781;
    --viz-grid: #e1e0d9; --viz-axis: #c3c2b7; --viz-muted: #898781;
    --tone-good-bg: #e7f6e7; --tone-good-fg: #006300;
    --tone-warning-bg: #fff4d6; --tone-warning-fg: #7a5300;
    --tone-critical-bg: #fde8e8; --tone-critical-fg: #a82727;
    --tone-info-bg: var(--color-background-info); --tone-info-fg: var(--color-text-info);
    --tone-neutral-bg: var(--color-muted); --tone-neutral-fg: var(--color-muted-foreground);
    max-width: 100%;
    font-size: 0.8125rem;
}
.dark .cp-surface {
    --viz-1: #3987e5; --viz-2: #d95926; --viz-3: #199e70; --viz-4: #c98500;
    --viz-5: #d55181; --viz-6: #0ca30c; --viz-7: #9085e9; --viz-8: #e66767;
    --viz-grid: #2c2c2a; --viz-axis: #383835;
    --tone-good-bg: rgba(12, 163, 12, 0.16); --tone-good-fg: #5fd35f;
    --tone-warning-bg: rgba(250, 178, 25, 0.16); --tone-warning-fg: #fac65a;
    --tone-critical-bg: rgba(208, 59, 59, 0.2); --tone-critical-fg: #f08a8a;
    --tone-info-bg: rgba(96, 165, 250, 0.14); --tone-info-fg: #93c5fd;
}
.cp-surface svg[data-lucide], .cp-surface i[data-lucide] + svg, .cp-a-icon svg { width: 15px; height: 15px; }

.cp-a-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; }
.cp-a-col { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.cp-a-row > * { min-width: 0; }
.cp-a-card {
    border: 1px solid var(--color-border);
    border-radius: 12px;
    background: var(--color-card);
    padding: 14px 16px;
}
.cp-a-text.prose-cp { font-size: 0.8125rem; }
.cp-a-text.prose-cp h3 { margin: 0; font-size: 0.95rem; }
.cp-a-caption { font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.02em; color: var(--color-muted-foreground); }
.cp-a-caption:empty { display: none; }
.cp-a-divider { border: 0; border-top: 1px solid var(--color-border); margin: 2px 0; width: 100%; }
.cp-a-divider.is-vertical { border-top: 0; border-left: 1px solid var(--color-border); width: 0; align-self: stretch; }
.cp-a-icon { display: inline-flex; color: var(--color-muted-foreground); }
.cp-a-image.is-feature { max-width: 100%; border-radius: 8px; }
.cp-a-image.is-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.cp-a-btn.is-borderless { border-color: transparent; background: transparent; color: var(--color-primary); padding: 0 8px; }
.cp-a-btn.is-borderless:hover:not(:disabled) { background: var(--color-muted); }
.cp-a-btn > .prose-cp, .cp-a-btn .cp-a-text { font-size: inherit; color: inherit; }
.cp-a-btn .cp-a-text p { margin: 0; }

/* Metrics: value leads, label follows */
.cp-a-metric {
    flex: 1 1 120px;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--color-background);
    border: 1px solid var(--color-border);
}
.cp-a-metric-label { font-size: 0.6875rem; color: var(--color-muted-foreground); }
.cp-a-metric-value { font-size: 1.125rem; font-weight: 600; line-height: 1.3; margin-top: 2px; }
.cp-a-metric-hint { font-size: 0.6875rem; color: var(--color-muted-foreground); margin-top: 2px; }
.cp-a-metric.is-critical { box-shadow: inset 3px 0 0 var(--viz-critical); }
.cp-a-metric.is-warning { box-shadow: inset 3px 0 0 var(--viz-warning); }
.cp-a-metric.is-good { box-shadow: inset 3px 0 0 var(--viz-good); }

.cp-a-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 600;
    white-space: nowrap;
    background: var(--tone-neutral-bg);
    color: var(--tone-neutral-fg);
}
.cp-a-badge svg { width: 12px; height: 12px; }
.cp-a-badge.is-good { background: var(--tone-good-bg); color: var(--tone-good-fg); }
.cp-a-badge.is-warning { background: var(--tone-warning-bg); color: var(--tone-warning-fg); }
.cp-a-badge.is-critical { background: var(--tone-critical-bg); color: var(--tone-critical-fg); }
.cp-a-badge.is-info { background: var(--tone-info-bg); color: var(--tone-info-fg); }

.cp-a-kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0; }
.cp-a-kv dt { color: var(--color-muted-foreground); font-size: 0.75rem; }
.cp-a-kv dd { margin: 0; font-size: 0.8125rem; overflow-wrap: anywhere; }

.cp-a-table { overflow-x: auto; border: 1px solid var(--color-border); border-radius: 10px; }
.cp-a-table table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
.cp-a-table th {
    text-align: left;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--color-muted-foreground);
    padding: 8px 12px;
    background: var(--color-background);
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}
.cp-a-table td { padding: 8px 12px; border-bottom: 1px solid var(--color-border); white-space: nowrap; }
.cp-a-table tr:last-child td { border-bottom: 0; }
.cp-a-table .is-num { text-align: right; font-variant-numeric: tabular-nums; }
.cp-a-table tr.is-clickable { cursor: pointer; }
.cp-a-table tr.is-clickable:hover td, .cp-a-table tr.is-clickable:focus-visible td { background: var(--color-muted); }
.cp-a-table tr.is-clickable:focus-visible { outline: 2px solid var(--color-ring); outline-offset: -2px; }
.cp-a-empty { padding: 14px; text-align: center; color: var(--color-muted-foreground); font-size: 0.8125rem; }

.cp-a-progress-top { display: flex; justify-content: space-between; font-size: 0.75rem; margin-bottom: 4px; }
.cp-a-progress-pct { color: var(--color-muted-foreground); font-variant-numeric: tabular-nums; }
.cp-a-progress-track { height: 6px; border-radius: 3px; background: var(--color-muted); overflow: hidden; }
.cp-a-progress-fill { height: 100%; border-radius: 3px; background: var(--viz-1); }
.cp-a-progress.is-good .cp-a-progress-fill { background: var(--viz-good); }
.cp-a-progress.is-warning .cp-a-progress-fill { background: var(--viz-warning); }
.cp-a-progress.is-critical .cp-a-progress-fill { background: var(--viz-critical); }

.cp-a-timeline { list-style: none; margin: 0; padding: 0; }
.cp-a-timeline li { position: relative; display: flex; gap: 10px; padding: 0 0 12px 0; }
.cp-a-timeline li:not(:last-child)::before {
    content: "";
    position: absolute;
    left: 4px;
    top: 14px;
    bottom: 0;
    width: 1px;
    background: var(--color-border);
}
.cp-a-tl-dot { width: 9px; height: 9px; margin-top: 4px; border-radius: 50%; background: var(--viz-neutral); flex-shrink: 0; box-shadow: 0 0 0 2px var(--color-card); }
.cp-a-timeline li.is-good .cp-a-tl-dot { background: var(--viz-good); }
.cp-a-timeline li.is-warning .cp-a-tl-dot { background: var(--viz-warning); }
.cp-a-timeline li.is-critical .cp-a-tl-dot { background: var(--viz-critical); }
.cp-a-tl-body { flex: 1; min-width: 0; }
.cp-a-tl-head { display: flex; justify-content: space-between; gap: 10px; }
.cp-a-tl-title { font-weight: 500; overflow-wrap: anywhere; }
.cp-a-tl-date { color: var(--color-muted-foreground); font-size: 0.6875rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cp-a-tl-detail { color: var(--color-muted-foreground); font-size: 0.75rem; margin-top: 2px; overflow-wrap: anywhere; }

.cp-a-callout { display: flex; gap: 8px; padding: 10px 12px; border-radius: 10px; background: var(--tone-neutral-bg); color: var(--color-foreground); }
.cp-a-callout svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 1px; }
.cp-a-callout.is-critical { background: var(--tone-critical-bg); }
.cp-a-callout.is-warning { background: var(--tone-warning-bg); }
.cp-a-callout.is-good { background: var(--tone-good-bg); }
.cp-a-callout.is-info { background: var(--tone-info-bg); }

.cp-a-tabbar { display: flex; gap: 2px; border-bottom: 1px solid var(--color-border); margin-bottom: 10px; }
.cp-a-tab { padding: 6px 10px; font-size: 0.75rem; color: var(--color-muted-foreground); border-bottom: 2px solid transparent; }
.cp-a-tab[aria-selected="true"] { color: var(--color-foreground); border-bottom-color: var(--color-primary); }

/* Inputs in a card */
.cp-a-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cp-a-label { font-size: 0.6875rem; color: var(--color-muted-foreground); }
.cp-a-input {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--color-input);
    border-radius: 8px;
    background: var(--color-background);
    color: var(--color-foreground);
    font-size: 0.8125rem;
    line-height: 1.45;
    resize: vertical;
}
.cp-a-input:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15); }
.cp-a-input:read-only { opacity: 0.7; }
.cp-a-check { display: inline-flex; align-items: center; gap: 8px; font-size: 0.8125rem; }
.cp-a-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cp-a-chip {
    padding: 4px 10px;
    border-radius: 9999px;
    border: 1px solid var(--color-border);
    font-size: 0.75rem;
    color: var(--color-foreground);
    background: var(--color-card);
}
.cp-a-chip[aria-pressed="true"] { border-color: var(--color-primary); background: var(--tone-info-bg); color: var(--tone-info-fg); font-weight: 500; }

/* Charts */
.cp-viz { margin: 0; border: 1px solid var(--color-border); border-radius: 12px; padding: 12px 14px; background: var(--color-card); }
.cp-viz-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.cp-viz-title { font-size: 0.8125rem; font-weight: 600; }
.cp-viz-toggle { font-size: 0.6875rem; color: var(--color-muted-foreground); padding: 2px 8px; border: 1px solid var(--color-border); border-radius: 6px; }
.cp-viz-toggle:hover { color: var(--color-foreground); }
.cp-viz-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-bottom: 6px; font-size: 0.75rem; color: var(--color-muted-foreground); }
.cp-viz-key { display: inline-flex; align-items: center; gap: 6px; }
.cp-viz-swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.cp-viz-swatch.is-line { height: 2px; width: 14px; border-radius: 1px; }
.cp-viz-plot { position: relative; width: 100%; }
.cp-viz-plot svg { display: block; overflow: visible; }
.cp-viz-grid { stroke: var(--viz-grid); stroke-width: 1; }
.cp-viz-base { stroke: var(--viz-axis); stroke-width: 1; }
.cp-viz-cross { stroke: var(--viz-axis); stroke-width: 1; }
.cp-viz-tick { fill: var(--viz-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.cp-viz-label { fill: var(--color-foreground); font-size: 12px; }
.cp-viz-value { fill: var(--color-muted-foreground); font-size: 11px; font-variant-numeric: tabular-nums; }
.cp-viz-hero { fill: var(--color-foreground); font-size: 18px; font-weight: 600; }
.cp-viz-mark { transition: opacity 0.12s ease; }
.cp-viz-mark.is-hover { opacity: 0.8; }
.cp-viz-dot { stroke: var(--color-card); stroke-width: 2; }
.cp-viz-tip {
    position: absolute;
    z-index: 2;
    pointer-events: none;
    min-width: 120px;
    padding: 8px 10px;
    border-radius: 8px;
    background: var(--color-popover);
    border: 1px solid var(--color-border);
    box-shadow: 0 8px 20px -8px rgba(15, 23, 42, 0.35);
    font-size: 0.75rem;
}
.cp-viz-tip[hidden] { display: none; }
.cp-viz-tip-title { color: var(--color-muted-foreground); margin-bottom: 4px; }
.cp-viz-tip-row { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.cp-viz-tip-row span { color: var(--color-muted-foreground); }
.cp-viz-tip-key { width: 10px; height: 2px; border-radius: 1px; }
.cp-viz-table table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
.cp-viz-table th, .cp-viz-table td { padding: 6px 8px; border-bottom: 1px solid var(--color-border); text-align: left; }
.cp-viz-table .is-num { text-align: right; font-variant-numeric: tabular-nums; }
.cp-viz-table[hidden], .cp-viz-plot[hidden] { display: none; }
.cp-viz-empty { color: var(--color-muted-foreground); font-size: 0.8125rem; padding: 16px 0; text-align: center; }

/* ── Starter questions (page-aware) and follow-up suggestions ── */
.cp-starters { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.cp-starters .ai-quick-chip svg { width: 15px; height: 15px; color: var(--color-primary); flex-shrink: 0; }
.cp-suggest { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
.cp-suggest-chip {
    padding: 5px 12px;
    border-radius: 9999px;
    border: 1px solid var(--color-border);
    background: var(--color-card);
    color: var(--color-foreground);
    font-size: 0.75rem;
    text-align: left;
    transition: border-color 0.15s ease, color 0.15s ease;
}
.cp-suggest-chip:hover { border-color: var(--color-primary); color: var(--color-primary); }

/* ── Voice ── */
.cp-input-box[hidden], .cp-voicebar[hidden], .cp-mic[hidden] { display: none; }
.cp-mic {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--color-muted-foreground);
    transition: background-color 0.15s ease, color 0.15s ease;
}
.cp-mic:hover { background: var(--color-muted); color: var(--color-primary); }
.cp-mic.is-unavailable { opacity: 0.45; cursor: help; }
.cp-mic.is-unavailable:hover { background: transparent; color: inherit; }
.cp-mic svg { width: 16px; height: 16px; }

/* The voice bar takes the input's place at the same height: a flowing wave
   (js/copilot/voice-wave.js) that follows whoever is talking, the state in a
   word, and two round buttons. */
.cp-voicebar {
    --cp-wave-1: #3b82f6; --cp-wave-2: #a855f7; --cp-wave-3: #ec4899;
    display: flex;
    align-items: center;
    gap: 6px;
    height: 42px;
    padding: 0 5px 0 4px;
    border: 1px solid color-mix(in srgb, var(--color-primary) 25%, var(--color-input));
    border-radius: 12px;
    background: var(--color-background);
}
.dark .cp-voicebar { --cp-wave-1: #60a5fa; --cp-wave-2: #c084fc; --cp-wave-3: #f472b6; }
.cp-voice-wave { flex: 1; min-width: 0; height: 100%; display: block; margin-left: 8px; }
.cp-voicebar[data-state="connecting"] .cp-voice-wave,
.cp-voicebar[data-state="muted"] .cp-voice-wave { opacity: 0.35; filter: grayscale(1); transition: opacity 0.2s ease; }
.cp-voice-state {
    flex-shrink: 0;
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--color-muted-foreground);
    white-space: nowrap;
    padding-right: 2px;
}
.cp-voice-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--color-muted-foreground);
    background: var(--color-muted);
    transition: background-color 0.15s ease, color 0.15s ease;
}
.cp-voice-btn:hover { color: var(--color-foreground); }
.cp-voice-btn svg { width: 15px; height: 15px; }
.cp-voice-btn[aria-pressed="true"] { color: var(--color-primary); background: color-mix(in srgb, var(--color-primary) 14%, transparent); }
.cp-voice-end { color: var(--color-error); background: color-mix(in srgb, var(--color-error) 10%, transparent); }
.cp-voice-end:hover { color: #fff; background: var(--color-error); }
.cp-user-bubble.is-voice::before { content: "🎙 "; }
.cp-user-bubble:empty::after { content: "…"; color: var(--color-muted-foreground); }
.cp-notice { text-align: center; font-size: 0.75rem; color: var(--color-muted-foreground); margin: 4px 0 18px; }
.cp-a-table td.is-wrap { white-space: normal; min-width: 200px; color: var(--color-muted-foreground); font-size: 0.75rem; line-height: 1.45; }
.cp-a-table td:first-child { font-weight: 500; }

/* Items: what an answer's lists and paragraphs become */
.cp-a-items { list-style: none; margin: 0; padding: 0; border: 1px solid var(--color-border); border-radius: 12px; background: var(--color-card); overflow: hidden; }
.cp-a-item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--color-border); }
.cp-a-item:last-child { border-bottom: 0; }
.cp-a-item-body { flex: 1; min-width: 0; }
.cp-a-item-title { font-size: 0.8125rem; font-weight: 600; overflow-wrap: anywhere; }
.cp-a-item-detail { font-size: 0.75rem; color: var(--color-muted-foreground); margin-top: 2px; line-height: 1.5; overflow-wrap: anywhere; }
.cp-a-item-title p, .cp-a-item-detail p { margin: 0; }
.cp-a-item-detail a, .cp-a-item-title a { color: var(--color-primary); }
.cp-a-item > svg { width: 15px; height: 15px; color: var(--color-muted-foreground); flex-shrink: 0; }
.cp-a-item.is-clickable { cursor: pointer; }
.cp-a-item.is-clickable:hover, .cp-a-item.is-clickable:focus-visible { background: var(--color-muted); outline: none; }

/* Metric cards in a row: an even grid — equal widths and heights, labels on
   one line (full text on hover), values on one baseline. Four across when
   there is room, two when the panel is narrow. */
.cp-a-row.is-metrics {
    display: grid;
    grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr));
    gap: 10px;
    align-items: stretch;
    grid-auto-rows: 1fr;
}
@container (max-width: 520px) {
    .cp-a-row.is-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.cp-column { container-type: inline-size; }
.cp-a-row.is-metrics > .cp-a-metric { flex: none; min-width: 0; display: flex; flex-direction: column; }
.cp-a-metric-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cp-a-metric-value { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
