:root {
    /* Brand */
    --primary: #002EC0;
    --primary-dark: #001F88;
    --primary-light: #335FE6;
    --accent: #ff6b35;

    --success: #2d8659;
    --warning: #d97706;
    --danger: #dc2626;

    /* Dark theme (default) */
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-tertiary: #1a2332;
    --bg-card: #1e293b;
    --bg-hover: #253447;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #334155;
    --border-light: #475569;
    --pill-bg: rgba(30, 41, 59, 0.7);
    --pill-border: rgba(51, 65, 85, 0.5);
    --canvas-bg-r: 10; --canvas-bg-g: 14; --canvas-bg-b: 26;
    --image-shadow: rgba(0, 0, 0, 0.5);

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6);

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light theme */
:root.light {
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f0f1f3;
    --bg-card: #ffffff;
    --bg-hover: rgba(0, 0, 0, 0.04);
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border-color: rgba(0, 0, 0, 0.1);
    --border-light: rgba(0, 0, 0, 0.15);
    --pill-bg: rgba(255, 255, 255, 0.8);
    --pill-border: rgba(0, 0, 0, 0.1);
    --canvas-bg-r: 248; --canvas-bg-g: 249; --canvas-bg-b: 250;
    --image-shadow: rgba(0, 0, 0, 0.15);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.12);
}

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

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    margin: 0;
    padding: 0;
    overflow: hidden;
    line-height: 1.6;
}

canvas {
    display: block;
}

.hidden { display: none !important; }

/* ==================== VOICE HEADER ==================== */

.voice-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 28px 20px 16px;
    pointer-events: none;
}

.voice-header > * {
    pointer-events: auto;
}

.voice-header__title {
    font-family: 'DM Sans', sans-serif;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.voice-header__status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.voice-header__status span:last-child {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: background var(--transition-base);
}

.status-dot.connected {
    background: var(--success);
    animation: pulse 2s infinite;
}

.status-dot.listening {
    background: var(--primary-light);
    animation: pulse 1.5s infinite;
}

.status-dot.speaking {
    background: var(--danger);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.85); }
}

/* ==================== CONTROL PILL ==================== */

.voice-controls {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
}

.control-pill {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    background: var(--pill-bg);
    backdrop-filter: blur(32px) saturate(1.4);
    -webkit-backdrop-filter: blur(32px) saturate(1.4);
    border: 1px solid var(--pill-border);
    border-radius: 9999px;
    /* Double-bezel: outer ambient glow + inner edge highlight */
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        0 4px 16px rgba(0, 0, 0, 0.12),
        0 12px 40px rgba(0, 0, 0, 0.18);
    gap: 2px;
}

.control-pill__divider {
    width: 1px;
    height: 24px;
    background: rgba(51, 65, 85, 0.6);
    margin: 0 4px;
    flex-shrink: 0;
}

.control-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 10px 20px;
    background: transparent;
    border: none;
    border-radius: 9999px;
    color: var(--text-secondary);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 220ms cubic-bezier(0.32, 0.72, 0, 1);
    white-space: nowrap;
}

.control-btn:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.control-btn:active:not(:disabled) {
    transform: scale(0.95);
    transition-duration: 80ms;
}

.control-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.control-btn svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.control-btn--start {
    color: var(--primary-light);
}

.control-btn--start:hover:not(:disabled) {
    color: #fff;
    background: rgba(0, 46, 192, 0.25);
}

.control-btn--danger {
    color: #fca5a5;
}

.control-btn--danger:hover:not(:disabled) {
    background: rgba(220, 38, 38, 0.2);
    color: #fca5a5;
}

.control-btn--muted {
    color: #fca5a5;
}

.control-btn--subtle {
    padding: 10px 14px;
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.control-btn--subtle svg {
    width: 18px;
    height: 18px;
}

.control-btn--subtle:hover:not(:disabled) {
    color: var(--text-secondary);
}

/* ==================== IMAGE DISPLAY ==================== */

#image-display {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 90;
    display: none;
    opacity: 0;
}

#image-display.visible {
    display: block;
    animation: imageIn 400ms ease-out forwards;
}

#image-display.dismissing {
    animation: imageOut 300ms ease-in forwards;
}

@keyframes imageIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.92);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes imageOut {
    from {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    to {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.95);
    }
}

#displayed-image {
    max-width: 55vw;
    max-height: 55vh;
    border-radius: 16px;
    box-shadow: 0 20px 60px var(--image-shadow);
    border: 1px solid var(--border-color);
    object-fit: contain;
}

/* ==================== ERROR TOAST ==================== */

#errorMessage {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(220, 38, 38, 0.9);
    color: white;
    padding: 12px 24px;
    border-radius: 12px;
    display: none;
    z-index: 200;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    font-size: 1rem;
    font-family: 'DM Sans', sans-serif;
    max-width: 90vw;
}

#errorMessage.show {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

/* ==================== THEME TOGGLE ==================== */

.theme-icon-moon { display: none; }
.theme-icon-sun  { display: block; }
:root.light .theme-icon-moon { display: block; }
:root.light .theme-icon-sun  { display: none; }
:root.light .theme-label-dark { display: none !important; }
:root.light .theme-label-light { display: inline !important; }

/* ==================== WAKE WORD HINT ==================== */

.voice-hint {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    z-index: 80;
    text-align: center;
    pointer-events: none;
    transition: opacity 400ms ease;
}

.voice-hint__text {
    font-family: 'DM Sans', sans-serif;
    font-size: 1.35rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.voice-hint__keyword {
    color: var(--primary-light);
    font-weight: 600;
}

.voice-hint--hidden {
    opacity: 0;
}

/* ==================== IMAGE HINT ==================== */

.image-hint {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    z-index: 80;
    text-align: center;
    pointer-events: none;
    transition: opacity 400ms ease;
}

.image-hint__text {
    font-family: 'DM Sans', sans-serif;
    font-size: 1.35rem;
    color: var(--text-muted);
    font-weight: 400;
}

.image-hint__keyword {
    color: var(--primary-light);
    font-weight: 600;
}

.image-hint--hidden {
    opacity: 0;
}

/* ==================== BRANDING ==================== */

.voice-branding {
    position: fixed;
    bottom: 8px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0.3;
    z-index: 50;
}

.voice-branding img {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    object-fit: cover;
}

.voice-branding span {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.5);
    font-family: 'JetBrains Mono', monospace;
}

/* ==================== LOGIN SCREEN ==================== */

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

.login-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
}

/* Admin pause overlay */
.pause-overlay {
    position: fixed;
    inset: 0;
    z-index: 9500;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(20, 20, 22, 0.72);
    backdrop-filter: grayscale(100%) blur(3px);
    -webkit-backdrop-filter: grayscale(100%) blur(3px);
    animation: fadeIn 0.3s ease-out;
}

.pause-overlay.hidden {
    display: none;
}

.pause-overlay__content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    color: #f5f5f5;
    text-align: center;
}

.pause-overlay__icon {
    display: inline-flex;
    opacity: 0.92;
}

.pause-overlay__icon svg {
    width: 56px;
    height: 56px;
}

.pause-overlay__text {
    font-size: 1.375rem;
    font-weight: 600;
    letter-spacing: -0.3px;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 3rem;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow-xl);
    animation: fadeIn 0.5s ease-out;
}

.login-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 0.5rem;
    letter-spacing: -0.5px;
}

.login-subtitle {
    color: var(--text-muted);
    text-align: center;
    font-size: 1.0625rem;
    margin-bottom: 2rem;
}

.login-field {
    margin-bottom: 1rem;
}

.login-field label {
    display: block;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-family: 'JetBrains Mono', monospace;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.login-field input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: 'DM Sans', sans-serif;
    transition: border-color var(--transition-base);
    outline: none;
}

.login-field input:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(0, 46, 192, 0.2);
}

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

.login-error {
    background: rgba(220, 38, 38, 0.15);
    border: 1px solid var(--danger);
    color: #fca5a5;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.btn {
    padding: 12px 24px;
    font-size: 1rem;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all var(--transition-base);
    font-weight: 500;
    font-family: 'DM Sans', sans-serif;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

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

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

.login-btn {
    width: 100%;
    padding: 14px;
    font-size: 1rem;
    margin-top: 0.75rem;
}

/* ==================== LIGHT THEME OVERRIDES ==================== */

:root.light .login-overlay {
    background: var(--bg-primary);
}

:root.light .login-card {
    background: var(--bg-card);
    border-color: var(--border-color);
}

:root.light .login-field input {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

:root.light .control-btn--danger {
    color: #dc2626;
}

:root.light .control-btn--danger:hover:not(:disabled) {
    background: rgba(220, 38, 38, 0.1);
}

:root.light .control-btn--muted {
    color: #dc2626;
}

:root.light .voice-branding span {
    color: rgba(0, 0, 0, 0.35);
}

:root.light #errorMessage {
    background: rgba(220, 38, 38, 0.95);
}

:root.light .login-error {
    background: rgba(220, 38, 38, 0.08);
    color: #dc2626;
}

/* ==================== RESPONSIVE ==================== */

@media (max-width: 480px) {
    .control-pill {
        padding: 6px 10px;
    }
    .control-btn {
        padding: 8px 14px;
        font-size: 0.8125rem;
    }
    .control-btn svg {
        width: 18px;
        height: 18px;
    }
    .voice-header__title {
        font-size: 1.5rem;
    }
    #displayed-image {
        max-width: 80vw;
        max-height: 35vh;
    }
}
