:root {
    color-scheme: light dark;
    --bg: #0f1115;
    --fg: #e8eaed;
    --muted: #9aa0a6;
    --accent: #6ea8fe;
    --surface: #1a1d23;
    --surface-2: #232730;
    --border: #2a2f3a;
    /* Scrollbar: quiet chrome that matches the shell, not OS default white. */
    --scrollbar-size: 8px;
    --scrollbar-thumb: #2a2f3a;
    --scrollbar-thumb-hover: #3d4452;
    --scrollbar-track: transparent;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    height: 100%;
}

/* Windows MAUI host: +25% type (15px → 18.75px) so chat prose reads desktop-native.
   Rem-based UI scales with the root. Web host keeps the 15px baseline. */
html.telos-host-maui,
html.telos-host-maui body {
    font-size: 18.75px;
}

/* ── Scrollbars (WebView2 / Chromium + Firefox) ─────────────────────────
   Thin, track-less, border-colored thumb — sits in the dark shell instead of
   the OS light track that dominated the Windows chat transcript. */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

*::-webkit-scrollbar {
    width: var(--scrollbar-size);
    height: var(--scrollbar-size);
}

*::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

*::-webkit-scrollbar-thumb {
    background-color: var(--scrollbar-thumb);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
    background-color: var(--scrollbar-thumb-hover);
}

*::-webkit-scrollbar-corner {
    background: transparent;
}

/* Chat transcript surface: slightly wider hit target, still quiet. */
.telos-surface::-webkit-scrollbar {
    width: 10px;
}

/* MAUI BlazorWebView mounts into #app; Web renders Routes straight into body.
   Both need a full-height flex root so chat can pin the composer. */
body {
    min-height: 100%;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

body > #app {
    flex: 1 1 auto;
    min-height: 100%;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* Chat page: lock the viewport so the composer sits above the footer
   even when the surface has little content. Other pages keep normal scroll. */
html:has(.telos-chat),
body:has(.telos-chat) {
    height: 100%;
    height: 100dvh;
    overflow: hidden;
}

body:has(.telos-chat) > #app {
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

/* Blazor unhandled-error strip. Must start hidden — framework only sets
   display:block when a circuit error fires. Without this rule the banner
   is always visible at the bottom of the page. */
#blazor-error-ui {
    background: #3a2424;
    border-top: 1px solid #6a3a3a;
    bottom: 0;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.35);
    color: #f0c0c0;
    display: none;
    left: 0;
    padding: 0.65rem 2.5rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    box-sizing: border-box;
    font-size: 0.9rem;
}

#blazor-error-ui .reload {
    color: var(--accent);
    margin-left: 0.5rem;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.85rem;
    top: 0.55rem;
    color: var(--muted);
    text-decoration: none;
}

.telos-shell {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 100%;
    min-height: 100dvh;
    width: 100%;
}

/* Chat: shell fills the flex root; main scrolls inside, composer pins. */
.telos-shell:has(.telos-chat) {
    flex: 1 1 auto;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
}

.telos-container {
    max-width: 880px;
    width: 100%;
    margin: 0 auto;
    padding-left: 2rem;
    padding-right: 2rem;
    box-sizing: border-box;
}

.telos-header {
    flex-shrink: 0;
    padding: 0.75rem 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.telos-header-inner {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.telos-brand {
    font-weight: 600;
    font-size: 1.15rem;
    color: var(--fg);
    text-decoration: none;
}

.telos-nav {
    display: flex;
    gap: 1rem;
}

.telos-nav-link {
    color: var(--muted);
    text-decoration: none;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.telos-nav-link:hover {
    color: var(--fg);
    background: var(--surface-2);
}

.telos-nav-link.active {
    color: var(--accent);
}

.telos-nav-muted {
    color: var(--muted);
    padding: 0.25rem 0.5rem;
}

.telos-main {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding-top: 1.25rem;
    padding-bottom: 0;
}

/* Body column fills main so chat can stretch and pin the composer. */
.telos-main > .telos-container {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.telos-shell:has(.telos-chat) .telos-main,
.telos-shell:has(.telos-chat) .telos-main > .telos-container {
    overflow: hidden;
}

.telos-footer {
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.5rem 1.25rem;
    padding: 0.75rem 1.5rem;
    color: var(--muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
    text-align: center;
}

.telos-footer-version {
    font-variant-numeric: tabular-nums;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    letter-spacing: 0.02em;
}

.telos-login-form {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    max-width: 22rem;
    margin-top: 1rem;
}

.telos-login-input {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--fg);
    border-radius: 8px;
    padding: 0.65rem 0.85rem;
    font-size: 1rem;
}

.telos-login-input:focus {
    outline: none;
    border-color: var(--accent);
}

.telos-lead {
    color: var(--muted);
    font-size: 1.05rem;
    margin-bottom: 2rem;
}

.telos-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.telos-card {
    display: block;
    padding: 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--fg);
    text-decoration: none;
    transition: border-color 0.15s ease;
}

.telos-card:hover {
    border-color: var(--accent);
}

.telos-card h2 {
    margin: 0 0 0.5rem 0;
    font-size: 1.05rem;
}

.telos-card p {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

/* ── Immersive chat surface (Slice A) ───────────────────────────── */
/* Fills main between header and footer; surface scrolls, composer stays put. */
.telos-chat {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    width: 100%;
}

/* Pinned question — stays as context while you read the response. */
.telos-qbar {
    flex-shrink: 0;
    z-index: 20;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 0.85rem 0 0.7rem;
    margin-bottom: 0.5rem;
}

.telos-qbar-text {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--fg);
    line-height: 1.35;
}

.telos-qbar-interp {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 0.2rem;
}

.telos-qbar-interp em { color: var(--accent); font-style: italic; }

/* The response surface — scrolls between qbar and composer. */
.telos-surface {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-bottom: 1rem;
    scrollbar-gutter: stable;
}

.telos-greeting {
    color: var(--muted);
    margin-top: 2rem;
}

.telos-greeting code {
    background: var(--surface-2);
    padding: 0.05rem 0.35rem;
    border-radius: 4px;
}

.telos-answer { margin: 0 0 2.25rem; }

/* Older answers recede so the current one reads as the focus. */
.telos-answer-past { opacity: 0.62; }
.telos-answer-past:hover { opacity: 1; }

.telos-answer-q {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--muted);
    margin: 0 0 0.6rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* Telos prose — generous, readable; this is the whole experience. */
.telos-p {
    font-size: 1.06rem;
    line-height: 1.7;
    margin: 0 0 1rem;
    color: var(--fg);
    animation: telos-fade-in 0.25s ease-out;
}

@keyframes telos-fade-in {
    from { opacity: 0; transform: translateY(0.25rem); }
    to { opacity: 1; transform: none; }
}

/* Typewriter reveal — each word fades in on its own staggered delay so the
   answer types out word-by-word (chat UX). The inline animation-delay is set
   per word in ChatMarkup.TypewriterParagraphs; this just defines the motion. */
.telos-tw {
    opacity: 0;
    animation: telos-tw-in 0.1s ease forwards;
}

@keyframes telos-tw-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Derived insights — set apart from the grounded facts. */
.telos-insights {
    margin-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.telos-insights-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: 0.7rem 0 0.5rem;
}

.telos-insights-label {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--accent);
}

.telos-insights-off {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 0.78rem;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
    padding: 0;
}

.telos-insights-off:hover { color: var(--fg); }

.telos-insight-p { color: #c8cdd6; }

/* Resolved subject mark (chat UX D): faint underline, no popup — just shows
   who/what the answer is about. */
.telos-subject {
    border-bottom: 1px dotted var(--muted);
}

/* Optional concept popover (only when ConceptHint.Summary is non-empty).
   Pop is reparented to <body> by JS so .telos-surface overflow cannot clip it. */
.telos-concept {
    position: relative;
    border-bottom: 1px dotted var(--muted);
    cursor: help;
}

.telos-concept:hover,
.telos-concept:focus,
.telos-concept.is-pop-open { border-bottom-color: var(--accent); outline: none; }

/* Lives under .telos-concept in the markup; JS reparents to <body> while open
   so .telos-surface's overflow-y:auto cannot clip it (fixed alone is not enough). */
.telos-concept-pop {
    position: fixed;
    top: 0;
    left: 0;
    min-width: 11rem;
    max-width: min(22rem, calc(100vw - 1rem));
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem 0.7rem;
    font-size: 0.85rem;
    font-weight: 400;
    font-style: normal;
    line-height: 1.45;
    color: var(--fg);
    white-space: normal;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
    opacity: 0;
    visibility: hidden;
    transform: translateY(4px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 10000;
    pointer-events: none;
    /* Opaque fill so answer text cannot paint through. */
    isolation: isolate;
}

.telos-concept-pop.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Action row: chips / alternatives on the left, rating on the right. */
.telos-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 0.9rem;
}

.telos-actions-left {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.telos-actions-right { flex-shrink: 0; }

/* Over-scroll / click affordances to the adjacent question. */
.telos-nav-hint {
    flex-shrink: 0;
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    color: var(--muted);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0.5rem 0;
    opacity: 0.75;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.telos-nav-hint:hover { opacity: 1; color: var(--fg); }
.telos-nav-prev { margin-bottom: 0.4rem; }
.telos-nav-next { margin: 0.2rem 0 1rem; }
.telos-nav-arrow { color: var(--accent); margin-right: 0.4rem; }

.telos-qbar-pos {
    font-size: 0.72rem;
    color: var(--muted);
    margin-top: 0.2rem;
}

/* Live "thinking / researching / composing" status. */
.telos-status {
    color: var(--muted);
    font-size: 1.02rem;
}

.telos-status-line {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.telos-status-icon {
    font-size: 1.15rem;
    line-height: 1;
    animation: telos-pulse 1.5s ease-in-out infinite;
}

.telos-status-label { font-weight: 500; color: var(--fg); }

@keyframes telos-pulse {
    0%, 100% { opacity: 0.55; transform: scale(0.94); }
    50% { opacity: 1; transform: scale(1.06); }
}

/* Favicons of pages being read — pop in, then shrink-dissolve. */
.telos-favicons {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}

.telos-favicon {
    width: 22px;
    height: 22px;
    border-radius: 5px;
    background: var(--surface-2);
    padding: 2px;
    box-sizing: border-box;
    animation: telos-fav-in 0.3s ease-out;
}

.telos-favicon-leaving {
    animation: telos-fav-out 0.4s ease-in forwards;
}

@keyframes telos-fav-in {
    from { opacity: 0; transform: scale(0.3); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes telos-fav-out {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0; transform: scale(0.2); }
}

/* Composer — bottom of the chat column (directly above the shell footer).
   Surface takes all free height; no sticky/fixed needed. */
.telos-composer {
    flex-shrink: 0;
    margin-top: 0;
    z-index: 20;
    background: var(--bg);
    border-top: 1px solid var(--border);
    padding: 0.75rem 0 0.85rem;
}

.chat-status-detail {
    margin-top: 0.25rem;
    font-size: 0.82rem;
    font-style: normal;
    color: var(--muted);
    opacity: 0.85;
}

/* Continuation chips ("Tell me more", "Compare X and Y"). */
.chat-chips {
    align-self: flex-start;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.4rem;
}

.chat-chip {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--accent);
    border-radius: 999px;
    padding: 0.25rem 0.7rem;
    font-size: 0.82rem;
    cursor: pointer;
}

.chat-chip:hover {
    background: var(--surface);
}

/* Thread controls (phase F): new-chat + topic-override chip in the qbar. */
.telos-qbar-controls {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
}

.telos-qbar-spacer { flex: 1; }

.telos-topic-chip,
.telos-newchat {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    border-radius: 999px;
    padding: 0.2rem 0.65rem;
    font-size: 0.78rem;
    cursor: pointer;
}

.telos-topic-chip:hover,
.telos-newchat:hover {
    background: var(--surface);
    color: var(--fg);
}

.telos-topic-chip { color: var(--accent); }

.telos-topic-pencil { opacity: 0.6; margin-left: 0.15rem; }

.telos-newchat:disabled { opacity: 0.4; cursor: default; }

.telos-topic-edit {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.telos-topic-input {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--fg);
    border-radius: 999px;
    padding: 0.2rem 0.65rem;
    font-size: 0.78rem;
    min-width: 12rem;
}

.telos-topic-ok {
    background: var(--accent);
    border: none;
    color: var(--bg);
    border-radius: 999px;
    padding: 0.2rem 0.7rem;
    font-size: 0.78rem;
    cursor: pointer;
}

/* Command picker — appears while typing a "/command". */
.command-palette {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--surface);
    overflow: hidden auto;
    margin-bottom: 0.4rem;
    max-height: 16rem;
}

.command-palette-item {
    display: grid;
    /* Fixed name column so every row's title/desc line up (each item is its own
       grid, so an `auto` column sized per-row instead of across rows). */
    grid-template-columns: 7.5rem 1fr;
    grid-template-areas: "name title" "name desc";
    column-gap: 0.6rem;
    text-align: left;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border);
    padding: 0.45rem 0.7rem;
    cursor: pointer;
}

.command-palette-item:last-child {
    border-bottom: none;
}

.command-palette-item:hover {
    background: var(--bg);
}

/* The highlighted (top) match — Tab selects it. */
.command-palette-item-active {
    background: var(--surface-2);
    box-shadow: inset 2px 0 0 var(--accent);
}

.command-palette-name {
    grid-area: name;
    align-self: center;
    font-family: var(--mono, monospace);
    font-size: 0.85rem;
    color: var(--accent);
    white-space: nowrap;
}

.command-palette-title {
    grid-area: title;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--fg);
}

.command-palette-arg {
    font-weight: 400;
    font-family: var(--mono, monospace);
    font-size: 0.78rem;
    color: var(--muted);
    margin-left: 0.4rem;
}

.command-palette-desc {
    grid-area: desc;
    font-size: 0.78rem;
    color: var(--muted);
}

.chat-actions {
    align-self: flex-start;
    display: flex;
    gap: 0.4rem;
    margin-top: -0.3rem;
    padding-left: 0.2rem;
}

.chat-thumb {
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0.35;
    padding: 0;
    font-size: 0.9rem;
}

.chat-thumb:hover { opacity: 0.8; }
.chat-thumb-active { opacity: 1; }

/* Sources control (lane 5): sits by the rating; reveals the answer's cited
   sources on demand instead of inline footnotes. */
.chat-sources {
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0.35;
    padding: 0;
    margin-right: 0.5rem;
    font-size: 0.9rem;
}

.chat-sources:hover { opacity: 0.8; }
.chat-sources-active { opacity: 1; }

.telos-sources {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-top: 0.6rem;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.telos-audit {
    border-left: 2px solid var(--telos-accent, #6c8cff);
}
.telos-audit-step {
    margin: 0.35rem 0 0.5rem;
    font-size: 0.85rem;
    line-height: 1.35;
}
.telos-audit-mode {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.72rem;
    opacity: 0.8;
    margin-bottom: 0.15rem;
}
.telos-audit-body {
    opacity: 0.92;
    word-break: break-word;
}
.telos-sources-head {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.telos-source {
    font-size: 0.82rem;
    color: var(--accent);
    text-decoration: none;
    word-break: break-all;
}

.telos-source:hover { text-decoration: underline; }

/* Brainstorm per-perspective breakdown: expand a single advisor (lane 8). */
.telos-panel {
    margin-top: 1.2rem;
    border-top: 1px solid var(--border);
    padding-top: 0.7rem;
}

.telos-panel-head {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 0.4rem;
}

.telos-advisor {
    border-bottom: 1px solid var(--border);
}

.telos-advisor:last-child { border-bottom: none; }

.telos-advisor-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    background: none;
    border: none;
    color: var(--fg);
    font-size: 0.9rem;
    text-align: left;
    cursor: pointer;
    padding: 0.5rem 0.2rem;
}

.telos-advisor-head:hover { color: var(--accent); }

.telos-advisor-caret { color: var(--muted); font-size: 0.75rem; }

.telos-advisor-label { font-weight: 600; }

.telos-advisor-empty { color: var(--muted); font-size: 0.82rem; }

.telos-advisor-body { padding: 0 0.2rem 0.6rem 1.4rem; }

.telos-advisor-points {
    margin: 0 0 0.4rem;
    padding-left: 1.1rem;
    color: #c8cdd6;
    font-size: 0.88rem;
}

.telos-advisor-points li { margin: 0.15rem 0; }

.telos-advisor-sources {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.telos-advisor-note { color: var(--muted); font-size: 0.85rem; margin: 0; }

.chat-toast {
    position: fixed;
    bottom: 5rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--fg);
    border-radius: 8px;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    z-index: 100;
    animation: chat-toast-in 0.2s ease-out;
}

@keyframes chat-toast-in {
    from { opacity: 0; transform: translate(-50%, 0.5rem); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

.chat-alternatives {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.35rem;
}

.chat-alt {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--fg);
    border-radius: 14px;
    padding: 0.25rem 0.8rem;
    cursor: pointer;
    font-size: 0.85rem;
}

.chat-alt:hover {
    border-color: var(--accent);
}

.chat-status-dots span {
    animation: chat-dot-pulse 1.2s infinite;
    display: inline-block;
}

.chat-status-dots span:nth-child(2) { animation-delay: 0.2s; }
.chat-status-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chat-dot-pulse {
    0%, 60%, 100% { opacity: 0.25; }
    30% { opacity: 1; }
}

.chat-form {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.chat-input {
    flex: 1;
    padding: 0.7rem 0.9rem;
    background: var(--surface);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
}

.chat-input:focus {
    outline: none;
    border-color: var(--accent);
}

.chat-send {
    padding: 0.7rem 1.25rem;
    background: var(--accent);
    color: #0c1018;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}

.chat-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.chat-send-brainstorm {
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
}

/* Per-message mode picker — drop-up beside Send. */
.chat-mode {
    position: relative;
    display: flex;
    align-items: stretch;
}

.chat-mode-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.7rem 0.8rem;
    background: var(--surface);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.88rem;
    white-space: nowrap;
}

.chat-mode-on .chat-mode-toggle {
    border-color: #8b5cf6;
    color: #c4b5fd;
}

.chat-mode-caret {
    font-size: 0.7rem;
    opacity: 0.7;
}

.chat-mode-menu {
    position: absolute;
    bottom: calc(100% + 0.4rem);
    right: 0;
    min-width: 11rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.3rem;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
    z-index: 40;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.chat-mode-item {
    text-align: left;
    background: transparent;
    border: none;
    color: var(--fg);
    border-radius: 7px;
    padding: 0.5rem 0.6rem;
    font-size: 0.9rem;
    cursor: pointer;
}

.chat-mode-item:hover {
    background: var(--surface);
}

.chat-mode-item-active {
    background: var(--surface);
    color: var(--accent);
}

.chat-chip-brainstorm {
    border-color: #8b5cf6;
    color: #c4b5fd;
}

.info-grid {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.5rem 1.5rem;
    margin: 0;
}

.info-grid dt {
    color: var(--muted);
}

.info-grid dd {
    margin: 0;
    font-variant-numeric: tabular-nums;
}

.info-sync-toggle {
    margin-top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.9rem;
}

.info-sync-toggle label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
}

.info-muted {
    margin-left: 0.5rem;
    color: var(--muted);
    font-size: 0.85rem;
}

.admin-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    font-size: 0.92rem;
}

.admin-table th,
.admin-table td {
    text-align: left;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
}

.admin-table th {
    color: var(--muted);
    font-weight: 500;
}

.admin-table code {
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    color: var(--accent);
}

.admin-pre {
    margin: 0.5rem 0 1rem;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 0.85rem;
    white-space: pre-wrap;
    overflow-x: auto;
}

.admin-pre-error {
    color: #c44;
}

.admin-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 580px;
}

.admin-form label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.admin-form input,
.admin-form textarea {
    background: var(--surface);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.45rem 0.6rem;
    font-size: 0.95rem;
    font-family: inherit;
}

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

.admin-form .hint {
    color: var(--muted);
    font-size: 0.85rem;
}

.admin-status {
    margin-top: 1rem;
    padding: 0.5rem 0.75rem;
    background: var(--surface);
    border-left: 3px solid var(--accent);
    border-radius: 4px;
}

.primer-filter {
    margin: 0 0 1.5rem 0;
    color: var(--muted);
}

.primer-filter select {
    background: var(--surface);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.35rem 0.6rem;
    margin-left: 0.5rem;
}

.primer-card {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.primer-author,
.primer-meta,
.primer-price {
    margin: 0;
    color: var(--muted);
    font-size: 0.85rem;
}

.primer-price {
    color: var(--accent);
    font-weight: 500;
}

.primer-back {
    color: var(--muted);
    font-size: 0.9rem;
    text-decoration: none;
}

.primer-back:hover {
    color: var(--fg);
}

.primer-steps {
    margin: 1rem 0;
    padding-left: 1.5rem;
    line-height: 1.8;
}

.primer-step-arg {
    margin-left: 0.5rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.primer-step-expect {
    margin-left: 0.5rem;
    color: var(--accent);
    font-size: 0.85rem;
}

.primer-activate {
    margin-top: 1rem;
    padding: 0.6rem 1.25rem;
    background: var(--accent);
    color: #0c1018;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
}

.primer-activate:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.primer-activate-message {
    margin-top: 0.75rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.tools-banner-blocked {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin: 1rem 0 1.5rem;
    color: var(--muted);
}

.tools-filter {
    display: flex;
    gap: 0.5rem;
    margin: 1.25rem 0;
    flex-wrap: wrap;
}

.tools-filter-btn {
    background: var(--surface);
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.35rem 0.9rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.tools-filter-btn:hover {
    color: var(--fg);
    border-color: var(--accent);
}

.tools-filter-active {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--surface-2);
}

.tools-section {
    margin-top: 2rem;
}

.tools-section-note {
    color: var(--muted);
    font-size: 0.9rem;
    margin: 0.25rem 0 0.75rem;
}

.tools-empty {
    color: var(--muted);
}

.tools-table td {
    vertical-align: top;
}

.tools-id {
    display: block;
    font-size: 0.82rem;
    margin-top: 0.2rem;
    color: var(--accent);
}

.tools-hint {
    display: block;
    font-size: 0.82rem;
    color: var(--muted);
    margin-top: 0.15rem;
}

.tools-status-active {
    color: #81c995;
}

.tools-status-paused {
    color: var(--muted);
}

.tools-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    justify-content: flex-end;
    white-space: nowrap;
}

.tools-btn-danger {
    border-color: #c44 !important;
    color: #f5a8a8 !important;
}

.tools-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.tools-modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.5rem;
    max-width: 420px;
    width: 100%;
}

.tools-modal h2 {
    margin: 0 0 0.75rem;
    font-size: 1.15rem;
}

.tools-modal-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1.25rem;
}
