:root {
    /* Modern color palette */
    --primary-color: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    
    --secondary-color: #10b981;
    --secondary-light: #34d399;
    --secondary-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%);
    
    --accent-color: #f59e0b;
    --accent-gradient: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    
    /* Backgrounds */
    --background: #0f172a;
    --background-light: #1e293b;
    --surface: #1e293b;
    --surface-glass: rgba(30, 41, 59, 0.8);
    --surface-hover: #334155;
    
    /* Text colors */
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    
    /* Borders */
    --border-color: rgba(148, 163, 184, 0.2);
    --border-focus: rgba(99, 102, 241, 0.5);
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6), 0 10px 10px -5px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.4);
    
    /* Radii */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    /* Transitions - optimized for performance */
    --transition-fast: 100ms ease-out;
    --transition-base: 150ms ease-out;
    --transition-slow: 200ms ease-out;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 0 clamp(0.25rem, 1.5vw, 2rem);
    overflow: hidden;
}

header {
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
    color: white;
    padding: clamp(0.75rem, 1.5vw, 1.25rem) clamp(1rem, 2vw, 2rem);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
}

header h1 {
    font-size: 1.875rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.025em;
}

.subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.main-content {
    display: grid;
    grid-template-columns: 1fr clamp(240px, 25vw, 380px);
    gap: clamp(0.5rem, 1.5vw, 1.5rem);
    padding: clamp(0.5rem, 1.5vw, 1.5rem);
    flex: 1;
    overflow: hidden;
    max-width: 100%;
    width: 100%;
    min-width: 0;
}

/* Chat Section */
.chat-section {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    min-width: 0;
    min-height: 0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: clamp(1rem, 2vw, 2rem);
    scroll-behavior: smooth;
    position: relative;
    min-height: 0;
}

.message {
    margin-bottom: 1.5rem;
    position: relative;
}

.message-header {
    display: flex;
    align-items: center;
    margin-bottom: 0.75rem;
    font-weight: 600;
    font-size: 0.875rem;
    letter-spacing: 0.025em;
}

.message-header .icon {
    margin-right: 0.625rem;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--radius-md);
    background: var(--background-light);
    border: 1px solid var(--border-color);
}

.message.user .message-header {
    color: var(--primary-light);
}

.message.user .message-header .icon {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(129, 140, 248, 0.1));
    border-color: rgba(99, 102, 241, 0.3);
}

.message.assistant .message-header {
    color: var(--secondary-light);
}

.message.assistant .message-header .icon {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(52, 211, 153, 0.1));
    border-color: rgba(16, 185, 129, 0.3);
}

.message-content {
    background: var(--background-light);
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    line-height: 1.6;
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--border-color);
}

.message.user .message-content {
    border-left-color: var(--primary-color);
}

.message.assistant .message-content {
    border-left-color: var(--secondary-color);
}

.message.error .message-content {
    border-left-color: #ef4444;
    color: #fca5a5;
}

/* Markdown styling in messages */
.message-content h1,
.message-content h2,
.message-content h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
    line-height: 1.3;
}

.message-content h1 { font-size: 1.5rem; }
.message-content h2 { font-size: 1.25rem; }
.message-content h3 { font-size: 1.1rem; }

.message-content p {
    margin-bottom: 1rem;
}

.message-content ul,
.message-content ol {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.message-content li {
    margin-bottom: 0.5rem;
}

.message-content code {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 0.875em;
}

.message-content pre {
    background: rgba(0, 0, 0, 0.4);
    padding: 1rem;
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: 1rem 0;
    border: 1px solid var(--border-color);
}

.message-content pre code {
    background: none;
    padding: 0;
}

/* Input Section */
.input-section {
    border-top: 1px solid var(--border-color);
    padding: clamp(0.75rem, 1.5vw, 1.5rem);
    background: var(--surface);
    backdrop-filter: blur(20px);
}

.text-input-section {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.input-container {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    background: var(--background-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.5rem;
}

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

#user-input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 0.875rem 1rem;
    font-family: inherit;
    font-size: 1rem;
    color: var(--text-primary);
    resize: none;
    max-height: 200px;
    line-height: 1.5;
}

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

#user-input:focus {
    outline: none;
}

.send-button {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-button:hover {
    background: var(--primary-dark);
}

.send-button:disabled {
    background: var(--background-light);
    cursor: not-allowed;
    opacity: 0.5;
}

.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.75rem;
    padding: 0 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-connected {
    color: var(--secondary-light);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-connected::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--secondary-color);
    border-radius: 50%;
}

.status-disconnected {
    color: #f87171;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-disconnected::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #ef4444;
    border-radius: 50%;
}

.status-connecting {
    color: var(--accent-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-connecting::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--accent-color);
    border-radius: 50%;
}

.session-info {
    font-size: 0.875rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.session-info::before {
    content: '👤';
}

/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: clamp(0.75rem, 1.5vw, 1.5rem);
    overflow-y: auto;
    min-width: 0;
}

.rules-panel, .info-panel {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
}

.rules-panel h3 {
    font-size: clamp(1rem, 1.5vw, 1.25rem);
    margin-bottom: clamp(1rem, 1.5vw, 1.5rem);
    color: var(--text-primary);
    font-weight: 700;
    letter-spacing: -0.025em;
}

.rules-section {
    margin-bottom: 1rem;
}

.rules-section:last-of-type {
    margin-bottom: 1.5rem;
}

.rules-section h4 {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.5rem 0.75rem;
    background: var(--background-light);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    user-select: none;
}

.rules-section h4:hover {
    background: var(--surface-hover);
}

.rules-section h4::before {
    content: '▶';
    font-size: 0.625rem;
    color: var(--primary-light);
}

.rules-section.expanded h4::before {
    transform: rotate(90deg);
}

.rules-list {
    font-size: 0.875rem;
    display: none;
    padding: 0 0.5rem;
}

.rules-section.expanded .rules-list {
    display: block;
    padding-top: 0.75rem;
}

.rule-item {
    background: var(--background-light);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--secondary-color);
    line-height: 1.5;
}

.no-rules {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.875rem;
    text-align: center;
    padding: 2rem 1rem;
    opacity: 0.7;
}

.refresh-button {
    width: 100%;
    background: var(--background-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.625rem 1rem;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 0.5rem;
}

.refresh-button:hover {
    background: var(--surface-hover);
}

.info-panel h4 {
    font-size: 1.125rem;
    margin-bottom: 1.25rem;
    color: var(--text-primary);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.info-panel ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.info-panel li {
    padding: 0.5rem 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
    padding-left: 1.75rem;
    position: relative;
    line-height: 1.6;
}

.info-panel li::before {
    content: "→";
    position: absolute;
    left: 0;
    top: 0.5rem;
    color: var(--primary-light);
    font-weight: 600;
    font-size: 0.875rem;
}

/* Typing indicator */
.typing-indicator {
    display: inline-flex;
    gap: 4px;
    padding: 1rem;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--primary-light);
    border-radius: 50%;
    opacity: 0.6;
}

.typing-indicator span:nth-child(2) {
    opacity: 0.8;
}

.typing-indicator span:nth-child(3) {
    opacity: 1;
}

/* Scrollbar */
.chat-messages::-webkit-scrollbar,
.sidebar::-webkit-scrollbar {
    width: 8px;
}

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

.chat-messages::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
    transition: background var(--transition-base);
}

.chat-messages::-webkit-scrollbar-thumb:hover,
.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Firefox scrollbar */
.chat-messages,
.sidebar {
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

/* Authentication Styles */
.login-section {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--background);
}

.auth-container {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    max-width: 420px;
    width: 100%;
    margin: 1rem;
}

.logo-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
    margin-top: 0.5rem;
}

.app-logo {
    width: 150px;
    height: 150px;
    object-fit: contain;
    filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.4));
    background: transparent;
    border-radius: 0;
}

.auth-container .logo-header {
    flex-direction: column;
    gap: 0.75rem;
}

.auth-container h1 {
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 0;
    font-size: 2.25rem;
    font-weight: 800;
    letter-spacing: -0.025em;
}

header .logo-header {
    flex-direction: row;
}

header .app-logo {
    width: 80px;
    height: 80px;
}

.auth-container .subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 2.5rem;
    font-size: 1rem;
}

.auth-form {
    animation: formFadeIn 0.5s ease-out;
}

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

.auth-form h2 {
    color: var(--text-primary);
    margin-bottom: 2rem;
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.625rem;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-group input {
    width: 100%;
    padding: 1rem 1.25rem;
    background: var(--background-light);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    color: var(--text-primary);
    transition: all var(--transition-base);
}

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

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-group select,
.form-group textarea {
    width: 100%;
    padding: 1rem 1.25rem;
    background: var(--background-light);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    color: var(--text-primary);
    font-family: inherit;
    transition: all var(--transition-base);
}

.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

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

.auth-button {
    width: 100%;
    padding: 0.875rem 1.25rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 0.5rem;
}

.auth-button:hover {
    background: var(--primary-dark);
}

.auth-switch {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.auth-switch a {
    color: var(--primary-light);
    text-decoration: none;
    font-weight: 600;
    transition: color var(--transition-base);
}

.auth-switch a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

/* General Button Styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    gap: 0.5rem;
}

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

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--surface-hover);
    border-color: var(--primary-color);
}

.btn-success {
    background: var(--secondary-gradient);
    color: white;
}

.btn-success:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.125rem;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

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

/* Icon button base style */
.icon-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-muted);
}

.icon-button:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

/* Clear chat button specific styling */
.clear-chat-btn:hover {
    color: #ef4444;
}

.logout-button {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 500;
}

.logout-button:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.session-info {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.9rem;
}

/* Responsive - viewport-aware scaling */

/* Large screens with zoom support */
@media (max-width: 1400px) {
    .main-content {
        grid-template-columns: 1fr clamp(220px, 22vw, 320px);
    }
}

@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr clamp(200px, 20vw, 300px);
    }

    header {
        padding: 1rem 1.5rem;
    }

    header h1 {
        font-size: clamp(1.25rem, 2.5vw, 1.75rem);
    }
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .sidebar {
        display: none;
    }

    header h1 {
        font-size: clamp(1.25rem, 3vw, 1.5rem);
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 0.5rem;
    }

    header {
        padding: 0.875rem 1rem;
    }

    .main-content {
        padding: 0.75rem;
        gap: 0.75rem;
    }

    .chat-messages {
        padding: 1.25rem;
    }
}

@media (max-width: 640px) {
    header {
        padding: 0.75rem 1rem;
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }

    header h1 {
        font-size: 1.25rem;
    }

    .subtitle {
        font-size: 0.75rem;
    }

    .header-actions {
        width: 100%;
        justify-content: space-between;
    }

    .main-content {
        padding: 0.5rem;
        gap: 0.5rem;
    }

    .chat-messages {
        padding: 1rem;
    }

    .input-section {
        padding: 0.75rem;
    }

    .message-content {
        padding: 0.875rem 1rem;
    }

    .auth-container {
        padding: 1.5rem;
    }

    .auth-container h1 {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 0.25rem;
    }

    .message-header .icon {
        width: 1.75rem;
        height: 1.75rem;
        font-size: 1rem;
    }

    .send-button {
        padding: 0.625rem;
    }

    .chat-messages {
        padding: 0.75rem;
    }

    .message-content {
        padding: 0.75rem;
    }
}

/* Utilities */
.fade-in {
    animation: fadeInUp 0.5s ease-out;
}

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

/* Loading animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s linear infinite;
}

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

.loader {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid rgba(99, 102, 241, 0.2);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Focus visible for accessibility */
*:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Selection styling */
::selection {
    background: rgba(99, 102, 241, 0.3);
    color: var(--text-primary);
}

::-moz-selection {
    background: rgba(99, 102, 241, 0.3);
    color: var(--text-primary);
}

/* ========================================
   Voice Chat Styles
   ======================================== */

/* Voice Mode Toggle Button */
.voice-mode-btn {
    background: var(--background-light);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.875rem 1.125rem;
    cursor: pointer;
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.voice-mode-btn:hover {
    background: var(--surface-hover);
    border-color: rgba(99, 102, 241, 0.5);
    color: var(--primary-light);
    transform: translateY(-1px);
}

.voice-mode-btn.active {
    background: var(--primary-gradient);
    border-color: var(--primary-color);
    color: white;
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
}


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

.voice-mode-btn svg {
    position: relative;
    z-index: 1;
}

/* Tooltip for voice button */
.voice-mode-btn[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    background: var(--background-light);
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 12px;
    white-space: nowrap;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    pointer-events: none;
    z-index: 1000;
    animation: tooltipFade 0.2s ease-out;
}

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

/* Voice Input Section */
.voice-input-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 20px;
    background: var(--surface);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    gap: 24px;
    animation: fadeInUp 0.3s ease-out;
}

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

.voice-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    width: 100%;
}

/* Voice Button */
.voice-button {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--primary-gradient);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-lg);
    color: white;
}

.voice-button:hover {
    background: var(--primary-dark);
}

.voice-button.recording {
    background: var(--secondary-color);
}

/* Voice Visualizer */
.voice-visualizer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 40px;
    opacity: 0;
}

.voice-visualizer.active {
    opacity: 1;
}

.visualizer-bar {
    width: 4px;
    height: 50%;
    background: var(--primary-color);
    border-radius: 2px;
}

/* Voice Status */
.voice-status {
    font-size: 14px;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    text-align: center;
    transition: all var(--transition-base);
}

.voice-status-connecting {
    background: rgba(251, 191, 36, 0.1);
    color: var(--accent-color);
}

.voice-status-connected {
    background: rgba(16, 185, 129, 0.1);
    color: var(--secondary-color);
}

.voice-status-recording {
    background: rgba(16, 185, 129, 0.2);
    color: var(--secondary-light);
}

.voice-status-processing {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-light);
}

.voice-status-speaking {
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary-light);
}

.voice-status-disconnected {
    background: rgba(148, 163, 184, 0.1);
    color: var(--text-muted);
}

.voice-status-error {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
}


/* Responsive adjustments for voice mode */
@media (max-width: 768px) {
    .voice-button {
        width: 70px;
        height: 70px;
    }

    .voice-button svg {
        width: 28px;
        height: 28px;
    }

    .voice-input-section {
        padding: 30px 16px;
    }
}

/* Accessibility for voice button */
.voice-button:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 4px;
}

/* Instruction text for voice mode */
.voice-instruction {
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
    margin-top: 8px;
}

/* Exit Voice Mode Button */
.exit-voice-button {
    margin-top: 20px;
    padding: 12px 24px;
    background: var(--background-light);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
}

.exit-voice-button:hover {
    background: var(--surface-hover);
    border-color: rgba(99, 102, 241, 0.5);
    color: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.exit-voice-button:active {
    transform: translateY(0);
}

.exit-voice-button svg {
    flex-shrink: 0;
}

/* ========================================
   Rules UI Enhancements
   ======================================== */

.rules-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.rules-section-header h3 {
    margin-bottom: 0 !important;
}

.refresh-button-small {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    background: var(--background-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-base);
}

.refresh-button-small:hover {
    background: var(--surface-hover);
    border-color: rgba(99, 102, 241, 0.5);
    color: var(--primary-light);
}

.refresh-button-small:hover svg {
    animation: spin 0.6s ease-in-out;
}

.refresh-button-small:active {
    transform: scale(0.95);
}

/* Rule item with delete button */
.rule-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.rule-text {
    flex: 1;
    line-height: 1.5;
}

.rule-delete-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-base);
    flex-shrink: 0;
    opacity: 0;
}

.rule-item:hover .rule-delete-btn {
    opacity: 1;
}

.rule-delete-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    color: #f87171;
}

.rule-delete-btn:active {
    transform: scale(0.9);
}

/* ========================================
   Toast Notifications
   ======================================== */

.toast-notification {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.875rem 1.25rem;
    z-index: 10000;
    display: none;
    align-items: center;
    gap: 0.5rem;
    max-width: 90vw;
}

.toast-notification.show {
    display: flex;
}

.toast-notification.success {
    border-left: 3px solid #10b981;
}

.toast-notification.error {
    border-left: 3px solid #ef4444;
}

.toast-notification.info {
    border-left: 3px solid var(--primary-color);
}

.toast-message {
    color: var(--text-primary);
    font-size: 0.9375rem;
    font-weight: 500;
}

/* ========================================
   Rules Panel Main Styles (for index.html)
   ======================================== */

.rules-panel-main {
    padding: 1.5rem;
}

.rules-panel-main h2 {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.rules-subtitle {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.rules-panel-main .rules-section {
    background: var(--background-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
}

.rules-panel-main .rules-section h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.rules-panel-main .rules-list {
    max-height: none;
    overflow: visible;
    padding: 0;
}

.rules-panel-main .rule-item {
    background: var(--surface);
    padding: 0.875rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.625rem;
    border: 1px solid var(--border-color);
    padding-left: 2.5rem;
    position: relative;
}

.rules-panel-main .rule-item:last-child {
    margin-bottom: 0;
}

.rules-panel-main .no-rules {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Info panel in rules tab */
.rules-panel-main .info-panel {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(16, 185, 129, 0.05));
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.rules-panel-main .info-panel h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.rules-panel-main .info-panel ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.rules-panel-main .info-panel li {
    font-size: 0.875rem;
    color: var(--text-secondary);
    padding: 0.5rem 0;
    padding-left: 1.75rem;
    position: relative;
    line-height: 1.6;
}

.rules-panel-main .info-panel li::before {
    content: '→';
    position: absolute;
    left: 0;
    color: var(--primary-light);
    font-size: 0.875rem;
    font-weight: 600;
    top: 0.5rem;
}

.rules-panel-main .info-panel li strong {
    color: var(--text-primary);
}

/* Rules examples */
.rules-examples {
    background: var(--background-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
}

.rules-examples h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.example-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.chip {
    display: inline-block;
    padding: 0.5rem 0.875rem;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    transition: all var(--transition-base);
    cursor: default;
}

.chip:hover {
    border-color: rgba(99, 102, 241, 0.4);
    color: var(--primary-light);
    background: rgba(99, 102, 241, 0.1);
}

/* No Rules Empty State */
.no-rules-container {
    text-align: center;
    padding: 2rem 1rem;
}

.no-rules-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    opacity: 0.7;
}

.no-rules {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.no-rules-hint {
    color: var(--text-muted);
    font-size: 0.875rem;
    font-style: italic;
}
