/* Kirk AI — Premium Dark Theme with Sidebar
   Color palette:
   --bg-primary:     #0D1117   (deep charcoal)
   --bg-secondary:   #161B22   (card backgrounds)
   --bg-tertiary:    #1C2333   (elevated surfaces)
   --border:         #21283B   (subtle borders)
   --border-hover:   #30394A   (hover borders)
   --text-primary:   #E6EDF3
   --text-secondary: #8B949E
   --text-muted:     #6E7681
   --accent:         #5BC0EB   (ice blue)
   --accent-glow:    rgba(91,192,235,0.25)
   --accent-subtle:  rgba(91,192,235,0.08)
   --user-bubble:    #1A2F4A
   --user-border:    #254670
*/

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

:root {
    --bg-primary: #0D1117;
    --bg-secondary: #161B22;
    --bg-tertiary: #1C2333;
    --border: #21283B;
    --border-hover: #30394A;
    --text-primary: #E6EDF3;
    --text-secondary: #8B949E;
    --text-muted: #6E7681;
    --accent: #5BC0EB;
    --accent-glow: rgba(91, 192, 235, 0.25);
    --accent-subtle: rgba(91, 192, 235, 0.08);
    --user-bubble: #1A2F4A;
    --user-border: #254670;
    --sidebar-width: 280px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.5);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    height: 100%;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100%;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}


/* ── App Layout ───────────────────────────────────────── */

.app-layout {
    display: flex;
    height: 100%;
    position: relative;
}


/* ── Sidebar ──────────────────────────────────────────── */

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    height: 100%;
    overflow: hidden;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.kirk-avatar-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #5BC0EB, #3A8FBF);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.brand-text {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.02em;
}

.new-chat-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--accent-subtle);
    border: 1px solid rgba(91, 192, 235, 0.2);
    border-radius: var(--radius-sm);
    color: var(--accent);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
    width: 100%;
}

.new-chat-btn:hover {
    background: rgba(91, 192, 235, 0.15);
    border-color: rgba(91, 192, 235, 0.35);
    color: #fff;
}

.new-chat-btn:active {
    transform: scale(0.97);
}

.sidebar-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    padding: 14px 16px 8px;
}

.session-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 8px 8px;
    min-height: 0;
}

/* ── Sidebar User Footer (not interactive — just identity) ── */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.sidebar-user.hidden {
    display: none;
}

.sidebar-user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #5BC0EB, #3A8FBF);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 13.5px;
    flex-shrink: 0;
    overflow: hidden;
    border: 1.5px solid rgba(91, 192, 235, 0.25);
}

.sidebar-user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.sidebar-user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.sidebar-user-email {
    font-size: 11.5px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
    margin-top: 1px;
}

.session-list::-webkit-scrollbar {
    width: 4px;
}

.session-list::-webkit-scrollbar-track {
    background: transparent;
}

.session-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

.session-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    border: 1px solid transparent;
    margin-bottom: 2px;
}

.session-item:hover {
    background: var(--bg-tertiary);
    border-color: var(--border);
}

.session-item.active {
    background: var(--accent-subtle);
    border-color: rgba(91, 192, 235, 0.2);
}

.session-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 1px;
    color: var(--text-muted);
}

.session-info {
    flex: 1;
    min-width: 0;
}

.session-preview {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 500;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.session-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 3px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.session-item.active .session-preview {
    color: #fff;
}

.session-item.active .session-icon {
    color: var(--accent);
}

.session-empty {
    text-align: center;
    padding: 30px 16px;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.5;
}

.session-loading {
    display: flex;
    justify-content: center;
    padding: 20px;
}

.session-delete {
    opacity: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all var(--transition);
    flex-shrink: 0;
    margin-top: 1px;
}

.session-item:hover .session-delete {
    opacity: 1;
}

.session-delete:hover {
    color: #f85149;
    background: rgba(248, 81, 73, 0.1);
}


/* ── Sidebar Overlay (mobile) ─────────────────────────── */

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 99;
}

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

.sidebar-toggle {
    display: none;
}


/* ── Chat Panel ───────────────────────────────────────── */

.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 0;
}


/* ── Header ────────────────────────────────────────────── */

.chat-header {
    position: relative;
    z-index: 10;
    background: linear-gradient(180deg, #131A24 0%, var(--bg-secondary) 100%);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.chat-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0.6;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    gap: 16px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all var(--transition);
}

.menu-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.kirk-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: linear-gradient(135deg, #5BC0EB, #3A8FBF);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px var(--bg-secondary), 0 0 16px rgba(91, 192, 235, 0.3);
    position: relative;
}

.kirk-avatar span {
    color: #fff;
    font-weight: 700;
    font-size: 19px;
    letter-spacing: -0.02em;
}

.kirk-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.header-text {
    min-width: 0;
}

.header-text h1 {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    padding: 5px 10px;
    background: var(--accent-subtle);
    border-radius: 20px;
    border: 1px solid rgba(91, 192, 235, 0.12);
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #3fb950;
    box-shadow: 0 0 6px rgba(63, 185, 80, 0.5);
    animation: pulse-dot 2s infinite;
}

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


/* ── Messages Area ─────────────────────────────────────── */

.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scroll-behavior: smooth;
}

/* Scrollbar */
.messages-area::-webkit-scrollbar {
    width: 5px;
}

.messages-area::-webkit-scrollbar-track {
    background: transparent;
}

.messages-area::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

.messages-area::-webkit-scrollbar-thumb:hover {
    background: var(--border-hover);
}


/* ── Messages ──────────────────────────────────────────── */

.message {
    display: flex;
    gap: 12px;
    max-width: 82%;
    animation: msg-appear 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    opacity: 0;
}

/* History messages should not animate */
.message.no-animate {
    animation: none;
    opacity: 1;
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

@keyframes msg-appear {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.msg-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 4px;
    font-weight: 700;
    font-size: 13px;
}

.message.assistant .msg-avatar {
    background: linear-gradient(135deg, #5BC0EB, #3A8FBF);
    color: #fff;
    box-shadow: 0 2px 8px rgba(91, 192, 235, 0.2);
    overflow: hidden;
}

.msg-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.message.user .msg-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.message.user .msg-avatar {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.msg-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.msg-sender {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    padding-left: 2px;
}

.message.user .msg-sender {
    text-align: right;
    padding-right: 2px;
    padding-left: 0;
}

.msg-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 18px;
    line-height: 1.65;
    font-size: 14.5px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Markdown formatting in assistant messages */
.msg-content p {
    margin: 0 0 8px;
}

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

.msg-content strong {
    color: #fff;
    font-weight: 600;
}

.msg-content em {
    color: var(--text-secondary);
    font-style: italic;
}

.msg-content code {
    background: rgba(91, 192, 235, 0.1);
    color: var(--accent);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

.msg-content pre {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    overflow-x: auto;
    margin: 8px 0;
}

.msg-content pre code {
    background: none;
    padding: 0;
    color: var(--text-primary);
}

.msg-content ul,
.msg-content ol {
    padding-left: 20px;
    margin: 6px 0;
}

.msg-content li {
    margin: 4px 0;
}

.msg-content a {
    color: var(--accent);
    text-decoration: none;
}

.msg-content a:hover {
    text-decoration: underline;
}

.msg-content h1,
.msg-content h2,
.msg-content h3 {
    color: #fff;
    margin: 12px 0 6px;
    line-height: 1.3;
}

.msg-content h1 { font-size: 1.3em; }
.msg-content h2 { font-size: 1.15em; }
.msg-content h3 { font-size: 1.05em; }

.msg-content blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 12px;
    margin: 8px 0;
    color: var(--text-secondary);
}

.msg-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 12px 0;
}

.message.assistant .msg-content {
    border-radius: 4px var(--radius-lg) var(--radius-lg) var(--radius-lg);
}

.message.user .msg-content {
    background: var(--user-bubble);
    border-color: var(--user-border);
    border-radius: var(--radius-lg) 4px var(--radius-lg) var(--radius-lg);
}

.msg-content.streaming {
    border-color: var(--accent);
    box-shadow: 0 0 12px rgba(91, 192, 235, 0.08);
}

/* Streaming cursor */
.msg-content.streaming::after {
    content: '';
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--accent);
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: blink-cursor 0.8s step-end infinite;
}

@keyframes blink-cursor {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}


/* ── Typing Indicator ──────────────────────────────────── */

.typing-bubble {
    display: flex;
    gap: 12px;
    max-width: 82%;
    animation: msg-appear 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    opacity: 0;
}

.typing-dots {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px var(--radius-lg) var(--radius-lg) var(--radius-lg);
    padding: 16px 22px;
    display: flex;
    gap: 5px;
    align-items: center;
}

.typing-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    opacity: 0.4;
    animation: typing-bounce 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.16s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.32s;
}

@keyframes typing-bounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.3;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}


/* ── Sources Drawer ────────────────────────────────────── */

.sources-drawer {
    flex-shrink: 0;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    display: none;
}

.sources-drawer.visible {
    display: block;
}

.sources-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 24px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: color var(--transition);
}

.sources-toggle:hover {
    color: var(--text-primary);
}

.sources-label {
    flex: 1;
    text-align: left;
}

.sources-count {
    font-size: 11px;
    font-weight: 600;
    background: var(--accent-subtle);
    color: var(--accent);
    padding: 1px 7px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.sources-chevron {
    transition: transform var(--transition);
}

.sources-drawer.expanded .sources-chevron {
    transform: rotate(180deg);
}

.sources-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sources-drawer.expanded .sources-content {
    max-height: 200px;
}

.sources-list {
    padding: 0 24px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    max-height: 180px;
}

.source-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    transition: border-color var(--transition);
}

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

.source-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: var(--accent-subtle);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 12px;
}

.source-info {
    flex: 1;
    min-width: 0;
}

.source-title {
    color: var(--text-primary);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.source-type {
    color: var(--text-muted);
    font-size: 11px;
    margin-top: 1px;
}

.source-score {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-subtle);
    padding: 2px 8px;
    border-radius: 10px;
    flex-shrink: 0;
}


/* ── Input Area ────────────────────────────────────────── */

.input-area {
    flex-shrink: 0;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    padding: 16px 24px 12px;
}

.input-form {
    display: flex;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 6px 6px 6px 18px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

#message-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 14.5px;
    font-family: inherit;
    line-height: 1.5;
    padding: 8px 0;
    resize: none;
    outline: none;
    max-height: 140px;
    min-height: 24px;
}

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

#voice-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all var(--transition);
}

#voice-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-hover);
    color: var(--text-primary);
}

#voice-btn.recording {
    background: rgba(248, 81, 73, 0.15);
    border-color: #f85149;
    color: #f85149;
    animation: pulse-record 1.5s infinite;
}

@keyframes pulse-record {
    0%, 100% { box-shadow: 0 0 0 0 rgba(248, 81, 73, 0.3); }
    50% { box-shadow: 0 0 0 6px rgba(248, 81, 73, 0); }
}

#voice-btn.unsupported {
    display: none;
}

#send-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    background: var(--accent);
    border: none;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all var(--transition);
}

#send-btn:hover {
    background: #7AD0F5;
    transform: scale(1.04);
}

#send-btn:active {
    transform: scale(0.96);
}

#send-btn:disabled {
    background: var(--border);
    color: var(--text-muted);
    cursor: not-allowed;
    transform: none;
}

.input-footer {
    display: flex;
    justify-content: center;
    padding-top: 10px;
}

.powered-by {
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

.powered-by strong {
    color: var(--text-secondary);
    font-weight: 600;
}


/* ── Welcome Message ───────────────────────────────────── */

.welcome-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 40px 20px 30px;
    animation: msg-appear 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    opacity: 0;
}

.welcome-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #5BC0EB, #3A8FBF);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 18px;
    box-shadow: 0 0 24px rgba(91, 192, 235, 0.25);
}

.welcome-avatar span {
    color: #fff;
    font-weight: 700;
    font-size: 26px;
}

.welcome-title {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 8px;
}

.welcome-text {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    max-width: 420px;
}

/* No-animate variant for welcome */
.welcome-card.no-animate {
    animation: none;
    opacity: 1;
}


/* ── Loading Overlay (for history fetch) ───────────────── */

.loading-history {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    gap: 14px;
    animation: msg-appear 0.3s forwards;
    opacity: 0;
}

.loading-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-history span {
    font-size: 13px;
    color: var(--text-secondary);
}


/* ── Mobile Responsive ─────────────────────────────────── */

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: var(--shadow-lg);
    }

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

    .menu-btn {
        display: flex;
    }

    .chat-panel {
        width: 100%;
    }
}

@media (max-width: 640px) {
    .header-inner {
        padding: 12px 16px;
    }

    .kirk-avatar {
        width: 38px;
        height: 38px;
    }

    .kirk-avatar span {
        font-size: 16px;
    }

    .header-text h1 {
        font-size: 16px;
    }

    .subtitle {
        font-size: 12px;
    }

    .status-badge {
        display: none;
    }

    .messages-area {
        padding: 16px 12px 12px;
        gap: 4px;
    }

    .message {
        max-width: 92%;
    }

    .msg-avatar {
        width: 28px;
        height: 28px;
        font-size: 11px;
    }

    .msg-content {
        padding: 11px 14px;
        font-size: 14px;
    }

    .input-area {
        padding: 12px 12px 10px;
    }

    .input-wrapper {
        padding: 4px 4px 4px 14px;
    }

    #message-input {
        font-size: 16px; /* prevents iOS zoom */
    }

    .sources-toggle,
    .sources-list {
        padding-left: 16px;
        padding-right: 16px;
    }

    .welcome-card {
        padding: 28px 16px 20px;
    }

    .welcome-avatar {
        width: 52px;
        height: 52px;
    }

    .welcome-avatar span {
        font-size: 22px;
    }

    .welcome-title {
        font-size: 18px;
    }
}

@media (max-width: 380px) {
    .header-text h1 {
        font-size: 15px;
    }
}


/* ── Selection Color ───────────────────────────────────── */

::selection {
    background: rgba(91, 192, 235, 0.3);
    color: #fff;
}


/* ── Performance: Low-powered devices & reduced motion ── */

/* Respect user's OS-level "reduce motion" preference */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Paint optimisations: hint the browser what to offload to GPU */
.message,
.welcome-card,
.typing-bubble,
.sidebar,
.sources-drawer {
    will-change: auto; /* default — only promoted when actively animating */
}

/* Mobile-only: shorter message animations + no heavy shadows */
@media (max-width: 768px) {
    .message,
    .msg-enter {
        animation-duration: 0.2s !important;
    }

    .welcome-card {
        animation-duration: 0.3s !important;
    }

    /* Drop the expensive large shadows on small phones */
    .sidebar,
    .modal {
        box-shadow: none !important;
    }

    /* Passive scrolling works better without scroll-behavior: smooth */
    .messages-area,
    .session-list {
        scroll-behavior: auto;
    }
}

/* Long session lists: skip off-screen rendering */
.session-list .session-item {
    content-visibility: auto;
    contain-intrinsic-size: 0 62px;
}

