/* Custom styles for Agent Alex Web UI - Late 90s Silicone Hacker Theme */

/* Self-hosted fonts: VT323 (display) and Fira Mono (body/code).
   Per kokubo theme — no programming ligatures. */
@font-face {
    font-family: 'VT323';
    src: url('../fonts/VT323-Regular.woff2') format('woff2'),
         url('../fonts/VT323-Regular.woff') format('woff');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Fira Mono';
    src: url('../fonts/FiraMono-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Fira Mono';
    src: url('../fonts/FiraMono-Bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

:root {
    --bg-color: #3a3d3f;
    --text-color: #cee5c2; /* Forest Parchment */
    --accent-green: #9ad992; /* Soft Sage */
    --accent-primary: #33a37e; /* Teal */
    --accent-purple: #33a37e; /* Alias for backward compat */
    --accent-orange: #f9c890; /* Warm Amber */
    --accent-red: #eca2a2; /* Dusty Rose */

    --blue-grey: #729fb1;        /* string literals, kokubo blue-grey */
    --sidebar-bg: #323536;
    --status-bg: #165c45;

    --glass-bg: rgba(50, 53, 54, 0.85);
    --glass-border: 1px solid rgba(206, 229, 194, 0.3);

    --font-main: 'VT323', 'Courier New', monospace;
    --font-code: 'Fira Mono', monospace;

    /* Kokubo accent tokens (Phase 1, parity with iOS Theme.swift) */
    --emerald: #6db686;          /* headings, variables */
    --pale-yellow: #eee8aa;      /* function names, accents */
    --sky-blue: #92c8dd;         /* comments, blockquotes */
    --mint: #80dbaf;             /* operators, regex, escape chars */
    --olive: #818a67;            /* numbers, constants */
    --parchment-bright: #e2ffd2; /* hover/select foreground */
    --parchment-dim: #bbcdb0;    /* input field foreground */
    --placeholder: #818e79;      /* placeholder text */
    --teal-dark: #226851;        /* button hover */
    --info-blue: #75beff;        /* info messages */
}

body {
    font-family: var(--font-main);
    background: radial-gradient(ellipse at 50% 120%, #3f3d38 0%, #3a3d3f 40%, #33363a 100%);
    color: var(--text-color);
    height: 100vh;
    overflow: hidden;
    position: relative;
    font-size: 1.2rem;
}

/* Accessibility */
.skip-link {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1001; /* Above CRT scanline overlay */
    font-family: var(--font-code);
    text-decoration: none;
    border: 2px solid var(--accent-green);
}

/* CRT Scanline Effect */
body::before {
    content: " ";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background:
        linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.025) 50%),
        linear-gradient(90deg, rgba(180, 120, 60, 0.015), rgba(154, 217, 146, 0.01), rgba(100, 140, 160, 0.015));
    z-index: 1000;
    background-size: 100% 2px, 3px 100%;
    pointer-events: none;
}

/* Vignette — dim monitor edges */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at center, transparent 60%, rgba(0, 0, 0, 0.25) 100%);
    z-index: 999;
    pointer-events: none;
}

/* Bootstrap Overrides */
.bg-dark {
    background-color: var(--bg-color) !important;
}

.bg-secondary {
    background-color: #323536 !important;
    border: var(--glass-border);
}

.text-light {
    color: var(--text-color) !important;
}

.text-muted {
    color: rgba(206, 229, 194, 0.4) !important;
}

.border-dark {
    border-color: #4a4d4f !important;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 10px;
    background: #2e3132;
}

::-webkit-scrollbar-thumb {
    background: #4a4d4f;
    border-radius: 5px;
    border: 2px solid #2e3132;
}

::-webkit-scrollbar-thumb:hover {
    background: #33a37e;
}

/* Layout Elements */
header {
    background: linear-gradient(180deg, #2e3132 0%, #383b3d 100%);
    border-bottom: 1px solid rgba(51, 163, 126, 0.4) !important;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-code);
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--accent-primary);
}

/* Message Area */
#messages-container {
    /* No ``scroll-behavior: smooth`` — at full chat-history sizes
       (~60k px content) every programmatic scroll-set animates over
       the entire delta, which the user perceives as "stuck" scroll
       and ``pinToBottomUntilStable``'s reads see stale ``scrollTop``
       values mid-animation. ``pinToBottomUntilStable`` already opts
       into ``behavior: 'instant'`` explicitly; per-call opt-in for
       smooth (e.g. ``scrollIntoView``) is rare enough to add at the
       call site if ever needed. */
    /* Disable Chrome's implicit scroll anchoring — when images / widgets in
       history decode after we've pinned to the bottom, scroll anchoring
       picks an element mid-viewport as the anchor and keeps *its* position
       stable. The growth then appears below the viewport, making the chat
       look like it loaded mid-way. With overflow-anchor disabled we control
       re-pinning ourselves in JS (pinToBottomUntilStable). */
    overflow-anchor: none;
    background-image:
        linear-gradient(rgba(180, 160, 120, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(180, 160, 120, 0.02) 1px, transparent 1px);
    background-size: 24px 24px;
}

/* New-messages floating indicator */
.new-message-indicator {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(50, 53, 54, 0.92);
    border: 1px solid #33a37e;
    color: #cee5c2;
    font-family: var(--font-code);
    font-size: 0.75rem;
    padding: 6px 16px;
    border-radius: 20px;
    cursor: pointer;
    z-index: 10;
    transition: opacity 0.2s, transform 0.2s;
    box-shadow: 0 2px 8px rgba(51, 163, 126, 0.15);
    display: flex;
    align-items: center;
    gap: 6px;
}
.new-message-indicator:hover {
    background: rgba(55, 58, 60, 0.95);
    box-shadow: 0 2px 12px rgba(51, 163, 126, 0.3);
}
.new-message-indicator.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(8px);
}
.new-message-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #33a37e;
    display: inline-block;
    animation: dotPulse 1.5s ease-in-out infinite;
}
@keyframes dotPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.message {
    max-width: 92%;
    word-wrap: break-word;
    font-family: var(--font-code);
    box-shadow: 2px 2px 6px rgba(0,0,0,0.3);
    position: relative;
}

.message.user {
    align-self: flex-end;
    background-color: rgba(154, 217, 146, 0.2); /* Emerald Green translucent */
    color: #fff;
    border: 1px solid var(--accent-green);
    border-radius: 10px 10px 0 10px;
    padding: 1rem;
}

/* User message tail removed — cleaner without it */

.message.agent {
    align-self: flex-start;
    background-color: rgba(154, 217, 146, 0.07);
    color: var(--text-color);
    border: 1px solid rgba(206, 229, 194, 0.25);
    border-radius: 10px 10px 10px 0;
    padding: 1rem;
    box-shadow: 2px 2px 6px rgba(0,0,0,0.25);
}

/* Redundant activity-timeline card ("ACTIVITY <id> · SUCCESS · details")
   hidden — the substrate's REPL turn cards (CODE · ITER N / OUTPUT · ITER N)
   already surface compute activity. */
.activity-timeline {
    display: none !important;
}

/* System messages — heartbeat / idle / non-user triggers from the agent
   itself. Visually distinct from user/agent so they don't masquerade as
   user input. Dashed border, centered layout, muted typography, and a
   SYSTEM label at the top-left. */
.message.system {
    align-self: center;
    max-width: 82%;
    background-color: rgba(154, 217, 146, 0.03);
    color: rgba(206, 229, 194, 0.8);
    border: 1px dashed rgba(206, 229, 194, 0.35);
    border-radius: 4px;
    padding: 0.75rem 1rem;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
    box-shadow: none;
    font-size: 0.9em;
    font-style: italic;
    position: relative;
}

.message.system::before {
    content: "⟡ SYSTEM";
    display: block;
    font-family: var(--font-main);
    font-size: 0.7rem;
    font-style: normal;
    font-weight: bold;
    letter-spacing: 0.12em;
    color: rgba(206, 229, 194, 0.6);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
}

.message.system .timestamp {
    opacity: 0.5;
}

.heartbeat-run {
    align-self: center;
    width: 82%;
    max-width: 82%;
    margin: 0.5rem auto;
}

.heartbeat-run-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    background: rgba(154, 217, 146, 0.04);
    border: 1px dashed rgba(206, 229, 194, 0.25);
    border-radius: 6px;
    padding: 0.4rem 0.75rem;
    color: rgba(206, 229, 194, 0.7);
    font-family: var(--font-main);
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    text-align: left;
}

.heartbeat-run-header:hover {
    background: rgba(154, 217, 146, 0.08);
    color: rgba(206, 229, 194, 0.95);
}

.heartbeat-run-text { flex: 1; }
.heartbeat-run-icon { opacity: 0.85; }
.heartbeat-run-toggle { opacity: 0.6; }

.heartbeat-run.collapsed .heartbeat-run-body { display: none; }

.heartbeat-run-body {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.heartbeat-run-body .message.system {
    align-self: stretch;
    max-width: 100%;
}

.heartbeat-run-body .message.system::before {
    display: none;
}

.message .timestamp {
    font-size: 0.8rem;
    opacity: 0.7;
    margin-top: 0.5rem;
    font-family: var(--font-main);
    text-transform: uppercase;
}

.message.error {
    background-color: rgba(236, 162, 162, 0.2);
    border-color: var(--accent-red);
    color: var(--accent-red);
    text-shadow: 0 0 2px var(--accent-red);
}

.btn.retry-btn {
    font-family: var(--font-code);
    font-size: 0.7rem;
    letter-spacing: 1px;
    margin-top: 0.5rem;
    padding: 0.3rem 0.8rem;
    border: 1px solid var(--accent-red);
    border-radius: 3px;
    color: var(--accent-red);
    background: transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.btn.retry-btn:hover {
    background: rgba(236, 162, 162, 0.2);
    box-shadow: 0 0 8px rgba(236, 162, 162, 0.3);
}

.btn.retry-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Attached images in messages */
.message-images {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
}

.chat-image {
    max-width: 280px;
    max-height: 280px;
    border-radius: 6px;
    border: 1px solid rgba(154, 217, 146, 0.2);
    cursor: pointer;
    object-fit: contain;
    transition: border-color 0.2s;
}

.chat-image:hover {
    border-color: var(--accent-green);
    box-shadow: 0 0 8px rgba(154, 217, 146, 0.3);
}

.message-videos {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
}

.video-wrapper {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-video {
    border: 1px solid rgba(154, 217, 146, 0.2);
    border-radius: 6px;
}

.transcript-toggle {
    background: none;
    border: 1px solid rgba(154, 217, 146, 0.25);
    color: var(--accent-green);
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
    align-self: flex-start;
    transition: background 0.2s, border-color 0.2s;
}

.transcript-toggle:hover {
    background: rgba(154, 217, 146, 0.08);
    border-color: var(--accent-green);
}

.video-transcript {
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 0.75rem;
    line-height: 1.4;
    color: var(--text-secondary, #aaa);
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(154, 217, 146, 0.1);
    border-radius: 4px;
    padding: 8px 10px;
    max-width: 320px;
    max-height: 200px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Markdown content in messages */
.message-content {
    line-height: 1.5;
    -webkit-user-select: text;
    user-select: text;
}

.message-content p {
    margin: 0 0 0.5em 0;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content a {
    color: var(--blue-grey);
    text-decoration: underline;
}

.message-content a:hover {
    color: #9cc4d3;
    text-shadow: 0 0 3px rgba(114, 159, 177, 0.3);
}

.message-content code {
    background-color: rgba(46, 49, 50, 0.8);
    padding: 0.15em 0.4em;
    border-radius: 3px;
    font-family: var(--font-code);
    font-size: 0.9em;
    border: 1px solid rgba(74, 77, 79, 0.5);
}

.message-content pre {
    background-color: rgba(46, 49, 50, 0.8);
    padding: 0.75em;
    border-radius: 4px;
    overflow-x: auto;
    margin: 0.5em 0;
    border: 1px solid rgba(74, 77, 79, 0.5);
}

.message-content pre code {
    background: none;
    padding: 0;
}

.message-content ul, .message-content ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}

.message-content li {
    margin: 0.25em 0;
}

.message-content blockquote {
    border-left: 3px solid var(--blue-grey);
    margin: 0.5em 0;
    padding-left: 1em;
    opacity: 0.9;
}

.message-content h1, .message-content h2, .message-content h3 {
    margin: 0.5em 0 0.25em 0;
    font-weight: bold;
}

.message-content h1 { font-size: 1.3em; }
.message-content h2 { font-size: 1.2em; }
.message-content h3 { font-size: 1.1em; }

.message-content table {
    border-collapse: collapse;
    display: block;
    overflow-x: auto;
    max-width: 100%;
    margin: 0.5em 0;
    font-size: 0.9em;
}

.message-content th,
.message-content td {
    padding: 0.35em 0.65em;
    border: 1px solid rgba(74, 77, 79, 0.5);
    text-align: left;
    white-space: nowrap;
}

.message-content th {
    background-color: rgba(46, 49, 50, 0.8);
    font-weight: bold;
    color: var(--emerald);
}

.message-content tr:nth-child(even) td {
    background-color: rgba(46, 49, 50, 0.3);
}

/* Live Activity Card */
.activity-card {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    align-self: flex-start;
    padding: 0.5rem 0.8rem;
    margin: 0.35rem 0;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(51, 163, 126, 0.3);
    border-radius: 6px;
    font-family: var(--font-code);
    font-size: 0.8rem;
    animation: activity-enter 0.25s ease-out;
}

.activity-card-exiting {
    animation: activity-exit 0.3s ease-in forwards;
}

@keyframes activity-enter {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes activity-exit {
    from { opacity: 1; transform: translateY(0); }
    to   { opacity: 0; transform: translateY(-4px); }
}

.activity-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
    animation: icon-pulse 2s ease-in-out infinite;
}

@keyframes icon-pulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

.activity-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
    flex: 1;
}

.activity-label {
    color: var(--accent-orange);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.activity-status {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 0.8rem;
}

.activity-timer {
    font-size: 0.65rem;
    color: var(--accent-purple);
    flex-shrink: 0;
    min-width: 2rem;
    text-align: right;
}

.activity-spinner {
    display: flex;
    gap: 3px;
    align-items: center;
    flex-shrink: 0;
}

.activity-spinner span {
    display: block;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--accent-purple);
    animation: spinner-dot 1.2s ease-in-out infinite;
}

.activity-spinner span:nth-child(2) {
    animation-delay: 0.15s;
}

.activity-spinner span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes spinner-dot {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1.1); }
}

/* Neural Thread — compute phase visualization */
/* Compute DAG — neural thread layout */
.activity-card.neural-thread {
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
    max-width: 100%;
    width: 100%;
    padding: 0.5rem 0.7rem;
}

.activity-card.neural-thread .activity-spinner {
    display: none;
}

.activity-card.dag-thread {
    padding: 0.4rem 0.5rem;
}

.dag-header {
    font-family: var(--font-code);
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 0.2rem;
}

/* DAG canvas viewport */
.dag-viewport {
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(51, 163, 126, 0.2) transparent;
}

.dag-viewport::-webkit-scrollbar {
    width: 3px;
}

.dag-viewport::-webkit-scrollbar-track {
    background: transparent;
}

.dag-viewport::-webkit-scrollbar-thumb {
    background: rgba(51, 163, 126, 0.2);
    border-radius: 2px;
}

.dag-canvas {
    display: block;
    width: 100%;
}

/* Budget bar */
.thread-budget-bar {
    height: 2px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 1px;
    margin-top: 4px;
    overflow: hidden;
}

.thread-budget-fill {
    height: 100%;
    width: 0%;
    background: var(--accent-purple);
    border-radius: 1px;
    transition: width 0.6s ease, background-color 1.5s ease;
}

/* Activity Timeline (Rich Trace) */
.activity-timeline {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    align-self: stretch;
    padding: 0.7rem 0.9rem;
    margin: 0.45rem 0;
    background: rgba(50, 53, 54, 0.6);
    border: 1px solid rgba(51, 163, 126, 0.25);
    border-radius: 8px;
    font-family: var(--font-code);
    font-size: 0.78rem;
}

.activity-timeline.collapsed .timeline-list {
    display: none;
}

.timeline-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.timeline-title {
    color: var(--accent-green);
    font-weight: 600;
}

.timeline-chain-status {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.7rem;
}

.timeline-toggle {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.65rem;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
}

.timeline-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.timeline-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 0.5rem;
    padding: 0.2rem 0.3rem;
    border-left: 2px solid rgba(255, 255, 255, 0.1);
}

.timeline-time {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.65rem;
}

.timeline-label {
    color: rgba(255, 255, 255, 0.9);
}

.timeline-status {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.65rem;
    text-transform: uppercase;
}

.timeline-item.timeline-error {
    border-left-color: rgba(236, 162, 162, 0.7);
}

.timeline-item.timeline-complete {
    border-left-color: rgba(154, 217, 146, 0.7);
}

/* Side-chat action indicator (lightweight fallback) */
.action-indicator {
    align-self: flex-start;
    font-size: 0.8rem;
    color: var(--accent-orange);
    padding: 0.35rem 0.7rem;
    margin: 0.25rem 0;
    font-family: var(--font-code);
    animation: icon-pulse 2s ease-in-out infinite;
}



/* Inputs and Forms */
input.form-control,
textarea.form-control {
    background-color: #323536 !important;
    color: var(--text-color) !important;
    border: 1px solid #4a4d4f !important;
    font-family: var(--font-code);
    border-radius: 0;
}

input.form-control::placeholder,
textarea.form-control::placeholder {
    color: rgba(206, 229, 194, 0.3) !important;
}

textarea.form-control {
    resize: none;
    overflow-y: auto;
    max-height: 200px;
}

input.form-control:focus,
textarea.form-control:focus {
    border-color: #33a37e !important;
    box-shadow: 0 0 6px rgba(51, 163, 126, 0.3);
    outline: none;
}

/* Buttons */
.btn {
    font-family: var(--font-main);
    text-transform: uppercase;
    font-weight: bold;
    border-radius: 3px;
    border: none;
    position: relative;
    overflow: hidden;
    transition: all 0.2s;
}

.btn-primary {
    background: #33a37e;
    box-shadow: 0 1px 3px rgba(0,0,0,0.4);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-primary:hover {
    background: #3bb88e;
    box-shadow: 0 1px 6px rgba(51, 163, 126, 0.25);
}

/* Google auth buttons — muted style */
#google-auth-btn,
#google-work-auth-btn,
.btn-warning {
    background: transparent;
    border: 1px solid #4a4d4f;
    color: #7a7d7f;
    box-shadow: none;
}

#google-auth-btn:hover,
#google-work-auth-btn:hover,
.btn-warning:hover {
    border-color: #33a37e;
    color: #cee5c2;
    background: transparent;
    box-shadow: none;
}

.btn-outline-light {
    border: 1px solid var(--text-color);
    color: var(--text-color);
    background: transparent;
}

.btn-outline-light:hover {
    background-color: rgba(206, 229, 194, 0.12);
    color: var(--text-color);
    box-shadow: none;
}

/* Sidebar */
.col-md-3.bg-secondary {
    border-left: 1px solid rgba(154, 217, 146, 0.15) !important;
    background: var(--sidebar-bg) !important;
}

/* Activity Log Scrollable Container */
#tool-calls {
    max-height: 300px;
    overflow-y: auto;
}

#tool-calls .tool-call-item {
    background-color: rgba(0, 0, 0, 0.6);
    border: 1px solid #4a4d4f;
    color: #ccc;
    font-family: var(--font-code);
}

#tool-calls .tool-name {
    color: var(--accent-orange);
}

/* Todo Panel */
.todo-add-form {
    display: flex;
    gap: 0.3rem;
    align-items: center;
}

.todo-add-form input {
    font-size: 0.75rem !important;
    padding: 0.2rem 0.4rem !important;
}

.todo-add-form .todo-add-btn {
    padding: 0.2rem 0.4rem;
    font-size: 0.75rem;
    flex-shrink: 0;
}

#todo-list {
    max-height: 250px;
    overflow-y: auto;
}

.todo-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.4rem;
    padding: 0.4rem 0.5rem;
    margin-bottom: 0.3rem;
    background-color: rgba(0, 0, 0, 0.6);
    border: 1px solid #4a4d4f;
    border-radius: 4px;
    font-family: var(--font-code);
    font-size: 0.75rem;
    transition: border-color 0.2s;
}

.todo-item:hover {
    border-color: var(--text-color);
}

.todo-item.done {
    opacity: 0.5;
}

.todo-item.done .todo-key,
.todo-item.done .todo-value {
    text-decoration: line-through;
}

.todo-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
    flex: 1;
}

.todo-key {
    color: var(--accent-orange);
    font-weight: bold;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.todo-value {
    color: #ccc;
    word-break: break-word;
}

.todo-actions {
    display: flex;
    gap: 0.15rem;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.2s;
}

.todo-item:hover .todo-actions,
.todo-item:focus-within .todo-actions {
    opacity: 1;
}

.todo-action-btn {
    padding: 0.1rem 0.3rem;
    font-size: 0.65rem;
    color: var(--text-color);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 3px;
    cursor: pointer;
    line-height: 1;
}

.todo-action-btn:hover {
    border-color: var(--text-color);
    background: rgba(154, 217, 146, 0.1);
    color: var(--text-color);
}

.todo-action-btn.delete:hover {
    border-color: var(--accent-red);
    background: rgba(236, 162, 162, 0.1);
    color: var(--accent-red);
}

.todo-action-btn.save {
    color: var(--accent-green);
}

.todo-action-btn.save:hover {
    border-color: var(--accent-green);
    background: rgba(154, 217, 146, 0.15);
}

.todo-edit-form {
    display: flex;
    gap: 0.3rem;
    align-items: center;
    flex: 1;
}

.todo-edit-form input {
    font-size: 0.75rem !important;
    padding: 0.15rem 0.3rem !important;
    flex: 1;
}

/* Status Badges */
.badge {
    border-radius: 3px;
    box-shadow: none;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.bg-success {
    background: rgba(154, 217, 146, 0.2) !important;
    color: #9ad992 !important;
    border: 1px solid rgba(154, 217, 146, 0.3);
}

.bg-warning {
    background: rgba(249, 200, 144, 0.2) !important;
    color: #f9c890 !important;
    border: 1px solid rgba(249, 200, 144, 0.3);
}

.bg-danger {
    background: rgba(236, 162, 162, 0.2) !important;
    color: #eca2a2 !important;
    border: 1px solid rgba(236, 162, 162, 0.3);
}

/* Typing Indicator - Bouncing Ellipsis */
#typing-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 1rem 1.5rem;
    min-height: 50px;
}

#typing-indicator span {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--accent-primary);
    box-shadow: 0 0 4px rgba(51, 163, 126, 0.3);
    animation: typingBounce 1.4s ease-in-out infinite;
}

#typing-indicator span:nth-child(1) {
    animation-delay: 0s;
}

#typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

#typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* File Preview */
.file-preview-item {
    border: 1px solid rgba(154, 217, 146, 0.3);
    padding: 2px;
    background: rgba(0,0,0,0.4);
    border-radius: 3px;
}

.file-preview-item .remove-btn {
    background: var(--accent-red);
    box-shadow: none;
}

/* Login Card */
.card {
    background-color: rgba(50, 53, 54, 0.92) !important;
    border: 1px solid rgba(154, 217, 146, 0.35);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5), 0 0 8px rgba(154, 217, 146, 0.1);
}

.card-title {
    color: var(--text-color);
    text-shadow: 0 0 4px rgba(206, 229, 194, 0.2);
}

/* Matrix Text Glitch Effect Animation (Optional/Simple) */
@keyframes glitch {
    0% { transform: translate(0) }
    20% { transform: translate(-2px, 2px) }
    40% { transform: translate(-2px, -2px) }
    60% { transform: translate(2px, 2px) }
    80% { transform: translate(2px, -2px) }
    100% { transform: translate(0) }
}

#status-indicator:hover {
    animation: glitch 0.3s cubic-bezier(.25, .46, .45, .94) both infinite;
}

#runtime-status-bar {
    display: flex;
    justify-content: center;
    padding: 0.5rem 0;
    background: transparent;
}

/* ----------------------------------------------------------------------
 * Context Budget Bar — chat header gauge for the substrate's prompt size.
 * The two `cb-fill` segments stack horizontally: text tokens (primary
 * fill) and visual tokens (overlaid). The empty space is headroom. Color
 * thresholds match the agent-facing dashboard's danger flag (≥25% per
 * variable, ≥60% / ≥85% for the bar overall).
 * -------------------------------------------------------------------- */

.context-budget-bar {
    position: relative;
    display: flex;
    align-items: center;
    height: 22px;
    margin: 0;
    padding: 0;
    background: rgba(0, 0, 0, 0.65);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    overflow: visible;
    cursor: help;
    transition: background 120ms ease;
}

.context-budget-bar:hover,
.context-budget-bar:focus {
    background: rgba(0, 0, 0, 0.85);
    outline: none;
}

.context-budget-bar .cb-fill {
    position: absolute;
    top: 0;
    bottom: 0;
    height: 100%;
    transition: width 200ms ease, background 200ms ease;
}

.context-budget-bar .cb-text {
    left: 0;
    background: linear-gradient(90deg, #1f8a4e 0%, #2cb87a 100%);
    z-index: 1;
}

.context-budget-bar .cb-visual {
    /* `left` is set inline by chat.js to text-fill width so visual stacks
     * after text. Gradient differs to tell them apart at a glance. */
    background: linear-gradient(90deg, #5677c4 0%, #7898d8 100%);
    z-index: 2;
}

/* Color band by overall usage. Set on the parent via class. */
.context-budget-bar.cb-band-yellow .cb-text {
    background: linear-gradient(90deg, #b89a25 0%, #d4b94a 100%);
}
.context-budget-bar.cb-band-red .cb-text {
    background: linear-gradient(90deg, #b6322e 0%, #d2554f 100%);
}

.context-budget-bar .cb-label {
    position: relative;
    z-index: 3;
    padding: 0 0.6rem;
    color: rgba(255, 255, 255, 0.92);
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 11px;
    line-height: 22px;
    letter-spacing: 0.04em;
    pointer-events: none;
}

.context-budget-bar .cb-pct {
    margin-left: 0.4rem;
    color: rgba(255, 255, 255, 0.65);
}

.context-budget-bar .cb-tooltip {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: auto;
    min-width: 320px;
    max-width: 520px;
    background: rgba(8, 12, 16, 0.97);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 4px;
    padding: 0.6rem 0.8rem;
    color: rgba(255, 255, 255, 0.9);
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 11px;
    line-height: 1.5;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.55);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-3px);
    transition: opacity 120ms ease, visibility 120ms ease, transform 120ms ease;
    pointer-events: none;
    z-index: 1100;
}

.context-budget-bar:hover .cb-tooltip,
.context-budget-bar:focus .cb-tooltip,
.context-budget-bar.cb-tooltip-pinned .cb-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.context-budget-bar .cb-tooltip-section + .cb-tooltip-section {
    margin-top: 0.6rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.context-budget-bar .cb-tooltip-title {
    color: rgba(255, 255, 255, 0.55);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.3rem;
}

.context-budget-bar .cb-comp-row,
.context-budget-bar .cb-var-row {
    display: flex;
    justify-content: space-between;
    gap: 0.6rem;
    padding: 0.1rem 0;
}

.context-budget-bar .cb-var-row .cb-var-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.context-budget-bar .cb-var-row .cb-var-tokens {
    color: rgba(255, 255, 255, 0.7);
}

.context-budget-bar .cb-var-row.cb-var-warn .cb-var-name::before {
    content: "⚠ ";
    color: #d2554f;
}

.context-budget-bar .cb-var-row .cb-var-kind {
    color: rgba(255, 255, 255, 0.45);
    font-size: 10px;
}

.context-budget-bar .cb-vars-more {
    margin-top: 0.3rem;
}

#agent-runtime-status.runtime-state {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: transparent;
    border: 1px solid currentColor;
    letter-spacing: 0.1em;
    font-family: var(--font-code);
    font-size: 0.7rem;
    padding: 0.25rem 0.6rem;
    transition: opacity 0.3s ease, color 0.3s ease;
}

#agent-runtime-status.runtime-idle {
    color: #9aa0a6;
    opacity: 0.5;
    border-color: rgba(154, 160, 166, 0.3);
}

#agent-runtime-status.runtime-paused {
    color: var(--accent-green);
    opacity: 0.6;
    border-color: rgba(154, 217, 146, 0.3);
}

#agent-runtime-status.runtime-inferencing {
    color: #f9c890;
    opacity: 1;
    background: rgba(249, 200, 144, 0.08);
}

#agent-runtime-status.runtime-executing {
    color: var(--accent-green);
    opacity: 1;
    background: rgba(154, 217, 146, 0.08);
}

#agent-runtime-status.runtime-thinking {
    color: #92c8dd;
    opacity: 1;
    background: rgba(146, 200, 221, 0.06);
    text-shadow: 0 0 8px rgba(146, 200, 221, 0.4);
}

#agent-runtime-status.runtime-compute-running {
    color: #80dbaf;
    opacity: 1;
    background: rgba(128, 219, 175, 0.08);
    text-shadow: 0 0 8px rgba(128, 219, 175, 0.5);
}
#agent-runtime-status.runtime-compute-running .runtime-spinner {
    animation-duration: 0.4s;
}

#agent-runtime-status .runtime-spinner {
    width: 0.6rem;
    height: 0.6rem;
    border: 1.5px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: runtimeSpin 0.8s linear infinite;
    flex: 0 0 auto;
}

#agent-runtime-status .runtime-label {
    line-height: 1;
}

@keyframes runtimeSpin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Helper Classes */
.secure-login-text {
    letter-spacing: 5px;
}

.access-footer {
    font-size: 0.7rem;
}

/* Toma Blob — tamagotchi mascot */
.toma-blob {
    flex-shrink: 0;
}

.blob-body {
    width: 28px;
    height: 24px;
    background: var(--accent-primary);
    border-radius: 50% 50% 45% 45%;
    position: relative;
    animation: blob-breathe 3s ease-in-out infinite;
    box-shadow: 0 2px 6px rgba(51, 163, 126, 0.3);
}

.blob-eye {
    position: absolute;
    width: 4px;
    height: 5px;
    background: #2e3132;
    border-radius: 50%;
    top: 8px;
    animation: blob-blink 4s ease-in-out infinite;
}

.blob-eye.left {
    left: 8px;
}

.blob-eye.right {
    right: 8px;
}

@keyframes blob-breathe {
    0%, 100% { transform: scaleY(1) translateY(0); }
    50% { transform: scaleY(0.92) translateY(1px); }
}

@keyframes blob-blink {
    0%, 42%, 46%, 100% { transform: scaleY(1); }
    44% { transform: scaleY(0.1); }
}

/* Inferencing — eyes squish to lines, body wobbles side to side */
.toma-blob.blob-inferencing .blob-body {
    animation: blob-infer-wobble 1.2s ease-in-out infinite;
    background: #7bc47a;
    box-shadow: 0 2px 8px rgba(123, 196, 122, 0.3);
}

.toma-blob.blob-inferencing .blob-eye {
    animation: blob-infer-eyes 1.2s ease-in-out infinite;
    height: 3px;
    top: 9px;
}

@keyframes blob-infer-wobble {
    0%, 100% { transform: rotate(-3deg) scaleY(0.95); }
    50% { transform: rotate(3deg) scaleY(1.02); }
}

@keyframes blob-infer-eyes {
    0%, 100% { transform: scaleY(0.6); }
    50% { transform: scaleY(1); }
}

/* Thinking / CoT — slow pulse, droopy eyes */
.toma-blob.blob-thinking .blob-body {
    animation: blob-think-pulse 2.5s ease-in-out infinite;
}
.toma-blob.blob-thinking .blob-eye {
    animation: blob-think-eye-droop 2.5s ease-in-out infinite;
}
@keyframes blob-think-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}
@keyframes blob-think-eye-droop {
    0%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(0.5); }
}

/* Executing tool — bouncy and alert, eyes wide */
.toma-blob.blob-executing .blob-body {
    animation: blob-execute-bounce 0.6s ease-in-out infinite;
    background: #9ad992;
    box-shadow: 0 2px 8px rgba(154, 217, 146, 0.3);
}

.toma-blob.blob-executing .blob-eye {
    width: 5px;
    height: 6px;
    animation: none;
}

@keyframes blob-execute-bounce {
    0%, 100% { transform: translateY(0) scaleX(1); }
    30% { transform: translateY(-3px) scaleX(0.95); }
    60% { transform: translateY(1px) scaleX(1.05); }
}

/* Computing / sub-agent — intense focus, rapid pulse */
.toma-blob.blob-computing .blob-body {
    animation: blob-compute-pulse 0.8s ease-in-out infinite;
    background: #5a9e6f;
    box-shadow: 0 2px 10px rgba(90, 158, 111, 0.3);
}

.toma-blob.blob-computing .blob-eye {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    top: 9px;
    animation: blob-compute-eyes 0.4s ease-in-out infinite alternate;
}

.toma-blob.blob-computing .blob-eye.left { left: 7px; }
.toma-blob.blob-computing .blob-eye.right { right: 7px; }

@keyframes blob-compute-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

@keyframes blob-compute-eyes {
    0% { transform: translateX(-1px); }
    100% { transform: translateX(1px); }
}

/* Sleeping / paused — eyes closed, slow float */
.toma-blob.blob-sleeping .blob-body {
    animation: blob-sleep-float 4s ease-in-out infinite;
    opacity: 0.6;
}

.toma-blob.blob-sleeping .blob-eye {
    height: 2px;
    top: 10px;
    border-radius: 2px;
    animation: none;
}

@keyframes blob-sleep-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(2px); }
}

.system-version-text {
    font-size: 0.7rem;
    letter-spacing: 3px;
    color: rgba(206, 229, 194, 0.4) !important;
}

/* Search Functionality */
#search-container {
    background: rgba(50, 53, 54, 0.95) !important;
    border-bottom: 1px solid #4a4d4f !important;
}

#search-input {
    background-color: #323536 !important;
    color: var(--text-color) !important;
    border: 1px solid #4a4d4f !important;
    font-family: var(--font-code);
}

#search-input:focus {
    border-color: #33a37e !important;
    box-shadow: 0 0 6px rgba(51, 163, 126, 0.3);
    outline: none;
}

#search-results-count {
    min-width: 80px;
    text-align: center;
    font-family: var(--font-code);
    color: var(--accent-green);
}

/* Search Result Highlighting */
.message.search-match {
    box-shadow: 0 0 8px var(--accent-orange), inset 0 0 10px rgba(249, 200, 144, 0.2);
    border-color: var(--accent-orange) !important;
}

.message.search-current {
    box-shadow: 0 0 15px var(--accent-orange), inset 0 0 20px rgba(249, 200, 144, 0.3);
    border-color: var(--accent-orange) !important;
    background-color: rgba(249, 200, 144, 0.15) !important;
}

.message.search-current::before {
    content: '';
    position: absolute;
    left: -15px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-left: 10px solid var(--accent-orange);
}

/* Tool Call Events in Chat */
.tool-call-event {
    align-self: flex-start;
    max-width: 96%;
    margin: 0.5rem 0;
    padding: 0.75rem;
    background-color: rgba(51, 163, 126, 0.1);
    border: 1px solid var(--accent-purple);
    border-radius: 8px;
    font-family: var(--font-code);
    font-size: 0.85rem;
}

.tool-call-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--accent-purple);
    font-weight: bold;
}

.tool-call-header .tool-icon {
    font-size: 1rem;
    opacity: 0.8;
}

.tool-call-header .tool-name {
    color: var(--accent-orange);
}

.tool-call-details {
    margin-top: 0.5rem;
}

.tool-call-details summary {
    cursor: pointer;
    color: var(--accent-green);
    font-size: 0.8rem;
    padding: 0.25rem 0;
    user-select: none;
}

.tool-call-details summary:hover {
    text-shadow: 0 0 5px var(--accent-green);
}

.tool-call-details[open] summary {
    margin-bottom: 0.5rem;
}

.tool-call-args,
.tool-call-result {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background-color: rgba(0, 0, 0, 0.4);
    border-radius: 4px;
}

.tool-call-args strong,
.tool-call-result strong {
    color: var(--text-color);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.tool-call-args pre,
.tool-call-result pre {
    margin: 0.25rem 0 0 0;
    padding: 0.5rem;
    background-color: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    font-size: 0.75rem;
    overflow-x: auto;
    max-height: 150px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
    color: #ccc;
}

.tool-result-truncated {
    margin-top: 0.35rem;
    font-size: 0.7rem;
    color: var(--accent-orange);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.tool-result-load {
    margin-top: 0.35rem;
    background: rgba(0, 0, 0, 0.45);
    color: var(--accent-green);
    border: 1px solid rgba(154, 217, 146, 0.4);
    font-size: 0.65rem;
    padding: 0.2rem 0.5rem;
    letter-spacing: 0.08em;
}

.tool-call-event .timestamp {
    font-size: 0.7rem;
    opacity: 0.6;
    margin-top: 0.5rem;
    font-family: var(--font-main);
    text-transform: uppercase;
    color: var(--accent-purple);
}

/* Compute Result Display */
.compute-status {
    margin-left: auto;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: bold;
}

.compute-status.success {
    background: rgba(154, 217, 146, 0.2);
    color: var(--text-color);
}

.compute-status.error {
    background: rgba(236, 162, 162, 0.2);
    color: var(--accent-pink);
}

.tool-call-event.compute-failure-event {
    background-color: rgba(236, 162, 162, 0.08);
    border-color: var(--accent-red);
}

.tool-call-event.compute-failure-event .tool-call-header {
    color: var(--accent-red);
}

.tool-call-event.compute-failure-event .tool-name {
    color: var(--accent-red);
}

.compute-failure-kind {
    font-size: 0.75rem;
    opacity: 0.75;
    color: var(--accent-red);
}

.compute-failure-error {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--accent-red);
    opacity: 0.85;
    white-space: pre-wrap;
    word-break: break-word;
}

.repl-failure-note {
    margin-top: 0.5rem;
    padding: 0.4rem 0.6rem;
    border-left: 2px solid var(--accent-red);
    background: rgba(236, 162, 162, 0.06);
    border-radius: 0 4px 4px 0;
}

.repl-failure-message {
    display: block;
    font-size: 0.75rem;
    color: var(--accent-red);
    opacity: 0.85;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: var(--font-code);
}

.compute-result-display {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 6px;
    border-left: 3px solid var(--accent-purple);
}

.compute-task {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.compute-task .label {
    color: var(--accent-green);
    font-weight: bold;
    margin-right: 0.5rem;
}

.compute-result-content {
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    line-height: 1.5;
}

.compute-result-content.success {
    border-left: 2px solid var(--text-color);
}

.compute-result-content.error {
    border-left: 2px solid var(--accent-pink);
    color: var(--accent-pink);
}

.result-bullet {
    padding: 0.2rem 0;
    padding-left: 0.5rem;
}

.result-kv {
    padding: 0.15rem 0;
}

.result-key {
    color: var(--accent-orange);
    font-weight: 500;
}

/* Compute Summary Header */
.compute-summary {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.compute-badge {
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.compute-badge.success {
    background: rgba(154, 217, 146, 0.2);
    color: var(--text-color);
    border: 1px solid var(--text-color);
}

.compute-badge.error {
    background: rgba(236, 162, 162, 0.2);
    color: var(--accent-red);
    border: 1px solid var(--accent-red);
}

.compute-iterations {
    font-size: 0.75rem;
    color: var(--accent-green);
    font-family: var(--font-code);
}

/* Collapsible Trace Container */
.compute-steps-container {
    margin: 0.75rem 0;
    border: 1px solid rgba(51, 163, 126, 0.3);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.3);
}

.compute-steps-container > summary {
    padding: 0.6rem 0.75rem;
    cursor: pointer;
    color: var(--accent-purple);
    font-size: 0.8rem;
    font-family: var(--font-code);
    user-select: none;
    transition: background-color 0.2s;
}

.compute-steps-container > summary:hover {
    background: rgba(51, 163, 126, 0.1);
}

.compute-steps-container[open] > summary {
    border-bottom: 1px solid rgba(51, 163, 126, 0.2);
    margin-bottom: 0.5rem;
}

/* Iteration Progress Strip */
.iteration-progress-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid rgba(51, 163, 126, 0.2);
}

.iteration-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    font-size: 0.6rem;
    font-weight: bold;
    font-family: var(--font-code);
    transition: transform 0.15s, box-shadow 0.15s;
}

.iteration-dot:hover {
    transform: scale(1.2);
}

.iteration-dot.success {
    background: rgba(154, 217, 146, 0.3);
    color: var(--accent-green);
    box-shadow: 0 0 4px rgba(154, 217, 146, 0.3);
}

.iteration-dot.success:hover {
    box-shadow: 0 0 8px rgba(154, 217, 146, 0.5);
}

.iteration-dot.error {
    background: rgba(236, 162, 162, 0.3);
    color: var(--accent-red);
    box-shadow: 0 0 4px rgba(236, 162, 162, 0.3);
}

.iteration-dot.error:hover {
    box-shadow: 0 0 8px rgba(236, 162, 162, 0.5);
}

.iteration-dot.warning {
    background: rgba(249, 200, 144, 0.3);
    color: var(--accent-orange);
    box-shadow: 0 0 4px rgba(249, 200, 144, 0.3);
}

.iteration-dot.warning:hover {
    box-shadow: 0 0 8px rgba(249, 200, 144, 0.5);
}

/* Iteration Groups */
.compute-steps {
    padding: 0 0.5rem 0.5rem 0.5rem;
}

.iteration-group {
    margin-bottom: 0.5rem;
    border-left: 3px solid var(--accent-green);
    background: rgba(0, 0, 0, 0.2);
    border-radius: 0 4px 4px 0;
}

.iteration-group:last-child {
    margin-bottom: 0;
}

.iteration-group.success {
    border-left-color: var(--accent-green);
}

.iteration-group.error {
    border-left-color: var(--accent-red);
}

.iteration-group.warning {
    border-left-color: var(--accent-orange);
}

/* Iteration Header */
.iteration-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.75rem;
    transition: background-color 0.2s;
}

.iteration-header:hover {
    background: rgba(255, 255, 255, 0.05);
}

.iteration-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    font-size: 0.7rem;
    font-weight: bold;
    flex-shrink: 0;
}

.iteration-number.success {
    background: rgba(154, 217, 146, 0.3);
    color: var(--accent-green);
}

.iteration-number.error {
    background: rgba(236, 162, 162, 0.3);
    color: var(--accent-red);
}

.iteration-number.warning {
    background: rgba(249, 200, 144, 0.3);
    color: var(--accent-orange);
}

.iteration-label {
    font-family: var(--font-code);
    font-weight: 500;
    color: var(--accent-green);
    flex-shrink: 0;
}

.iteration-preview {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--font-code);
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.4);
    min-width: 0;
}

.iteration-status-icon {
    margin-left: auto;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.iteration-status-icon.success {
    color: var(--accent-green);
}

.iteration-status-icon.error {
    color: var(--accent-red);
}

.iteration-status-icon.warning {
    color: var(--accent-orange);
}

/* Iteration Content */
.iteration-content {
    padding: 0.5rem 0.75rem 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.step-code-section,
.step-output-section,
.step-files-section,
.step-result-section {
    margin-bottom: 0.5rem;
}

.step-code-section:last-child,
.step-output-section:last-child,
.step-files-section:last-child,
.step-result-section:last-child {
    margin-bottom: 0;
}

.iteration-content strong {
    display: block;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--accent-green);
    margin-bottom: 0.25rem;
}

.iteration-content pre {
    margin: 0;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    font-size: 0.7rem;
    max-height: 200px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.iteration-content pre code {
    background: none;
    padding: 0;
    font-family: var(--font-code);
}

/* Prism.js overrides for our theme */
.iteration-content pre[class*="language-"],
.iteration-content code[class*="language-"] {
    background: transparent;
    font-size: 0.7rem;
}

/* Output sections */
.step-output-section.stdout pre {
    color: var(--text-color);
}

.step-output-section.stderr pre {
    color: var(--accent-orange);
    border-color: rgba(249, 200, 144, 0.3);
}

.step-output-section.error-msg pre {
    color: var(--accent-red);
    border-color: rgba(236, 162, 162, 0.3);
}

.step-files-section {
    font-size: 0.7rem;
    color: var(--accent-purple);
}

/* Expandable output toggle */
.output-toggle-btn {
    display: inline-block;
    margin-top: 0.3rem;
    padding: 0.15rem 0.5rem;
    background: none;
    border: 1px solid rgba(51, 163, 126, 0.4);
    border-radius: 3px;
    color: var(--accent-purple);
    font-family: var(--font-code);
    font-size: 0.65rem;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

.output-toggle-btn:hover {
    background: rgba(51, 163, 126, 0.15);
    border-color: var(--accent-purple);
}

/* JSON/dict formatted output */
pre.formatted-json {
    color: var(--accent-orange);
    border-color: rgba(249, 200, 144, 0.2);
    background: rgba(249, 200, 144, 0.05);
}

.compute-trace {
    margin-top: 0.5rem;
    font-size: 0.7rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Clickable Activity Log Items */
#tool-calls .tool-call-item.clickable {
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    border-radius: 4px;
}

#tool-calls .tool-call-item.clickable:hover {
    background: rgba(154, 217, 146, 0.1);
    border-color: var(--text-color);
    transform: translateX(2px);
}

#tool-calls .tool-call-item.clickable:active {
    transform: translateX(0);
    background: rgba(154, 217, 146, 0.2);
}

.tool-icon-small {
    margin-right: 0.3rem;
    font-size: 0.9em;
}

/* Highlight flash animation for scrolled-to elements */
.highlight-flash {
    animation: highlightPulse 2s ease-out;
}

@keyframes highlightPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(154, 217, 146, 0.7);
        background-color: rgba(154, 217, 146, 0.2);
    }
    50% {
        box-shadow: 0 0 15px 5px rgba(154, 217, 146, 0.4);
        background-color: rgba(154, 217, 146, 0.15);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(154, 217, 146, 0);
        background-color: transparent;
    }
}

/* Toast notifications */
.chat-notification {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(0, 0, 0, 0.9);
    color: var(--text-color);
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    border: 1px solid var(--text-color);
    font-family: var(--font-code);
    font-size: 0.85rem;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 9999;
}

.chat-notification.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.chat-notification.warning {
    border-color: var(--accent-orange);
    color: var(--accent-orange);
}

.chat-notification.error {
    border-color: var(--accent-pink);
    color: var(--accent-pink);
}

/* Make compute tool calls stand out more */
.tool-call-event[data-timestamp] {
    transition: all 0.3s ease;
}

.tool-call-event .tool-call-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Loading indicator */
#messages-loading {
    display: none;
    padding: 1rem;
    text-align: center;
    color: var(--text-color);
    font-family: var(--font-code);
    background: rgba(50, 53, 54, 0.8);
    border: 1px solid var(--text-color);
    border-radius: 6px;
    margin: 1rem auto;
    max-width: 300px;
}

#messages-loading.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ==================== CHAT DRAWER ==================== */

/* Toggle button - fixed on left edge */
#chat-drawer-toggle {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1050;
    background: rgba(50, 53, 54, 0.9);
    border: 1px solid rgba(154, 217, 146, 0.3);
    border-left: none;
    border-radius: 0 6px 6px 0;
    color: var(--text-color);
    padding: 0.8rem 0.4rem;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s;
    line-height: 1;
}

#chat-drawer-toggle:hover {
    background: rgba(154, 217, 146, 0.15);
    box-shadow: 0 0 10px rgba(154, 217, 146, 0.3);
}

#chat-drawer-toggle.open {
    left: 220px;
}

/* Overlay backdrop */
#chat-drawer-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1039;
}

#chat-drawer-overlay.open {
    display: block;
}

/* Drawer panel */
#chat-drawer {
    position: fixed;
    top: 0;
    left: -240px;
    width: 220px;
    height: 100%;
    z-index: 1040;
    background: rgba(46, 49, 50, 0.95);
    border-right: 1px solid rgba(154, 217, 146, 0.3);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.6);
    transition: left 0.3s ease;
    display: flex;
    flex-direction: column;
    padding: 0;
}

#chat-drawer.open {
    left: 0;
}

.chat-drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid rgba(154, 217, 146, 0.2);
}

.chat-drawer-title {
    font-family: var(--font-main);
    font-size: 1.1rem;
    letter-spacing: 3px;
    color: var(--accent-green);
    text-transform: uppercase;
}

#chat-drawer-close {
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.2rem;
    opacity: 0.6;
    transition: opacity 0.2s;
}

#chat-drawer-close:hover {
    opacity: 1;
}

/* Chat list inside drawer */
.chat-drawer-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    scrollbar-width: thin;
    scrollbar-color: var(--text-color) transparent;
}

.chat-tab {
    font-family: var(--font-code);
    font-size: 0.75rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 0.5rem 0.6rem;
    border: 1px solid rgba(154, 217, 146, 0.2);
    border-radius: 3px;
    color: var(--text-color);
    background: transparent;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    width: 100%;
    text-align: left;
}

.chat-tab:hover {
    background: rgba(154, 217, 146, 0.1);
    border-color: var(--text-color);
    color: var(--text-color);
}

.chat-tab.active {
    background: rgba(154, 217, 146, 0.2);
    border-color: var(--text-color);
    color: var(--text-color);
    box-shadow: 0 0 6px rgba(154, 217, 146, 0.3);
}

.chat-tab.paused {
    border-color: rgba(249, 200, 144, 0.5);
    color: var(--accent-orange);
    background: rgba(249, 200, 144, 0.08);
}

.chat-tab .chat-tab-status {
    font-size: 0.55rem;
    letter-spacing: 0.7px;
    color: var(--accent-orange);
    border: 1px solid rgba(249, 200, 144, 0.5);
    padding: 0 3px;
    border-radius: 3px;
    flex-shrink: 0;
}

.chat-tab .tab-close {
    font-size: 0.65rem;
    opacity: 0.5;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
    flex-shrink: 0;
}

.chat-tab .tab-close:hover {
    opacity: 1;
    color: var(--accent-red);
}

#new-chat-btn {
    font-family: var(--font-code);
    font-size: 0.7rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 0.5rem 0.6rem;
    margin-top: 0.3rem;
    border: 1px dashed rgba(154, 217, 146, 0.3);
    border-radius: 3px;
    color: var(--text-color);
    background: transparent;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

#new-chat-btn:hover {
    background: rgba(154, 217, 146, 0.1);
    border-color: var(--text-color);
}

/* Archive button on chat tabs */
.chat-tab .tab-archive {
    font-size: 0.6rem;
    opacity: 0.4;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
    flex-shrink: 0;
}

.chat-tab .tab-archive:hover {
    opacity: 1;
    color: var(--accent-purple);
}

/* Archive section in drawer */
.archive-section {
    border-top: 1px solid rgba(154, 217, 146, 0.15);
    padding: 0.3rem 0.5rem;
    flex-shrink: 0;
}

.archive-toggle {
    background: none;
    border: none;
    color: var(--accent-purple);
    font-family: var(--font-code);
    font-size: 0.65rem;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.2rem;
    width: 100%;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.archive-toggle:hover {
    opacity: 1;
}

.archive-chevron {
    transition: transform 0.2s;
    font-size: 0.6rem;
}

.archive-chevron.open {
    transform: rotate(90deg);
}

.archive-count {
    font-size: 0.55rem;
    border: 1px solid rgba(51, 163, 126, 0.4);
    padding: 0 4px;
    border-radius: 3px;
    color: var(--accent-purple);
}

.archive-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.3rem 0;
    max-height: 200px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-purple) transparent;
}

.archived-chat-item {
    font-family: var(--font-code);
    font-size: 0.65rem;
    padding: 0.35rem 0.5rem;
    border: 1px solid rgba(51, 163, 126, 0.2);
    border-radius: 3px;
    color: var(--accent-purple);
    background: rgba(51, 163, 126, 0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.3rem;
}

.archived-chat-item .archived-chat-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.archived-chat-item .archived-chat-title {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.archived-chat-item .archived-chat-time {
    display: block;
    font-size: 0.55rem;
    opacity: 0.6;
    margin-top: 1px;
}

.archived-chat-item .unarchive-btn {
    background: none;
    border: 1px solid rgba(51, 163, 126, 0.4);
    border-radius: 3px;
    color: var(--accent-purple);
    font-family: var(--font-code);
    font-size: 0.5rem;
    letter-spacing: 0.5px;
    padding: 2px 5px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}

.archived-chat-item .unarchive-btn:hover {
    background: rgba(51, 163, 126, 0.15);
    border-color: var(--accent-purple);
}

/* ==================== MOBILE RESPONSIVE STYLES ==================== */

/* Tablet and below */
@media (max-width: 991.98px) {
    /* Hide sidebar on tablet - can be toggled */
    .col-md-3.border-start {
        display: none;
    }
    
    .col-md-9 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* Mobile phones */
@media (max-width: 767.98px) {
    body {
        font-size: 1rem;
    }
    
    /* Compact header */
    header {
        padding: 0.5rem 0.75rem !important;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    header .logo-text h1 {
        font-size: 1rem !important;
        letter-spacing: 1px;
    }
    
    header .system-version-text {
        font-size: 0.55rem !important;
        letter-spacing: 1px;
    }
    
    /* Smaller status badges */
    #status-indicator {
        gap: 0.25rem !important;
    }
    
    #status-indicator .badge {
        font-size: 0.6rem;
        padding: 0.2rem 0.4rem;
    }
    
    /* Compact navigation */
    header nav {
        gap: 0.25rem !important;
    }
    
    header nav .btn {
        font-size: 0.65rem;
        padding: 0.25rem 0.5rem;
    }
    
    header nav .btn-outline-light:not(#search-toggle) {
        display: none; /* Hide DASHBOARD and RESEARCH on mobile */
    }
    
    header .btn-outline-danger {
        font-size: 0.6rem;
        padding: 0.2rem 0.4rem;
    }
    
    /* Main layout */
    .container-fluid {
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile browsers */
    }
    
    .row.flex-grow-1 {
        min-height: 0; /* Allow flex to shrink properly */
    }
    
    /* Messages container */
    #messages-container {
        padding: 0.75rem !important;
    }
    
    .message {
        max-width: 90%;
        padding: 0.75rem !important;
        font-size: 0.85rem;
    }
    
    .message .timestamp {
        font-size: 0.65rem;
    }
    
    /* Tool call events */
    .tool-call-event {
        max-width: 95%;
        padding: 0.5rem;
        font-size: 0.75rem;
    }
    
    /* Input area */
    .p-3.bg-secondary {
        padding: 0.5rem !important;
    }
    
    #message-form {
        gap: 0.5rem !important;
    }
    
    #message-input {
        font-size: 0.9rem;
        min-height: 36px !important;
    }
    
    #message-input::placeholder {
        font-size: 0.75rem;
    }
    
    #send-btn {
        padding: 0.4rem 0.75rem !important;
        font-size: 0.75rem;
    }
    
    #send-btn .bi-send-fill {
        display: none; /* Hide icon, keep text */
    }
    
    #attach-btn {
        padding: 0.4rem 0.5rem;
    }
    
    /* Search container */
    #search-container {
        padding: 0.5rem !important;
    }
    
    #search-input {
        font-size: 0.85rem;
    }
    
    /* Start of transmission text */
    #messages .text-center.text-muted {
        font-size: 0.7rem;
    }
    
    /* Compute result display */
    .compute-result-display {
        padding: 0.5rem;
    }
    
    .compute-task {
        font-size: 0.7rem;
    }
}

/* Activity Card: Variable Snapshots */
.activity-variables {
    margin-top: 0.4rem;
    padding-top: 0.3rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.7rem;
}

.vars-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--accent-green);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.65rem;
    margin-bottom: 0.25rem;
}

.vars-count {
    color: rgba(255, 255, 255, 0.5);
    font-weight: normal;
}

.var-entry {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    padding: 0.1rem 0.3rem;
    border-radius: 2px;
}

.var-entry.var-new {
    background: rgba(154, 217, 146, 0.1);
    border-left: 2px solid var(--accent-green);
}

.var-entry.var-changed {
    background: rgba(249, 200, 144, 0.1);
    border-left: 2px solid var(--accent-orange);
}

.var-name {
    color: var(--accent-orange);
    font-weight: 500;
    font-family: var(--font-code);
}

.var-type {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.6rem;
}

.var-size {
    color: rgba(255, 255, 255, 0.35);
    font-size: 0.6rem;
    margin-left: auto;
}

.var-func {
    padding: 0.15rem 0.3rem;
    border-left: 2px solid var(--accent-purple);
    background: rgba(51, 163, 126, 0.08);
}

.var-func .var-name {
    color: var(--accent-purple);
}

/* Activity Card: Partial Result Streaming */
.activity-partial-result {
    margin-top: 0.4rem;
    padding: 0.4rem 0.5rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(154, 217, 146, 0.15);
    border-radius: 4px;
    font-family: var(--font-code);
    font-size: 0.7rem;
    color: var(--text-color);
    max-height: 200px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.4;
}

/* Extra small phones */
@media (max-width: 375px) {
    header .logo-text h1 {
        font-size: 0.85rem !important;
    }
    
    header .system-version-text {
        display: none;
    }
    
    #status-indicator .badge {
        font-size: 0.55rem;
        padding: 0.15rem 0.3rem;
    }
    
    header nav .btn-primary {
        display: none; /* Hide CHAT button on very small screens */
    }
    
    #send-btn {
        padding: 0.35rem 0.5rem !important;
    }
    
    .message {
        font-size: 0.8rem;
    }
}

/* Landscape mobile - reduce header even more */
@media (max-height: 500px) and (orientation: landscape) {
    header {
        padding: 0.25rem 0.5rem !important;
    }

    header .logo-text h1 {
        font-size: 0.9rem !important;
    }

    header .system-version-text {
        display: none;
    }

    .p-3.bg-secondary {
        padding: 0.4rem !important;
    }
}

/* ==================== PHASE 2: COMPUTE & TOOL PRESENTATION ==================== */

/* Copy button on code blocks (2.2) */
.code-block-wrapper {
    position: relative;
}

.copy-code-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    padding: 2px 8px;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(154, 217, 146, 0.3);
    border-radius: 3px;
    color: var(--text-color);
    font-family: var(--font-code);
    font-size: 0.6rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 2;
    letter-spacing: 1px;
}

.code-block-wrapper:hover .copy-code-btn {
    opacity: 1;
}

.copy-code-btn:hover {
    background: rgba(154, 217, 146, 0.15);
    border-color: var(--accent-green);
}

/* Thumbs up/down on agent final() turn cards. Renders below the
   timestamp; muted by default and brightens on hover. The active
   selection (last-clicked signal) stays highlighted so users see
   what they just sent. */
.message-feedback {
    display: flex;
    gap: 6px;
    margin-top: 4px;
    align-items: center;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.message.agent:hover .message-feedback {
    opacity: 1;
}

/* Touch devices have no hover — keep thumbs at full opacity so
   they're discoverable. ``hover: none`` matches phones / tablets;
   desktop still uses the dim-until-hover behavior above. */
@media (hover: none) {
    .message-feedback {
        opacity: 1;
    }
}

.feedback-btn {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    color: inherit;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.feedback-btn:hover {
    background: rgba(154, 217, 146, 0.10);
    border-color: var(--accent-green, #9ad992);
}

.feedback-btn:active {
    transform: scale(0.92);
}

.feedback-btn.feedback-active {
    background: rgba(154, 217, 146, 0.20);
    border-color: var(--accent-green, #9ad992);
}

.feedback-btn.feedback-negative.feedback-active {
    background: rgba(217, 154, 154, 0.20);
    border-color: #d99a9a;
}

/* Prompt inspector modal: dynamically inserted on inspect-button
   click; renders the full messages array sent to the LLM that
   produced this final. Style match the chat surface (mono / dark)
   rather than a generic Bootstrap modal. */
.prompt-inspector-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.prompt-inspector-panel {
    background: var(--bg-primary, #0f0f0f);
    color: var(--fg-primary, #e0e0e0);
    border: 1px solid var(--accent-green, #9ad992);
    border-radius: 6px;
    width: min(900px, 100%);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.prompt-inspector-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-bottom: 1px solid rgba(154, 217, 146, 0.25);
}

.prompt-inspector-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 1px;
}

.prompt-inspector-close {
    background: transparent;
    border: 1px solid transparent;
    color: inherit;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0 8px;
    border-radius: 3px;
}

.prompt-inspector-close:hover {
    background: rgba(154, 217, 146, 0.10);
    border-color: var(--accent-green, #9ad992);
}

.prompt-inspector-body {
    overflow-y: auto;
    padding: 16px 18px;
    flex: 1;
}

.prompt-inspector-empty {
    padding: 24px;
    text-align: center;
    opacity: 0.7;
}

.prompt-inspector-system {
    margin-bottom: 12px;
    border: 1px solid rgba(154, 217, 146, 0.20);
    border-radius: 4px;
    padding: 6px 10px;
}

.prompt-inspector-system summary {
    cursor: pointer;
    font-weight: 600;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 11px;
}

.prompt-inspector-turn {
    margin-bottom: 14px;
    padding: 12px 14px;
    border-radius: 6px;
    border-left: 3px solid rgba(154, 217, 146, 0.30);
    background: rgba(255, 255, 255, 0.02);
}

.prompt-inspector-turn.role-user {
    border-left-color: rgba(120, 180, 240, 0.7);
    background: rgba(120, 180, 240, 0.04);
}

.prompt-inspector-turn.role-assistant {
    border-left-color: rgba(154, 217, 146, 0.7);
    background: rgba(154, 217, 146, 0.04);
}

.prompt-inspector-role {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 10px;
    font-weight: 600;
    opacity: 0.85;
    margin-bottom: 8px;
}

.prompt-inspector-turn.role-user .prompt-inspector-role {
    background: rgba(120, 180, 240, 0.16);
    color: rgba(160, 200, 240, 0.95);
}

.prompt-inspector-turn.role-assistant .prompt-inspector-role {
    background: rgba(154, 217, 146, 0.16);
    color: rgba(170, 220, 160, 0.95);
}

.prompt-inspector-content {
    font-family: var(--font-body, system-ui, sans-serif);
    font-size: 13px;
    line-height: 1.5;
}

.prompt-inspector-content > *:first-child { margin-top: 0; }
.prompt-inspector-content > *:last-child { margin-bottom: 0; }

.prompt-inspector-content p {
    margin: 0 0 0.5em 0;
}

.prompt-inspector-content code {
    background-color: rgba(46, 49, 50, 0.8);
    padding: 0.15em 0.4em;
    border-radius: 3px;
    font-family: var(--font-code, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace);
    font-size: 0.9em;
    border: 1px solid rgba(74, 77, 79, 0.5);
}

.prompt-inspector-content pre {
    background-color: rgba(46, 49, 50, 0.8);
    padding: 0.75em;
    border-radius: 4px;
    overflow-x: auto;
    margin: 0.5em 0;
    border: 1px solid rgba(74, 77, 79, 0.5);
    white-space: pre;
    word-break: normal;
    font-size: 12px;
    line-height: 1.4;
}

.prompt-inspector-content pre code {
    background: none;
    padding: 0;
    border: none;
    border-radius: 0;
    font-size: inherit;
}

.prompt-inspector-content ul,
.prompt-inspector-content ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}

.prompt-inspector-content li { margin: 0.25em 0; }

.prompt-inspector-content blockquote {
    border-left: 3px solid var(--blue-grey);
    margin: 0.5em 0;
    padding-left: 1em;
    opacity: 0.9;
}

.prompt-inspector-content h1,
.prompt-inspector-content h2,
.prompt-inspector-content h3,
.prompt-inspector-content h4 {
    margin: 0.5em 0 0.25em 0;
    font-weight: bold;
}

.prompt-inspector-content h1 { font-size: 1.25em; }
.prompt-inspector-content h2 { font-size: 1.15em; }
.prompt-inspector-content h3 { font-size: 1.05em; }
.prompt-inspector-content h4 { font-size: 1em; }

.prompt-inspector-content a {
    color: var(--blue-grey);
    text-decoration: underline;
}

.prompt-inspector-turn.is-final {
    position: relative;
    margin-top: 28px;
    padding: 16px 18px;
    background: rgba(154, 217, 146, 0.09);
    border: 1px solid rgba(154, 217, 146, 0.35);
    border-left: 4px solid var(--accent-green, #9ad992);
    box-shadow: 0 0 0 1px rgba(154, 217, 146, 0.10), 0 4px 12px rgba(0, 0, 0, 0.20);
}

/* "Final Output ↓" banner — points the eye at the reply that
   produced the click. Pure CSS so the JS role label stays clean. */
.prompt-inspector-turn.is-final::before {
    content: '↓ FINAL OUTPUT';
    position: absolute;
    top: -10px;
    left: 14px;
    padding: 2px 10px;
    border-radius: 10px;
    background: var(--accent-green, #9ad992);
    color: #0f0f0f;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
}

.prompt-inspector-turn.is-final .prompt-inspector-role {
    background: rgba(154, 217, 146, 0.28);
    color: var(--accent-green, #9ad992);
    opacity: 1;
}

.prompt-inspector-turn.is-final .prompt-inspector-content {
    font-size: 13.5px;
}

.prompt-inspector-footer {
    padding: 8px 12px;
    border-top: 1px solid rgba(154, 217, 146, 0.25);
    font-size: 11px;
    opacity: 0.7;
    word-break: break-all;
}

/* REPL tool-result rendering. Compute calls return
   ``{stdout, stderr, exit_code, final_called, files_changed}`` and
   the stdout/stderr strings are typically multi-line. JSON.stringify
   leaves ``\n`` as escaped chars, so we render those fields as
   proper preformatted blocks instead. */
.prompt-inspector-repl-result {
    margin: 0.5em 0;
    border: 1px solid rgba(74, 77, 79, 0.55);
    border-radius: 4px;
    overflow: hidden;
    background: rgba(46, 49, 50, 0.3);
}

.prompt-inspector-repl-meta {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 5px 10px;
    background: rgba(46, 49, 50, 0.6);
    border-bottom: 1px solid rgba(74, 77, 79, 0.4);
    font-family: var(--font-code, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace);
    font-size: 11px;
}

.prompt-inspector-repl-sep {
    opacity: 0.4;
}

.prompt-inspector-repl-exit.ok {
    color: rgba(154, 217, 146, 0.95);
}

.prompt-inspector-repl-exit.err {
    color: rgba(220, 130, 130, 0.95);
    font-weight: 600;
}

.prompt-inspector-repl-final {
    color: rgba(154, 217, 146, 0.95);
    font-weight: 600;
}

.prompt-inspector-repl-files {
    opacity: 0.75;
}

.prompt-inspector-repl-section + .prompt-inspector-repl-section {
    border-top: 1px solid rgba(74, 77, 79, 0.4);
}

.prompt-inspector-repl-label {
    padding: 3px 10px;
    background: rgba(46, 49, 50, 0.55);
    font-family: var(--font-code, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    opacity: 0.6;
}

.prompt-inspector-repl-section.is-err .prompt-inspector-repl-label {
    color: rgba(220, 130, 130, 0.95);
    background: rgba(80, 40, 40, 0.4);
    opacity: 1;
}

/* Pre rules inside the REPL result deliberately override the
   ``.prompt-inspector-content pre`` defaults — no border, flush to
   the section, soft-wrap stdout/stderr (these are user-facing text,
   not code), capped height with internal scroll. */
.prompt-inspector-content .prompt-inspector-repl-section pre {
    margin: 0;
    padding: 8px 12px;
    background: rgba(20, 22, 23, 0.55);
    border: none;
    border-radius: 0;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 12px;
    line-height: 1.45;
    max-height: 360px;
    overflow-y: auto;
}

.prompt-inspector-content .prompt-inspector-repl-section.is-err pre {
    background: rgba(50, 25, 25, 0.45);
    color: rgba(255, 200, 200, 0.95);
}

.prompt-inspector-content .prompt-inspector-repl-section pre code {
    background: none;
    padding: 0;
    border: none;
    font-size: inherit;
}

/* Max-height + "show more" on large compute output (2.3) */
.compute-output-collapsible.collapsed {
    max-height: 300px;
    overflow: hidden;
    position: relative;
}

.compute-output-collapsible.collapsed::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    pointer-events: none;
}

/* Compute error display improvements (2.7) */
.step-output-section.error-msg {
    position: relative;
    padding-left: 1.5rem;
}

.step-output-section.error-msg::before {
    content: '\2717';
    position: absolute;
    left: 0;
    top: 0;
    color: var(--accent-red);
    font-size: 0.9rem;
    font-weight: bold;
}

.step-output-section.error-msg pre,
.step-output-section.stderr pre {
    word-break: break-word;
    overflow-x: auto;
}

.step-output-section.stderr {
    position: relative;
    padding-left: 1.5rem;
}

.step-output-section.stderr::before {
    content: '\26A0';
    position: absolute;
    left: 0;
    top: 0;
    color: var(--accent-orange);
    font-size: 0.9rem;
}

/* ==================== PHASE 3: CONNECTION RESILIENCE ==================== */

/* Connection lost banner (3.1) */
.connection-lost-banner {
    background: rgba(236, 162, 162, 0.15);
    border-bottom: 2px solid #eca2a2;
    color: #eca2a2;
    padding: 0.5rem 1rem;
    font-family: var(--font-code);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 10;
}

.connection-lost-banner a {
    color: #f0c0c0;
    text-decoration: underline;
    font-weight: bold;
}

.connection-lost-banner a:hover {
    color: #fff;
}

.connection-lost-dismiss {
    margin-left: auto;
    background: none;
    border: none;
    color: #eca2a2;
    font-size: 1rem;
    cursor: pointer;
    padding: 0 0.5rem;
}

.connection-lost-dismiss:hover {
    color: #fff;
}

/* Toast notification positioning fix for mobile (3.4) */
.chat-notification {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 80px);
}

@media (max-width: 768px) {
    .chat-notification {
        bottom: 140px;
    }
}

/* ==================== PHASE 4: UX & POLISH ==================== */

/* Cap textarea growth on mobile (4.4) */
#message-input {
    max-height: 40vh;
    overflow-y: auto;
}

/* Keyboard shortcuts modal (4.2) */
.shortcuts-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.shortcuts-modal {
    background: rgba(48, 51, 52, 0.96);
    border: 1px solid rgba(154, 217, 146, 0.3);
    border-radius: 4px;
    padding: 1.5rem 2rem;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

.shortcuts-modal h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    font-family: var(--font-code);
    letter-spacing: 2px;
}

.shortcuts-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.5rem 1rem;
    margin-bottom: 1rem;
}

.shortcuts-list dt {
    text-align: right;
}

.shortcuts-list kbd {
    background: rgba(154, 217, 146, 0.1);
    border: 1px solid rgba(154, 217, 146, 0.3);
    border-radius: 3px;
    padding: 0.15rem 0.5rem;
    font-family: var(--font-code);
    font-size: 0.8rem;
    color: var(--accent-green);
}

.shortcuts-list dd {
    margin: 0;
    color: #adb5bd;
    font-family: var(--font-code);
    font-size: 0.85rem;
    line-height: 1.8;
}

.shortcuts-close {
    display: block;
    margin: 0 auto;
    padding: 0.3rem 1.5rem;
    background: none;
    border: 1px solid var(--accent-green);
    border-radius: 4px;
    color: var(--accent-green);
    font-family: var(--font-code);
    font-size: 0.75rem;
    letter-spacing: 1px;
    cursor: pointer;
}

.shortcuts-close:hover {
    background: rgba(154, 217, 146, 0.1);
}

/* Scheduler styles (4.9 — extracted from inline) */
.scheduler-page .bg-darker { background-color: #2e3132 !important; }
.scheduler-page .task-card,
.scheduler-page .todo-card {
    background-color: #323536;
    border: 1px solid #4a4d4f;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    transition: all 0.2s ease;
    cursor: pointer;
}
.scheduler-page .task-card:hover,
.scheduler-page .todo-card:hover {
    border-color: #eca2a2;
    box-shadow: 0 0 10px rgba(236, 162, 162, 0.2);
}
.scheduler-page .task-card.task-selected {
    border-color: #729fb1;
    box-shadow: 0 0 10px rgba(114, 159, 177, 0.35);
    background-color: #383b3d;
}
.scheduler-page .status-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
}
.scheduler-page .cron-expression {
    font-family: monospace;
    background-color: rgba(0,0,0,0.3);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
}
.scheduler-page .todo-pending { border-left: 3px solid #f9c890; }
.scheduler-page .todo-done { border-left: 3px solid #9ad992; opacity: 0.7; }
.scheduler-page .task-enabled { border-left: 3px solid #9ad992; }
.scheduler-page .task-disabled { border-left: 3px solid #4a4d4f; opacity: 0.6; }
.scheduler-page .section-header {
    padding: 1rem;
    border-bottom: 1px solid #4a4d4f;
    background-color: #2a2d2e;
}
.scheduler-page .action-btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}
.scheduler-page .report-item {
    background-color: rgba(0,0,0,0.2);
    border-radius: 4px;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
}
.scheduler-page .report-success { border-left: 2px solid #9ad992; }
.scheduler-page .report-failed { border-left: 2px solid #dc3545; }
.scheduler-page .report-running { border-left: 2px solid #f9c890; }

/* ==================== PHASE 5: ACCESSIBILITY & PERFORMANCE ==================== */

/* Respect prefers-reduced-motion (5.4) */
@media (prefers-reduced-motion: reduce) {
    .live-dot, .spin, body::before, body::after { animation: none !important; }
    .memory-item, .folder-header, .event-node { transition: none !important; }
    .activity-card { animation: none !important; }
    .activity-card-exiting { animation: none !important; }
    .chat-notification { transition: none !important; }
}

/* Color-blind safe status indicators (5.5) */
.badge.bg-success::before { content: '\2713 '; }
.badge.bg-danger::before { content: '\2717 '; }
.badge.bg-warning::before { content: '\231A '; }

.msg-checkmark {
    color: #818a67;
    font-size: 0.75em;
    margin-left: 4px;
}

/* Focus-visible styles for keyboard navigation (5.6) */
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--accent-green);
    outline-offset: 2px;
}

/* Firefox scrollbar compatibility (5.7) */
#messages-container,
#messages,
.col-md-3 {
    scrollbar-width: thin;
    scrollbar-color: #4a4d4f #2e3132;
}

/* CRT scanline + vignette optimization (5.8) */
body::before {
    will-change: transform;
    contain: strict;
}

body::after {
    contain: strict;
}

/* ═══════════════════════════════════════════════════════════
   REPL Turn Cards
   One box per REPL turn; all intermediate code/output stays
   inside the same bubble until the final message.
   ═══════════════════════════════════════════════════════════ */

.repl-turn-card {
    align-self: flex-start;
    width: min(96%, 1100px);
    margin: 0.45rem 0;
    padding: 0;
    background: linear-gradient(180deg, rgba(16, 20, 23, 0.98) 0%, rgba(11, 14, 18, 0.98) 100%);
    border: 1px solid rgba(114, 159, 177, 0.2);
    border-left: 3px solid var(--blue-grey);
    border-radius: 8px;
    overflow: hidden;
    box-shadow:
        0 2px 10px rgba(0, 0, 0, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.repl-turn-card .repl-turn-header {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.45rem 0.75rem;
    background: linear-gradient(180deg, #252a2e 0%, #1d2225 100%);
    border-bottom: 1px solid rgba(114, 159, 177, 0.12);
    color: var(--sky-blue);
    font-weight: normal;
    cursor: pointer;
    user-select: none;
}

.repl-turn-card .repl-turn-header:focus-visible {
    outline: 1px solid rgba(114, 159, 177, 0.65);
    outline-offset: -1px;
}

.repl-turn-card .repl-turn-header .tool-name {
    color: var(--blue-grey);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.68rem;
}

.repl-stream-label {
    font-size: 0.68rem;
    letter-spacing: 0.04em;
    color: rgba(168, 188, 194, 0.72);
}

.repl-turn-card .repl-turn-badge {
    margin-left: auto;
    padding: 1px 6px;
    border-radius: 3px;
    background: rgba(114, 159, 177, 0.12);
    color: var(--sky-blue);
    font-size: 0.65rem;
    font-family: var(--font-code);
    letter-spacing: 0.05em;
}

.repl-turn-card .repl-turn-status {
    margin-left: 0.35rem;
}

.repl-turn-flow {
    position: relative;
    padding: 0.45rem 0.65rem 0.55rem 0.95rem;
}

.repl-turn-card.collapsed .repl-turn-flow {
    display: none;
}

.repl-turn-card.collapsed .repl-turn-header {
    border-bottom: none;
}

.repl-turn-flow::before {
    content: '';
    position: absolute;
    left: 0.8rem;
    top: 0.65rem;
    bottom: 0.8rem;
    width: 1px;
    background: linear-gradient(180deg, rgba(114, 159, 177, 0.42) 0%, rgba(114, 159, 177, 0.08) 100%);
}

.repl-turn-step {
    position: relative;
    margin: 0.4rem 0 0.4rem 0.7rem;
    padding: 0;
    background: rgba(8, 12, 16, 0.95);
    border: 1px solid rgba(114, 159, 177, 0.12);
    border-radius: 6px;
    overflow: hidden;
}

.repl-turn-step::before {
    content: '';
    position: absolute;
    left: -0.95rem;
    top: 0.8rem;
    width: 0.75rem;
    height: 1px;
    background: rgba(114, 159, 177, 0.28);
}

.repl-step-label,
.repl-step-header {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.65rem;
    background: rgba(32, 37, 42, 0.92);
    border-bottom: 1px solid rgba(114, 159, 177, 0.1);
    color: var(--sky-blue);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.repl-step-header {
    justify-content: space-between;
}

.repl-code-block {
    border-left: 2px solid var(--blue-grey);
}

.repl-live-stream {
    border-left: 2px solid rgba(114, 159, 177, 0.55);
}

.repl-live-stream.repl-live-reasoning {
    border-left-color: var(--accent-orange);
}

.repl-live-stream.repl-live-content {
    border-left-color: var(--blue-grey);
    opacity: 0.92;
}

.repl-exec-result {
    border-left: 2px solid var(--accent-green);
}

.repl-exec-result.repl-exec-error {
    border-left-color: var(--accent-red);
}

.repl-code-block .repl-code-pre {
    margin: 0;
    padding: 0.7rem 0.75rem;
    background: rgba(8, 12, 16, 0.95);
    color: #b8d4b0;
    font-family: var(--font-code);
    font-size: 0.78rem;
    line-height: 1.55;
    overflow: auto;
    max-height: 280px;
    border: none;
    border-radius: 0;
    white-space: pre-wrap;
    word-break: break-word;
    text-shadow: 0 0 8px rgba(154, 217, 146, 0.08);
}

.repl-code-block .repl-code-pre code {
    font-family: inherit;
    color: inherit;
}

.repl-exec-result .tool-call-details {
    margin: 0;
    border-top: 1px solid rgba(114, 159, 177, 0.1);
}

.repl-exec-result .tool-call-details summary {
    padding: 0.4rem 0.65rem;
    font-size: 0.72rem;
    color: var(--sky-blue);
    cursor: pointer;
    user-select: none;
    font-family: var(--font-code);
    letter-spacing: 0.03em;
    transition: color 0.15s;
}

.repl-exec-result .tool-call-details summary:hover {
    color: var(--accent-green);
    text-shadow: 0 0 6px rgba(154, 217, 146, 0.2);
}

.repl-exec-result .tool-call-details[open] summary {
    border-bottom: 1px solid rgba(114, 159, 177, 0.08);
    margin-bottom: 0;
}

.repl-exec-result .repl-output-pre {
    margin: 0;
    padding: 0.55rem 0.75rem;
    background: rgba(8, 12, 16, 0.9);
    color: #a8b8a0;
    font-family: var(--font-code);
    font-size: 0.75rem;
    line-height: 1.5;
    overflow: auto;
    max-height: 220px;
    border: none;
    border-radius: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.repl-exec-result .repl-stderr-label {
    color: var(--accent-red);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    opacity: 0.8;
}

.repl-turn-card .compute-status.success,
.repl-exec-result .compute-status.success {
    background: rgba(154, 217, 146, 0.15);
    color: var(--accent-green);
    font-size: 0.7rem;
    padding: 1px 5px;
    border-radius: 2px;
}

.repl-turn-card .compute-status.error,
.repl-exec-result .compute-status.error {
    background: rgba(236, 162, 162, 0.15);
    color: var(--accent-red);
    font-size: 0.7rem;
    padding: 1px 5px;
    border-radius: 2px;
}

/* Compact connected appearance when code + output are adjacent */
.repl-turn-step + .repl-turn-step {
    margin-top: -1px;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

/* Mobile */
@media (max-width: 768px) {
    .repl-turn-card {
        width: 98%;
    }

    .repl-turn-flow {
        padding-left: 0.8rem;
    }

    .repl-turn-step {
        margin-left: 0.55rem;
    }

    .repl-code-block .repl-code-pre {
        max-height: 200px;
        font-size: 0.72rem;
    }

    .repl-exec-result .repl-output-pre {
        max-height: 160px;
    }
}

/* ======================================================================
   Kokubo Prism + chat overrides (Phase 1)
   Maps prism-tomorrow's token classes onto kokubo tokens. Loading order:
   prism-tomorrow.min.css (CDN, in <head>), then this file. These rules
   win.
   ====================================================================== */

/* Comment family — kokubo skyBlue */
code[class*="language-"] .token.comment,
code[class*="language-"] .token.prolog,
code[class*="language-"] .token.doctype,
code[class*="language-"] .token.cdata {
    color: var(--sky-blue);
    font-style: italic;
}

/* String literals — kokubo blueGrey */
code[class*="language-"] .token.string,
code[class*="language-"] .token.attr-value,
code[class*="language-"] .token.char {
    color: var(--blue-grey);
}

/* Numbers, constants — kokubo olive */
code[class*="language-"] .token.number,
code[class*="language-"] .token.boolean,
code[class*="language-"] .token.constant,
code[class*="language-"] .token.symbol {
    color: var(--olive);
}

/* Keywords, control flow — kokubo sage */
code[class*="language-"] .token.keyword,
code[class*="language-"] .token.atrule,
code[class*="language-"] .token.important {
    color: var(--accent-green);
    font-weight: 500;
}

/* Function names, accents — kokubo paleYellow */
code[class*="language-"] .token.function,
code[class*="language-"] .token.builtin,
code[class*="language-"] .token.class-name {
    color: var(--pale-yellow);
}

/* Class/type definitions — kokubo teal */
code[class*="language-"] .token.tag,
code[class*="language-"] .token.namespace {
    color: var(--accent-primary);
}

/* Operators — kokubo mint */
code[class*="language-"] .token.operator,
code[class*="language-"] .token.entity,
code[class*="language-"] .token.url,
code[class*="language-"] .token.variable {
    color: var(--mint);
}

/* Punctuation — parchment (default text color) */
code[class*="language-"] .token.punctuation,
code[class*="language-"] .token.bracket {
    color: var(--text-color);
}

/* Default body text + bg inside code blocks */
code[class*="language-"],
pre[class*="language-"] {
    color: var(--text-color);
    background: var(--sidebar-bg);
    text-shadow: none;
}

/* Markdown blockquote — kokubo skyBlue per markup.quote.markdown */
.message.agent blockquote,
.message.user blockquote {
    color: var(--sky-blue);
    border-left-color: var(--sky-blue);
    font-style: italic;
}

/* Inline code outside fenced blocks — kokubo blueGrey */
.message.agent :not(pre) > code,
.message.user :not(pre) > code {
    color: var(--blue-grey);
    background: var(--bg-color);
    padding: 1px 4px;
    border-radius: 3px;
}

/* Markdown headings inside chat messages — kokubo emerald */
.message.agent h1, .message.agent h2, .message.agent h3,
.message.user h1, .message.user h2, .message.user h3 {
    color: var(--emerald);
}

/* Input fields foreground/placeholder — kokubo input tokens */
input.form-control,
textarea.form-control {
    color: var(--parchment-dim);
}
input.form-control::placeholder,
textarea.form-control::placeholder {
    color: var(--placeholder);
    opacity: 1;   /* override Bootstrap default 0.5 */
}
