@import url('https://fonts.googleapis.com/css2?family=Google+Sans:wght@400;500;700&family=Roboto:wght@300;400;500&display=swap');

/* ========================== */
/*         GENERAL RESET      */
/* ========================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Google Sans', 'Roboto', sans-serif;
}

:root {
    --primary-color: #202124;
    --secondary-color: #303134;
    --accent-color: #4CAF50;
    --text-color: #e8eaed;
    --subheading-color: #9aa0a6;
    --placeholder-color: #969ba1;
    --bot-message-bg: #303134;
    --user-message-bg: #4CAF50;
    --user-message-text: #202124;
    --input-bg: #444 !important;
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow-color: rgba(0, 0, 0, 0.3);
}

/* ========================== */
/*           BODY             */
/* ========================== */
html,
body {
    height: 100%;
    background: var(--primary-color);
    display: flex;
    flex-direction: column;
    /* prevent double scrollbars */
}

/* ========================== */
/*          SIDEBAR           */
/* ========================== */
.sidebar {
    width: 80px;
    height: 100vh;
    background: linear-gradient(135deg, #1c1c1c 30%, #292929 100%);
    padding: 10px 0;
    position: fixed;
    left: 0;
    top: 0;
    display: flex;
    justify-content: space-evenly;
    box-shadow: 4px 0 10px rgba(0, 0, 0, 0.2);
    border-right: 2px solid var(--border-color);
    overflow: hidden;
    transition: width 0.3s ease;
    z-index: 1000;
}

.sidebar.expanded {
    width: 250px;
}

.sidebar-icons {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding-top: 70px;
    align-items: center;
}

.sidebar-icon {
    background: none;
    border: none;
    color: white;
    font-size: 30px;
    cursor: pointer;
    transition: color 0.2s;
    margin-bottom: 20px;
}

.sidebar.expanded .sidebar-icons {
    display: none;
}

[class$="-theme"] .sidebar-icon:hover {
    color: var(--primary);
}

#closeSidebar {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    align-self: flex-end;
    margin: 10px;
    display: none;
    align-items: center !important;
}

.sidebar.expanded #closeSidebar {
    display: block;
}

.sidebar-content {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    padding-top: 0;
    display: flex;
    flex-direction: column;
    height: calc(88vh - -67px);
    /* fills sidebar minus top padding */
    overflow: hidden;
    /* nothing escapes the sidebar */
}

.sidebar.expanded .sidebar-content {
    opacity: 1;
    pointer-events: auto;
}

#chat-thread-label {
    color: var(--accent-color);
}

.menu-label {
    font-weight: bold;
    text-transform: uppercase;
    color: #4dbf00;
    font-size: 1.2rem;
    padding: 15px 0;
    border-bottom: 2px solid var(--border-color);
    width: 100%;
    text-align: center;
}

.menu-list {
    list-style: none;
    padding: 0;
    width: 100%;
    margin-top: 20px;
}

.menu-list a {
    color: #ddd;
    font-size: 17px;
    padding: 12px 20px;
    display: block;
    border-radius: 8px;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    transition: all 0.3s ease-in-out;
}

.menu-list a:hover {
    background: rgba(77, 191, 0, 0.15);
    color: #4dbf00;
}

/* ========================== */
/*  HAMBURGER BUTTON          */
/* ========================== */
.toggle-btn {
    background: none;
    border: none;
    color: white;
    font-size: 30px;
    cursor: pointer;
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 2000;
    display: block;
}

.sidebar.expanded .toggle-btn {
    display: none !important;
}

/* ========================== */
/*           HEADER           */
/* ========================== */
.header {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 50;
}

body.hide-header .header {
    display: none;
}

.site-title {
    position: fixed;
    top: 1rem;
    left: 6rem;
    font-size: 1.5rem;
    font-weight: 600;
    color: white;
}

.header .title {
    font-size: 3rem;
    background: linear-gradient(270deg, #4285f4, #d96570, #4285f4);
    background-size: 600% 600%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: gradientMove 10s ease infinite;
}

@keyframes gradientMove {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

.header .subtitle {
    font-size: 2rem;
    color: var(--subheading-color);
}

.micro-subtitle {
    font-size: 0.85rem;
    color: #b5b5b5;
    min-height: 1em;
    margin-top: 0.25rem;
    font-style: italic;
}

.welcome {
    text-align: center;
    margin-bottom: 14rem;
}

/* Inline pasted chips in user messages */
.pasted-chip-inline {
    position: relative;
    display: inline-block;
    background: #3a3a3a;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 6px 50px 6px 10px;
    margin: 4px 4px 4px 0;
    max-width: 200px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.65);
    font-family: 'Courier New', monospace;
}

.pasted-chip-inline .chip-label {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: #4a4a4a;
    color: rgba(255, 255, 255, 0.5);
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.06em;
    padding: 2px 5px;
    border-radius: 4px;
    text-transform: uppercase;
    font-family: 'Google Sans', sans-serif;
}

#chat-box {
    width: 70%;
    max-width: 100rem;
    display: flex;
    flex-direction: column;
    margin-left: auto;
    margin-right: auto;
    padding-top: 5rem;
    /* ← messages always start from here */
    padding-bottom: 20rem;
    overflow-y: auto;
}

#chat-box.has-messages {
    justify-content: flex-start;
    /* top-aligned when chatting */
}

#chat-box::-webkit-scrollbar {
    display: none;
}

/* Hide scrollbar (Firefox) */
#chat-box {
    scrollbar-width: none;
    /* Firefox */
}

/* ========================== */
/*       MESSAGES  ← CHANGED  */
/* ========================== */
.message,
.bot-message,
.user-message {
    max-width: 68%;
    padding: 14px 18px;
    border-radius: 16px;
    margin-bottom: 12px;
    word-wrap: break-word;
    position: relative;
    animation: fadeIn 0.3s ease;
    line-height: 1.65;
    text-align: center;
    font-size: 18px;
}


.bot-message {
    background: #2f2f2f;
    border: 1.5px solid rgba(255, 255, 255, 0.35) !important;
    color: var(--text-color);
    align-self: flex-start;
    border-radius: 4px 18px 18px 18px;
    margin-right: auto;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.user-message {
    background: var(--user-message-bg);
    color: var(--user-message-text);
    align-self: flex-end;
    border-radius: 18px 18px 4px 18px;
    margin-left: auto;
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
    font-weight: 500;
    border: 1.5px solid rgba(255, 255, 255, 0.45) !important;
}

.bot-message p,
.user-message p {
    margin: 0;
    padding: 0;
    border: none !important;
}

/* Copy Button */
.copy-button {
    position: absolute !important;
    top: 5px;
    right: 5px;
    font-size: 14px;
    color: white;
    background: rgba(255, 255, 255, 0.2);
    padding: 5px;
    border-radius: 5px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.bot-message:hover .copy-button {
    opacity: 1;
}

/* ========================== */
/*  CHAT INPUT  ← CHANGED     */
/* ========================== */

/* The outer wrapper — fades out at bottom */
.input-section {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0 1rem 0.75rem;
    background: linear-gradient(to top, var(--primary-color) 75%, transparent);
    z-index: 100;
    /* Make sure it doesn't shrink */
    flex-shrink: 0;
}

/* Card — vertical flex so textarea is on top, actions on bottom */
.chat-input-container {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
    background: #2f2f2f;
    border-radius: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
    max-width: 750px;
    margin: 0 auto;
    overflow: visible;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.chat-input-container:focus-within {
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 32px rgba(0, 0, 0, 0.45);
}

/* Image preview sits at top, inside the card */
#image-preview {
    display: none;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 14px 0;
    background: transparent;
    max-height: 110px;
    overflow-y: auto;
    margin-bottom: 0;
}

#image-preview.active {
    display: flex;
}

/* Textarea — transparent, no inner box look */
#user-input {
    flex: 1;
    background: transparent !important;
    border: none;
    outline: none;
    padding: 14px 16px 6px;
    color: var(--text-color) !important;
    font-size: 15px;
    font-family: 'Google Sans', 'Roboto', sans-serif;
    border-radius: 0;
    resize: none;
    min-height: 46px;
    max-height: 180px;
    /* allows it to grow on shift+enter */
    overflow-y: auto;
    line-height: 1.5;
    width: 100%;
}

#user-input::placeholder {
    color: rgba(255, 255, 255, 0.35);
    font-style: normal;
    /* was: italic */
}

/* Bottom bar inside the card */
.input-actions-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 10px 10px;
}

.input-actions-left,
.input-actions-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Small icon buttons */
.icon-button {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 15px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
}

.icon-button:hover {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.9);
}

/* Slash command button */
.slash-button {
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.slash-button:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-color: rgba(255, 255, 255, 0.2);
}

/* Green circular send button */
.send-btn {
    width: 32px;
    height: 32px;
    background: #4CAF50;
    border: none;
    border-radius: 50%;
    color: #111;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, transform 0.1s ease;
    flex-shrink: 0;
    pointer-events: auto !important;
    z-index: 101 !important;
}

.send-btn:hover {
    background: #5bc85f;
    transform: scale(1.07);
}

.send-btn:active {
    transform: scale(0.94);
}

/* Word counter */
#word-counter {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.3);
    user-select: none;
    flex-shrink: 0;
    display: none;
    margin-right: 4px;
}

/* Tools wrapper */
.tools-wrapper {
    position: relative;
}

/* Tools dropdown */
.tools-popup {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    background: #2a2a2a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    padding: 6px;
    z-index: 999;
    flex-direction: column;
    gap: 2px;
    min-width: 200px;
}

.tools-popup.show {
    display: flex;
}

.tool-option {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 13px;
    padding: 8px 10px;
    text-align: left;
    cursor: pointer;
    border-radius: 8px;
    width: 100%;
    transition: background 0.15s ease;
}

.tool-option:hover {
    background: rgba(255, 255, 255, 0.07);
}

.model-label {
    font-size: 13px;
    color: var(--text-color);
    display: flex;
    align-items: center;
    padding: 8px 10px;
}

.model-label select {
    margin-left: 8px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-color);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 2px 6px;
    font-size: 12px;
    flex: 1;
}

/* ========================== */
/*  CODE BLOCKS  ← NEW        */
/* ========================== */

.message-code-block {
    background: #1e1e1e;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    margin: 10px 0;
    overflow: hidden;
    font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
    font-size: 13px;
    max-width: 100%;
}

table {
    border-collapse: collapse;
    width: 100%;
    margin: 16px 0;
    font-size: 14px;
}

th,
td {
    border: 1px solid #3a3a3a;
    padding: 10px;
    text-align: center;
}

th {
    background: #1e1e1e;
    font-weight: 600;
}

tr:nth-child(even) {
    background: #252526;
}

tr:nth-child(odd) {
    background: #1e1e1e;
}

.message-code-block .code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 12px;
    background: rgba(255, 255, 255, 0.04);
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.message-code-block .code-lang {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-family: 'Google Sans', sans-serif;
}

.message-code-block .code-copy-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    font-size: 12px;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: color 0.15s, background 0.15s;
    font-family: 'Google Sans', sans-serif;
}

.message-code-block .code-copy-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.08);
}

.message-code-block pre {
    margin: 0;
    padding: 14px 16px;
    overflow-x: auto;
    line-height: 1.6;
    background: transparent;
    color: #e6e6e6;
    white-space: pre;
    font-size: 13px;
}

.message-code-block pre::-webkit-scrollbar {
    height: 5px;
}

.message-code-block pre::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

/* Long text "paste" block */
.message-long-text {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-left: 3px solid #4CAF50;
    border-radius: 8px;
    padding: 12px 16px;
    margin: 8px 0;
    font-size: 14px;
    line-height: 1.65;
    color: rgba(255, 255, 255, 0.85);
    max-height: 220px;
    overflow-y: auto;
    position: relative;
}

.message-long-text::-webkit-scrollbar {
    width: 5px;
}

.message-long-text::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

/* ========================== */
/*        ANIMATIONS          */
/* ========================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================== */
/*  DISCLAIMER  ← CHANGED     */
/* ========================== */
.disclaimer-text {
    text-align: center;
    font-size: 11px;
    color: rgb(255, 255, 255);
    padding: 4px 0 6px;
    letter-spacing: 0.02em;
}

/* ========================== */
/*       IMAGE MESSAGES       */
/* ========================== */
.image-container {
    display: inline-block;
    max-width: 80%;
    margin: 8px 0;
    background: var(--chat-bubble-bg, #2c2c2c);
    border-radius: 12px;
    padding: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    animation: FadeIn 0.25s ease-in-out;
}

.image-wrapper {
    overflow: hidden;
    border-radius: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.uploaded-image {
    display: block;
    max-width: 103%;
    max-height: 108px;
    border-radius: 0px;
    object-fit: cover;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    cursor: pointer;
}

.uploaded-image:hover {
    transform: scale(1.03);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25);
}

.user-text {
    margin-top: 6px;
    font-size: 14px;
    color: #ddd;
    text-align: center;
}

@keyframes FadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================== */
/*         BUTTONS            */
/* ========================== */
.notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #1e1e2f;
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    font-size: 0.95rem;
    z-index: 9999;
    pointer-events: none;
}

.hidden-answer {
    filter: blur(8px) !important;
    cursor: pointer !important;
    transition: filter 0.3s ease !important;
    color: #888 !important;
}

.hidden-answer.revealed {
    filter: blur(0) !important;
    color: #fff !important;
}

@keyframes typing {
    0% {
        opacity: 0;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

.typing-indicator {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 10px;
}

.typing-indicator span {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin: 0 2px;
    background-color: #4CAF50;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

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

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

.edit-button {
    position: absolute;
    top: 6px;
    right: 6px;
    opacity: 0;
    transition: opacity 0.15s ease, transform 0.15s ease;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.25);
    color: #fff;
    padding: 6px;
    border-radius: 6px;
    font-size: 14px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transform: translateY(-2px);
}

.message:hover .edit-button {
    opacity: 1;
    transform: translateY(0);
}

.edit-textarea {
    width: 100%;
    height: 100px;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    resize: vertical;
}

.save-button {
    margin-top: 10px;
    padding: 5px 10px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999;
}

.modal-content {
    background-color: #2e2e2e;
    padding: 20px;
    border-radius: 8px;
    width: 80%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    color: white;
    z-index: 9999;
}

.modal-content strong {
    color: white;
}

.close-btn {
    font-size: 30px;
    cursor: pointer;
    position: absolute;
    top: 10px;
    right: 10px;
}

.close-btn:hover {
    color: red;
}

#debug-panel {
    display: none;
    position: fixed;
    bottom: 10px;
    right: 10px;
    background: rgba(17, 17, 17, 0.95);
    color: white;
    padding: 12px;
    border-radius: 10px;
    z-index: 9999;
    font-family: monospace;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
    cursor: move;
    width: auto;
    max-width: 320px;
    user-select: none;
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#debug-panel .button-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-start;
}

#debug-panel button {
    flex: 1 1 calc(50% - 6px);
    background: #222;
    border: none;
    color: white;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    text-align: center;
    transition: background 0.2s ease;
    min-width: 100px;
}

#debug-panel button:hover {
    background: #333;
}

/* ========================== */
/*       IMAGE PREVIEW        */
/* ========================== */
.image-preview {
    display: none;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 14px 0;
    background: transparent;
    max-height: 110px;
    overflow-y: auto;
    margin-bottom: 0;
    transition: all 0.3s ease;
}

.image-preview.active {
    display: flex;
}

.uploaded-preview {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease;
    cursor: pointer;
}

.uploaded-preview:hover {
    transform: scale(1.05);
}

.remove-btn {
    position: absolute;
    top: -6px;
    right: -6px;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    border-radius: 50%;
    color: white;
    width: 20px;
    height: 20px;
    font-size: 14px;
    line-height: 20px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.preview-wrapper:hover .remove-btn {
    opacity: 1;
}

.preview-wrapper {
    position: relative;
    display: inline-block;
}

/* ========================== */
/*       CHAT THREADS         */
/* ========================== */
.thread-link {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: #e6e6e6;
    text-align: left;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 10px;
    padding: 10px 14px;
    width: 100%;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.thread-link:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(3px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

body:not([class*="-theme"]) .active-thread .thread-link {
    background: linear-gradient(135deg, #43ed8d, #38ecb0);
    color: #fff;
    font-weight: 600;
    transform: translateX(3px);
}

[class*="-theme"] .active-thread .thread-link {
    background: none !important;
    background-color: var(--primary) !important;
    color: var(--text-inverse) !important;
    font-weight: 600;
    transform: translateX(3px);
}

.delete-btn {
    background: transparent;
    border: none;
    color: #ff7070;
    font-size: 1.3rem;
    cursor: pointer;
    opacity: 0.7;
    margin-left: 8px;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.delete-btn:hover {
    opacity: 1;
    transform: scale(1.2);
}

#chat-threads-list {
    list-style: none;
    padding: 10px;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 25vh;
    /* ← limits how tall threads can grow */
    overflow-y: auto;
    /* ← scrolls within that box */
}

#chat-threads-list::-webkit-scrollbar {
    width: 6px;
}

#chat-threads-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
}

/* Pasted blocks row container */
.pasted-blocks-row {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 6px;
    padding: 8px 14px 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.pasted-blocks-row::-webkit-scrollbar {
    display: none;
}

/* Individual pasted chip */
.pasted-block {
    position: relative;
    background: #2a2a2a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 8px 30px 26px 10px;
    /* right pad for ×, bottom for label */
    width: 140px;
    flex-shrink: 0;
    max-height: 72px;
    overflow: hidden;
    cursor: default;
}

.pasted-block::before {
    content: '';
    position: absolute;
    bottom: 22px;
    left: 0;
    right: 0;
    height: 28px;
    background: linear-gradient(to top, #2a2a2a 40%, transparent);
    pointer-events: none;
}

.pasted-block-text {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
    font-family: 'Courier New', monospace;
    white-space: pre;
    overflow: hidden;
    line-height: 1.4;
    pointer-events: none;
    user-select: none;
}

.pasted-label {
    position: absolute;
    bottom: 6px;
    left: 8px;
    background: #3a3a3a;
    color: rgba(255, 255, 255, 0.5);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.07em;
    padding: 2px 7px;
    border-radius: 5px;
    font-family: 'Google Sans', sans-serif;
    text-transform: uppercase;
    pointer-events: none;
    user-select: none;
}

.pasted-remove {
    position: absolute;
    top: 4px;
    right: 5px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.3);
    font-size: 14px;
    cursor: pointer;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 4px;
    transition: color 0.15s ease, background 0.15s ease;
}

.pasted-remove:hover {
    color: white;
    background: rgba(255, 255, 255, 0.08);
}

.created-by {
    text-align: center;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.4);
    margin-top: 20px;
    margin-bottom: 10px;
}

.created-by a {
    color: rgba(255, 255, 255, 0.6);
    text-decoration: underline;
    transition: color 0.15s ease;
}

/* ========================== */
/*     MOBILE VIEW (≤768px)   */
/* ========================== */
@media (max-width: 768px) {
    * {
        touch-action: manipulation;
    }

    .site-title {
        z-index: 1 !important;
        /* Very low - behind everything */
        position: fixed !important;
        top: 0;
        left: 0;
        right: 0;
        padding: 12px 16px;
        margin: 0;
        font-size: 18px;
        text-align: center;
        background: rgba(0, 0, 0, 0.95);
        /* Back to solid for proper cutoff */
        backdrop-filter: blur(15px);
        border-bottom: 2px solid #4dbf00;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
        height: 50px;
        display: flex;
        align-items: center;
        justify-content: center;
        pointer-events: none;
        /* Don't block clicks on other elements */
    }

    .site-title::after {
        content: '';
        position: absolute;
        bottom: -2px;
        left: 0;
        right: 0;
        height: 2px;
        background: linear-gradient(90deg, transparent 0%, #4dbf00 25%, #4dbf00 75%, transparent 100%);
        box-shadow: 0 1px 3px rgba(77, 191, 0, 0.5);
    }

    .sidebar {
        width: 0;
        height: 100vh;
        position: fixed;
        top: 0;
        left: 0;
        overflow: hidden;
        background: none;
        box-shadow: none;
        border-right: none;
        transition: width 0.3s ease, box-shadow 0.3s ease;
        z-index: 1000;
        padding-top: 20px;
    }

    .sidebar.expanded {
        width: 80%;
        max-width: 240px;
        box-shadow: 4px 0 10px rgba(0, 0, 0, 0.4);
        border-right: 2px solid var(--border-color);
        background: linear-gradient(135deg, #1c1c1c 30%, #292929 100%) !important;
    }

    .sidebar.expanded .sidebar-content {
        display: block;
        padding: 15px;
    }

    .toggle-btn {
        position: fixed;
        top: 7px;
        left: 12px;
        border: none;
        font-size: 20px;
        width: 36px;
        height: 36px;
        border-radius: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        z-index: 1002;
        transition: all 0.2s ease;
        pointer-events: auto;
    }

    .toggle-btn:hover {
        transform: scale(1.1);
    }

    .sidebar.expanded #closeSidebar {
        display: block;
        position: absolute;
        top: 10px;
        left: 15px;
        background: none;
        border: none;
        font-size: 28px;
        color: #fff;
        cursor: pointer;
    }

    .sidebar:not(.expanded) .sidebar-icons {
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
    }

    #chat-box {
        width: 100%;
        display: flex;
        flex-direction: column;
        overflow-y: auto;
        padding: 130px 0px 200px 0px;
        /* ← ADD THIS: pushes content above the input bar */
        -webkit-overflow-scrolling: touch;
    }

    .header {
        position: fixed;
        top: 45%;
        left: 0;
        right: 0;
        transform: translateY(-50%);
        width: 100%;
        text-align: center;
        padding: 0 20px;
    }

    .header .title {
        font-size: 2.2rem;
        text-align: center;
        display: block;
    }

    .header .subtitle {
        font-size: 1.4rem;
        text-align: center;
    }

    .micro-subtitle {
        text-align: center;
        font-size: 0.8rem;
    }

    .welcome {
        text-align: center;
        margin-bottom: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        width: 100%;
    }

    /* Messages on mobile */
    .message {
        position: relative;
        width: 55%;
        line-height: 1.4;
        border-radius: 10px;
        margin: 6px 0;
        padding: 10px 14px;
        word-wrap: break-word;
        word-break: break-word;
        white-space: pre-wrap;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
        clear: both;
        display: inline-block;
    }

    .message a {
        display: inline !important;
        text-decoration: underline !important;
        word-break: break-all !important;
        font-weight: bold !important;
        font-size: 15px !important;
    }

    .user-message {
        align-self: flex-end;
        background-color: #30b35a;
        color: #fff;
        margin-left: 45%;
        border-bottom-right-radius: 6px;
        text-align: center;
    }

    .bot-message {
        align-self: flex-start;
        background: linear-gradient(135deg, #2c2c2c 0%, #383838 100%);
        color: #fff;
        margin-right: 45%;
        border-bottom-left-radius: 6px;
        border: 1px solid rgba(255, 255, 255, 0.1);
        text-align: center;
    }

    /* Input on mobile — keep the card but tighten it */
    .chat-input-container {
        border-radius: 1.2rem;
        margin: 0 4px;
    }

    #user-input {
        font-size: 17px;
        padding: 12px 14px 4px;
        min-height: 40px;
        max-height: 100px;
    }

    .icon-button,
    .slash-button {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }

    .send-btn {
        width: 30px;
        height: 30px;
        font-size: 13px;
    }

    .message-code-block pre {
        font-size: 12px;
    }

    .theme-container {
        position: fixed !important;
        top: 7px !important;
        right: 1px !important;
        padding: 0px 1px !important;
        border-radius: 18px !important;
        background: rgba(0, 0, 0, 0.8) !important;
        backdrop-filter: blur(5px) !important;
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 6px !important;
        z-index: 1002 !important;
        height: 36px;
        transition: all 0.2s ease;
        pointer-events: auto;
    }

    .theme-container label {
        display: none;
    }

    #theme-select {
        font-size: 13px;
        padding: 4px 8px;
        background: transparent;
        border: none;
        border-radius: 6px;
        cursor: pointer;
        min-width: 70px;
        font-weight: 500;
        outline: none;
    }

    .readme-modal {
        padding: 8px;
        align-items: flex-start;
        margin-bottom: auto;
    }

    .modal-content {
        width: 92%;
        max-width: 92%;
        max-height: 75vh;
        padding: 12px;
        font-size: 13px;
        border-radius: 12px;
        background: rgba(0, 0, 0, 0.95);
        backdrop-filter: blur(10px);
        border: 1px solid rgba(255, 255, 255, 0.2);
    }

    .close-btn {
        font-size: 22px;
        top: 8px;
        right: 12px;
        color: #fff;
        background: rgba(255, 255, 255, 0.1);
        border-radius: 50%;
        width: 30px;
        height: 30px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .typing-indicator {
        font-size: 12px;
        color: rgba(255, 255, 255, 0.6);
        margin: 4px 0;
        padding: 0 12px;
    }

    h1,
    h2,
    h3 {
        font-size: 16px;
        line-height: 1.2;
    }

    p {
        font-size: 14px;
        line-height: 1.3;
    }

    code {
        font-size: 12px;
        padding: 2px 4px;
        background: rgba(0, 0, 0, 0.3);
        border-radius: 3px;
    }

    pre {
        font-size: 11px;
        padding: 8px;
        border-radius: 6px;
        overflow-x: auto;
        background: rgba(0, 0, 0, 0.4);
        border: 1px solid rgba(255, 255, 255, 0.1);
    }

    .tools-popup {
        position: fixed !important;
        bottom: 90px;
        /* above input bar */
        left: 10px;
        right: 10px;
        width: auto;
        max-width: none;
        border-radius: 16px;
        background: rgba(0, 0, 0, 0.95);
        backdrop-filter: blur(20px);
        padding: 10px;
        z-index: 9999;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
        animation: slideUp 0.2s ease;
        text-align: center !important;
    }

    @keyframes slideUp {
        from {
            transform: translateY(20px);
            opacity: 0;
        }

        to {
            transform: translateY(0);
            opacity: 1;
        }
    }
}