/* ========================================
   Marathi Voice Assistant - ChatGPT-inspired UI
   ======================================== */

/* ── CSS Variables (Light Theme) ── */
:root,
[data-theme="light"] {
    --bg-primary: #f7f7f8;
    --bg-secondary: #ffffff;
    --bg-sidebar: #f9f9f9;
    --bg-sidebar-hover: #ececec;
    --bg-input: #ffffff;
    --bg-input-border: #d9d9e3;
    --bg-user-msg: #1B4F72;
    --bg-bot-msg: #f7f7f8;
    --bg-cloud-msg: #faf5ff;
    --bg-cloud-accent: #8e44ad;
    --bg-topbar: rgba(255,255,255,0.85);
    --bg-typing: #f7f7f8;
    --bg-badge: #e8f0fe;
    --bg-suggestion: #ffffff;

    --text-primary: #1a1a2e;
    --text-secondary: #6b6b80;
    --text-tertiary: #8e8ea0;
    --text-inverse: #ffffff;
    --text-link: #1B4F72;
    --text-user-msg: #ffffff;
    --text-bot-msg: #1a1a2e;

    --border-color: #e5e5e5;
    --border-light: #f0f0f0;

    --accent-primary: #1B4F72;
    --accent-hover: #2E86C1;
    --accent-green: #2e7d32;
    --accent-blue: #1565c0;
    --accent-purple: #7b1fa2;
    --accent-orange: #e65100;
    --accent-red: #d32f2f;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --shadow-input: 0 0 0 2px rgba(27,79,114,0.15);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 50%;

    --sidebar-width: 280px;
    --topbar-height: 56px;
    --input-area-min: 80px;

    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Dark Theme ── */
[data-theme="dark"] {
    --bg-primary: #1a1a2e;
    --bg-secondary: #212136;
    --bg-sidebar: #16162a;
    --bg-sidebar-hover: #2a2a44;
    --bg-input: #2a2a44;
    --bg-input-border: #3a3a55;
    --bg-user-msg: #2E86C1;
    --bg-bot-msg: #212136;
    --bg-cloud-msg: #2a2040;
    --bg-cloud-accent: #a855f7;
    --bg-topbar: rgba(26,26,46,0.9);
    --bg-typing: #212136;
    --bg-badge: #2a2a44;
    --bg-suggestion: #212136;

    --text-primary: #e4e4e7;
    --text-secondary: #a1a1b5;
    --text-tertiary: #6b6b80;
    --text-inverse: #ffffff;
    --text-link: #5dade2;
    --text-user-msg: #ffffff;
    --text-bot-msg: #e4e4e7;

    --border-color: #2a2a44;
    --border-light: #232340;

    --accent-primary: #2E86C1;
    --accent-hover: #5dade2;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);
    --shadow-input: 0 0 0 2px rgba(46,134,193,0.25);
}

/* ── Reset & Base ── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, system-ui, Roboto, 'Helvetica Neue', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
    height: 100vh;
    display: flex;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* ── Scrollbar Styling ── */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* ========================================
   SIDEBAR
   ======================================== */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform var(--transition-slow), background-color var(--transition-normal);
    z-index: 100;
    overflow: hidden;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.sidebar-header {
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid var(--border-color);
}

.new-chat-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--accent-primary);
    color: var(--text-inverse);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: background-color var(--transition-fast), transform var(--transition-fast);
}

.new-chat-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.new-chat-btn:active {
    transform: translateY(0);
}

.sidebar-close-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.sidebar-close-btn:hover {
    background: var(--bg-sidebar-hover);
}

/* Sidebar Sections */
.sidebar-section {
    padding: 16px 12px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-section:last-of-type {
    flex: 1;
    overflow-y: auto;
    border-bottom: none;
}

.sidebar-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    margin-bottom: 12px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.stat-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    padding: 10px;
    text-align: center;
    border: 1px solid var(--border-color);
    transition: border-color var(--transition-fast), transform var(--transition-fast);
}

.stat-card:hover {
    border-color: var(--accent-primary);
    transform: translateY(-1px);
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-primary);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    margin-top: 2px;
}

/* Recent Queries */
.recent-queries {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.recent-query-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: background-color var(--transition-fast), color var(--transition-fast);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recent-query-item:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-primary);
}

.recent-query-item svg {
    flex-shrink: 0;
    opacity: 0.5;
}

.recent-query-text {
    overflow: hidden;
    text-overflow: ellipsis;
}

.empty-state-small {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    text-align: center;
    padding: 16px 8px;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-footer-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: background-color var(--transition-fast), color var(--transition-fast);
    width: 100%;
}

.sidebar-footer-btn:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-primary);
}

/* ── Theme Toggle Row (matches network-mode-toggle layout) ── */
.sidebar-footer-btn-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    margin: 0 8px 8px;
    background: var(--bg-sidebar-hover);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.sidebar-footer-btn-row:hover {
    background: var(--border-color);
}

.sidebar-footer-btn-row .wake-word-toggle-info {
    color: var(--text-secondary);
}

.sidebar-footer-btn-row:hover .wake-word-toggle-info {
    color: var(--text-primary);
}

.theme-mode-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-tertiary);
    letter-spacing: 0.3px;
    transition: all 0.25s ease;
}

[data-theme="dark"] .theme-mode-badge {
    background: rgba(139, 92, 246, 0.12);
    color: #a78bfa;
}

[data-theme="light"] .theme-mode-badge {
    background: rgba(251, 191, 36, 0.15);
    color: #d97706;
}

/* Theme toggle icon visibility */
[data-theme="light"] .icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }

.sidebar-brand {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    text-align: center;
    padding: 4px 0;
}

.brand-version {
    opacity: 0.5;
    margin-left: 4px;
}

/* ========================================
   MAIN CONTENT
   ======================================== */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-width: 0;
    position: relative;
    transition: margin-left var(--transition-slow);
}

/* ── Top Bar ── */
.topbar {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 16px;
    background: var(--bg-topbar);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 50;
    flex-shrink: 0;
    transition: background-color var(--transition-normal);
}

.menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    margin-right: 8px;
    transition: background-color var(--transition-fast);
}

.menu-btn:hover {
    background: var(--bg-sidebar-hover);
}

.topbar-title {
    display: flex;
    flex-direction: column;
}

.topbar-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

.topbar-subtitle {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.language-indicator {
    display: flex;
    align-items: center;
}

.lang-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    transition: all var(--transition-fast);
}

.lang-auto { background: var(--bg-badge); color: var(--text-secondary); }
.lang-mr { background: #e8f5e9; color: #2e7d32; }
.lang-en { background: #e3f2fd; color: #1565c0; }

[data-theme="dark"] .lang-mr { background: #1b3a20; color: #66bb6a; }
[data-theme="dark"] .lang-en { background: #1a2740; color: #64b5f6; }

/* ========================================
   CHAT CONTAINER
   ======================================== */
.chat-container {
    flex: 1;
    overflow-y: auto;
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column;
}

/* ── Welcome Screen ── */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 40px 20px;
    text-align: center;
    animation: fadeInUp 0.5s ease;
}

.welcome-screen.hidden {
    display: none;
}

.welcome-icon {
    width: 72px;
    height: 72px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-hover));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    margin-bottom: 20px;
    animation: pulse-glow 3s ease-in-out infinite;
}

.welcome-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.welcome-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.welcome-suggestions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    max-width: 520px;
    width: 100%;
}

.suggestion-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: var(--bg-suggestion);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: left;
    transition: all var(--transition-fast);
    line-height: 1.4;
}

.suggestion-chip:hover {
    border-color: var(--accent-primary);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
    transform: translateY(-2px);
}

.chip-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

/* ── Messages ── */
.messages {
    display: flex;
    flex-direction: column;
    padding: 16px 0;
    max-width: 768px;
    width: 100%;
    margin: 0 auto;
}

.message {
    display: flex;
    gap: 12px;
    padding: 16px 24px;
    animation: fadeInUp 0.3s ease;
    max-width: 100%;
}

.message + .message {
    margin-top: 4px;
}

/* Message Avatar */
.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.85rem;
    font-weight: 600;
}

.message-user .message-avatar {
    background: var(--bg-user-msg);
    color: var(--text-inverse);
    order: 1;
}

.message-bot .message-avatar {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-hover));
    color: var(--text-inverse);
}

/* Message Content */
.message-content {
    flex: 1;
    min-width: 0;
}

.message-user {
    flex-direction: row-reverse;
}

.message-user .message-content {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    line-height: 1.6;
    word-wrap: break-word;
    max-width: 100%;
    position: relative;
}

.message-user .message-bubble {
    background: var(--bg-user-msg);
    color: var(--text-user-msg);
    border-bottom-right-radius: 4px;
}

.message-bot .message-bubble {
    background: var(--bg-bot-msg);
    color: var(--text-bot-msg);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
}

.message-bot.cloud-source .message-bubble {
    background: var(--bg-cloud-msg);
    border-left: 3px solid var(--bg-cloud-accent);
}

/* Message Metadata */
.message-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.meta-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    transition: all var(--transition-fast);
}

.meta-badge-mr {
    background: #e8f5e9;
    color: #2e7d32;
}

.meta-badge-en {
    background: #e3f2fd;
    color: #1565c0;
}

.meta-badge-cloud {
    background: #f3e5f5;
    color: #7b1fa2;
}

.meta-badge-local {
    background: #e8f5e9;
    color: #2e7d32;
}

.meta-badge-confidence {
    background: var(--bg-badge);
    color: var(--text-secondary);
}

[data-theme="dark"] .meta-badge-mr { background: #1b3a20; color: #66bb6a; }
[data-theme="dark"] .meta-badge-en { background: #1a2740; color: #64b5f6; }
[data-theme="dark"] .meta-badge-cloud { background: #2a1a3a; color: #ce93d8; }
[data-theme="dark"] .meta-badge-local { background: #1b3a20; color: #66bb6a; }
[data-theme="dark"] .meta-badge-confidence { background: var(--bg-badge); color: var(--text-tertiary); }

.meta-time {
    font-size: 0.7rem;
    color: var(--text-tertiary);
}

/* Confidence Bar */
.confidence-bar {
    width: 40px;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    overflow: hidden;
    display: inline-block;
    vertical-align: middle;
}

.confidence-fill {
    height: 100%;
    border-radius: 2px;
    transition: width var(--transition-slow);
}

.confidence-high { background: #4caf50; }
.confidence-medium { background: #ff9800; }
.confidence-low { background: #f44336; }

/* Error Message */
.message-error .message-bubble {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

[data-theme="dark"] .message-error .message-bubble {
    background: #3a1a1a;
    border-color: #5a2020;
    color: #fca5a5;
}

/* ── Typing Indicator ── */
.typing-indicator {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 16px 24px;
    max-width: 768px;
    width: 100%;
    margin: 0 auto;
}

.typing-indicator.visible {
    display: flex;
}

.typing-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-hover));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.typing-dots {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--bg-bot-msg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    border-bottom-left-radius: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    background: var(--text-tertiary);
    animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

/* ========================================
   INPUT AREA
   ======================================== */
.input-area {
    padding: 12px 24px 16px;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
    transition: background-color var(--transition-normal);
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 768px;
    margin: 0 auto;
    background: var(--bg-input);
    border: 1px solid var(--bg-input-border);
    border-radius: var(--radius-lg);
    padding: 8px 12px;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input-wrapper:focus-within {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-input);
}

.input-wrapper textarea {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.5;
    resize: none;
    max-height: 150px;
    padding: 4px 0;
    min-height: 24px;
}

.input-wrapper textarea::placeholder {
    color: var(--text-tertiary);
}

.input-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    padding-bottom: 2px;
}

/* Voice Button */
.voice-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    position: relative;
    overflow: visible;
}

.voice-btn:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-primary);
}

/* Pulse rings - hidden by default */
.mic-pulse-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: var(--radius-full);
    border: 2px solid transparent;
    pointer-events: none;
    opacity: 0;
    transform: scale(1);
    transition: opacity 0.3s ease;
}

/* Sound wave bars - hidden by default */
.mic-sound-waves {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 2px;
    height: 20px;
}

.mic-wave-bar {
    display: block;
    width: 3px;
    height: 4px;
    background: currentColor;
    border-radius: 2px;
    transition: height 0.1s ease;
}

/* ── Recording State ── */
.voice-btn.recording {
    background: var(--accent-red);
    color: white;
    box-shadow: 0 0 0 0 rgba(211, 47, 47, 0.4);
    z-index: 2;
}

.voice-btn.recording .mic-icon {
    display: none;
}

.voice-btn.recording .mic-sound-waves {
    display: flex;
}

.voice-btn.recording .mic-wave-bar {
    animation: mic-wave-bounce 0.6s ease-in-out infinite;
}

.voice-btn.recording .mic-wave-bar:nth-child(1) { animation-delay: 0.0s; }
.voice-btn.recording .mic-wave-bar:nth-child(2) { animation-delay: 0.1s; }
.voice-btn.recording .mic-wave-bar:nth-child(3) { animation-delay: 0.2s; }
.voice-btn.recording .mic-wave-bar:nth-child(4) { animation-delay: 0.3s; }
.voice-btn.recording .mic-wave-bar:nth-child(5) { animation-delay: 0.4s; }

.voice-btn.recording .mic-pulse-ring {
    opacity: 1;
    border-color: rgba(211, 47, 47, 0.5);
    animation: mic-pulse-expand 1.8s ease-out infinite;
}

.voice-btn.recording .mic-pulse-ring-2 {
    animation-delay: 0.9s;
}

@keyframes mic-wave-bounce {
    0%, 100% { height: 4px; }
    50% { height: 16px; }
}

@keyframes mic-pulse-expand {
    0% {
        transform: scale(1);
        opacity: 0.6;
    }
    100% {
        transform: scale(2.2);
        opacity: 0;
    }
}

/* ── Mic Status Indicator (below input) ── */
.mic-status-indicator {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 4px 12px;
    margin: 4px auto 0;
    border-radius: 20px;
    background: rgba(211, 47, 47, 0.08);
    border: 1px solid rgba(211, 47, 47, 0.2);
    animation: mic-status-fade-in 0.3s ease;
}

.mic-status-indicator.active {
    display: inline-flex;
}

.mic-status-indicator.active + .input-hint {
    display: none;
}

.mic-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-red);
    animation: mic-status-blink 1s ease-in-out infinite;
}

.mic-status-text {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-red);
    letter-spacing: 0.03em;
}

@keyframes mic-status-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

@keyframes mic-status-fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

[data-theme="dark"] .mic-status-indicator {
    background: rgba(239, 83, 80, 0.12);
    border-color: rgba(239, 83, 80, 0.25);
}

[data-theme="dark"] .mic-status-dot {
    background: #ef5350;
}

[data-theme="dark"] .mic-status-text {
    color: #ef5350;
}

/* Send Button */
.send-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--radius-full);
    background: var(--accent-primary);
    color: var(--text-inverse);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    opacity: 0.4;
}

.send-btn:not(:disabled) {
    opacity: 1;
}

.send-btn:not(:disabled):hover {
    background: var(--accent-hover);
    transform: scale(1.05);
}

.send-btn:disabled {
    cursor: default;
}

.input-footer {
    max-width: 768px;
    margin: 6px auto 0;
    text-align: center;
}

.input-hint {
    font-size: 0.7rem;
    color: var(--text-tertiary);
}

/* ========================================
   ANIMATIONS
   ======================================== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-6px);
    }
}

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(27, 79, 114, 0.3);
    }
    50% {
        box-shadow: 0 0 20px 6px rgba(27, 79, 114, 0.15);
    }
}

@keyframes pulse-recording {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(211, 47, 47, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(211, 47, 47, 0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.active {
        display: block;
        opacity: 1;
    }

    .sidebar-close-btn {
        display: flex;
    }

    .menu-btn {
        display: flex;
    }

    .main {
        margin-left: 0;
    }

    .welcome-suggestions {
        grid-template-columns: 1fr;
    }

    .message {
        padding: 12px 16px;
    }

    .input-area {
        padding: 10px 12px 14px;
    }

    .typing-indicator {
        padding: 12px 16px;
    }

    .topbar {
        padding: 0 12px;
    }

    .welcome-screen {
        padding: 24px 16px;
    }

    .welcome-title {
        font-size: 1.25rem;
    }
}

@media (max-width: 480px) {
    .suggestion-chip {
        padding: 10px 12px;
        font-size: 0.8rem;
    }

    .message-bubble {
        padding: 10px 12px;
        font-size: 0.9rem;
    }

    .welcome-icon {
        width: 56px;
        height: 56px;
    }

    .welcome-icon svg {
        width: 32px;
        height: 32px;
    }
}

/* Large screens - wider chat */
@media (min-width: 1200px) {
    .messages,
    .typing-indicator,
    .input-wrapper,
    .input-footer {
        max-width: 860px;
    }
}

/* ========================================
   UTILITY CLASSES
   ======================================== */
.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}


/* ========================================
   AUDIO PLAYBACK BUTTONS
   ======================================== */

.message-actions {
    margin-top: 6px;
}

.audio-play-btn,
.audio-tts-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 150ms ease;
}

.audio-play-btn:hover,
.audio-tts-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.audio-play-btn.playing,
.audio-tts-btn.playing {
    background: var(--accent-primary);
    color: #fff;
    border-color: var(--accent-primary);
    animation: pulse-playing 1.2s ease infinite;
}

@keyframes pulse-playing {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Stop Button — hidden by default, shown when sibling is playing */
.audio-stop-btn {
    display: none;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border: 1px solid var(--accent-red);
    border-radius: 20px;
    background: var(--bg-secondary);
    color: var(--accent-red);
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 150ms ease;
}

.audio-stop-btn:hover {
    background: var(--accent-red);
    color: #fff;
}

.audio-play-btn.playing + .audio-stop-btn,
.audio-tts-btn.playing + .audio-stop-btn {
    display: inline-flex;
    animation: fadeInUp 0.2s ease;
}


/* ========================================
   MATCHED QUESTION DISPLAY
   ======================================== */

.matched-question {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    font-style: italic;
    margin-top: 4px;
    padding: 4px 8px;
    background: var(--bg-badge);
    border-radius: 4px;
    border-left: 2px solid var(--accent-primary);
}


/* ========================================
   SCORE & AUTO-LEARN BADGES
   ======================================== */

.meta-badge-scores {
    background: var(--bg-badge);
    color: var(--text-tertiary);
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.65rem;
    letter-spacing: 0.02em;
}

.meta-badge-autolearn {
    background: #fff3e0;
    color: #e65100;
}

[data-theme="dark"] .meta-badge-autolearn {
    background: #3a2a10;
    color: #ffb74d;
}


/* ========================================
   ADMIN BUTTON (Topbar)
   ======================================== */

.admin-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 150ms ease;
}

.admin-btn:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-primary);
}


/* ========================================
   ADMIN MODAL
   ======================================== */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-container {
    background: var(--bg-secondary);
    border-radius: 12px;
    width: 90%;
    max-width: 720px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: fadeInUp 0.2s ease;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.modal-close-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 150ms ease;
}

.modal-close-btn:hover {
    background: var(--bg-sidebar-hover);
}

.modal-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-color);
    padding: 0 16px;
    overflow-x: auto;
}

.modal-tab {
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 150ms ease;
    white-space: nowrap;
}

.modal-tab:hover {
    color: var(--text-primary);
}

.modal-tab.active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
}

.modal-body {
    padding: 16px 20px;
    overflow-y: auto;
    flex: 1;
    min-height: 200px;
}


/* ========================================
   ADMIN PANEL CONTENT
   ======================================== */

.admin-loading,
.admin-empty,
.admin-error {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-tertiary);
    font-size: 0.9rem;
}

.admin-error {
    color: #d32f2f;
}

/* ── Logs Table ── */

.admin-table-wrap {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.admin-table th,
.admin-table td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.admin-table th {
    font-weight: 600;
    color: var(--text-tertiary);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
}

.admin-table tr:hover {
    background: var(--bg-primary);
}

.td-time {
    white-space: nowrap;
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.td-query,
.td-match {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.src-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.src-badge.src-local { background: #e8f5e9; color: #2e7d32; }
.src-badge.src-cloud { background: #e3f2fd; color: #1565c0; }
.src-badge.src-none  { background: #fef2f2; color: #d32f2f; }

[data-theme="dark"] .src-badge.src-local { background: #1b3a1b; color: #81c784; }
[data-theme="dark"] .src-badge.src-cloud { background: #0d2a4a; color: #64b5f6; }
[data-theme="dark"] .src-badge.src-none  { background: #3a1b1b; color: #e57373; }

/* ── List Items (Unmatched, Popular) ── */

.admin-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.admin-list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    transition: background 150ms ease;
}

.admin-list-item:hover {
    background: var(--bg-primary);
}

.ask-count {
    display: inline-block;
    min-width: 32px;
    padding: 2px 6px;
    background: var(--accent-primary);
    color: #fff;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 700;
    text-align: center;
}

.ask-query {
    flex: 1;
    font-size: 0.85rem;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ask-lang {
    font-size: 0.72rem;
    color: var(--text-tertiary);
}

.ask-conf {
    font-size: 0.72rem;
    color: var(--text-tertiary);
    white-space: nowrap;
}

/* ── Review Cards ── */

.review-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.review-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 14px;
    transition: all 300ms ease;
}

.review-card.review-approved {
    opacity: 0;
    transform: translateX(30px);
    border-color: #2e7d32;
}

.review-card.review-rejected {
    opacity: 0;
    transform: translateX(-30px);
    border-color: #d32f2f;
}

.review-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.review-card-id {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    font-weight: 600;
}

.review-card-date {
    font-size: 0.72rem;
    color: var(--text-tertiary);
}

.review-card-question {
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.review-card-answer {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
    line-height: 1.5;
}

.review-card-actions {
    display: flex;
    gap: 8px;
}

.btn-approve,
.btn-reject {
    padding: 6px 14px;
    border: none;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 150ms ease;
}

.btn-approve {
    background: #e8f5e9;
    color: #2e7d32;
}

.btn-approve:hover {
    background: #c8e6c9;
}

.btn-approve:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-reject {
    background: #fef2f2;
    color: #d32f2f;
}

.btn-reject:hover {
    background: #fecaca;
}

.btn-reject:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

[data-theme="dark"] .btn-approve {
    background: #1b3a1b;
    color: #81c784;
}

[data-theme="dark"] .btn-approve:hover {
    background: #2a4a2a;
}

[data-theme="dark"] .btn-reject {
    background: #3a1b1b;
    color: #e57373;
}

[data-theme="dark"] .btn-reject:hover {
    background: #4a2a2a;
}

/* ── Import/Export ── */

.import-export-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.action-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.action-info {
    flex: 1;
}

.action-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.action-desc {
    font-size: 0.78rem;
    color: var(--text-tertiary);
}

.import-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.action-btn {
    padding: 8px 18px;
    background: var(--accent-primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 150ms ease;
    white-space: nowrap;
}

.action-btn:hover {
    opacity: 0.9;
}

.import-status {
    font-size: 0.78rem;
    color: var(--text-tertiary);
    white-space: nowrap;
}

.import-status.import-success {
    color: #2e7d32;
}

.import-status.import-error {
    color: #d32f2f;
}


/* ── Resources Tab ── */

.resource-summary {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 16px;
}

.resource-summary-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.resource-auto-refresh {
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--text-tertiary);
    background: var(--bg-secondary);
    padding: 2px 8px;
    border-radius: 10px;
}

.resource-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.resource-stat {
    text-align: center;
    padding: 8px 4px;
    background: var(--bg-secondary);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.resource-stat-value {
    display: block;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-primary);
    line-height: 1.3;
}

.resource-stat-label {
    display: block;
    font-size: 0.68rem;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.resource-stat-hint {
    display: block;
    font-size: 0.6rem;
    color: var(--text-tertiary);
    opacity: 0.7;
    margin-top: 1px;
}

.resource-cpu-cores {
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--text-tertiary);
    background: var(--bg-secondary);
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
}

.resource-table-header {
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    padding-left: 2px;
}

.td-resource {
    font-family: 'Courier New', monospace;
    font-size: 0.78rem;
    text-align: right;
    white-space: nowrap;
}

.resource-slow {
    color: #d32f2f;
    font-weight: 600;
}

[data-theme="dark"] .resource-slow {
    color: #e57373;
}


/* ========================================
   MODAL RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    .modal-container {
        width: 95%;
        max-height: 85vh;
        border-radius: 10px;
    }

    .modal-tabs {
        padding: 0 8px;
    }

    .modal-tab {
        padding: 8px 12px;
        font-size: 0.78rem;
    }

    .modal-body {
        padding: 12px 14px;
    }

    .action-row {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .td-query,
    .td-match {
        max-width: 100px;
    }

    .resource-summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .modal-tab {
        padding: 8px 8px;
        font-size: 0.72rem;
    }
}


/* ========================================
   VOICE MODE
   ======================================== */

/* ── Voice Mode Trigger Button ── */
.voice-mode-btn {
    width: 36px;
    height: 36px;
    border: 2px solid var(--accent-primary);
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--accent-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
    margin-left: 4px;
}

.voice-mode-btn:hover {
    background: var(--accent-primary);
    color: var(--text-inverse);
    transform: scale(1.05);
}

.voice-mode-btn.active {
    background: var(--accent-primary);
    color: var(--text-inverse);
    animation: pulse-glow 2s ease-in-out infinite;
}

[data-theme="dark"] .voice-mode-btn {
    border-color: var(--accent-hover);
    color: var(--accent-hover);
}

[data-theme="dark"] .voice-mode-btn:hover,
[data-theme="dark"] .voice-mode-btn.active {
    background: var(--accent-hover);
    color: #fff;
}

/* ── Voice Mode Overlay ── */
.voice-mode-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    z-index: 300;
    align-items: center;
    justify-content: center;
}

.voice-mode-overlay.active {
    display: flex;
    animation: fadeInUp 0.3s ease;
}

.voice-mode-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 40px 24px;
    position: relative;
    gap: 32px;
}

/* ── Close Button ── */
.voice-mode-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    border: none;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    z-index: 10;
}

.voice-mode-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    transform: scale(1.1);
}

/* ── Animated Orb ── */
.voice-mode-orb {
    position: relative;
    width: 160px;
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.orb-core {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-hover));
    box-shadow: 0 0 40px rgba(46, 134, 193, 0.4);
    transition: all 0.5s ease;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

/* Mic icon inside orb */
.orb-mic-icon {
    color: rgba(255, 255, 255, 0.9);
    transition: opacity 0.3s ease, transform 0.3s ease;
    position: absolute;
}

/* Sound waves inside orb - hidden by default */
.orb-sound-waves {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: 32px;
    position: absolute;
}

.orb-wave-bar {
    display: block;
    width: 4px;
    height: 6px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 2px;
}

/* Listening state: show sound waves, hide mic icon */
.voice-mode-orb.listening .orb-mic-icon {
    opacity: 0;
    transform: scale(0.5);
}

.voice-mode-orb.listening .orb-sound-waves {
    display: flex;
}

.voice-mode-orb.listening .orb-wave-bar {
    animation: orb-wave-animate 0.7s ease-in-out infinite;
}

.voice-mode-orb.listening .orb-wave-bar:nth-child(1) { animation-delay: 0.0s; }
.voice-mode-orb.listening .orb-wave-bar:nth-child(2) { animation-delay: 0.1s; }
.voice-mode-orb.listening .orb-wave-bar:nth-child(3) { animation-delay: 0.2s; }
.voice-mode-orb.listening .orb-wave-bar:nth-child(4) { animation-delay: 0.3s; }
.voice-mode-orb.listening .orb-wave-bar:nth-child(5) { animation-delay: 0.4s; }

@keyframes orb-wave-animate {
    0%, 100% { height: 6px; }
    50% { height: 28px; }
}

/* Thinking state: show spinning mic */
.voice-mode-orb.thinking .orb-mic-icon {
    opacity: 0.6;
    animation: orb-mic-spin 1.5s linear infinite;
}

.voice-mode-orb.thinking .orb-sound-waves {
    display: none;
}

@keyframes orb-mic-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Speaking state: pulsing mic */
.voice-mode-orb.speaking .orb-mic-icon {
    opacity: 0.8;
    animation: orb-mic-pulse 0.8s ease-in-out infinite;
}

.voice-mode-orb.speaking .orb-sound-waves {
    display: none;
}

@keyframes orb-mic-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* Waiting state: dim mic */
.voice-mode-orb.waiting .orb-mic-icon {
    opacity: 0.4;
}

.voice-mode-orb.waiting .orb-sound-waves {
    display: none;
}

/* Wake detected: flash mic */
.voice-mode-orb.wake-detected .orb-mic-icon {
    opacity: 1;
    animation: orb-mic-flash 0.5s ease;
}

@keyframes orb-mic-flash {
    0% { transform: scale(1); opacity: 0.4; }
    30% { transform: scale(1.3); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

.orb-ring {
    position: absolute;
    border-radius: var(--radius-full);
    border: 2px solid rgba(46, 134, 193, 0.3);
    transition: all 0.5s ease;
}

.orb-ring-1 { width: 100px; height: 100px; opacity: 0.6; }
.orb-ring-2 { width: 130px; height: 130px; opacity: 0.3; }
.orb-ring-3 { width: 160px; height: 160px; opacity: 0.15; }

/* Orb State: Listening */
.voice-mode-orb.listening .orb-core {
    background: linear-gradient(135deg, #2e7d32, #66bb6a);
    box-shadow: 0 0 60px rgba(46, 125, 50, 0.5);
}

.voice-mode-orb.listening .orb-ring {
    border-color: rgba(46, 125, 50, 0.4);
    animation: orb-pulse-listen 2s ease-in-out infinite;
}

.voice-mode-orb.listening .orb-ring-2 { animation-delay: 0.3s; }
.voice-mode-orb.listening .orb-ring-3 { animation-delay: 0.6s; }

/* Orb State: Thinking */
.voice-mode-orb.thinking .orb-core {
    background: linear-gradient(135deg, #e65100, #ff9800);
    box-shadow: 0 0 50px rgba(230, 81, 0, 0.4);
    animation: orb-spin 1.5s linear infinite;
}

.voice-mode-orb.thinking .orb-ring {
    border-color: rgba(230, 81, 0, 0.3);
    animation: orb-contract 1.5s ease-in-out infinite;
}

/* Orb State: Speaking */
.voice-mode-orb.speaking .orb-core {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-hover));
    box-shadow: 0 0 60px rgba(27, 79, 114, 0.5);
}

.voice-mode-orb.speaking .orb-ring {
    border-color: rgba(27, 79, 114, 0.4);
    animation: orb-pulse-speak 0.8s ease-in-out infinite;
}

.voice-mode-orb.speaking .orb-ring-2 { animation-delay: 0.15s; }
.voice-mode-orb.speaking .orb-ring-3 { animation-delay: 0.3s; }

/* Orb Animations */
@keyframes orb-pulse-listen {
    0%, 100% { transform: scale(1); opacity: 0.6; }
    50% { transform: scale(1.15); opacity: 0.3; }
}

@keyframes orb-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes orb-contract {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(0.85); }
}

@keyframes orb-pulse-speak {
    0%, 100% { transform: scale(1); opacity: 0.6; }
    50% { transform: scale(1.2); opacity: 0.15; }
}

/* ── Status Text ── */
.voice-mode-status {
    font-size: 1.1rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    text-align: center;
    letter-spacing: 0.02em;
    min-height: 28px;
}

/* ── Transcript Area ── */
.voice-mode-transcript {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    max-width: 500px;
    width: 100%;
    text-align: center;
    min-height: 60px;
}

.transcript-user {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.7);
    font-style: italic;
    max-height: 60px;
    overflow-y: auto;
    word-wrap: break-word;
    width: 100%;
}

.transcript-user:empty { display: none; }

.transcript-bot {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.95);
    font-weight: 500;
    max-height: 100px;
    overflow-y: auto;
    word-wrap: break-word;
    width: 100%;
    line-height: 1.5;
}

.transcript-bot:empty { display: none; }

/* ── Error Display ── */
.voice-mode-error {
    display: none;
    font-size: 0.85rem;
    color: #ef5350;
    text-align: center;
    padding: 8px 16px;
    background: rgba(239, 83, 80, 0.1);
    border-radius: var(--radius-sm);
    max-width: 400px;
}

.voice-mode-error.visible {
    display: block;
}

/* ── Voice Mode Responsive ── */
@media (max-width: 768px) {
    .voice-mode-container {
        padding: 24px 16px;
        gap: 24px;
    }

    .voice-mode-orb { width: 120px; height: 120px; }
    .orb-core { width: 60px; height: 60px; }
    .orb-ring-1 { width: 76px; height: 76px; }
    .orb-ring-2 { width: 98px; height: 98px; }
    .orb-ring-3 { width: 120px; height: 120px; }

    .orb-mic-icon { width: 24px; height: 24px; }
    .orb-wave-bar { width: 3px; }
    @keyframes orb-wave-animate {
        0%, 100% { height: 4px; }
        50% { height: 20px; }
    }

    .voice-mode-close {
        top: 12px;
        right: 12px;
        width: 40px;
        height: 40px;
    }

    .voice-mode-status { font-size: 1rem; }
    .voice-mode-transcript { max-width: 90%; }
}

@media (max-width: 480px) {
    .voice-mode-orb { width: 100px; height: 100px; }
    .orb-core { width: 50px; height: 50px; }
    .orb-ring-1 { width: 64px; height: 64px; }
    .orb-ring-2 { width: 82px; height: 82px; }
    .orb-ring-3 { width: 100px; height: 100px; }

    .orb-mic-icon { width: 20px; height: 20px; }
    .orb-wave-bar { width: 2.5px; gap: 2px; }
}


/* ══════════════════════════════════════════════════════════════════
   WAKE WORD FEATURE STYLES
   ══════════════════════════════════════════════════════════════════ */

/* ── Wake Word Toggle (Sidebar) ── */
.wake-word-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    margin: 0 8px 8px;
    background: var(--bg-sidebar-hover);
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.wake-word-toggle:hover {
    background: var(--border-color);
}

.wake-word-toggle-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
}

/* ── Toggle Switch ── */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: var(--bg-input-border);
    border-radius: 22px;
    transition: 0.25s;
}

.toggle-slider:before {
    content: "";
    position: absolute;
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: 0.25s;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--accent-primary);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(18px);
}

/* ── Voice Mode: Waiting State (Wake Word) ── */
.voice-mode-orb.waiting .orb-core {
    background: linear-gradient(135deg, #546e7a, #78909c);
    box-shadow: 0 0 30px rgba(84, 110, 122, 0.3);
    animation: orb-breathe 3s ease-in-out infinite;
}

.voice-mode-orb.waiting .orb-ring {
    border-color: rgba(84, 110, 122, 0.2);
    animation: orb-breathe-ring 3s ease-in-out infinite;
}

.voice-mode-orb.waiting .orb-ring-2 { animation-delay: 0.5s; }
.voice-mode-orb.waiting .orb-ring-3 { animation-delay: 1.0s; }

@keyframes orb-breathe {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.05); opacity: 1; }
}

@keyframes orb-breathe-ring {
    0%, 100% { transform: scale(1); opacity: 0.2; }
    50% { transform: scale(1.08); opacity: 0.1; }
}

/* ── Voice Mode: Wake Detected Flash ── */
.voice-mode-orb.wake-detected .orb-core {
    background: linear-gradient(135deg, #ffd600, #ffab00);
    box-shadow: 0 0 80px rgba(255, 214, 0, 0.6);
    animation: orb-flash 0.5s ease;
}

.voice-mode-orb.wake-detected .orb-ring {
    border-color: rgba(255, 214, 0, 0.5);
    animation: orb-flash-ring 0.5s ease;
}

@keyframes orb-flash {
    0% { transform: scale(1); }
    30% { transform: scale(1.3); }
    100% { transform: scale(1.05); }
}

@keyframes orb-flash-ring {
    0% { transform: scale(1); opacity: 0.3; }
    30% { transform: scale(1.4); opacity: 0.8; }
    100% { transform: scale(1.1); opacity: 0.4; }
}

/* ── Wake Word Badge (Voice Mode Overlay) ── */
.voice-mode-wake-badge {
    display: none;
    position: absolute;
    top: 24px;
    left: 24px;
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.78rem;
    font-weight: 500;
    align-items: center;
    gap: 6px;
    z-index: 10;
    letter-spacing: 0.02em;
}

.voice-mode-wake-badge.visible {
    display: flex;
}

.voice-mode-wake-badge.active {
    color: #ffd600;
    border-color: rgba(255, 214, 0, 0.3);
    background: rgba(255, 214, 0, 0.08);
}

.voice-mode-wake-badge.active svg {
    stroke: #ffd600;
}

/* ── Wake Word Hint ── */
.voice-mode-wake-hint {
    display: none;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.5);
    text-align: center;
    letter-spacing: 0.02em;
    animation: fadeInUp 0.5s ease;
}

.voice-mode-wake-hint.visible {
    display: block;
}

.voice-mode-wake-hint span {
    color: #ffd600;
    font-weight: 600;
}

/* ── Responsive adjustments for wake word ── */
@media (max-width: 768px) {
    .voice-mode-wake-badge {
        top: 16px;
        left: 16px;
        font-size: 0.72rem;
        padding: 5px 10px;
    }

    .voice-mode-wake-hint {
        font-size: 0.82rem;
    }
}


/* ══════════════════════════════════════════════════════════════════
   WAKE WORD CONFIGURATION PANEL (Admin Tools)
   ══════════════════════════════════════════════════════════════════ */

/* ── Sidebar: Wake Word Section Layout ── */
.wake-word-section {
    margin: 0 8px 8px;
}

/* ── Network Mode Toggle ── */
.network-mode-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    margin: 0 8px 8px;
    background: var(--bg-sidebar-hover);
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.network-mode-toggle:hover {
    background: var(--border-color);
}

.network-mode-label {
    font-weight: 600;
    transition: color 0.25s;
}

/* When toggle is OFF (offline) — label turns amber */
.network-mode-toggle.offline .network-mode-label {
    color: #f59e0b;
}

/* When toggle is ON (online) — label stays green */
.network-mode-toggle.online .network-mode-label {
    color: #22c55e;
}

/* Network slider uses green/amber instead of blue */
.toggle-slider-network {
    background-color: #f59e0b !important;
}

.toggle-switch input:checked + .toggle-slider-network {
    background-color: #22c55e !important;
}

/* Network status indicator in header area */
.network-status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
}

.network-status-indicator.online {
    background: rgba(34, 197, 94, 0.12);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.25);
}

.network-status-indicator.offline {
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.25);
}

.network-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    animation: statusPulse 2s ease-in-out infinite;
}

.network-status-indicator.online .network-status-dot {
    background: #22c55e;
}

.network-status-indicator.offline .network-status-dot {
    background: #f59e0b;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ── Config Panel Layout ── */
.ww-config-panel {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 4px 0;
}

.ww-section-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.ww-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.ww-section-count {
    font-size: 0.78rem;
    color: var(--text-tertiary);
    background: var(--bg-badge);
    padding: 2px 10px;
    border-radius: 12px;
}

/* ── Status Section ── */
.ww-status-section {
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    padding: 16px;
    border: 1px solid var(--border-color);
}

.ww-status-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.ww-status-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.ww-status-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.45;
}

.ww-status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    transition: all var(--transition-normal);
}

.ww-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.ww-status-indicator.ww-active {
    background: rgba(46, 125, 50, 0.1);
    color: #2e7d32;
}

.ww-status-indicator.ww-active .ww-status-dot {
    background: #2e7d32;
    box-shadow: 0 0 6px rgba(46, 125, 50, 0.5);
    animation: ww-dot-pulse 2s ease-in-out infinite;
}

.ww-status-indicator.ww-inactive {
    background: var(--bg-badge);
    color: var(--text-secondary);
}

.ww-status-indicator.ww-inactive .ww-status-dot {
    background: var(--text-tertiary);
}

[data-theme="dark"] .ww-status-indicator.ww-active {
    background: rgba(46, 125, 50, 0.15);
    color: #66bb6a;
}

[data-theme="dark"] .ww-status-indicator.ww-active .ww-status-dot {
    background: #66bb6a;
    box-shadow: 0 0 6px rgba(102, 187, 106, 0.4);
}

@keyframes ww-dot-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.3); }
}

/* Larger toggle for the config panel */
.toggle-switch-lg {
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}

.toggle-switch-lg .toggle-slider:before {
    height: 20px;
    width: 20px;
}

.toggle-switch-lg input:checked + .toggle-slider:before {
    transform: translateX(22px);
}

/* ── Wake Words List ── */
.ww-words-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ww-word-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.ww-word-item:hover {
    border-color: var(--accent-primary);
    background: var(--bg-suggestion);
}

.ww-word-text {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    font-family: 'Segoe UI', system-ui, sans-serif;
}

.ww-word-lang {
    font-size: 0.7rem;
    padding: 2px 8px;
    background: var(--bg-badge);
    color: var(--text-secondary);
    border-radius: 10px;
    font-weight: 500;
}

.ww-word-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.ww-word-remove:hover {
    background: rgba(211, 47, 47, 0.1);
    color: #d32f2f;
}

.ww-empty {
    text-align: center;
    padding: 20px;
    color: var(--text-tertiary);
    font-size: 0.85rem;
    font-style: italic;
}

/* ── Add New Word ── */
.ww-add-section, .ww-test-section {
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    padding: 16px;
    border: 1px solid var(--border-color);
}

.ww-add-row, .ww-test-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.ww-input {
    flex: 1;
    padding: 9px 14px;
    border: 1px solid var(--bg-input-border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.88rem;
    outline: none;
    transition: border-color var(--transition-fast);
}

.ww-input:focus {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-input);
}

.ww-input::placeholder {
    color: var(--text-tertiary);
}

.ww-add-btn, .ww-test-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    flex-shrink: 0;
}

.ww-add-btn {
    background: var(--accent-primary);
    color: white;
}

.ww-add-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.ww-test-btn {
    background: var(--bg-badge);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.ww-test-btn:hover {
    background: var(--bg-sidebar-hover);
    border-color: var(--accent-primary);
}

.ww-add-hint {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: 10px;
    line-height: 1.5;
}

/* ── Test Results ── */
.ww-test-result {
    margin-top: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    line-height: 1.5;
    display: none;
}

.ww-test-result.ww-test-match {
    display: block;
    background: rgba(46, 125, 50, 0.08);
    color: #2e7d32;
    border: 1px solid rgba(46, 125, 50, 0.2);
}

.ww-test-result.ww-test-no-match {
    display: block;
    background: rgba(211, 47, 47, 0.06);
    color: #d32f2f;
    border: 1px solid rgba(211, 47, 47, 0.15);
}

[data-theme="dark"] .ww-test-result.ww-test-match {
    background: rgba(102, 187, 106, 0.1);
    color: #66bb6a;
    border-color: rgba(102, 187, 106, 0.2);
}

[data-theme="dark"] .ww-test-result.ww-test-no-match {
    background: rgba(239, 83, 80, 0.1);
    color: #ef5350;
    border-color: rgba(239, 83, 80, 0.2);
}

.ww-test-extracted {
    display: block;
    margin-top: 4px;
    font-style: italic;
    opacity: 0.85;
}

/* ── Save Status Toast ── */
.ww-save-status {
    text-align: center;
    font-size: 0.82rem;
    font-weight: 500;
    padding: 0;
    border-radius: var(--radius-sm);
    transition: all var(--transition-normal);
    min-height: 0;
    overflow: hidden;
}

.ww-save-status.ww-save-success {
    padding: 8px 14px;
    background: rgba(46, 125, 50, 0.08);
    color: #2e7d32;
}

.ww-save-status.ww-save-error {
    padding: 8px 14px;
    background: rgba(211, 47, 47, 0.06);
    color: #d32f2f;
}

[data-theme="dark"] .ww-save-status.ww-save-success {
    background: rgba(102, 187, 106, 0.1);
    color: #66bb6a;
}

[data-theme="dark"] .ww-save-status.ww-save-error {
    background: rgba(239, 83, 80, 0.1);
    color: #ef5350;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .ww-add-row, .ww-test-row {
        flex-direction: column;
    }

    .ww-add-btn, .ww-test-btn {
        width: 100%;
        justify-content: center;
    }
}


/* ══════════════════════════════════════════════════════════════════
   WAKE WORD VOICE TRAINING UI
   ══════════════════════════════════════════════════════════════════ */

/* ── Training Section Container ── */
.ww-train-section {
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    padding: 18px;
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--accent-primary);
}

.ww-train-section > .ww-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
}

.ww-train-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 14px;
    line-height: 1.45;
}

/* ── Model Status ── */
.ww-model-status {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.83rem;
}

.ww-model-trained {
    background: rgba(46, 125, 50, 0.06);
    border: 1px solid rgba(46, 125, 50, 0.15);
}

.ww-model-untrained {
    background: var(--bg-badge);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.ww-model-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: #2e7d32;
    margin-bottom: 6px;
}

.ww-model-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.ww-model-dot.trained {
    background: #2e7d32;
    box-shadow: 0 0 6px rgba(46,125,50,0.5);
}

.ww-model-dot.untrained {
    background: var(--text-tertiary);
}

[data-theme="dark"] .ww-model-badge { color: #66bb6a; }
[data-theme="dark"] .ww-model-trained {
    background: rgba(102, 187, 106, 0.08);
    border-color: rgba(102, 187, 106, 0.15);
}

.ww-model-metrics {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.ww-metric {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.ww-metric strong {
    color: var(--text-primary);
}

.ww-model-date {
    font-size: 0.72rem;
    color: var(--text-tertiary);
    margin-top: 6px;
}

/* ── Recording Cards (Positive / Negative) ── */
.ww-record-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

@media (max-width: 768px) {
    .ww-record-controls {
        grid-template-columns: 1fr;
    }
}

.ww-record-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ww-record-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ww-record-card-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ww-record-card-icon.positive {
    background: rgba(46, 125, 50, 0.12);
    color: #2e7d32;
}

.ww-record-card-icon.negative {
    background: rgba(211, 47, 47, 0.1);
    color: #d32f2f;
}

.ww-record-card-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
    flex: 1;
}

.ww-record-card-count {
    font-size: 0.78rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--bg-badge);
    color: var(--text-secondary);
}

.ww-record-card-hint {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    line-height: 1.4;
}

/* ── Record Buttons ── */
.ww-record-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 14px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.ww-record-btn-pos {
    background: rgba(46, 125, 50, 0.1);
    color: #2e7d32;
    border: 1px solid rgba(46, 125, 50, 0.2);
}

.ww-record-btn-pos:hover {
    background: rgba(46, 125, 50, 0.18);
}

.ww-record-btn-neg {
    background: rgba(211, 47, 47, 0.08);
    color: #d32f2f;
    border: 1px solid rgba(211, 47, 47, 0.15);
}

.ww-record-btn-neg:hover {
    background: rgba(211, 47, 47, 0.15);
}

.ww-record-btn-test {
    background: var(--bg-badge);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.ww-record-btn-test:hover {
    border-color: var(--accent-primary);
}

/* Recording animation */
.ww-record-btn.recording {
    animation: ww-recording-pulse 1s ease-in-out infinite;
}

.ww-record-btn.recording svg circle {
    fill: #d32f2f;
}

@keyframes ww-recording-pulse {
    0%, 100% { transform: scale(1); box-shadow: none; }
    50% { transform: scale(1.02); box-shadow: 0 0 12px rgba(211, 47, 47, 0.3); }
}

[data-theme="dark"] .ww-record-btn-pos {
    background: rgba(102, 187, 106, 0.1);
    color: #66bb6a;
    border-color: rgba(102, 187, 106, 0.2);
}

[data-theme="dark"] .ww-record-btn-neg {
    background: rgba(239, 83, 80, 0.1);
    color: #ef5350;
    border-color: rgba(239, 83, 80, 0.15);
}

/* ── Sample Lists ── */
.ww-sample-list {
    max-height: 150px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.ww-sample-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    background: var(--bg-primary);
    transition: background var(--transition-fast);
}

.ww-sample-row:hover {
    background: var(--bg-sidebar-hover);
}

.ww-sample-play, .ww-sample-del {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--transition-fast);
}

.ww-sample-play {
    color: var(--accent-primary);
}

.ww-sample-play:hover {
    background: rgba(27, 79, 114, 0.1);
}

.ww-sample-del {
    color: var(--text-tertiary);
}

.ww-sample-del:hover {
    background: rgba(211, 47, 47, 0.1);
    color: #d32f2f;
}

.ww-sample-name {
    flex: 1;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ww-sample-dur {
    color: var(--text-tertiary);
    font-size: 0.7rem;
    flex-shrink: 0;
}

.ww-sample-empty {
    text-align: center;
    padding: 12px 8px;
    color: var(--text-tertiary);
    font-size: 0.78rem;
    font-style: italic;
}

.ww-clear-btn {
    margin-top: 4px;
    padding: 5px 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: transparent;
    color: var(--text-tertiary);
    font-size: 0.72rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    align-self: flex-end;
}

.ww-clear-btn:hover:not(:disabled) {
    border-color: #d32f2f;
    color: #d32f2f;
}

.ww-clear-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ── Train Button ── */
.ww-train-action {
    text-align: center;
    margin-top: 4px;
}

.ww-train-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 32px;
    border: none;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-hover));
    color: white;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
    letter-spacing: 0.02em;
}

.ww-train-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(27, 79, 114, 0.3);
}

.ww-train-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.ww-train-btn.training {
    animation: ww-train-pulse 1.5s ease-in-out infinite;
}

@keyframes ww-train-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(46, 134, 193, 0.4); }
    50% { box-shadow: 0 0 0 12px rgba(46, 134, 193, 0); }
}

.ww-train-hint {
    font-size: 0.78rem;
    color: var(--text-tertiary);
    margin-top: 8px;
}

/* ── Live Test ── */
.ww-live-test {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.ww-live-test-desc {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
