/* ============================================================================
   INTIMATE THEATER DESIGN SYSTEM - Blueroom AI
   Apple-inspired minimalism: restraint, hierarchy through space, purposeful motion
   ============================================================================ */

/* Import Google Fonts - Inter for UI, Spectral for character voice, Playfair for hero */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Spectral:ital,wght@0,400;0,500;0,600;1,400&family=Playfair+Display:wght@600&family=JetBrains+Mono:wght@400;500&display=swap');

/* ============================================================================
   CSS CUSTOM PROPERTIES - Near-Monochrome + Single Accent
   ============================================================================ */
:root {
    /* Grayscale spectrum (warm undertones) */
    --ink-black: #0d0d0f;
    --charcoal: #1a1a1e;
    --graphite: #28282e;
    --slate: #3a3a42;
    --pewter: #6b6b75;
    --silver: #9c9ca6;
    --pearl: #e8e8ec;
    --ivory: #f8f8fa;

    /* Single accent - purple */
    --accent: #7c3aed;
    --accent-soft: rgba(124, 58, 237, 0.15);
    --accent-glow: rgba(124, 58, 237, 0.08);

    /* Semantic colors */
    --success-color: #4ade80;
    --warning-color: #fbbf24;
    --danger-color: #f87171;
    --info-color: #60a5fa;

    /* Typography */
    --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-voice: 'Spectral', Georgia, serif;
    --font-display: 'Playfair Display', Georgia, serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Type scale (8pt base) */
    --text-xs: 0.75rem;    /* 12px */
    --text-sm: 0.875rem;   /* 14px */
    --text-base: 1rem;     /* 16px */
    --text-lg: 1.125rem;   /* 18px */
    --text-xl: 1.5rem;     /* 24px */
    --text-2xl: 2rem;      /* 32px */
    --text-hero: 3rem;     /* 48px */

    /* Spacing scale (8pt system) */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 48px;
    --space-8: 64px;
    --space-9: 96px;

    /* Shadows - depth without noise */
    --shadow-subtle: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-medium: 0 4px 12px rgba(0, 0, 0, 0.15);
    --shadow-lifted: 0 8px 30px rgba(0, 0, 0, 0.12);

    /* Border radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-full: 9999px;

    /* Transitions */
    --ease-smooth: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --duration-fast: 150ms;
    --duration-normal: 300ms;
}

/* ============================================================================
   LIGHT THEME - Inverted color scheme for chat screen
   ============================================================================ */
[data-theme="light"] {
    --ink-black: #ffffff;
    --charcoal: #f8f8fa;
    --graphite: #e8e8ec;
    --slate: #d1d1d8;
    --pewter: #9c9ca6;
    --silver: #6b6b75;
    --pearl: #28282e;
    --ivory: #1a1a1e;
    --accent: #6d28d9;
    --accent-soft: rgba(109, 40, 217, 0.15);
    --accent-glow: rgba(109, 40, 217, 0.12);
    --shadow-subtle: 0 1px 2px rgba(0, 0, 0, 0.08);
    --shadow-medium: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lifted: 0 8px 30px rgba(0, 0, 0, 0.06);
}

/* Light theme adjustments for body gradient */
[data-theme="light"] body::before {
    background: radial-gradient(ellipse at 50% 30%, var(--charcoal) 0%, var(--ink-black) 70%);
}

/* Light theme sidebar */
[data-theme="light"] .sidebar {
    background-color: var(--charcoal);
    border-right-color: var(--slate);
}

[data-theme="light"] .sidebar-brand a {
    color: var(--ivory);
}

[data-theme="light"] .sidebar-link {
    color: var(--silver);
}

[data-theme="light"] .sidebar-link:hover {
    background-color: var(--graphite);
    color: var(--pearl);
}

[data-theme="light"] .sidebar-link.active {
    color: var(--accent);
}

/* Light theme dropdown menus */
[data-theme="light"] .dropdown-menu {
    background-color: var(--charcoal);
    border-color: var(--slate);
}

[data-theme="light"] .dropdown-item {
    color: var(--silver);
}

[data-theme="light"] .dropdown-item:hover,
[data-theme="light"] .dropdown-item:focus {
    background-color: var(--graphite);
    color: var(--pearl);
}

/* Light theme topbar + mobile toggle */
[data-theme="light"] .topbar {
    background-color: var(--ink-black);
    border-bottom-color: var(--slate);
}

[data-theme="light"] .sidebar-mobile-toggle {
    background-color: var(--charcoal);
    border-color: var(--slate);
    color: var(--pearl);
}

/* Light theme user avatar */
[data-theme="light"] .user-avatar {
    background-color: var(--graphite);
    color: var(--pearl);
}

/* Light theme character cards - ensure readability */
[data-theme="light"] .character-card .card-name {
    color: var(--ivory);
}

[data-theme="light"] .trait-tag {
    background-color: var(--accent-soft);
    color: var(--accent);
}

/* Light theme button primary text stays white on purple */
[data-theme="light"] .btn-primary {
    color: white;
}

[data-theme="light"] .btn-primary:hover {
    color: white;
}

/* ============================================================================
   GLOBAL STYLES
   ============================================================================ */
body {
    font-family: var(--font-ui);
    background-color: var(--ink-black);
    color: var(--pearl);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Subtle radial gradient for depth - charcoal center fading to ink-black */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at 50% 30%, var(--charcoal) 0%, var(--ink-black) 70%);
    pointer-events: none;
    z-index: -1;
}

/* Typography hierarchy */
h1, h2, h3, .display-1, .display-2, .display-3, .display-4, .display-5, .display-6 {
    font-family: var(--font-ui);
    font-weight: 600;
    color: var(--ivory);
    letter-spacing: -0.01em;
}

h4, h5, h6 {
    font-family: var(--font-ui);
    font-weight: 500;
    color: var(--pearl);
}

/* Hero headline - Playfair Display, used once per page max */
.hero-headline {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: var(--text-hero);
    line-height: 1.1;
    color: var(--ivory);
    letter-spacing: -0.02em;
}

/* Character voice - Spectral serif for AI messages */
.voice-text {
    font-family: var(--font-voice);
    font-size: var(--text-base);
    line-height: 1.7;
    color: var(--pearl);
}

/* ============================================================================
   ANIMATIONS - Purposeful, Not Decorative
   ============================================================================ */

/* Elements arrive: slide up 8px while fading */
@keyframes arrive {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-arrive {
    animation: arrive var(--duration-normal) var(--ease-smooth) forwards;
    opacity: 0;
}

/* Staggered delays - 40ms apart */
.animate-arrive.delay-1 { animation-delay: 40ms; }
.animate-arrive.delay-2 { animation-delay: 80ms; }
.animate-arrive.delay-3 { animation-delay: 120ms; }
.animate-arrive.delay-4 { animation-delay: 160ms; }
.animate-arrive.delay-5 { animation-delay: 200ms; }

/* Shimmer loading effect */
.shimmer {
    background: linear-gradient(90deg, var(--charcoal) 25%, var(--graphite) 50%, var(--charcoal) 75%);
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Loading spinner */
.loading-spin {
    animation: spin 1s linear infinite;
}

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

/* ============================================================================
   APP LAYOUT - Sidebar + Main Area
   ============================================================================ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 240px;
    background-color: var(--charcoal);
    border-right: 1px solid var(--slate);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    overflow-y: auto;
}

.sidebar-brand {
    padding: var(--space-6) var(--space-5);
}

.sidebar-brand a {
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: var(--text-lg);
    color: var(--ivory);
    text-decoration: none;
    letter-spacing: 0.08em;
}

.sidebar-brand a:hover {
    color: var(--accent);
}

.sidebar-nav {
    flex: 1;
    padding: 0 var(--space-3);
    display: flex;
    flex-direction: column;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    color: var(--silver);
    text-decoration: none;
    font-family: var(--font-ui);
    font-size: var(--text-sm);
    font-weight: 400;
    transition: all var(--duration-fast) var(--ease-smooth);
    margin-bottom: 2px;
}

.sidebar-link:hover {
    background-color: var(--graphite);
    color: var(--pearl);
}

.sidebar-link.active {
    background-color: var(--accent-soft);
    color: var(--accent);
    font-weight: 500;
}

.sidebar-link i {
    width: 20px;
    text-align: center;
    font-size: var(--text-sm);
    flex-shrink: 0;
}

.sidebar-link-btn {
    background: none;
    border: none;
    cursor: pointer;
    width: 100%;
    text-align: left;
}

.sidebar-divider {
    height: 1px;
    background-color: var(--slate);
    margin: var(--space-3) var(--space-4);
}

.sidebar-footer {
    padding: var(--space-3);
    border-top: 1px solid var(--slate);
}

.sidebar-copyright {
    color: var(--pewter);
    font-size: var(--text-xs);
    letter-spacing: 0.08em;
    margin-top: var(--space-2);
    padding: 0 var(--space-3);
    text-transform: uppercase;
}

.sidebar-logout-form {
    margin: 0;
}

/* Main area */
.main-area {
    margin-left: 240px;
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-content {
    flex: 1;
    padding: var(--space-5) var(--space-6);
    max-width: 1400px;
    width: 100%;
}

/* Topbar (search + CTA in pages that use it) */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-6);
    border-bottom: 1px solid var(--slate);
    background-color: var(--ink-black);
    flex-shrink: 0;
}

.topbar-search {
    flex: 1;
    max-width: 400px;
}

.topbar-search .form-control {
    background-color: var(--graphite);
    border: 1px solid transparent;
    border-radius: var(--radius-full);
    padding: var(--space-2) var(--space-4);
    padding-left: 36px;
    font-size: var(--text-sm);
    color: var(--pearl);
}

.topbar-search {
    position: relative;
}

.topbar-search i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--pewter);
    font-size: var(--text-sm);
}

/* Mobile sidebar toggle button */
.sidebar-mobile-toggle {
    display: none;
    position: fixed;
    top: var(--space-4);
    left: var(--space-4);
    z-index: 1050;
    background-color: var(--charcoal);
    border: 1px solid var(--slate);
    border-radius: var(--radius-md);
    color: var(--pearl);
    padding: var(--space-2) var(--space-3);
    cursor: pointer;
}

/* No-sidebar mode (for chat page) */
body.no-sidebar .sidebar { display: none; }
body.no-sidebar .sidebar-mobile-toggle { display: none; }
body.no-sidebar .main-area { margin-left: 0; }

/* Legacy navbar support (for dropdown menus in other templates) */
.dropdown-menu {
    background-color: var(--charcoal);
    border: 1px solid var(--slate);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lifted);
    padding: var(--space-2);
}

.dropdown-item {
    color: var(--silver);
    font-family: var(--font-ui);
    font-size: var(--text-sm);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    transition: all var(--duration-fast) var(--ease-smooth);
}

.dropdown-item:hover,
.dropdown-item:focus {
    background-color: var(--graphite);
    color: var(--pearl);
}

.dropdown-divider {
    border-color: var(--slate);
    margin: var(--space-2) 0;
}

/* ============================================================================
   CARDS - Subtle Lift on Hover, No Color Change
   ============================================================================ */
.card {
    background-color: var(--charcoal);
    border: 1px solid transparent;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-subtle);
    transition: transform var(--duration-normal) var(--ease-smooth),
                box-shadow var(--duration-normal) var(--ease-smooth),
                border-color var(--duration-normal) var(--ease-smooth);
    overflow: hidden;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
    border-color: var(--slate);
}

.card-header {
    background-color: var(--graphite);
    border-bottom: 1px solid var(--slate);
    font-family: var(--font-ui);
    font-weight: 500;
    color: var(--pearl);
    padding: var(--space-4) var(--space-5);
}

.card-body {
    padding: var(--space-5);
    color: var(--silver);
}

.card-footer {
    background-color: var(--graphite);
    border-top: 1px solid var(--slate);
    padding: var(--space-4) var(--space-5);
}

/* ============================================================================
   BUTTONS - Primary (Gold), Ghost (Transparent + Border)
   ============================================================================ */
.btn {
    font-family: var(--font-ui);
    font-weight: 500;
    font-size: var(--text-sm);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-5);
    transition: all var(--duration-fast) var(--ease-smooth);
    border: none;
    cursor: pointer;
}

/* Primary button - purple, used for main CTAs only */
.btn-primary {
    background-color: var(--accent);
    color: white;
    font-weight: 600;
}

.btn-primary:hover {
    background-color: #6d28d9;
    color: white;
    transform: translateY(-1px);
}

.btn-primary:focus {
    box-shadow: 0 0 0 3px var(--accent-soft);
    background-color: var(--accent);
    color: white;
}

/* Ghost button - transparent with border */
.btn-outline-secondary,
.btn-ghost {
    background-color: transparent;
    border: 1px solid var(--slate);
    color: var(--silver);
}

.btn-outline-secondary:hover,
.btn-ghost:hover {
    background-color: var(--graphite);
    border-color: var(--pewter);
    color: var(--pearl);
}

/* Secondary button */
.btn-secondary {
    background-color: var(--graphite);
    color: var(--silver);
    border: 1px solid var(--slate);
}

.btn-secondary:hover {
    background-color: var(--slate);
    color: var(--pearl);
    border-color: var(--pewter);
}

/* Outline primary - purple border ghost */
.btn-outline-primary {
    background-color: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
}

.btn-outline-primary:hover {
    background-color: var(--accent);
    color: white;
}

/* Success, Warning, Danger buttons */
.btn-success {
    background-color: var(--success-color);
    color: var(--ink-black);
}

.btn-warning {
    background-color: var(--warning-color);
    color: var(--ink-black);
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

/* Button sizes */
.btn-lg {
    padding: var(--space-4) var(--space-6);
    font-size: var(--text-base);
}

.btn-sm {
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-xs);
}

/* Icon button */
.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
}

/* ============================================================================
   FORMS - Invisible Until Focused
   ============================================================================ */
.form-control {
    background-color: var(--graphite);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4);
    font-family: var(--font-ui);
    font-size: var(--text-sm);
    color: var(--pearl);
    transition: all var(--duration-fast) var(--ease-smooth);
}

.form-control:focus {
    background-color: var(--charcoal);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
    color: var(--ivory);
    outline: none;
}

.form-control::placeholder {
    color: var(--pewter);
}

.form-label {
    font-family: var(--font-ui);
    font-weight: 500;
    font-size: var(--text-sm);
    color: var(--pearl);
    margin-bottom: var(--space-2);
}

.form-select {
    background-color: var(--graphite);
    border: 1px solid transparent;
    color: var(--pearl);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
}

.form-select:focus {
    background-color: var(--charcoal);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Input group */
.input-group-text {
    background-color: var(--graphite);
    border: 1px solid transparent;
    color: var(--pewter);
}

.input-group:focus-within .input-group-text {
    border-color: var(--accent);
}

/* ============================================================================
   BADGES
   ============================================================================ */
.badge {
    font-family: var(--font-ui);
    font-size: var(--text-xs);
    font-weight: 500;
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
}

.badge-gradient-success,
.bg-success {
    background-color: var(--success-color) !important;
    color: var(--ink-black);
}

.badge-gradient-warning,
.bg-warning {
    background-color: var(--warning-color) !important;
    color: var(--ink-black);
}

.badge-gradient-danger,
.bg-danger {
    background-color: var(--danger-color) !important;
    color: white;
}

.badge-gradient-primary,
.bg-primary {
    background-color: var(--accent) !important;
    color: var(--ink-black);
}

/* ============================================================================
   TABLES
   ============================================================================ */
.table {
    border-collapse: separate;
    border-spacing: 0;
    color: var(--silver);
}

.table thead th {
    background-color: var(--graphite);
    border: none;
    font-family: var(--font-ui);
    font-weight: 500;
    text-transform: uppercase;
    font-size: var(--text-xs);
    letter-spacing: 0.05em;
    color: var(--pewter);
    padding: var(--space-4);
}

.table tbody tr {
    border: none;
    transition: background-color var(--duration-fast) var(--ease-smooth);
}

.table-hover tbody tr:hover {
    background-color: var(--graphite);
}

.table tbody td {
    border: none;
    border-bottom: 1px solid var(--slate);
    padding: var(--space-4);
    vertical-align: middle;
}

/* ============================================================================
   ALERTS
   ============================================================================ */
.alert {
    background-color: var(--charcoal);
    border: none;
    border-radius: var(--radius-md);
    padding: var(--space-4) var(--space-5);
    font-family: var(--font-ui);
    box-shadow: var(--shadow-subtle);
    color: var(--pearl);
}

.alert-success {
    background-color: rgba(74, 222, 128, 0.1);
    border-left: 3px solid var(--success-color);
}

.alert-danger {
    background-color: rgba(248, 113, 113, 0.1);
    border-left: 3px solid var(--danger-color);
}

.alert-warning {
    background-color: rgba(251, 191, 36, 0.1);
    border-left: 3px solid var(--warning-color);
}

.alert-info {
    background-color: rgba(96, 165, 250, 0.1);
    border-left: 3px solid var(--info-color);
}

/* ============================================================================
   MODALS
   ============================================================================ */
.modal-content {
    background-color: var(--charcoal);
    border: 1px solid var(--slate);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lifted);
}

.modal-header {
    border-bottom: 1px solid var(--slate);
    padding: var(--space-5);
}

.modal-title {
    font-family: var(--font-ui);
    font-weight: 500;
    color: var(--ivory);
}

.modal-body {
    padding: var(--space-5);
    color: var(--silver);
}

.modal-footer {
    border-top: 1px solid var(--slate);
    padding: var(--space-4) var(--space-5);
}

.btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
    opacity: 0.5;
}

.btn-close:hover {
    opacity: 1;
}

/* ============================================================================
   SCORE DISPLAYS (Analytics)
   ============================================================================ */
.score-display {
    font-family: var(--font-ui);
    font-size: var(--text-2xl);
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
}

.score-good { color: var(--success-color); }
.score-poor { color: var(--danger-color); }
.score-medium { color: var(--warning-color); }

.score-circle {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: var(--text-sm);
    box-shadow: var(--shadow-medium);
}

.score-circle.good { background-color: var(--success-color); color: var(--ink-black); }
.score-circle.poor { background-color: var(--danger-color); color: white; }
.score-circle.medium { background-color: var(--warning-color); color: var(--ink-black); }

/* ============================================================================
   PROGRESS BARS
   ============================================================================ */
.progress {
    height: 6px;
    border-radius: var(--radius-full);
    background-color: var(--graphite);
    overflow: hidden;
}

.progress-bar {
    border-radius: var(--radius-full);
    transition: width 0.6s var(--ease-smooth);
    background-color: var(--accent);
}

/* ============================================================================
   METRIC CARDS
   ============================================================================ */
.metric-card {
    background-color: var(--charcoal);
    border: 1px solid var(--slate);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    text-align: center;
    transition: all var(--duration-normal) var(--ease-smooth);
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.metric-value {
    font-family: var(--font-ui);
    font-size: var(--text-2xl);
    font-weight: 600;
    line-height: 1;
    margin-bottom: var(--space-2);
    color: var(--ivory);
}

.metric-label {
    font-family: var(--font-ui);
    font-size: var(--text-xs);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--pewter);
}

/* Stats card */
.stats-card {
    background-color: var(--charcoal);
    border: 1px solid var(--slate);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    text-align: center;
    transition: all var(--duration-normal) var(--ease-smooth);
}

.stats-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.stats-icon {
    font-size: var(--text-2xl);
    margin-bottom: var(--space-4);
    color: var(--pewter);
}

/* ============================================================================
   CHART CONTAINERS
   ============================================================================ */
.chart-container {
    position: relative;
    height: 400px;
    margin: var(--space-5) 0;
    padding: var(--space-4);
    background-color: var(--charcoal);
    border-radius: var(--radius-lg);
    border: 1px solid var(--slate);
}

.chart-loading,
.chart-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 300px;
    background-color: var(--graphite);
    border-radius: var(--radius-md);
    color: var(--pewter);
}

/* ============================================================================
   TEXT UTILITIES
   ============================================================================ */
.text-muted {
    color: var(--pewter) !important;
}

.text-secondary {
    color: var(--silver) !important;
}

.text-primary {
    color: var(--accent) !important;
}

.text-dark {
    color: var(--ivory) !important;
}

/* ============================================================================
   CODE BLOCKS
   ============================================================================ */
pre {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    background-color: var(--ink-black);
    border: 1px solid var(--slate);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    color: var(--silver);
}

code {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--accent);
    background-color: var(--graphite);
    padding: 2px var(--space-2);
    border-radius: var(--radius-sm);
}

/* Footer (legacy, hidden in sidebar layout) */

/* ============================================================================
   USER AVATAR
   ============================================================================ */
.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background-color: var(--graphite);
    color: var(--pearl);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-ui);
    font-weight: 500;
    font-size: var(--text-sm);
}

.user-avatar-lg {
    width: 80px;
    height: 80px;
    font-size: var(--text-xl);
}

/* ============================================================================
   LANDING PAGE - Single Focal Point
   ============================================================================ */
.landing-page {
    background: transparent;
}

.landing-hero {
    padding: var(--space-7) 0 var(--space-6);
}

.landing-hero-inner {
    max-width: 700px;
}

.landing-hero .hero-headline {
    margin-bottom: var(--space-4);
    font-size: var(--text-2xl);
}

.hero-bullets {
    color: var(--silver);
    font-size: var(--text-sm);
    line-height: 1.6;
}

.hero-bullets p {
    margin: 0 0 var(--space-1);
}

/* Statement section (replaces "How It Works" numbered steps) */
.statement-section {
    padding: var(--space-8) 0;
    text-align: center;
}

.statement-section h2 {
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: var(--text-xl);
    color: var(--pearl);
    margin-bottom: var(--space-7);
}

.statement {
    font-family: var(--font-ui);
    font-size: var(--text-lg);
    color: var(--silver);
    margin-bottom: var(--space-5);
    opacity: 0;
    transform: translateY(8px);
    transition: all var(--duration-normal) var(--ease-smooth);
}

.statement.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Characters preview - horizontal scroll on landing */
.characters-preview {
    padding: var(--space-7) 0;
}

.characters-preview h2 {
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: var(--text-xl);
    color: var(--pearl);
    text-align: center;
    margin-bottom: var(--space-6);
}

/* Persona Cards - Mystery, Not Information Overload */
.persona-card {
    background-color: var(--charcoal);
    border: 1px solid transparent;
    border-radius: var(--radius-lg);
    transition: all var(--duration-normal) var(--ease-smooth);
}

.persona-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
    border-color: var(--slate);
}

.persona-card .card-title {
    font-family: var(--font-voice);
    font-weight: 500;
    color: var(--ivory);
    font-size: var(--text-lg);
}

.persona-card .card-text {
    color: var(--pewter);
    font-size: var(--text-sm);
}

/* Character avatar - gold ring only on hover/focus */
.persona-avatar-lg {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-full);
    background-color: var(--graphite);
    color: var(--pearl);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-voice);
    font-weight: 500;
    font-size: var(--text-2xl);
    border: 2px solid transparent;
    transition: border-color var(--duration-normal) var(--ease-smooth);
}

.persona-card:hover .persona-avatar-lg,
.persona-card:focus-within .persona-avatar-lg {
    border-color: var(--accent);
}

.persona-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background-color: var(--graphite);
    color: var(--pearl);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-ui);
    font-weight: 500;
    font-size: var(--text-base);
}

/* Conversation cards */
.conversation-card {
    background-color: var(--charcoal);
    border: 1px solid transparent;
    border-radius: var(--radius-lg);
    transition: all var(--duration-normal) var(--ease-smooth);
}

.conversation-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
    border-color: var(--slate);
}

/* Feature cards */
.feature-card {
    background-color: var(--charcoal);
    border: 1px solid var(--slate);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    text-align: center;
    transition: all var(--duration-normal) var(--ease-smooth);
}

.feature-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.feature-card i {
    color: var(--pewter) !important;
    font-size: var(--text-xl);
    margin-bottom: var(--space-4);
}

.feature-card h5 {
    font-family: var(--font-ui);
    font-weight: 500;
    color: var(--pearl);
    margin-bottom: var(--space-3);
}

.feature-card p {
    color: var(--pewter);
    font-size: var(--text-sm);
    margin-bottom: 0;
}

/* How it works section (simplified) */
.how-it-works {
    padding: var(--space-8) 0;
}

.how-it-works h2 {
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: var(--text-xl);
    color: var(--pearl);
    text-align: center;
    margin-bottom: var(--space-7);
}

.how-step {
    background-color: var(--charcoal);
    border: 1px solid transparent;
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    text-align: center;
    transition: all var(--duration-normal) var(--ease-smooth);
    position: relative;
}

.how-step:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
    border-color: var(--slate);
}

.how-step .step-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto var(--space-4);
    border-radius: var(--radius-full);
    background-color: var(--graphite);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--pewter);
    font-size: var(--text-lg);
}

.how-step .step-number {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    background-color: var(--accent);
    color: var(--ink-black);
    border-radius: var(--radius-full);
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: var(--text-xs);
    display: flex;
    align-items: center;
    justify-content: center;
}

.how-step h5 {
    font-family: var(--font-ui);
    font-weight: 500;
    color: var(--pearl);
    margin-bottom: var(--space-2);
}

.how-step p {
    color: var(--pewter);
    font-size: var(--text-sm);
    margin-bottom: 0;
}

/* Sections */
.recent-conversations,
.personas-section,
.features-section {
    padding: var(--space-7) 0;
}

.recent-conversations h2,
.personas-section h2 {
    font-family: var(--font-ui);
    font-weight: 600;
    color: var(--pearl);
}

/* Background light override */
.bg-light {
    background-color: var(--charcoal) !important;
}

/* ============================================================================
   CHARACTER GRID - 5 Column Layout for Landing + Characters
   ============================================================================ */
.characters-section {
    padding: var(--space-5) 0;
}

.characters-tabs {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
}

.tab-btn {
    background: none;
    border: none;
    font-family: var(--font-ui);
    font-size: var(--text-base);
    font-weight: 500;
    color: var(--pewter);
    padding: var(--space-2) var(--space-4);
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-smooth);
}

.tab-btn.active {
    color: var(--ivory);
    border-bottom-color: var(--accent);
}

.tab-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.category-pills {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-6);
    flex-wrap: wrap;
}

.pill {
    font-family: var(--font-ui);
    font-size: var(--text-xs);
    font-weight: 500;
    padding: var(--space-1) var(--space-4);
    border-radius: var(--radius-full);
    background-color: var(--graphite);
    color: var(--silver);
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-smooth);
}

.pill.active {
    background-color: var(--accent);
    color: white;
}

.pill:hover:not(.active) {
    background-color: var(--slate);
    color: var(--pearl);
}

.characters-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: var(--space-5);
}

.character-card {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: transform var(--duration-normal) var(--ease-smooth),
                box-shadow var(--duration-normal) var(--ease-smooth);
}

.character-card-overflow {
    display: none;
}

.character-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lifted);
}

.character-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.character-card .card-image {
    aspect-ratio: 3/4;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.character-card .card-image-initial {
    font-family: var(--font-display);
    font-size: var(--text-hero);
    font-weight: 600;
    color: rgba(255, 255, 255, 0.2);
}

.character-card .card-info {
    padding: var(--space-3) var(--space-1) var(--space-1);
}

.character-card .card-name {
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--ivory);
    margin: 0 0 var(--space-1);
    line-height: 1.3;
}

.character-card .card-desc {
    font-family: var(--font-ui);
    font-size: var(--text-xs);
    color: var(--pewter);
    margin: 0 0 var(--space-2);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.character-card .card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.character-card .card-creator {
    font-size: var(--text-xs);
    color: var(--silver);
}

.character-card .card-views {
    font-size: var(--text-xs);
    color: var(--pewter);
}

.character-card .card-chat-btn {
    margin-top: var(--space-2);
    width: 100%;
    font-size: var(--text-xs);
    padding: var(--space-2) var(--space-3);
}

.see-more-link {
    color: var(--silver);
    text-decoration: none;
    font-family: var(--font-ui);
    font-size: var(--text-sm);
    transition: color var(--duration-fast) var(--ease-smooth);
}

.see-more-link:hover {
    color: var(--accent);
}

/* ============================================================================
   CHARACTER PROFILE PAGE
   ============================================================================ */
.character-profile {
    max-width: 1000px;
}

.character-profile-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: var(--space-7);
    align-items: start;
}

.profile-left {
    position: sticky;
    top: var(--space-5);
}

.profile-image {
    aspect-ratio: 3/4;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-4);
}

.profile-image-initial {
    font-family: var(--font-display);
    font-size: 5rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.15);
}

.profile-creator {
    font-size: var(--text-sm);
    color: var(--silver);
    margin-bottom: var(--space-3);
    text-align: center;
}

.profile-name {
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    color: var(--ivory);
    margin-bottom: var(--space-3);
}

.profile-description {
    color: var(--silver);
    font-size: var(--text-base);
    line-height: 1.6;
    margin-bottom: var(--space-5);
}

.profile-stats {
    display: flex;
    gap: var(--space-6);
    margin-bottom: var(--space-5);
}

.profile-stats .stat {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--pewter);
    font-size: var(--text-sm);
}

.profile-stats .stat i {
    color: var(--silver);
}

.profile-traits {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-bottom: var(--space-5);
}

.trait-tag {
    font-family: var(--font-ui);
    font-size: var(--text-xs);
    font-weight: 500;
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    background-color: var(--accent-soft);
    color: var(--accent);
}

.profile-date {
    font-size: var(--text-sm);
    color: var(--pewter);
    margin-bottom: var(--space-5);
}

.profile-section {
    margin-bottom: var(--space-6);
}

.profile-section h3 {
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: var(--text-base);
    color: var(--pearl);
    margin-bottom: var(--space-3);
}

.profile-section p {
    color: var(--silver);
    font-size: var(--text-sm);
    line-height: 1.7;
}

.profile-actions {
    display: flex;
    gap: var(--space-3);
    margin-bottom: var(--space-6);
}

.activity-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    background-color: var(--success-color);
    margin-right: var(--space-2);
}

.activity-item {
    font-size: var(--text-sm);
    color: var(--pewter);
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--slate);
}

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

.activity-item.activity-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--graphite);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    border-bottom: none;
    margin-bottom: var(--space-2);
}

.activity-item.activity-card:last-child {
    margin-bottom: 0;
}

.activity-time {
    font-size: var(--text-xs);
    color: var(--pewter);
    white-space: nowrap;
    margin-left: var(--space-3);
}

/* Topbar auth buttons container */
.topbar-auth {
    display: flex;
    gap: var(--space-2);
    align-items: center;
}

/* ============================================================================
   CHARACTERS PAGE (legacy search)
   ============================================================================ */
.characters-page h1 {
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    color: var(--ivory);
}

.characters-page .input-group {
    max-width: 400px;
    margin: 0 auto;
}

.characters-page .input-group-text {
    background-color: transparent;
    border: none;
    color: var(--pewter);
}

.characters-page #characterSearch {
    background-color: transparent;
    border: none;
    border-bottom: 1px solid var(--slate);
    border-radius: 0;
    padding-left: 0;
}

.characters-page #characterSearch:focus {
    border-bottom-color: var(--accent);
    box-shadow: none;
}

/* ============================================================================
   SPINNER
   ============================================================================ */
.spinner-border {
    color: var(--accent) !important;
}

/* ============================================================================
   RESPONSIVE ADJUSTMENTS
   ============================================================================ */
@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform var(--duration-normal) var(--ease-smooth);
    }

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

    .sidebar-mobile-toggle {
        display: block;
    }

    .main-area {
        margin-left: 0;
    }

    .main-content {
        padding: var(--space-5) var(--space-4);
        padding-top: calc(var(--space-5) + 48px);
    }

    .topbar {
        padding-left: calc(var(--space-6) + 40px);
    }

    .characters-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

@media (max-width: 768px) {
    :root {
        --text-hero: 2.5rem;
        --text-2xl: 1.75rem;
    }

    .landing-hero {
        padding: var(--space-7) 0 var(--space-6);
    }

    .landing-hero .lead {
        font-size: var(--text-base);
    }

    .card-body {
        padding: var(--space-4);
    }

    .chart-container {
        height: 300px;
        padding: var(--space-3);
    }

    .characters-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .character-profile-layout {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 576px) {
    .main-content {
        padding: var(--space-4);
        padding-top: calc(var(--space-4) + 48px);
    }

    .btn-group {
        flex-direction: column;
        width: 100%;
    }

    .btn-group .btn {
        border-radius: var(--radius-md) !important;
        margin-bottom: var(--space-1);
    }

    .characters-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ============================================================================
   PRINT STYLES
   ============================================================================ */
@media print {
    .sidebar,
    .sidebar-mobile-toggle,
    .btn,
    .alert {
        display: none !important;
    }

    .card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #000;
    }

    body {
        background: white !important;
        color: black !important;
    }
}

/* ============================================================================
   CHARACTER CREATE / EDIT FORM
   ============================================================================ */

.character-form-page {
    max-width: 860px;
    padding: var(--space-6) var(--space-5);
}

/* Individual field group */
.char-form-group {
    margin-bottom: var(--space-6);
}

.char-form-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--pearl);
    margin-bottom: var(--space-3);
    letter-spacing: 0.01em;
}

/* Single-line text input */
.char-form-input {
    width: 100%;
    background: var(--graphite);
    border: 1px solid var(--slate);
    border-radius: var(--radius-md);
    color: var(--ivory);
    font-family: var(--font-ui);
    font-size: var(--text-base);
    padding: 14px var(--space-4);
    transition: border-color var(--duration-fast) var(--ease-smooth);
    outline: none;
}

.char-form-input::placeholder { color: var(--pewter); }

.char-form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Multi-line textarea */
.char-form-textarea {
    width: 100%;
    min-height: 180px;
    background: var(--graphite);
    border: 1px solid var(--slate);
    border-radius: var(--radius-md);
    color: var(--ivory);
    font-family: var(--font-ui);
    font-size: var(--text-base);
    line-height: 1.6;
    padding: 14px var(--space-4);
    resize: vertical;
    transition: border-color var(--duration-fast) var(--ease-smooth);
    outline: none;
}

.char-form-textarea::placeholder { color: var(--pewter); }

.char-form-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Persona section */
.char-persona-section { margin-top: var(--space-2); }

.char-persona-hint {
    font-weight: 400;
    color: var(--pewter);
    font-size: var(--text-sm);
}

.char-tone-group {
    margin-top: var(--space-5);
}

.char-tone-group-title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--pearl);
    margin-bottom: var(--space-3);
}

/* Checkbox grid: 4 columns */
.char-tone-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-3);
}

/* Wider grid for clinical diagnoses (2 columns — longer labels) */
.char-tone-grid--wide {
    grid-template-columns: repeat(2, 1fr);
}

.char-tone-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
}

.char-tone-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}

.char-tone-label {
    font-size: var(--text-sm);
    color: var(--silver);
    user-select: none;
}

.char-tone-item:hover .char-tone-label { color: var(--ivory); }

/* Submit row */
.char-form-submit {
    display: flex;
    gap: var(--space-3);
    padding-top: var(--space-4);
    margin-top: var(--space-5);
    border-top: 1px solid var(--slate);
}

.char-submit-btn {
    padding: 12px var(--space-6);
    font-size: var(--text-base);
    font-weight: 500;
}

.char-cancel-btn {
    padding: 12px var(--space-5);
    font-size: var(--text-base);
}

/* Edit button on character detail page */
.profile-edit-btn-wrap {
    display: flex;
    justify-content: flex-end;
    margin-bottom: var(--space-4);
}

.profile-edit-btn {
    font-size: var(--text-sm);
    color: var(--silver);
    border-color: var(--slate);
}

.profile-edit-btn:hover {
    color: var(--ivory);
    border-color: var(--silver);
}

/* Responsive adjustments */
@media (max-width: 767px) {
    .char-tone-grid { grid-template-columns: repeat(2, 1fr); }
    .char-tone-grid--wide { grid-template-columns: 1fr; }
    .character-form-page { padding: var(--space-4); }
}
