/**
 * SeanceAI - Cosmic Celestial Theme
 * Deep Space Mysticism & Starlight Design System
 */

/* ===== Google Fonts Import ===== */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;500;600;700&family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;1,400;1,500&family=Inter:wght@300;400;500;600&family=Space+Mono:wght@400;700&display=swap');

/* ===== CSS Variables - Cosmic Palette ===== */
:root {
    /* Void & Deep Space */
    --void-black: #000000;
    --deep-space: #050510;
    --nebula-dark: #0a0a1a;
    --cosmic-night: #0d0d20;

    /* Stellar Purples */
    --stellar-purple: #4b0082;
    --nebula-violet: #7b2cbf;
    --cosmic-magenta: #9d4edd;

    /* Midnight Blues */
    --midnight-blue: #1a1a4a;
    --cosmic-blue: #0066cc;
    --starlight-blue: #4fc3f7;
    --aurora-cyan: #00ffff;

    /* Stellar Golds */
    --stellar-gold: #ffd700;
    --ancient-gold: #d4af37;
    --gold-glow: rgba(255, 215, 0, 0.3);

    /* Backgrounds */
    --bg-primary: var(--void-black);
    --bg-secondary: var(--deep-space);
    --bg-tertiary: var(--nebula-dark);
    --bg-card: rgba(10, 10, 26, 0.85);
    --bg-hover: rgba(75, 0, 130, 0.2);
    --bg-glass: rgba(10, 10, 26, 0.7);

    /* Text - Blue-tinted whites */
    --text-primary: #f0f0ff;
    --text-secondary: rgba(240, 240, 255, 0.7);
    --text-muted: rgba(240, 240, 255, 0.5);
    --text-tertiary: rgba(240, 240, 255, 0.3);

    /* Accent Colors */
    --accent-blue: var(--starlight-blue);
    --accent-blue-hover: var(--aurora-cyan);
    --accent-blue-light: rgba(79, 195, 247, 0.15);
    --accent-purple: var(--nebula-violet);
    --accent-gold: var(--stellar-gold);
    --accent-gold-dim: var(--ancient-gold);
    --accent-gold-bright: #ffed4a;

    /* Borders */
    --border-subtle: rgba(123, 44, 191, 0.2);
    --border-accent: rgba(79, 195, 247, 0.3);
    --border-divider: rgba(240, 240, 255, 0.08);
    --border-glow: rgba(157, 78, 221, 0.5);

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.7);
    --shadow-xl: 0 12px 48px rgba(0, 0, 0, 0.8);
    --shadow-glow: 0 0 30px rgba(75, 0, 130, 0.4);
    --shadow-stellar: 0 0 40px rgba(255, 215, 0, 0.2);
    --shadow-purple: 0 0 30px rgba(123, 44, 191, 0.3);
    --shadow-cyan: 0 0 20px rgba(0, 255, 255, 0.2);

    /* Typography */
    --font-display: 'Cinzel', Georgia, serif;
    --font-elegant: 'Cormorant Garamond', Georgia, serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'Space Mono', 'Courier New', monospace;
    --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    --space-3xl: 4rem;

    /* Border radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: 600ms cubic-bezier(0.68, -0.55, 0.265, 1.55);

    /* Glassmorphism */
    --glass-bg: rgba(10, 10, 26, 0.75);
    --glass-border: rgba(123, 44, 191, 0.2);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

/* ===== Light Mode (Cosmic Light) ===== */
body.light-mode {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-tertiary: #0f3460;
    --bg-card: rgba(22, 33, 62, 0.9);
    --bg-hover: rgba(75, 0, 130, 0.15);
    --bg-glass: rgba(22, 33, 62, 0.8);

    --text-primary: #e8e8ff;
    --text-secondary: rgba(232, 232, 255, 0.8);
    --text-muted: rgba(232, 232, 255, 0.6);
    --text-tertiary: rgba(232, 232, 255, 0.4);

    --border-subtle: rgba(79, 195, 247, 0.25);
    --border-accent: rgba(79, 195, 247, 0.4);

    --glass-bg: rgba(22, 33, 62, 0.85);
    --glass-border: rgba(79, 195, 247, 0.25);
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    position: relative;
}

/* ===== Cosmic Background ===== */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(75, 0, 130, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(0, 102, 204, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(123, 44, 191, 0.08) 0%, transparent 70%),
        linear-gradient(180deg, var(--deep-space) 0%, var(--void-black) 50%, var(--nebula-dark) 100%);
    z-index: -2;
    animation: nebulaShift 60s ease-in-out infinite;
}

@keyframes nebulaShift {
    0%, 100% {
        filter: hue-rotate(0deg);
    }
    50% {
        filter: hue-rotate(30deg);
    }
}

/* ===== Star Field ===== */
#star-field {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

.star {
    position: absolute;
    border-radius: 50%;
    animation: twinkle var(--twinkle-duration, 3s) ease-in-out infinite;
    animation-delay: var(--twinkle-delay, 0s);
}

@keyframes twinkle {
    0%, 100% {
        opacity: var(--star-opacity, 0.5);
        transform: scale(1);
    }
    50% {
        opacity: calc(var(--star-opacity, 0.5) * 1.5);
        transform: scale(1.2);
    }
}

/* ===== Shooting Stars ===== */
.shooting-star {
    position: fixed;
    width: 100px;
    height: 1px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.8) 50%, rgba(79, 195, 247, 0.8) 100%);
    transform: rotate(-45deg);
    animation: shootingStar 6s ease-in-out infinite;
    opacity: 0;
    z-index: -1;
}

.shooting-star:nth-child(1) {
    top: 10%;
    left: 80%;
    animation-delay: 0s;
}

.shooting-star:nth-child(2) {
    top: 30%;
    left: 90%;
    animation-delay: 3s;
}

.shooting-star:nth-child(3) {
    top: 50%;
    left: 70%;
    animation-delay: 7s;
}

@keyframes shootingStar {
    0% {
        opacity: 0;
        transform: translateX(0) translateY(0) rotate(-45deg);
    }
    5% {
        opacity: 1;
    }
    15% {
        opacity: 0;
        transform: translateX(-300px) translateY(300px) rotate(-45deg);
    }
    100% {
        opacity: 0;
        transform: translateX(-300px) translateY(300px) rotate(-45deg);
    }
}

/* ===== Particles / Atmospheric Effects ===== */
.particles-container {
    display: none;
}

.fog-layer {
    display: none;
}

/* ===== Constellation Canvas ===== */
#constellation-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.4;
}

/* ===== App Container ===== */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-lg);
    position: relative;
    z-index: 1;
}

/* ===== Cosmic Header ===== */
.main-header {
    text-align: center;
    padding: var(--space-2xl) var(--space-md) var(--space-xl);
    margin-bottom: var(--space-2xl);
    position: relative;
}

/* Header Actions */
.header-actions {
    position: absolute;
    top: var(--space-lg);
    right: var(--space-lg);
    display: flex;
    gap: var(--space-sm);
    align-items: center;
}

.header-action-btn {
    width: 40px;
    height: 40px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.header-action-btn:hover {
    background: var(--bg-hover);
    color: var(--accent-blue);
    border-color: var(--accent-blue);
    box-shadow: var(--shadow-cyan);
    transform: scale(1.05);
}

/* GitHub Link */
.github-link {
    width: 40px;
    height: 40px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    text-decoration: none;
}

.github-link:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-accent);
    box-shadow: var(--shadow-purple);
    transform: scale(1.05);
}

/* Theme Toggle */
.theme-toggle {
    width: 40px;
    height: 40px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: var(--stellar-gold);
}

.theme-toggle:hover {
    background: var(--bg-hover);
    border-color: var(--stellar-gold);
    box-shadow: var(--shadow-stellar);
    transform: scale(1.1);
}

.theme-toggle .theme-icon-dark {
    display: inline;
}

.theme-toggle .theme-icon-light {
    display: none;
}

body.light-mode .theme-toggle .theme-icon-dark {
    display: none;
}

body.light-mode .theme-toggle .theme-icon-light {
    display: inline;
}

/* ===== Cosmic Logo ===== */
.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.logo-icon {
    font-size: 2.5rem;
    color: var(--stellar-gold);
    filter: drop-shadow(0 0 15px rgba(255, 215, 0, 0.5));
    animation: logoGlow 3s ease-in-out infinite;
}

@keyframes logoGlow {
    0%, 100% {
        filter: drop-shadow(0 0 15px rgba(255, 215, 0, 0.5));
        transform: scale(1);
    }
    50% {
        filter: drop-shadow(0 0 25px rgba(255, 215, 0, 0.8));
        transform: scale(1.05);
    }
}

.logo h1 {
    font-family: var(--font-display);
    font-size: 2.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--text-primary);
    text-shadow:
        0 0 10px rgba(255, 215, 0, 0.3),
        0 0 20px rgba(123, 44, 191, 0.3),
        0 0 40px rgba(79, 195, 247, 0.2);
    margin: 0;
}

.tagline {
    font-family: var(--font-elegant);
    font-size: 1.25rem;
    font-style: italic;
    color: var(--text-secondary);
    font-weight: 400;
    letter-spacing: 0.02em;
    margin-top: var(--space-sm);
}

.tagline-sub {
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--text-secondary);
    opacity: 0.7;
    margin-top: var(--space-xs);
}

/* ===== Tab Navigation ===== */
.tab-navigation {
    display: flex;
    justify-content: center;
    gap: var(--space-md);
    margin-top: var(--space-xl);
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-xl);
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    font-family: var(--font-display);
    font-size: 0.9rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.tab-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--stellar-purple), var(--cosmic-blue));
    opacity: 0;
    transition: opacity var(--transition-normal);
    z-index: -1;
}

.tab-btn:hover {
    color: var(--text-primary);
    border-color: var(--border-accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-purple);
}

.tab-btn:hover::before {
    opacity: 0.2;
}

.tab-btn.active {
    background: linear-gradient(135deg, var(--stellar-purple), var(--cosmic-blue));
    border-color: var(--nebula-violet);
    color: var(--text-primary);
    box-shadow: var(--shadow-glow), var(--shadow-md);
}

.tab-icon {
    font-size: 1.2rem;
}

.tab-label {
    font-weight: 500;
}

body.in-conversation .tab-navigation {
    display: none;
}

/* ===== Views ===== */
.view {
    display: none !important;
    flex: 1;
    animation: cosmicFadeIn 0.6s ease;
}

.view.active {
    display: flex !important;
    flex-direction: column;
}

@keyframes cosmicFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.98);
        filter: blur(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

/* ===== Intro Section ===== */
.intro-section {
    text-align: center;
    margin-bottom: var(--space-xl);
}

.intro-section h2 {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
    letter-spacing: 0.02em;
}

.intro-section p {
    font-family: var(--font-elegant);
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
    font-size: 1.1rem;
    line-height: 1.7;
    font-style: italic;
}

.intro-section .intro-explainer {
    font-family: var(--font-body);
    font-style: normal;
    font-size: 1rem;
    color: var(--text-secondary);
    opacity: 0.85;
    margin-bottom: var(--space-xs);
}

/* ===== Filter Controls ===== */
.filter-controls {
    display: flex;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
    flex-wrap: wrap;
    justify-content: center;
}

.search-wrapper {
    position: relative;
    flex: 1;
    max-width: 400px;
    min-width: 200px;
}

.search-wrapper .search-icon {
    position: absolute;
    left: var(--space-md);
    top: 50%;
    transform: translateY(-50%);
    font-size: 1rem;
    opacity: 0.6;
    pointer-events: none;
}

#search-input {
    width: 100%;
    padding: var(--space-md) var(--space-md) var(--space-md) calc(var(--space-md) * 2.5);
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.95rem;
    transition: all var(--transition-normal);
}

#search-input::placeholder {
    color: var(--text-muted);
}

#search-input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px var(--accent-blue-light), var(--shadow-cyan);
    background: var(--bg-card);
}

.era-filter-wrapper {
    min-width: 180px;
}

#era-filter {
    width: 100%;
    padding: var(--space-md);
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all var(--transition-normal);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23f0f0ff' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--space-md) center;
    padding-right: calc(var(--space-md) * 2.5);
}

#era-filter:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px var(--accent-blue-light), var(--shadow-cyan);
}

#era-filter option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: var(--space-2xl);
    color: var(--text-secondary);
}

.no-results p {
    font-size: 1.1rem;
    margin-bottom: var(--space-sm);
}

.no-results span {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* ===== Figures Grid ===== */
.figures-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-lg);
    padding-bottom: var(--space-xl);
}

/* ===== Cosmic Portal Cards ===== */
.figure-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

/* Cosmic portal border effect */
.figure-card::before {
    content: '';
    position: absolute;
    inset: -2px;
    background: conic-gradient(
        from 0deg,
        var(--stellar-purple),
        var(--cosmic-blue),
        var(--aurora-cyan),
        var(--stellar-gold),
        var(--nebula-violet),
        var(--stellar-purple)
    );
    border-radius: var(--radius-xl);
    z-index: -2;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.figure-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--glass-bg);
    border-radius: calc(var(--radius-xl) - 2px);
    z-index: -1;
}

.figure-card:hover,
.figure-card:focus-visible {
    transform: translateY(-6px);
    box-shadow: var(--shadow-lg), var(--shadow-purple);
}

.figure-card:hover::before {
    opacity: 1;
    animation: portalSpin 4s linear infinite;
}

@keyframes portalSpin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.figure-card:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
}

/* ===== Celestial Portrait ===== */
.figure-portrait {
    width: 110px;
    height: 110px;
    margin: 0 auto var(--space-lg);
    border-radius: var(--radius-full);
    padding: 4px;
    background: linear-gradient(135deg, var(--stellar-purple), var(--cosmic-blue), var(--stellar-gold));
    box-shadow: var(--shadow-md), var(--shadow-purple);
    transition: all var(--transition-normal);
    position: relative;
}

/* Orbital rings */
.figure-portrait::before,
.figure-portrait::after {
    content: '';
    position: absolute;
    border: 1px solid var(--border-accent);
    border-radius: 50%;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.figure-portrait::before {
    inset: -10px;
    animation: orbitSlow 8s linear infinite paused;
}

.figure-portrait::after {
    inset: -18px;
    animation: orbitFast 6s linear infinite reverse paused;
}

.figure-card:hover .figure-portrait::before,
.figure-card:hover .figure-portrait::after {
    opacity: 0.6;
    animation-play-state: running;
}

@keyframes orbitSlow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes orbitFast {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.figure-card:hover .figure-portrait {
    transform: scale(1.08);
    box-shadow: var(--shadow-lg), var(--shadow-stellar);
}

.figure-portrait img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-tertiary);
}

/* Figure Info */
.figure-info {
    text-align: center;
}

.figure-name {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
    letter-spacing: 0.02em;
}

.figure-dates {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--accent-blue);
    margin-bottom: var(--space-sm);
    font-weight: 500;
}

.figure-tagline {
    font-family: var(--font-elegant);
    font-size: 1rem;
    font-style: italic;
    color: var(--text-secondary);
    margin-bottom: var(--space-md);
    line-height: 1.5;
}

.figure-era {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--stellar-gold);
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.1), rgba(212, 175, 55, 0.15));
    padding: var(--space-xs) var(--space-md);
    border-radius: var(--radius-full);
    border: 1px solid rgba(255, 215, 0, 0.2);
}

/* ===== Cosmic Loading Spinner ===== */
.loading-spinner {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-3xl);
    color: var(--text-secondary);
}

.spinner {
    width: 60px;
    height: 60px;
    position: relative;
    margin-bottom: var(--space-lg);
}

.spinner::before,
.spinner::after {
    content: '';
    position: absolute;
    inset: 0;
    border: 3px solid transparent;
    border-radius: 50%;
}

.spinner::before {
    border-top-color: var(--stellar-gold);
    border-right-color: var(--nebula-violet);
    animation: spinOuter 1.2s linear infinite;
}

.spinner::after {
    inset: 8px;
    border-bottom-color: var(--aurora-cyan);
    border-left-color: var(--cosmic-blue);
    animation: spinInner 0.8s linear infinite reverse;
}

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

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

/* ===== Error Message ===== */
.error-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: var(--space-2xl);
    color: var(--text-secondary);
}

.error-message button {
    margin-top: var(--space-md);
    padding: var(--space-sm) var(--space-xl);
    background: linear-gradient(135deg, var(--stellar-purple), var(--cosmic-blue));
    color: var(--text-primary);
    border: none;
    border-radius: var(--radius-full);
    font-family: var(--font-display);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.error-message button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-purple);
}

/* ===== Conversation View ===== */
#conversation-view {
    height: 100%;
    flex-direction: column;
}

#conversation-view.active {
    display: flex;
}

body.in-conversation .main-header,
body.in-conversation .main-footer {
    display: none;
}

body.in-conversation .app-container {
    height: 100vh;
    padding: var(--space-sm);
}

body.in-conversation #conversation-view {
    flex: 1;
    min-height: 0;
}

/* ===== Conversation Header ===== */
.conversation-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-md);
    flex-shrink: 0;
    box-shadow: var(--shadow-md);
    position: relative;
}

.conversation-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg,
        transparent,
        var(--stellar-purple),
        var(--cosmic-blue),
        var(--aurora-cyan),
        var(--cosmic-blue),
        var(--stellar-purple),
        transparent
    );
    opacity: 0.8;
    animation: headerGlow 3s ease-in-out infinite;
}

@keyframes headerGlow {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.back-button {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.back-button:hover {
    background: var(--bg-hover);
    border-color: var(--border-accent);
    color: var(--text-primary);
    transform: translateX(-3px);
}

.back-arrow {
    font-size: 1.1rem;
}

.current-figure-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.header-portrait {
    width: 50px;
    height: 50px;
    border-radius: var(--radius-full);
    padding: 2px;
    background: linear-gradient(135deg, var(--stellar-purple), var(--cosmic-blue));
    overflow: hidden;
}

.header-portrait img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.header-text h2 {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.02em;
}

.header-text p {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Branch Selector */
.branch-selector-wrapper {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

#branch-selector {
    background: var(--glass-bg);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-xs) var(--space-sm);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition-normal);
    min-width: 120px;
}

#branch-selector:hover {
    border-color: var(--border-accent);
}

#branch-selector:focus {
    outline: none;
    border-color: var(--stellar-gold);
    box-shadow: 0 0 0 2px var(--gold-glow);
}

.branch-btn {
    background: var(--glass-bg);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-xs) var(--space-sm);
    color: var(--text-primary);
    font-size: 1rem;
    cursor: pointer;
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.branch-btn:hover {
    background: var(--bg-hover);
    border-color: var(--stellar-gold);
    transform: scale(1.05);
}

.branch-btn-message {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    cursor: pointer;
    padding: var(--space-xs);
    border-radius: 4px;
    transition: all var(--transition-fast);
    opacity: 0;
    margin-left: auto;
}

.message:hover .branch-btn-message {
    opacity: 1;
}

.branch-btn-message:hover {
    color: var(--stellar-gold);
    background: var(--gold-glow);
}

.message-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-top: var(--space-xs);
    gap: var(--space-xs);
}

/* Model Selector */
.model-selector-wrapper {
    margin-left: auto;
}

#model-selector,
#party-model-selector {
    padding: var(--space-sm) var(--space-md);
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-normal);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='%23f0f0ff' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--space-sm) center;
    padding-right: calc(var(--space-md) + 12px);
    min-width: 140px;
}

#model-selector:focus,
#party-model-selector:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px var(--accent-blue-light);
}

#model-selector option,
#party-model-selector option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

#model-selector optgroup,
#party-model-selector optgroup {
    font-weight: 600;
    color: var(--stellar-gold);
}

/* Action Buttons */
.share-button,
.copy-button,
.download-button {
    width: 38px;
    height: 38px;
    padding: 0;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-normal);
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.share-button:hover,
.copy-button:hover,
.download-button:hover {
    background: var(--bg-hover);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    transform: scale(1.08);
    box-shadow: var(--shadow-cyan);
}

.share-button .share-icon,
.copy-button .copy-icon,
.download-button .download-icon {
    font-size: 16px;
}

/* ===== The Void - Chat Container ===== */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, var(--nebula-dark) 0%, var(--void-black) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: var(--space-md);
    min-height: 0;
    box-shadow: var(--shadow-lg), inset 0 0 60px rgba(0, 0, 0, 0.5);
    position: relative;
}

.chat-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg,
        var(--stellar-purple),
        var(--cosmic-blue),
        var(--aurora-cyan),
        var(--stellar-gold),
        var(--aurora-cyan),
        var(--cosmic-blue),
        var(--stellar-purple)
    );
    animation: voidPulse 4s ease-in-out infinite;
}

@keyframes voidPulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    min-height: 0;
}

/* Cosmic Scrollbar */
.messages::-webkit-scrollbar {
    width: 8px;
}

.messages::-webkit-scrollbar-track {
    background: var(--void-black);
}

.messages::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--stellar-purple), var(--cosmic-blue));
    border-radius: 4px;
}

.messages::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--nebula-violet), var(--starlight-blue));
}

/* ===== Cosmic Messages ===== */
.message {
    display: flex;
    gap: var(--space-md);
    max-width: 85%;
    animation: messageEmerge 0.4s ease;
}

@keyframes messageEmerge {
    from {
        opacity: 0;
        transform: translateY(15px) scale(0.98);
        filter: blur(3px);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

.figure-message {
    align-self: flex-start;
}

.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-portrait {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    padding: 2px;
    background: linear-gradient(135deg, var(--stellar-purple), var(--cosmic-blue));
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.message-portrait img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

/* AI Message Style */
.figure-message .message-content {
    background: linear-gradient(135deg, rgba(75, 0, 130, 0.15), rgba(10, 10, 26, 0.9));
    border-left: 3px solid var(--nebula-violet);
    border-radius: 0 var(--radius-md) var(--radius-md) var(--radius-md);
    padding: var(--space-md);
    box-shadow: var(--shadow-sm), inset 0 0 30px rgba(75, 0, 130, 0.1);
    position: relative;
}

.figure-message .message-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: -3px;
    bottom: 0;
    width: 3px;
    background: linear-gradient(180deg, var(--nebula-violet), var(--cosmic-blue));
    border-radius: 3px 0 0 3px;
}

/* User Message Style */
.user-message .message-content {
    background: linear-gradient(135deg, rgba(0, 102, 204, 0.15), rgba(10, 10, 26, 0.9));
    border-right: 3px solid var(--aurora-cyan);
    border-radius: var(--radius-md) 0 var(--radius-md) var(--radius-md);
    padding: var(--space-md);
    box-shadow: var(--shadow-sm), inset 0 0 30px rgba(0, 255, 255, 0.05);
}

.message-content {
    font-family: var(--font-body);
}

.message-author {
    display: block;
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--stellar-gold);
    margin-bottom: var(--space-xs);
    letter-spacing: 0.02em;
}

.message-content p {
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--text-primary);
}

.message-content em {
    color: var(--text-secondary);
    font-style: italic;
}

/* New message glow effect */
.message.new-message .message-content {
    animation: newMessageGlow 1s ease-out;
}

@keyframes newMessageGlow {
    from {
        box-shadow: 0 0 20px var(--gold-glow), var(--shadow-sm);
    }
    to {
        box-shadow: var(--shadow-sm);
    }
}

/* ===== Typing Indicator ===== */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md);
    color: var(--text-secondary);
    font-family: var(--font-elegant);
    font-style: italic;
}

.typing-indicator.hidden {
    display: none;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--stellar-purple), var(--cosmic-blue));
    animation: typingPulse 1.4s ease-in-out infinite;
    box-shadow: 0 0 10px var(--border-glow);
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingPulse {
    0%, 60%, 100% {
        transform: scale(1);
        opacity: 0.5;
    }
    30% {
        transform: scale(1.3);
        opacity: 1;
    }
}

/* ===== Starter Questions ===== */
.starter-questions {
    text-align: center;
    padding: var(--space-md);
}

.starter-label {
    font-family: var(--font-elegant);
    color: var(--text-secondary);
    font-style: italic;
    margin-bottom: var(--space-md);
    font-size: 1rem;
}

.question-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    justify-content: center;
}

.starter-btn {
    padding: var(--space-sm) var(--space-lg);
    background: var(--glass-bg);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.starter-btn:hover {
    background: var(--bg-hover);
    border-color: var(--stellar-gold);
    color: var(--stellar-gold);
    transform: translateY(-2px);
    box-shadow: var(--shadow-stellar);
}

/* ===== Chat Form ===== */
.chat-form {
    padding: var(--space-md);
    background: var(--glass-bg);
    border-top: 1px solid var(--border-subtle);
}

.input-wrapper {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
}

#message-input,
#party-message-input {
    flex: 1;
    padding: var(--space-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.95rem;
    transition: all var(--transition-normal);
}

#message-input::placeholder,
#party-message-input::placeholder {
    color: var(--text-muted);
    font-style: italic;
}

#message-input:focus,
#party-message-input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px var(--accent-blue-light), var(--shadow-cyan);
}

.send-button {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--stellar-purple), var(--cosmic-blue));
    border: none;
    border-radius: var(--radius-full);
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
}

.send-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.send-button:not(:disabled):hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-lg), var(--shadow-purple);
}

.send-icon {
    font-weight: bold;
}

/* ===== Suggestions ===== */
.message-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    margin-top: var(--space-md);
    padding-top: var(--space-sm);
    border-top: 1px solid var(--border-subtle);
}

.suggestion-btn {
    padding: var(--space-xs) var(--space-md);
    background: transparent;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.suggestion-btn:hover {
    background: var(--bg-hover);
    border-color: var(--stellar-gold);
    color: var(--stellar-gold);
}

/* Party Suggestions */
.party-suggestions {
    padding: var(--space-sm) var(--space-md);
}

.suggestion-pills {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    justify-content: center;
}

/* ===== Dinner Party Styles ===== */
.curated-combos {
    text-align: center;
    margin-bottom: var(--space-lg);
}

.combos-label {
    font-family: var(--font-elegant);
    color: var(--text-secondary);
    font-style: italic;
    margin-bottom: var(--space-sm);
}

.combo-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    justify-content: center;
}

.combo-btn {
    padding: var(--space-sm) var(--space-md);
    background: var(--glass-bg);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.combo-btn:hover {
    background: var(--bg-hover);
    border-color: var(--stellar-gold);
    color: var(--stellar-gold);
    transform: translateY(-2px);
}

.guest-selection-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
    padding: 0 var(--space-sm);
}

.guest-count {
    font-family: var(--font-mono);
    color: var(--stellar-gold);
    font-size: 0.9rem;
}

.clear-guests-btn {
    padding: var(--space-xs) var(--space-md);
    background: transparent;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.clear-guests-btn:not(:disabled):hover {
    border-color: #ff4757;
    color: #ff4757;
}

.clear-guests-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Guest Grid */
.guest-grid .figure-card {
    transition: all var(--transition-normal);
}

.guest-grid .figure-card.selected {
    border-color: var(--stellar-gold);
    box-shadow: var(--shadow-stellar), var(--shadow-md);
}

.guest-grid .figure-card.selected::before {
    opacity: 1;
    background: conic-gradient(
        from 0deg,
        var(--stellar-gold),
        var(--aurora-cyan),
        var(--stellar-gold)
    );
    animation: portalSpin 3s linear infinite;
}

.guest-grid .figure-card.selected .figure-portrait {
    background: linear-gradient(135deg, var(--stellar-gold), var(--aurora-cyan));
}

/* Start Party Button */
.start-party-container {
    text-align: center;
    padding: var(--space-xl) 0;
}

.start-party-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-2xl);
    background: linear-gradient(135deg, var(--stellar-purple), var(--cosmic-blue));
    border: 2px solid var(--stellar-gold);
    border-radius: var(--radius-full);
    color: var(--text-primary);
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-lg);
}

.start-party-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    border-color: var(--border-subtle);
}

.start-party-btn:not(:disabled):hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: var(--shadow-xl), var(--shadow-stellar);
}

.party-icon {
    font-size: 1.3rem;
}

.party-hint {
    font-family: var(--font-elegant);
    color: var(--text-muted);
    font-style: italic;
    margin-top: var(--space-sm);
    font-size: 0.9rem;
}

/* Dinner Party Header */
.dinner-party-header {
    flex-wrap: wrap;
}

.party-guests-info {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    flex: 1;
    min-width: 0;
}

.party-guest-portrait {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    padding: 2px;
    background: linear-gradient(135deg, var(--stellar-purple), var(--cosmic-blue));
    margin-left: -10px;
    transition: all var(--transition-fast);
}

.party-guest-portrait:first-child {
    margin-left: 0;
}

.party-guest-portrait:hover {
    transform: scale(1.1);
    z-index: 1;
}

.party-guest-portrait img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

/* ===== Summoning Overlay ===== */
.summoning-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-slow);
}

.summoning-overlay.active {
    opacity: 1;
    visibility: visible;
}

.summoning-circle {
    position: relative;
    width: 300px;
    height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.summoning-ring {
    position: absolute;
    border: 2px solid transparent;
    border-radius: 50%;
    animation: summoningExpand 2s ease-out forwards;
    opacity: 0;
}

.summoning-ring:nth-child(1) {
    width: 100%;
    height: 100%;
    border-color: var(--stellar-purple);
    animation-delay: 0s;
    box-shadow: 0 0 30px var(--stellar-purple), inset 0 0 30px var(--stellar-purple);
}

.summoning-ring:nth-child(2) {
    width: 130%;
    height: 130%;
    border-color: var(--cosmic-blue);
    animation-delay: 0.3s;
    box-shadow: 0 0 20px var(--cosmic-blue), inset 0 0 20px var(--cosmic-blue);
}

.summoning-ring:nth-child(3) {
    width: 160%;
    height: 160%;
    border-color: var(--stellar-gold);
    animation-delay: 0.6s;
    box-shadow: 0 0 40px var(--stellar-gold), inset 0 0 40px var(--stellar-gold);
}

@keyframes summoningExpand {
    0% {
        transform: scale(0) rotate(0deg);
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        transform: scale(1) rotate(180deg);
        opacity: 0.8;
    }
}

.summoning-portrait {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    overflow: hidden;
    opacity: 0;
    transform: scale(0);
    animation: portraitEmerge 1s ease-out 0.8s forwards;
    background: linear-gradient(135deg, var(--stellar-purple), var(--cosmic-blue));
    padding: 4px;
    box-shadow:
        0 0 60px var(--stellar-gold),
        0 0 100px var(--cosmic-blue),
        0 0 140px var(--stellar-purple);
}

.summoning-portrait img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

@keyframes portraitEmerge {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    60% {
        transform: scale(1.1);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ===== Saved Conversations Panel ===== */
.saved-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 350px;
    max-width: 90vw;
    height: 100vh;
    background: var(--glass-bg);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-left: 1px solid var(--border-subtle);
    z-index: 100;
    transform: translateX(100%);
    transition: transform var(--transition-slow);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xl);
}

.saved-panel:not(.hidden) {
    transform: translateX(0);
}

.saved-panel.hidden {
    transform: translateX(100%);
}

.saved-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-subtle);
}

.saved-panel-header h3 {
    font-family: var(--font-display);
    font-size: 1.2rem;
    color: var(--stellar-gold);
}

.close-panel-btn {
    width: 32px;
    height: 32px;
    background: transparent;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-panel-btn:hover {
    background: rgba(255, 71, 87, 0.1);
    border-color: #ff4757;
    color: #ff4757;
}

.saved-list {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-md);
}

.saved-conversation-item {
    padding: var(--space-md);
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.saved-conversation-item:hover {
    border-color: var(--stellar-gold);
    box-shadow: var(--shadow-stellar);
}

.saved-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 99;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.saved-overlay:not(.hidden) {
    opacity: 1;
    visibility: visible;
}

/* ===== Toast Notification ===== */
.toast {
    position: fixed;
    bottom: var(--space-xl);
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: var(--space-md) var(--space-xl);
    background: linear-gradient(135deg, var(--stellar-purple), var(--cosmic-blue));
    border: 1px solid var(--stellar-gold);
    border-radius: var(--radius-full);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.9rem;
    box-shadow: var(--shadow-lg), var(--shadow-stellar);
    z-index: 1001;
    opacity: 0;
    transition: all var(--transition-normal);
}

.toast:not(.hidden) {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* ===== Cosmic Footer ===== */
.main-footer {
    text-align: center;
    padding: var(--space-xl) var(--space-md);
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border-subtle);
    margin-top: auto;
}

.main-footer p {
    margin-bottom: var(--space-xs);
}

.main-footer a {
    color: var(--stellar-gold);
    text-decoration: none;
    transition: all var(--transition-fast);
}

.main-footer a:hover {
    color: var(--aurora-cyan);
    text-shadow: 0 0 10px var(--aurora-cyan);
}

.credit {
    font-family: var(--font-elegant);
    font-style: italic;
}

/* ===== Streaming Message ===== */
.streaming-message .message-content {
    background: linear-gradient(135deg, rgba(75, 0, 130, 0.2), rgba(10, 10, 26, 0.9));
}

.streaming-text {
    position: relative;
}

.cursor {
    display: inline-block;
    width: 2px;
    height: 1.1em;
    background: var(--stellar-gold);
    margin-left: 2px;
    animation: cursorBlink 0.8s ease-in-out infinite;
    vertical-align: text-bottom;
}

@keyframes cursorBlink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* ===== Mobile Responsiveness ===== */
@media (max-width: 768px) {
    .app-container {
        padding: var(--space-md);
    }

    .main-header {
        padding: var(--space-xl) var(--space-sm) var(--space-lg);
    }

    .header-actions {
        top: var(--space-md);
        right: var(--space-md);
    }

    .logo h1 {
        font-size: 2rem;
    }

    .tagline {
        font-size: 1rem;
    }

    .tab-navigation {
        gap: var(--space-sm);
    }

    .tab-btn {
        padding: var(--space-sm) var(--space-md);
        font-size: 0.8rem;
    }

    .figures-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: var(--space-md);
    }

    .figure-card {
        padding: var(--space-lg);
    }

    .figure-portrait {
        width: 90px;
        height: 90px;
    }

    .conversation-header {
        flex-wrap: wrap;
        gap: var(--space-sm);
        padding: var(--space-sm);
    }

    .model-selector-wrapper {
        width: 100%;
        margin-left: 0;
        margin-top: var(--space-sm);
    }

    #model-selector,
    #party-model-selector {
        width: 100%;
    }

    .message {
        max-width: 95%;
    }

    .summoning-circle {
        width: 250px;
        height: 250px;
    }

    .summoning-portrait {
        width: 120px;
        height: 120px;
    }
}

@media (max-width: 480px) {
    .logo {
        flex-direction: column;
        gap: var(--space-sm);
    }

    .logo h1 {
        font-size: 1.75rem;
    }

    .logo-icon {
        font-size: 2rem;
    }

    .figures-grid {
        grid-template-columns: 1fr;
    }

    .filter-controls {
        flex-direction: column;
    }

    .search-wrapper,
    .era-filter-wrapper {
        width: 100%;
        max-width: none;
    }

    .header-actions {
        position: static;
        justify-content: center;
        margin-bottom: var(--space-md);
    }

    .saved-panel {
        width: 100%;
    }

    .back-button span:not(.back-arrow) {
        display: none;
    }

    .share-button,
    .copy-button,
    .download-button {
        width: 34px;
        height: 34px;
    }
}

/* ===== Accessibility ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .star {
        animation: none !important;
    }

    .shooting-star {
        display: none;
    }
}

/* Focus visible for keyboard navigation */
:focus-visible {
    outline: 2px solid var(--stellar-gold);
    outline-offset: 2px;
}

button:focus:not(:focus-visible),
input:focus:not(:focus-visible),
select:focus:not(:focus-visible) {
    outline: none;
}

/* ===== Cosmic Summoning Effect ===== */
body.cosmic-summoning {
    overflow: hidden;
}

body.cosmic-summoning::after {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at center, transparent 0%, var(--void-black) 70%);
    animation: cosmicPulse 1.5s ease-out;
    pointer-events: none;
    z-index: 999;
}

@keyframes cosmicPulse {
    0% {
        opacity: 0;
        background: radial-gradient(circle at center, rgba(123, 44, 191, 0.5) 0%, var(--void-black) 50%);
    }
    30% {
        opacity: 1;
        background: radial-gradient(circle at center, rgba(79, 195, 247, 0.4) 0%, var(--void-black) 60%);
    }
    60% {
        background: radial-gradient(circle at center, rgba(255, 215, 0, 0.3) 0%, var(--void-black) 70%);
    }
    100% {
        opacity: 0;
        background: radial-gradient(circle at center, transparent 0%, var(--void-black) 80%);
    }
}
