/* === Reset & Base === */
:root {
    --primary-color: #702f70;
    --primary-hover: #8f3950;
    --bg-color: #f9f9f9;
    --sidebar-width: 280px;
    --text-color: #333;
    --border-color: #e5e5e5;
    --card-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    height: 100vh;
    display: flex;
    overflow: hidden; /* Prevent body scroll, handle inside containers */
}

/* === Sidebar === */
.sidebar {
    width: var(--sidebar-width);
    background: white;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: transform 0.3s ease;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo {
    width: 96px;
    height: 96px;
    border-radius: 10px;
    object-fit: cover;
}

.sidebar-title {
    font-family: 'Playfair Display', serif;
    font-weight: 600;
    font-size: 1.2rem;
    color: var(--primary-color);
}

.new-chat-btn {
    margin: 15px 20px;
    padding: 12px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s;
    font-size: 0.95rem;
    box-shadow: var(--card-shadow);
}

.new-chat-btn:hover {
    background: #f5f5f5;
    border-color: #d0d0d0;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 10px 20px;
}

.nav-section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #888;
    margin: 20px 0 10px;
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    color: #555;
    text-decoration: none;
    transition: background 0.2s;
}

.nav-item:hover {
    background: #f0f0f0;
    color: var(--primary-color);
}

/* Sidebar resizer */
.sidebar-resizer {
    width: 6px;
    cursor: col-resize;
    background: transparent;
    border-right: 1px solid var(--border-color);
    transition: background 0.2s, border-color 0.2s;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-resizer::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 3px;
    height: 40px;
    background: #666;
    border-radius: 2px;
    opacity: 0.8;
    transition: opacity 0.2s, background 0.2s;
}

.sidebar-resizer::after {
    content: '⋮⋮';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 10px;
    color: #555;
    letter-spacing: -2px;
    opacity: 0.9;
    transition: opacity 0.2s, color 0.2s;
    pointer-events: none;
}

.sidebar-resizer:hover {
    background: #f1ecf4;
    border-color: #d8cbe2;
}

.sidebar-resizer:hover::before {
    opacity: 1;
    background: var(--primary-color);
}

.sidebar-resizer:hover::after {
    opacity: 1;
    color: var(--primary-color);
}

body.resizing,
body.resizing * {
    user-select: none;
    cursor: col-resize !important;
}

/* Collapsible thread styles */
.history-thread {
    margin-bottom: 8px;
}

.thread-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.expand-toggle {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 4px 6px;
    font-size: 0.75rem;
    transition: transform 0.2s ease, color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

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

.expand-toggle.expanded {
    transform: rotate(90deg);
}

.followup-items {
    margin-left: 20px;
    margin-top: 4px;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.2s ease, margin 0.3s ease;
    max-height: 0;
    opacity: 0;
}

.followup-items.collapsed {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
    margin-bottom: 0;
}

.followup-items.expanded {
    max-height: 2000px;
    opacity: 1;
}

/* Members Preview Styles */
.members-preview {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    padding: 15px;
    margin: 10px 0;
    text-align: center;
}

.members-preview-header {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #702f70;
    font-weight: 600;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.members-preview-content {
    font-size: 0.85rem;
    color: #666;
    line-height: 1.5;
    margin-bottom: 12px;
}

.members-preview-item {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 10px;
    margin: 8px 0;
    text-align: left;
    opacity: 0.7;
    position: relative;
}

.members-preview-item::after {
    content: '🔒';
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 0.9rem;
}

.members-preview-cta {
    margin-top: 12px;
}

.members-preview-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background 0.2s;
    width: 100%;
}

.members-preview-btn:hover {
    background: var(--primary-hover);
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    background: #fcfcfc;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
}

.user-info {
    flex: 1;
    overflow: hidden;
}

.user-name {
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.credit-badge {
    font-size: 0.75rem;
    color: #666;
    display: flex;
    align-items: center;
    gap: 4px;
}

.buy-credits-btn {
    width: 100%;
    padding: 8px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    margin-top: 10px;
}

.buy-credits-btn:hover {
    background: var(--primary-hover);
}

/* === Main Content === */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    background: white;
}

/* === Search Area === */
.search-container {
    max-width: 800px; /* Reset to original max-width */
    width: 100%;
    margin: 0 auto;
    padding: 20px;
    transition: all 0.4s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Center State (Default) */
.search-container.centered {
    height: 100%;
    align-items: center;
    text-align: center;
}

/* Top State (Results) */
.search-container.top {
    height: auto;
    padding: 20px 20px 10px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(10px);
    position: relative;
    top: auto;
    z-index: 50;
    transition: transform 0.3s ease, bottom 0.3s ease;
}

/* Collapsed state - hidden below viewport */
.search-container.top.collapsed {
    transform: translateY(100%);
    bottom: 0;
}

/* Drag handle for query box */
.query-box-drag-handle {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 20px;
    background: white;
    border: 1px solid var(--border-color);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    cursor: ns-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    transition: background 0.2s, border-color 0.2s;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.05);
}

.query-box-drag-handle:hover {
    background: #f8f9fa;
    border-color: var(--primary-color);
}

.query-box-drag-handle::before {
    content: '';
    width: 40px;
    height: 4px;
    background: #ccc;
    border-radius: 2px;
    transition: background 0.2s;
}

.query-box-drag-handle:hover::before {
    background: var(--primary-color);
}

/* Restore button when query box is collapsed */
.query-box-restore-btn {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 20px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    z-index: 1002;
    display: none;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(112, 47, 112, 0.3);
    transition: all 0.2s;
}

.query-box-restore-btn:hover {
    background: var(--primary-hover);
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 6px 16px rgba(112, 47, 112, 0.4);
}

.query-box-restore-btn.visible {
    display: flex;
}

/* Adjust search container when collapsed */
.search-container.top.collapsed ~ .results-scroll-area,
.main-content:has(.search-container.top.collapsed) .results-scroll-area {
    padding-bottom: 20px !important;
}

.brand-large {
    margin-bottom: 40px;
    display: none; /* Hidden by default, shown in centered state */
}

.search-container.centered .brand-large {
    display: block;
}

/* Keep queries-remaining-display visible in top mode for freemium users */
.search-container.top #queries-remaining-display {
    display: flex !important;
    margin-top: 0;
    margin-bottom: 15px;
    justify-content: center;
}

.search-container.top #reset-freemium-btn {
    display: inline-block !important;
    margin-top: 8px;
}

.brand-large h1 {
    font-family: 'Playfair Display', serif;
    font-size: 3rem;
    color: var(--primary-color);
    margin: 0;
}

.brand-large p {
    color: #666;
    font-size: 1.1rem;
    margin-top: 10px;
}

/* === Floating Recommendations Pop-up === */
.floating-recommendations {
    position: fixed;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    width: 320px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    z-index: 1000;
    display: none; /* Shown via JS */
    flex-direction: column;
    max-height: 80vh;
    overflow: hidden;
}

.floating-recommendations.visible {
    display: flex;
}

.close-recommendations {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.05);
    border: none;
    font-size: 1.5rem;
    color: #666;
    cursor: pointer;
    line-height: 1;
    z-index: 11;
    padding: 6px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.close-recommendations:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #333;
    transform: scale(1.1);
}

.close-recommendations:active {
    transform: scale(0.95);
}

.recommendations-header {
    padding: 15px 40px 10px 15px;
    border-bottom: 1px solid #f0f0f0;
    background: #fcfcfc;
}

.recommendations-title {
    font-family: 'Playfair Display', serif;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.recommendations-content {
    padding: 12px;
    overflow-y: auto;
    font-size: 0.85rem;
}

/* Consolidated recommendation item */
.rec-item {
    margin-bottom: 15px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f5f5f5;
}

.rec-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.rec-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: #999;
    font-weight: 700;
    margin-bottom: 4px;
    display: block;
}

.rec-image-wrapper {
    margin-bottom: 8px;
    text-align: center;
}

.rec-image-wrapper a {
    display: inline-block;
    text-decoration: none;
}

.rec-image {
    width: 100%;
    max-width: 120px;
    height: auto;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.rec-image:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.rec-title {
    font-weight: 600;
    color: var(--text-color);
    margin: 2px 0 6px;
    line-height: 1.25;
}

.rec-title a {
    color: inherit;
    text-decoration: none;
}

.rec-title a:hover {
    color: var(--primary-color);
}

.rec-blurb {
    color: #666;
    line-height: 1.35;
    margin: 0;
    font-size: 0.8rem;
}

.rec-blurb p {
    margin: 0 0 6px 0;
}

.rec-blurb p:last-child {
    margin-bottom: 0;
}

.rec-action {
    margin-top: 8px;
}

.rec-btn {
    display: inline-block;
    padding: 4px 10px;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Hide on small screens or adjust for mobile */
@media (max-width: 1024px) {
    .floating-recommendations {
        display: none !important; /* Hide floating popup on mobile - use inline recommendations instead */
    }
}

.textarea-wrapper {
    position: relative;
    width: 100%;
}

.query-textarea {
    width: 100%;
    padding: 16px 50px 16px 20px;
    border: 1px solid #ddd;
    border-radius: 12px;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    line-height: 1.5;
    resize: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transition: all 0.2s;
    min-height: 60px;
    overflow-y: hidden;
}

.query-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 4px 16px rgba(112, 47, 112, 0.15);
}

.send-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.textarea-wrapper .send-btn {
    position: absolute;
    right: 12px;
    bottom: 12px;
}

.send-btn:hover {
    background: var(--primary-hover);
}

.send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* === Results Area === */
.results-scroll-area {
    flex: 1;
    overflow-y: auto;
    padding: 0 20px 40px;
    scroll-behavior: smooth;
    position: relative;
}

/* Compact query option controls (Response Style + Anonymous) */
.query-controls {
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}

.control-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #666;
    margin-right: 10px;
}

.tone-control {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.tone-pills {
    display: inline-flex;
    gap: 8px;
    flex-wrap: wrap;
}

.tone-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: #fff;
    cursor: pointer;
    font-size: 0.9rem;
    color: #444;
    user-select: none;
}

.tone-pill input {
    margin: 0;
}

.tone-pill:has(input:checked) {
    border-color: rgba(112, 47, 112, 0.55);
    background: rgba(112, 47, 112, 0.06);
}

.anon-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.anon-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: #495057;
}

.anon-toggle input {
    margin: 0;
}

.anon-tooltip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid #cfd4da;
    color: #6c757d;
    font-size: 12px;
    font-weight: 700;
    background: #fff;
}

.anon-status {
    font-size: 0.85rem;
    color: #6c757d;
}

.anon-note {
    margin-top: 10px;
    background: #fff3cd;
    border: 1px solid #ffeeba;
    border-radius: 8px;
    padding: 10px 12px;
    color: #856404;
    font-size: 0.85rem;
    line-height: 1.35;
}

/* Scroll to Bottom Button */
.scroll-to-bottom-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background-color: var(--primary-color);
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 999;
    box-shadow: 0 4px 12px rgba(112, 47, 112, 0.3);
    border: none;
}

.scroll-to-bottom-btn.visible {
    opacity: 1;
    visibility: visible;
    display: flex;
}

.scroll-to-bottom-btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(112, 47, 112, 0.4);
}

@media (max-width: 768px) {
    .scroll-to-bottom-btn {
        bottom: 20px;
        right: 20px;
        width: 45px;
        height: 45px;
        font-size: 18px;
    }
}

.result-container {
    max-width: 800px;
    margin: 0 auto;
    display: none; /* Hidden initially */
}

.result-container.active {
    display: block;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.query-header {
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: bold;
    color: var(--text-color);
    margin: 10px 0 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.stop-query-btn {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(220, 53, 69, 0.2);
}

.stop-query-btn:hover {
    background: #c82333;
    box-shadow: 0 4px 8px rgba(220, 53, 69, 0.3);
    transform: translateY(-1px);
}

.stop-query-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(220, 53, 69, 0.2);
}

.stop-query-btn i {
    font-size: 1.1rem;
}

.response-content {
    font-size: 1rem;
    line-height: 1.7;
    color: #2c2c2c;
}

/* Markdown & Typography in Response */
.response-content h2 { color: var(--primary-color); font-size: 1.5rem; margin-top: 1.5em; }
.response-content h3 { color: #444; font-size: 1.2rem; margin-top: 1.2em; }
.response-content p { margin-bottom: 1em; }
.response-content ul, .response-content ol { padding-left: 1.5em; margin-bottom: 1em; }
.response-content blockquote {
    border-left: 4px solid var(--primary-color);
    padding-left: 15px;
    margin: 15px 0;
    font-style: italic;
    background: #f9f9f9;
    padding: 15px;
    border-radius: 0 8px 8px 0;
}

/* Tables */
.response-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 25px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    background-color: #fff;
}

.response-content table thead {
    background-color: var(--primary-color);
}

.response-content table th {
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 1.05em;
}

.response-content table tbody tr {
    border-bottom: 1px solid #e0e0e0;
}

.response-content table tbody tr:last-child {
    border-bottom: none;
}

.response-content table tbody tr:nth-child(even) {
    background-color: #f8f9fa;
}

.response-content table tbody tr:hover {
    background-color: #f0f0f0;
}

.response-content table td {
    padding: 12px 15px;
    border: 1px solid #e0e0e0;
    color: #2c2c2c;
    line-height: 1.6;
}

.response-content table td strong {
    color: var(--primary-color);
    font-weight: 600;
}

.responsive-table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 25px 0;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    background: #fff;
}

.responsive-table-wrapper::-webkit-scrollbar {
    height: 8px;
}

.responsive-table-wrapper::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 8px;
}

.responsive-table-wrapper::-webkit-scrollbar-thumb {
    background: rgba(112, 47, 112, 0.4);
    border-radius: 8px;
}

.responsive-table-wrapper table {
    margin: 0;
    width: 100%;
    min-width: 520px;
}

.responsive-table-hint {
    font-size: 0.75rem;
    color: #666;
    margin-top: 6px;
    text-align: right;
}

/* Responsive tables */
@media (max-width: 768px) {
    .response-content .responsive-table-wrapper {
        margin: 20px 0;
    }

    .response-content table {
        font-size: 0.9em;
    }
    
    .response-content table th,
    .response-content table td {
        padding: 8px 10px;
    }
}

.response-content code {
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    color: #c7254e;
}

/* Sources Section */
.sources-chip-container {
    margin-top: 40px;
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
}

.sources-header {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: #666;
    font-weight: 600;
    margin-bottom: 15px;
}

.source-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
}

.source-card {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    font-size: 0.9rem;
    background: #fafafa;
    transition: all 0.2s;
}

.source-card:hover {
    border-color: var(--primary-color);
    background: white;
}

/* Video Recommendations Styles */
.video-recommendations-container {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.video-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 15px;
}

.video-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    transition: all 0.2s;
    box-shadow: var(--card-shadow);
}

.video-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(112, 47, 112, 0.15);
}

.video-card-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-color);
    margin: 0 0 12px 0;
    line-height: 1.4;
}

.video-card-role {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #7a7a7a;
    margin-bottom: 8px;
}

.explore-book-row {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.explore-book-image {
    width: 110px;
    height: auto;
    border-radius: 8px;
    border: 1px solid #eee;
    display: block;
}

.explore-book-blurb {
    margin: 0 0 12px 0;
    color: #555;
    line-height: 1.55;
    font-size: 0.92rem;
}

.video-summary-toggle {
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 8px 14px;
    font-size: 0.85rem;
    color: #555;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    font-weight: 500;
    margin-bottom: 10px;
}

.video-summary-toggle:hover {
    background: #e0e0e0;
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.video-summary-toggle .toggle-icon {
    display: inline-block;
    transition: transform 0.2s;
    font-size: 0.75rem;
}

.video-card-actions {
    display: flex;
    gap: 12px;
    margin-top: 15px;
    align-items: center;
}

.video-watch-btn {
    padding: 10px 20px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s;
    font-weight: 500;
}

.video-watch-btn:hover {
    background: var(--primary-hover);
}

.video-summary-content {
    margin-top: 10px;
    margin-bottom: 10px;
    padding: 12px;
    font-size: 0.9rem;
    line-height: 1.6;
    color: #555;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 3px solid var(--primary-color);
}

/* Collapsible Chunks Styles */
.video-section {
    margin-bottom: 15px;
    background-color: #f8f9fa;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.video-collapsible {
    width: 100%;
    background-color: transparent;
    border: none;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    text-align: left;
}

.video-collapsible:hover {
    background-color: #f0f0f0;
}

.video-collapsible.active {
    background-color: #f0e6f0;
    font-weight: 500;
}

.video-collapsible .collapse-icon {
    font-size: 18px;
    margin-right: 10px;
    color: var(--primary-color);
}

.video-collapsible .video-title {
    flex: 1;
    color: var(--text-color);
    font-weight: 500;
}

.video-collapsible .chunk-count {
    color: #666;
    font-size: 0.85rem;
    margin-left: 10px;
    background-color: rgba(112, 47, 112, 0.1);
    padding: 2px 8px;
    border-radius: 12px;
}

.video-collapsible .toggle-arrow {
    font-size: 12px;
    color: var(--primary-color);
    transition: transform 0.3s ease;
    margin-left: 10px;
}

.video-collapsible.active .toggle-arrow {
    transform: rotate(90deg);
}

.chunk-content {
    background-color: white;
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

.chunk {
    background-color: #fafbfc;
    border-left: 3px solid var(--primary-color);
    padding: 15px 20px;
    margin-bottom: 15px;
    border-radius: 0 8px 8px 0;
    font-size: 0.9rem;
    line-height: 1.6;
}

.chunk:last-child {
    margin-bottom: 0;
}

.chunk p {
    margin: 0 0 10px 0;
    color: var(--text-color);
}

.chunk-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    font-size: 0.8rem;
    color: #666;
}

.chunk-meta span {
    background-color: #f0e6f0;
    padding: 3px 10px;
    border-radius: 12px;
    font-weight: 500;
}

/* Collapsible Sources Container */
#sources-collapsible-container {
    margin-top: 30px;
    background-color: #f8f9fa;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(112, 47, 112, 0.05);
    border: 1px solid var(--border-color);
}

.sources-collapsible-btn {
    width: 100%;
    background: linear-gradient(135deg, #f8f9fa 0%, #f5f6f8 100%);
    border: none;
    padding: 20px 25px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-color);
}

.sources-collapsible-btn:hover {
    background: linear-gradient(135deg, #f5f6f8 0%, #f0f1f3 100%);
}

.sources-collapsible-btn.active {
    background: linear-gradient(135deg, #f0e6f0 0%, #e9dce9 100%);
    border-bottom: 2px solid var(--primary-color);
}

.sources-collapsible-btn .collapse-icon {
    font-size: 20px;
    margin-right: 12px;
}

.sources-collapsible-btn .sources-title {
    flex: 1;
    text-align: left;
}

.sources-collapsible-btn .toggle-arrow {
    font-size: 14px;
    transition: transform 0.3s ease;
    color: var(--primary-color);
}

.sources-collapsible-btn.active .toggle-arrow {
    transform: rotate(90deg);
}

.sources-collapsible-content {
    background-color: white;
    padding: 25px;
}

.sources-section {
    margin-bottom: 30px;
}

.sources-section:last-child {
    margin-bottom: 0;
}

.sources-header {
    color: var(--primary-color);
    font-size: 1.2em;
    font-weight: 600;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0e6f0;
}
    box-shadow: var(--card-shadow);
}

.source-title { font-weight: 600; margin-bottom: 4px; color: var(--primary-color); }
.source-meta { font-size: 0.8rem; color: #888; }

/* Processing Steps */
.processing-indicator {
    margin: 20px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-size: 0.9rem;
    color: #555;
    display: none; /* Hidden by default */
}

.processing-step {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.processing-step:last-child { margin-bottom: 0; }
.spinner { animation: spin 1s linear infinite; }
@keyframes spin { 100% { transform: rotate(360deg); } }

/* Follow-up Chips - Secondary styling */
.followup-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.followup-chip {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    color: #6c757d;
    padding: 6px 12px;
    border-radius: 16px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
    font-weight: 400;
}

.followup-chip:hover {
    background: #e9ecef;
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Hide follow-up input area initially */
.followup-input-wrapper {
    display: none;
}

.followup-input-wrapper.visible {
    display: block;
}

/* Mobile Responsive */
.mobile-menu-toggle {
    display: none;
    position: absolute;
    top: 15px;
    left: 15px;
    z-index: 110;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-color);
    cursor: pointer;
}

/* Mobile styles for query box drag handle */
@media (max-width: 768px) {
    .query-box-drag-handle {
        width: 80px;
        height: 24px;
        top: -24px;
        background: #f8f9fa;
        border: 2px solid var(--border-color);
    }
    
    .query-box-drag-handle::before {
        width: 50px;
        height: 5px;
        background: #999;
    }
    
    .query-box-drag-handle:active {
        background: #e9ecef;
        border-color: var(--primary-color);
    }
    
    .query-box-drag-handle:active::before {
        background: var(--primary-color);
    }
    
    /* Make restore button more prominent on mobile */
    .query-box-restore-btn {
        bottom: 15px;
        padding: 12px 24px;
        font-size: 1rem;
        box-shadow: 0 6px 20px rgba(112, 47, 112, 0.4);
    }
}

.mobile-user-status {
    display: none;
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 110;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--primary-color);
}

@media (max-width: 768px) {
    .mobile-menu-toggle { display: block; }
    .mobile-user-status { display: flex; }
    .mobile-close-sidebar { display: block !important; }
    .sidebar-resizer { display: none; }
    
    .sidebar {
        position: fixed; /* Use fixed to float over content */
        left: -280px;
        top: 0;
        height: 100%;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
        transition: left 0.3s ease; /* Animate left property */
    }
    
    .sidebar.open { left: 0; }

    .search-container {
        padding: 15px !important; /* Add padding on mobile */
    }
    
    .search-container.top { 
        padding-left: 60px; /* Space for toggle */
        padding-right: 15px;
    }
    
    .result-container {
        padding: 0 15px; /* Add horizontal padding on mobile */
        max-width: 100%; /* Allow full width minus padding */
    }
    
    .response-content {
        padding: 0 10px; /* Add padding to prevent text overflow */
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    .query-header {
        font-size: 1rem;
        font-weight: bold;
        padding: 0 10px; /* Add padding to header */
    }
    
    /* Stop button on mobile - make it smaller and adjust text */
    .stop-query-btn {
        padding: 8px 12px;
        font-size: 0.85rem;
    }
    
    /* Overlay when sidebar is open on mobile */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0; left: 0; width: 100%; height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 90;
    }
    
    .sidebar.open + .sidebar-overlay {
        display: block;
    }

    /* Query submit button: place below the text input, aligned right */
    .textarea-wrapper {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
    }

    .textarea-wrapper .send-btn {
        position: static;
        margin-top: 12px;
        width: 44px;
        height: 44px;
        border-radius: 10px;
    }

    .query-textarea {
        padding-right: 20px; /* button is no longer inside the textarea on mobile */
    }
}

/* Modal Styles for Credits/Auth (Reused) */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal-box {
    background: white;
    padding: 30px;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}
