/* ============================================
   HoloDream Web App — Dark Theme
   ============================================ */

:root {
    --bg-primary: #0f0f14;
    --bg-secondary: #16161e;
    --bg-card: #1c1c28;
    --bg-input: #22222e;
    --bg-hover: #2a2a38;
    --border-color: rgba(255, 255, 255, 0.06);
    --border-light: rgba(255, 255, 255, 0.1);
    --text-primary: #f0f0f5;
    --text-secondary: #a0a0b0;
    --text-muted: #666680;
    --accent: #6366f1;
    --accent-hover: #5558e8;
    --accent-glow: rgba(99, 102, 241, 0.15);
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --user-bubble: #6366f1;
    --bot-bubble: #1c1c28;
    --sidebar-width: 240px;
    --topbar-height: 0px;
    --bottombar-height: 64px;
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'DM Sans', sans-serif;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
}

/* ---- Reset & Base ---- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    font-family: var(--font-body);
    font-size: 15px;
    color: var(--text-primary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    color: var(--accent-hover);
}

h1, h2, h3, h4, h5 {
    font-family: var(--font-heading);
    font-weight: 600;
}

/* ---- Loading Screen ---- */
.loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: var(--bg-primary);
}

.loading-logo {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 2rem;
}

.loading-progress {
    display: block;
    width: 5rem;
    height: 5rem;
}

.loading-progress circle {
    fill: none;
    stroke: var(--bg-card);
    stroke-width: 0.5rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--accent);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    margin-top: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Loading");
}

/* ---- Layout ---- */
.app-layout {
    display: flex;
    height: 100vh;
    height: 100dvh; /* dynamic viewport height — respects mobile browser chrome */
    overflow: hidden;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
}

.sidebar-logo {
    padding: 1.5rem 1.25rem;
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: linear-gradient(to right, #818cf8 0%, #c084fc 35%, #ec4899 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 12px rgba(139, 92, 246, 0.3));
}

.sidebar-logo span {
    font-weight: 400;
}

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0.5rem 0.75rem;
    gap: 0.25rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-weight: 500;
    transition: all 0.15s ease;
    cursor: pointer;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent-glow);
    color: var(--accent);
}

.nav-item .nav-icon {
    font-size: 1.25rem;
    width: 1.5rem;
    text-align: center;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.page-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.brand-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 2rem;
    letter-spacing: 0.5px;
    background: linear-gradient(to right, #818cf8 0%, #c084fc 35%, #ec4899 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 16px rgba(139, 92, 246, 0.25));
}

.brand-title span {
    font-weight: 400;
}

/* Discover header: brand + search icon on mobile */
.discover-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding-right: 96px; /* room for search + hamburger */
}

.discover-search {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
    background: var(--bg-input);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 99px;
    padding: 0.6rem 1rem;
    transition: border-color 0.2s;
}

.discover-search:focus-within {
    border-color: var(--accent);
}

.discover-search .search-icon {
    font-size: 0.9rem;
    opacity: 0.7;
    flex-shrink: 0;
}

.discover-search input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: var(--font-body);
}

.discover-search input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.search-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 0.25rem;
    flex-shrink: 0;
    transition: color 0.2s;
}

.search-close-btn:hover {
    color: var(--text-primary);
}

.page-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.6rem;
    color: var(--text-primary);
}

/* ---- Hamburger Menu (Upper Right) ---- */
.hamburger-menu {
    position: fixed;
    top: 0.75rem;
    right: 0.75rem;
    z-index: 200;
}

.hamburger-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.3rem;
    color: var(--text-primary);
    transition: background 0.2s;
}

.hamburger-btn:hover {
    background: var(--bg-hover);
}

.hamburger-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 199;
}

.hamburger-dropdown {
    position: absolute;
    top: 48px;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    min-width: 180px;
    padding: 0.5rem 0;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 201;
}

.hamburger-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.9rem;
    cursor: pointer;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    transition: background 0.15s;
}

.hamburger-item:hover {
    background: var(--bg-hover);
}

.hamburger-logout {
    color: var(--danger);
    border-top: 1px solid var(--border-color);
    margin-top: 0.25rem;
    padding-top: 0.65rem;
}

/* ---- Bottom Tab Bar (Mobile) ---- */
.bottom-tabs {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottombar-height);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    z-index: 100;
}

.bottom-tabs-inner {
    display: flex;
    height: 100%;
    align-items: center;
    justify-content: space-around;
}

.tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.15s ease;
}

.tab-item:hover, .tab-item.active {
    color: var(--accent);
}

.tab-item .tab-icon {
    font-size: 1.25rem;
}

/* ---- Topic Cards ---- */
.topics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
}

.topic-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.5rem;
}

.topic-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.topic-icon {
    font-size: 2rem;
}

.topic-name {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
}

.topic-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.3;
}

/* ---- Cards ---- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.card-body {
    padding: 1rem;
}

/* ---- Bot Card ---- */
.bot-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
}

.bot-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.bot-card .avatar {
    width: 112px;
    height: 112px;
    border-radius: 50%;
    object-fit: cover;
    object-position: center 10%;
    margin-bottom: 0.75rem;
}

.bot-card .bot-name {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}

.bot-card .bot-title {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.bot-card .category-badge {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 99px;
    font-size: 0.65rem;
    background: rgba(0, 0, 0, 0.7);
    color: #e0e0ff;
    backdrop-filter: blur(4px);
}

.bot-card .brain-badge {
    position: absolute;
    top: 2rem;
    right: 0.6rem;
    font-size: 1.4rem;
    line-height: 1;
    color: #ffd86b;
    text-shadow: 0 0 6px rgba(255, 216, 107, 0.9), 0 0 12px rgba(255, 180, 80, 0.5);
    cursor: default;
    pointer-events: auto;
}

/* ---- Bot Grid ---- */
.bot-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

/* ---- Featured Row ---- */
.featured-row {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding: 0.5rem 0;
    scrollbar-width: thin;
    scrollbar-color: var(--bg-hover) transparent;
}

.featured-row .bot-card {
    width: 240px;
    flex-shrink: 0;
}

/* ---- Category Chips ---- */
.category-chips {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    scrollbar-width: none;
    justify-content: center;
    flex-wrap: wrap;
}

.category-chips::-webkit-scrollbar {
    display: none;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border-radius: 99px;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.15s ease;
}

.chip:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.chip.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

/* ============================================================
   About Page — designed, not default-styled
   ============================================================ */
.about-page {
    /* Scroll container — must match .page-content behavior since
       .main-content has overflow:hidden and .app-layout is 100vh. */
    flex: 1;
    overflow-y: auto;
    padding: 0 1.25rem 5rem;
    line-height: 1.65;
}
.about-page > section,
.about-page > footer {
    max-width: 1080px;
    margin-left: auto;
    margin-right: auto;
}

/* ---- Hero ---- */
.about-hero {
    text-align: center;
    padding: 4rem 1rem 3rem;
    position: relative;
}
.about-hero-inner {
    max-width: 760px;
    margin: 0 auto;
}
.about-hero-eyebrow {
    display: inline-block;
    padding: 0.35rem 0.9rem;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    background: var(--accent-glow);
    color: var(--accent);
    margin-bottom: 1.5rem;
}
.about-hero-title {
    font-size: clamp(2rem, 5vw, 3.25rem);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.025em;
    margin: 0 0 1.25rem;
}
.about-hero-title-grad {
    background: linear-gradient(135deg, #ff6b9d 0%, #ffd86b 33%, #4fd1c5 66%, #b794f6 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.about-hero-lede {
    font-size: 1.15rem;
    color: var(--text-secondary);
    max-width: 640px;
    margin: 0 auto;
}

/* ---- Stats band ---- */
.about-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    padding: 1.5rem;
    margin: 1.5rem 0 3.5rem;
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(183, 148, 246, 0.08) 100%);
    border: 1px solid rgba(99, 102, 241, 0.15);
}
.about-stat {
    text-align: center;
    padding: 0.75rem;
}
.about-stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0.5rem;
    letter-spacing: -0.03em;
}
.about-stat-number-grad {
    background: linear-gradient(135deg, #ff6b9d 0%, #b794f6 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.about-stat-plus {
    color: var(--accent);
}
.about-stat-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.4;
}
.about-sparkle-lg {
    background: linear-gradient(135deg, #ff6b9d 0%, #ffd86b 33%, #4fd1c5 66%, #b794f6 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-size: 2.5rem;
    display: inline-block;
    filter: drop-shadow(0 0 12px rgba(255, 216, 107, 0.35));
}
.about-sparkle-med {
    background: linear-gradient(135deg, #ff6b9d 0%, #ffd86b 33%, #4fd1c5 66%, #b794f6 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-size: 1.6rem;
}
.about-sparkle-inline {
    background: linear-gradient(135deg, #ff6b9d 0%, #ffd86b 33%, #4fd1c5 66%, #b794f6 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-weight: 700;
}

/* ---- Feature cards ---- */
.about-features {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
    margin-bottom: 4rem;
}
.about-card {
    background: var(--bg-card, rgba(255, 255, 255, 0.03));
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    padding: 1.75rem;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.about-card:hover {
    transform: translateY(-2px);
    border-color: rgba(99, 102, 241, 0.3);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.08);
}
.about-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    margin-bottom: 1rem;
    background: rgba(99, 102, 241, 0.1);
}
.about-card-icon-a { background: rgba(255, 107, 157, 0.12); }
.about-card-icon-b { background: rgba(255, 216, 107, 0.14); }
.about-card-icon-c { background: rgba(79, 209, 197, 0.14); }
.about-card-icon-d { background: rgba(183, 148, 246, 0.14); }
.about-card-icon-e { background: rgba(99, 102, 241, 0.14); }
.about-card-icon-f { background: rgba(251, 146, 60, 0.14); }
.about-card h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 0.65rem;
    letter-spacing: -0.01em;
}
.about-card p {
    margin: 0 0 0.75rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
}
.about-card p:last-child { margin-bottom: 0; }

/* ---- CTA band ---- */
.about-cta {
    text-align: center;
    padding: 3rem 1.5rem;
    margin-bottom: 3rem;
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(183, 148, 246, 0.12) 100%);
    border: 1px solid rgba(99, 102, 241, 0.15);
}
.about-cta-title {
    font-size: 1.6rem;
    font-weight: 700;
    margin: 0 0 0.75rem;
    letter-spacing: -0.02em;
}
.about-cta-sub {
    color: var(--text-secondary);
    max-width: 560px;
    margin: 0 auto 1.75rem;
}
.about-cta-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}
.about-btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border-radius: 99px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    font-family: inherit;
    text-decoration: none;
    line-height: 1.2;
    transition: transform 0.15s ease, filter 0.15s ease, box-shadow 0.2s ease;
}
.about-btn-primary { text-decoration: none; }
.about-btn-secondary { text-decoration: none; }
.about-btn-secondary:visited { color: var(--text-primary); }
.about-btn-primary {
    background: linear-gradient(135deg, #6366f1 0%, #b794f6 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.3);
}
.about-btn-primary:hover { transform: translateY(-1px); filter: brightness(1.05); box-shadow: 0 6px 18px rgba(99, 102, 241, 0.4); }
.about-btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.2);
}
.about-btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

/* ---- Footer ---- */
.about-footer {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.88rem;
    padding-top: 1rem;
}
.about-footer a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.15s;
}
.about-footer a:hover { color: var(--accent); }
.about-footer-dot {
    margin: 0 0.6rem;
    opacity: 0.5;
}

/* ---- Light-theme adjustments ---- */
html.light-theme .about-card {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.08);
}
html.light-theme .about-card:hover {
    border-color: rgba(99, 102, 241, 0.4);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.1);
}
html.light-theme .about-stats,
html.light-theme .about-cta {
    border-color: rgba(99, 102, 241, 0.2);
}
html.light-theme .about-btn-secondary {
    border-color: rgba(0, 0, 0, 0.15);
}

/* ---- Responsive ---- */
@media (max-width: 720px) {
    .about-features {
        grid-template-columns: 1fr;
    }
    .about-stats {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    .about-hero {
        padding: 2.5rem 0.5rem 2rem;
    }
    .about-hero-title {
        font-size: 2rem;
    }
    .about-card {
        padding: 1.35rem;
    }
}

/* ---- Logged-out CTA nav item (sidebar) ---- */
.nav-item.nav-item-cta {
    background: var(--accent);
    color: white;
    border: none;
    margin-top: 0.5rem;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
}
.nav-item.nav-item-cta:hover {
    filter: brightness(1.1);
}

/* ---- Logged-out Log In button in bottom tabs (mobile) ---- */
.tab-item.tab-item-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

/* "All" chip florette — rainbow gradient clipped to glyph */
.all-florette {
    background: linear-gradient(135deg, #ff6b9d 0%, #ffd86b 33%, #4fd1c5 66%, #b794f6 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-size: 1.1em;
    font-weight: 600;
    line-height: 1;
    display: inline-block;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.7rem 1.5rem;
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
    border-color: var(--border-light);
    background: var(--bg-hover);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-full {
    width: 100%;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

/* ---- Inputs ---- */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-input {
    width: 100%;
    padding: 0.7rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.15s ease;
}

.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input::placeholder {
    color: var(--text-muted);
}

textarea.form-input {
    resize: vertical;
    min-height: 80px;
}

select.form-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a0a0b0' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
}

/* ---- Chat ---- */
.chat-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 3.5rem 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.chat-header .avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    object-position: center 10%;
}

.chat-header .bot-info {
    flex: 1;
}

.chat-header .bot-info h3 {
    font-size: 1rem;
    margin: 0;
}

.chat-header .bot-info span {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.chat-back-btn {
    display: none;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.3rem;
    padding: 0.25rem;
    cursor: pointer;
    margin-right: -0.25rem;
}

.chat-header .voice-btn {
    background: none;
    border: 2px solid #22c55e;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #22c55e;
    cursor: pointer;
    font-size: 1.1rem;
}

.chat-header .voice-btn.active {
    background: #22c55e;
    border-color: #22c55e;
    color: white;
}

.chat-header .favorite-btn {
    background: none;
    border: 2px solid var(--text-muted);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.1rem;
}

.chat-header .favorite-btn.favorited {
    border-color: #f59e0b;
    color: #f59e0b;
}

.chat-header .share-btn {
    background: none;
    border: 2px solid var(--accent);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    cursor: pointer;
    font-size: 1.1rem;
}

/* ---- Scene Cards ---- */
.scene-card {
    cursor: pointer;
}

.scene-card .bot-name {
    font-size: 0.95rem;
}

.scene-card .bot-title {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-style: italic;
}

.scene-difficulty {
    display: inline-block;
    font-size: 0.65rem;
    padding: 0.15rem 0.5rem;
    border-radius: 99px;
    margin-top: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.scene-difficulty.easy {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.scene-difficulty.medium {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.scene-difficulty.hard, .scene-difficulty.very.hard {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

/* ---- Scene List on Bot Cards ---- */
.bot-card.has-scenes .bot-card-main {
    cursor: pointer;
}

.scene-list {
    padding: 0.25rem 0.5rem 0.5rem;
    border-top: 1px solid var(--border);
}

.scene-link {
    display: block;
    padding: 0.3rem 0.4rem;
    font-size: 0.78rem;
    color: var(--accent);
    cursor: pointer;
    border-radius: 4px;
    text-decoration: none;
}

.scene-link:hover {
    background: var(--bg-hover);
}

/* ---- Scene Presets in Modal ---- */
.scene-preset-btn {
    text-align: left;
    padding: 0.6rem 0.8rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.88rem;
    transition: all 0.15s;
}

.scene-preset-btn:hover {
    border-color: var(--accent);
    background: var(--bg-hover);
}

.scene-preset-btn.active {
    border-color: var(--accent);
    background: rgba(139, 92, 246, 0.1);
    color: var(--accent);
}

/* ---- Mood Indicator ---- */
.mood-indicator {
    text-align: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    cursor: pointer;
    transition: background 0.15s;
}

.mood-indicator:hover {
    background: var(--bg-hover);
}

/* ---- Mood Grid ---- */
.mood-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.mood-chip {
    padding: 0.4rem 0.8rem;
    border-radius: 99px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.15s;
}

.mood-chip:hover {
    border-color: var(--accent);
}

.mood-chip.selected {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

/* ---- Diary Posts ---- */
.diary-post-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
}

.diary-post-date {
    display: block;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.diary-post-preview {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0.5rem 0 0;
    line-height: 1.4;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 0.25rem;
    opacity: 0.6;
    transition: opacity 0.15s;
}

.btn-icon:hover {
    opacity: 1;
}

.bot-profile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.bot-profile-card {
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    max-width: 380px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    text-align: center;
}

/* Category chip pinned to the upper-right of profile cards (modal + profile page). */
.profile-card-category {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    padding: 0.25rem 0.65rem;
    border-radius: 99px;
    font-size: 0.7rem;
    background: rgba(0, 0, 0, 0.55);
    color: #e0e0ff;
    backdrop-filter: blur(4px);
    line-height: 1.2;
    white-space: nowrap;
}

html.light-theme .profile-card-category {
    background: rgba(255, 255, 255, 0.85);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.bot-profile-tagline {
    font-style: italic;
    color: var(--accent);
    font-size: 1rem;
    margin: 0.25rem 0 0.25rem;
    padding: 0 0.5rem;
    line-height: 1.35;
}
.bot-profile-bio {
    color: var(--text-primary);
    font-size: 0.95rem;
    margin: 0.25rem 0 0.5rem;
    padding: 0 0.5rem;
    line-height: 1.5;
}
.bot-profile-title {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.bot-profile-card img {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    object-fit: cover;
    object-position: center 10%;
    border: 3px solid var(--border-color);
}

.bot-profile-card h2 {
    margin: 0;
    font-size: 1.4rem;
}

.bot-profile-card span {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.bot-profile-card button {
    margin-top: 0.5rem;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.message {
    max-width: 80%;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-lg);
    line-height: 1.5;
    font-size: 0.9rem;
    word-wrap: break-word;
}

.message.user {
    align-self: flex-end;
    background: var(--user-bubble);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.assistant {
    align-self: flex-start;
    background: var(--bot-bubble);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.chat-image {
    max-width: 200px;
    max-height: 200px;
    border-radius: var(--radius-sm);
    margin-bottom: 0.4rem;
    display: block;
}

/* Placeholder shown while the bot's image is being generated server-side.
   Replaces the <img> until the 'image_ready' SSE event arrives. */
.image-pending {
    width: 200px;
    height: 200px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(167, 92, 246, 0.12));
    border: 1px dashed rgba(167, 139, 250, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.image-pending .image-pending-label {
    font-size: 0.85em;
    color: var(--text-muted);
}

/* ---- Typing dots indicator ---- */
.typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 0;
}

.typing-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: typing-bounce 1.4s ease-in-out infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing-bounce {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-4px); }
}

/* Share snippet selection mode */
.message-wrapper { position: relative; cursor: pointer; border-radius: var(--radius-lg); padding: 2px; transition: background 0.15s; }
.message-wrapper:hover { background: rgba(99, 102, 241, 0.05); }
.message-wrapper.selected { background: rgba(99, 102, 241, 0.1); outline: 2px solid rgba(99, 102, 241, 0.4); border-radius: var(--radius-lg); }

/* ---- Per-message 3-dot menu (hover-reveal) ---- */
.chat-msg-row {
    display: flex;
    align-items: center;
    position: relative;
    gap: 0.25rem;
}
.chat-msg-row.user-row { justify-content: flex-end; }
.chat-msg-row.assistant-row { justify-content: flex-start; }

/* User's own messages: menu button goes to the LEFT of the bubble (outside edge) */
.chat-msg-row.user-row .msg-menu-wrapper { order: -1; }
/* Assistant messages: menu button goes to the RIGHT of the bubble */
.chat-msg-row.assistant-row .msg-menu-wrapper { order: 2; }

.msg-menu-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
}
.msg-menu-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.15rem;
    line-height: 1;
    padding: 0.15rem 0.4rem;
    border-radius: 99px;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s;
}
.chat-msg-row:hover .msg-menu-btn { opacity: 0.55; }
.msg-menu-btn:hover { opacity: 1 !important; background: rgba(128, 128, 128, 0.12); }
/* Touch devices: always show the button, since there's no hover */
@media (hover: none) {
    .msg-menu-btn { opacity: 0.4; }
}

.msg-menu-overlay {
    position: fixed;
    inset: 0;
    z-index: 40;
}
.msg-menu-dropdown {
    position: absolute;
    top: 100%;
    margin-top: 0.25rem;
    background: var(--bg-card, #fff);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
    z-index: 50;
    min-width: 170px;
    overflow: hidden;
}
.chat-msg-row.user-row .msg-menu-dropdown { right: 0; }
.chat-msg-row.assistant-row .msg-menu-dropdown { left: 0; }

.msg-menu-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.9rem;
    background: none;
    border: none;
    color: var(--text-primary);
    text-align: left;
    font-size: 0.88rem;
    cursor: pointer;
}
.msg-menu-item:hover { background: rgba(99, 102, 241, 0.08); }
.msg-menu-item span { font-size: 0.95rem; opacity: 0.75; }

html:not(.light-theme) .msg-menu-dropdown {
    background: #1a1a22;
    border-color: rgba(255, 255, 255, 0.1);
}
html:not(.light-theme) .msg-menu-item { color: var(--text-primary); }
html:not(.light-theme) .msg-menu-item:hover { background: rgba(99, 102, 241, 0.15); }
.selection-badge { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; background: var(--accent); color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.7rem; font-weight: 700; }
.selection-toolbar { padding: 0.75rem 1rem; border-top: 1px solid var(--border-color); background: var(--bg-secondary); display: flex; gap: 0.75rem; align-items: center; justify-content: space-between; }

.chat-input-area {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.chat-input-area .form-input {
    flex: 1;
}

.chat-input-area .send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    flex-shrink: 0;
}

.chat-input-area .send-btn:hover:not(:disabled) {
    background: var(--accent-hover);
}

.chat-input-area .send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Voice-mode (telephone) button — primary CTA for monetization, so visually
   distinct from the rest of the input bar. Filled green circle in default
   state ("call this character"); switches to red while a voice call is
   active to suggest "tap to hang up". */
.chat-input-area .voice-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 50%;
    background: #22c55e;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 1px 3px rgba(34, 197, 94, 0.35);
}

.chat-input-area .voice-btn:hover:not(:disabled) {
    background: #16a34a;
    transform: scale(1.05);
}

.chat-input-area .voice-btn.active {
    background: #dc2626;
    box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.2);
}

.chat-input-area .voice-btn.active:hover:not(:disabled) {
    background: #b91c1c;
}

.chat-input-area .voice-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.image-upload-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 50%;
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    font-size: 1.35rem;
    line-height: 1;
    padding-bottom: 7px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
    position: relative;
    overflow: hidden;
}

.image-upload-btn input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.image-upload-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.welcome-message {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
}

.welcome-message .avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    object-position: center 10%;
    margin-bottom: 1rem;
}

/* ---- Voice Mode ---- */
.voice-overlay {
    position: absolute;
    inset: 0;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 12%;
    z-index: 50;
}

.voice-visualizer-container {
    position: relative;
    width: 340px;
    height: 340px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#voice-visualizer-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 340px;
    height: 340px;
}

.voice-avatar {
    position: relative;
    width: 196px;
    height: 196px;
    border-radius: 50%;
    object-fit: cover;
    object-position: center 10%;
    border: 3px solid var(--accent);
    z-index: 1;
    box-shadow: 0 0 24px rgba(99, 102, 241, 0.3);
}

.voice-status {
    margin-top: 1.5rem;
    font-size: 1rem;
    color: var(--text-secondary);
}

.voice-action-btn {
    margin-top: 1.5rem;
    min-width: 160px;
}

.voice-close-btn {
    margin-top: 1rem;
}

/* ---- Debug Menu ---- */
.debug-menu-wrapper {
    position: relative;
}

.debug-menu-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
    letter-spacing: 1px;
}

.debug-menu-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.debug-menu-dropdown {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    min-width: 200px;
    padding: 0.5rem 0;
    z-index: 60;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.4);
}

.debug-menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1rem;
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.1s;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    font-family: var(--font-body);
}

.debug-menu-item:hover {
    background: var(--bg-hover);
}

.debug-menu-item:disabled {
    color: var(--text-muted);
    cursor: not-allowed;
}

.debug-menu-item .check {
    color: var(--accent);
    font-weight: bold;
}

/* ---- Stats Panel ---- */
.stats-panel {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    max-height: 380px;
    overflow-y: auto;
    z-index: 51;
    position: relative;
}

.stats-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stats-label {
    color: var(--text-secondary);
}

.stats-value {
    font-weight: 600;
    font-family: monospace;
    color: var(--text-primary);
}

.stats-value.yes { color: var(--success); }
.stats-value.no { color: var(--danger); }

.stats-divider {
    border-top: 1px solid var(--border-color);
    margin: 0.25rem 0;
}

.stats-slider-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.stats-slider-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stats-slider-row label {
    flex: 1;
    color: var(--text-secondary);
    font-size: 0.8rem;
    white-space: nowrap;
}

.stats-slider-row input[type="range"] {
    flex: 2;
    accent-color: var(--accent);
    height: 4px;
}

.stats-slider-row .slider-value {
    min-width: 55px;
    text-align: right;
    font-family: monospace;
    font-size: 0.8rem;
    color: var(--text-primary);
}

.level-meter-container {
    height: 8px;
    background: var(--bg-input);
    border-radius: 4px;
    overflow: hidden;
}

.level-meter-bar {
    height: 100%;
    width: 0%;
    border-radius: 4px;
    transition: width 0.08s linear;
    background: var(--warning);
}

.stats-select {
    width: 100%;
    padding: 0.35rem 0.5rem;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    cursor: pointer;
}

.stats-btn {
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    cursor: pointer;
    transition: opacity 0.15s;
}

.stats-btn:hover { opacity: 0.85; }

.stats-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.stats-actions button {
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.stats-actions button:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
}

.stats-actions button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ---- Tap Talk Button ---- */
.tap-talk-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: none;
    border: 2px solid var(--success);
    color: var(--success);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}

.tap-talk-btn:hover {
    background: rgba(34, 197, 94, 0.1);
}

.tap-talk-btn.recording {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
    animation: pulse-mic 1s ease-in-out infinite;
}

@keyframes pulse-mic {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { transform: scale(1.05); box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

/* ---- Voice Transcript in Overlay ---- */
.voice-transcript {
    position: absolute;
    bottom: 80px;
    left: 1rem;
    right: 1rem;
    max-height: 180px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.75rem;
    background: rgba(15, 15, 20, 0.85);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.voice-transcript .message {
    max-width: 100%;
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
}

/* ---- Auth Pages ---- */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-primary);
    padding: 2rem;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 2.5rem;
}

.auth-logo {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
    text-align: center;
    margin-bottom: 0.5rem;
}

.auth-subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

.auth-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    color: var(--danger);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.auth-links {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.auth-links a {
    font-weight: 600;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.25rem 0;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.btn-google {
    background: #fff;
    color: #3c4043;
    border: 1px solid #dadce0;
    font-weight: 500;
    gap: 0.75rem;
}

.btn-google:hover:not(:disabled) {
    background: #f7f8f8;
    border-color: #c6c6c6;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.btn-google .google-icon {
    flex-shrink: 0;
}

/* ---- Section Headers ---- */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.section-header h2 {
    font-size: 1.2rem;
}

.section-header .see-all {
    font-size: 0.85rem;
    color: var(--accent);
    cursor: pointer;
}

/* ---- Modal ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 1rem;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 2rem;
    max-width: 420px;
    width: 100%;
}

.modal-content h3 {
    font-size: 1.2rem;
    margin-bottom: 0.75rem;
}

.modal-content p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 1.5rem;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

/* Chat Break form */
.chat-break-form {
    margin-bottom: 0.5rem;
}

.chat-break-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
    cursor: pointer;
}

.chat-break-input {
    width: 70px;
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.95rem;
    text-align: center;
}

.chat-break-input:disabled {
    opacity: 0.4;
}

/* ---- Reply Length Options ---- */
.reply-length-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.reply-length-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    text-align: left;
    color: var(--text-primary);
    font-family: var(--font-body);
}

.reply-length-option:hover {
    background: var(--bg-hover);
}

.reply-length-option.active {
    border-color: var(--accent);
    background: var(--accent-glow);
}

.reply-length-label {
    font-weight: 600;
    font-size: 0.9rem;
    min-width: 65px;
}

.reply-length-desc {
    flex: 1;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.reply-length-check {
    color: var(--accent);
    font-weight: 700;
    font-size: 1rem;
}

/* ---- Toast ---- */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 500;
    animation: slideIn 0.3s ease;
    max-width: 360px;
}

.toast.success {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: var(--success);
}

.toast.error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--danger);
}

.toast.info {
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: var(--accent);
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ---- Avatar Selector ---- */
.avatar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
    gap: 0.75rem;
}

.avatar-option {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    cursor: pointer;
    border: 3px solid transparent;
    transition: border-color 0.15s;
}

.avatar-option:hover {
    border-color: var(--border-light);
}

.avatar-option.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ---- Account / Admin Table-like ---- */
.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.stat-value {
    font-weight: 600;
    font-size: 0.9rem;
}

.stat-value.good {
    color: var(--success);
}

.stat-value.warning {
    color: var(--warning);
}

.stat-value.danger {
    color: var(--danger);
}

/* ---- Config/Tier List Items ---- */
.list-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: border-color 0.15s;
}

.list-item:hover {
    border-color: var(--accent);
}

.list-item .item-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.list-item .item-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.list-item .active-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 99px;
    font-size: 0.7rem;
    font-weight: 600;
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

/* ---- Quota Bar ---- */
.quota-bar {
    height: 6px;
    background: var(--bg-input);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 0.25rem;
}

.quota-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* ---- Spinner ---- */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ---- Error UI ---- */
#blazor-error-ui {
    background: var(--bg-card);
    border-top: 2px solid var(--danger);
    bottom: 0;
    box-sizing: border-box;
    color: var(--text-primary);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
    color: var(--text-secondary);
}

.blazor-error-boundary {
    background: var(--danger);
    padding: 1rem;
    color: white;
    border-radius: var(--radius-md);
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

/* ---- Plan Cards ---- */
.plans-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.plan-card {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    transition: border-color 0.2s;
}

.plan-card.plan-pro {
    border-color: var(--accent);
}

.plan-card.plan-ultimate {
    border: double 2px transparent;
    background-image: linear-gradient(var(--bg-card), var(--bg-card)),
                      linear-gradient(135deg, #8b5cf6, #ec4899);
    background-origin: border-box;
    background-clip: padding-box, border-box;
    box-shadow: 0 0 16px rgba(139, 92, 246, 0.2), 0 0 32px rgba(236, 72, 153, 0.1);
}

.plan-card.plan-current {
    border-color: var(--success);
}

.plan-popular-tag {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.75rem;
    border-radius: 10px;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.plan-header {
    text-align: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.plan-header h3 {
    margin: 0 0 0.5rem;
    font-size: 1.1rem;
}

.plan-price {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 2px;
}

.price-amount {
    font-size: 1.75rem;
    font-weight: 700;
}

.price-period {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.plan-features {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem;
    flex: 1;
}

.plan-features li {
    padding: 0.35rem 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.plan-features li::before {
    content: "\2713\00a0";
    color: var(--success);
    font-weight: 600;
}

.plan-badge {
    text-align: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--success);
    padding: 0.5rem;
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: var(--radius-md);
    background: rgba(34, 197, 94, 0.08);
}

.plan-cta {
    width: 100%;
}

@media (max-width: 768px) {
    .plans-grid {
        grid-template-columns: 1fr;
    }
}

/* ---- Light Theme Override ---- */
html.light-theme {
    --bg-primary: #f5f5f7;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-input: #f0f0f2;
    --bg-hover: #e8e8ec;
    --border-color: rgba(0, 0, 0, 0.08);
    --border-light: rgba(0, 0, 0, 0.12);
    --text-primary: #1a1a2e;
    --text-secondary: #555566;
    --text-muted: #8e8e93;
    --user-bubble: #6366f1;
    --bot-bubble: #e5e5ea;
}

html.light-theme body {
    color: var(--text-primary);
}

html.light-theme .discover-search {
    border-color: rgba(0, 0, 0, 0.2);
}

html.light-theme .discover-search input::placeholder {
    color: rgba(0, 0, 0, 0.4);
}

html.light-theme .bot-card .category-badge {
    background: rgba(255, 255, 255, 0.85);
    color: #333;
}

/* ---- Toggle Switch ---- */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-hover);
    border-radius: 26px;
    transition: 0.3s;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--accent);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(22px);
}

/* ---- Responsive Helpers ---- */
.mobile-only { display: none; }
.desktop-only { display: block; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .mobile-only { display: block; }
    .desktop-only { display: none; }
    .sidebar {
        display: none;
    }

    .bottom-tabs {
        display: block;
    }

    .main-content {
        padding-bottom: var(--bottombar-height);
    }

    /* Chat page: full-screen takeover on mobile */
    .chat-container {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 200;
        background: var(--bg-primary);
    }

    .chat-back-btn {
        display: flex;
    }

    .bot-grid {
        grid-template-columns: repeat(2, 1fr);
        justify-content: stretch;
    }

    .message {
        max-width: 90%;
    }

    .page-content {
        padding: 1rem;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    :root {
        --sidebar-width: 200px;
    }

}
