/* ========================================
   Top Navigation — Hidden (using sidebar)
   ======================================== */

.top-nav {
    display: none;
}

/* Hamburger menu, mobile-top-bar, and mobile-logo base styles are
   defined in style.css — only chat-specific overrides go here. */

/* Nav link/actions — hidden with top nav */
.nav-container,
.nav-left,
.nav-actions,
.nav-link,
.nav-logo,
.new-chat-btn-nav,
.delete-chat-btn-nav {
    display: none;
}

/* ========================================
   Chat Container
   ======================================== */

.chat-container {
    flex: 1;
    min-width: 0; /* allow shrinking beside fixed sidebar; avoids clipped finance sidebars */
    display: flex;
    flex-direction: column;
    background-color: var(--bg-main);
    overflow-y: auto;
    overflow-x: hidden;
    height: 100%;
}

/* ========================================
   Messages Container
   ======================================== */

.messages-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px 20px 100px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 0;
}

/* ========================================
   Welcome / Landing Screen
   ======================================== */

.welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 40px 20px;
}

.welcome-message h2 {
    font-family: var(--font-brand);
    font-size: clamp(2.5rem, 5vw, 4.5rem);
    font-weight: 400;
    color: var(--text-primary);
    letter-spacing: -1px;
    margin-bottom: 32px;
    line-height: 1.1;
}

.landing-wordmark {
    position: relative;
    display: inline-block;
}

.landing-wordmark-main {
    display: inline-block;
}

.landing-wordmark-suffix {
    position: absolute;
    right: -10px;
    top: -0.55em;
    transform: translateX(100%);
    font-family: var(--font-ui);
    font-size: 0.28em;
    font-weight: 700;
    color: var(--text-tertiary);
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.landing-wordmark-suffix .suffix-ai-mark {
    display: block;
    width: auto;
    height: 3em;
    object-fit: contain;
}

.landing-about-link {
    margin-top: -18px;
    margin-bottom: 26px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-decoration: none;
    transition: color 0.15s ease, transform 0.15s ease;
}

.landing-about-link:hover {
    color: var(--text-primary);
    transform: translateY(-1px);
}

.welcome-message p {
    display: none;
}

/* ========================================
   Search Box (Landing State)
   ======================================== */

.welcome-search-wrapper {
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
}

/* Landing: story spotlight cards (same width as search); “more” pinned right */
.home-spotlights-wrap {
    width: 100%;
    max-width: 720px;
    margin: 0 auto 18px;
    padding: 0;
}

.home-spotlights-bar {
    display: flex;
    align-items: stretch;
    gap: 10px;
    width: 100%;
    min-height: 64px;
}

.home-spotlights-track {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 2px 0 6px;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}

.home-spotlight-card {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 0;
    min-height: 64px;
    max-height: 72px;
    text-decoration: none;
    text-align: left;
    color: var(--text-primary);
    border: 1px solid rgba(0, 0, 0, 0.09);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.72);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.65) inset;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.home-spotlight-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.1);
    border-color: rgba(0, 0, 0, 0.12);
}

.home-spotlight-card__thumb {
    flex: 0 0 56px;
    width: 56px;
    min-width: 56px;
    align-self: stretch;
    background: linear-gradient(145deg, #e2e8f0, #cbd5e1);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.home-spotlight-card__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.home-spotlight-card__thumb-placeholder {
    width: 28px;
    height: 28px;
    opacity: 0.45;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2'/%3E%3Cpath d='M18 14h-8M15 18h-5M10 6h8v8'/%3E%3C/svg%3E") center / contain no-repeat;
}

.home-spotlight-card__body {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    align-items: center;
    padding: 10px 12px 10px 10px;
}

.home-spotlight-card__title--ai {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.home-spotlight-card__ai-mark {
    flex-shrink: 0;
    display: block;
    object-fit: contain;
}

.home-spotlight-card__title {
    font-size: 13px;
    font-weight: 750;
    letter-spacing: -0.2px;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.home-spotlight-more {
    flex: 0 0 auto;
    flex-shrink: 0;
    align-self: stretch;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 132px;
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: -0.1px;
    line-height: 1.25;
    text-align: center;
    text-decoration: none;
    color: #f8fafc;
    border: 1px solid #1e293b;
    border-radius: 14px;
    background: linear-gradient(145deg, #1e293b, #334155);
    box-shadow: 0 4px 14px rgba(30, 41, 59, 0.22);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.home-spotlight-more:hover {
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 8px 22px rgba(30, 41, 59, 0.35);
}

@media (max-width: 540px) {
    .home-spotlights-bar {
        flex-wrap: nowrap;
        gap: 8px;
    }

    .home-spotlight-more {
        min-width: 100px;
        padding: 8px 10px;
        font-size: 11px;
    }

    .home-spotlight-card {
        min-width: 140px;
    }
}

.chat-input-area {
    padding: 16px 20px 24px;
    border-top: none;
    background: var(--bg-main);
    flex-shrink: 0;
}

.chat-input-area .chat-form {
    max-width: 800px;
    margin: 0 auto;
}

.chat-input-area .input-wrapper {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border-color: rgba(0, 0, 0, 0.1);
}

/* Landing state: input is centered in the welcome area */
.chat-input-area.landing-mode {
    position: static;
    padding: 0;
}

.chat-form {
    width: 100%;
}

.input-wrapper {
    display: flex;
    flex-direction: column;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-wrapper:focus-within {
    border-color: #c0c0c0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.message-input {
    flex: 1;
    padding: 18px 24px 8px;
    border: none;
    font-size: 16px;
    font-family: var(--font-ui);
    resize: none;
    max-height: 120px;
    background: transparent;
    color: var(--text-primary);
    line-height: 1.5;
}

.message-input::placeholder {
    color: var(--text-tertiary);
    font-size: 16px;
}

.message-input:focus {
    outline: none;
}

/* Input Toolbar */
.input-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px 12px;
}

.input-toolbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.input-toolbar-left .attach-menu-wrapper {
    order: 0;
}

.input-toolbar-left .ask-as-wrapper {
    order: 1;
}

.input-toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Ask-as control (Uliza kama ...) */
.ask-as-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.65);
    border: 1px solid rgba(0, 0, 0, 0.10);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    position: relative;
}

.ask-as-info {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.ask-as-info-btn {
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(0, 0, 0, 0.12);
    background: rgba(255, 255, 255, 0.55);
    color: var(--text-secondary);
    border-radius: 999px;
    cursor: pointer;
    padding: 0;
    transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.ask-as-info-btn:hover {
    background: rgba(255, 255, 255, 0.8);
    color: var(--text-primary);
    border-color: rgba(0, 0, 0, 0.2);
}

.ask-as-info-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.12);
}

.ask-as-info-popover {
    position: absolute;
    left: 0;
    bottom: calc(100% + 10px);
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 14px;
    padding: 12px 12px 10px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
    min-width: 280px;
    max-width: 340px;
    z-index: 1200;
    display: none;
    cursor: default;
}

/* invisible bridge to keep hover active between the button and popover */
.ask-as-info-popover::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -10px;
    height: 10px;
    background: transparent;
}

.ask-as-info:hover .ask-as-info-popover,
.ask-as-info:focus-within .ask-as-info-popover {
    display: block;
}

.ask-as-info-title {
    font-size: 13px;
    font-weight: 800;
    letter-spacing: -0.2px;
    color: var(--text-primary);
}

.ask-as-info-body {
    margin-top: 6px;
    font-size: 12.5px;
    line-height: 1.45;
    color: var(--text-secondary);
}

.ask-as-info-link {
    display: inline-flex;
    margin-top: 10px;
    font-size: 12.5px;
    font-weight: 700;
    color: #0f766e; /* teal-700 */
    text-decoration: none;
}

.ask-as-info-link:hover {
    text-decoration: underline;
}

.ask-as-wrapper:focus-within {
    border-color: rgba(0, 0, 0, 0.25);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06), 0 6px 16px rgba(0, 0, 0, 0.08);
    background: rgba(255, 255, 255, 0.78);
}

.ask-as-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: -0.1px;
    white-space: nowrap;
}

.ask-as-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    padding: 6px 28px 6px 10px;
    border-radius: 999px;
    cursor: pointer;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23111' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

.ask-as-select:focus-visible {
    outline: none;
}

.ask-as-select:hover {
    background-color: rgba(0, 0, 0, 0.03);
}

@media (max-width: 480px) {
    .ask-as-wrapper {
        gap: 8px;
        padding: 5px 10px;
    }
    .ask-as-label {
        font-size: 12px;
    }
    .ask-as-select {
        font-size: 12px;
        padding: 6px 26px 6px 8px;
        background-position: right 7px center;
    }
    .ask-as-info-popover {
        min-width: 240px;
        max-width: 280px;
        left: -40px;
    }
}

.toolbar-btn {
    background: none;
    border: none;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-ui);
}

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

.toolbar-btn svg {
    width: 18px;
    height: 18px;
}

.toolbar-btn-attach {
    font-size: 20px;
    padding: 6px 8px;
}

.send-btn {
    width: 32px;
    height: 32px;
    background-color: var(--text-primary);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
    background-color: #333;
    transform: scale(1.05);
}

.send-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Share Chat Button */
.share-chat-btn {
    position: relative;
    width: 32px;
    height: 32px;
    background: none;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

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

.share-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    background: var(--text-primary);
    color: white;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.share-tooltip.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ========================================
   Suggestion Chips (Perplexity-style pills)
   ======================================== */

.suggestion-prompts {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    width: 100%;
    min-width: 0;
    margin: 0;
    padding: 8px 12px 12px;
    box-sizing: border-box;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

/* Landing CTAs */
.landing-ctas-container {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 14px;
    width: 100%;
    max-width: 680px;
    margin-left: auto;
    margin-right: auto;
    animation: fadeIn 0.8s ease forwards;
}

.subscription-cta {
    background: transparent;
    border: none;
    padding: 10px 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 14px;
    text-align: left;
    transition: all 0.2s ease;
    box-shadow: none;
}

/* Bell-only variant (button opens modal) */
.subscription-cta--bell {
    width: auto;
    padding: 0;
    gap: 0;
}

.subscription-cta--bell .subscription-cta-header {
    gap: 0;
}

.subscription-cta:focus-within {
    border: none;
    box-shadow: none;
}

.subscription-cta-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-tertiary);
}

.subscription-cta-header svg {
    color: var(--primary-accent);
}

.subscription-bell-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    background: rgba(255, 255, 255, 0.65);
    color: var(--text-primary);
    padding: 10px 14px;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.18s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.subscription-bell-btn:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.8);
    border-color: rgba(0, 0, 0, 0.18);
}

.subscription-bell-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.18);
}

.subscription-bell-btn svg {
    color: var(--primary-accent);
}

.subscription-bell-text {
    font-size: 13px;
    font-weight: 800;
    letter-spacing: -0.1px;
}

.subscription-form {
    display: flex;
    gap: 10px;
}

@media (max-width: 600px) {
    .landing-ctas-container {
        flex-direction: column;
        align-items: center;
        gap: 18px;
    }
    .subscription-form,
    .auth-cta {
        flex-direction: column;
    }
    .subscription-submit-btn,
    .auth-cta-btn {
        width: 100%;
    }
    .auth-cta-text {
        text-align: center;
    }
}

.subscription-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: var(--radius-lg);
    padding: 10px 16px;
    font-size: 14px;
    color: var(--text-primary);
    font-family: var(--font-ui);
}

.subscription-input:focus {
    outline: none;
    border-color: var(--text-tertiary);
}

.subscription-submit-btn {
    background: var(--text-primary);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-ui);
}

.subscription-submit-btn:hover {
    background: #333;
}

.auth-cta {
    display: flex;
    align-items: center;
    gap: 12px;
}

.auth-cta-text {
    font-size: 14px;
    color: var(--text-secondary);
}

.auth-cta-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-ui);
}

.auth-cta-btn:hover {
    background: var(--bg-hover);
    border-color: var(--text-tertiary);
}

/* Hide during chat */
.chat-container.chatting .landing-ctas-container {
    display: none !important;
}

.suggestion-chip {
    background: var(--bg-light);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 10px 18px;
    border-radius: var(--radius-lg);
    font-size: 14px;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-ui);
    box-shadow: none;
    flex-shrink: 0;
    white-space: nowrap;
}

.suggestion-chip:hover {
    background: var(--secondary-color);
    border-color: #ccc;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.suggestion-chip:active {
    transform: translateY(0);
}

/* Quick Suggestions (below input in chat mode) */
.quick-suggestions {
    display: none;
}

/* ========================================
   Chat Mode (after first message)
   ======================================== */

.chat-container.chatting .chat-input-area {
    padding: 16px 20px 24px;
    border-top: none;
    background: var(--bg-main);
}

.chat-container.chatting .input-wrapper {
    max-width: 800px;
    margin: 0 auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border-color: rgba(0, 0, 0, 0.1);
}

/* ========================================
   Message Styles
   ======================================== */

.message {
    display: flex;
    margin-bottom: 8px;
    animation: slideIn 0.3s ease;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
}

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

.message.user {
    justify-content: flex-end;
}

.message.assistant {
    justify-content: flex-start;
}

.message-content {
    max-width: 75%;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    word-wrap: break-word;
    line-height: 1.6;
    font-size: 15px;
}

/* Ensure any rendered <img> inside markdown fits bubble */
.message-content img {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 12px;
}

.message.user .message-content {
    background-color: var(--text-primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
    background-color: var(--bg-light);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    border-bottom-left-radius: 4px;
}

/* Loading Indicator */
.message.loading .message-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
}

.loading-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}

.loading-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: var(--text-tertiary);
    animation: bounce 1.4s infinite;
}

.loading-dot:nth-child(2) { animation-delay: 0.2s; }
.loading-dot:nth-child(3) { animation-delay: 0.4s; }

.loading-phrase {
    display: flex;
    flex-direction: column;
    gap: 4px;
    animation: fadeIn 0.5s ease;
}

.loading-phrase-swahili {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    font-style: italic;
}

.loading-phrase-english {
    font-size: 12px;
    color: var(--text-secondary);
    opacity: 0.8;
}

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

@keyframes bounce {
    0%, 80%, 100% { opacity: 0.5; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-6px); }
}

/* ========================================
   Scrollbar Styling
   ======================================== */

.messages-container::-webkit-scrollbar {
    width: 4px;
}

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

.messages-container::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 2px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* ========================================
   Markdown Styling in Messages
   ======================================== */

.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4,
.message-content h5,
.message-content h6 {
    margin: 12px 0 8px 0;
    font-weight: 600;
    line-height: 1.3;
}

.message-content h1 { font-size: 1.4em; }
.message-content h2 { font-size: 1.2em; }
.message-content h3 { font-size: 1.1em; }
.message-content h4,
.message-content h5,
.message-content h6 { font-size: 1em; }

.message-content p { margin: 8px 0; }

.message-content ul,
.message-content ol {
    margin: 8px 0;
    padding-left: 24px;
}

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

.message-content code {
    background-color: rgba(0, 0, 0, 0.06);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'SF Mono', 'Consolas', 'Courier New', monospace;
    font-size: 0.88em;
}

.message.user .message-content code {
    background-color: rgba(255, 255, 255, 0.2);
}

.message-content pre {
    background-color: rgba(0, 0, 0, 0.06);
    padding: 14px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 8px 0;
}

.message.user .message-content pre {
    background-color: rgba(255, 255, 255, 0.15);
}

.message-content pre code {
    background-color: transparent;
    padding: 0;
    font-size: 0.85em;
}

.message-content blockquote {
    border-left: 3px solid var(--border-color);
    padding-left: 14px;
    margin: 8px 0;
    font-style: italic;
    color: var(--text-secondary);
}

.message.user .message-content blockquote {
    border-left-color: rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.8);
}

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

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

.message.user .message-content a {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: underline;
}

.message-content strong { font-weight: 600; }
.message-content em { font-style: italic; }

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

.message.user .message-content hr {
    border-top-color: rgba(255, 255, 255, 0.2);
}

.message-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 8px 0;
    font-size: 0.9em;
}

.message-content table th,
.message-content table td {
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    text-align: left;
}

.message.user .message-content table th,
.message.user .message-content table td {
    border-color: rgba(255, 255, 255, 0.2);
}

.message-content table th {
    font-weight: 600;
    background-color: var(--secondary-color);
}

.message.user .message-content table th {
    background-color: rgba(255, 255, 255, 0.1);
}

/* ========================================
   Category View & Grid Layout
   ======================================== */

.category-view {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

.category-header {
    margin-bottom: 32px;
}

.category-header h2 {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    font-family: var(--font-brand);
}

.category-description {
    font-size: 16px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.post-count {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--text-secondary);
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
}

/* Posts Grid */
.posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 24px;
    animation: fadeIn 0.5s ease;
}

.posts-grid-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 16px;
}

.loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border-color);
    border-top-color: var(--text-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.posts-error {
    padding: 40px;
    text-align: center;
    color: var(--error-color);
    background: rgba(239, 68, 68, 0.05);
    border-radius: var(--radius-sm);
}

/* Post Card */
.post-card {
    background: var(--bg-light);
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    border: 1px solid var(--border-light);
}

.post-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
    border-color: var(--border-color);
}

.post-card-image {
    width: 100%;
    height: 220px;
    overflow: hidden;
    background: var(--secondary-color);
}

.post-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.post-card:hover .post-card-image img {
    transform: scale(1.03);
}

.post-card-content {
    padding: 20px;
}

.post-card-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.post-card-excerpt {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 14px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.post-card-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: var(--text-tertiary);
}

.post-date {
    display: flex;
    align-items: center;
    gap: 4px;
}

.post-date::before {
    content: '🕐';
    font-size: 12px;
}

/* ========================================
   Individual Post View
   ======================================== */

.post-view {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 24px;
    animation: fadeIn 0.5s ease;
}

.post-view-error {
    text-align: center;
    padding: 60px 20px;
}

.post-view-error h2 {
    font-size: 24px;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.post-view-error p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.back-to-category-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background-color: var(--bg-light);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 24px;
    font-family: var(--font-ui);
}

.back-to-category-btn:hover {
    background-color: var(--secondary-color);
    transform: translateX(-4px);
}

.post-article {
    background: var(--bg-light);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    border: 1px solid var(--border-light);
}

.post-header {
    padding: 32px;
    border-bottom: 1px solid var(--border-light);
}

.post-title {
    font-size: 36px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
    margin-bottom: 16px;
    font-family: var(--font-brand);
}

.post-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 14px;
    color: var(--text-secondary);
}

.post-author {
    font-weight: 600;
    color: var(--primary-accent);
}

.post-author::before {
    content: '✍️';
    margin-right: 6px;
}

.post-featured-image {
    width: 100%;
    height: 400px;
    overflow: hidden;
    background: var(--secondary-color);
}

.post-featured-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.post-content {
    padding: 32px;
    font-size: 16px;
    line-height: 1.8;
    color: var(--text-primary);
}

.post-content p { margin-bottom: 20px; }

.post-content h3 {
    font-size: 24px;
    font-weight: 600;
    margin-top: 32px;
    margin-bottom: 16px;
}

.post-content ul,
.post-content ol {
    margin-left: 24px;
    margin-bottom: 20px;
}

.post-content li { margin-bottom: 8px; }

.post-content a {
    color: var(--primary-accent);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s ease;
}

.post-content a:hover {
    border-bottom-color: var(--primary-accent);
}

/* ========================================
   Finance Layout (Perplexity Style)
   ======================================== */

.finance-view {
    padding-top: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

/* Finance Header */
.finance-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.finance-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.finance-header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: var(--transition);
}

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

.finance-search-container {
    position: relative;
    display: flex;
    align-items: center;
}

.finance-search-container svg {
    position: absolute;
    left: 12px;
    color: var(--text-secondary);
}

.finance-search-input {
    width: 280px;
    background: transparent;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-full);
    padding: 8px 16px 8px 36px;
    font-size: 14px;
    color: var(--text-primary);
    transition: var(--transition);
}

.finance-search-input::placeholder {
    color: var(--text-tertiary);
}

.finance-search-input:focus {
    outline: none;
    border-color: var(--text-secondary);
    width: 320px;
}

/* Sub-Navigation & Dropdown */
.finance-subnav {
    display: flex;
    align-items: center;
    gap: 32px;
    margin-bottom: 24px;
    font-size: 15px;
}

.market-dropdown-container {
    position: relative;
}

.market-dropdown-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.market-dropdown-btn:hover, .market-dropdown-btn.active {
    background: var(--bg-light);
}

.market-dropdown-btn svg {
    transition: transform 0.2s ease;
}

.market-dropdown-btn.active svg {
    transform: rotate(180deg);
}

.market-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 8px;
    width: 320px;
    background: #ffffff;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 100;
    padding: 12px;
}

.market-dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-section {
    margin-bottom: 12px;
}

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

.dropdown-section-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-tertiary);
    margin-bottom: 8px;
    padding-left: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.dropdown-item:hover {
    background: var(--bg-light);
}

.di-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-primary);
}

.di-name {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.di-price {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.di-change {
    font-size: 13px;
    font-weight: 600;
    width: 65px;
    text-align: right;
}

.di-change.positive { color: #10B981; }
.di-change.negative { color: #EF4444; }

.finance-subnav-links {
    display: flex;
    gap: 24px;
    color: var(--text-secondary);
    font-weight: 500;
}

.finance-subnav-links span {
    cursor: pointer;
    transition: var(--transition);
}

.finance-subnav-links span:hover {
    color: var(--text-primary);
}

.finance-subnav-links span.active {
    color: var(--text-primary);
}

/* 1. Top Assets Scroll */
.top-assets-scroll {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    width: 100%;
    max-width: 100%;
    padding-bottom: 20px;
    margin-bottom: 24px;
    scrollbar-width: none;
    -ms-overflow-style: none; /* IE and Edge */
}

.top-assets-scroll::-webkit-scrollbar {
    display: none;
}

.finance-main-col {
    min-width: 0; /* Important: prevents column from expanding beyond 1fr due to flex children */
}

/* 2. Two Column Layout */
.finance-columns {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 40px;
    width: 100%;
}

@media (max-width: 992px) {
    .finance-columns {
        grid-template-columns: 1fr;
    }
}

/* Common Block Styles */
.finance-block {
    margin-bottom: 32px;
}

.finance-block-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-light);
}

.finance-block-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    font-family: var(--font-brand);
}

.update-time {
    font-size: 12px;
    color: var(--text-tertiary);
}

/* 3. Market Summary List */
.market-summary-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.summary-item {
    padding: 16px;
    background: var(--bg-light);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
}

.summary-item:hover {
    background: #fdfdfd;
}

.summary-headline {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.summary-detail {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* 4. Heatmap Grid */
.heatmap-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: 80px;
    gap: 4px;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.heatmap-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 8px;
    color: white;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.2s ease;
}

.heatmap-cell:hover {
    filter: brightness(1.1);
}

.heatmap-cell span {
    pointer-events: none;
    line-height: 1.4;
}

.heatmap-cell.positive { background-color: #10B981; }
.heatmap-cell.negative { background-color: #EF4444; }
.heatmap-cell.neutral { background-color: #9CA3AF; }

.heatmap-cell.h-large { grid-column: span 2; grid-row: span 2; font-size: 15px; }
.heatmap-cell.h-medium { grid-column: span 2; grid-row: span 1; }
.heatmap-cell.h-small { grid-column: span 1; grid-row: span 1; font-size: 11px; }

/* 5. Sidebar Styles */
.sidebar-block {
    background: #f9f9f9;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
}

.sidebar-list {
    display: flex;
    flex-direction: column;
}

.sidebar-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
}

.sidebar-list-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.sidebar-list-item:first-child {
    padding-top: 0;
}

.sl-name {
    font-size: 13px;
    color: var(--text-secondary);
    flex: 1;
}

.sl-value {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    width: 70px;
    text-align: right;
}

.sl-change {
    font-size: 13px;
    font-weight: 600;
    width: 65px;
    text-align: right;
}

.sl-change.positive { color: #10B981; }
.sl-change.negative { color: #EF4444; }

/* Gainers / Losers Tabs */
.finance-block-header.tabs {
    justify-content: flex-start;
    gap: 20px;
    border-bottom: 1px solid var(--border-color);
}

.tab {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    padding-bottom: 8px;
    cursor: pointer;
    position: relative;
    top: 1px;
}

.tab.active {
    color: var(--text-primary);
    border-bottom: 2px solid var(--text-primary);
}

.sidebar-list-item.gainer {
    justify-content: flex-start;
    gap: 12px;
}

.gainer-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: #eee;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-primary);
}

.gainer-info {
    flex: 1;
}

.g-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.g-ticker {
    font-size: 11px;
    color: var(--text-tertiary);
}

.gainer-stats {
    text-align: right;
}

.g-price {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.g-change {
    font-size: 12px;
    font-weight: 600;
}

.g-change.positive { color: #10B981; }
.g-change.negative { color: #EF4444; }

/* Integration with posts */
.finance-posts {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}
/* ========================================
   Entertainers Section (Entertainment page)
   ======================================== */

.entertainers-section {
    margin-top: 40px;
    padding-top: 32px;
    border-top: 1px solid var(--border-light);
}

.entertainers-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.entertainers-header h3 {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
    font-family: var(--font-brand);
}

.entertainers-nav {
    display: none;
}

.entertainers-nav-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--bg-light);
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.entertainers-nav-btn:hover {
    background: var(--secondary-color);
    border-color: #ccc;
}

.entertainers-scroll-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 12px;
}

.entertainer-card {
    flex: 0 0 auto;
    width: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 16px 8px;
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.entertainer-card:hover {
    background: var(--bg-light);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    transform: translateY(-2px);
}

.entertainer-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    font-weight: 700;
    font-family: var(--font-ui);
    letter-spacing: 1px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s ease;
}

.entertainer-card:hover .entertainer-avatar {
    transform: scale(1.08);
}

.entertainer-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.entertainer-genre {
    font-size: 11px;
    color: var(--text-tertiary);
    text-align: center;
}

@media (max-width: 768px) {
    .entertainer-card {
        width: 100px;
    }

    .entertainer-avatar {
        width: 60px;
        height: 60px;
        font-size: 16px;
    }

    .entertainers-header h3 {
        font-size: 18px;
    }
}

/* ========================================
   Sources Badge & List
   ======================================== */

.sources-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-secondary);
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.post-sources-count {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-secondary);
    border-radius: 16px;
    font-size: 13px;
    font-weight: 500;
}

.post-sources {
    margin-top: 40px;
    padding: 24px 32px;
    background: var(--secondary-color);
    border-top: 1px solid var(--border-light);
    border-radius: 0 0 12px 12px;
}

.post-sources h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sources-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.source-item {
    padding: 14px;
    background: var(--bg-light);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    transition: border-color 0.2s ease;
}

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

.source-link {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px;
    text-decoration: none;
    margin-bottom: 6px;
}

.source-title {
    color: var(--primary-accent);
    font-weight: 600;
    font-size: 15px;
}

.source-title:hover { text-decoration: underline; }

.source-date {
    color: var(--text-tertiary);
    font-size: 13px;
}

.source-snippet {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
    font-style: italic;
}

/* ========================================
   Responsive Design
   ======================================== */

@media (max-width: 768px) {
    /* .hamburger-menu and .mobile-top-bar show rules are in style.css */

    .message-content {
        max-width: 85%;
    }

    .messages-container {
        padding: 15px;
        padding-bottom: 100px;
    }

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

    .welcome-message h2 {
        font-size: 2.5rem;
    }

    .suggestion-prompts {
        gap: 8px;
    }

    .suggestion-chip {
        padding: 8px 14px;
        font-size: 13px;
    }

    .category-view,
    .post-view {
        padding: 16px;
    }

    .category-header h2 {
        font-size: 24px;
    }

    .category-description {
        font-size: 14px;
    }

    .posts-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .post-card-image {
        height: 180px;
    }

    .post-title {
        font-size: 28px;
    }

    .post-featured-image {
        height: 250px;
    }

    .post-header,
    .post-content {
        padding: 20px;
    }

    .post-content {
        font-size: 15px;
    }
}

@media (max-width: 480px) {
    .welcome-message h2 {
        font-size: 2rem;
    }

    .input-wrapper {
        border-radius: 20px;
    }

    .message-input {
        padding: 14px 18px 6px;
        font-size: 15px;
    }

    .input-toolbar {
        gap: 10px;
    }

    .message-content {
        max-width: 90%;
        padding: 12px 14px;
        font-size: 14px;
    }

    .messages-container {
        padding: 12px;
        gap: 12px;
    }

    .send-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .category-header {
        margin-bottom: 20px;
    }

    .posts-grid {
        gap: 12px;
    }

    .post-card-content {
        padding: 16px;
    }

    .post-card-title {
        font-size: 16px;
    }

    .post-title {
        font-size: 24px;
    }

    .post-featured-image {
        height: 200px;
    }

    .back-to-category-btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 360px) {
    .chat-input-area {
        padding-left: 10px;
        padding-right: 10px;
    }

    .message-input {
        padding: 12px 14px 6px;
        font-size: 15px;
    }

    .input-toolbar {
        flex-direction: column;
        align-items: stretch;
        padding: 8px 10px 12px;
        gap: 10px;
    }

    .input-toolbar-left {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
        row-gap: 10px;
    }

    .ask-as-wrapper {
        flex: 1 1 auto;
        min-width: 0;
    }

    .input-toolbar-right {
        width: 100%;
        justify-content: flex-end;
    }

    .suggestion-prompts {
        gap: 8px;
        padding: 8px 10px 10px;
    }

    .suggestion-chip {
        padding: 8px 12px;
    }
}

/* ========================================
   iTrust EAC Large Cap ETF Heatmap
   ======================================== */

.etf-heatmap-container {
    padding-bottom: 24px;
}

.heatmap-header-with-tabs {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 16px;
}

.heatmap-tabs {
    display: flex;
    background: var(--bg-hover);
    padding: 4px;
    border-radius: var(--radius-md);
    gap: 4px;
}

.heatmap-tab {
    background: transparent;
    border: none;
    padding: 6px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.heatmap-tab:hover {
    color: var(--text-primary);
}

.heatmap-tab.active {
    background: var(--bg-light);
    color: var(--text-primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

@media (max-width: 768px) {
    .heatmap-header-with-tabs {
        flex-direction: column;
    }
    .heatmap-tabs {
        width: 100%;
    }
    .heatmap-tab {
        flex: 1;
        text-align: center;
    }
}

/* Market Summary Accordion */
.market-summary-accordion {
    padding: 0;
    overflow: hidden;
}

.ms-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ms-accordion-list {
    display: flex;
    flex-direction: column;
}

.ms-accordion-item {
    border-bottom: 1px solid var(--border-color);
}

.ms-accordion-item:last-child {
    border-bottom: none;
}

.ms-accordion-header {
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.ms-accordion-header:hover {
    background-color: var(--bg-hover);
}

.ms-title {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
}

.ms-icon {
    font-size: 12px;
    color: var(--text-secondary);
    margin-left: 16px;
    transition: transform 0.2s ease;
}

.ms-accordion-item.active .ms-accordion-header {
    background-color: var(--bg-hover);
}

.ms-accordion-content {
    padding: 0 20px 20px 20px;
    background-color: var(--bg-hover);
}

.ms-accordion-content p {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-secondary);
}

.ms-sources {
    margin-top: 12px;
}

.ms-sources-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 12px;
    color: var(--text-secondary);
}

.ms-sources-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 15px;
    padding-top: 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.ms-source-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    color: #64748b;
    text-decoration: none;
    transition: all 0.2s ease;
}

.ms-source-link:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: var(--finance-primary, #00b894);
    transform: translateY(-1px);
}

.ms-source-link i {
    font-size: 10px;
    opacity: 0.7;
}

/* Portfolio Brokerage Block */
.portfolio-block {
    padding: 0;
    overflow: hidden;
}

.portfolio-block .pb-header {
    padding: 16px 20px;
    border-bottom: 0;
}

.portfolio-block .pb-header h3 {
    margin: 0;
    font-size: 16px;
    color: var(--text-primary);
}

.portfolio-block .pb-content {
    padding: 0 20px 20px;
}

.portfolio-block .pb-title {
    margin: 0 0 8px 0;
    font-size: 18px;
    font-weight: 500;
    color: var(--text-primary);
}

.portfolio-block .pb-desc {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-secondary);
}

.portfolio-block .pb-action {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-hover);
    text-align: center;
}

.portfolio-block .btn-outline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: transparent;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.portfolio-block .btn-outline:hover {
    background-color: var(--border-color);
}

/* ========================================
   Search Plus Menu (Attach Dropdown)
   ======================================== */

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

.attach-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 260px;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    padding: 8px;
    display: none;
    flex-direction: column;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    z-index: 1100;
    backdrop-filter: blur(8px);
    animation: menuFadeInDown 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: top left;
}

@keyframes menuFadeInDown {
    from { 
        opacity: 0; 
        transform: translateY(-8px) scale(0.98); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0) scale(1); 
    }
}

.attach-menu.active {
    display: flex;
}

.attach-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    color: #374151; /* gray-700 */
    cursor: pointer;
    font-size: 14px;
    font-weight: 450;
    transition: all 0.2s ease;
    user-select: none;
}

.attach-menu-item:hover {
    background: #f3f4f6; /* gray-100 */
}

.attach-menu-item svg:not(.lock-icon):not(.chevron-right) {
    width: 20px;
    height: 20px;
    color: #6b7280; /* gray-500 */
}

.attach-menu-item:hover svg:not(.lock-icon):not(.chevron-right) {
    color: #111827; /* gray-900 */
}

.attach-menu-item span {
    flex: 1;
    white-space: nowrap;
}

.attach-menu-item .chevron-right {
    width: 14px;
    height: 14px;
    color: #9ca3af; /* gray-400 */
}

.attach-submenu {
    display: flex;
    flex-direction: column;
    padding-left: 12px;
    margin-top: 4px;
    margin-bottom: 4px;
    gap: 4px;
}

.attach-submenu-item {
    padding: 8px 12px;
    font-size: 13px;
}

.attach-submenu-item svg {
    width: 16px !important;
    height: 16px !important;
}

.attach-menu-item.has-right-submenu {
    position: relative;
    overflow: visible;
}

.attach-submenu-popover {
    position: absolute;
    left: calc(100% + 8px);
    bottom: -8px;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    padding: 8px;
    display: none;
    flex-direction: column;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    min-width: 220px;
    z-index: 1101;
    cursor: default;
}

/* invisible bridge to keep hover active between the button and popover */
.attach-submenu-popover::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -10px;
    width: 10px;
    background: transparent;
}

.attach-menu-item.has-right-submenu:hover .attach-submenu-popover {
    display: flex;
}

.attach-menu-item.locked {
    color: #9ca3af;
    cursor: default;
}

.attach-menu-item.locked:hover {
    background: transparent;
}

.attach-menu-item .lock-icon {
    width: 14px;
    height: 14px;
    color: #d1d5db; /* gray-300 */
    margin-left: auto;
}

.attach-menu-divider {
    height: 1px;
    background: #f3f4f6;
    margin: 6px 0;
}

.badge-max {
    background: #e0f2fe; /* light blue */
    color: #0369a1; /* medium blue */
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    margin-left: 8px;
    border: 1px solid #bae6fd;
}

/* Ensure parents don't clip our menu */
.input-toolbar-left,
.input-toolbar,
.input-wrapper,
.welcome-search-wrapper,
.welcome-message {
    overflow: visible !important;
}

/* Landing search specific tweak */
.welcome-message {
    position: relative;
}

/* Image Attachment Previews */
.attachment-preview-container {
    display: none;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px;
    background: transparent;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.attachment-preview-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px 6px 6px;
    background: #1f2937; /* gray-800 for dark pill */
    border-radius: 10px;
    color: #f9fafb;
    max-width: 240px;
    animation: pillFadeIn 0.2s ease-out;
}

@keyframes pillFadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.attachment-thumb {
    width: 32px;
    height: 32px;
    min-width: 32px;
    background: #374151;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.attachment-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.attachment-meta {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.attachment-name {
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.attachment-remove {
    background: transparent;
    border: none;
    color: #9ca3af;
    padding: 4px;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.attachment-remove:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.attachment-size {
    font-size: 10px;
    color: #9ca3af;
}

/* Ensure container shows only when has content */
.attachment-preview-container:not(:empty) {
    display: flex;
}

/* Message Attachments within Chat Bubbles */
.message-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.message-attachment-image {
    max-width: 260px;
    max-height: 260px;
    border-radius: 12px;
    object-fit: cover;
    display: block;
    cursor: zoom-in;
    border: 1px solid rgba(0, 0, 0, 0.08);
    transition: all 0.2s ease;
}

.message-attachment-image:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.assistant .message-attachment-image {
    background: #f3f4f6;
}

.user .message-attachment-image {
    border-color: rgba(255, 255, 255, 0.15);
}

.message-content span {
    display: block;
}

/* Image search results (assistant-rendered thumbnails + lightbox) */
.chat-image-result {
    display: inline-flex;
    flex-direction: column;
    gap: 6px;
    margin: 8px 0 10px;
    max-width: 100%;
}

.chat-image-thumb {
    width: 100%;
    max-width: 100%;
    max-height: 320px;
    object-fit: contain;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    cursor: zoom-in;
    background: #f3f4f6;
}

.chat-image-link {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.chat-image-link:hover {
    color: var(--text-primary);
    text-decoration: underline;
}

.chat-image-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.chat-image-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
}

.chat-image-lightbox-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(92vw, 980px);
    max-height: 88vh;
    background: rgba(18, 18, 18, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    padding: 14px;
    box-shadow: 0 20px 70px rgba(0, 0, 0, 0.4);
}

.chat-image-lightbox-img {
    width: 100%;
    height: auto;
    max-height: 76vh;
    object-fit: contain;
    border-radius: 12px;
    background: #0b0b0b;
}

.chat-image-lightbox-close {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    font-size: 22px;
    line-height: 30px;
    cursor: pointer;
}

.chat-image-lightbox-open {
    color: rgba(255, 255, 255, 0.78);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    align-self: flex-start;
    padding-right: 42px; /* leave room for close button */
}

.chat-image-lightbox-open:hover {
    color: #fff;
    text-decoration: underline;
}