/* ========================================
   Global Styles — Perplexity-Inspired Theme
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;500;600;700&family=Inter:wght@300;400;500;600;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

:root {
    --primary-color: #1a1a1a;
    --primary-accent: #4a90d9;
    --secondary-color: #f5f5f5;
    --text-primary: #1a1a1a;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    --border-color: #e5e7eb;
    --border-light: #f0f0f0;
    --bg-light: #ffffff;
    --bg-main: #f0efe9;
    --bg-secondary: #fafaf9;
    --bg-tertiary: #f0f0ee;
    --bg-sidebar: #f3f3f2;
    --bg-hover: rgba(0, 0, 0, 0.04);
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --sidebar-width: 240px;
    --transition: all 0.2s ease;
    --font-brand: 'Playfair Display', Georgia, 'Times New Roman', serif;
    --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 24px;
    --radius-xl: 28px;
}

html,
body {
    height: 100%;
    font-family: var(--font-ui);
    background-color: var(--bg-main);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Prevent horizontal overflow on mobile */
    max-width: 100vw;
    overflow-x: hidden;
}

/* ========================================
   Shorts Strip (WIP) — small horizontal scroll
   ======================================== */

.shorts-strip {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--border-light);
}

.shorts-strip-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.shorts-strip-title {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.shorts-wip-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(0, 0, 0, 0.10);
    color: var(--text-secondary);
}

.shorts-strip-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.35;
    white-space: nowrap;
}

.shorts-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 8px 2px 4px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.shorts-scroll::-webkit-scrollbar {
    display: none;
}

.short-card {
    flex: 0 0 130px;
    height: 210px;
    border-radius: 16px;
    position: relative;
    overflow: hidden;
    scroll-snap-align: start;
    border: 1px solid rgba(0,0,0,0.08);
    box-shadow: 0 10px 26px rgba(0,0,0,0.10);
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.short-card:hover,
.short-card:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 14px 32px rgba(0,0,0,0.12);
}

.short-card:focus-visible {
    outline: 2px solid rgba(26, 26, 26, 0.22);
    outline-offset: 2px;
}

.short-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.55) 0%, rgba(0,0,0,0.10) 45%, rgba(0,0,0,0.05) 100%);
    pointer-events: none;
}

.short-card-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 1;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.22);
    color: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.short-card-play {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.22);
    color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.short-card-meta {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 1;
    color: #fff;
}

.short-card-title {
    font-size: 12.5px;
    font-weight: 900;
    line-height: 1.25;
    letter-spacing: -0.01em;
    margin: 0 0 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.short-card-sub {
    font-size: 11px;
    opacity: 0.85;
    margin: 0;
}

/* Preset gradients (events/general) */
.short-card--violet { background: linear-gradient(135deg, #7c3aed 0%, #111827 100%); }
.short-card--orange { background: linear-gradient(135deg, #4f46e5 0%, #1e1b4b 100%); }
.short-card--blue   { background: linear-gradient(135deg, #2563eb 0%, #0b1220 100%); }
.short-card--green  { background: linear-gradient(135deg, #059669 0%, #064e3b 100%); }
.short-card--slate  { background: linear-gradient(135deg, #334155 0%, #0f172a 100%); }

/* Sports variants (cool neutrals — no brand orange on cards) */
.short-card--sports-1 { background: linear-gradient(135deg, #334155 0%, #0f172a 100%); }
.short-card--sports-2 { background: linear-gradient(135deg, #0f766e 0%, #134e4a 100%); }
.short-card--sports-3 { background: linear-gradient(135deg, #2563eb 0%, #0b1220 100%); }
.short-card--sports-4 { background: linear-gradient(135deg, #475569 0%, #1e293b 100%); }
.short-card--sports-5 { background: linear-gradient(135deg, #6366f1 0%, #1e1b4b 100%); }

@media (max-width: 520px) {
    .shorts-strip-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 4px;
    }
    .shorts-strip-subtitle {
        white-space: normal;
    }
    .short-card {
        flex-basis: 118px;
        height: 196px;
    }
}

/* App Container */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Main Content Wrapper */
.main-wrapper {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ========================================
   Sidebar — Light Perplexity Style
   ======================================== */

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    overflow: visible;
    transition: var(--transition);
    border-right: 1px solid var(--border-light);
    padding: 12px 0;
    position: relative;
    z-index: 1001;
}

/* Sidebar logo + language switch */
.sidebar-logo-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 16px 16px 20px 20px;
}

.sidebar-logo-area {
    padding: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.site-lang-switch {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
    background: var(--bg-hover, rgba(0, 0, 0, 0.05));
    border-radius: 10px;
    padding: 2px;
    border: 1px solid var(--border-light, rgba(0, 0, 0, 0.08));
}

.site-lang-switch__opt {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 28px;
    padding: 0 6px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.04em;
    color: var(--text-secondary, #64748b);
    text-decoration: none;
    border-radius: 8px;
    transition: background 0.15s ease, color 0.15s ease;
}

.site-lang-switch__opt:hover {
    color: var(--text-primary, #0f172a);
    background: rgba(255, 255, 255, 0.6);
}

.site-lang-switch__opt.is-active {
    background: var(--text-primary, #0f172a);
    color: var(--bg-main, #fff);
}

.site-lang-switch--mobile {
    transform: scale(0.92);
    transform-origin: center left;
    pointer-events: auto;
}

.sidebar-logo-area .logo-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-logo-area .logo-text {
    font-family: var(--font-brand);
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

/* Brand mark: nukta ai */
.brand-logo {
    display: inline-flex;
    align-items: baseline;
    gap: 0;
}

.brand-logo .brand-name {
    font-family: var(--font-brand);
    letter-spacing: -0.3px;
}

.brand-logo .brand-ai {
    font-family: var(--font-ui);
    font-weight: 700;
    font-size: 0.78em;
    margin-left: 4px;
    color: var(--primary-accent);
    letter-spacing: -0.1px;
}

.brand-logo .brand-tm {
    font-family: var(--font-ui);
    font-weight: 700;
    font-size: 0.62em;
    margin-left: 3px;
    position: relative;
    top: -0.45em;
    color: var(--text-tertiary);
}

.brand-logo .brand-agent {
    font-family: var(--font-ui);
    font-weight: 700;
    font-size: 0.62em;
    margin-left: 3px;
    position: relative;
    top: -0.45em;
    color: var(--text-tertiary);
    letter-spacing: 0.1px;
    text-transform: lowercase;
}

/* Simple generic page layout */
.generic-page {
    width: 100%;
    max-width: 980px;
    margin: 0 auto;
    padding: 28px 22px 40px;
}

.generic-hero {
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 26px 22px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06);
}

.generic-hero h1 {
    font-family: var(--font-brand);
    font-size: 34px;
    letter-spacing: -0.6px;
    margin-bottom: 10px;
}

.generic-hero p {
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.65;
    max-width: 74ch;
}

.generic-card {
    margin-top: 14px;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 18px 22px;
}

.generic-card h2 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 10px;
}

.generic-card p,
.generic-card li {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.7;
}

.generic-card ul {
    padding-left: 18px;
}

.generic-cta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 10px 14px;
    background: var(--text-primary);
    color: var(--bg-main);
    text-decoration: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 14px;
}

.generic-cta:hover {
    opacity: 0.9;
}

/* ========================================
   Tanzania Agent Page (Light UI)
   ======================================== */

.agent-page {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 28px 22px 56px;
}

.agent-topline {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-tertiary);
    font-size: 13px;
    margin-bottom: 18px;
}

.agent-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.08);
    color: var(--text-primary);
    font-weight: 700;
    letter-spacing: 0.2px;
    font-size: 12px;
}

.agent-pill-ai {
    color: var(--primary-accent);
    font-weight: 800;
}

.agent-topline-sep {
    opacity: 0.6;
}

.agent-topline-title {
    color: var(--text-secondary);
    font-weight: 600;
}

.agent-hero {
    position: relative;
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 24px;
    align-items: center;
    padding: 26px 22px;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 22px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.06);
    overflow: hidden;
}

.agent-hero-title {
    font-family: var(--font-brand);
    font-size: clamp(34px, 3.8vw, 56px);
    font-weight: 500;
    letter-spacing: -1px;
    line-height: 1.05;
    margin: 0 0 12px 0;
}

.agent-hero-accent {
    display: block;
    color: #2a7a60; /* soft green accent like screenshot, but light theme */
    font-style: italic;
    font-weight: 500;
}

.agent-hero-subtitle {
    margin: 0;
    max-width: 70ch;
    color: var(--text-secondary);
    line-height: 1.65;
    font-size: 14.5px;
}

.agent-hero-ctas {
    display: flex;
    gap: 12px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.agent-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 12px;
    font-weight: 650;
    font-size: 14px;
    text-decoration: none;
    transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease, border-color 0.15s ease;
    user-select: none;
}

.agent-btn-primary {
    background: var(--text-primary);
    color: var(--bg-main);
    border: 1px solid rgba(0, 0, 0, 0.15);
}

.agent-btn-primary:hover {
    opacity: 0.92;
    transform: translateY(-1px);
}

.agent-btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid rgba(0, 0, 0, 0.16);
}

.agent-btn-secondary:hover {
    background: rgba(0, 0, 0, 0.03);
    transform: translateY(-1px);
}

.agent-hero-art {
    position: relative;
    min-height: 220px;
}

.agent-hero-orb {
    position: absolute;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    right: -70px;
    top: -60px;
    background: radial-gradient(circle at 30% 30%, rgba(42, 122, 96, 0.32), rgba(42, 122, 96, 0.08) 55%, rgba(0, 0, 0, 0) 70%);
    filter: blur(0.2px);
}

.agent-hero-orb-2 {
    width: 170px;
    height: 170px;
    right: -25px;
    top: 65px;
    background: radial-gradient(circle at 35% 35%, rgba(42, 122, 96, 0.22), rgba(42, 122, 96, 0.06) 55%, rgba(0, 0, 0, 0) 72%);
}

.agent-section {
    margin-top: 26px;
}

.agent-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.agent-section-eyebrow {
    font-size: 11px;
    font-weight: 800;
    color: var(--text-tertiary);
    letter-spacing: 0.9px;
    text-transform: uppercase;
}

.agent-models-section {
    padding: 18px 20px;
    background: var(--bg-light);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 16px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.04);
}

.agent-models-heading {
    margin: 0 0 8px 0;
    font-size: clamp(17px, 2.2vw, 20px);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
}

.agent-models-lead {
    margin: 0 0 14px 0;
    max-width: 75ch;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.55;
}

.agent-models-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 10px;
}

.agent-models-list li {
    margin: 0;
}

.agent-model-chip {
    display: inline-flex;
    align-items: center;
    padding: 6px 11px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 650;
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.035);
    border: 1px solid rgba(0, 0, 0, 0.1);
    letter-spacing: 0.01em;
}

.agent-features {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.agent-card {
    background: var(--bg-light);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.05);
}

.agent-card h3 {
    margin: 10px 0 6px 0;
    font-size: 14px;
    font-weight: 800;
    color: var(--text-primary);
}

.agent-card p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.55;
}

.agent-card-icon {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 14px;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.agent-card-icon-green { background: rgba(42, 122, 96, 0.12); color: #2a7a60; }
.agent-card-icon-amber { background: rgba(245, 158, 11, 0.14); color: #b45309; }
.agent-card-icon-blue  { background: rgba(74, 144, 217, 0.14); color: #3d7ec4; }

.agent-steps {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.agent-step {
    display: grid;
    grid-template-columns: 54px 1fr;
    gap: 14px;
    padding: 14px 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.agent-step-num {
    font-family: var(--font-ui);
    font-weight: 900;
    color: rgba(0, 0, 0, 0.35);
    font-size: 18px;
    letter-spacing: 0.6px;
}

.agent-step-title {
    font-weight: 800;
    color: var(--text-primary);
    font-size: 14px;
    margin-bottom: 2px;
}

.agent-step-text {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.55;
}

.agent-country-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.agent-country-btn {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    min-width: 120px;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.14);
    background: transparent;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 800;
    font-size: 13px;
    transition: background 0.15s ease, transform 0.15s ease;
}

.agent-country-btn span {
    font-weight: 700;
    color: var(--text-tertiary);
}

.agent-country-btn:hover {
    background: rgba(0, 0, 0, 0.03);
    transform: translateY(-1px);
}

.agent-howto {
    display: flex;
    flex-direction: column;
}

.agent-howto-item {
    display: grid;
    grid-template-columns: 40px 1fr;
    gap: 14px;
    padding: 14px 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.agent-howto-num {
    font-weight: 900;
    color: rgba(0, 0, 0, 0.4);
    font-size: 18px;
}

.agent-howto-title {
    font-weight: 850;
    color: var(--text-primary);
    font-size: 14px;
    margin-bottom: 2px;
}

.agent-howto-text {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.55;
}

@media (max-width: 900px) {
    .agent-hero {
        grid-template-columns: 1fr;
    }
    .agent-hero-art {
        min-height: 120px;
    }
    .agent-features {
        grid-template-columns: 1fr;
    }
}

/* Sidebar Navigation */
.sidebar-nav {
    padding: 0 8px;
    flex-shrink: 0;
    overflow: visible !important;
}

.nav-section {
    margin-bottom: 2px;
}

.nav-section-header {
    padding: 8px 12px 4px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-section-header h3 {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nav-section-toggle {
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: 14px;
    cursor: pointer;
    padding: 4px;
    transition: var(--transition);
    border-radius: 4px;
}

.nav-section-toggle:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.nav-section-content {
    display: flex;
    flex-direction: column;
    gap: 1px;
    overflow: visible;
}

/* Navigation Items */
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 400;
    cursor: pointer;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    transition: var(--transition);
    border-radius: var(--radius-sm);
    border-left: none;
}

.nav-item:hover {
    background-color: var(--bg-hover);
}

.nav-item.active {
    background-color: rgba(0, 0, 0, 0.06);
    font-weight: 500;
}

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

.sidebar-submenu-popover {
    position: absolute;
    left: calc(100% + 8px);
    top: 10px;
    background: #ffffff !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
    border-radius: var(--radius-sm);
    padding: 8px;
    display: none;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15) !important;
    min-width: 240px;
    z-index: 9999 !important;
    cursor: default;
}

.sidebar-submenu-popover::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -8px;
    width: 8px;
    background: transparent;
}

.nav-item.has-right-submenu:hover .sidebar-submenu-popover {
    display: flex !important;
}

.nav-icon {
    font-size: 16px;
    width: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.nav-label {
    flex: 1;
    font-size: 14px;
}

/* New Thread Button */
.sidebar-new-thread-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin: 4px 8px 12px;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 400;
    cursor: pointer;
    transition: var(--transition);
    width: calc(100% - 16px);
    text-align: left;
    font-family: var(--font-ui);
}

.sidebar-new-thread-btn:hover {
    background: var(--bg-hover);
}

.sidebar-new-thread-btn .icon {
    font-size: 18px;
    width: 20px;
    text-align: center;
}

/* Chat History Panel */
.chat-history-panel {
    flex: 1;
    padding: 4px 8px;
    overflow-y: auto;
}

.chat-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 8px 8px 12px;
}

.chat-history-header h3 {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-tertiary);
    letter-spacing: 0.5px;
}

.new-thread-btn {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 4px;
}

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

.new-thread-btn .icon {
    font-size: 14px;
}

/* Chat History List */
#chatHistoryList {
    list-style: none;
}

.chat-history-item {
    padding: 8px 12px;
    margin-bottom: 2px;
    background-color: transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    color: var(--text-primary);
    transition: var(--transition);
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    position: relative;
}

.chat-history-item:hover {
    background-color: var(--bg-hover);
}

.chat-history-item.active {
    background-color: rgba(0, 0, 0, 0.06);
    font-weight: 500;
}

.chat-history-item-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.chat-history-item-delete {
    opacity: 0;
    background-color: transparent;
    border: none;
    color: var(--error-color);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 13px;
    transition: var(--transition);
    flex-shrink: 0;
}

.chat-history-item:hover .chat-history-item-delete {
    opacity: 1;
}

.chat-history-item-delete:hover {
    background-color: rgba(239, 68, 68, 0.1);
}

.chat-history-empty {
    padding: 16px 12px;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 13px;
}

.chat-history-auth-prompt {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
    margin: 6px 8px 14px;
    padding: 14px 12px 12px;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    text-align: left;
}

.chat-history-auth-msg {
    margin: 0;
    line-height: 1.5;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.01em;
}

.chat-history-auth-prompt .auth-login-trigger {
    justify-content: center;
    font-weight: 600;
    background: var(--primary-accent);
    color: #fff;
    border: 1px solid var(--primary-accent);
    box-shadow: 0 1px 2px rgba(74, 144, 217, 0.25);
}

.chat-history-auth-prompt .auth-login-trigger:hover {
    background: #3d7ec4;
    border-color: #3d7ec4;
    color: #fff;
    box-shadow: 0 2px 10px rgba(74, 144, 217, 0.35);
}

.chat-history-auth-prompt .auth-login-trigger:active {
    transform: scale(0.99);
}

.chat-history-item-title {
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 13px;
}

.chat-history-item.active .chat-history-item-title {
    font-weight: 500;
}

.chat-history-item-date {
    font-size: 11px;
    color: var(--text-tertiary);
}

/* Stories Panel */
.stories-panel {
    flex: 1;
    padding: 4px 8px;
    overflow-y: auto;
}

.stories-header {
    padding: 4px 8px 8px 12px;
}

.stories-header h3 {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-tertiary);
    letter-spacing: 0.5px;
}

#storiesList {
    list-style: none;
}

.story-item {
    padding: 10px 12px;
    margin-bottom: 4px;
    background-color: transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    color: var(--text-primary);
    transition: var(--transition);
    border-left: 3px solid var(--primary-accent);
}

.story-item:hover {
    background-color: var(--bg-hover);
}

.story-item-title {
    font-weight: 500;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.story-item-excerpt {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.story-item-date {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.stories-loading {
    padding: 16px;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 13px;
}

.stories-error {
    padding: 12px;
    background-color: rgba(239, 68, 68, 0.06);
    border-radius: 6px;
    color: var(--error-color);
    font-size: 12px;
}

/* More Menu (popover above footer) */
.sidebar-more-menu {
    padding: 8px;
    margin: 0 8px;
    border-top: 1px solid var(--border-light);
    animation: fadeIn 0.15s ease;
}

.more-menu-item {
    display: block;
    padding: 8px 12px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.more-menu-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 12px 12px;
    border-top: 1px solid var(--border-light);
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-top: auto;
}

.sidebar-footer-btn {
    flex: 1;
    max-width: 100px;
    padding: 8px;
    background-color: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 16px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

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

/* Scrollbar Styling */
.sidebar::-webkit-scrollbar,
.chat-history-panel::-webkit-scrollbar,
.stories-panel::-webkit-scrollbar,
.nav-section-content::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track,
.chat-history-panel::-webkit-scrollbar-track,
.stories-panel::-webkit-scrollbar-track,
.nav-section-content::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb,
.chat-history-panel::-webkit-scrollbar-thumb,
.stories-panel::-webkit-scrollbar-thumb,
.nav-section-content::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 2px;
}

.sidebar::-webkit-scrollbar-thumb:hover,
.chat-history-panel::-webkit-scrollbar-thumb:hover,
.stories-panel::-webkit-scrollbar-thumb:hover,
.nav-section-content::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* ========================================
   Confirmation Modal
   ======================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    animation: slideUp 0.3s ease;
}

.subscription-modal {
    position: relative;
}

.subscription-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: transparent;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 6px 8px;
    line-height: 1;
    border-radius: 8px;
    transition: var(--transition);
}

.subscription-modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

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

.modal-header {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.modal-body {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.modal-btn {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    font-family: var(--font-ui);
}

.modal-btn-cancel {
    background-color: var(--secondary-color);
    color: var(--text-primary);
}

.modal-btn-cancel:hover {
    background-color: var(--border-color);
}

.modal-btn-confirm {
    background-color: var(--error-color);
    color: white;
}

.modal-btn-confirm:hover {
    background-color: #dc2626;
}

.modal-btn-primary {
    background-color: var(--primary-accent);
    color: #fff;
}

.modal-btn-primary:hover {
    background-color: #3d7ec4;
}

/* Guest leave chat — custom prompt instead of beforeunload */
.guest-leave-chat-overlay {
    z-index: 10020;
    backdrop-filter: blur(4px);
}

.guest-leave-chat-modal {
    max-width: 420px;
}

.guest-leave-chat-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
}

.guest-leave-chat-actions .modal-btn {
    width: 100%;
    justify-content: center;
    padding: 10px 16px;
}

.guest-leave-chat-btn-leave {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

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

/* ========================================
   Mobile Top Bar — Shared across all pages
   ======================================== */

/* Hidden on desktop by default */
.mobile-top-bar {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
    height: 56px;
    min-height: 56px;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    z-index: 12501;
    /* Subtle shadow for elevation */
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    /* Prevent bar from shrinking */
    flex-shrink: 0;
}

.mobile-top-bar-brand {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    max-width: calc(100% - 120px);
    /* Let edge buttons (hamburger / actions) receive taps even if the
       centered brand visually overlaps on very narrow screens. */
    pointer-events: none;
    overflow: hidden;
}

.mobile-logo {
    font-family: var(--font-brand);
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.3px;
    pointer-events: none;
    user-select: none;
    flex-shrink: 0;
}

/* Hamburger button */
.hamburger-menu {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    gap: 5px;
    background: none;
    border: none;
    /* 44×44 touch target */
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    padding: 0;
    z-index: 12502;
    flex-shrink: 0;
    transition: background 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.hamburger-menu:hover,
.hamburger-menu:focus-visible {
    background: var(--bg-hover);
    outline: none;
}

.hamburger-menu span {
    width: 22px;
    height: 2px;
    background-color: var(--text-primary);
    border-radius: 2px;
    transition: all 0.25s ease;
    display: block;
}

.hamburger-menu.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.hamburger-menu.active span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}

.hamburger-menu.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* New Chat / action button in mobile top bar */
.sidebar-new-chat-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--text-primary);
    color: var(--bg-main);
    border: none;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    font-weight: 300;
    flex-shrink: 0;
    transition: opacity 0.15s ease, transform 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    /* Ensure the icon is vertically centred */
    padding: 0;
}

.sidebar-new-chat-btn .icon {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    margin-top: -1px; /* optical correction for + sign */
}

.sidebar-new-chat-btn:hover,
.sidebar-new-chat-btn:focus-visible {
    opacity: 0.85;
    transform: scale(1.05);
    outline: none;
}

.sidebar-new-chat-btn:active {
    transform: scale(0.95);
}

/* Home/search icon button in mobile top bar (used on discover-family pages) */
.mobile-home-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--text-primary);
    color: var(--bg-main);
    text-decoration: none;
    flex-shrink: 0;
    transition: opacity 0.15s ease, transform 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.mobile-home-btn svg {
    color: var(--bg-main);
    stroke: var(--bg-main);
}

.mobile-home-btn:hover,
.mobile-home-btn:focus-visible {
    opacity: 0.85;
    transform: scale(1.05);
    outline: none;
}

.mobile-home-btn:active {
    transform: scale(0.95);
}

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

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
        height: 100dvh; /* use dynamic viewport height to avoid iOS address-bar gap */
        height: 100vh; /* fallback */
    }

    .hamburger-menu {
        display: flex;
    }

    .mobile-top-bar {
        display: flex;
    }

    .mobile-home-btn {
        display: flex;
    }

    .main-wrapper {
        position: relative;
        flex-direction: column;
        /* Fill the remaining height after the 56px top bar */
        height: calc(100dvh - 56px);
        height: calc(100vh - 56px); /* fallback */
        overflow: hidden;
    }

    .sidebar {
        position: fixed;
        left: 0;
        /* Start below the mobile top bar to avoid click/scroll conflicts */
        top: 56px;
        height: calc(100dvh - 56px);
        width: var(--sidebar-width);
        /* Must sit above the sticky top bar and overlay */
        z-index: 12000;
        transform: translateX(-100%);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.1);
        transition: transform 0.3s ease;
        background-color: var(--bg-sidebar);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .chat-container {
        flex: 1;
    }

    /* Overlay when sidebar is open */
    .sidebar-overlay {
        position: fixed;
        left: 0;
        top: 0;
        width: 100%;
        height: 100dvh;
        background-color: rgba(0, 0, 0, 0);
        /* Below the sticky top bar (11001), below sidebar (11000) */
        z-index: 11900;
        pointer-events: none;
        transition: background-color 0.3s ease;
    }

    .sidebar-overlay.active {
        background-color: rgba(0, 0, 0, 0.3);
        pointer-events: auto;
    }
}

@media (max-width: 480px) {
    .sidebar {
        width: 100%;
        max-width: 280px;
    }
}


/* AI Disclaimer Popup Styles */
.ai-disclaimer-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -40%);
    width: 90%;
    max-width: 450px;
    background: rgba(17, 18, 23, 0.9);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    padding: 28px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    z-index: 10000;
    display: none;
    flex-direction: column;
    gap: 16px;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.ai-disclaimer-popup.show {
    transform: translate(-50%, -50%);
    opacity: 1;
}

.disclaimer-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
    text-align: center;
}

.disclaimer-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: #f59e0b;
}

.disclaimer-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
}

.ai-disclaimer-popup p {
    margin: 0;
    font-size: 15px;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.9);
}

.disclaimer-footer {
    display: flex;
    justify-content: center;
    margin-top: 8px;
}

.dismiss-btn {
    background: #6366f1;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.dismiss-btn:hover {
    background: #4f46e5;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.dismiss-btn:active {
    transform: translateY(0);
}

/* Background overlay for centering */
.ai-disclaimer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9999;
    display: none;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.ai-disclaimer-overlay.show {
    display: block;
    opacity: 1;
}

@media (max-width: 480px) {
    .ai-disclaimer-popup {
        padding: 24px;
    }
}

/* ========================================
   Shared Finance Navigation & Sentiment
   ======================================== */

.finance-nav-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    gap: 16px;
    flex-wrap: nowrap;
}

.header-status-group {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.sentiment-widget {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.sentiment-main {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sentiment-bars {
    display: flex;
    gap: 2px;
}

.sentiment-widget.neutral .sentiment-label {
    color: #f59e0b; /* Amber for Neutral */
}

.sentiment-widget.neutral .sentiment-bars .bar.active {
    background: #f59e0b;
    opacity: 1;
}

.sentiment-bars .bar {
    width: 4px;
    height: 14px;
    background: rgba(0, 0, 0, 0.08); /* Better for Light Theme */
    border-radius: 2px;
}

.sentiment-label {
    font-size: 14px;
    font-weight: 600;
    color: #ff4d4d; /* Default red for Bearish */
}

.sentiment-meta {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 400;
}

.finance-mobile-nav {
    display: none;
}

.finance-nav-select {
    width: 100%;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font-ui);
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    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='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.finance-nav-select:focus {
    outline: none;
    border-color: #00b894;
}

@media (max-width: 768px) {
    .finance-nav-select {
        border: none;
        border-bottom: 2.5px solid var(--text-primary);
        border-radius: 0;
        background-color: transparent;
        padding: 10px 36px 10px 4px;
        font-size: 15px;
        font-weight: 700;
        box-shadow: none;
        background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='18' height='18' 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-position: right 4px center;
    }
    .finance-nav-select:focus {
        border-bottom-color: #00b894;
    }
}

@media (max-width: 768px) {
    .finance-sub-nav.desktop-nav,
    .finance-nav.desktop-nav {
        display: none !important;
    }
    .finance-mobile-nav {
        display: block;
    }
    .sentiment-meta,
    .status-market {
        display: none; /* Hide extra text to save space on mobile */
    }
    .sentiment-widget {
        min-width: auto;
        align-items: flex-end;
        gap: 2px;
    }
    .sentiment-main {
        gap: 5px;
    }
    .sentiment-label {
        font-size: 10px;
        font-weight: 600;
    }
    .sentiment-bars .bar {
        width: 3px;
        height: 10px;
    }
    .market-status-simple {
        font-size: 10px !important;
        gap: 4px !important;
    }
    .market-status-simple .status-dot {
        width: 6px !important;
        height: 6px !important;
    }
    .header-status-group {
        gap: 2px;
    }
}
