/* ═══════════════════════════════════════════════════════════════
   AI Hindi 1 — ChatGPT-Style Design System
   ═══════════════════════════════════════════════════════════════ */

/* ── Design Tokens ─────────────────────────────────────────────── */
:root {
    --bg: #212121;
    --sidebar-bg: #171717;
    --surface: #2f2f2f;
    --surface-2: #3d3d3d;
    --sidebar-hover: #2a2a2a;
    --border: rgba(255, 255, 255, 0.1);
    --text-1: #ececec;
    --text-2: #b4b4b4;
    --text-3: #6b6b6b;
    --brand-green: #10A37F;
    --accent: #7eb3f7;
    --accent-hover: #a4c6f9;
    --chip-bg: #3d3d3d;
    --chip-hover: #4a4a4a;
    --user-bubble: #2f2f2f;
    --send-active: #10A37F;
    --input-bg: #2f2f2f;
    --shadow: 0 2px 16px rgba(0, 0, 0, 0.4);
    --font: 'Inter', system-ui, -apple-system, sans-serif;
    --radius-pill: 24px;
    --radius-lg: 18px;
    --radius-md: 12px;
    --sidebar-w: 260px;
    --transition: 0.2s ease;
}

html[data-theme="light"] {
    --bg: #ffffff;
    --sidebar-bg: #f9f9f9;
    --surface: #f9f9f9;
    --surface-2: #efefef;
    --sidebar-hover: #ececec;
    --border: rgba(0, 0, 0, 0.1);
    --text-1: #0d0d0d;
    --text-2: #6b6b6b;
    --text-3: #ababab;
    --brand-green: #10A37F;
    --accent: #1a73e8;
    --accent-hover: #1557b0;
    --chip-bg: #f4f4f4;
    --chip-hover: #ebebeb;
    --user-bubble: #f0f0f0;
    --send-active: #10A37F;
    --input-bg: #f9f9f9;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

/* ── Reset ─────────────────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    /* Completely removes the blue semi-transparent tap highlight on mobile */
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text-1);
    height: 100dvh;
    overflow: hidden;
    font-size: 16px;
    font-weight: 400;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    letter-spacing: -0.01em;
}

button {
    font-family: var(--font);
    cursor: pointer;
}

button,
.action-icon,
svg,
.material-symbols-outlined,
.material-symbols-filled,
.chat-item,
.dropdown-item,
.bottom-sheet-item,
.model-name-chip,
.sheet-menu li {
    user-select: none;
    -webkit-user-select: none;
}

.material-symbols-filled {
    font-family: 'Material Symbols Outlined';
    font-weight: normal;
    font-style: normal;
    font-size: 24px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    font-feature-settings: 'liga';
    -webkit-font-feature-settings: 'liga';
    -webkit-font-smoothing: antialiased;
    /* This applies the filled variation */
    font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

a {
    color: var(--accent);
    text-decoration: none;
}

/* ── Layout ────────────────────────────────────────────────────── */
.app-container {
    display: flex;
    height: 100dvh;
    overflow: hidden;
}

/* ══════════════════════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════════════════════ */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    padding: 8px 8px 12px;
    height: 100dvh;
    flex-shrink: 0;
    transition: width var(--transition), padding var(--transition);
    overflow: hidden;
    /* No border — ChatGPT style seamless */
}

/* Collapsed sidebar */
.sidebar.collapsed {
    width: 72px;
    padding: 12px 8px;
    align-items: center;
}

.sidebar.collapsed .new-chat-label,
.sidebar.collapsed .recent-chats-section,
.sidebar.collapsed .settings-label,
.sidebar.collapsed .section-label,
.sidebar.collapsed .edit-btn {
    display: none;
}

.sidebar.collapsed .new-chat-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    padding: 0;
    justify-content: center;
}

/* ── Sidebar Top Row ─────────────────────────────────────── */
.sidebar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 8px;
    margin-bottom: 8px;
    flex-shrink: 0;
}

.sidebar.collapsed .sidebar-top {
    justify-content: center;
}

/* ── Sidebar Top Search ─────────────────────────────────── */
.sidebar-search-container {
    padding: 12px 0 8px 0;
    /* Remove horizontal padding so input matches new chat button width */
    margin-bottom: 0px;
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.sidebar.collapsed .sidebar-search-container {
    display: none;
}

.search-icon {
    position: absolute;
    left: 16px;
    /* Match the internal padding of the input */
    color: var(--text-2);
    font-size: 20px;
    pointer-events: none;
}

.sidebar-search-input {
    width: 100%;
    flex: 1;
    padding: 10px 16px 10px 40px;
    border-radius: 8px;
    border: none;
    background: var(--surface-2);
    color: var(--text-1);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: background-color 0.2s, box-shadow 0.2s;
}

.sidebar-search-input:hover,
.sidebar-search-input:focus {
    background: var(--surface-2);
    box-shadow: 0 0 0 1px var(--border);
}

/* ── Icon Button (shared) ───────────────────────────────── */
.icon-btn {
    background: none;
    border: none;
    color: var(--text-2);
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition), color var(--transition);
    min-width: 44px;
    min-height: 44px;
}

.icon-btn:hover {
    background: var(--surface-2);
    color: var(--text-1);
}

.icon-btn .material-symbols-outlined {
    font-size: 22px;
}

/* ── New Chat Button (ChatGPT-style: transparent, full-width row) ── */
.new-chat-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    background: transparent;
    color: var(--text-1);
    border: none;
    border-radius: 8px;
    padding: 9px 10px;
    font-size: 14px;
    font-weight: 400;
    margin-bottom: 2px;
    width: 100%;
    transition: background var(--transition);
    white-space: nowrap;
    overflow: hidden;
}

.new-chat-btn:hover {
    background: var(--sidebar-hover);
}

.new-chat-btn .material-symbols-outlined {
    font-size: 20px;
    flex-shrink: 0;
    color: var(--text-1);
}

.prompt-gen-item {
    background: transparent;
}

.prompt-gen-item:hover {
    background: var(--sidebar-hover);
}

/* ── Section Label (ChatGPT: tiny muted, no uppercase) ──── */
.section-label {
    font-size: 12px;
    font-weight: 400;
    color: var(--text-3);
    padding: 14px 10px 4px;
    letter-spacing: 0;
}

/* ── Recent Chats ───────────────────────────────────────── */
.recent-chats-section {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}

.recent-chats-section::-webkit-scrollbar {
    width: 4px;
}

.recent-chats-section::-webkit-scrollbar-thumb {
    background: var(--surface-2);
    border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-3);
}

.chat-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 8px;
    color: var(--text-1);
    font-size: 14px;
    transition: background var(--transition);
    cursor: pointer;
    position: relative;
}

.chat-item:hover,
.chat-item.active {
    background: var(--sidebar-hover);
}

/* Prompt-gen mode indicator icon in sidebar */
.chat-mode-icon {
    font-size: 13px !important;
    color: var(--text-3);
    flex-shrink: 0;
}

.chat-item .material-symbols-outlined {
    font-size: 18px;
    color: var(--text-2);
    flex-shrink: 0;
}

.chat-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.chat-timestamp {
    font-size: 13px;
    font-weight: 400;
    color: var(--text-3);
    margin-left: auto;
    flex-shrink: 0;
    white-space: nowrap;
}

.chat-options-btn {
    opacity: 0;
    background: transparent;
    border: none;
    color: var(--text-2);
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    flex-shrink: 0;
    transition: opacity var(--transition), background var(--transition);
}

.chat-item:hover .chat-options-btn,
.chat-item.active .chat-options-btn {
    opacity: 1;
}

@media (max-width: 768px) {
    .chat-options-btn {
        opacity: 1;
    }
}

.chat-options-btn:hover {
    background: var(--surface-2);
}

.chat-pinned-icon {
    font-size: 16px;
    margin-left: 4px;
    color: var(--text-2);
    display: inline-flex;
    vertical-align: middle;
}

/* Dropdown (Premium Floating UI) */
.chat-options-dropdown {
    position: fixed;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.25);
    z-index: 1000;
    width: 200px;
    display: none;
    flex-direction: column;
    padding: 6px;
    overflow: hidden;
    animation: fadeIn 0.15s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.98);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.chat-options-dropdown.show {
    display: flex;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    color: var(--text-1);
    font-size: 14px;
    border-radius: var(--radius-md);
    transition: background var(--transition);
}

.dropdown-item:hover {
    background: var(--surface);
}

.dropdown-item.danger-text {
    color: #ef4444;
}

.dropdown-item.danger-text .material-symbols-outlined {
    color: #ef4444;
}

.dropdown-item .material-symbols-outlined {
    font-size: 18px;
    color: var(--text-2);
}

/* ── Sidebar Footer ─────────────────────────────────────── */
.sidebar-footer-settings {
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    position: relative;
    flex-shrink: 0;
}

.settings-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    background: none;
    border: none;
    color: var(--text-2);
    padding: 9px 10px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 400;
    transition: background var(--transition), color var(--transition);
}

.settings-btn:hover {
    background: var(--sidebar-hover);
    color: var(--text-1);
}

.settings-btn .material-symbols-outlined {
    font-size: 20px;
}

/* ── Settings Desktop Popover ───────────────────────────── */
.settings-popover {
    display: none;
    /* hidden by default; shown by JS on desktop only */
    position: absolute;
    bottom: calc(100% + 8px);
    /* float above the settings button */
    left: 8px;
    right: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22), 0 2px 8px rgba(0, 0, 0, 0.10);
    z-index: 500;
    padding: 6px;
    overflow: hidden;
    animation: popoverIn 0.15s ease-out;
}

@keyframes popoverIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.settings-popover.open {
    display: block;
}

.settings-popover-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    background: none;
    border: none;
    color: var(--text-1);
    font-size: 14px;
    font-family: var(--font);
    padding: 10px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
    text-align: left;
}

.settings-popover-item:hover {
    background: var(--surface-2);
}

.settings-popover-item .material-symbols-outlined {
    font-size: 20px;
    color: var(--text-2);
    flex-shrink: 0;
}

.settings-popover-label {
    flex: 1;
}

.settings-popover-arrow {
    font-size: 18px !important;
    color: var(--text-3) !important;
}

/* ── Theme Sub-Popover (desktop) ────────────────────────── */
.theme-sub-popover {
    min-width: 200px;
}

.theme-sub-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 8px 4px 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.theme-sub-back {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-2);
    cursor: pointer;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    padding: 0;
    transition: background var(--transition), color var(--transition);
    flex-shrink: 0;
}

.theme-sub-back:hover {
    background: var(--surface-2);
    color: var(--text-1);
}

.theme-sub-back .material-symbols-outlined {
    font-size: 18px !important;
}

/* Active theme checkmark in desktop popover */
.theme-check {
    font-size: 18px !important;
    color: var(--accent) !important;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.theme-choice-btn.active-theme .theme-check {
    opacity: 1;
}

/* On mobile: hide popover entirely (use bottom-sheet instead) */
@media (max-width: 768px) {
    .settings-popover {
        display: none !important;
    }
}

.bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--surface);
    border-radius: 24px 24px 0 0;
    padding: 8px 0 24px 0;
    z-index: 1000;
    transform: translateY(100%);
    /* Hidden down by default */
    transition: transform var(--transition) cubic-bezier(0.4, 0.0, 0.2, 1);
    box-shadow: 0px -4px 24px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
}

.bottom-sheet.active {
    transform: translateY(0);
    /* Slide up */
}

.sheet-header {
    padding: 16px 24px;
}

.sheet-header h3 {
    font-weight: 500;
    font-size: 20px;
    color: var(--text-1);
}

.sheet-menu {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sheet-menu li {
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 16px;
    color: var(--text-1);
    cursor: pointer;
    transition: background var(--transition);
}

.sheet-menu li:hover,
.sheet-menu li:active {
    background: var(--surface-2);
}

.sheet-menu li .material-symbols-outlined {
    color: var(--text-2);
}

/* Specific styles for items with arrows (Like Theme button) */
.sheet-menu li.has-arrow {
    justify-content: space-between;
}

/* Styles for Theme Selection items */
.theme-options {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.theme-options li {
    justify-content: space-between;
    padding: 14px 24px;
}

.theme-options li.selected {
    background-color: rgba(138, 180, 248, 0.08);
    /* Selection bg */
}

html[data-theme="light"] .theme-options li.selected {
    background-color: rgba(26, 115, 232, 0.08);
}

.checkmark {
    font-variation-settings: 'FILL' 1;
    /* Filled icon */
    color: var(--accent) !important;
    font-size: 20px !important;
}

/* ══════════════════════════════════════════════════════════
   MAIN CHAT INTERFACE
══════════════════════════════════════════════════════════ */
.chat-interface {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
    position: relative;
    background: var(--bg);
}

/* ── Layout Wrapper (Desktop Centering & State Shift) ── */
.chat-layout-wrapper {
    display: flex;
    flex-direction: column;
    width: 100%;
    margin: 0 auto;
    flex: 1;
    position: relative;
    overflow: hidden;
    transition: justify-content 0.3s ease;
}

/* Desktop Only: Centered Empty State */
@media (min-width: 768px) {
    body:not(.chat-active) .chat-layout-wrapper {
        justify-content: center;
        align-items: center;
        height: 100%;
    }

    body:not(.chat-active) .chat-container {
        flex: none;
        width: 100%;
        padding: 0;
        margin: 0;
    }

    body:not(.chat-active) .input-area {
        margin-top: 32px;
        margin-bottom: 32px;
        width: 100%;
        max-width: 800px;
        padding-bottom: 0;
    }

    body.chat-active .input-area {
        margin-top: auto;
    }
}

/* ── Top Bar ─────────────────────────────────────────────── */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    flex-shrink: 0;
    position: relative;
    /* Support absolute centering of title */
    min-height: 56px;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

#topBarBranding {
    display: block;
}

@media (max-width: 768px) {
    body.chat-active #topBarBranding {
        display: none !important;
    }
}

.mobile-menu-btn {
    display: none;
}

.model-name-chip {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 4px;
    background: transparent;
    border-radius: var(--radius-md);
    padding: 6px 12px;
    cursor: pointer;
    transition: background var(--transition);
    user-select: none;
    z-index: 10;
}

.model-name-chip:hover {
    background: var(--surface-2);
}

@media(max-width: 768px) {
    .model-name-chip {
        max-width: calc(100% - 110px);
        justify-content: center;
    }
}

.model-name-text {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 1;
    min-width: 0;
}

.model-arrow {
    font-size: 20px;
    color: var(--text-2);
    flex-shrink: 0;
}

/* ── Chat Container (scroll area) ───────────────────────── */
.chat-container {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* Ensure top-to-bottom flow */
    align-items: stretch; /* Allow messages to span full width where possible */
    padding: 0 20px 20px;
    scroll-behavior: smooth;
    min-height: 0;
    position: relative; /* Critical for offsetTop calculation precision */
}

.chat-container::-webkit-scrollbar {
    width: 6px;
}

.chat-container::-webkit-scrollbar-thumb {
    background: var(--surface-2);
    border-radius: 4px;
}

/* ── Backdrop overlay (mobile sidebar) ─────────────────── */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 199;
    backdrop-filter: blur(1px);
}

.sidebar-backdrop.visible {
    display: block;
}

/* ── Scroll to Bottom FAB (Inside Input Area) ── */
.scroll-to-bottom-btn {
    position: absolute;
    bottom: calc(100% + 15px); /* Position it clearly above the input box */
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow);
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

.scroll-to-bottom-btn.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

@media (min-width: 769px) {
    .scroll-to-bottom-btn.visible {
        transform: translateY(0);
    }
}

.scroll-to-bottom-btn .material-symbols-outlined {
    font-size: 20px;
}

.scroll-to-bottom-btn:hover {
    background: var(--surface-2);
}

/* ══════════════════════════════════════════════════════════
   WELCOME / EMPTY STATE
══════════════════════════════════════════════════════════ */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    max-width: 100%;
    width: 100%;
    padding: 0 24px;
    flex: 1;
    margin: auto;
}

/* Hide welcome screen and pills once chat starts */
body.chat-active .welcome-screen,
body.chat-active .suggestion-pills-container {
    display: none !important;
}

/* Hide messages when chat is empty */
body:not(.chat-active) #chatContainer .messages-list {
    display: none;
}

/* Suggestion Pills Container */
.suggestion-pills-container {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    width: 100%;
    max-width: 900px;
    margin: 24px auto !important;
    padding: 0 16px;
    z-index: 10;
}

@media (max-width: 767px) {
    /* Fix: Reorder Mobile Layout Elements (Greeting -> Pills -> Input) and anchor Input to bottom */
    body:not(.chat-active) .chat-layout-wrapper {
        display: flex;
        flex-direction: column;
        height: 100dvh;
    }
    body:not(.chat-active) .chat-container {
        order: 1;
        flex: none;
        margin-top: auto;
    }
    body:not(.chat-active) .welcome-screen {
        margin-top: 0;
        padding-bottom: 0;
    }
    body:not(.chat-active) .suggestion-pills-container {
        order: 2;
        gap: 8px;
        margin-top: 0 !important;
        margin-bottom: 4px !important;
    }
    body:not(.chat-active) .input-area {
        order: 3;
        margin-bottom: 0;
    }
}

.greeting-title {
    font-size: 32px;
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 8px;
    color: var(--text-1);
    letter-spacing: -0.02em;
}

html[data-theme="light"] .greeting-title {
    color: #0d0d0d;
}

.greeting-subtitle {
    font-size: 28px;
    font-weight: 500;
    color: var(--text-2);
    line-height: 1.2;
    margin-bottom: 0;
}

/* ── Suggestion Cards (Pill-Style) ──────────────────── */
.suggestion-card {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 50px; /* Force pill shape */
    padding: 10px 20px;
    font-size: 14px;
    font-family: var(--font);
    font-weight: 500;
    color: var(--text-1);
    text-align: left;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.2, 0, 0, 1);
    line-height: 1.4;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    white-space: nowrap;
}

html[data-theme="light"] .suggestion-card {
    background: #ffffff;
    border: 1px solid #e5e5e5;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.suggestion-card:hover {
    background: var(--surface-2);
    border-color: var(--brand-green);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

html[data-theme="light"] .suggestion-card:hover {
    background: #f8f9fa;
    border-color: #bbf7d0;
}

.suggestion-card:active {
    transform: translateY(0) scale(0.98);
}

.suggestion-card .material-symbols-outlined {
    font-size: 18px;
    color: var(--brand-green);
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .suggestion-card {
        padding: 8px 16px;
        font-size: 13px;
    }
    .suggestion-card .material-symbols-outlined {
        font-size: 16px;
    }
}

/* Empty/Active state toggles handled above */


/* ══════════════════════════════════════════════════════════
   MESSAGES
══════════════════════════════════════════════════════════ */
.messages-list {
    max-width: 800px;
    width: 100%;
    margin: 0 auto !important;
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* Match container */
    gap: 24px;
    padding-top: 12px;
    padding-bottom: 20px;
}

.messages-list:empty {
    padding: 0;
    margin: 0;
}

.message {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* User message — right side bubble */
.message.user {
    align-items: flex-end;
    flex-direction: column;
    justify-content: flex-end;
    gap: 4px;
}

/* Desktop: keep column layout so actions stay under the bubble, not split to far right */

.message.user .message-content {
    background: var(--user-bubble);
    border-radius: 16px;
    padding: 12px 18px;
    max-width: 70%;
    font-size: 16px;
    color: var(--text-1);
    position: relative;
    word-break: break-word;
    font-weight: 400;
    line-height: 1.6;
}

.message.user .message-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 4px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    /* Stay width-constrained to match the bubble (max 70%) */
    max-width: 70%;
}

.message.user.show-actions .message-actions {
    opacity: 1;
    pointer-events: auto;
}

/* AI message — left aligned, flat (no bubble) */
.message.ai {
    align-items: flex-start;
    justify-content: flex-start;
    text-align: left;
    padding-left: 16px;
}

.message.ai .message-content {
    background: transparent;
    padding: 0;
    max-width: 100%;
    font-size: 16px;
    line-height: 1.75;
    color: var(--text-1);
    font-weight: 400;
}

/* Markdown inside AI messages */
.message.ai .message-content h1,
.message.ai .message-content h2,
.message.ai .message-content h3 {
    margin: 16px 0 8px;
    font-weight: 600;
    line-height: 1.3;
}

.message.ai .message-content h1 {
    font-size: 22px;
}

.message.ai .message-content h2 {
    font-size: 18px;
}

.message.ai .message-content h3 {
    font-size: 16px;
}

.message.ai .message-content p {
    margin-bottom: 10px;
}

.message.ai .message-content ul,
.message.ai .message-content ol {
    padding-left: 22px;
    margin-bottom: 10px;
}

.message.ai .message-content li {
    margin-bottom: 4px;
}

.message.ai .message-content strong {
    font-weight: 600;
}

.message.ai .message-content em {
    font-style: italic;
}

.code-block {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin: 12px 0;
}

.code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}

.lang-tag {
    font-size: 12px;
    font-family: var(--font);
    font-weight: 500;
    color: var(--text-2);
    text-transform: uppercase;
}

.copy-code-btn {
    background: none;
    border: none;
    color: var(--text-2);
    font-size: 12px;
    font-family: var(--font);
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: color var(--transition);
}

.copy-code-btn:hover {
    color: var(--text-1);
}

.message.ai .message-content pre {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 14px 16px;
    overflow-x: auto;
    margin: 0;
    font-size: 13px;
}

.message.ai .message-content code {
    background: var(--surface);
    border-radius: 6px;
    padding: 2px 6px;
    font-size: 13px;
    font-family: 'Fira Code', 'Courier New', monospace;
}

.message.ai .message-content pre code {
    background: none;
    padding: 0;
}

.message.ai .message-content blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 16px;
    color: var(--text-2);
    margin: 10px 0;
}

.message.ai .message-content a {
    color: var(--accent);
}

.message.ai .message-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 12px 0;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: 0 0 0 1px var(--border);
}

.message.ai .message-content th,
.message.ai .message-content td {
    padding: 10px 14px;
    text-align: left;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}

.message.ai .message-content th {
    background: var(--surface-2);
    font-weight: 600;
}

.message.ai .message-content tr:last-child td {
    border-bottom: none;
}

.message.ai .message-content tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

html[data-theme="light"] .message.ai .message-content tr:nth-child(even) {
    background: #f8f9fa;
}

/* ── Message Action Row ─────────────────────────────────── */
.message-actions {
    display: flex;
    flex-direction: row;
    gap: 12px;
    margin-top: 8px;
    opacity: 0;
    transition: opacity var(--transition);
    position: relative;
    /* Keep above content overlaps */
    z-index: 10;
}

.message.ai:hover .message-actions,
.message.user:hover .message-actions,
.message.show-actions .message-actions {
    opacity: 1;
}

.action-btn {
    background: transparent;
    border: none;
    color: var(--text-2);
    cursor: pointer;
    pointer-events: auto;
    padding: 10px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition), background var(--transition);
    min-width: 44px;
    min-height: 44px;
}

.action-btn:hover {
    background: var(--surface-2);
    color: var(--text-1);
}

.message.user .action-btn:hover {
    color: var(--brand-green);
}

.action-btn .material-symbols-outlined {
    font-size: 18px;
}

.action-btn.tts-active {
    color: var(--brand-green);
    background: rgba(16, 163, 127, 0.1);
    animation: tts-pulse 1.5s infinite ease-in-out;
}

@keyframes tts-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 163, 127, 0.4);
    }

    70% {
        box-shadow: 0 0 0 8px rgba(16, 163, 127, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(16, 163, 127, 0);
    }
}

.action-btn.active.like-btn {
    background: transparent;
}
.action-btn.active.like-btn .material-symbols-outlined {
    font-variation-settings: 'FILL' 1;
    color: #10a37f;
}

.action-btn.active.dislike-btn {
    background: transparent;
}
.action-btn.active.dislike-btn .material-symbols-outlined {
    font-variation-settings: 'FILL' 1;
    color: #ef4444;
}

/* ── User Message Edit Inline ─────────────────────────────── */
.message-content.editing {
    outline: none;
    border: 1px solid var(--brand-green);
    box-shadow: 0 0 0 1px var(--brand-green);
    background: var(--input-bg);
    color: var(--text-1);
    border-radius: var(--radius-lg);
    padding: 12px 16px !important;
    min-width: 100px;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.6;
    white-space: pre-wrap;
    resize: none;
    overflow-y: hidden;
}

.user-edit-textarea {
    width: 100%;
    min-height: 96px;
    background: transparent;
    border: none;
    color: var(--text-1);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.6;
    resize: none;
    outline: none;
    overflow: hidden;
}

.inline-edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}

.inline-edit-send {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--surface-2);
    color: var(--text-2);
    border: none;
    border-radius: 20px;
    padding: 8px 18px;
    font-size: 14px;
    transition: background var(--transition), color var(--transition);
    cursor: default;
}

.inline-edit-send.active {
    background: var(--brand-green);
    color: #ffffff;
    cursor: pointer;
}

.inline-edit-send.active:hover {
    background: #0d8a6a;
}

.inline-edit-cancel {
    background: transparent;
    color: var(--brand-green);
    border: none;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 14px;
    transition: background var(--transition);
    cursor: pointer;
}

.inline-edit-cancel:hover {
    background: var(--chip-hover);
}

/* ── Dynamic Text Streaming Loader ────────────────────────── */
.dynamic-loader {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 2px 4px;
}

.dynamic-loader .dot {
    width: 10px;
    height: 10px;
    background: var(--brand-green);
    border-radius: 50%;
    animation: pulse 1s infinite alternate ease-in-out;
}

.dynamic-loader .text {
    font-size: 14px;
    color: var(--text-2);
    font-weight: 500;
}

@keyframes pulse {
    0% {
        transform: scale(0.8);
        opacity: 0.6;
    }

    100% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* ══════════════════════════════════════════════════════════
   RELATED POSTS (AI RESPONSE)
══════════════════════════════════════════════════════════ */
.related-posts-block {
    margin-top: 16px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    max-width: 100%;
}

.related-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.related-action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--surface-2);
    border: none;
    color: var(--text-2);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    transition: background var(--transition), color var(--transition);
}

.related-action-btn:hover {
    background: var(--chip-hover);
    color: var(--text-1);
}

.related-action-btn .material-symbols-outlined {
    font-size: 18px;
}

.related-posts-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.related-posts-header .material-symbols-outlined {
    font-size: 18px;
    color: var(--brand-green);
}

.related-posts-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.related-post-link {
    display: block;
    color: var(--text-1);
    font-size: 14px;
    text-decoration: none;
    line-height: 1.4;
    padding: 8px 12px;
    background: var(--surface-2);
    border-radius: var(--radius-md);
    transition: background var(--transition), color var(--transition), transform 0.15s ease;
}

.related-post-link:hover {
    background: var(--border);
    color: var(--brand-green);
    transform: translateX(4px);
}

/* ══════════════════════════════════════════════════════════
   INPUT AREA (fixed bottom)
══════════════════════════════════════════════════════════ */
.input-area {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 20px env(safe-area-inset-bottom, 14px);
    background: var(--bg);
    width: 100%;
    gap: 8px;
    position: sticky;
    bottom: 0;
    z-index: 50;
}

/* ── Suggestion Chips — hidden by default ─────────────── */
.suggestion-chips {
    display: none;
}

.chip {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--chip-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    color: var(--text-1);
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    transition: background var(--transition), border-color var(--transition), transform 0.15s;
    cursor: pointer;
    white-space: nowrap;
}

.chip:hover {
    background: var(--chip-hover);
    border-color: var(--text-3);
    transform: translateY(-1px);
}

.chip .material-symbols-outlined {
    font-size: 16px;
    color: var(--text-2);
}



/* ── Input Wrapper ─────────────────────────────────────── */
.input-wrapper {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    width: 100%;
    max-width: 800px;
    margin: 0 auto 20px;
    min-height: 120px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    transition: border-color var(--transition), box-shadow var(--transition);
    position: relative;
    z-index: 60;
}

html[data-theme="light"] .input-wrapper {
    background: #ffffff;
    border: 1px solid #e5e5e5;
}

.input-wrapper:focus-within {
    border-color: #bbf7d0;
    box-shadow: 0 0 0 1px #bbf7d0, 0 4px 12px rgba(0, 0, 0, 0.05);
}

.input-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-top: auto;
    gap: 8px;
    /* minimum 8px gap between Mic and Send to prevent fat-finger misclicks */
    margin-bottom: 2px;
    position: relative;
    z-index: 110;
}

/* ── Model Selector Pill Button ── */
.model-selector-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: none;
    color: var(--text-2);
    border-radius: var(--radius-pill);
    padding: 6px 10px;
    font-size: 14px;
    font-family: var(--font);
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
    white-space: nowrap;
}

.model-selector-btn:hover {
    background: var(--surface-2);
    color: var(--text-1);
}

.model-selector-btn .dropdown-icon {
    font-size: 18px;
    color: inherit;
}

/* ── Model Selection Float Menu ── */
.model-selection-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
}
.model-selection-overlay.show {
    display: block;
}

.model-selection-menu {
    position: fixed;
    bottom: 90px;
    right: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    z-index: 1001;
    width: 240px;
    padding: 8px 0;
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px) scale(0.98);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.model-selection-menu.show {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

@media (max-width: 768px) {
    .model-selection-menu {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        border-radius: 24px 24px 0 0;
        transform: translateY(100%);
        padding: 8px 0 24px 0;
    }
    .model-selection-menu.show {
        transform: translateY(0);
    }
    .model-selection-overlay {
        background: rgba(0, 0, 0, 0.45);
        backdrop-filter: blur(1px);
    }
}

.model-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 12px 20px;
    background: none;
    border: none;
    color: var(--text-1);
    font-size: 15px;
    font-family: var(--font);
    cursor: pointer;
    transition: background var(--transition);
    text-align: left;
}

.model-option:hover {
    background: var(--surface-2);
}

.model-option .left-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.model-option .left-content .material-symbols-outlined {
    font-size: 20px;
    color: var(--text-2);
}
.model-option .checkmark {
    color: var(--brand-green);
    font-size: 20px;
    font-variation-settings: 'FILL' 1;
}


/* Textarea */
#userInput {
    flex-grow: 1;
    background: transparent;
    border: none;
    color: var(--text-1);
    font-size: 15px;
    font-family: var(--font);
    resize: none;
    outline: none;
    max-height: 200px;
    overflow-y: auto;
    line-height: 1.6;
    align-self: stretch;
    padding-right: 0;
    margin-bottom: 12px;
}

#userInput:focus {
    outline: none;
}

#userInput::placeholder {
    color: var(--text-3);
}

/* Mic Button — 44×44px minimum touch target (WCAG 2.5.8) */
.mic-btn {
    background: transparent;
    border: none;
    color: var(--text-2);
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color var(--transition), background var(--transition);
    cursor: pointer;
}

.mic-btn:hover {
    color: var(--text-1);
}

.mic-btn.listening {
    color: var(--brand-green);
    animation: mic-pulse 1.2s infinite ease-in-out;
}

.mic-btn.paused {
    color: var(--text-3);
    animation: none;
}

@keyframes mic-pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.15);
        opacity: 0.7;
    }
}

/* Send Button — Green theme, medium 38×38px touch target */
.send-btn {
    background: var(--surface-2);
    border: none;
    color: var(--text-3);
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition);
    position: relative;
    z-index: 120;
    pointer-events: auto !important;
    cursor: pointer;
}

html[data-theme="light"] .send-btn {
    background: #e5e5e5;
    color: #999;
}

.send-btn.active {
    background: var(--brand-green);
    color: #ffffff;
}

.send-btn:disabled {
    cursor: not-allowed;
    opacity: 0.45;
    background: var(--surface-2);
    color: var(--text-3);
}

/* Stop Generation - Extreme Specificity */
.input-area .send-btn.active.stopping {
    background: var(--brand-green) !important;
    color: #ffffff !important;
    border: none !important;
    transition: background 0.3s ease, color 0.3s ease;
}

html[data-theme="light"] .send-btn.active {
    background: var(--brand-green);
    color: #ffffff;
}

html[data-theme="light"] .send-btn:disabled {
    background: #e5e5e5;
    color: #bbb;
}

html[data-theme="light"] .input-area .send-btn.active.stopping,
html[data-theme="dark"] .input-area .send-btn.active.stopping {
    background: var(--brand-green) !important;
    color: #ffffff !important;
    border: none !important;
}

.send-btn .material-symbols-outlined {
    font-size: 18px;
    font-weight: 600;
}

/* ── Action More Menu (3-dot dropdown) ───────────────────── */
.action-more-menu {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0,0,0,0.28);
    z-index: 200;
    flex-direction: column;
    min-width: 160px;
    padding: 6px;
    animation: fadeIn 0.15s ease;
}

.action-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: none;
    background: transparent;
    color: var(--text-1);
    font-family: var(--font);
    font-size: 14px;
    border-radius: 8px;
    cursor: pointer;
    width: 100%;
    text-align: left;
    transition: background var(--transition);
}

.action-menu-item:hover {
    background: var(--surface-2);
}

.action-menu-item .material-symbols-outlined {
    font-size: 18px;
    color: var(--text-2);
}

/* ── Input Disclaimer ───────────────────────────────────── */
.input-disclaimer {
    font-size: 12px;
    color: var(--text-3);
    text-align: center;
    max-width: 750px;
    width: 100%;
    margin-top: 8px;
}

.hidden-desktop {
    display: none !important;
}

/* ══════════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════════ */
@media(max-width: 768px) {
    .mobile-help-divider,
    .mobile-help-menu {
        display: none !important;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100dvh;
        z-index: 200;
        /* Use transform for smooth GPU-accelerated slide */
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
        /* Keep width fixed on mobile — no collapse */
        width: var(--sidebar-w) !important;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .top-bar {
        position: relative;
    }

    .mobile-menu-btn {
        display: flex !important;
    }

    .hidden-desktop {
        display: flex !important;
    }

    .model-name-chip {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        max-width: calc(100% - 90px);
        justify-content: center;
    }

    .edit-btn-mobile {
        display: flex !important;
    }

    .model-name-text {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .input-area {
        padding: 0 8px calc(env(safe-area-inset-bottom, 12px) + 20px);
    }

    .input-wrapper {
        border-radius: 20px;
    }

    .chat-options-btn {
        opacity: 1;
    }

    .user-msg-options-btn {
        display: none !important;
    }

    .edit-btn-mobile {
        display: flex;
    }

    /* User message: column layout on mobile (bubble above, actions below) */
    .message.user {
        align-items: flex-end;
        flex-direction: column;
        gap: 2px;
    }

    .message.user .message-content {
        max-width: 82%;
    }

    .message.user .message-actions {
        opacity: 1;
        pointer-events: auto;
        width: 100%;
        justify-content: flex-end;
        padding-right: 4px;
    }

    .message.user .action-btn {
        min-width: 36px;
        min-height: 36px;
        padding: 8px;
    }

    /* Compact send button on mobile */
    .send-btn {
        width: 34px;
        height: 34px;
    }

    .send-btn .material-symbols-outlined {
        font-size: 16px;
    }
}

/* ── Footer / Disclaimer ────────────────────────────────── */
.footer-text {
    font-size: 10px;
    letter-spacing: 0.2px;
    color: var(--text-3);
    text-align: center;
    max-width: 750px;
    width: 100%;
    margin-top: 8px;
}

.edit-btn-mobile {
    display: none;
}

/* ══════════════════════════════════════════════════════════
   UTILITY / MISC
══════════════════════════════════════════════════════════ */
/* Sidebar collapsed: icons-only mode */
.sidebar.collapsed .sidebar-menu-btn {
    margin: 0 auto;
}

.sidebar.collapsed .new-chat-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    padding: 0;
}

/* Tech greeting gradient override for light mode */
.tech-greeting {
    background: linear-gradient(90deg, #4285f4, #9b72cb, #d96570);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

html[data-theme="light"] .tech-greeting {
    background: linear-gradient(90deg, #0d6efd, #0dcaf0);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Mobile: show always-visible options btn */
@media(max-width: 768px) {
    .message-actions {
        opacity: 1;
    }

    .hidden-mobile {
        display: none !important;
    }
}

/* ── DOM Virtualizer Lock ── */
.generating-active {
    min-height: 100px;
    position: relative;
}

/* Scrollbar global */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--surface-2);
    border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-3);
}

/* ── Bottom Sheet Menu ──────────────────────────────────── */
.bottom-sheet-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    pointer-events: none;
    z-index: 999;
    transition: opacity 0.3s ease;
}

.bottom-sheet-overlay.visible {
    opacity: 1;
    pointer-events: auto;
    z-index: 9999;
}

.bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100vw;
    background: var(--surface);
    border-radius: 24px 24px 0 0;
    padding: 24px 16px 32px 16px;
    z-index: 10000;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);
}

.bottom-sheet.open {
    transform: translateY(0);
}

.bottom-sheet.open {
    transform: translateY(0);
}

.bottom-sheet-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 24px;
    background: transparent;
    border: none;
    color: var(--text-1);
    font-size: 16px;
    text-align: left;
    width: 100%;
    transition: background-color 0.2s;
    border-radius: 0;
    cursor: pointer;
}

.bottom-sheet-item:hover {
    background-color: var(--chip-hover);
}

.bottom-sheet-item.danger {
    color: #ff6b6b;
}

.bottom-sheet-item.danger .material-symbols-outlined {
    color: #ff6b6b;
}

.bottom-sheet-item .material-symbols-outlined {
    color: var(--text-2);
    font-size: 24px;
}

/* ── Mobile Search Overlay ──────────────────────────────── */
.mobile-search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100dvh;
    background: var(--bg);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.mobile-search-overlay.open {
    transform: translateY(0);
}

.mobile-search-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.mobile-search-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-1);
    font-size: 16px;
    outline: none;
}

.mobile-search-input::placeholder {
    color: var(--text-3);
}

.mobile-search-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* Sidebar Backdrop Overlay */
.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    pointer-events: none;
    z-index: 150;
    transition: opacity 0.3s ease;
}

.sidebar-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
}

/* ───────────────────────────────────────────────────────── */
/* ── ADVANCED MARKDOWN FORMATTING (TABLES, QUOTES, LISTS) ─ */
/* ───────────────────────────────────────────────────────── */

.message-content table {
    width: 100%;
    margin: 16px 0;
    border-collapse: collapse;
    font-size: 14px;
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    border: 1px solid #333537;
    border-radius: 8px;
    background: var(--surface);
}

.message-content table th,
.message-content table td {
    padding: 12px 16px;
    border: 1px solid var(--border);
    text-align: left;
}

.message-content table th {
    background: var(--surface-2);
    font-weight: 600;
    color: var(--text-1);
    border-top: none;
}

.message-content table tr:nth-child(even) {
    background: rgba(128, 128, 128, 0.06);
}

.message-content table tr:hover {
    background: var(--surface-2);
}

.message-content blockquote {
    border-left: 4px solid var(--brand-green);
    margin: 16px 0;
    padding: 8px 16px;
    background: rgba(16, 163, 127, 0.05);
    border-radius: 0 8px 8px 0;
    color: #b0b0b0;
    font-style: italic;
}

.message-content ul,
.message-content ol {
    margin: 12px 0 12px 24px;
    padding: 0;
}

.message-content li {
    margin-bottom: 6px;
}

.message-content li:last-child {
    margin-bottom: 0;
}



/* ══════════════════════════════════════════════════════════
   INLINE EDIT UI MATCH & SCROLL FAB (PHASE 8)
══════════════════════════════════════════════════════════ */


/* Scroll-to-Bottom FAB */
.scroll-to-bottom-btn {
    position: absolute;
    bottom: 115px;
    /* Positioned comfortably above the input area dock */
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--surface);
    color: var(--text-1);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 100;
}

.scroll-to-bottom-btn.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

.scroll-to-bottom-btn:active {
    transform: translateX(-50%) scale(0.9);
}

/* ══════════════════════════════════════════════════════════
   INLINE MODAL (replaces ugly browser prompt/confirm)
══════════════════════════════════════════════════════════ */
.inline-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: modalFadeIn 0.18s ease;
    padding: 24px;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.inline-modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 24px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    animation: modalSlideUp 0.2s ease;
}

@keyframes modalSlideUp {
    from { opacity: 0; transform: translateY(12px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.inline-modal-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-1);
    margin-bottom: 16px;
    line-height: 1.3;
}

.inline-modal-message {
    font-size: 14px;
    color: var(--text-2);
    margin-bottom: 20px;
    line-height: 1.6;
}

.inline-modal-input {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-1);
    font-family: var(--font);
    font-size: 15px;
    padding: 12px 14px;
    outline: none;
    margin-bottom: 20px;
    transition: border-color 0.2s;
}

.inline-modal-input:focus {
    border-color: var(--brand-green);
    box-shadow: 0 0 0 1px var(--brand-green);
}

.inline-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.inline-modal-btn {
    padding: 10px 20px;
    border-radius: 24px;
    border: none;
    font-size: 14px;
    font-family: var(--font);
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition), opacity var(--transition);
}

.inline-modal-btn.cancel {
    background: var(--surface-2);
    color: var(--text-1);
}

.inline-modal-btn.cancel:hover {
    background: var(--chip-hover);
}

.inline-modal-btn.confirm {
    background: var(--brand-green);
    color: #ffffff;
}

.inline-modal-btn.confirm:hover {
    opacity: 0.88;
}

.inline-modal-btn.confirm.danger {
    background: #ef4444;
    color: #ffffff;
}

.inline-modal-btn.confirm.danger:hover {
    background: #dc2626;
}

/* ══════════════════════════════════════════════════════════
   PREMIUM ARTICLE CARDS (Zero-Cost Rich Cards)
══════════════════════════════════════════════════════════ */
.related-posts-block {
    margin: 14px 0 6px 0;
    animation: rpSlideIn 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes rpSlideIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Cards Container: vertical stack on mobile, horizontal scroll on wider ── */
.article-cards-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

@media (min-width: 769px) {
    .article-cards-container {
        flex-direction: row;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }
    .article-cards-container::-webkit-scrollbar {
        height: 4px;
    }
    .article-cards-container::-webkit-scrollbar-track {
        background: transparent;
    }
    .article-cards-container::-webkit-scrollbar-thumb {
        background: rgba(128, 128, 128, 0.3);
        border-radius: 4px;
    }
}

/* ── Individual Card ─────────────────────────────────────── */
.article-card {
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
    text-decoration: none;
    color: inherit;
    overflow: hidden;
    transition: transform 0.25s cubic-bezier(0.2, 0, 0, 1),
                box-shadow 0.25s ease;
    cursor: pointer;
    min-width: 0;
    flex-shrink: 0;
}

@media (min-width: 769px) {
    .article-card {
        width: 220px;
        min-width: 220px;
        scroll-snap-align: start;
    }
}

.article-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.13);
}

.article-card:active {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.10);
}

/* ── Card Image ──────────────────────────────────────────── */
.article-card-img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 10px 10px 0 0;
    display: block;
    background: linear-gradient(135deg, #e2e8f0, #f1f5f9);
}

/* ── Card Body (title + description) ─────────────────────── */
.article-card-body {
    padding: 12px 14px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* ── Card Title ──────────────────────────────────────────── */
.article-card-title {
    font-family: var(--font);
    font-size: 14.5px;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.35;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── Card Description ────────────────────────────────────── */
.article-card-desc {
    font-family: var(--font);
    font-size: 13px;
    color: #475569;
    line-height: 1.45;
    margin: 0;
    /* Ensure CSS permits full description visibility */
    display: block;
}

/* ── Dark Mode Overrides ─────────────────────────────────── */
[data-theme="dark"] .article-card {
    background: #1e293b;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
}

[data-theme="dark"] .article-card:hover {
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
}

[data-theme="dark"] .article-card-img {
    background: linear-gradient(135deg, #334155, #1e293b);
}

[data-theme="dark"] .article-card-title {
    color: #f1f5f9;
}

[data-theme="dark"] .article-card-desc {
    color: #94a3b8;
}

/* ── Mobile: full-width stacked cards ────────────────────── */
@media (max-width: 768px) {
    .article-cards-container {
        flex-direction: column;
        gap: 10px;
    }
    .article-card {
        width: 100%;
    }
    .article-card-img {
        height: 150px;
    }
    .article-card-body {
        padding: 10px 12px 12px;
    }
    .article-card-title {
        font-size: 14px;
    }
    .article-card-desc {
        font-size: 12.5px;
        display: block;
    }
}


/* ── Desktop Chat Options Dropdown ───────────────────────── */
.chat-options-dropdown {
    position: fixed;
    width: 200px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0,0,0,0.28);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    padding: 6px 0;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
}

.chat-options-dropdown.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.chat-options-dropdown .dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: var(--text-1);
    font-size: 14px;
    font-family: var(--font);
    cursor: pointer;
    transition: background 0.2s ease;
    user-select: none;
}

.chat-options-dropdown .dropdown-item:hover {
    background: var(--surface-2);
}

.chat-options-dropdown .dropdown-item .material-symbols-outlined {
    font-size: 18px;
    color: var(--text-2);
}

.chat-options-dropdown .dropdown-item:last-child,
.chat-options-dropdown .dropdown-item:last-child .material-symbols-outlined {
    color: #ff6b6b;
}

/* ══════════════════════════════════════════════════════════
   REPORT MODAL
══════════════════════════════════════════════════════════ */
.report-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.report-modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.report-modal {
    background: var(--surface);
    width: 100%;
    max-width: 480px;
    border-radius: var(--radius-lg);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 85vh;
    transform: translateY(20px) scale(0.98);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.report-modal-overlay.open .report-modal {
    transform: translateY(0) scale(1);
}

.report-header {
    display: flex;
    align-items: flex-start;
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--border);
    position: relative;
    min-height: 56px;
}

.report-title-area {
    flex-grow: 1;
    text-align: center;
    padding: 0 40px;
}

.report-title-area h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-1);
    margin: 0;
    line-height: 1.4;
}

.report-title-area p {
    font-size: 13px;
    color: var(--text-2);
    margin: 4px 0 0;
    line-height: 1.3;
}

.icon-btn.report-back {
    position: absolute;
    left: 12px;
    top: 14px;
    width: 32px;
    height: 32px;
}

.icon-btn.report-close {
    position: absolute;
    right: 12px;
    top: 14px;
    width: 32px;
    height: 32px;
}

.report-body {
    padding: 0;
    overflow-y: auto;
    flex-grow: 1;
}

.report-list {
    display: flex;
    flex-direction: column;
}

.report-list-item {
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--text-1);
    font-size: 15px;
    cursor: pointer;
    transition: background var(--transition);
    text-align: left;
}

.report-list-item:hover {
    background: var(--surface-2);
}

.report-list-item:last-child {
    border-bottom: none;
}

.report-arrow {
    color: var(--text-3);
    font-size: 20px;
}

.report-input-container {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.report-textarea {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    color: var(--text-1);
    font-family: var(--font);
    font-size: 15px;
    resize: vertical;
    outline: none;
    transition: border-color var(--transition);
}

.report-textarea:focus {
    border-color: var(--brand-green);
}

.report-submit-btn {
    background: var(--brand-green);
    color: #fff;
    border: none;
    border-radius: var(--radius-pill);
    padding: 14px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition), transform 0.15s ease;
}

.report-submit-btn:hover {
    background: #0d8a6a;
    transform: translateY(-1px);
}

.report-success {
    padding: 40px 32px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.report-success-icon {
    font-size: 48px;
    color: var(--brand-green);
}

.report-success-msg {
    font-size: 15px;
    color: var(--text-1);
    line-height: 1.6;
}

.report-learn-more {
    color: var(--accent);
    font-size: 14px;
    text-decoration: none;
    margin-top: 8px;
}

.report-learn-more:hover {
    text-decoration: underline;
}

@media (max-width: 768px) {
    .report-modal-overlay {
        align-items: flex-end;
    }
    
    .report-modal {
        margin-top: auto;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        max-width: 100%;
        max-height: 90vh;
        transform: translateY(100%);
        transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    }
    
    .report-list-item {
        padding: 18px 20px;
    }
}

/* ─────────────────────────────────────────────────────────────
   Bug Report Modal & Success Toast
───────────────────────────────────────────────────────────── */
.help-sub-popover {
    min-width: 200px;
}

#bugReportModalOverlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    display: none; /* toggled by JS flex */
}

#bugReportModal {
    background: var(--surface);
    width: 90%;
    max-width: 400px;
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    animation: popoverIn 0.2s ease-out;
}

#bugReportModal .report-header {
    border-bottom: none;
    padding-bottom: 0;
}

#bugReportInput {
    background: var(--surface-2);
    border: 1px solid var(--border);
    margin-top: 10px;
    border-radius: var(--radius-sm);
}

#bugReportInput:focus {
    border-color: var(--text-3);
}

.bug-report-submit-btn {
    background: var(--text-1);
    color: var(--bg);
    border: none;
    border-radius: 20px;
    padding: 8px 20px;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

html[data-theme="light"] .bug-report-submit-btn {
    background: #000;
    color: #fff;
}

html[data-theme="dark"] .bug-report-submit-btn {
    background: #fff;
    color: #000;
}

.bug-report-submit-btn:hover {
    opacity: 0.8;
}

.bug-report-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #10a37f; /* ChatGPT green */
    color: #fff;
    padding: 12px 20px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 3000;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    animation: toastSlideDown 0.3s ease-out, toastFadeOut 0.3s ease-in 2.7s forwards;
    pointer-events: none;
}

@keyframes toastSlideDown {
    from { transform: translate(-50%, -20px); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
}

@keyframes toastFadeOut {
    to { opacity: 0; }
}

/* ══════════════════════════════════════════════════════════
   WELCOME SCREEN & SUGGESTION PILLS
   ══════════════════════════════════════════════════════════ */
.welcome-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
    animation: fadeIn 0.8s ease-out;
    margin-top: -10vh; /* Adjust for vertical centering in wrapper */
}

.greeting-title {
    font-size: 3.5rem;
    font-weight: 800;
    margin-bottom: 12px;
    letter-spacing: -0.03em;
}

.gradient-text {
    background: linear-gradient(90deg, #10A37F, #7eb3f7);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

.greeting-subtitle {
    font-size: 1.6rem;
    color: var(--text-2);
    margin-bottom: 48px;
    font-weight: 400;
    max-width: 600px;
}

.suggestion-pills-container {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    justify-content: center;
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px 60px;
}

.suggestion-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 30px;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-1);
    font-size: 15px;
    transition: all 0.25s cubic-bezier(0.2, 0, 0, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    font-weight: 500;
}

.suggestion-card:hover {
    background: var(--surface-2);
    border-color: var(--brand-green);
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 8px 20px rgba(16, 163, 127, 0.15);
}

.suggestion-card .material-symbols-outlined {
    font-size: 22px;
    color: var(--brand-green);
}

/* Hide welcome elements when chat starts */
.chat-interface.chat-started .welcome-screen,
.chat-interface.chat-started .suggestion-pills-container {
    display: none !important;
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    .greeting-title {
        font-size: 2.5rem;
    }
    .greeting-subtitle {
        font-size: 1.2rem;
        margin-bottom: 15px;
    }
    .suggestion-pills-container {
        gap: 10px;
        padding-bottom: 40px;
    }
    .suggestion-card {
        padding: 10px 18px;
        font-size: 13px;
    }
}