:root {
    --primary: #1a1a1a;
    --primary-light: #2a2a2a;
    --accent: #e85d75;
    --accent-hover: #ff7090;
    --text: #e8e8e8;
    --text-muted: #a0a0a0;
    --bg: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --border: #333;
    --user-bg: #2a2a3a;
    --assistant-bg: transparent;
    --groq-color: #e85d75;
    --cerebras-color: #5da8e8;
    --tavily-color: #5de8a8;

    --font-display: 'Instrument Serif', serif;
    --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at 20% 50%, rgba(232, 93, 117, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(232, 93, 117, 0.08) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.app-container {
    display: flex;
    flex-direction: row;
    height: 100vh;
    position: relative;
    z-index: 1;
    overflow: hidden;
}

/* ── Sidebar ────────────────────────────────────────────────────────────────── */
.logo-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    color: inherit;
}

.sidebar {
    width: 260px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: rgba(10, 10, 10, 0.95);
    border-right: 1px solid var(--border);
    height: 100vh;
    overflow: hidden;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 20;
}

/* Collapsed state — push off-screen */
.sidebar.collapsed {
    transform: translateX(-100%);
    width: 0;
    border-right: none;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1rem 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-section-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 1rem 1.25rem 0.5rem;
    flex-shrink: 0;
}

.conversation-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.25rem 0.5rem;
}

.conversation-list::-webkit-scrollbar       { width: 4px; }
.conversation-list::-webkit-scrollbar-track { background: transparent; }
.conversation-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.conv-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.75rem;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s ease;
    position: relative;
}

.conv-item:hover  { background: var(--primary-light); }
.conv-item.active { background: rgba(232, 93, 117, 0.12); }
.conv-item.active .conv-title { color: var(--accent); }

.conv-icon {
    font-size: 0.9rem;
    flex-shrink: 0;
    opacity: 0.6;
}

.conv-body {
    flex: 1;
    min-width: 0;
}

.conv-title {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.conv-meta {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.conv-delete {
    flex-shrink: 0;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.2rem;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s, background 0.15s;
}

.conv-item:hover .conv-delete  { opacity: 1; }
.conv-delete:hover              { color: var(--accent); background: rgba(232,93,117,0.12); }

.sidebar-empty {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    padding: 2rem 1rem;
    opacity: 0.6;
}

/* Overlay (mobile only) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 15;
    backdrop-filter: blur(2px);
}

/* ── Main area ──────────────────────────────────────────────────────────────── */
.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

/* ── Header ────────────────────────────────────────────────────────────────── */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.875rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: rgba(15, 15, 15, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    gap: 1rem;
    flex-shrink: 0;
}

/* Generic icon-only button */
.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 9px;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background: var(--primary-light);
    color: var(--text);
    border-color: #444;
}

.sidebar-toggle { flex-shrink: 0; }

.header-title {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-style: italic;
    color: var(--text-muted);
    flex: 1;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 0.5rem;
}

/* Logo (inside sidebar only) */
.logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    color: inherit;
}

.logo-icon {
    font-size: 1.6rem;
    line-height: 1;
    animation: wiggle 2s ease-in-out infinite;
    display: block;
}

@keyframes wiggle {
    0%, 100% { transform: rotate(0deg); }
    25%       { transform: rotate(-5deg); }
    75%       { transform: rotate(5deg); }
}

.logo-text {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 400;
    font-style: italic;
    letter-spacing: -0.02em;
    color: var(--text);
}

/* ── New Chat Button (header) ───────────────────────────────────────────────── */
.new-chat-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 10px;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    transition: all 0.2s ease;
    font-weight: 500;
    flex-shrink: 0;
}

.new-chat-btn:hover {
    background: var(--primary-light);
    color: var(--text);
    border-color: var(--accent);
}

.new-chat-btn svg { flex-shrink: 0; }

/* ── Chat Container ────────────────────────────────────────────────────────── */
.chat-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 2rem 12%;
    scroll-behavior: smooth;
}

.chat-container::-webkit-scrollbar       { width: 8px; }
.chat-container::-webkit-scrollbar-track { background: transparent; }
.chat-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.chat-container::-webkit-scrollbar-thumb:hover { background: var(--primary-light); }

/* ── Welcome Screen ────────────────────────────────────────────────────────── */
.welcome-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    animation: fadeIn 0.6s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

.welcome-content {
    text-align: center;
    max-width: 700px;
    width: 100%;
    padding: 1rem 0 2rem;
}

.welcome-title {
    font-family: var(--font-display);
    font-size: 3.5rem;
    font-weight: 400;
    font-style: italic;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--text) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: slideUp 0.8s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to   { opacity: 1; transform: translateY(0); }
}

.welcome-subtitle {
    font-size: 1.125rem;
    color: var(--text-muted);
    margin-bottom: 2.5rem;
    animation: slideUp 0.8s ease 0.1s backwards;
}



/* ── Usage Dashboard ───────────────────────────────────────────────────────── */
.usage-dashboard {
    display: flex;
    flex-direction: column;
    gap: 0;
    background: rgba(26, 26, 26, 0.7);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
    animation: slideUp 0.8s ease 0.2s backwards;
    text-align: left;
    backdrop-filter: blur(10px);
}

/* Side-by-side row for Groq Router + Cerebras */
.usage-providers-row {
    display: flex;
    gap: 1.5rem;
}

.usage-provider {
    flex: 1;
    min-width: 0;
}

.provider-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.provider-badge {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 0.2rem 0.55rem;
    border-radius: 6px;
}

.groq-badge {
    background: rgba(232, 93, 117, 0.15);
    color: var(--groq-color);
    border: 1px solid rgba(232, 93, 117, 0.3);
}

.cerebras-badge {
    background: rgba(93, 168, 232, 0.15);
    color: var(--cerebras-color);
    border: 1px solid rgba(93, 168, 232, 0.3);
}

.provider-subtitle {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
    flex: 1;
}

.usage-refresh {
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    transition: color 0.2s, transform 0.3s;
    line-height: 1;
}

.usage-refresh:hover {
    color: var(--text);
    transform: rotate(180deg);
}

.usage-bars {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.usage-row {
    display: grid;
    grid-template-columns: 2.5rem 1fr 4.5rem;
    align-items: center;
    gap: 0.5rem;
}

.usage-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-muted);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.usage-bar-track {
    height: 5px;
    background: rgba(255, 255, 255, 0.07);
    border-radius: 99px;
    overflow: hidden;
    position: relative;
}

.usage-bar-fill {
    height: 100%;
    border-radius: 99px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 0;
}

.groq-fill {
    background: linear-gradient(90deg, #c04458, var(--groq-color));
}

.cerebras-fill {
    background: linear-gradient(90deg, #3a7fbe, var(--cerebras-color));
}

.tavily-badge {
    background: rgba(93, 232, 168, 0.15);
    color: var(--tavily-color);
    border: 1px solid rgba(93, 232, 168, 0.3);
}

.tavily-fill {
    background: linear-gradient(90deg, #2ea870, var(--tavily-color));
}

/* Single-line Tavily tracker */
.tavily-tracker {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-top: 1.25rem;
    padding-top: 1.1rem;
    border-top: 1px solid var(--border);
}

.tavily-label {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.tavily-bar-track {
    flex: 1;
}

/* Warn / danger colour overrides */
.usage-bar-fill.warn   { filter: brightness(1.2) saturate(1.3); }
.usage-bar-fill.danger {
    background: linear-gradient(90deg, #ff3333, #ff8800) !important;
    animation: pulse-bar 1s ease infinite;
}

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

.usage-numbers {
    display: flex;
    align-items: baseline;
    gap: 0.25rem;
    justify-content: flex-end;
}

.usage-numbers span:first-child {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text);
    min-width: 2rem;
    text-align: right;
}

.usage-max {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.usage-divider {
    width: 1px;
    background: var(--border);
    align-self: stretch;
    flex-shrink: 0;
}

/* ── Messages ──────────────────────────────────────────────────────────────── */
.messages-wrapper {
    max-width: 100%;
    width: 100%;
    margin: 0 auto;
    overflow-x: hidden;
}

.message {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    animation: messageSlide 0.4s ease forwards;
    opacity: 0;
}

@keyframes messageSlide {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.25rem;
}

.message.user      .message-avatar { background: var(--user-bg); }
.message.assistant .message-avatar { background: var(--accent); }

.message-content { flex: 1; min-width: 0; line-height: 1.6; overflow: hidden; }

.message-role {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

.message.user      .message-role { color: var(--text); }
.message.assistant .message-role { color: var(--accent); }

.message-text { color: var(--text); word-wrap: break-word; overflow-wrap: break-word; min-width: 0; overflow: hidden; }

.message-text h1,
.message-text h2,
.message-text h3,
.message-text h4,
.message-text h5,
.message-text h6 { margin-top: 1.5rem; margin-bottom: 0.75rem; font-weight: 600; }

.message-text h1 { font-size: 1.75rem; }
.message-text h2 { font-size: 1.5rem; }
.message-text h3 { font-size: 1.25rem; }

.message-text p             { margin-bottom: 1rem; }
.message-text p:last-child  { margin-bottom: 0; }
.message-text ul, .message-text ol { margin-left: 1.5rem; margin-bottom: 1rem; }
.message-text li            { margin-bottom: 0.5rem; }

.message-text code {
    background: var(--bg-secondary);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.875rem;
}

.message-text pre {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 1rem;
}

.message-text pre code     { background: none; padding: 0; }
.message-text blockquote   { border-left: 3px solid var(--accent); padding-left: 1rem; margin: 1rem 0; color: var(--text-muted); }
.message-text strong       { font-weight: 600; color: var(--text); }
.message-text em           { font-style: italic; }
.message-text a            { color: var(--accent); text-decoration: underline; }
.message-text a:hover      { color: var(--accent-hover); }

/* Tables */
.message-text .table-scroll {
    overflow-x: auto;
    overflow-y: visible;
    margin-bottom: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
}

.message-text table {
    border-collapse: collapse;
    font-size: 0.9rem;
    white-space: nowrap;
    width: max-content;
    min-width: 100%;
}

.message-text thead { background: rgba(232, 93, 117, 0.1); }

.message-text th,
.message-text td {
    padding: 0.6rem 0.9rem;
    border: 1px solid var(--border);
    text-align: left;
    white-space: nowrap;
}

.message-text th {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--accent);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.message-text tr:nth-child(even) td { background: rgba(255,255,255,0.02); }
.message-text tr:hover td { background: rgba(232, 93, 117, 0.05); }

/* KaTeX / LaTeX */
.message-text .katex-display {
    margin: 1rem 0;
    overflow-x: auto;
}

.message-text .katex { font-size: 1.05em; }

.message.user .message-text {
    background: var(--user-bg);
    padding: 1rem 1.25rem;
    border-radius: 16px;
    border-top-left-radius: 4px;
}

/* ── Typing Indicator ──────────────────────────────────────────────────────── */
.typing-indicator { display: flex; gap: 0.375rem; padding: 1rem 1.25rem; }

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    animation: typingBounce 1.4s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

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

.typing-label {
    display: block;
    padding: 0.75rem 1.25rem;
    font-size: 0.825rem;
    color: var(--text-secondary);
    font-style: italic;
    animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50%       { opacity: 1;   }
}

/* ── Input Area ────────────────────────────────────────────────────────────── */
.input-area {
    padding: 1.5rem 12% 1rem;
    border-top: 1px solid var(--border);
    background: rgba(15, 15, 15, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    flex-shrink: 0;
}

.input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0;
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 16px;
    padding: 0.75rem 1rem 0.6rem;
    transition: border-color 0.2s ease;
}

.input-wrapper:focus-within { border-color: var(--accent); }

#messageInput {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text);
    font-family: var(--font-body);
    font-size: 1rem;
    resize: none;
    outline: none;
    max-height: 200px;
    line-height: 1.5;
    display: flex;
    align-items: center;
    padding: 0;
    /* vertically center single-line placeholder */
    min-height: 2rem;
}

#messageInput::placeholder { color: var(--text-muted); }

/* Bottom row: send button */
.input-controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-top: 0.5rem;
}

.send-btn {
    width: 34px;
    height: 34px;
    border: none;
    background: var(--accent);
    color: white;
    border-radius: 9px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.send-btn:hover:not(:disabled)  { background: var(--accent-hover); transform: translateY(-2px); }
.send-btn:active:not(:disabled) { transform: translateY(0); }
.send-btn:disabled              { opacity: 0.4; cursor: not-allowed; }

.input-footer {
    margin-top: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.disclaimer  { font-size: 0.75rem; color: var(--text-muted); font-family: var(--font-mono); }
.char-counter {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    transition: color 0.2s ease;
    flex-shrink: 0;
}
.char-counter.warn   { color: #f0a500; }
.char-counter.danger { color: var(--accent); }

/* ── Error ─────────────────────────────────────────────────────────────────── */
.error-message {
    background: rgba(232, 93, 117, 0.1);
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 1rem 1.25rem;
    border-radius: 12px;
    margin-bottom: 1rem;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    animation: shake 0.4s ease;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25%       { transform: translateX(-10px); }
    75%       { transform: translateX(10px); }
}

/* ── Desktop ───────────────────────────────────────────────────────────────── */
@media (min-width: 1024px) {
    .welcome-content { max-width: 780px; }
}

/* ── Mobile ────────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    /* Sidebar becomes an overlay on mobile */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        width: 260px !important;
        z-index: 30;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.visible {
        display: block;
    }

    .header { padding: 0.75rem 1rem; }
    .chat-container { padding: 1rem 5%; }
    .input-area { padding: 1rem 5%; }

    .welcome-title    { font-size: 2.5rem; }
    .welcome-subtitle { font-size: 1rem; }
    .message          { gap: 0.75rem; }
    .message-avatar   { width: 32px; height: 32px; font-size: 1rem; }

    .usage-dashboard  { padding: 1.25rem; }
    .usage-providers-row { flex-direction: column; gap: 1rem; }
    .usage-divider    { width: 100%; height: 1px; }
    .usage-row        { grid-template-columns: 2.25rem 1fr 4rem; }

    .new-chat-btn span { display: none; }
}

@media (max-width: 480px) {
    .welcome-title { font-size: 2rem; }
    .usage-dashboard { padding: 1rem; }
    .tavily-tracker { flex-wrap: wrap; }
    .header-title { display: none; }
}

/* ── Stop button state ─────────────────────────────────────────────────────── */
.send-btn.stop-mode {
    background: #c0392b;
}
.send-btn.stop-mode:hover:not(:disabled) {
    background: #e74c3c;
}

/* ── Code block wrapper ────────────────────────────────────────────────────── */
.code-block-wrapper {
    position: relative;
    margin-bottom: 1rem;
}

.code-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #161b22;
    border: 1px solid #30363d;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    padding: 0.4rem 0.75rem;
}

.code-lang-label {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: #8b949e;
    text-transform: lowercase;
    letter-spacing: 0.04em;
}

.code-copy-btn {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    background: transparent;
    border: 1px solid #30363d;
    color: #8b949e;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    padding: 0.2rem 0.55rem;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.code-copy-btn:hover {
    background: rgba(255,255,255,0.06);
    color: var(--text);
    border-color: #6e7681;
}

.code-copy-btn.copied {
    color: #3fb950;
    border-color: #3fb950;
}

.message-text .code-block-wrapper pre {
    margin-bottom: 0;
    border-radius: 0 0 8px 8px;
    border: 1px solid #30363d;
    border-top: none;
    background: #0d1117;
    padding: 1rem;
    overflow-x: auto;
}

.message-text .code-block-wrapper pre code {
    background: none;
    padding: 0;
    font-size: 0.875rem;
    line-height: 1.6;
}

/* Override hljs background to match our theme */
.hljs { background: #0d1117 !important; }

/* ── Message action buttons ─────────────────────────────────────────────────── */
.message-actions {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.6rem;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.message:hover .message-actions { opacity: 1; }

.msg-action-btn {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.msg-action-btn:hover {
    background: var(--bg-secondary);
    color: var(--text);
    border-color: #555;
}

.msg-action-btn.copied {
    color: #3fb950;
    border-color: #3fb950;
}
/* ── Search Source Cards ──────────────────────────────────────────────────────── */
.search-sources {
    margin-top: 1.25rem;
    border-top: 1px solid var(--border);
    padding-top: 1rem;
}

.search-sources-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.search-sources-label::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
    opacity: 0.7;
}

.source-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.source-card {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.7rem 0.35rem 0.5rem;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    transition: all 0.15s ease;
    max-width: 280px;
    min-width: 0;
}

.source-card:hover {
    background: rgba(232, 93, 117, 0.08);
    border-color: rgba(232, 93, 117, 0.4);
    color: var(--text);
    transform: translateY(-1px);
}

.source-card-num {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    background: rgba(232, 93, 117, 0.15);
    border: 1px solid rgba(232, 93, 117, 0.3);
    color: var(--accent);
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    font-weight: 600;
    line-height: 1;
}

.source-card-favicon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    border-radius: 3px;
    object-fit: contain;
}

.source-card-favicon-fallback {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    opacity: 0.4;
}

.source-card-text {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.source-card-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text);
    font-size: 0.72rem;
    line-height: 1.2;
}

.source-card-domain {
    font-size: 0.62rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}