*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
    background: #0d1117;
    color: #c9d1d9;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.14); }


body {
    display: flex;
    flex-direction: column;
}

.test-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: rgba(240,136,62,0.07);
    border-bottom: 1px solid rgba(240,136,62,0.12);
    color: #f0883e;
    text-align: center;
    font-size: 0.6rem;
    font-weight: 500;
    padding: 2px 0;
    letter-spacing: 0.4px;
    backdrop-filter: blur(8px);
}

.test-banner i {
    margin-right: 4px;
    font-size: 0.85em;
}

.sidebar {
    position: fixed;
    top: 18px; /* below test banner */
    left: 0;
    bottom: 22px; /* above footer */
    width: 280px;
    background: #161b22;
    border-right: 1px solid rgba(255,255,255,0.05);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    overflow: hidden;
}

.main-content {
    position: fixed;
    left: 280px;
    top: 18px;
    right: 0;
    bottom: 22px;
    display: flex;
    flex-direction: column;
}

.app-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
    background: rgba(13,17,23,0.95);
    border-top: 1px solid rgba(255,255,255,0.03);
    z-index: 100;
    backdrop-filter: blur(8px);
}

.app-footer a {
    color: #6e7681;
    font-size: 0.7rem;
    text-decoration: none;
    transition: color 0.2s ease;
}

.app-footer a:hover {
    color: #d42026;
}

.footer-sep {
    color: #30363d;
    font-size: 0.6rem;
}


.sidebar-top {
    padding: 16px 18px 8px;
    flex-shrink: 0;
    overflow-y: auto;
    max-height: 60vh;
}

.sidebar-top > * {
    margin-bottom: 10px;
}

.sidebar-bottom {
    flex: 1;
    overflow-y: auto;
    padding: 0 14px 12px;
    display: flex;
    flex-direction: column;
}

.sidebar-logo {
    margin-bottom: 12px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.sidebar-logo img {
    display: block;
    max-width: 130px;
}

.sidebar-brand {
    font-size: 0.95rem;
    font-weight: 700;
    color: #e6edf3;
    padding: 4px 0 8px;
    line-height: 1;
    margin-bottom: 6px;
    letter-spacing: -0.01em;
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.sidebar-brand .brand-sub {
    display: block;
    font-weight: 400;
    color: #6e7681;
    font-size: 0.76em;
    margin-top: 1px;
    letter-spacing: 0;
}

.sidebar-divider {
    border: none;
    border-top: 1px solid rgba(255,255,255,0.05);
    margin: 8px 0;
}

/* New chat button */
.btn-new-chat {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    background: #d42026;
    border: none;
    color: #fff;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.84rem;
    padding: 10px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 4px 0;
    font-family: inherit;
}

.btn-new-chat:hover {
    background: #b91c22;
    box-shadow: 0 4px 14px rgba(37,99,235,0.25);
}


/* User card */
.user-card {
    margin: 6px 0;
}

.user-info-card {
    background: rgba(255,255,255,0.025);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 10px;
    padding: 10px 12px;
}

.user-info-name {
    font-weight: 600;
    color: #e6edf3;
    font-size: 0.84rem;
    margin-bottom: 3px;
    display: flex;
    align-items: center;
    gap: 7px;
}

.user-info-name i {
    font-size: 0.82em;
    color: #6366f1;
}

.user-info-role {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.7rem;
    color: #3fb950;
}

.user-info-role .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #3fb950;
    display: inline-block;
    flex-shrink: 0;
}

.user-info-role.anonymous {
    color: #8b949e;
}

.user-info-role.anonymous .dot {
    background: #8b949e;
}


/* Auth section */
.auth-section {
    margin: 4px 0;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.login-form input {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    color: #c9d1d9;
    padding: 8px 12px;
    font-size: 0.84rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease;
}

.login-form input:focus {
    border-color: rgba(99,102,241,0.35);
}

.login-form input::placeholder {
    color: #484f58;
}

.btn-login {
    background: #d42026;
    border: none;
    color: #fff;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.84rem;
    padding: 8px 12px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s ease;
}

.btn-login:hover {
    background: #b91c22;
}

.auth-info {
    color: #8b949e;
    font-size: 0.82rem;
    padding: 8px 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.login-info {
    background: rgba(99,102,241,0.06);
    border: 1px solid rgba(99,102,241,0.18);
    border-radius: 6px;
    color: #b8bbc4;
    font-size: 0.75rem;
    line-height: 1.45;
    padding: 8px 10px;
    margin-top: 6px;
}

.login-info i {
    color: #6366f1;
    margin-right: 4px;
}

.login-info b {
    color: #e6e6e6;
}

.btn-login-ol {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #d42026;
    color: #fff;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.84rem;
    padding: 9px 12px;
    text-decoration: none;
    transition: background 0.2s ease;
    margin-top: 6px;
}

.btn-login-ol:hover {
    background: #b91c22;
    text-decoration: none;
}

.btn-logout {
    background: rgba(255,255,255,0.025);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 8px;
    color: #8b949e;
    font-size: 0.8rem;
    padding: 7px 12px;
    cursor: pointer;
    font-family: inherit;
    width: 100%;
    transition: all 0.2s ease;
}

.btn-logout:hover {
    background: rgba(255,255,255,0.05);
    color: #c9d1d9;
}

.login-error {
    color: #f85149;
    font-size: 0.76rem;
    margin-top: 2px;
}


/* Corporate info */
.corporate-info {
    font-size: 0.72rem;
    color: #6e7681;
    padding: 2px 0;
}

.corporate-info b {
    color: #c9d1d9;
}


/* Admin tools */
.admin-tools {
    margin: 4px 0;
}

.admin-eval-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(99,102,241,0.1);
    border: 1px solid rgba(99,102,241,0.2);
    border-radius: 8px;
    color: #a5b4fc;
    font-size: 0.82rem;
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
}

.admin-eval-btn:hover {
    background: rgba(99,102,241,0.2);
    border-color: rgba(99,102,241,0.4);
    color: #c7d2fe;
    text-decoration: none;
}

/* Settings */
.settings-section {
    margin: 2px 0;
}

.settings-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    color: #8b949e;
    cursor: pointer;
    padding: 6px 4px;
    border-radius: 6px;
    transition: background 0.15s ease;
    user-select: none;
}

.settings-header:hover {
    background: rgba(255,255,255,0.03);
}

.settings-chevron {
    margin-left: auto;
    font-size: 0.65em;
    transition: transform 0.2s ease;
}

.settings-chevron.open {
    transform: rotate(180deg);
}

.settings-body {
    padding: 8px 4px 4px;
}

.setting-group {
    margin-bottom: 10px;
}

.setting-label {
    font-size: 0.74rem;
    color: #6e7681;
    margin-bottom: 4px;
    display: block;
}

.setting-label i {
    margin-right: 3px;
    font-size: 0.85em;
    color: #8b949e;
}

.setting-hint {
    font-size: 0.65rem;
    color: #484f58;
    margin-top: 3px;
    font-style: italic;
}

.toggle-group {
    display: flex;
    gap: 4px;
}

.toggle-btn {
    flex: 1;
    background: rgba(255,255,255,0.025);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 6px;
    color: #8b949e;
    font-size: 0.78rem;
    padding: 5px 10px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s ease;
}

.toggle-btn:hover {
    background: rgba(255,255,255,0.05);
    color: #c9d1d9;
}

.toggle-btn.active {
    background: rgba(99,102,241,0.1);
    border-color: rgba(99,102,241,0.25);
    color: #a5b4fc;
}

/* Corporate language checkboxes */
.corp-languages {
    margin-top: 8px;
}

.corp-languages .setting-label {
    margin-bottom: 6px;
}

.corp-lang-display {
    font-size: 0.82rem;
    color: #c9d1d9;
    padding: 4px 10px;
    background: rgba(255,255,255,0.04);
    border-radius: 6px;
    display: inline-block;
}
.corp-lang-pills {
    display: flex; gap: 6px;
    margin-top: 4px; flex-wrap: wrap;
}
.corp-lang-pill {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    color: #8b949e;
    font-size: 0.78rem;
    padding: 5px 10px;
    cursor: pointer;
    font-family: inherit;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.corp-lang-pill:hover {
    color: #c9d1d9;
    border-color: rgba(99,102,241,0.3);
}
.corp-lang-pill.active {
    background: rgba(99,102,241,0.15);
    border-color: #a5b4fc;
    color: #a5b4fc;
    font-weight: 600;
}
.corp-lang-link {
    color: #a5b4fc;
    text-decoration: none;
    font-size: 0.75rem;
}
.corp-lang-link:hover {
    text-decoration: underline;
    color: #c4b5fd;
}


/* Chat history */
.history-section-title {
    font-size: 0.62rem;
    font-weight: 700;
    color: #484f58;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    padding: 4px 0 2px;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.history-empty {
    font-size: 0.76rem;
    color: #484f58;
    padding: 8px 0;
    font-style: italic;
}

.history-date-group {
    font-size: 0.6rem;
    font-weight: 600;
    color: #484f58;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 4px 2px;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 1px;
}

.history-item-btn {
    flex: 1;
    background: transparent;
    border: none;
    border-left: 2px solid transparent;
    border-radius: 0 8px 8px 0;
    color: #8b949e;
    font-size: 0.78rem;
    padding: 6px 10px;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s ease;
}

.history-item-btn:hover {
    background: rgba(255,255,255,0.025);
    border-left-color: #6366f1;
    color: #c9d1d9;
}

.history-item-btn.active {
    background: rgba(99,102,241,0.06);
    border-left-color: #6366f1;
    color: #e6edf3;
}

.history-item-delete {
    background: transparent;
    border: none;
    color: #484f58;
    font-size: 0.72rem;
    padding: 4px 6px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.history-item-delete:hover {
    color: #f85149;
    background: rgba(248,81,73,0.08);
}

.history-actions {
    padding-top: 6px;
    border-top: 1px solid rgba(255,255,255,0.05);
    margin-top: 4px;
}

.btn-danger {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    background: transparent;
    border: 1px solid rgba(248,81,73,0.15);
    color: #f85149;
    font-size: 0.78rem;
    border-radius: 8px;
    padding: 7px 12px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s ease;
}

.btn-danger:hover {
    background: rgba(248,81,73,0.08);
}


/* Mobile sidebar */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 22px;
    left: 8px;
    z-index: 1100;
    background: #161b22;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    color: #8b949e;
    font-size: 1rem;
    padding: 6px 10px;
    cursor: pointer;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}


/* Chat header */
.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: rgba(13,17,23,0.92);
    border-bottom: 1px solid rgba(255,255,255,0.05);
    backdrop-filter: blur(10px);
    flex-shrink: 0;
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-header-avatar {
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, #6366f1, #818cf8);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.85rem;
}

.chat-header-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #e6edf3;
}

.chat-header-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.7rem;
    color: #3fb950;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #3fb950;
    display: inline-block;
}

.header-btn {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    color: #8b949e;
    font-size: 0.78rem;
    padding: 6px 10px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s ease;
}

.header-btn:hover {
    background: rgba(255,255,255,0.07);
    color: #c9d1d9;
}

/* Learner switcher (admin preview of learner mode) */
.learner-switcher {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.learner-switcher.is-active {
    background: rgba(88, 166, 255, 0.16);
    border-color: rgba(88, 166, 255, 0.45);
    color: #58a6ff;
}
.learner-switcher.is-active:hover {
    background: rgba(88, 166, 255, 0.24);
    color: #79b8ff;
}


/* Welcome screen */
.welcome-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem 1rem;
    overflow-y: auto;
}

.welcome-icon {
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, #6366f1, #818cf8);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: #fff;
    margin-bottom: 1rem;
    box-shadow: 0 4px 20px rgba(99,102,241,0.2);
}

.welcome-screen h2 {
    font-size: 1.45rem;
    font-weight: 600;
    color: #e6edf3;
    margin: 0 0 0.5rem;
    letter-spacing: -0.02em;
    line-height: 1.3;
}

.welcome-sub {
    font-size: 0.88rem;
    color: #8b949e;
    max-width: 440px;
    margin: 0 auto;
    line-height: 1.6;
}

.quick-questions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 2rem;
    max-width: 540px;
    width: 100%;
}

.quick-question-btn {
    background: rgba(22,27,34,0.7);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 12px;
    color: #b1bac4;
    font-size: 0.83rem;
    padding: 14px 18px;
    cursor: pointer;
    font-family: inherit;
    line-height: 1.45;
    min-height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    transition: all 0.2s ease;
}

.quick-question-btn:hover {
    border-color: rgba(99,102,241,0.25);
    background: rgba(99,102,241,0.06);
    color: #e6edf3;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}


/* Chat messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px 16px;
    scroll-behavior: smooth;
    display: none;
}

.chat-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 1.4rem;
    animation: msg-in 0.25s ease-out;
}

@keyframes msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.chat-row-bot {
    justify-content: flex-start;
    max-width: 88%;
}

.chat-row-user {
    justify-content: flex-end;
    margin-left: auto;
    max-width: 70%;
}

/* Avatars */
.chat-avatar {
    width: 30px;
    height: 30px;
    min-width: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.75rem;
    color: #fff;
}

.chat-avatar-bot {
    background: linear-gradient(135deg, #6366f1, #818cf8);
    box-shadow: 0 2px 8px rgba(99,102,241,0.2);
}

.chat-avatar-user {
    background: #30363d;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* Message bubbles */
.chat-msg {
    padding: 14px 18px;
    line-height: 1.7;
    font-size: 0.95rem;
    color: #c9d1d9;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.chat-msg-bot {
    background: #161b22;
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 2px 14px 14px 14px;
    min-width: 200px;
}

.chat-msg-user {
    background: #1c2333;
    border: 1px solid rgba(99,102,241,0.12);
    border-radius: 14px 2px 14px 14px;
}

/* US-22 — inline screenshot attachments (WhatsApp-style) */
.chat-msg-has-attach {
    padding: 4px 4px 10px 4px;
    overflow: hidden;
}

.chat-msg-has-attach .chat-msg-text {
    padding: 6px 14px 2px 14px;
    line-height: 1.5;
}

.chat-msg-attachments {
    display: grid;
    grid-template-columns: 1fr;
    gap: 3px;
    border-radius: 10px 2px 2px 10px;
    overflow: hidden;
    margin-bottom: 6px;
}

.chat-attach-count-2 { grid-template-columns: 1fr 1fr; }
.chat-attach-count-3 { grid-template-columns: 1fr 1fr 1fr; }

.chat-attach-tile {
    position: relative;
    padding: 0;
    border: none;
    background: #0d1117;
    cursor: pointer;
    overflow: hidden;
    aspect-ratio: 16 / 10;
    border-radius: 8px;
    transition: opacity 150ms, transform 150ms;
}

.chat-attach-tile:hover {
    opacity: 0.92;
}

.chat-attach-tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.chat-attach-caption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 16px 8px 6px 8px;
    background: linear-gradient(to top, rgba(0,0,0,0.72), rgba(0,0,0,0));
    color: #e6edf3;
    font-size: 0.72rem;
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-attach-err {
    padding: 1px 5px;
    background: rgba(248,113,113,0.25);
    color: #fecaca;
    border-radius: 3px;
    font-size: 0.62rem;
    font-weight: 700;
    flex: 0 0 auto;
}

/* US-22.10: "grounded on N screenshot" badge in bot bubble footer */
.chat-grounded-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    background: rgba(99,102,241,0.14);
    color: #a5b4fc;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    margin-left: 6px;
    line-height: 1.5;
}

.chat-grounded-badge i {
    font-size: 0.7rem;
    opacity: 0.85;
}

/* Lightbox for full-size view */
.chat-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.88);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    cursor: zoom-out;
    animation: chat-lightbox-fadein 120ms ease-out;
}

.chat-lightbox img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}

.chat-lightbox-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 150ms;
}

.chat-lightbox-close:hover {
    background: rgba(255,255,255,0.22);
}

@keyframes chat-lightbox-fadein {
    from { opacity: 0; }
    to { opacity: 1; }
}


/* Markdown inside bubbles */
.chat-msg h1, .chat-msg h2, .chat-msg h3 {
    color: #e6edf3;
    font-weight: 600;
    margin: 0.8rem 0 0.4rem;
    line-height: 1.35;
}
.chat-msg h1 { font-size: 1.1em; }
.chat-msg h2 { font-size: 1.02em; }
.chat-msg h3 { font-size: 0.96em; }

.chat-msg strong { color: #e6edf3; font-weight: 600; }

.chat-msg ul, .chat-msg ol {
    margin: 0.6rem 0 0.6rem 0;
    padding-left: 1.5rem;
}
.chat-msg ol {
    padding-left: 1.6rem;
}
.chat-msg li {
    margin-bottom: 0.4rem;
    line-height: 1.7;
    padding-left: 0.3rem;
}
.chat-msg li::marker {
    color: #6e7681;
}

.chat-msg a { color: #58a6ff; text-decoration: none; }
.chat-msg a:hover { text-decoration: underline; color: #79c0ff; }

.chat-msg code {
    background: rgba(110,118,129,0.15);
    color: #e5a00d;
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 0.87em;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
}

.chat-msg pre {
    background: #0d1117;
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 8px;
    padding: 0.8rem 1rem;
    margin: 0.5rem 0;
    overflow-x: auto;
}
.chat-msg pre code {
    background: none;
    color: #c9d1d9;
    padding: 0;
}

.chat-msg blockquote {
    border-left: 3px solid #6366f1;
    padding-left: 0.8rem;
    margin: 0.5rem 0;
    color: #8b949e;
    font-style: italic;
}

.chat-msg p { margin-bottom: 0.65rem; }
.chat-msg p:last-child { margin-bottom: 0; }
.chat-msg p:first-child { margin-top: 0; }

/* Wrapper for bubble + timestamp */
.chat-msg-wrapper {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Timestamp under bubble */
.chat-timestamp {
    font-size: 0.65rem;
    color: #484f58;
    margin-top: 3px;
    padding: 0 4px;
}

.chat-timestamp-bot {
    text-align: left;
}

.chat-timestamp-user {
    text-align: right;
}

.chat-msg table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.5rem 0;
    font-size: 0.88em;
}
.chat-msg th {
    background: rgba(255,255,255,0.03);
    color: #e6edf3;
    font-weight: 600;
    text-align: left;
    padding: 8px 12px;
    border-bottom: 2px solid rgba(255,255,255,0.06);
}
.chat-msg td {
    padding: 6px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    color: #b1bac4;
}
.chat-msg tr:hover td {
    background: rgba(255,255,255,0.015);
}


/* Typing indicator */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 0;
}

.typing-indicator .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #6366f1;
    animation: typing-bounce 1.4s ease-in-out infinite;
}
.typing-indicator .dot:nth-child(1) { animation-delay: 0s; }
.typing-indicator .dot:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.3; }
    30%            { transform: translateY(-6px); opacity: 1; }
}

.typing-label {
    font-size: 0.76rem;
    color: #6e7681;
    margin-left: 8px;
    font-style: italic;
}

.typing-bubble {
    animation: pulse-bg 2s ease-in-out infinite;
}

@keyframes pulse-bg {
    0%, 100% { background: #161b22; }
    50% { background: #1c2333; }
}


/* Streaming cursor */
.streaming-cursor {
    display: inline-block;
    animation: cursor-blink 1s step-end infinite;
    color: #6366f1;
    font-weight: 600;
    margin-left: 1px;
}

@keyframes cursor-blink {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0; }
}


/* Suggestion pills */
.suggestions-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 40px 16px;
    justify-content: flex-start;
    animation: msg-in 0.3s ease-out;
}

.suggestion-pill {
    background: rgba(22,27,34,0.7);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 20px;
    color: #b1bac4;
    font-size: 0.82rem;
    padding: 8px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    line-height: 1.4;
    max-width: 320px;
    text-align: center;
}

.suggestion-pill:hover {
    border-color: rgba(99,102,241,0.25);
    background: rgba(99,102,241,0.06);
    color: #e6edf3;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}


/* Chat input bar */
.chat-input-bar {
    padding: 10px 20px 14px;
    flex-shrink: 0;
}

.chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #161b22;
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 24px;
    padding: 6px 6px 6px 18px;
    transition: border-color 0.2s ease;
}

.chat-input-wrapper:focus-within {
    border-color: rgba(99,102,241,0.35);
    box-shadow: 0 0 0 2px rgba(99,102,241,0.08);
}

.ai-disclaimer {
    text-align: center;
    font-size: 0.72rem;
    color: #6e7681;
    padding: 4px 0 0;
    letter-spacing: 0.01em;
}

/* Feedback thumbs */
.chat-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 3px;
}

.feedback-btns {
    display: flex;
    gap: 3px;
}

/* MI-03 debug log link (admin only, next to feedback buttons) */
.debug-log-link {
    color: #f0883e;
    font-size: 0.75em;
    text-decoration: none;
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid transparent;
    transition: border-color 0.15s, background 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 8px;
}
.debug-log-link:hover {
    border-color: #f0883e55;
    background: rgba(240, 136, 62, 0.08);
}
.debug-log-link i { font-size: 0.85em; }

.fb-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 0.88rem;
    transition: color 0.15s, background 0.15s, transform 0.15s;
}

.fb-btn[data-value="1"] { color: #f85149; }
.fb-btn[data-value="2"] { color: #f0883e; }
.fb-btn[data-value="3"] { color: #d2a436; }
.fb-btn[data-value="4"] { color: #56d364; }
.fb-btn[data-value="5"] { color: #3fb950; }

.fb-btn:hover {
    background: rgba(255,255,255,0.06);
    transform: scale(1.2);
}

.fb-btn.active {
    transform: scale(1.3);
    filter: brightness(1.3);
}

/* Feedback comment form */
.fb-comment-form {
    margin-top: 6px;
    max-width: 320px;
}

.fb-comment-form textarea {
    width: 100%;
    background: #161b22;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 6px;
    color: #c9d1d9;
    padding: 6px 8px;
    font-size: 0.8rem;
    font-family: inherit;
    resize: vertical;
    min-height: 40px;
}

.fb-comment-form textarea:focus {
    outline: none;
    border-color: rgba(99,102,241,0.35);
}

.fb-comment-actions {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

.fb-comment-submit, .fb-comment-cancel {
    padding: 3px 10px;
    border: none;
    border-radius: 4px;
    font-size: 0.72rem;
    cursor: pointer;
}

.fb-comment-submit {
    background: rgba(99,102,241,0.2);
    color: #a5b4fc;
}

.fb-comment-submit:hover {
    background: rgba(99,102,241,0.3);
}

.fb-comment-cancel {
    background: transparent;
    color: #6e7681;
}

.fb-comment-cancel:hover {
    color: #c9d1d9;
}

/* US-06.6 — Source citations: styles in sources-widget.css */

#chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: #c9d1d9;
    font-size: 0.9rem;
    font-family: inherit;
    line-height: 1.5;
    resize: none;
    outline: none;
    max-height: 120px;
    padding: 6px 0;
}

#chat-input::placeholder {
    color: #484f58;
}

.send-btn {
    width: 36px;
    height: 36px;
    background: #d42026;
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.send-btn:hover:not(:disabled) {
    background: #b91c22;
    transform: scale(1.05);
}

.send-btn:disabled {
    background: #30363d;
    color: #484f58;
    cursor: default;
}


/* Responsive */

/* Large desktop (1400px+) */
@media (min-width: 1400px) {
    .chat-msg { font-size: 1rem; line-height: 1.75; }
    .chat-messages { padding: 24px 32px 16px; }
    .welcome-screen h2 { font-size: 1.55rem; }
    .quick-questions { max-width: 600px; gap: 12px; }
    .quick-question-btn { font-size: 0.88rem; min-height: 58px; }
}

/* Ultra-wide desktop (1920px+) */
@media (min-width: 1920px) {
    .sidebar { width: 300px; }
    .main-content { left: 300px; }
    .chat-msg { font-size: 1.02rem; line-height: 1.8; padding: 14px 20px; }
    .chat-messages { padding: 28px 40px 20px; }
    .chat-avatar { width: 34px; height: 34px; min-width: 34px; font-size: 0.82rem; }
    .chat-row { gap: 12px; margin-bottom: 1.6rem; }
    .welcome-screen h2 { font-size: 1.7rem; }
    .welcome-icon { width: 58px; height: 58px; font-size: 1.4rem; }
    .quick-questions { max-width: 660px; }
}

/* Tablet landscape / small desktop (1024px - 768px) */
@media (max-width: 1024px) {
    .sidebar { width: 260px; }
    .main-content { left: 260px; }
    .chat-header { padding: 8px 16px; }
    .chat-messages { padding: 16px 16px 10px; }
}

/* Tablet portrait / mobile (768px and below) */
@media (max-width: 768px) {
    /* Sidebar becomes overlay */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        width: 280px;
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-toggle { display: block; }
    .sidebar-overlay.active { display: block; }

    /* Main fills screen */
    .main-content {
        left: 0;
    }

    /* Chat area */
    .chat-header { padding: 8px 12px; }
    .chat-header-avatar { width: 30px; height: 30px; font-size: 0.8rem; }
    .chat-header-title { font-size: 0.85rem; }
    .chat-messages { padding: 12px 12px 8px; }
    .chat-input-bar { padding: 8px 12px 10px; }
    .chat-input-wrapper textarea { font-size: 0.88rem; }

    /* Bubbles */
    .chat-row { margin-bottom: 1rem; gap: 8px; }
    .chat-row-bot { max-width: 95%; }
    .chat-row-user { max-width: 85%; }
    .chat-msg { font-size: 0.88rem; padding: 10px 12px; }
    .chat-avatar { width: 28px; height: 28px; min-width: 28px; font-size: 0.7rem; }

    /* Suggestions */
    .suggestion-pill { font-size: 0.78rem; padding: 7px 13px; }

    /* Welcome */
    .welcome-screen { padding: 1.5rem 1rem; }
    .welcome-screen h2 { font-size: 1.25rem; }
    .welcome-sub { font-size: 0.82rem; }
    .quick-questions { grid-template-columns: 1fr 1fr; max-width: 400px; gap: 8px; }
    .quick-question-btn { min-height: 48px; font-size: 0.82rem; padding: 10px 14px; }

    /* Footer */
    .app-footer { padding: 2px 0; }
    .app-footer a { font-size: 0.52rem; }
}

/* Small mobile (480px and below) */
@media (max-width: 480px) {
    .chat-row-bot { max-width: 98%; }
    .chat-row-user { max-width: 92%; }
    .chat-avatar { width: 24px; height: 24px; min-width: 24px; font-size: 0.65rem; }
    .chat-msg { font-size: 0.85rem; padding: 8px 10px; line-height: 1.6; }
    .chat-row { gap: 6px; margin-bottom: 0.8rem; }

    .suggestion-pill { font-size: 0.76rem; padding: 6px 11px; max-width: 280px; }

    .welcome-screen { padding: 1rem 0.5rem; }
    .welcome-icon { width: 44px; height: 44px; font-size: 1.1rem; }
    .welcome-screen h2 { font-size: 1.1rem; }
    .welcome-sub { font-size: 0.78rem; }

    .quick-questions { grid-template-columns: 1fr; max-width: 300px; }
    .quick-question-btn { min-height: 44px; font-size: 0.8rem; padding: 10px 12px; }

    .chat-header { padding: 6px 10px; }
    .chat-header-avatar { width: 28px; height: 28px; }
    .chat-input-bar { padding: 6px 8px 8px; }
    .send-btn { width: 36px; height: 36px; font-size: 0.8rem; }
}
