/* ═══════════════════════════════════════════════════════════════════════════════
   AI Chat Overlay — Full-Width Content Area Design
   ═══════════════════════════════════════════════════════════════════════════════
   The overlay fills the entire content area below the header bar.
   It squeezes when sidebars toggle and includes a vertical timeline sidebar.
*/

/* ── Chat Overlay Container ───────────────────────────────────────────────── */

#chat-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    height: 100%;
    z-index: 100;
    background: var(--bg-main, #050a14);
    display: none;
    flex-direction: row;
    overflow: hidden;
    padding: 0 0 15px 0;
    margin: 0;
    box-sizing: border-box;
    animation: chatOverlayIn 0.3s ease;
}

#chat-overlay.active {
    display: flex;
}

/* Slide-down transition: input area starts near top, slides to bottom */
#chat-overlay.from-search .chat-main {
    animation: chatFromSearchIn 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

#chat-overlay.from-search .chat-input-area {
    animation: inputSlideDown 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes chatFromSearchIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes inputSlideDown {
    0% {
        transform: translateY(-70vh);
        opacity: 0.9;
    }
    60% {
        opacity: 1;
    }
    100% {
        transform: translateY(0);
    }
}

@keyframes chatOverlayIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ── Timeline Sidebar (Session History) ───────────────────────────────────── */

.chat-timeline {
    width: 64px;
    min-width: 64px;
    max-height: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 8px 0;
    overflow: hidden;
    scrollbar-width: none;
    background: #050a14;
    position: relative;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1), min-width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    box-sizing: border-box;
    
    /* Theme variables matching production Copilot mode */
    --tl-accent: #00f0ff;
    --tl-accent-rgb: 0, 240, 255;
    --tl-border: rgba(0, 240, 255, 0.12);
    --tl-bg: rgba(0, 240, 255, 0.02);
    --tl-node: rgba(0, 240, 255, 0.5);
    --tl-node-active: #00f0ff;
    --tl-line: rgba(0, 240, 255, 0.12);
    --tl-text: rgba(0, 240, 255, 0.6);
    --tl-text-dim: rgba(0, 240, 255, 0.3);
    --tl-text-bright: rgba(0, 240, 255, 0.85);
    --tl-separator: rgba(0, 240, 255, 0.08);
}
.chat-timeline::-webkit-scrollbar { display: none; }

/* On hover — expand to double the width space (440px) */
.chat-timeline:hover {
    width: 440px;
    min-width: 440px;
}

/* New session button (top) */
.timeline-new-btn {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--tl-bg);
    border: 1.5px solid var(--tl-border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--tl-accent);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin: 4px 0 8px 19px;  /* 19px left centers 26px inside 64px (center = 32px) */
}
.timeline-new-btn:hover {
    background: rgba(var(--tl-accent-rgb), 0.12);
    color: var(--tl-accent);
    border-color: rgba(var(--tl-accent-rgb), 0.3);
    box-shadow: 0 0 12px rgba(var(--tl-accent-rgb), 0.2);
}
.timeline-new-btn svg {
    width: 13px;
    height: 13px;
    stroke: currentColor;
    stroke-width: 2.5;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ── Collapsed View ── */
.timeline-collapsed-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 64px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    scrollbar-width: none;
    transition: opacity 200ms ease;
    opacity: 0.5;
    position: relative; /* relative for absolute continuous line */
}
.timeline-collapsed-content::-webkit-scrollbar { display: none; }
.chat-timeline:hover .timeline-collapsed-content {
    display: none;
}
.timeline-collapsed-content:hover {
    opacity: 1;
}

/* Continuous vertical line behind dots in collapsed view */
.timeline-collapsed-content::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 31.5px; /* centers the 1px line in the 64px width */
    width: 1px;
    background: var(--tl-line);
    z-index: 1;
}

.timeline-search-icon-collapsed {
    color: var(--tl-text-dim);
    margin: 8px auto 12px;
    flex-shrink: 0;
    opacity: 0.6;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2;
    background: #050a14;
    padding: 2px;
}

/* Collapsed Node */
.timeline-node {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #050a14; /* masks the vertical line segment behind it */
    border: 1.5px solid var(--tl-node);
    flex-shrink: 0;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    z-index: 2;
    margin: 10px 0;
}
.timeline-node:hover {
    background: var(--tl-accent);
    box-shadow: 0 0 8px rgba(var(--tl-accent-rgb), 0.5);
    transform: scale(1.4);
}
.timeline-node.active {
    background: var(--tl-node-active);
    box-shadow: 0 0 8px rgba(var(--tl-accent-rgb), 0.6);
    width: 10px;
    height: 10px;
}
.timeline-node.starred {
    background: var(--tl-node-active);
    box-shadow: 0 0 6px rgba(var(--tl-accent-rgb), 0.4);
}

/* Collapsed Date separator */
.date-separator-collapsed {
    width: 20px;
    height: 28px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    position: relative;
    z-index: 2;
    background: #050a14;
    margin: 0 auto; /* center in 64px */
}
.date-separator-collapsed::after {
    content: '';
    width: 100%;
    height: 1px;
    background: var(--tl-separator);
}

/* ── Expanded View ── */
.timeline-expanded-content {
    display: none;
    flex-direction: column;
    height: 100%;
    width: 100%;
    overflow: hidden;
    opacity: 0;
    transition: opacity 200ms ease;
}
.chat-timeline:hover .timeline-expanded-content {
    display: flex;
    opacity: 1;
}

/* Search bar */
.timeline-search-bar {
    padding: 6px 10px;
    border-bottom: 1px solid var(--tl-border);
    width: 100%;
    box-sizing: border-box;
    flex-shrink: 0;
}
.timeline-search-input-wrapper {
    position: relative;
    width: 100%;
}
.timeline-search-input-icon {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--tl-text-dim);
    pointer-events: none;
}
.timeline-search-input-expanded {
    width: 100%;
    background: rgba(var(--tl-accent-rgb), 0.04);
    border: 1px solid rgba(var(--tl-accent-rgb), 0.12);
    border-radius: 6px;
    padding: 5px 8px 5px 28px;
    font-size: 11px;
    font-family: monospace;
    color: var(--tl-text-bright);
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s;
}
.timeline-search-input-expanded:focus {
    border-color: rgba(var(--tl-accent-rgb), 0.3);
}
.timeline-search-input-expanded::placeholder {
    color: var(--tl-text-dim);
}

/* Session list scroll area */
.timeline-session-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px 0;
    scrollbar-width: none;
}
.timeline-session-list::-webkit-scrollbar { display: none; }

/* Pinned Section */
.timeline-pinned-section {
    padding: 2px 0 6px;
    border-bottom: 1px solid var(--tl-separator);
}
.timeline-pinned-label {
    font-size: 11px;
    font-family: monospace;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--tl-text-dim);
    padding: 8px 4px 4px 24px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Expanded Date separator */
.timeline-date-separator-expanded {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px 4px 24px;
}
.timeline-date-separator-line {
    flex: 1;
    height: 1px;
    background: var(--tl-separator);
}
.timeline-date-separator-text {
    font-size: 9px;
    font-family: monospace;
    color: var(--tl-text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
    font-weight: 600;
}

/* Session Row */
.timeline-session-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px 0 24px;
    cursor: pointer;
    transition: background 0.15s ease;
    position: relative;
    min-height: 48px;
}
.timeline-session-row:hover {
    background: rgba(var(--tl-accent-rgb), 0.04);
}
.timeline-session-row.active {
    background: rgba(var(--tl-accent-rgb), 0.08);
}
.timeline-session-row.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 2px;
    height: 60%;
    background: var(--tl-accent);
    border-radius: 0 2px 2px 0;
    box-shadow: 0 0 6px rgba(var(--tl-accent-rgb), 0.4);
}

/* Timeline Node Column in Row */
.timeline-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 16px;
    flex-shrink: 0;
    position: relative;
    align-self: stretch;
}
.timeline-col::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 1px;
    background: var(--tl-line);
}
.timeline-session-row.last-row .timeline-col::before {
    bottom: 50%;
}
.timeline-row-node {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--tl-node);
    flex-shrink: 0;
    transition: all 0.15s;
    position: relative;
    z-index: 1;
}
.timeline-session-row.active .timeline-row-node {
    background: var(--tl-node-active);
    box-shadow: 0 0 6px rgba(var(--tl-accent-rgb), 0.5);
    width: 9px;
    height: 9px;
}

/* Session Info Text */
.timeline-session-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.timeline-session-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--tl-text-bright);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}
.timeline-session-time {
    font-size: 9px;
    font-family: monospace;
    color: var(--tl-text-dim);
}

/* Actions (Visible on Row Hover) */
.timeline-session-actions {
    display: none;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
.timeline-session-row:hover .timeline-session-actions {
    display: flex;
}
.timeline-star-btn, .timeline-edit-btn, .timeline-delete-btn {
    padding: 3px;
    border-radius: 4px;
    border: none;
    background: transparent;
    color: var(--tl-text-dim);
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.timeline-star-btn:hover, .timeline-edit-btn:hover {
    color: var(--tl-accent);
    background: rgba(var(--tl-accent-rgb), 0.1);
}
.timeline-star-btn.active {
    color: var(--tl-accent) !important;
}

/* Delete button turns red on hover */
.timeline-delete-btn:hover {
    color: #ef4444 !important;
    background: rgba(239, 68, 68, 0.1) !important;
}

/* Inline Edit Input */
.timeline-edit-form {
    width: 100%;
}
.timeline-edit-input {
    width: 100%;
    background: rgba(var(--tl-accent-rgb), 0.08);
    border: 1px solid rgba(var(--tl-accent-rgb), 0.25);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 13px;
    color: var(--tl-text-bright);
    outline: none;
    font-family: inherit;
}

/* Delete Confirmation State (Matches Investing Tools Style) */
.timeline-session-row.timeline-row-confirming {
    background: rgba(255, 80, 80, 0.08) !important;
}
.timeline-delete-confirm {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
.timeline-confirm-yes, .timeline-confirm-no {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 700;
    transition: all 0.15s ease;
}
.timeline-confirm-yes {
    background: rgba(255, 80, 80, 0.15);
    color: #ff5050;
}
.timeline-confirm-yes:hover {
    background: rgba(255, 80, 80, 0.3);
}
.timeline-confirm-divider {
    color: var(--tl-text-dim);
    opacity: 0.3;
    font-size: 11px;
}
.timeline-confirm-no {
    background: rgba(0, 240, 255, 0.08);
    color: var(--tl-accent);
}
.timeline-confirm-no:hover {
    background: rgba(0, 240, 255, 0.2);
}

/* ── Chat Main Area ───────────────────────────────────────────────────────── */

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    max-height: 100%;
    height: 100%;
    overflow: hidden;
    box-sizing: border-box;
}

/* Close button */
.chat-close-bar {
    display: flex; align-items: center; justify-content: flex-end;
    padding: 6px 16px 0; flex-shrink: 0;
}
.chat-close-btn {
    background: none; border: none;
    color: var(--text-muted, #6a7080); cursor: pointer;
    padding: 6px; border-radius: 6px; transition: all 0.15s;
    display: flex; align-items: center; justify-content: center;
}
.chat-close-btn:hover {
    color: var(--text-primary, #e6e8ec);
    background: rgba(255, 255, 255, 0.06);
}
.chat-close-btn svg {
    width: 18px; height: 18px; stroke: currentColor;
    stroke-width: 2; fill: none;
    stroke-linecap: round; stroke-linejoin: round;
}

/* ── Messages Area ────────────────────────────────────────────────────────── */

.chat-messages {
    flex: 1 1 0;
    min-height: 0;
    max-height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 32px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scrollbar-width: none;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
}

.chat-messages::-webkit-scrollbar { display: none; }

/* ── Empty State (Production Manawa Landing) ─────────────────────────────── */

.chat-empty-header {
    display: none;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-bottom: 24px;
}

.chat-empty-logo-wrap {
    position: relative;
    margin-bottom: 12px;
}

.chat-empty-logo-glow {
    position: absolute;
    inset: 0;
    background: rgba(0, 240, 255, 0.2);
    filter: blur(48px);
    border-radius: 50%;
    transform: scale(1.5);
}

.chat-empty-logo {
    width: 96px;
    height: 96px;
    position: relative;
    z-index: 1;
    filter: drop-shadow(0 0 15px rgba(0, 240, 255, 0.4));
}

.chat-empty-heading {
    font-size: 42px;
    font-weight: 300;
    color: #fff;
    margin: 0;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.chat-empty-heading-accent {
    color: var(--neon-cyan, #00f0ff);
    font-weight: 500;
}

/* Empty State centering layouts */
.chat-main.is-empty #chat-messages {
    display: none !important;
}

.chat-main.is-empty .chat-input-area {
    flex: 1;
    display: grid;
    grid-template-rows: 1fr auto 1fr;
    height: 100%;
    align-items: center;
    justify-items: center;
    padding: 24px;
    max-width: 820px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

.chat-main.is-empty .chat-empty-header {
    grid-row: 1;
    align-self: end;
    display: flex;
    margin-bottom: 32px;
}

.chat-main.is-empty .chat-input-wrapper {
    grid-row: 2;
    align-self: center;
    width: 100%;
    position: relative;
}

.chat-main.is-empty .chat-input-box {
    width: 100%;
    margin-bottom: 0px;
}

.chat-main.is-empty .chat-shortcuts {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 10px;
    margin-bottom: 0;
    white-space: nowrap;
}

.chat-main.is-empty .chat-starter-cards {
    grid-row: 3;
    align-self: start;
    display: grid;
    margin-top: 48px;
}

.chat-input-wrapper {
    width: 100%;
}

/* ── Starter Chips ────────────────────────────────────────────────────────── */

.chat-starters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    max-width: 600px;
}

.chat-starter-chip {
    padding: 10px 18px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    font-size: 13px;
    color: var(--text-secondary, #9da3b0);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.chat-starter-chip:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.25);
    color: #ffffff;
    transform: translateY(-1px);
}

/* ── Message Bubble ───────────────────────────────────────────────────────── */

.chat-msg {
    display: flex;
    flex-direction: column;
    gap: 6px;
    animation: chat-msg-in 0.3s ease;
}

@keyframes chat-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-msg--user {
    align-items: flex-end;
}

.chat-msg--user .chat-msg-bubble {
    background: rgba(0, 240, 255, 0.08);
    border: 1px solid rgba(0, 240, 255, 0.15);
    border-radius: 16px 16px 4px 16px;
    max-width: 85%;
    color: var(--neon-cyan, #00f0ff);
    box-shadow: 0 4px 12px rgba(0, 240, 255, 0.1);
    backdrop-filter: blur(4px);
    font-weight: 300;
}

.chat-msg-user-row {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
}

.chat-msg-copy-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid rgba(0, 240, 255, 0.15);
    background: none;
    color: rgba(0, 240, 255, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    opacity: 0;
    flex-shrink: 0;
}

.chat-msg--user:hover .chat-msg-copy-btn {
    opacity: 1;
}

.chat-msg-copy-btn:hover {
    border-color: rgba(0, 240, 255, 0.35);
    background: rgba(0, 240, 255, 0.08);
    color: var(--neon-cyan, #00f0ff);
}

.chat-msg-copy-btn svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

.chat-msg-timestamp-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    margin-right: 8px;
}

.chat-msg-timestamp {
    font-size: 10px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    color: rgba(0, 240, 255, 0.4);
}

.chat-msg-copied-feedback {
    font-size: 10px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    color: var(--win, #00ff9d);
    animation: fadeIn 0.2s ease-out;
}

.chat-msg--assistant .chat-msg-bubble {
    background: none;
    border: none;
    border-radius: 0;
    max-width: 100%;
    color: #ffffff;
    font-family: var(--font-inter), var(--font-sans);
    font-size: 14px;
    font-weight: 300;
    line-height: 1.65;
}

.chat-msg--assistant .chat-msg-bubble p {
    color: #ffffff;
    font-weight: 300;
    margin-bottom: 12px;
}

.chat-msg--assistant .chat-msg-bubble strong {
    color: #ffffff;
    font-weight: 700;
    text-shadow: none;
}

.chat-msg--assistant .chat-msg-bubble h1,
.chat-msg--assistant .chat-msg-bubble h2,
.chat-msg--assistant .chat-msg-bubble h3,
.chat-msg--assistant .chat-msg-bubble h4,
.chat-msg--assistant .chat-msg-bubble h5,
.chat-msg--assistant .chat-msg-bubble h6 {
    color: #ffffff;
    text-shadow: none;
    margin-top: 16px;
    margin-bottom: 8px;
    font-weight: 700;
}

.chat-msg--assistant .chat-msg-bubble ul,
.chat-msg--assistant .chat-msg-bubble ol {
    color: #ffffff;
    margin-bottom: 12px;
}

.chat-msg--assistant .chat-msg-bubble li {
    color: #ffffff;
    font-weight: 300;
}

.chat-msg--assistant .chat-msg-bubble li::marker {
    color: #ffffff;
}

.chat-msg--assistant .chat-msg-bubble a {
    color: #ffffff;
    text-decoration: underline;
}

.chat-msg--assistant .chat-msg-bubble code {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-msg--assistant .chat-msg-bubble table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 13px;
    border: 1px solid rgba(0, 240, 255, 0.15);
    border-radius: 6px;
    overflow: hidden;
}

.chat-msg--assistant .chat-msg-bubble th {
    background: rgba(0, 240, 255, 0.03);
    color: var(--neon-cyan, #00f0ff);
    font-weight: 700;
    font-size: 13px;
    text-transform: none;
    letter-spacing: normal;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(0, 240, 255, 0.15);
    border-right: 1px solid rgba(0, 240, 255, 0.1);
    text-shadow: 0 0 4px rgba(0, 240, 255, 0.25);
}

.chat-msg--assistant .chat-msg-bubble th:last-child {
    border-right: none;
}

.chat-msg--assistant .chat-msg-bubble td {
    padding: 8px 14px;
    color: #e6e8ec;
    border-bottom: 1px solid rgba(0, 240, 255, 0.06);
    border-right: 1px solid rgba(0, 240, 255, 0.06);
}

.chat-msg--assistant .chat-msg-bubble td:last-child {
    border-right: none;
}

.chat-msg--assistant .chat-msg-bubble tr:last-child td {
    border-bottom: none;
}

.chat-msg--assistant .chat-msg-bubble tr:nth-child(even) {
    background: rgba(0, 240, 255, 0.01);
}

/* Terminal streaming block cursor */
.chat-msg--assistant.streaming .chat-msg-bubble::after {
    content: '';
    display: none;
}

@keyframes chat-cursor-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* ── Terminal Console Logs ── */
.chat-run-body {
    background: rgba(0, 240, 255, 0.01);
    border: 1px solid rgba(0, 240, 255, 0.1);
    border-radius: 8px;
    padding: 16px;
    font-family: 'Fira Code', 'SF Mono', Consolas, monospace;
    font-size: 11px;
    color: rgba(0, 240, 255, 0.85);
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-sizing: border-box;
    margin-bottom: 12px;
    box-shadow: inset 0 0 10px rgba(0, 240, 255, 0.03);
    transition: max-height 0.3s ease, opacity 0.2s;
}

.chat-run-body.collapsed {
    max-height: 0 !important;
    padding: 0 !important;
    border: none !important;
    overflow: hidden;
    opacity: 0;
    margin-bottom: 0 !important;
}

.chat-terminal-line {
    white-space: pre-wrap;
    word-break: break-all;
    line-height: 1.5;
    font-weight: 300;
    animation: terminal-line-in 0.2s ease-out forwards;
}

.terminal-cursor {
    display: inline-block;
    color: var(--neon-cyan, #00f0ff);
    text-shadow: 0 0 5px rgba(0, 240, 255, 0.5);
    margin-right: 4px;
}

/* Only the last console line's cursor blinks while the run is active */
.chat-run-body.running .chat-terminal-line:last-of-type .terminal-cursor {
    animation: chat-cursor-blink 1s step-end infinite;
}

.chat-terminal-line.working-on-it {
    color: rgba(0, 240, 255, 0.6);
}

.chat-terminal-line.reasoning {
    color: rgba(0, 240, 255, 0.7);
}

.chat-terminal-line.tool-run {
    color: rgba(0, 240, 255, 0.85);
}

.chat-terminal-line.tool-answer-header {
    color: rgba(0, 240, 255, 0.6);
    margin-top: 4px;
}

.chat-terminal-result {
    font-family: inherit;
    font-size: 11px;
    color: rgba(0, 240, 255, 0.6);
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(0, 240, 255, 0.05);
    border-radius: 4px;
    padding: 8px 12px;
    margin: 2px 0 6px 0;
    max-height: 200px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
    animation: terminal-line-in 0.25s ease-out forwards;
    transform-origin: top;
}

@keyframes terminal-line-in {
    from {
        opacity: 0;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-terminal-result::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
.chat-terminal-result::-webkit-scrollbar-thumb {
    background: rgba(0, 240, 255, 0.15);
    border-radius: 3px;
}
.chat-terminal-result::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 240, 255, 0.3);
}

/* Pulsing/Blinking Running logo avatar */
.chat-run-avatar.running {
    animation: chat-logo-blink 1.5s ease-in-out infinite;
}

.chat-msg-bubble {
    padding: 14px 18px;
    font-size: 14px;
    line-height: 1.65;
    color: var(--text-primary, #e6e8ec);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Markdown content inside assistant messages */
.chat-msg-bubble h1, .chat-msg-bubble h2, .chat-msg-bubble h3, .chat-msg-bubble h4, .chat-msg-bubble h5, .chat-msg-bubble h6 {
    margin: 14px 0 8px 0;
    font-weight: 600;
    color: var(--text-primary, #e6e8ec);
}

.chat-msg-bubble h1 { font-size: 17px; }
.chat-msg-bubble h2 { font-size: 16px; }
.chat-msg-bubble h3 { font-size: 15px; color: var(--neon-cyan, #00f0ff); }
.chat-msg-bubble h4 { font-size: 14.5px; }
.chat-msg-bubble h5 { font-size: 14px; }
.chat-msg-bubble h6 { font-size: 13.5px; }

.chat-msg-bubble p { margin: 6px 0; }

.chat-msg-bubble ul, .chat-msg-bubble ol {
    margin: 6px 0;
    padding-left: 20px;
}

.chat-msg-bubble li { margin: 3px 0; }

.chat-msg-bubble code {
    background: rgba(0, 240, 255, 0.06);
    border: 1px solid rgba(0, 240, 255, 0.1);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 12px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    color: var(--neon-cyan, #00f0ff);
}

.chat-msg-bubble pre {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border, rgba(255,255,255,0.08));
    border-radius: 8px;
    padding: 12px;
    margin: 8px 0;
    overflow-x: auto;
}

.chat-msg-bubble pre code {
    background: none;
    border: none;
    padding: 0;
    color: var(--text-primary, #e6e8ec);
}

.chat-msg-bubble table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 12px;
}

.chat-msg-bubble th {
    text-align: left;
    padding: 6px 10px;
    border-bottom: 1px solid var(--border, rgba(255,255,255,0.08));
    color: var(--text-muted, #6a7080);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 11px;
}

.chat-msg-bubble td {
    padding: 6px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    color: var(--text-secondary, #9da3b0);
}

.chat-msg-bubble strong { color: var(--text-primary, #e6e8ec); }

.chat-msg-bubble a {
    color: var(--neon-cyan, #00f0ff);
    text-decoration: none;
}

.chat-msg-bubble a:hover {
    text-decoration: underline;
}

/* ── Tool Card (Collapsible — matches production Manawa) ──────────────────── */

.chat-tool-card {
    display: flex;
    flex-direction: column;
    background: #050a14;
    border: 1px solid rgba(0, 240, 255, 0.2);
    border-radius: 6px;
    color: var(--neon-cyan, #00f0ff);
    overflow: hidden;
    animation: chat-msg-in 0.3s ease;
    transition: border-color 0.2s;
}

.chat-tool-card:hover {
    border-color: rgba(0, 240, 255, 0.4);
}

.chat-tool-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    cursor: pointer;
    transition: background 0.15s;
}

.chat-tool-card-header:hover {
    background: rgba(0, 240, 255, 0.03);
}

.chat-tool-card-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-tool-card-icon svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.chat-tool-card-name {
    font-size: 11px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.chat-tool-card-status {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    flex-shrink: 0;
}

.chat-tool-spinner {
    width: 12px;
    height: 12px;
    border: 2px solid rgba(0, 240, 255, 0.15);
    border-top-color: var(--neon-cyan, #00f0ff);
    border-radius: 50%;
    animation: chat-spin 0.8s linear infinite;
}

@keyframes chat-spin {
    to { transform: rotate(360deg); }
}

.chat-tool-check svg {
    width: 12px;
    height: 12px;
    stroke: var(--neon-cyan, #00f0ff);
    stroke-width: 2;
    fill: none;
}

.chat-tool-chevron {
    font-size: 9px;
    color: rgba(0, 240, 255, 0.4);
    transition: transform 0.2s;
}

.chat-tool-card.expanded .chat-tool-chevron {
    transform: rotate(90deg);
}

.chat-tool-card-args {
    padding: 0 10px 6px;
    margin-top: -4px;
    font-size: 10px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    color: rgba(0, 240, 255, 0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-tool-card-body {
    display: none;
    border-top: 1px solid rgba(0, 240, 255, 0.1);
    padding: 8px 10px;
    max-height: 300px;
    overflow-y: auto;
    scrollbar-width: none;
}

.chat-tool-card-body::-webkit-scrollbar { display: none; }

.chat-tool-card.expanded .chat-tool-card-body {
    display: block;
}

.chat-tool-card-result {
    font-size: 10px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    color: rgba(0, 240, 255, 0.7);
    white-space: pre-wrap;
    word-break: break-all;
    line-height: 1.5;
}

/* ── Reasoning / Thinking Block (Collapsible) ─────────────────────────────── */

.chat-reasoning-block {
    background: rgba(0, 240, 255, 0.05);
    border-left: 2px solid rgba(0, 240, 255, 0.3);
    padding: 8px 12px;
    border-radius: 0 6px 6px 0;
    color: rgba(0, 240, 255, 0.8);
    animation: chat-msg-in 0.3s ease;
    transition: all 0.3s;
}

.chat-reasoning-header {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    opacity: 0.6;
    margin-bottom: 4px;
}

.chat-reasoning-header svg {
    width: 12px;
    height: 12px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

.chat-reasoning-label {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
}

.chat-reasoning-chevron {
    font-size: 9px;
    color: rgba(0, 240, 255, 0.4);
    transition: transform 0.2s;
    margin-left: 2px;
}

.chat-reasoning-block.expanded .chat-reasoning-chevron {
    transform: rotate(90deg);
}

.chat-reasoning-content {
    font-size: 11px;
    line-height: 1.6;
    white-space: pre-wrap;
    max-height: 60px;
    overflow: hidden;
    transition: max-height 0.3s;
}

.chat-reasoning-block.expanded .chat-reasoning-content {
    max-height: 400px;
    overflow-y: auto;
    scrollbar-width: none;
}

.chat-reasoning-block.expanded .chat-reasoning-content::-webkit-scrollbar { display: none; }

/* ── Thinking Indicator ───────────────────────────────────────────────────── */

.chat-thinking {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 0;
    animation: chat-msg-in 0.3s ease;
}

.chat-thinking-logo {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0, 240, 255, 0.05);
    border: 1px solid rgba(0, 240, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.15);
    animation: chat-logo-blink 1.5s ease-in-out infinite;
}

.chat-thinking-logo img {
    width: 20px;
    height: 20px;
    object-fit: contain;
    opacity: 0.9;
}

.chat-thinking-text {
    font-size: 13px;
    color: var(--neon-cyan, #00f0ff);
    font-weight: 500;
    letter-spacing: 0.02em;
}

@keyframes chat-logo-blink {
    0%, 100% {
        opacity: 0.6;
        box-shadow: 0 0 8px rgba(0, 240, 255, 0.1);
        border-color: rgba(0, 240, 255, 0.1);
    }
    50% {
        opacity: 1;
        box-shadow: 0 0 20px rgba(0, 240, 255, 0.4);
        border-color: rgba(0, 240, 255, 0.4);
    }
}

/* ── Run Header (Manawa Avatar Row) ───────────────────────────────────────── */

.chat-run-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 24px 0 12px;
    animation: chat-msg-in 0.5s ease;
}

.chat-run-header-toggle {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid transparent;
    background: none;
    color: rgba(0, 240, 255, 0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-run-header-toggle:hover {
    border-color: rgba(0, 240, 255, 0.3);
    background: rgba(0, 240, 255, 0.1);
    color: var(--neon-cyan, #00f0ff);
}

.chat-run-header-toggle svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    transition: transform 0.2s;
}

.chat-run-header-toggle.collapsed svg {
    transform: rotate(-90deg);
}

.chat-run-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0, 240, 255, 0.05);
    border: 1px solid rgba(0, 240, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.15);
}

.chat-run-avatar img {
    width: 20px;
    height: 20px;
    object-fit: contain;
    opacity: 0.9;
}

.chat-run-label {
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
}

.chat-run-label-name {
    font-weight: 500;
    color: var(--neon-cyan, #00f0ff);
    font-size: 14px;
    letter-spacing: 0.03em;
}

.chat-run-label-badge {
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid rgba(0, 240, 255, 0.3);
    font-size: 10px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    color: rgba(0, 240, 255, 0.7);
    background: rgba(0, 240, 255, 0.05);
}

/* Collapsible run content transitions are handled in main definition */

/* ── Run Footer (Task Completed) ──────────────────────────────────────────── */

.chat-run-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    margin-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    animation: chat-msg-in 0.7s ease;
    margin-bottom: 20px;
}

.chat-run-footer-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-run-footer-check {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.15);
}

.chat-run-footer-check svg {
    width: 10px;
    height: 10px;
    stroke: #ffffff;
    stroke-width: 2.5;
    fill: none;
}

.chat-run-footer-text {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.7);
}

.chat-run-footer-meta {
    font-size: 10px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    color: rgba(255, 255, 255, 0.35);
    margin-left: 4px;
}

.chat-run-footer-center {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-run-footer-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: none;
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    position: relative;
}

.chat-run-footer-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.chat-run-footer-btn.saved {
    background: rgba(0, 255, 157, 0.05);
    color: var(--win, #00ff9d);
}

.chat-run-footer-btn svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

.chat-run-footer-btn .chat-footer-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translate(-50%, -8px);
    background: #050a14;
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 9px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.chat-run-footer-btn:hover .chat-footer-tooltip {
    opacity: 1;
    transform: translate(-50%, -4px);
}

.chat-run-footer-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-run-footer-right .chat-rating-label {
    font-size: 11px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: -0.01em;
}

.chat-run-footer-stars {
    display: flex;
    align-items: center;
    gap: 2px;
}

.chat-footer-star {
    background: none;
    border: none;
    padding: 2px;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.2);
    transition: transform 0.2s;
}

.chat-footer-star:hover {
    transform: scale(1.25);
    color: #ffffff;
}

.chat-footer-star svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    transition: fill 0.2s, color 0.2s, filter 0.2s;
}

/* ── Suggested Actions (Follow-Up Pills — matches production Manawa) ──────── */

.chat-suggested-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px 0;
    margin-bottom: 10px;
    flex-wrap: wrap;
    animation: fadeInUp 0.3s ease-out;
}

.chat-suggested-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(0, 240, 255, 0.5);
    white-space: nowrap;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

.chat-suggested-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid rgba(0, 255, 157, 0.25);
    background: rgba(0, 255, 157, 0.06);
    color: rgba(255, 255, 255, 0.85);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.chat-suggested-pill:hover {
    background: rgba(0, 255, 157, 0.15);
    border-color: rgba(0, 255, 157, 0.5);
}

.chat-suggested-pill svg {
    width: 12px;
    height: 12px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    opacity: 0.6;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Sources Panel ────────────────────────────────────────────────────────── */

.chat-sources {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 0;
}

.chat-source-tag {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: rgba(168, 85, 247, 0.06);
    border: 1px solid rgba(168, 85, 247, 0.12);
    border-radius: 14px;
    font-size: 11px;
    color: var(--neon-violet, #a855f7);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
}

.chat-source-tag:hover {
    background: rgba(168, 85, 247, 0.1);
    border-color: rgba(168, 85, 247, 0.25);
    text-decoration: none;
}

.chat-source-tag svg {
    width: 12px;
    height: 12px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

/* ── Legacy Suggestion Chips (kept for backward compat) ───────────────────── */

.chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 0 0 0;
}

.chat-suggestion-chip {
    padding: 6px 12px;
    background: rgba(0, 240, 255, 0.04);
    border: 1px solid rgba(0, 240, 255, 0.1);
    border-radius: 16px;
    font-size: 12px;
    color: var(--text-secondary, #9da3b0);
    cursor: pointer;
    transition: all 0.2s;
}

.chat-suggestion-chip:hover {
    background: rgba(0, 240, 255, 0.08);
    border-color: rgba(0, 240, 255, 0.2);
    color: var(--neon-cyan, #00f0ff);
}

/* ── Message Actions ──────────────────────────────────────────────────────── */

.chat-msg-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s;
    padding-top: 4px;
}

.chat-msg:hover .chat-msg-actions {
    opacity: 1;
}

.chat-msg-action {
    background: none;
    border: none;
    color: var(--text-muted, #6a7080);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 12px;
    transition: all 0.12s;
    display: flex;
    align-items: center;
    gap: 3px;
}

.chat-msg-action:hover {
    color: var(--text-primary, #e6e8ec);
    background: rgba(255, 255, 255, 0.06);
}

.chat-msg-action--active {
    color: var(--neon-cyan, #00f0ff);
}

/* ── Rating Stars ─────────────────────────────────────────────────────────── */

.chat-rating {
    display: flex;
    gap: 2px;
}

.chat-rating-star {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted, #6a7080);
    font-size: 14px;
    padding: 2px;
    transition: color 0.12s, transform 0.12s;
}

.chat-rating-star:hover {
    transform: scale(1.2);
}

.chat-rating-star.filled {
    color: #fbbf24;
}

/* ── Input Bar ────────────────────────────────────────────────────────────── */

.chat-input-area {
    padding: 16px 32px 0;
    background: transparent;
    flex-shrink: 0;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
}

.chat-input-usage {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    font-size: 11px;
    color: var(--text-muted, #6a7080);
}

.chat-usage-bar {
    flex: 1;
    height: 3px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 2px;
    overflow: hidden;
}

.chat-usage-fill {
    height: 100%;
    background: var(--neon-cyan, #00f0ff);
    border-radius: 2px;
    transition: width 0.5s ease;
}

.chat-usage-fill.warning { background: #fbbf24; }
.chat-usage-fill.danger { background: #b05252; }

/* ── Manawa-style 2-Row Input Box ─────────────────────────────────────────── */

.chat-input-box {
    position: relative;
    background: rgba(5, 10, 20, 0.90);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(0, 240, 255, 0.2);
    border-radius: 18px;
    padding: 12px 14px 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
    transition: border-color 0.2s, box-shadow 0.2s;
    margin-bottom: 25px;
}

.chat-input-box:focus-within {
    border-color: rgba(0, 240, 255, 0.5);
    box-shadow: 0 0 30px rgba(0, 240, 255, 0.1);
}

.chat-input-box:hover {
    box-shadow: 0 0 40px rgba(0, 240, 255, 0.15);
}

/* Clear button (X) — absolute top-right */
.chat-clear-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(0, 240, 255, 0.05);
    border: none;
    color: rgba(0, 240, 255, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    z-index: 10;
    flex-shrink: 0;
}

.chat-clear-btn:hover {
    background: rgba(0, 240, 255, 0.1);
    color: var(--neon-cyan, #00f0ff);
}

.chat-clear-btn svg {
    width: 11px;
    height: 11px;
    stroke: currentColor;
    stroke-width: 2.5;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Row 1: Textarea */
.chat-input {
    width: 100%;
    background: none;
    border: none;
    outline: none;
    color: #ffffff;
    font-size: 15px;
    font-family: var(--font-sans);
    resize: none;
    min-height: 24px;
    max-height: 120px;
    line-height: 1.5;
    font-weight: 300;
    padding-right: 28px; /* space for clear btn */
    overflow-y: auto;
    scrollbar-width: none;
}

.chat-input::-webkit-scrollbar { display: none; }

.chat-input::placeholder {
    color: rgba(255, 255, 255, 0.35);
    opacity: 1;
}

/* Row 2: Controls */
.chat-input-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 8px;
    min-height: 40px;
}

.chat-input-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* + button (file upload label) */
.chat-plus-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-plus-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.4);
}

.chat-plus-btn svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    stroke-width: 2.5;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Manawa mode button (logo + dot) */
.chat-mode-btn {
    position: relative;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    border: 1.5px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    overflow: hidden;
}

.chat-mode-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
}

.chat-mode-logo {
    width: 18px;
    height: 18px;
    object-fit: contain;
    opacity: 0.85;
    transition: opacity 0.2s;
}

.chat-mode-btn:hover .chat-mode-logo {
    opacity: 1;
}

.chat-mode-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #ffffff;
    border: 1.5px solid rgba(5, 10, 20, 0.9);
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.8);
}

/* Send button */
.chat-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: #ffffff;
    border: none;
    color: #050a14;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.1);
}

.chat-send-btn:hover {
    background: #e6e8ec;
    box-shadow: 0 4px 16px rgba(255, 255, 255, 0.15);
    transform: scale(1.04);
}

.chat-send-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.chat-send-btn svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ── Keyboard Shortcuts ───────────────────────────────────────────────────── */

.chat-shortcuts {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 8px 0 0;
    font-size: 10px;
    color: var(--text-muted, #6a7080);
    opacity: 0.5;
}

.chat-shortcut kbd {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 10px;
    font-family: var(--font-sans);
    color: var(--text-muted, #6a7080);
}

/* ── Delete Animation ────────────────────────────────────────────────────── */

@keyframes chat-msg-out {
    from { opacity: 1; transform: translateX(0); max-height: 300px; }
    to { opacity: 0; transform: translateX(30px); max-height: 0; padding: 0; margin: 0; overflow: hidden; }
}

/* ── Chart Container ─────────────────────────────────────────────────────── */

.chat-chart-container {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    border: 1px solid var(--border, rgba(255,255,255,0.08));
    overflow: hidden;
}

.chat-chart-container canvas {
    width: 100% !important;
}

.chat-chart-container table {
    width: 100%;
    font-size: 11px;
    border-collapse: collapse;
}

.chat-chart-container table th,
.chat-chart-container table td {
    padding: 4px 8px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    color: var(--text-secondary, #9da3b0);
}

.chat-chart-container table th {
    color: var(--text-muted, #6a7080);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 10px;
}

/* ── Action Button Hover Colors ──────────────────────────────────────────── */

.chat-msg-action[data-action="delete"]:hover { color: #b05252; }
.chat-msg-action[data-action="rerun"]:hover { color: var(--neon-cyan, #00f0ff); }
.chat-msg-action[data-action="save"]:hover { color: #fbbf24; }
.chat-msg-action[data-action="export"]:hover { color: var(--neon-violet, #a855f7); }

/* ── Attachment Preview Strip ─────────────────────────────────────────────── */

.chat-attach-preview {
    display: none;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 0 6px;
    max-height: 180px;
    overflow-y: auto;
    scrollbar-width: none;
}

.chat-attach-preview::-webkit-scrollbar { display: none; }

.chat-attach-chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 10px;
    overflow: hidden;
    animation: chat-msg-in 0.2s ease;
    transition: opacity 0.15s;
}

.chat-attach-chip.uploading { opacity: 0.6; }

.chat-attach-chip:not(.file) {
    width: 64px;
    height: 64px;
    border: 1px solid rgba(0, 240, 255, 0.15);
    background: rgba(0, 0, 0, 0.3);
}

.chat-attach-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.chat-attach-chip.file {
    padding: 6px 10px;
    background: rgba(0, 240, 255, 0.04);
    border: 1px solid rgba(0, 240, 255, 0.1);
    max-width: 220px;
}

.chat-attach-icon { font-size: 14px; flex-shrink: 0; }

.chat-attach-name {
    font-size: 11px;
    color: var(--text-secondary, #9da3b0);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

.chat-attach-size {
    font-size: 10px;
    color: var(--text-muted, #6a7080);
    flex-shrink: 0;
}

.chat-attach-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted, #6a7080);
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.1s, color 0.1s;
}

.chat-attach-chip:hover .chat-attach-remove { opacity: 1; }
.chat-attach-remove:hover { color: #b05252; border-color: rgba(176, 82, 82, 0.4); }

.chat-attach-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 18px;
    height: 18px;
    border: 2px solid rgba(0, 240, 255, 0.15);
    border-top-color: var(--neon-cyan, #00f0ff);
    border-radius: 50%;
    animation: chat-spin 0.8s linear infinite;
}

/* ── Drag-and-Drop Zone ──────────────────────────────────────────────────── */

.chat-drop-zone {
    position: absolute;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 10, 20, 0.92);
    border: 2px dashed rgba(0, 240, 255, 0.3);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}

.chat-drop-zone.active {
    opacity: 1;
    pointer-events: auto;
}

.chat-drop-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--neon-cyan, #00f0ff);
    font-size: 16px;
    font-weight: 500;
}

.chat-drop-zone-content svg {
    color: var(--neon-cyan, #00f0ff);
    opacity: 0.6;
}

.chat-drop-hint {
    font-size: 12px;
    color: var(--text-muted, #6a7080);
    font-weight: 400;
}

/* ── Inline Attachments (in message bubbles) ─────────────────────────────── */

.chat-inline-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 0;
}

.chat-inline-attach-img {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(0, 240, 255, 0.12);
    cursor: pointer;
    transition: border-color 0.15s, transform 0.15s;
}

.chat-inline-attach-img:hover {
    border-color: rgba(0, 240, 255, 0.35);
    transform: scale(1.04);
}

.chat-inline-attach-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.chat-inline-attach-file {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    background: rgba(0, 240, 255, 0.03);
    border: 1px solid rgba(0, 240, 255, 0.08);
    border-radius: 8px;
    font-size: 11px;
    color: var(--text-muted, #6a7080);
}

/* ── Attach Button SVG ───────────────────────────────────────────────────── */

.chat-attach-btn {
    background: none;
    border: none;
    color: var(--text-muted, #6a7080);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.12s, transform 0.12s;
    flex-shrink: 0;
}

.chat-attach-btn:hover {
    color: var(--neon-cyan, #00f0ff);
    transform: rotate(-15deg);
}

/* ── Search-to-Chat Indicator ─────────────────────────────────────────────── */

.search-ai-hint {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    display: none;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--neon-cyan, #00f0ff);
    opacity: 0.7;
    pointer-events: none;
    animation: aiHintPulse 2s ease-in-out infinite;
}

.search-ai-hint.visible {
    display: flex;
}

.search-ai-hint svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

@keyframes aiHintPulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* ── Header Chat Button (+) ───────────────────────────────────────────────── */

#chat-open-btn {
    position: relative;
}

#chat-open-btn::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    opacity: 0;
    transition: opacity 0.2s;
    background: radial-gradient(circle, rgba(0, 240, 255, 0.15), transparent 70%);
}

#chat-open-btn:hover::after {
    opacity: 1;
}

/* ── Starter Suggestion Cards (empty state) ───────────────────────────────── */

.chat-starter-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    width: 100%;
    max-width: 820px;
    box-sizing: border-box;
}

.chat-starter-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    padding: 24px 20px;
    background: rgba(5, 10, 20, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.25s ease;
    color: inherit;
    width: 100%;
    box-sizing: border-box;
}

.chat-starter-card:hover {
    background: rgba(0, 255, 112, 0.04);
    border-color: rgba(0, 255, 112, 0.25);
    box-shadow: 0 0 25px rgba(0, 255, 112, 0.08);
    transform: translateY(-2px);
}

.starter-card-icon {
    width: 28px;
    height: 28px;
    stroke: #00ff70;
    opacity: 0.9;
    flex-shrink: 0;
    transition: transform 0.2s;
    margin-bottom: 4px;
}

.chat-starter-card:hover .starter-card-icon {
    transform: scale(1.1);
}

.starter-card-text-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 4px;
}

.starter-card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary, #e6e8ec);
    line-height: 1.3;
}

.starter-card-desc {
    font-size: 12px;
    color: var(--text-muted, #6a7080);
    line-height: 1.5;
    opacity: 0.7;
}

/* Mobile-specific header actions on the top right */
.chat-mobile-header-actions {
    display: none;
}

.timeline-mobile-close-btn {
    display: none;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .chat-main {
        margin-left: 0px !important; /* no left margin since timeline is hidden on mobile closed state */
    }

    .chat-timeline {
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 110;
        width: 0px; /* hidden by default on mobile */
        min-width: 0px;
        overflow: hidden;
        border-right: none;
        box-shadow: none;
        transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), min-width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .chat-timeline.mobile-open {
        width: 100% !important;
        min-width: 100% !important;
        border-right: 1px solid var(--tl-border);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.6);
    }

    .timeline-collapsed-content {
        display: none !important; /* no collapsed view elements shown on mobile */
    }

    /* Force expanded content to show when timeline is open on mobile */
    .chat-timeline.mobile-open .timeline-expanded-content {
        display: flex !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }
    
    .chat-timeline:hover {
        width: 0px;
        min-width: 0px;
    }
    
    .chat-timeline.mobile-open:hover {
        width: 100% !important;
        min-width: 100% !important;
    }

    .timeline-tooltip {
        display: none !important;
    }
    
    .chat-messages {
        padding: 12px 16px;
    }
    
    .chat-input-area {
        padding: 12px 16px 0;
    }

    .chat-starter-cards {
        grid-template-columns: 1fr;
    }

    .chat-starter-card {
        flex-direction: row;
        align-items: center;
        text-align: left;
        padding: 12px 16px;
        gap: 16px;
    }

    .starter-card-text-wrap {
        align-items: flex-start;
        text-align: left;
        gap: 2px;
    }

    .starter-card-icon {
        margin-bottom: 0;
    }

    .chat-navigator {
        display: none !important;
    }

    .chat-close-bar {
        justify-content: space-between;
    }

    /* Show mobile-specific buttons */
    .chat-mobile-header-actions {
        display: flex;
        align-items: center;
        gap: 12px;
        margin-right: 0;
    }
    
    .chat-mobile-btn {
        background: transparent;
        border: none;
        padding: 4px;
        color: rgba(0, 240, 255, 0.6);
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.2s ease;
    }
    
    .chat-mobile-btn:hover {
        color: #00f0ff;
        filter: drop-shadow(0 0 4px rgba(0, 240, 255, 0.8));
    }
    
    .chat-mobile-btn svg {
        width: 16px;
        height: 16px;
        stroke: currentColor;
        stroke-width: 2.5;
        fill: none;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .timeline-mobile-close-btn {
        display: flex;
        position: absolute;
        top: 12px;
        right: 16px;
        z-index: 120;
        background: transparent;
        border: none;
        color: rgba(0, 240, 255, 0.6);
        cursor: pointer;
        padding: 4px;
        align-items: center;
        justify-content: center;
        transition: all 0.2s ease;
    }
    
    .timeline-mobile-close-btn:hover {
        color: #00f0ff;
        filter: drop-shadow(0 0 4px rgba(0, 240, 255, 0.8));
    }
    
    .timeline-mobile-close-btn svg {
        width: 16px;
        height: 16px;
        stroke: currentColor;
        stroke-width: 2.5;
        fill: none;
        stroke-linecap: round;
        stroke-linejoin: round;
    }
}

@media (max-width: 480px) {
    .chat-messages {
        padding: 10px 12px;
    }
    
    .chat-input-area {
        padding: 10px 12px;
    }
}

/* ── Header Chat Title ────────────────────────────────────────────────────── */

.header-chat-title {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex: 1;
}

.chat-title-brand {
    font-size: 18px;
    font-weight: 600;
    color: var(--neon-cyan, #00f0ff);
    letter-spacing: -0.01em;
}

.chat-title-version {
    font-size: 11px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    color: var(--neon-cyan, #00f0ff);
    border: 1px solid rgba(0, 240, 255, 0.25);
    padding: 2px 6px;
    border-radius: 6px;
    opacity: 0.8;
}

/* ── Floating Message Navigator (Right side scroll indicator) ── */

.chat-main {
    position: relative; /* ensure absolute positioning works for children */
}

.chat-navigator {
    position: absolute;
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: flex-end; /* right-align the chevrons and items */
    width: 240px;
    gap: 10px; /* default gap between arrows and lines track */
    z-index: 90;
    pointer-events: none;
    transition: gap 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-navigator:hover {
    gap: 15px; /* increased on hover */
}

.chat-nav-arrow {
    pointer-events: auto;
    width: 30px; /* reduced by 25% from 40px */
    height: 16px; /* compact height to be directly next to first/last */
    background: transparent;
    border: none;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(0, 240, 255, 0.4);
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-nav-arrow:hover {
    color: #00f0ff;
    filter: drop-shadow(0 0 4px rgba(0, 240, 255, 0.8));
}

.chat-nav-arrow.disabled {
    opacity: 0.15;
    pointer-events: none;
}

.chat-nav-lines {
    display: flex;
    flex-direction: column;
    align-items: flex-end; /* right-align the wrapper column */
    gap: 0px; /* no gap between items, making the entire vertical track hoverable */
    width: 100%;
    transition: gap 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-navigator:hover .chat-nav-lines {
    gap: 0px;
}

.chat-nav-item {
    pointer-events: auto;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    width: 100%;
    padding: 5px 0; /* default padding 5px top/bottom (10px visual space between lines) */
    cursor: pointer;
    position: relative;
    transition: padding 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-navigator:hover .chat-nav-item {
    padding: 10px 0; /* all items expand to 10px top/bottom (20px visual space between lines) when navigator is hovered */
}

.chat-navigator:hover .chat-nav-item:hover {
    padding: 20px 0; /* the hovered item expands even more for a dynamic focal effect */
}

.chat-nav-line-wrapper {
    width: 30px; /* reduced by 25% from 40px */
    display: flex;
    justify-content: flex-start; /* both user and assistant start from the same left-most point */
    flex-shrink: 0;
}

.chat-nav-line {
    height: 1.5px; /* reduced thickness by 25% from 2px */
    background: rgba(0, 240, 255, 0.25);
    border-radius: 1px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: left center; /* scale from the left start point */
}

.chat-nav-line.user {
    width: 15px; /* User query: 15px (reduced by 25% from 20px) */
}

.chat-nav-line.assistant {
    width: 30px; /* Assistant answer: 30px (reduced by 25% from 40px) */
}

.chat-nav-item:hover .chat-nav-line,
.chat-nav-item.active .chat-nav-line {
    background: #00f0ff;
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.8);
    height: 2.25px; /* reduced hover thickness by 25% from 3px */
}

/* Inline tooltip text next to the line (no bubble container) */
.chat-nav-label {
    position: absolute;
    right: 42px; /* positioned left of the 30px line wrapper + gap/margin */
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    opacity: 0;
    transform: translateX(8px);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    text-align: right;
    white-space: nowrap;
}

.chat-nav-item:hover .chat-nav-label {
    opacity: 1;
    transform: translateX(0);
}

.chat-nav-label-author {
    font-weight: 700;
    color: #00f0ff;
    margin-bottom: 2px;
    text-transform: uppercase;
    font-size: 11px; /* increased name to 11px */
    letter-spacing: 0.05em;
    line-height: 1;
}

.chat-nav-label-text {
    color: rgba(255, 255, 255, 0.7);
    max-width: 165px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px; /* increased text to 13px */
    line-height: 1.2;
}
