/* Premium V2 Theme - Peptide Coach
 * A refined, performance-optimized evolution of the premium theme
 * Mobile-first approach with smooth 60fps animations
 */

/* ============================================
   CSS CUSTOM PROPERTIES
   ============================================ */
:root {
    /* Core Colors */
    --beige: #F9F5EF;
    --beige-dark: #EDE7DD;
    --beige-darker: #DDD6C9;
    --charcoal: #282828;
    --charcoal-light: #3A3A3A;
    --charcoal-dark: #1A1A1A;
    --charcoal-darker: #121212;

    /* Accent */
    --gold: #C9A961;
    --gold-light: #D4B976;
    --gold-dark: #B89A52;
    --gold-glow: rgba(201, 169, 97, 0.15);

    /* Text */
    --text-primary: #F9F5EF;
    --text-secondary: #A8A299;
    --text-muted: #706B63;
    --text-dark: #282828;

    /* Borders */
    --border-light: #E5DFD5;
    --border-dark: #404040;
    --border-subtle: #333333;

    /* Shadows - optimized for performance */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.2);
    --shadow-gold: 0 0 0 3px var(--gold-glow);

    /* Layout */
    --sidebar-width: 280px;
    --header-height: 72px;
    --footer-height: 56px;
    --content-max-width: 800px;
    --input-max-width: 720px;

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

    /* Animation */
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
    --duration-fast: 150ms;
    --duration-normal: 250ms;
    --duration-slow: 350ms;

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

    /* Touch targets */
    --touch-target: 44px;

    /* Status/Error Colors */
    --error: #dc3545;
    --error-light: #ff6b6b;
    --error-bg: rgba(220, 53, 69, 0.1);
    --error-border: rgba(220, 53, 69, 0.3);
}

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

html {
    height: 100%;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    background: var(--charcoal);
    color: var(--text-primary);
    overflow-x: hidden;
    overscroll-behavior: none;
}

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

:focus:not(:focus-visible) {
    outline: none;
}

/* Smooth scrolling with reduced motion support */
@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

/* ============================================
   LAYOUT
   ============================================ */
.app {
    display: flex;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--beige);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transform: translateX(0);
    transition: transform var(--duration-slow) var(--ease-out);
    will-change: transform;
}

.sidebar-header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-light);
}

.new-chat-btn {
    width: 100%;
    padding: var(--space-md) var(--space-lg);
    background: var(--charcoal);
    color: var(--beige);
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease-out),
                transform var(--duration-fast) var(--ease-out);
    min-height: var(--touch-target);
}

.new-chat-btn:hover {
    background: var(--charcoal-light);
}

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

.sidebar-close {
    display: none;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-sm);
    scrollbar-width: thin;
    scrollbar-color: var(--border-light) transparent;
}

.chat-list::-webkit-scrollbar {
    width: 6px;
}

.chat-list::-webkit-scrollbar-track {
    background: transparent;
}

.chat-list::-webkit-scrollbar-thumb {
    background: var(--beige-darker);
    border-radius: var(--radius-full);
}

.chat-list-empty {
    padding: var(--space-2xl) var(--space-lg);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md);
    margin-bottom: var(--space-xs);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease-out);
    min-height: var(--touch-target);
}

.chat-item:hover {
    background: var(--beige-dark);
}

.chat-item.active {
    background: var(--charcoal);
}

.chat-item.active .chat-title,
.chat-item.active .chat-meta {
    color: var(--beige);
}

.chat-preview {
    flex: 1;
    min-width: 0;
}

.chat-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.chat-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.chat-delete {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    opacity: 0;
    transition: opacity var(--duration-fast),
                background var(--duration-fast),
                color var(--duration-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

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

.chat-delete:hover {
    background: var(--error-bg);
    color: var(--error);
}

/* Main Content */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--charcoal);
}

/* Header */
.header {
    height: var(--header-height);
    padding: 0 var(--space-xl);
    border-bottom: 1px solid var(--border-dark);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.menu-btn {
    display: none;
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.logo-icon {
    width: 36px;
    height: 36px;
    color: var(--gold);
}

.logo-text h1 {
    font-size: 1rem;
    font-weight: 400;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.logo-text p {
    font-size: 0.6875rem;
    color: var(--text-secondary);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.session-badge {
    padding: var(--space-sm) var(--space-md);
    background: var(--charcoal-light);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-xl);
    scrollbar-width: thin;
    scrollbar-color: var(--border-dark) transparent;
}

.chat-container::-webkit-scrollbar {
    width: 6px;
}

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

.chat-container::-webkit-scrollbar-thumb {
    background: var(--border-dark);
    border-radius: var(--radius-full);
}

.chat-container::-webkit-scrollbar-thumb:hover {
    background: var(--gold-dark);
}

/* Welcome Screen */
.welcome {
    max-width: 600px;
    margin: var(--space-2xl) auto;
    text-align: center;
    padding: 0 var(--space-md);
}

.welcome-title {
    font-size: 2rem;
    font-weight: 300;
    color: var(--text-primary);
    margin-bottom: var(--space-md);
    letter-spacing: 0.5px;
    line-height: 1.3;
}

.welcome-subtitle {
    font-size: 1.0625rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-2xl);
    line-height: 1.5;
}

/* Trust Badges */
.trust-badges {
    display: flex;
    justify-content: center;
    gap: var(--space-xl);
    margin-bottom: var(--space-2xl);
    flex-wrap: wrap;
}

.trust-badge {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--text-secondary);
    font-size: 0.8125rem;
}

.trust-badge svg {
    width: 18px;
    height: 18px;
    color: var(--gold);
}

/* Quick Start */
.quick-start {
    margin-top: var(--space-2xl);
}

.quick-start-label {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-lg);
}

.suggestion-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
    max-width: 420px;
    margin: 0 auto;
}

.suggestion-btn {
    padding: var(--space-md) var(--space-lg);
    background: var(--charcoal-light);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease-out),
                border-color var(--duration-fast) var(--ease-out),
                transform var(--duration-fast) var(--ease-out);
    min-height: var(--touch-target);
}

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

.suggestion-btn:active {
    transform: scale(0.98);
}

/* Recent Chats (Welcome Back) */
.recent-chats {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    margin: var(--space-xl) 0;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.recent-chat {
    padding: var(--space-lg);
    background: var(--charcoal-light);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-md);
    cursor: pointer;
    text-align: left;
    transition: border-color var(--duration-fast) var(--ease-out),
                transform var(--duration-fast) var(--ease-out);
    min-height: var(--touch-target);
}

.recent-chat:hover {
    border-color: var(--gold);
}

.recent-chat:active {
    transform: scale(0.99);
}

.recent-chat-preview {
    font-size: 0.9375rem;
    color: var(--text-primary);
    font-weight: 500;
    margin-bottom: var(--space-xs);
}

.recent-chat-meta {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

/* Messages */
.messages-wrapper {
    max-width: var(--content-max-width);
    margin: 0 auto;
    width: 100%;
}

.message {
    display: flex;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
    animation: messageIn var(--duration-slow) var(--ease-out);
}

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

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

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8125rem;
    font-weight: 600;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: var(--beige);
    color: var(--charcoal);
}

.message.assistant .message-avatar {
    background: var(--gold);
    color: var(--charcoal);
}

.message-content {
    max-width: 75%;
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-lg);
    line-height: 1.7;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message.user .message-content {
    background: var(--beige);
    color: var(--text-dark);
    border-bottom-right-radius: var(--radius-sm);
}

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

/* Markdown Content */
.message-content h3,
.message-content h4,
.message-content h5 {
    margin-top: var(--space-md);
    margin-bottom: var(--space-sm);
    font-weight: 500;
}

.message-content p {
    margin-bottom: var(--space-sm);
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content a {
    color: var(--gold);
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color var(--duration-fast);
}

.message-content a:hover {
    color: var(--gold-light);
}

.message.user .message-content a {
    color: var(--charcoal);
}

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

.message-content ul,
.message-content ol {
    margin: var(--space-sm) 0;
    padding-left: var(--space-lg);
}

.message-content li {
    margin-bottom: var(--space-xs);
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.typing-dots {
    display: flex;
    gap: 6px;
    padding: var(--space-md) var(--space-lg);
    background: var(--charcoal-light);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-lg);
    border-bottom-left-radius: var(--radius-sm);
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gold);
    animation: typingBounce 1.2s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.15s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* Error Message */
.error-message {
    max-width: var(--content-max-width);
    margin: 0 auto var(--space-xl);
    padding: var(--space-md) var(--space-lg);
    background: var(--error-bg);
    border: 1px solid var(--error-border);
    border-left-width: 3px;
    border-radius: var(--radius-md);
    color: var(--error-light);
    font-size: 0.875rem;
    animation: messageIn var(--duration-slow) var(--ease-out);
}

/* Rate Limit Message */
.limit-message {
    max-width: var(--content-max-width);
    margin: 0 auto var(--space-xl);
    padding: var(--space-lg);
    background: var(--gold-glow);
    border: 1px solid var(--gold);
    border-radius: var(--radius-md);
    display: flex;
    gap: var(--space-md);
    align-items: flex-start;
    animation: messageIn var(--duration-slow) var(--ease-out);
}

.limit-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.limit-content {
    flex: 1;
    color: var(--text-primary);
    font-size: 0.9375rem;
    line-height: 1.6;
}

.limit-content a {
    color: var(--gold);
    text-decoration: underline;
    font-weight: 500;
}

/* Input Area */
.input-area {
    padding: var(--space-lg) var(--space-xl) var(--space-xl);
    border-top: 1px solid var(--border-dark);
    flex-shrink: 0;
}

.chat-form {
    max-width: var(--input-max-width);
    margin: 0 auto;
}

.input-wrapper {
    display: flex;
    gap: var(--space-md);
    align-items: flex-end;
    background: var(--charcoal-light);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    transition: border-color var(--duration-fast) var(--ease-out),
                box-shadow var(--duration-fast) var(--ease-out);
}

.input-wrapper:focus-within {
    border-color: var(--gold);
    box-shadow: var(--shadow-gold);
}

.message-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 1rem;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    color: var(--text-primary);
    line-height: 1.5;
}

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

.message-input::placeholder {
    color: var(--text-muted);
}

.send-btn {
    width: var(--touch-target);
    height: var(--touch-target);
    border: none;
    border-radius: var(--radius-md);
    background: var(--gold);
    color: var(--charcoal);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background var(--duration-fast) var(--ease-out),
                transform var(--duration-fast) var(--ease-out);
}

.send-btn:hover:not(:disabled) {
    background: var(--gold-light);
}

.send-btn:active:not(:disabled) {
    transform: scale(0.95);
}

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

.send-btn svg {
    width: 20px;
    height: 20px;
}

/* Footer */
.footer {
    padding: var(--space-md) var(--space-xl);
    border-top: 1px solid var(--border-dark);
    flex-shrink: 0;
}

.footer-content {
    max-width: var(--input-max-width);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    flex-wrap: wrap;
    font-size: 0.8125rem;
}

.footer-link {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color var(--duration-fast);
    padding: var(--space-xs) var(--space-sm);
}

.footer-link:hover {
    color: var(--gold);
}

.footer-link.danger:hover {
    color: var(--error-light);
}

.footer-sep {
    color: var(--text-muted);
    opacity: 0.5;
}

/* Dropdowns */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-trigger {
    color: var(--text-secondary);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: color var(--duration-fast);
    padding: var(--space-xs) var(--space-sm);
    user-select: none;
}

.dropdown-trigger:hover {
    color: var(--gold);
}

.dropdown-menu {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: var(--space-sm);
    background: var(--charcoal-light);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: var(--space-sm);
    display: none;
    flex-direction: column;
    gap: 2px;
    min-width: 200px;
    z-index: 100;
}

.dropdown-menu.show {
    display: flex;
    animation: dropdownIn var(--duration-fast) var(--ease-out);
}

@keyframes dropdownIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.dropdown-item {
    padding: var(--space-sm) var(--space-md);
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.8125rem;
    text-align: left;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background var(--duration-fast);
    white-space: nowrap;
    min-height: 36px;
    display: flex;
    align-items: center;
}

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

.dropdown-item.active {
    background: var(--gold);
    color: var(--charcoal);
    font-weight: 500;
}

/* Mobile Settings Panel */
.settings-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--charcoal-light);
    border-top: 1px solid var(--gold);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    transform: translateY(100%);
    transition: transform var(--duration-slow) var(--ease-out);
    z-index: 1000;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.4);
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.settings-panel.show {
    transform: translateY(0);
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-dark);
    flex-shrink: 0;
}

.settings-header h3 {
    font-size: 1.125rem;
    font-weight: 400;
    color: var(--gold);
    letter-spacing: 0.5px;
}

.settings-close {
    width: var(--touch-target);
    height: var(--touch-target);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 1.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--duration-fast);
}

.settings-close:hover {
    color: var(--text-primary);
}

.settings-content {
    padding: var(--space-lg);
    overflow-y: auto;
    flex: 1;
}

.setting-group {
    margin-bottom: var(--space-xl);
}

.setting-group:last-child {
    margin-bottom: 0;
}

.setting-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-md);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.setting-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
}

.setting-options.single-col {
    grid-template-columns: 1fr;
}

.setting-option {
    padding: var(--space-md);
    background: var(--charcoal);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: background var(--duration-fast),
                border-color var(--duration-fast);
    min-height: var(--touch-target);
    display: flex;
    align-items: center;
    justify-content: center;
}

.setting-option:hover {
    border-color: var(--gold);
}

.setting-option.active {
    background: var(--gold);
    border-color: var(--gold);
    color: var(--charcoal);
    font-weight: 500;
}

.reset-btn {
    width: 100%;
    padding: var(--space-md);
    background: transparent;
    border: 1px solid var(--error-border);
    border-radius: var(--radius-md);
    color: var(--error-light);
    font-size: 0.875rem;
    cursor: pointer;
    transition: background var(--duration-fast),
                border-color var(--duration-fast);
    min-height: var(--touch-target);
}

.reset-btn:hover {
    background: var(--error-bg);
    border-color: var(--error-light);
}

/* Settings Backdrop */
.settings-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--duration-normal),
                visibility var(--duration-normal);
}

.settings-backdrop.show {
    opacity: 1;
    visibility: visible;
}

/* Sidebar Backdrop (mobile) */
.sidebar-backdrop {
    display: none;
}

@media (max-width: 768px) {
    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 199;
        opacity: 0;
        visibility: hidden;
        transition: opacity var(--duration-normal),
                    visibility var(--duration-normal);
    }

    .sidebar-backdrop.show {
        opacity: 1;
        visibility: visible;
    }
}

/* Modals */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--duration-normal),
                visibility var(--duration-normal);
}

.modal-backdrop.show {
    opacity: 1;
    visibility: visible;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    background: var(--charcoal-light);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-lg);
    z-index: 2001;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--duration-normal),
                visibility var(--duration-normal),
                transform var(--duration-normal) var(--ease-out);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal.show {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-dark);
    flex-shrink: 0;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 400;
    color: var(--text-primary);
}

.modal-close {
    width: var(--touch-target);
    height: var(--touch-target);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--duration-fast);
    border-radius: var(--radius-sm);
}

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

.modal-body {
    padding: var(--space-lg);
    overflow-y: auto;
    flex: 1;
    color: var(--text-primary);
    line-height: 1.7;
}

.modal-body h1,
.modal-body h2,
.modal-body h3 {
    color: var(--gold);
    margin-top: var(--space-lg);
    margin-bottom: var(--space-md);
}

.modal-body h1:first-child,
.modal-body h2:first-child,
.modal-body h3:first-child {
    margin-top: 0;
}

.modal-body a {
    color: var(--gold);
}

.modal-body p {
    margin-bottom: var(--space-md);
}


/* ============================================
   RESPONSIVE - MOBILE (< 768px)
   ============================================ */
@media (max-width: 767px) {
    :root {
        --header-height: 60px;
        --footer-height: 48px;
    }

    /* Sidebar - Off-canvas on mobile */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        z-index: 200;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
    }

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

    .sidebar-header {
        padding-top: 4rem;
        position: relative;
    }

    .sidebar-close {
        display: flex;
        position: absolute;
        top: var(--space-md);
        right: var(--space-md);
        width: var(--touch-target);
        height: var(--touch-target);
        border: none;
        background: var(--charcoal);
        color: var(--beige);
        font-size: 1.25rem;
        cursor: pointer;
        border-radius: var(--radius-sm);
        align-items: center;
        justify-content: center;
    }

    /* Menu button visible on mobile */
    .menu-btn {
        display: flex;
        width: var(--touch-target);
        height: var(--touch-target);
        border: 1px solid var(--border-dark);
        background: var(--charcoal-light);
        color: var(--text-primary);
        font-size: 1.25rem;
        cursor: pointer;
        border-radius: var(--radius-md);
        align-items: center;
        justify-content: center;
    }

    /* Header adjustments */
    .header {
        padding: 0 var(--space-md);
    }

    .logo-text h1 {
        font-size: 0.875rem;
    }

    .logo-text p {
        display: none;
    }

    .session-badge {
        display: none;
    }

    /* Chat container */
    .chat-container {
        padding: var(--space-md);
    }

    /* Welcome */
    .welcome {
        margin: var(--space-lg) auto;
    }

    .welcome-title {
        font-size: 1.5rem;
    }

    .welcome-subtitle {
        font-size: 0.9375rem;
        margin-bottom: var(--space-xl);
    }

    .trust-badges {
        flex-direction: column;
        gap: var(--space-md);
        margin-bottom: var(--space-xl);
    }

    .trust-badge {
        font-size: 0.75rem;
    }

    .trust-badge svg {
        width: 16px;
        height: 16px;
    }

    .suggestion-grid {
        gap: var(--space-sm);
    }

    .suggestion-btn {
        padding: var(--space-md);
        font-size: 0.8125rem;
    }

    /* Messages */
    .message {
        gap: var(--space-sm);
    }

    .message-avatar {
        width: 32px;
        height: 32px;
        font-size: 0.75rem;
    }

    .message-content {
        max-width: 85%;
        padding: var(--space-md);
        font-size: 0.9375rem;
    }

    /* Input */
    .input-area {
        padding: var(--space-md);
    }

    .message-input {
        font-size: 16px; /* Prevent iOS zoom */
    }

    /* Footer */
    .footer {
        padding: var(--space-sm) var(--space-md);
    }

    .footer-content {
        gap: var(--space-sm);
    }

    .footer-sep,
    .footer-link.desktop-only,
    .dropdown.desktop-only {
        display: none;
    }

    .footer-link.mobile-toggle {
        display: inline;
    }
}

/* ============================================
   RESPONSIVE - SMALL MOBILE (< 400px)
   ============================================ */
@media (max-width: 399px) {
    .welcome-title {
        font-size: 1.375rem;
    }

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

    .suggestion-btn {
        font-size: 0.875rem;
    }

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

/* ============================================
   UTILITY CLASSES
   ============================================ */
.desktop-only {
    display: inline;
}

.mobile-only {
    display: none;
}

@media (max-width: 767px) {
    .desktop-only {
        display: none !important;
    }

    .mobile-only {
        display: inline !important;
    }
}

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

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

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .sidebar,
    .header,
    .footer,
    .input-area,
    .settings-panel,
    .modal-backdrop,
    .modal {
        display: none !important;
    }

    .main {
        display: block;
    }

    .chat-container {
        overflow: visible;
        padding: 0;
    }
}
