/* Reset & Variables */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Prevent horizontal scroll on mobile */
html, body {
    overflow-x: hidden;
    max-width: 100%;
}

/* Global dark themed scrollbar for all elements */
::-webkit-scrollbar {
    width: 12px !important;
    height: 12px !important;
}

::-webkit-scrollbar-track {
    background: #030712 !important; /* var(--gray-950) */
    border-radius: 6px !important;
}

::-webkit-scrollbar-thumb {
    background: #374151 !important; /* var(--gray-700) */
    border-radius: 6px !important;
    border: 3px solid #030712 !important;
    background-clip: padding-box !important;
}

::-webkit-scrollbar-thumb:hover {
    background: #6366F1 !important; /* var(--primary) */
}

::-webkit-scrollbar-thumb:active {
    background: #4F46E5 !important; /* var(--primary-dark) */
}

/* Specific selectors for better coverage */
html::-webkit-scrollbar,
body::-webkit-scrollbar,
div::-webkit-scrollbar,
textarea::-webkit-scrollbar,
.messages::-webkit-scrollbar,
.sidebar::-webkit-scrollbar,
.modal-content::-webkit-scrollbar {
    width: 12px !important;
    height: 12px !important;
}

html::-webkit-scrollbar-track,
body::-webkit-scrollbar-track,
div::-webkit-scrollbar-track,
textarea::-webkit-scrollbar-track,
.messages::-webkit-scrollbar-track,
.sidebar::-webkit-scrollbar-track,
.modal-content::-webkit-scrollbar-track {
    background: #030712 !important;
}

html::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb,
div::-webkit-scrollbar-thumb,
textarea::-webkit-scrollbar-thumb,
.messages::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb,
.modal-content::-webkit-scrollbar-thumb {
    background: #374151 !important;
    border-radius: 6px !important;
    border: 3px solid #030712 !important;
}

/* For Firefox */
* {
    scrollbar-width: thin !important;
    scrollbar-color: #374151 #030712 !important;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

:root {
    --black: #000000;
    --white: #FFFFFF;
    --gray-950: #030712;
    --gray-900: #111827;
    --gray-800: #1F2937;
    --gray-750: #283341;
    --gray-700: #374151;
    --gray-600: #4B5563;
    --gray-500: #6B7280;
    --gray-400: #9CA3AF;
    --gray-300: #D1D5DB;
    --gray-200: #E5E7EB;
    --gray-100: #F3F4F6;
    
    --primary: #6366F1;
    --primary-dark: #4F46E5;
    
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Safe area for iOS devices */
    --safe-area-inset-top: env(safe-area-inset-top, 0px);
}

/* Base */
html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--black);
    color: var(--white);
    line-height: 1.6;
    overflow: hidden;
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
}

/* App Container */
.app {
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    width: 100%;
    max-width: 100vw;
}

/* Header */
.header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--gray-900);
    position: relative;
    flex-shrink: 0;
    min-height: 60px;
    z-index: 100; /* Ensure header stays on top */
    background: var(--gray-950); /* Ensure background is set */
}

.header-left {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding-left: 1rem;
    padding-top: 0.5rem;
}

.header-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 1rem;
    padding-top: 0.5rem;
}

.header-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0 1rem;
}

.header-title {
    text-align: center;
}

.header-title h1 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--gray-400);
    margin: 0;
    white-space: normal;
    word-break: break-word;
    line-height: 1.2;
    text-align: center;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.125rem;
}

.logo-text {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    font-size: 1.5rem;
    letter-spacing: 0.15em;
    background: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 2px 4px rgba(99, 102, 241, 0.1);
    position: relative;
    padding-bottom: 2px;
}

.logo-text::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, #6366F1, #8B5CF6, transparent);
    opacity: 0.5;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.icon-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--gray-800);
    border-radius: var(--radius);
    color: var(--gray-400);
    cursor: pointer;
    transition: var(--transition);
    margin: 0;
}

.icon-btn:hover {
    color: var(--white);
    border-color: var(--gray-700);
    background: var(--gray-900);
}

.new-case-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
    border-radius: var(--radius);
    color: var(--white);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    animation: pulseGlow 3s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes pulseGlow {
    0%, 100% {
        box-shadow: 
            0 0 5px rgba(99, 102, 241, 0.5),
            0 0 10px rgba(99, 102, 241, 0.3),
            0 0 15px rgba(79, 70, 229, 0.2),
            inset 0 0 10px rgba(255, 255, 255, 0.1);
    }
    50% {
        box-shadow: 
            0 0 10px rgba(99, 102, 241, 0.8),
            0 0 20px rgba(99, 102, 241, 0.6),
            0 0 30px rgba(79, 70, 229, 0.4),
            inset 0 0 15px rgba(255, 255, 255, 0.2);
    }
}

.new-case-btn::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, var(--primary), var(--primary-dark), var(--primary));
    border-radius: var(--radius);
    opacity: 0;
    z-index: -1;
    transition: opacity 0.3s;
}

.new-case-btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    transition: left 0.5s;
}

.new-case-btn:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 
        0 0 20px rgba(99, 102, 241, 1),
        0 0 40px rgba(99, 102, 241, 0.8),
        0 0 60px rgba(79, 70, 229, 0.6);
}

.new-case-btn:hover::before {
    opacity: 1;
}

.new-case-btn:hover::after {
    left: 100%;
}

/* Premium Button */
.premium-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    margin: 0;
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    border: none;
    border-radius: var(--radius);
    color: var(--black);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
    flex-shrink: 0;
}

/* Ensure icon-only premium button matches icon-btn dimensions */
.premium-btn.icon-only {
    width: 40px;
    height: 40px;
    padding: 0;
}

.premium-btn:hover {
    transform: translateY(-1px) scale(1.02);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
    background: linear-gradient(135deg, #FFE55C 0%, #FFAA00 100%);
}

/* Premium button when user is subscribed */
.premium-btn.premium-active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
    animation: none; /* Remove pulse animation when active */
}

.premium-btn.premium-active:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, #4F46E5 100%);
    box-shadow: 0 0 25px rgba(99, 102, 241, 0.6);
    transform: translateY(-1px) scale(1.02);
}

/* Cancelled subscription styling */
.premium-btn.premium-active.subscription-cancelled {
    background: linear-gradient(135deg, #D97706 0%, #92400E 100%);
    box-shadow: 0 0 15px rgba(217, 119, 6, 0.4);
}

.premium-btn.premium-active.subscription-cancelled:hover {
    background: linear-gradient(135deg, #B45309 0%, #78350F 100%);
    box-shadow: 0 0 25px rgba(217, 119, 6, 0.6);
}

/* Cancel warning text */
.cancel-warning {
    background: rgba(217, 119, 6, 0.1);
    border: 1px solid rgba(217, 119, 6, 0.3);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    text-align: center;
    font-weight: 500;
}

/* Main Content */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Prevent double scrollbars */
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    padding: 0 2rem;
    position: relative;
    min-height: 0; /* Allow proper flex sizing */
}

.case-header {
    padding: 2rem 0 1rem;
    text-align: center;
}

.case-info-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.case-title-container {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    max-width: 100%;
}

.case-title-display {
    font-size: 0.875rem;
    font-weight: 500;
    margin: 0;
    cursor: pointer;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    transition: var(--transition);
    max-width: 400px;
    word-break: break-word;
    line-height: 1.4;
    color: var(--gray-400);
}

.case-title-display:hover {
    background: var(--gray-900);
    color: var(--gray-300);
    transform: scale(1.02);
}

.case-title-input {
    font-size: 0.875rem;
    font-weight: 600;
    background: var(--gray-900);
    border: 2px solid var(--primary);
    border-radius: 8px;
    color: var(--white);
    padding: 0.5rem 0.75rem;
    outline: none;
    text-align: center;
    max-width: 400px;
    width: 300px;
}

.case-title-input::placeholder {
    color: var(--gray-500);
}


.case-title-actions {
    display: flex;
    gap: 0.25rem;
}

.title-action-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
}

.title-action-btn.save-btn {
    background: var(--primary);
    color: var(--white);
}

.title-action-btn.save-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.title-action-btn.cancel-btn {
    background: var(--gray-800);
    color: var(--gray-400);
}

.title-action-btn.cancel-btn:hover {
    background: var(--gray-700);
    color: var(--white);
}

.case-header #case-id {
    font-size: 0.75rem;
    color: var(--gray-600);
    font-family: monospace;
    display: block;
    text-align: center;
    opacity: 0.8;
}

/* Messages */
.messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem 0;
    padding-bottom: 200px; /* Space for fixed input area + footer */
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    -ms-overflow-style: -ms-autohiding-scrollbar; /* Better scrolling on IE/Edge */
    scrollbar-gutter: stable; /* Prevent layout shift */
    will-change: scroll-position; /* Performance optimization */
    min-height: 0; /* Allow proper scrolling */
    
    /* Chrome-specific scroll fixes */
    transform: translateZ(0); /* Force GPU acceleration */
    -webkit-transform: translateZ(0);
    backface-visibility: hidden; /* Prevent flicker */
    -webkit-backface-visibility: hidden;
    
    /* Ensure content doesn't go under header */
    position: relative;
    
    /* Bottom-align welcome message when there's only one message */
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

/* When there are multiple messages, use normal flow */
.messages.has-multiple-messages {
    justify-content: flex-start;
}

/* Messages scrollbar styles moved to global section */

/* Welcome Screen */

/* Message Bubbles */
.message {
    margin-bottom: 1.5rem;
    animation: messageIn 0.3s ease-out;
}

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

.message-user {
    display: flex;
    justify-content: flex-end;
}

.message-user .bubble {
    background: var(--gray-900);
    border: 1px solid var(--gray-800);
    border-radius: var(--radius) var(--radius) 4px var(--radius);
    padding: 0.875rem 1.25rem;
    max-width: 70%;
}

.message-assistant .bubble {
    background: transparent;
    border: 1px solid var(--gray-900);
    border-radius: var(--radius) var(--radius) var(--radius) 4px;
    padding: 0.875rem 1.25rem;
    max-width: 85%;
}

.bubble {
    font-size: 0.9375rem;
    line-height: 1.6;
}

/* Legal Analysis Styling */
.message.legal-analysis {
    margin: 2rem 0;
}

.message.legal-analysis .bubble {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.05) 0%, rgba(139, 92, 246, 0.05) 100%);
    border: 2px solid var(--primary);
    box-shadow: 
        0 0 20px rgba(99, 102, 241, 0.1),
        0 4px 12px rgba(0, 0, 0, 0.3),
        inset 0 0 20px rgba(99, 102, 241, 0.05);
    max-width: 95%;
    padding: 1.5rem 2rem;
    position: relative;
    overflow: hidden;
}

.message.legal-analysis .bubble::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.1) 0%, transparent 70%);
    animation: legalPulse 4s ease-in-out infinite;
}

@keyframes legalPulse {
    0%, 100% {
        transform: scale(0.8);
        opacity: 0.3;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.1;
    }
}

.legal-analysis-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.1), transparent);
    border-radius: var(--radius);
    position: relative;
}

.legal-analysis-header::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 10%;
    right: 10%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
}

.legal-analysis-header.premium {
    background: linear-gradient(90deg, transparent, rgba(255, 215, 0, 0.1), transparent);
}

.legal-analysis-header.premium::after {
    background: linear-gradient(90deg, transparent, #FFD700, transparent);
}

.legal-icon {
    font-size: 2rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.legal-title {
    font-family: 'Cinzel', serif;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    background: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 2px 4px rgba(99, 102, 241, 0.2);
}

.legal-analysis-header.premium .legal-title {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Enhanced formatting for legal analysis content */
.message.legal-analysis h3 {
    color: var(--primary);
    margin: 1.5rem 0 1rem;
    font-weight: 600;
    position: relative;
    padding-left: 1rem;
}

.message.legal-analysis h3::before {
    content: '▸';
    position: absolute;
    left: 0;
    color: var(--primary);
}

.message.legal-analysis strong {
    color: var(--white);
    font-weight: 600;
}

.message.legal-analysis a {
    color: var(--primary);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: var(--transition);
}

.message.legal-analysis a:hover {
    border-bottom-color: var(--primary);
    text-shadow: 0 0 20px rgba(99, 102, 241, 0.5);
}

/* Input Area */
.input-area {
    position: fixed;
    bottom: 60px; /* Above footer */
    left: 0;
    right: 0;
    padding: 1rem;
    background: var(--black);
    border-top: 1px solid var(--gray-900);
    z-index: 200; /* Above footer (100) but below sidebar (300) */
    transition: bottom 0.2s ease-out;
    /* Ensure input area stays above keyboard on iOS */
    transform: translate3d(0, 0, 0);
    -webkit-transform: translate3d(0, 0, 0);
}

.attached-files {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
    max-height: 80px;
    overflow-y: auto;
    padding: 0.25rem 0;
}

.attached-file {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--gray-900);
    border: 1px solid var(--gray-800);
    border-radius: 8px;
    font-size: 0.875rem;
    color: var(--gray-300);
}

.attached-file svg {
    width: 16px;
    height: 16px;
    color: var(--gray-500);
}

.remove-file {
    background: none;
    border: none;
    color: var(--gray-500);
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    padding: 0;
    margin-left: 0.25rem;
}

.remove-file:hover {
    color: var(--white);
}

.input-form {
    position: relative;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Desktop input width constraint */
@media (min-width: 1024px) {
    .input-form {
        max-width: 800px;
        margin: 0 auto;
    }
}

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--gray-950);
    border: 1px solid var(--gray-800);
    border-radius: var(--radius);
    padding: 0.75rem;
    transition: var(--transition);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.input-wrapper:focus-within {
    border-color: var(--primary);
}

#message-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--white);
    font-size: 0.9375rem;
    line-height: 1.5;
    resize: none;
    outline: none;
    min-height: 40px;
    max-height: 120px;
    text-align: left;
    padding: 8px;
    display: block;
    -webkit-appearance: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    font-family: inherit;
    /* Ensure proper touch target */
    cursor: text;
    user-select: text;
    -webkit-user-select: text;
    /* Hide scrollbar */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
    align-self: stretch;
    width: 100%;
    box-sizing: border-box;
    word-wrap: break-word;
    overflow-wrap: break-word;
    /* Ensure input is always interactive */
    pointer-events: auto !important;
    -webkit-user-modify: read-write-plaintext-only;
}

/* Message input uses global dark scrollbar theme */

#message-input::placeholder {
    color: var(--gray-600);
}

/* Model Selector */
.model-selector-container {
    padding: 0 1rem;
    margin-bottom: 0.5rem;
}

.model-selector {
    display: flex;
    background: var(--gray-900);
    border-radius: var(--radius);
    padding: 0.1875rem;
    gap: 0.125rem;
    max-width: 160px;
    margin: 0 auto;
}

.model-option {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.model-option:hover:not(.active) {
    background: var(--gray-800);
}

.model-option.active {
    background: var(--primary);
}

.model-option .model-name {
    font-weight: 500;
    font-size: 0.8125rem;
    color: var(--gray-400);
    letter-spacing: 0.025em;
}

.model-option.active .model-name {
    color: var(--white);
}

.input-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.attach-btn,
.voice-btn,
.send-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.attach-btn,
.voice-btn {
    background: transparent;
    color: var(--gray-500);
}

.attach-btn:hover,
.voice-btn:hover {
    background: var(--gray-900);
    color: var(--gray-300);
}

.voice-btn.recording {
    background: var(--primary);
    color: var(--white);
    animation: voicePulse 1s ease-in-out infinite;
}

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

.send-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

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

/* Sidebar */
.sidebar {
    position: fixed;
    right: -400px;
    top: 0;
    bottom: 0;
    width: 400px;
    background: var(--gray-950);
    border-left: 1px solid var(--gray-900);
    transition: right 0.3s ease-out;
    z-index: 300; /* Higher than footer (100) and input area (200) */
    display: flex;
    flex-direction: column;
}

.sidebar.active {
    right: 0;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--gray-900);
}

.sidebar .new-case-btn {
    margin: 1rem;
    margin-bottom: 0;
    width: calc(100% - 2rem);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
    border-radius: var(--radius);
    color: var(--white);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    animation: pulseGlow 3s ease-in-out infinite;
    font-weight: 600;
    font-size: 0.9375rem;
}

.sidebar .new-case-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.sidebar .new-case-btn:active {
    transform: translateY(0);
}

.sidebar-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

.close-sidebar {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--gray-500);
    font-size: 1.5rem;
    cursor: pointer;
    border-radius: 8px;
}

.close-sidebar:hover {
    background: var(--gray-900);
    color: var(--white);
}

.cases-list {
    padding: 1rem;
    overflow-y: auto;
    flex: 1;
    min-height: 0; /* Enable proper scrolling */
    padding-bottom: 2rem; /* Extra padding to ensure last item is visible */
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--gray-900);
    background: var(--gray-950);
    flex-shrink: 0;
}

.shred-all-btn {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--radius);
    color: #D97706;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: var(--transition);
}

.shred-all-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.3);
    transform: translateY(-1px);
}

.case-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    background: var(--gray-900);
    border: 1px solid var(--gray-800);
    border-radius: var(--radius);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

/* New case animation */
.case-item-new {
    animation: slideInFromTop 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes slideInFromTop {
    0% {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    50% {
        transform: translateY(0) scale(1.02);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Highlight animation for new cases */
.case-item.highlight {
    animation: highlightPulse 2s ease-in-out;
}

@keyframes highlightPulse {
    0%, 100% {
        border-color: var(--gray-800);
        box-shadow: none;
    }
    25%, 75% {
        border-color: var(--primary);
        box-shadow: 
            0 0 0 2px rgba(99, 102, 241, 0.2),
            0 0 20px rgba(99, 102, 241, 0.2),
            inset 0 0 20px rgba(99, 102, 241, 0.05);
    }
    50% {
        border-color: var(--primary);
        box-shadow: 
            0 0 0 4px rgba(99, 102, 241, 0.3),
            0 0 30px rgba(99, 102, 241, 0.3),
            inset 0 0 30px rgba(99, 102, 241, 0.1);
    }
}

/* Shimmer effect on hover */
.case-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.03),
        transparent
    );
    transition: left 0.5s;
}

.case-item:hover::before {
    left: 100%;
}

.case-item-content {
    flex: 1;
    padding: 1rem;
    cursor: pointer;
}

.case-item:hover {
    border-color: var(--gray-700);
    transform: translateX(-2px);
}

.case-item-title {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.case-item-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    color: var(--gray-500);
}

.case-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding-right: 0.5rem;
}

.case-edit-btn,
.case-share-btn,
.case-delete-btn {
    padding: 0.5rem;
    background: transparent;
    border: none;
    color: var(--gray-600);
    cursor: pointer;
    border-radius: var(--radius);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.case-edit-btn:hover {
    background: var(--gray-800);
    color: var(--primary);
}

.case-share-btn:hover {
    background: var(--gray-800);
    color: var(--primary);
}

.case-delete-btn:hover {
    background: var(--gray-800);
    color: #D97706;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(8px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--gray-950);
    border: 1px solid var(--gray-800);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
}

/* Modal scrollbars now use global dark theme */

/* Firefox scrollbar */
.modal-content,
.modal-body,
.privacy-content,
.linked-devices-list,
.premium-modal {
    scrollbar-width: thin;
    scrollbar-color: var(--gray-700) var(--gray-900);
}

/* Global scrollbar styles for all elements */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--gray-700) var(--gray-900);
}

*::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

*::-webkit-scrollbar-track {
    background: var(--gray-950);
    border-radius: 6px;
}

*::-webkit-scrollbar-thumb {
    background: var(--gray-700);
    border-radius: 6px;
    border: 3px solid var(--gray-950);
    background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
    border: 3px solid var(--gray-950);
    background-clip: padding-box;
}

*::-webkit-scrollbar-corner {
    background: var(--gray-950);
}

/* Specific overrides for certain elements */
.messages::-webkit-scrollbar {
    width: 8px;
}

.messages::-webkit-scrollbar-track {
    background: transparent;
}

.messages::-webkit-scrollbar-thumb {
    background: var(--gray-800);
    border-radius: 4px;
    border: 2px solid transparent;
}

.messages::-webkit-scrollbar-thumb:hover {
    background: var(--gray-600);
}

/* Cases sidebar scrollbar */
.cases-list::-webkit-scrollbar {
    width: 8px;
}

.cases-list::-webkit-scrollbar-track {
    background: var(--gray-950);
}

.cases-list::-webkit-scrollbar-thumb {
    background: var(--gray-800);
    border-radius: 4px;
}

.cases-list::-webkit-scrollbar-thumb:hover {
    background: var(--gray-600);
}

/* Textarea scrollbar */
textarea::-webkit-scrollbar {
    width: 8px;
}

textarea::-webkit-scrollbar-track {
    background: var(--gray-900);
    border-radius: 4px;
}

textarea::-webkit-scrollbar-thumb {
    background: var(--gray-700);
    border-radius: 4px;
}

textarea::-webkit-scrollbar-thumb:hover {
    background: var(--gray-600);
}

/* Ensure scrollbar styles work on all divs with overflow */
div[style*="overflow"]::-webkit-scrollbar,
div[style*="overflow-y"]::-webkit-scrollbar,
div[style*="overflow-x"]::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

div[style*="overflow"]::-webkit-scrollbar-track,
div[style*="overflow-y"]::-webkit-scrollbar-track,
div[style*="overflow-x"]::-webkit-scrollbar-track {
    background: var(--gray-900);
}

div[style*="overflow"]::-webkit-scrollbar-thumb,
div[style*="overflow-y"]::-webkit-scrollbar-thumb,
div[style*="overflow-x"]::-webkit-scrollbar-thumb {
    background: var(--gray-700);
    border-radius: 5px;
}

div[style*="overflow"]::-webkit-scrollbar-thumb:hover,
div[style*="overflow-y"]::-webkit-scrollbar-thumb:hover,
div[style*="overflow-x"]::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* Voice Modal */
.voice-modal {
    min-width: 300px;
}

.voice-animation {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.voice-circle {
    width: 12px;
    height: 12px;
    background: var(--primary);
    border-radius: 50%;
    animation: voicePulse 1.4s ease-in-out infinite;
}

.voice-circle:nth-child(2) {
    animation-delay: 0.2s;
}

.voice-circle:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes voicePulse {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1.2);
        opacity: 1;
    }
}

.voice-modal p {
    color: var(--gray-400);
    margin-bottom: 1.5rem;
}

.stop-btn {
    padding: 0.625rem 2rem;
    background: var(--gray-900);
    border: 1px solid var(--gray-800);
    border-radius: var(--radius);
    color: var(--white);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.stop-btn:hover {
    background: var(--gray-800);
    border-color: var(--gray-700);
}

/* Premium Modal */
.premium-modal {
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 0;
}

.premium-header {
    background: linear-gradient(135deg, var(--gray-950) 0%, var(--gray-900) 100%);
    padding: 2rem;
    text-align: center;
    position: relative;
    border-bottom: 1px solid var(--gray-800);
}

.premium-icon {
    margin-bottom: 1rem;
}

.premium-header h2 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--white);
}

.premium-header p {
    color: var(--gray-400);
    font-size: 1rem;
    margin: 0;
}

.premium-modal .modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 36px;
    height: 36px;
    background: var(--gray-900);
    border: 1px solid var(--gray-800);
    color: var(--gray-400);
    font-size: 1.125rem;
    cursor: pointer;
    border-radius: 50%;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 300;
}

.modal-close:hover {
    background: var(--gray-800);
    border-color: var(--gray-700);
    color: var(--white);
    transform: rotate(90deg) scale(1.1);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.2);
}

.modal-close:active {
    transform: rotate(90deg) scale(0.95);
}

.premium-features {
    padding: 2rem;
    display: grid;
    gap: 1.5rem;
}

.feature-card {
    padding: 1.5rem;
    background: var(--gray-900);
    border: 1px solid var(--gray-800);
    border-radius: var(--radius);
    transition: var(--transition);
    text-align: center;
}

.feature-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.feature-icon {
    width: 40px;
    height: 40px;
    margin: 0 auto 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-800);
    border-radius: 10px;
    color: var(--primary);
}

.feature-card h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--white);
}

.feature-card p {
    color: var(--gray-400);
    font-size: 0.9375rem;
    line-height: 1.6;
    margin: 0;
}

.premium-pricing {
    padding: 2rem;
    background: var(--gray-950);
    border-top: 1px solid var(--gray-800);
    text-align: center;
}

.pricing-toggle {
    display: flex;
    background: var(--gray-900);
    border-radius: var(--radius);
    padding: 0.25rem;
    margin-bottom: 2rem;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
}

.pricing-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    color: var(--gray-400);
    font-weight: 500;
    font-size: 0.875rem;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.pricing-btn.active {
    background: var(--primary);
    color: var(--white);
}

.save-badge {
    background: var(--primary);
    color: var(--white);
    padding: 0.125rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    margin-left: 0.5rem;
    white-space: nowrap;
    display: inline-block;
}

.currency-selector {
    display: flex;
    background: var(--gray-900);
    border-radius: var(--radius);
    padding: 0.25rem;
    margin-bottom: 1.5rem;
    max-width: 200px;
    margin-left: auto;
    margin-right: auto;
}

.currency-btn {
    flex: 1;
    padding: 0.5rem 1rem;
    background: transparent;
    border: none;
    color: var(--gray-400);
    font-weight: 500;
    font-size: 0.875rem;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.currency-btn.active {
    background: var(--gray-800);
    color: var(--white);
}

.pricing-card {
    margin-bottom: 2rem;
}

.price-amount {
    font-size: 3rem;
    font-weight: 700;
    color: var(--white);
    margin-bottom: 0.25rem;
}

.price-period {
    color: var(--gray-400);
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
}

.price-note {
    color: var(--gray-500);
    font-size: 0.875rem;
}

.gst-info {
    margin-top: 0.5rem;
}

.gst-text {
    color: var(--gray-600);
    font-size: 0.75rem;
    font-style: italic;
}

.pricing-toggle {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.pricing-option {
    flex: 1;
    padding: 1rem;
    border: 2px solid var(--gray-700);
    border-radius: 0.75rem;
    background: var(--gray-800);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.pricing-option:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.pricing-option.active {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.pricing-option .price {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--white);
    margin-bottom: 0.25rem;
}

.pricing-option .period {
    font-size: 0.875rem;
    color: var(--gray-400);
}

.save-badge {
    position: absolute;
    top: -0.5rem;
    right: 0.5rem;
    background: var(--primary);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.subscribe-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 1rem 2rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
    border-radius: var(--radius);
    color: var(--white);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 1rem;
    position: relative;
    overflow: hidden;
    animation: pulseGlow 3s ease-in-out infinite;
}

.subscribe-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.subscribe-btn:active:not(:disabled) {
    transform: translateY(0);
}

.subscribe-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.payment-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    margin-top: 2rem;
}

.subscribe-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 1rem 2rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
    border-radius: var(--radius);
    color: var(--white);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.subscribe-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
    background: linear-gradient(135deg, var(--primary-dark) 0%, #3730A3 100%);
}

.subscribe-btn:active:not(:disabled) {
    transform: translateY(0);
}

.subscribe-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--gray-700);
}


.coming-soon-text {
    text-align: center;
    color: var(--primary);
    font-size: 0.875rem;
    font-weight: 600;
    margin-top: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.privacy-policy-link {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.75rem;
}

.privacy-policy-link a {
    color: var(--primary);
    text-decoration: none;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.privacy-policy-link a:hover {
    opacity: 1;
    text-decoration: underline;
}

.privacy-notice {
    text-align: center;
    color: var(--gray-500);
    font-size: 0.875rem;
    margin-top: 1rem;
}

.privacy-link {
    color: var(--primary);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: var(--transition);
}

.privacy-link:hover {
    border-bottom-color: var(--primary);
}

.privacy-content {
    padding: 1.5rem;
    border-top: 1px solid var(--gray-800);
    max-height: 300px;
    overflow-y: auto;
}

.privacy-content h3 {
    font-size: 1.125rem;
    margin-bottom: 1rem;
    color: var(--white);
}

.privacy-text {
    color: var(--gray-400);
    font-size: 0.875rem;
    line-height: 1.6;
}

.premium-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--gray-900);
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    color: var(--primary);
    font-size: 0.875rem;
    font-weight: 500;
}

.passkey-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: 1rem;
}

/* Animation enhancements */
.icon-btn,
.new-case-btn,
.premium-btn,
.send-btn {
    position: relative;
    overflow: hidden;
}

.icon-btn::after,
.new-case-btn::after,
.premium-btn::after,
.send-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.icon-btn:active::after,
.new-case-btn:active::after,
.premium-btn:active::after,
.send-btn:active::after {
    width: 300px;
    height: 300px;
}

/* Loading Animation */
.typing-dots {
    display: flex;
    gap: 4px;
    padding: 1rem;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--gray-600);
    border-radius: 50%;
    animation: typing 1.4s ease-in-out infinite;
}

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

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

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Comprehensive Analysis Animation */
.comprehensive-analysis-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem;
    animation: fadeIn 0.5s ease-in-out;
}

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

.analysis-text {
    text-align: center;
    margin-bottom: 1.5rem;
}

.analysis-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-100);
    margin-bottom: 0.25rem;
}

.analysis-subtitle {
    font-size: 0.875rem;
    color: var(--gray-500);
}

.analysis-progress {
    width: 200px;
    height: 4px;
    background: var(--gray-800);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.progress-bar {
    position: absolute;
    height: 100%;
    width: 40%;
    background: linear-gradient(90deg, var(--primary), var(--primary-dark));
    border-radius: 2px;
    animation: oscillate 2s ease-in-out infinite;
}

@keyframes oscillate {
    0% {
        left: 0;
    }
    50% {
        left: 60%;
    }
    100% {
        left: 0;
    }
}

/* Footer */
.footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--black);
    border-top: 1px solid var(--gray-900);
    padding: 1rem 2rem;
    z-index: 100; /* Base level for footer */
    display: flex;
    align-items: center;
    height: 60px;
}

.footer-content {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}

.footer-center {
    text-align: center;
}

.footer-tagline {
    color: var(--gray-600);
    font-size: 0.65rem;
    font-weight: 300;
    margin: 0;
    letter-spacing: 0.5px;
    opacity: 0.8;
}

/* Test Mode Toggle */
.test-mode-toggle {
    margin-top: 0.5rem;
    font-size: 0.75rem;
}

.test-mode-toggle label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
    color: var(--gray-500);
}

.test-mode-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.test-mode-toggle span {
    user-select: none;
}

/* Test mode indicator */
.test-mode-indicator {
    position: fixed;
    top: 10px;
    right: 10px;
    background: #FFB800;
    color: var(--black);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.75rem;
    font-weight: 600;
    z-index: 1000;
    display: none;
}

body.test-mode-active .test-mode-indicator {
    display: block;
}

/* Responsive Premium Modal */
@media (max-width: 768px) {
    .premium-modal {
        max-width: 95vw;
        margin: 1rem;
    }
    
    .premium-header {
        padding: 1.5rem;
    }
    
    .premium-header h2 {
        font-size: 1.5rem;
    }
    
    .premium-features {
        padding: 1.5rem;
        gap: 1rem;
    }
    
    .feature-card {
        padding: 1rem;
    }
    
    .premium-pricing {
        padding: 1.5rem;
    }
    
    .price-amount {
        font-size: 2.5rem;
    }
    
    .pricing-toggle {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .pricing-btn {
        text-align: center;
    }
}

/* Adjust main content to account for footer - see main class definition above */

/* Mobile footer */
@media (max-width: 768px) {
    .footer {
        padding: 1rem;
    }
    
    .footer-tagline {
        font-size: 0.875rem;
    }
    
    .footer-copyright {
        font-size: 0.6875rem;
    }
}
/* Advanced Mobile Optimizations */
@media (max-width: 768px) {
    /* Fix mobile layout - use height instead of position fixed */
    html {
        height: 100%;
    }
    
    body {
        height: 100%;
        margin: 0;
        overflow: hidden;
    }
    
    .app {
        display: flex;
        flex-direction: column;
        height: 100%;
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
        position: relative;
    }
    
    /* Header Mobile Layout */
    .header {
        padding: 0.75rem;
        display: grid;
        grid-template-columns: auto 1fr auto;
        gap: 0.5rem;
        min-height: auto;
        position: relative;
        background: var(--gray-950);
        z-index: 1000;
        flex-shrink: 0;
    }
    
    .main {
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        min-height: 0;
        position: relative;
    }
    
    .messages {
        flex: 1;
        overflow-y: scroll; /* Use scroll instead of auto */
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        /* Add top padding to ensure first message isn't hidden */
        padding-top: 1rem;
        /* Adjust padding bottom for fixed input area and footer */
        padding-bottom: 180px; /* 60px footer + 120px input area approx */
        /* Ensure scrolling works */
        min-height: 0;
        position: relative;
    }
    
    .header-left {
        display: flex;
        justify-content: flex-start;
        padding-left: 0.75rem;
        padding-top: 0.25rem;
    }
    
    .header-center {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.25rem;
    }
    
    .header-right {
        display: flex;
        justify-content: flex-end;
        gap: 0.5rem;
        padding-right: 0.75rem;
        padding-top: 0.25rem;
    }
    
    .logo {
        justify-content: center;
    }
    
    .logo-text {
        font-size: 1.25rem;
    }
    
    .header-title h1 {
        font-size: 0.75rem;
        color: var(--gray-500);
    }
    
    .header-actions {
        gap: 0.375rem;
        align-items: center;
    }
    
    /* Compact buttons on mobile */
    .icon-btn {
        width: 36px;
        height: 36px;
    }
    
    /* Keep premium button same size as icon buttons when icon-only */
    .premium-btn.icon-only {
        width: 36px;
        height: 36px;
        padding: 0;
    }
    
    .premium-btn svg {
        width: 16px;
        height: 16px;
    }
    
    /* Main content adjustments */
    .main {
        padding: 0 1rem;
        padding-bottom: 200px; /* More space for input area + footer */
    }
    
    /* Case header mobile */
    .case-header {
        padding: 1rem 0 0.75rem;
    }
    
    .case-info-wrapper {
        gap: 0.375rem;
    }
    
    .case-title-container {
        flex-direction: row; /* Keep inline */
        flex-wrap: nowrap;
        align-items: center;
        width: 100%;
        max-width: 100%;
    }
    
    .case-title-display {
        font-size: 1.125rem;
        padding: 0.375rem 0.5rem;
        flex: 1;
        min-width: 0; /* Allow text truncation */
        text-overflow: ellipsis;
        overflow: hidden;
        white-space: nowrap;
    }
    
    .case-title-input {
        font-size: 1.125rem;
        padding: 0.375rem 0.5rem;
        width: 100%;
        max-width: 100%;
    }
    
    
    .case-header #case-id {
        font-size: 0.7rem;
    }
    
    .case-title-actions {
        flex-shrink: 0;
        margin-left: 0.5rem;
    }
    
    /* Messages area */
    .messages {
        padding: 0.75rem 0 1rem;
    }
    
    .message {
        margin-bottom: 1rem;
    }
    
    .message-user .bubble,
    .message-assistant .bubble {
        max-width: 85%;
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }
    
    /* Legal analysis mobile adjustments */
    .message.legal-analysis .bubble {
        max-width: 95%;
        padding: 1rem;
    }
    
    .legal-analysis-header {
        padding: 1rem;
        gap: 0.5rem;
    }
    
    .legal-title {
        font-size: 1.125rem;
    }
    
    .legal-icon {
        font-size: 1.5rem;
    }
    
    /* Fixed input area for mobile */
    .input-area {
        position: fixed;
        bottom: 60px; /* Account for footer height */
        left: 0;
        right: 0;
        background: var(--black);
        border-top: 1px solid var(--gray-900);
        padding: 0.75rem 1rem 1rem;
        z-index: 101; /* Above footer */
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
        box-sizing: border-box;
        transition: bottom 0.3s ease-in-out;
    }
    
    .input-wrapper {
        padding: 0.625rem;
        gap: 0.375rem;
        width: 100%;
        max-width: calc(100% - 2px); /* Account for border */
        box-sizing: border-box;
        display: flex;
        align-items: center;
    }
    
    .input-form {
        width: 100%;
        max-width: 100%;
    }
    
    #message-input {
        font-size: 0.875rem;
        min-height: 20px;
        padding-top: 8px;
        padding-bottom: 8px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        word-wrap: break-word;
        overflow-wrap: break-word;
        flex: 1;
        min-width: 0; /* Important for flex items */
    }
    
    .attach-btn,
    .voice-btn,
    .send-btn {
        width: 32px;
        height: 32px;
    }
    
    /* Sidebar mobile */
    .sidebar {
        width: 100%;
        right: -100%;
    }
    
    .sidebar-header {
        padding: 1rem;
    }
    
    .sidebar-header h3 {
        font-size: 1rem;
    }
    
    .sidebar .new-case-btn {
        margin: 0.75rem;
        margin-bottom: 0;
        width: calc(100% - 1.5rem);
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }
    
    .cases-list {
        padding: 0.75rem;
        height: calc(100% - 180px);
    }
    
    .case-item {
        margin-bottom: 0.375rem;
    }
    
    .case-item-content {
        padding: 0.75rem;
    }
    
    .case-item-title {
        font-size: 0.875rem;
    }
    
    .case-item-meta {
        font-size: 0.75rem;
    }
    
    /* Sidebar footer mobile */
    .sidebar-footer {
        padding: 0.75rem;
    }
    
    .shred-all-btn {
        font-size: 0.8125rem;
        padding: 0.625rem 0.875rem;
    }
    
    
    /* Footer - Always visible on mobile */
    .footer {
        display: block;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 100;
        background: var(--black);
        border-top: 1px solid var(--gray-900);
        padding: 0.75rem 1rem;
        height: 60px; /* Fixed height */
        transition: transform 0.3s ease-in-out;
    }
    
    .footer-content {
        max-width: 100%;
    }
    
    .footer-tagline {
        font-size: 0.875rem;
        margin: 0;
    }
}

/* Keyboard open state - Robust */
body.keyboard-open {
    /* Prevent body scrolling when keyboard is open */
    position: fixed;
    width: 100%;
    overflow: hidden;
}

body.keyboard-open .footer {
    /* Hide footer when keyboard is open to maximize space */
    display: none;
}

body.keyboard-open .input-area {
    /* Smooth transition and ensure it stays above keyboard */
    transition: bottom 0.2s ease-out;
    z-index: 9999; /* Ensure it's always on top */
}

body.keyboard-open .messages {
    /* Smooth scrolling with proper containment */
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    overflow-y: auto;
    overflow-x: hidden;
    /* Don't set fixed height - allow full scroll range */
}

body.keyboard-open .main {
    /* Prevent padding issues */
    padding-bottom: 0;
    overflow: hidden;
}

body.keyboard-open .app {
    /* Fixed positioning to prevent scrolling issues */
    overflow: hidden;
}

/* Extra padding for mobile Safari when uploading documents */
@media (max-width: 768px) {
    .messages {
        padding-bottom: 160px; /* More space on mobile */
    }
    
    /* When keyboard is open on mobile Safari, ensure messages are visible */
    body.keyboard-open .messages {
        /* Minimal padding when keyboard is open */
        padding-bottom: 10px;
        /* Allow free scrolling without height constraints */
        height: auto;
        /* Maintain top padding even when keyboard is open */
        padding-top: 1.5rem;
    }
    
    /* Ensure header stays in place when keyboard is open */
    body.keyboard-open .header {
        position: sticky;
        position: -webkit-sticky;
        top: 0;
        z-index: 1000;
    }
}

/* Ensure input area is always interactive on mobile */
@media (max-width: 768px) {
    .input-area {
        -webkit-transform: translate3d(0, 0, 0); /* Hardware acceleration */
        transform: translate3d(0, 0, 0);
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
        will-change: bottom;
    }
    
    .input-wrapper {
        -webkit-transform: translate3d(0, 0, 0);
        transform: translate3d(0, 0, 0);
    }
    
    #message-input {
        font-size: 16px !important; /* Prevent zoom on iOS */
        -webkit-text-size-adjust: 100%;
        -webkit-appearance: none;
        border-radius: 0;
    }
    
    /* Ensure smooth scrolling on mobile */
    .messages {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }
    
    /* Better touch targets on mobile */
    .send-btn,
    .attach-btn {
        min-width: 44px;
        min-height: 44px;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    .header {
        padding: 0.75rem;
        gap: 0.375rem;
    }
    
    /* Ensure input area doesn't overflow */
    .input-area {
        padding: 0.5rem;
        padding-bottom: 0.75rem;
    }
    
    .model-selector-container {
        padding: 0 0.5rem;
        margin-bottom: 0.5rem;
    }
    
    .model-option {
        padding: 0.4rem 0.75rem;
    }
    
    .model-option .model-name {
        font-size: 0.75rem;
    }
    
    .input-wrapper {
        padding: 0.5rem;
        gap: 0.25rem;
    }
    
    #message-input {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 8px;
        min-height: 36px;
        display: flex;
        align-items: center;
    }
    
    .attach-btn,
    .voice-btn,
    .send-btn {
        width: 30px;
        height: 30px;
        flex-shrink: 0;
    }
    
    .input-actions {
        gap: 0.25rem;
    }
    
    /* Keep tagline visible but smaller on mobile */
    .header-title h1 {
        font-size: 0.625rem;
        font-weight: 700;
        line-height: 1.1;
    }
    
    .logo {
        font-size: 1.25rem;
    }
    
    .logo svg {
        width: 28px;
        height: 28px;
    }
    
    .logo-text {
        font-size: 1.125rem;
    }
    
    .header-actions {
        gap: 0.25rem;
    }
    
    .icon-btn {
        width: 32px;
        height: 32px;
        flex-shrink: 0;
    }
    
    /* Keep premium button same size as icon buttons when icon-only */
    .premium-btn.icon-only {
        width: 32px;
        height: 32px;
        padding: 0;
        min-height: auto;
    }
    
    /* Compact buttons with better touch targets */
    .new-case-btn {
        padding: 0.375rem 0.5rem;
        font-size: 0.75rem;
        min-height: 36px;
    }
    
    .main {
        padding: 0 0.5rem;
        max-width: 100vw;
        overflow-x: hidden;
    }
    
    .input-area {
        padding: 0.625rem 0.5rem;
    }
    
    /* Ensure nothing overflows */
    .app, .header, .main, .messages, .input-area {
        max-width: 100vw;
        overflow-x: hidden;
    }
}

/* Landscape mobile adjustments */
@media (max-height: 600px) and (orientation: landscape) {
    .header {
        padding: 0.75rem;
        min-height: 50px;
    }
    
    .header-title {
        display: none; /* Hide tagline in landscape */
    }
    
    .case-header {
        padding: 0.5rem 0;
    }
    
    .main {
        padding-bottom: 100px;
    }
    
    .input-area {
        padding: 0.5rem 1rem 0.75rem;
    }
    
    .messages {
        padding: 0.5rem 0;
    }
}

/* Safe area insets for modern phones */
@supports (padding: env(safe-area-inset-left)) {
    .app {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
    
    .header {
        padding: 0.75rem;
        padding-left: max(0.75rem, env(safe-area-inset-left));
        padding-right: max(0.75rem, env(safe-area-inset-right));
    }
    
    .input-area {
        padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
        padding-left: max(0.5rem, env(safe-area-inset-left));
        padding-right: max(0.5rem, env(safe-area-inset-right));
        width: 100%;
        box-sizing: border-box;
    }
    
    .main {
        padding-bottom: calc(120px + env(safe-area-inset-bottom));
        padding-left: max(0.5rem, env(safe-area-inset-left));
        padding-right: max(0.5rem, env(safe-area-inset-right));
    }
}

/* High-res displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .header,
    .input-wrapper,
    .sidebar {
        border-width: 0.5px;
    }
}

/* Very small screens (iPhone SE, etc.) */
@media (max-width: 375px) {
    .header {
        padding: 0.75rem;
    }
    
    .logo-text {
        display: none;
    }
    
    .header-title h1 {
        font-size: 0.5625rem;
    }
}

/* Touch-friendly interactions */
@media (hover: none) and (pointer: coarse) {
    .icon-btn,
    .new-case-btn,
    .premium-btn,
    .send-btn,
    .attach-btn,
    .voice-btn {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
    
    .case-title-display:hover {
        background: transparent; /* Disable hover on touch */
    }
    
}

/* PWA Update Banner */
.update-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--primary);
    color: var(--white);
    padding: 0.75rem 1rem;
    z-index: 10000;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
    }
    to {
        transform: translateY(0);
    }
}

.update-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.update-content span {
    font-size: 0.875rem;
    font-weight: 500;
}

.update-btn {
    padding: 0.375rem 1rem;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    color: var(--white);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.update-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.4);
}

/* PWA Install prompt */
.install-prompt {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--gray-900);
    border: 1px solid var(--gray-800);
    border-radius: var(--radius);
    padding: 1rem 1.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    max-width: 90vw;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateX(-50%) translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

.install-prompt-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.install-prompt-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.install-prompt-text h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.install-prompt-text p {
    font-size: 0.875rem;
    color: var(--gray-400);
    margin: 0;
}

.install-prompt-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.install-btn,
.dismiss-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

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

.install-btn:hover {
    background: var(--primary-dark);
}

.dismiss-btn {
    background: transparent;
    color: var(--gray-400);
    border: 1px solid var(--gray-800);
}

.dismiss-btn:hover {
    background: var(--gray-900);
    border-color: var(--gray-700);
}

/* Offline indicator */
.offline-indicator {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--gray-900);
    border: 1px solid var(--gray-800);
    border-radius: 20px;
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--gray-400);
    z-index: 100;
    opacity: 0;
    transition: opacity 0.3s;
}

.offline-indicator.show {
    opacity: 1;
}

.offline-indicator svg {
    width: 16px;
    height: 16px;
}

/* iOS PWA styles */
@supports (-webkit-touch-callout: none) {
    /* iOS specific styles */
    .app {
        padding-top: env(safe-area-inset-top);
    }
    
    .header {
        padding-top: calc(1.5rem + env(safe-area-inset-top));
    }
    
    /* Standalone mode (when installed as PWA) */
    @media (display-mode: standalone) {
        .header {
            background: var(--black);
            position: sticky;
            top: 0;
            z-index: 100;
        }
    }
}

/* Android PWA enhancements */

/* Retry button in messages */
.retry-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: var(--radius);
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.retry-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

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

/* Document generation button loading state */
.doc-gen-btn.loading {
    background: var(--gray-800);
    cursor: wait;
    position: relative;
}

.doc-gen-btn.loading .spinner {
    display: inline-block;
}

/* Subscription Modal Styles */
.subscription-modal {
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 0; /* Remove default modal padding */
    position: relative;
}

.subscription-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--gray-800);
    flex-shrink: 0;
    position: relative;
}

.subscription-modal .modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

.subscription-modal .modal-close,
.modal-close,
.close-btn {
    width: 36px;
    height: 36px;
    background: var(--gray-900);
    border: 1px solid var(--gray-800);
    color: var(--gray-400);
    font-size: 1.125rem;
    cursor: pointer;
    border-radius: 50%;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 300;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

.subscription-modal .close-btn:hover,
.modal-close:hover,
.close-btn:hover {
    background: var(--gray-800);
    border-color: var(--gray-700);
    color: var(--white);
    transform: rotate(90deg) scale(1.1);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.2);
}

.subscription-modal .close-btn:active,
.modal-close:active,
.close-btn:active {
    transform: rotate(90deg) scale(0.95);
}

.subscription-modal .modal-body {
    padding: 2rem;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    /* Custom scrollbar for modal body */
    scrollbar-width: thin;
    scrollbar-color: var(--gray-700) var(--gray-900);
}

.subscription-modal .modal-body::-webkit-scrollbar {
    width: 10px;
}

.subscription-modal .modal-body::-webkit-scrollbar-track {
    background: var(--gray-900);
    border-radius: 5px;
}

.subscription-modal .modal-body::-webkit-scrollbar-thumb {
    background: var(--gray-700);
    border-radius: 5px;
    border: 2px solid var(--gray-900);
}

.subscription-modal .modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

.subscription-status {
    text-align: center;
    margin-bottom: 2rem;
}

.subscription-icon {
    margin-bottom: 1rem;
}

.subscription-active h3,
.subscription-inactive h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0.5rem 0;
}

.subscription-info {
    color: var(--gray-400);
    margin: 0.5rem 0;
}

.subscription-expiry {
    color: var(--primary);
    font-size: 0.9rem;
    margin-top: 1rem;
}

.passkey-section {
    background: var(--gray-900);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.passkey-section h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0 0 0.5rem;
}

.passkey-section p {
    color: var(--gray-400);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.passkey-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.passkey-btn {
    flex: 1;
    min-width: 140px;
    padding: 0.75rem 1rem;
    background: var(--gray-800);
    border: 1px solid var(--gray-700);
    border-radius: var(--radius);
    color: var(--white);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.passkey-btn:hover {
    background: var(--gray-700);
    border-color: var(--gray-600);
    transform: translateY(-1px);
}

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

/* Compatibility notice styling */
.compatibility-notice {
    padding: 1rem;
    margin: 1rem 0;
    background: var(--gray-800);
    border: 1px solid var(--gray-700);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    color: var(--gray-400);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.compatibility-notice::before {
    content: "ⓘ";
    font-size: 1.2rem;
    color: var(--primary);
}

.subscription-footer {
    text-align: center;
    padding-top: 1rem;
    border-top: 1px solid var(--gray-800);
}

/* Premium Modal Passkey Section */
.premium-passkey-section {
    padding: 1.5rem 2rem 1rem;
    background: var(--gray-950);
    border-top: 1px solid var(--gray-800);
    text-align: center;
}

.passkey-sync-info {
    margin-bottom: 1rem;
}

.passkey-sync-info p {
    color: var(--gray-400);
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
}

.passkey-sync-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--gray-900);
    border: 1px solid var(--gray-700);
    border-radius: var(--radius);
    color: var(--primary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.passkey-sync-btn:hover {
    background: var(--gray-800);
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

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

.passkey-sync-btn svg {
    width: 18px;
    height: 18px;
}

/* Device ID Display */
.device-id-display {
    margin-top: 1rem;
    padding-top: 0.5rem;
    color: var(--gray-600);
    font-size: 0.625rem; /* Tiny font size */
    font-family: monospace;
    opacity: 0.7;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .premium-passkey-section {
        padding: 1rem;
    }
    
    .passkey-sync-info p {
        font-size: 0.8125rem;
    }
    
    .passkey-sync-btn {
        padding: 0.625rem 1.25rem;
        font-size: 0.8125rem;
    }
    
    .device-id-display {
        font-size: 0.5625rem;
    }
}

/* Support Section */
.support-section {
    background: var(--gray-900);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-top: 1.5rem;
}

.support-section h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0 0 0.5rem;
    color: var(--white);
}

.support-section p {
    color: var(--gray-400);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.support-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-300);
}

.form-group input,
.form-group textarea {
    background: var(--gray-800);
    border: 1px solid var(--gray-700);
    border-radius: var(--radius);
    padding: 0.75rem;
    color: var(--white);
    font-size: 0.9375rem;
    font-family: inherit;
    transition: var(--transition);
    outline: none;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--gray-750);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--gray-500);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.submit-support-btn {
    padding: 0.75rem 1.5rem;
    background: var(--primary);
    border: none;
    border-radius: var(--radius);
    color: var(--white);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.submit-support-btn:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.submit-support-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.submit-support-btn .btn-loading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.support-status {
    margin-top: 1rem;
    padding: 0.75rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    display: none;
}

.support-status.success {
    display: block;
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: #22c55e;
}

.support-status.error {
    display: block;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #D97706;
}

.manage-subscription-btn,
.upgrade-btn {
    padding: 0.75rem 2rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
    border-radius: var(--radius);
    color: var(--white);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    animation: pulseGlow 3s ease-in-out infinite;
}

.manage-subscription-btn:hover,
.upgrade-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.manage-subscription-btn:active,
.upgrade-btn:active {
    transform: translateY(0);
}

.upgrade-btn {
    margin-top: 1rem;
}

/* Document Generation Buttons */
.document-generation-buttons {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--gray-900);
    border-radius: var(--radius);
    border: 1px solid var(--gray-800);
}

.doc-gen-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    color: var(--primary);
    font-weight: 600;
}

.doc-gen-header svg {
    width: 20px;
    height: 20px;
}

.doc-gen-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
}

.doc-gen-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 0.75rem;
    background: var(--gray-800);
    border: 1px solid var(--gray-700);
    border-radius: var(--radius);
    color: var(--white);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 80px;
    text-align: center;
}

.doc-gen-btn:hover {
    background: var(--gray-700);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.doc-gen-btn .doc-icon {
    font-size: 1.5rem;
}

/* Document Download Section */
.document-download-section {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: var(--radius);
    text-align: center;
}

.document-download-section h3 {
    color: var(--white);
    margin: 0 0 0.5rem;
    font-size: 1.25rem;
}

.document-download-section p {
    color: rgba(255, 255, 255, 0.9);
    margin: 0 0 1rem;
}

.download-doc-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--white);
    color: var(--primary);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.download-doc-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

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

/* Cancel subscription button */
.cancel-subscription-btn {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: 1px solid var(--gray-600);
    border-radius: var(--radius);
    color: var(--gray-300);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.cancel-subscription-btn:hover {
    border-color: #FCD34D;
    color: #D97706;
}

/* Subscription Management Modal */
.subscription-management-modal {
    max-width: 600px;
    width: 90%;
    padding: 0;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    overflow: hidden;
}

.subscription-management-modal .modal-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--gray-800);
    flex-shrink: 0;
}

.subscription-management-modal .modal-body {
    padding: 2rem;
    overflow-y: auto;
    flex: 1;
}

.back-btn {
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.back-btn:hover {
    color: var(--white);
}

.current-plan-section {
    margin-bottom: 2rem;
}

.current-plan-card {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 1.5rem;
    background: var(--gray-900);
    border-radius: var(--radius);
    border: 1px solid var(--gray-800);
}

.plan-icon {
    flex-shrink: 0;
}

.plan-details h4 {
    margin: 0 0 0.5rem;
    font-size: 1.125rem;
    font-weight: 600;
}

.plan-price {
    color: var(--primary);
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 0.25rem;
}

.plan-expiry {
    color: var(--gray-400);
    font-size: 0.875rem;
    margin: 0;
}


/* Linked Devices Section */
.linked-devices-section {
    margin-bottom: 2rem;
}

.linked-devices-section h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0 0 0.5rem;
}

.devices-info {
    color: var(--gray-400);
    font-size: 0.875rem;
    margin: 0 0 1rem;
}

.devices-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.device-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--gray-900);
    border: 1px solid var(--gray-800);
    border-radius: var(--radius-sm);
}

.device-item.current {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.device-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.device-icon {
    color: var(--gray-400);
}

.device-details h5 {
    margin: 0 0 0.25rem;
    font-size: 0.9375rem;
    font-weight: 500;
}

.device-details p {
    margin: 0;
    font-size: 0.75rem;
    color: var(--gray-400);
}

.current-badge {
    display: inline-block;
    margin-top: 0.25rem;
    padding: 0.125rem 0.5rem;
    background: var(--primary);
    color: white;
    font-size: 0.625rem;
    font-weight: 600;
    border-radius: 9999px;
}

.remove-device-btn {
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    padding: 0.5rem;
    transition: color 0.2s ease;
}

.remove-device-btn:hover {
    color: #D97706;
}

.device-limit-warning {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-sm);
    color: #FCA5A5;
    font-size: 0.875rem;
}

/* Danger Zone */
.danger-zone {
    padding: 1.5rem;
    background: rgba(239, 68, 68, 0.05);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--radius);
}

.danger-zone h3 {
    color: #D97706;
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0 0 0.5rem;
}

.danger-zone p {
    color: var(--gray-400);
    font-size: 0.875rem;
    margin: 0 0 1rem;
}

.cancel-subscription-btn {
    padding: 0.75rem 1.5rem;
    background: none;
    border: 1px solid #FCD34D;
    color: #D97706;
    border-radius: var(--radius-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cancel-subscription-btn:hover {
    background: #FEF3C7;
    color: white;
}

/* Cancel Confirmation Modal */
.cancel-confirmation-modal {
    max-width: 450px;
    width: 90%;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.cancel-confirmation-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--gray-800);
}

.cancel-confirmation-modal .modal-body {
    padding: 2rem;
}

.cancel-warning {
    text-align: center;
    padding: 2rem 0;
}

.cancel-warning svg {
    color: #D97706;
    margin-bottom: 1rem;
}

.cancel-warning h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 1rem;
}

.cancel-warning p {
    color: var(--gray-400);
    margin: 0 0 1rem;
}

.cancel-warning ul {
    list-style: none;
    padding: 0;
    margin: 0 0 2rem;
    text-align: left;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
}

.cancel-warning li {
    padding: 0.5rem 0;
    color: var(--gray-300);
}

.cancel-options {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.btn-secondary {
    padding: 0.75rem 2rem;
    background: var(--gray-800);
    border: 1px solid var(--gray-700);
    color: white;
    border-radius: var(--radius-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: var(--gray-700);
}

.btn-danger {
    padding: 0.75rem 2rem;
    background: #FEF3C7;
    border: none;
    color: white;
    border-radius: var(--radius-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-danger:hover {
    background: #FDE68A;
}

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

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

/* Disabled button states */
.doc-gen-btn:disabled,
.download-doc-btn:disabled,
.change-plan-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Error states */
.error-message {
    color: #D97706;
    text-align: center;
    padding: 1rem;
}

/* Success animation */
@keyframes successPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.download-success {
    animation: successPulse 0.3s ease-out;
}

/* Loading states */
.loading-devices {
    text-align: center;
    padding: 2rem;
    color: var(--gray-400);
}

/* Device count */
.device-count {
    text-align: right;
    font-size: 0.875rem;
    color: var(--gray-400);
    margin-bottom: 0.5rem;
}

/* Retry button */
.retry-btn {
    margin-top: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--gray-800);
    border: 1px solid var(--gray-700);
    color: white;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.retry-btn:hover {
    background: var(--gray-700);
}

@media (display-mode: standalone) {
    /* Hide install prompts when already installed */
    .install-prompt {
        display: none;
    }
    
    /* Adjust header for standalone mode */
    .header {
        padding-top: 1.5rem;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Safari-specific fixes */
@supports (-webkit-appearance: none) {
    /* Ensure proper rendering in Safari */
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
    
    /* Fix for Safari button styling */
    button {
        -webkit-appearance: none;
        appearance: none;
    }
    
    /* Ensure HTML is properly rendered */
    html {
        -webkit-text-size-adjust: 100%;
    }
}


/* Subscription Management Styles */
.plan-option-price {
    color: var(--primary);
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0.5rem 0;
}

.plan-option-info {
    color: var(--gray-400);
    font-size: 0.875rem;
    margin: 0.5rem 0;
}

/* Linked Devices Section */
.linked-devices-section {
    margin-bottom: 2rem;
}

.linked-devices-section h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0 0 0.5rem;
}

.devices-info {
    color: var(--gray-400);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.devices-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.device-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--gray-900);
    border: 1px solid var(--gray-800);
    border-radius: var(--radius);
    transition: var(--transition);
}

.device-item:hover {
    border-color: var(--gray-700);
}

.device-item.current-device {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.device-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.device-name {
    font-weight: 500;
    color: var(--white);
}

.device-id {
    font-size: 0.75rem;
    color: var(--gray-500);
    font-family: monospace;
}

.current-badge {
    background: var(--primary);
    color: var(--white);
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.device-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.last-active {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.remove-device-btn {
    padding: 0.375rem 0.75rem;
    background: transparent;
    border: 1px solid var(--gray-600);
    border-radius: var(--radius-sm);
    color: var(--gray-300);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.remove-device-btn:hover {
    border-color: #FCD34D;
    color: #D97706;
    background: rgba(239, 68, 68, 0.1);
}

.no-devices {
    text-align: center;
    color: var(--gray-500);
    padding: 2rem;
}

/* Cancel Warning Modal */
.cancel-warning {
    text-align: center;
    padding: 2rem;
}

.cancel-warning svg {
    color: #D97706;
    margin-bottom: 1rem;
}

.cancel-warning h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 1rem;
}

.cancel-warning p {
    color: var(--gray-400);
    margin-bottom: 1rem;
}

.cancel-warning ul {
    list-style: none;
    padding: 0;
    margin: 0;
    text-align: left;
    display: inline-block;
}

.cancel-warning li {
    color: var(--gray-400);
    padding: 0.25rem 0;
}


.cancel-options {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
}


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

/* Upload Progress Modal */
.upload-progress-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

.upload-progress-modal.active {
    display: flex;
}

.upload-progress-content {
    background: var(--gray-900);
    border: 1px solid var(--gray-800);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    max-width: 400px;
    width: 90%;
    animation: modalIn 0.3s ease-out;
}

.upload-progress-icon {
    margin-bottom: 1rem;
    color: var(--primary);
}

.upload-spinner {
    animation: spin 2s linear infinite;
}

.spinner-track {
    animation: spin 1s linear infinite;
    transform-origin: center;
}

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

.upload-progress-title {
    color: var(--white);
    font-size: 1.25rem;
    margin: 0 0 0.5rem 0;
    font-weight: 600;
}

.upload-progress-message {
    color: var(--gray-400);
    font-size: 0.9rem;
    margin: 0 0 1rem 0;
}

.upload-progress-filename {
    color: var(--gray-500);
    font-size: 0.8rem;
    font-style: italic;
    word-break: break-all;
}

/* Legal Advice Generation Modal */
.legal-advice-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    padding: 20px;
}

.legal-advice-modal.active {
    display: flex;
    animation: modalIn 0.3s ease-out;
}

.legal-advice-content {
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 16px;
    padding: 32px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.legal-advice-icon {
    margin-bottom: 24px;
    color: #007bff;
}

.advice-spinner {
    animation: spin 1.5s linear infinite;
}

.legal-advice-title {
    color: #fff;
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 12px;
}

.legal-advice-message {
    color: #ccc;
    font-size: 16px;
    line-height: 1.6;
    margin-bottom: 20px;
}

.legal-advice-status {
    color: #007bff;
    font-size: 14px;
    font-style: italic;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}
/* Referral Section Styles */
.referral-section {
    margin-top: 2rem;
    padding: 1.5rem;
    background: rgba(99, 102, 241, 0.05);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 12px;
}

.referral-header {
    text-align: center;
    margin-bottom: 1rem;
}

.referral-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.referral-header p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.referral-link-container {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.referral-link-input {
    flex: 1;
    padding: 0.75rem 1rem;
    background: var(--gray-900);
    border: 1px solid var(--gray-700);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: monospace;
    cursor: text;
    user-select: all;
}

.referral-link-input:focus {
    outline: none;
    border-color: var(--purple);
}

.copy-referral-btn {
    padding: 0.75rem 1.25rem;
    background: var(--purple);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.copy-referral-btn:hover {
    background: #5b21b6;
    transform: translateY(-1px);
}

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

.copy-referral-btn.copied {
    background: #10b981;
}

.referral-stats {
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-secondary);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
}

.referral-stats .separator {
    color: var(--gray-600);
}

.referral-stats span:not(.separator) {
    color: var(--purple);
    font-weight: 500;
}

/* Chrome-specific scrolling fixes */
@media screen and (-webkit-min-device-pixel-ratio:0) and (min-resolution:.001dpcm) {
    /* Chrome mobile specific */
    @media (max-width: 768px) {
        .messages {
            /* Chrome mobile needs specific scroll handling */
            overflow-y: scroll !important;
            overflow-x: hidden !important;
            -webkit-overflow-scrolling: touch;
            transform: translateZ(0); /* Force hardware acceleration */
            will-change: scroll-position;
            /* Ensure it's the scroll container */
            flex: 1 1 auto;
            min-height: 0;
            position: relative;
        }
        
        .main {
            /* Ensure main doesn't scroll */
            overflow: hidden !important;
            height: 100%;
        }
    }
    
    /* Chrome desktop */
    @media (min-width: 769px) {
        .messages {
            overflow-y: auto !important;
            overflow-x: hidden;
            transform: translate3d(0, 0, 0);
        }
    }
}

/* Additional Chrome scroll fixes for Windows */
@supports (-webkit-appearance: none) and (not (-moz-appearance: none)) {
    .messages::-webkit-scrollbar {
        width: 12px;
    }
    
    .messages::-webkit-scrollbar-track {
        background: var(--gray-950);
    }
    
    .messages::-webkit-scrollbar-thumb {
        background: var(--gray-700);
        border-radius: 6px;
    }
    
    .messages::-webkit-scrollbar-thumb:hover {
        background: var(--gray-600);
    }
}
EOF < /dev/null