/* BASE STYLES */
:root {
--color-white: rgba(255, 255, 255, 1);
--color-black: rgba(0, 0, 0, 1);
--color-slate-900: rgba(19, 52, 59, 1);
--color-gray-300: rgba(167, 169, 169, 1);
--color-primary: #2DD4BF;
--color-primary-rgb: 45, 212, 191;
--color-speaking: #8B5CF6;
--color-speaking-rgb: 139, 92, 246;
--color-danger: #EF4444;
--color-danger-rgb: 239, 68, 68;
--color-warning: #F59E0B;
--color-warning-rgb: 245, 158, 11;

--space-8: 8px;
--space-12: 12px;
--space-16: 16px;
--space-20: 20px;
--space-24: 24px;
--space-32: 32px;
--space-48: 48px;

--radius-md: 10px;
--radius-lg: 18px;
--radius-xl: 24px;
--radius-full: 9999px;

--font-size-base: 14px;
--font-size-md: 16px;
--font-size-lg: 18px;
--font-weight-medium: 500;
--font-weight-semibold: 600;

--duration-fast: 150ms;
--duration-normal: 250ms;
--duration-slow: 400ms;
--ease-standard: cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--color-black);
    color: var(--color-white);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow: hidden;
}

body.light-theme {
    background-color: #f5f9fb;
    color: var(--color-slate-900);
}

/* Z-INDEX LAYERS:
1. Text boxes (z-index: 10)
2. Particles canvas (z-index: 50)
3. Controls (z-index: 100)
*/

/* APP HEADER */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-16) var(--space-24);
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0));
    backdrop-filter: blur(18px);
    z-index: 1300;
}

body.light-theme .app-header {
    background: linear-gradient(180deg, rgba(245, 249, 251, 0.85), rgba(245, 249, 251, 0));
}

.header-actions {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-btn {
    all: unset;
    display: inline-flex;
    align-items: center;
    gap: var(--space-12);
    padding: 0 var(--space-16);
    height: 44px;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--color-white);
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-medium);
    cursor: pointer;
    transition: transform var(--duration-normal) var(--ease-standard), background-color 0.2s ease;
}

.header-btn:hover {
    transform: translateY(-1px);
}

body.light-theme .header-btn {
    background: rgba(15, 23, 42, 0.06);
    border-color: rgba(15, 23, 42, 0.1);
    color: var(--color-slate-900);
}

body.light-theme .header-btn:hover {
    background: rgba(15, 23, 42, 0.1);
}

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

.account-btn span {
    font-weight: var(--font-weight-semibold);
    letter-spacing: 0.02em;
}

.theme-toggle {
    all: unset;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    cursor: pointer;
    transition: background-color 0.2s ease;
}

body.light-theme .theme-toggle {
    background: rgba(15, 23, 42, 0.06);
    border-color: rgba(15, 23, 42, 0.1);
}

/* Current Station Display */
.current-station {
    display: flex;
    align-items: center;
    gap: var(--space-8);
    padding: var(--space-8) var(--space-12);
    border-radius: var(--radius-full);
    background: rgba(45, 212, 191, 0.1);
    border: 1px solid rgba(45, 212, 191, 0.2);
    color: var(--color-primary);
    font-size: 13px;
    font-weight: var(--font-weight-medium);
    transition: all var(--duration-normal) var(--ease-standard);
    max-width: 200px;
}

.current-station svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    stroke: currentColor;
}

.current-station #station-name-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

/* Light theme styles for current station */
body.light-theme .current-station {
    background: rgba(45, 212, 191, 0.08);
    border-color: rgba(45, 212, 191, 0.15);
    color: #059669;
}

/* Loading state */
.current-station.loading {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.2);
    color: var(--color-warning);
}

body.light-theme .current-station.loading {
    background: rgba(245, 158, 11, 0.08);
    border-color: rgba(245, 158, 11, 0.15);
    color: #D97706;
}

/* Error state */
.current-station.error {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
    color: var(--color-danger);
}

body.light-theme .current-station.error {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.15);
    color: #DC2626;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .current-station {
        max-width: 120px;
    }
    
    .current-station #station-name-text {
        max-width: 80px;
    }
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.18);
}

body.light-theme .theme-toggle:hover {
    background: rgba(15, 23, 42, 0.12);
}

.theme-toggle-icon {
    color: var(--color-white);
    stroke-width: 2px;
}

body.light-theme .theme-toggle-icon {
    color: var(--color-slate-900);
}

/* PARTICLE CANVAS - Takes upper portion of screen */
#background-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 50vh;  /* Half of screen height */
    z-index: 50;
    pointer-events: none;
}

/* VOICE MODE - Container for text elements */
.voice-mode-container {
    position: fixed;
    top: 50vh;  /* Start right after particles */
    left: 0;
    width: 100%;
    height: 50vh;  /* Use remaining half of screen */
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 80px;  /* Significantly increased from 60px for much more space */
    z-index: 10;
    pointer-events: none;
}

body.voice-mode .voice-mode-container {
    display: flex;
}

/* VOICE MODE STATUS - Now relative positioned */
.voice-status-container {
    position: relative;  /* Changed from absolute */
    text-align: center;
    width: 90%;
    max-width: 500px;
    margin-bottom: 40px;  /* Significantly increased from var(--space-24) for much more space */
}

.status-text {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--color-white);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

body.light-theme .status-text {
    color: var(--color-slate-900);
    text-shadow: none;
}

/* TRANSCRIPTION CONTAINERS - Now relative positioned */
.transcription-container,
.processing-transcription {
    position: relative;  /* Changed from absolute */
    width: calc(90% - var(--space-32));
    max-width: 450px;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(15px);
    border-radius: var(--radius-lg);
    padding: var(--space-16) var(--space-20);
    display: none;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    margin-bottom: 32px;  /* Significantly increased from var(--space-16) for more space */
}

.processing-transcription {
    border: 2px solid rgba(45, 212, 191, 0.3);
    text-align: center;
}

.transcription-container {
    border: 2px solid rgba(45, 212, 191, 0.3);
    max-height: calc(var(--space-16) * 2 + var(--font-size-md) * 4);
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
    position: relative;
    pointer-events: all;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(45, 212, 191, 0.25) transparent;
}

.transcription-container::-webkit-scrollbar {
    width: 3px;
    background: transparent;
}

.transcription-container::-webkit-scrollbar-thumb {
    background: rgba(45, 212, 191, 0.3);
    border-radius: 9999px;
    transition: background 0.2s ease;
}

.transcription-container:hover::-webkit-scrollbar-thumb,
.transcription-container.scrolling::-webkit-scrollbar-thumb {
    background: rgba(45, 212, 191, 0.65);
}

.transcription-container::-webkit-scrollbar-track {
    background: transparent;
    margin: 6px 0;
}

.transcription-container.scrolling {
    scrollbar-color: rgba(45, 212, 191, 0.55) transparent;
}

/* Smooth scroll behavior */
.transcription-container {
    scroll-padding-top: 10px;
    scroll-padding-bottom: 10px;
}

/* Focus styles for keyboard navigation */
.transcription-container:focus {
    outline: 2px solid rgba(45, 212, 191, 0.5);
    outline-offset: -2px;
}

/* Apply same scroll behavior to processing transcription */
.processing-transcription {
    scroll-behavior: smooth;
    pointer-events: all;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(45, 212, 191, 0.25) transparent;
}

.processing-transcription::-webkit-scrollbar {
    width: 3px;
    background: transparent;
}

.processing-transcription::-webkit-scrollbar-thumb {
    background: rgba(45, 212, 191, 0.3);
    border-radius: 9999px;
    transition: background 0.2s ease;
}

.processing-transcription:hover::-webkit-scrollbar-thumb,
.processing-transcription.scrolling::-webkit-scrollbar-thumb {
    background: rgba(45, 212, 191, 0.65);
}

.processing-transcription::-webkit-scrollbar-track {
    background: transparent;
    margin: 6px 0;
}

.processing-transcription.scrolling {
    scrollbar-color: rgba(45, 212, 191, 0.55) transparent;
}

.processing-transcription:focus {
    outline: 2px solid rgba(45, 212, 191, 0.5);
    outline-offset: -2px;
}

body.light-theme .processing-transcription,
body.light-theme .transcription-container {
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 8px 30px rgba(15, 23, 42, 0.15);
}

body.light-theme .processing-transcription {
    border-color: rgba(45, 212, 191, 0.4);
}

body.light-theme .transcription-container {
    border-color: rgba(45, 212, 191, 0.4);
}

/* Light theme scrollbar colors */
body.light-theme .transcription-container,
body.light-theme .processing-transcription {
    scrollbar-color: rgba(45, 212, 191, 0.35) transparent;
}

body.light-theme .transcription-container::-webkit-scrollbar-thumb,
body.light-theme .processing-transcription::-webkit-scrollbar-thumb {
    background: rgba(45, 212, 191, 0.4);
}

body.light-theme .transcription-container:hover::-webkit-scrollbar-thumb,
body.light-theme .transcription-container.scrolling::-webkit-scrollbar-thumb,
body.light-theme .processing-transcription:hover::-webkit-scrollbar-thumb,
body.light-theme .processing-transcription.scrolling::-webkit-scrollbar-thumb {
    background: rgba(13, 148, 136, 0.75);
}

.transcription-container.visible,
.processing-transcription.visible {
    display: block;
    animation: fadeInScale 0.3s ease-out;
}

@keyframes fadeInScale {
    from { 
        opacity: 0; 
        transform: scale(0.95);  /* Removed translateX(-50%) which was causing the glitch */
    }
    to { 
        opacity: 1; 
        transform: scale(1);  /* Removed translateX(-50%) */
    }
}

.processing-text {
    color: #0D9488;
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-medium);
    white-space: pre-wrap;
}

.transcription-text {
    color: #0D9488;
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-medium);
    line-height: 1.6;
    word-wrap: break-word;
    white-space: pre-wrap;
    text-align: left;
    overflow-y: auto;
    max-height: inherit;
    scroll-behavior: smooth;
}

.transcription-text h3,
.transcription-text h4 {
    margin: 0 0 var(--space-8);
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-semibold);
}

.transcription-text p {
    margin: 0 0 var(--space-8);
}

.transcription-text ul {
    margin: 0;
    padding-left: var(--space-16);
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--space-8);
}

.transcription-text ul li {
    position: relative;
    padding-left: var(--space-16);
}

.transcription-text ul li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(45, 212, 191, 0.6);
}

body.light-theme .processing-text {
    color: #0D9488;
}

body.light-theme .transcription-text {
    color: #0D9488;
}

/* AI RESPONSE STYLING */
.transcription-container.ai-response {
    border: 2px solid rgba(139, 92, 246, 0.4);
    background: rgba(139, 92, 246, 0.05);
}

.transcription-container.ai-response .transcription-text {
    color: #A855F7;
}

body.light-theme .transcription-container.ai-response {
    border: 2px solid rgba(139, 92, 246, 0.5);
    background: rgba(139, 92, 246, 0.08);
}

body.light-theme .transcription-container.ai-response .transcription-text {
    color: #8B5CF6;
}

/* Add subtle glow animation for AI response */
.transcription-container.ai-response {
    animation: aiResponseGlow 2s ease-in-out infinite alternate;
}

@keyframes aiResponseGlow {
    from {
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    }
    to {
        box-shadow: 0 8px 32px rgba(139, 92, 246, 0.3), 0 0 20px rgba(139, 92, 246, 0.2);
    }
}

body.light-theme .transcription-container.ai-response {
    animation: aiResponseGlowLight 2s ease-in-out infinite alternate;
}

@keyframes aiResponseGlowLight {
    from {
        box-shadow: 0 8px 30px rgba(15, 23, 42, 0.15);
    }
    to {
        box-shadow: 0 8px 30px rgba(139, 92, 246, 0.25), 0 0 15px rgba(139, 92, 246, 0.15);
    }
}

/* VOICE CONTROLS - Fixed at bottom */
.voice-controls {
    position: fixed;  /* Keep fixed */
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-24);
    z-index: 100;
    pointer-events: all;
}

.control-btn {
    all: unset;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-standard);
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--color-white);
}

.control-btn:hover {
    transform: scale(1.05);
}

.mic-btn {
    width: 78px;
    height: 78px;
    background: rgba(var(--color-primary-rgb), 0.1);
    border: 1px solid rgba(var(--color-primary-rgb), 0.2);
    color: var(--color-primary);
}

.stop-btn {
    background: rgba(var(--color-warning-rgb), 0.16);
    border: 1px solid rgba(var(--color-warning-rgb), 0.4);
    color: var(--color-warning);
}

.stop-btn:hover {
    background: rgba(var(--color-warning-rgb), 0.24);
    border-color: rgba(var(--color-warning-rgb), 0.55);
}

.cancel-btn {
    display: none;
    background: rgba(var(--color-danger-rgb), 0.16);
    border: 1px solid rgba(var(--color-danger-rgb), 0.35);
    color: var(--color-danger);
}

.cancel-btn:hover {
    background: rgba(var(--color-danger-rgb), 0.24);
    border-color: rgba(var(--color-danger-rgb), 0.5);
}

.listen-again-btn {
    background: linear-gradient(135deg, rgba(13, 148, 136, 0.95), rgba(20, 184, 166, 0.95));
    border: 1px solid rgba(13, 148, 136, 0.5);
    color: #ECFEFF;
    box-shadow: 0 0 18px rgba(13, 148, 136, 0.35);
}

.listen-again-btn:hover {
    background: linear-gradient(135deg, rgba(13, 148, 136, 1), rgba(16, 185, 129, 1));
    box-shadow: 0 0 22px rgba(13, 148, 136, 0.45);
}

body.light-theme .control-btn {
    background: rgba(15, 23, 42, 0.08);
    border-color: rgba(15, 23, 42, 0.12);
    color: var(--color-slate-900);
}

body.light-theme .mic-btn {
    background: rgba(var(--color-primary-rgb), 0.18);
    border-color: rgba(var(--color-primary-rgb), 0.45);
}

body.light-theme .stop-btn {
    background: rgba(var(--color-warning-rgb), 0.22);
    border-color: rgba(var(--color-warning-rgb), 0.5);
    color: #B45309;
}

body.light-theme .stop-btn:hover {
    background: rgba(var(--color-warning-rgb), 0.3);
    border-color: rgba(var(--color-warning-rgb), 0.6);
}

body.light-theme .cancel-btn {
    display: none;
    background: rgba(var(--color-danger-rgb), 0.22);
    border-color: rgba(var(--color-danger-rgb), 0.45);
    color: #B91C1C;
}

body.light-theme .cancel-btn:hover {
    background: rgba(var(--color-danger-rgb), 0.3);
    border-color: rgba(var(--color-danger-rgb), 0.55);
}

body.light-theme .listen-again-btn {
    background: linear-gradient(135deg, rgba(45, 212, 191, 0.92), rgba(16, 185, 129, 0.92));
    border-color: rgba(13, 148, 136, 0.55);
    color: #065F46;
    box-shadow: 0 0 16px rgba(13, 148, 136, 0.25);
}

body.light-theme .listen-again-btn:hover {
    background: linear-gradient(135deg, rgba(45, 212, 191, 1), rgba(16, 185, 129, 1));
    box-shadow: 0 0 20px rgba(13, 148, 136, 0.35);
}

/* CHAT INTERFACE */
#chat-interface {
    display: none;
    flex-direction: column;
    justify-content: flex-end;
    position: absolute;
    bottom: var(--space-48);
    left: 50%;
    transform: translateX(-50%) scale(0.95);
    width: 50vw;
    height: 70vh;
    max-width: 800px;
    min-width: 400px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-xl);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    overflow: hidden;
    opacity: 0;
    transition: opacity var(--duration-slow) var(--ease-standard), transform var(--duration-slow) var(--ease-standard);
    pointer-events: none;
    z-index: 1002;
}

body.light-theme #chat-interface {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

body.chat-mode #chat-interface {
    opacity: 1;
    transform: translateX(-50%) scale(1);
    pointer-events: all;
    display: flex;
}

body.keyboard-visible #chat-interface {
    height: 100dvh;
}

body.keyboard-visible #chat-messages {
    padding-bottom: calc(var(--space-24) + 140px);
}

body.chat-mode .voice-mode-container {
    display: none;
}

#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-24);
    display: flex;
    flex-direction: column;
    gap: var(--space-16);
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

#chat-messages::-webkit-scrollbar {
    width: 6px;
}

#chat-messages::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

.message {
    padding: var(--space-12) var(--space-16);
    border-radius: var(--radius-lg);
    max-width: 85%;
    font-weight: var(--font-weight-medium);
    word-wrap: break-word;
    font-size: var(--font-size-base);
    line-height: 1.5;
    opacity: 1;
    transition: opacity var(--duration-slow) var(--ease-standard), transform var(--duration-slow) var(--ease-standard);
    position: relative;
}

.message.pending {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
}

.message.assistant {
    background: rgba(255, 255, 255, 0.1);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    white-space: pre-wrap;
    position: relative;
}

.message.user {
    background: var(--color-primary);
    align-self: flex-end;
    color: #0F172A;
    border-bottom-right-radius: 4px;
}

body.light-theme .message.assistant {
    background: rgba(19, 52, 59, 0.06);
}

.message.assistant h2,
.message.assistant h3,
.message.assistant h4 {
    margin: 0 0 var(--space-8);
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
}

.message.assistant p {
    margin: 0 0 var(--space-12);
}

.message.assistant ul {
    margin: 0;
    padding-left: var(--space-16);
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--space-8);
}

.message.assistant ul li {
    position: relative;
    padding-left: var(--space-16);
}

.message.assistant ul li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(var(--color-primary-rgb), 0.7);
}

.message.assistant a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: var(--font-weight-semibold);
}

.message.assistant a:hover {
    text-decoration: underline;
}

.message.assistant code {
    background: rgba(255, 255, 255, 0.12);
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 0.92em;
}

body.light-theme .message.assistant ul li::before {
    background: rgba(var(--color-primary-rgb), 0.55);
}

body.light-theme .message.assistant code {
    background: rgba(15, 23, 42, 0.08);
}

.loader-indicator {
    align-self: flex-start;
    padding: var(--space-12) var(--space-16);
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    gap: var(--space-12);
    transition: opacity var(--duration-normal) var(--ease-standard), transform var(--duration-normal) var(--ease-standard);
}

.loader-indicator.fade-out {
    opacity: 0;
    transform: translateY(-10px);
}

body.light-theme .loader-indicator {
    background: rgba(19, 52, 59, 0.06);
}

.loader-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* INPUT CONTAINER */
#perplexity-input-container {
    padding: var(--space-16) var(--space-24);
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

body.keyboard-visible #perplexity-input-container {
    padding-bottom: calc(var(--space-16) + env(safe-area-inset-bottom));
}

body.light-theme #perplexity-input-container {
    background: rgba(255, 255, 255, 0.5);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.perplexity-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-lg);
    border: 1px solid transparent;
    transition: border-color var(--duration-normal);
}

body.light-theme .perplexity-input-wrapper {
    background: rgba(19, 52, 59, 0.04);
}

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

#perplexity-chat-input {
    flex: 1;
    border: none;
    background: transparent;
    color: inherit;
    font-size: var(--font-size-md);
    font-family: inherit;
    resize: none;
    outline: none;
    height: 48px;
    max-height: 120px;
    line-height: 1.5;
    scrollbar-width: none;
    padding: 12px 80px 12px var(--space-16);
}

#perplexity-chat-input::-webkit-scrollbar {
    display: none;
}

#perplexity-chat-input::placeholder {
    color: var(--color-gray-300);
}

body.light-theme #perplexity-chat-input::placeholder {
    color: rgba(19, 52, 59, 0.5);
}

.input-actions {
    position: absolute;
    right: var(--space-8);
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: var(--space-8);
}

.action-btn {
    all: unset;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease;
    color: var(--color-primary);
}

.action-btn:hover {
    background-color: rgba(var(--color-primary-rgb), 0.1);
}

.action-btn.send-btn {
    background-color: var(--color-primary);
    color: var(--color-slate-900);
}

.action-btn.info-btn {
    background-color: rgba(var(--color-primary-rgb), 0.15);
    color: var(--color-primary);
    animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(var(--color-primary-rgb), 0.5);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 20px rgba(var(--color-primary-rgb), 0.8);
        transform: scale(1.05);
    }
}

/* Train Info Icon Styles */
.train-info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #33FFFF 0%, #0099CC 100%);
    border-radius: 50%;
    color: #1a1a2e;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(51, 255, 255, 0.3);
    border: 2px solid rgba(51, 255, 255, 0.4);
    position: relative;
    text-decoration: none;
    z-index: 102;
    opacity: 1;
    visibility: visible;
}

.train-info-icon:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 16px rgba(51, 255, 255, 0.5);
    background: linear-gradient(135deg, #66FFFF 0%, #33CCFF 100%);
    border-color: rgba(51, 255, 255, 0.8);
}

.train-info-icon:active {
    transform: scale(0.95);
    box-shadow: 0 2px 4px rgba(51, 255, 255, 0.4);
}

/* Train Info Popup Styles */
.train-info-popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.train-info-popup.show {
    opacity: 1;
    visibility: visible;
    display: flex !important;
}

.train-info-popup-content {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border: 1px solid var(--color-primary);
    border-radius: 12px;
    max-width: 90vw;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.train-info-popup.show .train-info-popup-content {
    transform: scale(1);
}

.train-info-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: rgba(51, 255, 255, 0.1);
    border-bottom: 1px solid rgba(51, 255, 255, 0.2);
}

.train-info-header h3 {
    margin: 0;
    color: var(--color-primary);
    font-size: 18px;
    font-weight: 600;
}

.close-popup {
    background: none;
    border: none;
    color: var(--color-primary);
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: background 0.2s ease;
    z-index: 10000;
    position: relative;
    min-width: 32px;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-popup:hover {
    background: rgba(51, 255, 255, 0.2);
    transform: scale(1.1);
}

.close-popup:active {
    transform: scale(0.95);
}

.close-detailed-modal {
    background: none;
    border: none;
    color: var(--color-primary);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s ease;
    z-index: 1000;
    position: relative;
    min-width: 40px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.train-info-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.train-info-body::-webkit-scrollbar {
    width: 6px;
}

.train-info-body::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.train-info-body::-webkit-scrollbar-thumb {
    background: var(--color-primary);
    border-radius: 3px;
}

.train-info-card {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border: 1px solid rgba(51, 255, 255, 0.3);
    border-radius: 8px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.train-info-card:hover {
    border-color: var(--color-primary);
    box-shadow: 0 4px 20px rgba(51, 255, 255, 0.2);
    transform: translateY(-2px);
}

.train-info-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.click-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(51, 255, 255, 0.2);
    transition: all 0.2s ease;
    font-weight: bold;
}

.click-indicator:hover {
    background: rgba(51, 255, 255, 0.4);
    transform: scale(1.1);
}

.train-number {
    background: var(--color-primary);
    color: #1a1a2e;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 12px;
}

.train-name {
    color: var(--color-primary);
    font-weight: 600;
    font-size: 14px;
    flex: 1;
    margin-left: 8px;
}

.train-info-route {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(51, 255, 255, 0.1);
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 10px;
}

.train-station {
    text-align: center;
    flex: 1;
}

.station-name {
    font-weight: bold;
    color: #ffffff;
    font-size: 14px;
    margin-bottom: 2px;
}

.station-time {
    color: #888;
    font-size: 11px;
    font-weight: normal;
    margin-top: 2px;
    opacity: 0.9;
}

.route-arrow {
    color: var(--color-primary);
    font-size: 18px;
    margin: 0 15px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    min-width: 20px;
}

/* Time info section styling */
.time-info {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    padding: 8px 12px;
    margin: 8px 0;
    border: 1px solid rgba(51, 255, 255, 0.2);
}

.train-info-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    font-size: 11px;
}

.detail-label {
    color: #66B2FF;
}

.detail-value {
    color: #ffffff;
    text-align: right;
}

@media (max-width: 768px) {
    .train-info-popup-content {
        max-width: 95vw;
        max-height: 85vh;
    }
    
    .train-info-body {
        max-height: 65vh;
    }

    .train-info-details {
        grid-template-columns: 1fr;
        gap: 4px;
    }
    
    .detail-value {
        text-align: left;
        margin-top: 2px;
    }
}

/* MOBILE RESPONSIVE */
@media (max-width: 768px) {
    #background-canvas {
        height: 50vh;  /* Keep consistent proportions on mobile */
    }

    .app-header {
        padding: var(--space-12) var(--space-16);
    }

    .header-btn {
        height: 40px;
        padding: 0 var(--space-12);
    }

    .account-btn span {
        display: none;
    }

    .voice-mode-container {
        top: 50vh;  /* Start right after particles */
        height: 50vh;
        padding-top: 60px;  /* Significantly increased from 50px for more space on mobile */
    }

    .voice-status-container {
        margin-bottom: 30px;  /* Significantly increased from var(--space-20) for more space */
    }

    .transcription-container,
    .processing-transcription {
        margin-bottom: 24px;  /* Significantly increased from var(--space-16) for more spacing */
        padding: var(--space-12) var(--space-16);  /* Slightly smaller padding on mobile */
    }

    .voice-controls {
        bottom: 40px;
    }

    body.chat-mode #chat-interface {
        position: fixed !important;
        width: 100vw !important;
        height: 100dvh !important;
        top: 0 !important;
        left: 0 !important;
        bottom: unset !important;
        transform: none !important;
        border-radius: 0 !important;
        min-width: unset;
        padding-top: 96px;
        padding-bottom: env(safe-area-inset-bottom);
    }
}

.route-timeline {
    position: relative;
    padding-left: 32px;
}

.timeline-node {
    position: relative;
    padding: 16px 0;
    display: flex; /* Use flexbox for alignment */
    align-items: center; /* Vertically center content */
}

.node-connector {
    position: absolute;
    left: -26px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: rgba(255, 255, 255, 0.1);
}

.timeline-node:first-child .node-connector {
    top: 50%;
}

.timeline-node:last-child .node-connector {
    bottom: 50%;
}

.timeline-node.completed .node-connector {
    background: #2DD4BF;
}

.node-marker {
    position: absolute;
    left: -32px;
    /* top is no longer needed with flexbox */
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    z-index: 1; /* Ensure marker is above connector */
}

.timeline-node.completed .node-marker {
    background: #2DD4BF;
    border-color: #2DD4BF;
}

.timeline-node.active .node-marker {
    width: 18px;
    height: 18px;
    left: -34px;
    background: #22c55e;
    border-color: #22c55e;
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.6);
}

.live-indicator {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: #22c55e;
    animation: ripple 1.5s infinite;
}

@keyframes ripple {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(1.5); opacity: 0; }
}

.node-content {
    display: flex;
    justify-content: space-between;
    align-items: start;
    width: 100%;
}

.train-status-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.train-status-overlay.visible {
    display: flex;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.status-panel {
    width: 90%;
    max-width: 650px;
    max-height: 85vh;
    background: linear-gradient(145deg, rgba(25, 25, 35, 0.98), rgba(20, 20, 30, 0.98));
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease;
}

body.light-theme .status-panel {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(245, 245, 250, 0.98));
}

@keyframes slideUp {
    from { transform: translateY(30px) scale(0.95); }
    to { transform: translateY(0) scale(1); }
}

.panel-header {
    padding: 24px;
    background: linear-gradient(135deg, rgba(45, 212, 191, 0.15), rgba(45, 212, 191, 0.05));
    border-bottom: 1px solid rgba(45, 212, 191, 0.25);
}

.header-main {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.train-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.train-title {
    font-size: 18px;
    font-weight: 600;
    color: #fff;
    margin: 0;
}

body.light-theme .train-title {
    color: #1a1a2e;
}

.train-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.status-badge.on-time {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.15), rgba(34, 197, 94, 0.08));
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.status-badge.delayed {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(239, 68, 68, 0.08));
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.status-badge.early {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(59, 130, 246, 0.08));
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.status-icon {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.status-badge.on-time .status-icon {
    animation: pulse 2s infinite;
}

.close-panel {
    all: unset;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.close-panel:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

.route-label {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 16px;
}

body.light-theme .route-label {
    color: rgba(26, 26, 46, 0.6);
}

.view-selector {
    display: flex;
    gap: 12px;
}

.view-btn {
    all: unset;
    padding: 8px 16px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

body.light-theme .view-btn {
    background: rgba(26, 26, 46, 0.05);
    color: rgba(26, 26, 46, 0.6);
}

.view-btn.active {
    background: #2DD4BF;
    color: #0a0a0a;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse 2s infinite;
}

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

.panel-body {
    padding: 24px;
    max-height: calc(85vh - 160px);
    overflow-y: auto;
}

.current-location-card {
    display: flex;
    gap: 16px;
    padding: 16px;
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.15), rgba(34, 197, 94, 0.05));
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: 12px;
    margin-bottom: 24px;
}

.location-icon {
    color: #22c55e;
}

.location-details {
    flex: 1;
}

.location-status {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 4px;
}

body.light-theme .location-status {
    color: rgba(26, 26, 46, 0.6);
}

.location-station {
    font-size: 16px;
    font-weight: 600;
    color: #22c55e;
    margin-bottom: 4px;
}

.location-time {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
}

body.light-theme .location-time {
    color: rgba(26, 26, 46, 0.8);
}

.delay-indicator {
    padding: 2px 6px;
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border-radius: 4px;
    font-size: 12px;
    margin-left: 8px;
}

.route-timeline {
    position: relative;
    padding-left: 32px;
}

.timeline-node {
    position: relative;
    padding: 16px 0;
    display: flex; /* Use flexbox for alignment */
    align-items: center; /* Vertically center content */
}

.node-connector {
    position: absolute;
    left: -26px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: rgba(255, 255, 255, 0.1);
}

.timeline-node:first-child .node-connector {
    top: 50%;
}

.timeline-node:last-child .node-connector {
    bottom: 50%;
}

.timeline-node.completed .node-connector {
    background: #2DD4BF;
}

.node-marker {
    position: absolute;
    left: -32px;
    /* top is no longer needed with flexbox */
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    z-index: 1; /* Ensure marker is above connector */
}

.timeline-node.completed .node-marker {
    background: #2DD4BF;
    border-color: #2DD4BF;
}

.timeline-node.active .node-marker {
    width: 18px;
    height: 18px;
    left: -34px;
    background: #22c55e;
    border-color: #22c55e;
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.6);
}

.live-indicator {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: #22c55e;
    animation: ripple 1.5s infinite;
}

@keyframes ripple {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(1.5); opacity: 0; }
}

.node-content {
    display: flex;
    justify-content: space-between;
    align-items: start;
    width: 100%;
}

.station-label {
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    margin-bottom: 4px;
}

body.light-theme .station-label {
    color: #1a1a2e;
}

.platform-tag {
    padding: 2px 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
}

body.light-theme .platform-tag {
    background: rgba(26, 26, 46, 0.1);
    color: rgba(26, 26, 46, 0.7);
}

.node-timing {
    text-align: right;
    min-width: 100px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.time-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 4px 8px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    border-left: 2px solid transparent;
}

body.light-theme .time-row {
    background: rgba(26, 26, 46, 0.03);
}

.time-row.arrival {
    border-left-color: #10b981;
}

.time-row.departure {
    border-left-color: #f59e0b;
}

.time-type {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    min-width: 22px;
    text-align: left;
}

body.light-theme .time-type {
    color: rgba(26, 26, 46, 0.5);
}

.time-val {
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.95);
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
    min-width: 52px;
    text-align: center;
}

body.light-theme .time-val {
    color: rgba(26, 26, 46, 0.95);
    background: rgba(26, 26, 46, 0.05);
}

.delay-indicator {
    padding: 2px 8px;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(239, 68, 68, 0.08));
    color: #ef4444;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border: 1px solid rgba(239, 68, 68, 0.2);
    margin-left: 6px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.delay-indicator::before {
    content: '⚠';
    font-size: 8px;
}

.status-tag {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
}

.status-tag.on-time {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.halt-info {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.4);
}

body.light-theme .halt-info {
    color: rgba(26, 26, 46, 0.4);
}

.schedule-view {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.schedule-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

body.light-theme .schedule-row {
    background: rgba(0, 0, 0, 0.05);
}

.schedule-station {
    display: flex;
    align-items: center;
    gap: 8px;
}

.station-name {
    font-size: 14px;
    font-weight: 500;
    color: #fff;
}

body.light-theme .station-name {
    color: #1a1a2e;
}

/* Light theme fixes for train status modal */
body.light-theme .node-connector {
    background: rgba(26, 26, 46, 0.1);
}

body.light-theme .node-marker {
    background: rgba(26, 26, 46, 0.1);
    border-color: rgba(26, 26, 46, 0.2);
}

body.light-theme .close-panel {
    background: rgba(26, 26, 46, 0.1);
    color: #1a1a2e;
}

body.light-theme .close-panel:hover {
    background: rgba(26, 26, 46, 0.2);
}

/* Mobile responsive styles for train status modal */
@media (max-width: 768px) {
    .status-panel {
        width: 95vw;
        max-width: none;
        margin: 10px;
    }

    .train-title {
        font-size: 16px;
    }

    .status-badge {
        font-size: 10px;
        padding: 3px 8px;
    }

    .route-label {
        font-size: 13px;
    }

    .panel-body {
        padding: 16px;
        max-height: calc(90vh - 140px);
    }

    .timeline-node {
        padding: 12px 0;
    }

    .node-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .node-timing {
        align-self: flex-end;
        min-width: 90px;
        gap: 4px;
    }

    .time-row {
        gap: 6px;
        padding: 3px 6px;
    }

    .time-type {
        min-width: 20px;
        font-size: 9px;
    }

    .time-val {
        min-width: 48px;
        font-size: 12px;
        padding: 1px 4px;
    }

    .delay-indicator {
        padding: 1px 6px;
        font-size: 9px;
        margin-left: 4px;
    }

    .station-label {
        font-size: 13px;
    }

    .route-timeline {
        padding-left: 28px;
    }

    .node-marker {
        left: -28px;
        width: 12px;
        height: 12px;
    }

    .timeline-node.active .node-marker {
        width: 16px;
        height: 16px;
        left: -30px;
    }

    .node-connector {
        left: -22px;
    }
}

.schedule-times {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    gap: 8px;
}

body.light-theme .schedule-times {
    color: rgba(26, 26, 46, 0.8);
}

.halt-duration {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
}

body.light-theme .halt-duration {
    color: rgba(26, 26, 46, 0.5);
}

/* Make train results clickable */
.message.assistant h3,
.transcription-text h3 {
    cursor: pointer; /* Change cursor to pointer to indicate clickable */
    padding: 8px;
    margin: -8px -8px var(--space-16) -8px; /* Added margin-bottom */
    border-radius: 8px;
    transition: all 0.2s ease;
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none; /* Prevent text selection */
}

.message.assistant h3:hover,
.transcription-text h3:hover {
    background-color: rgba(51, 255, 255, 0.05); /* Subtle hover background */
    transform: translateY(-1px); /* Slight lift effect */
    box-shadow: 0 2px 8px rgba(51, 255, 255, 0.1); /* Subtle glow */
}

.message.assistant h3:active,
.transcription-text h3:active {
    transform: translateY(0); /* Press down effect */
    background-color: rgba(51, 255, 255, 0.1); /* Slightly stronger active state */
}

/* Loading state for train headers */
.message.assistant h3.loading,
.transcription-text h3.loading {
    opacity: 0.7;
    pointer-events: none;
    background-color: rgba(51, 255, 255, 0.05);
}

.message.assistant h3.loading::after,
.transcription-text h3.loading::after {
    content: '⟳';
    animation: spin 1s linear infinite;
    background-color: rgba(51, 255, 255, 0.3);
}

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

/* Add a small indicator to show it's clickable */
.message.assistant h3::after,
.transcription-text h3::after {
    content: '→';
    color: #1a1a2e;
    background: var(--color-primary);
    font-weight: bold;
    font-size: 1.2em; /* Larger arrow */
    margin-left: 12px;
    opacity: 1; /* Always visible */
    transition: all 0.2s ease;
    border-radius: 50%; /* Make it circular */
    width: 28px; /* Fixed width */
    height: 28px; /* Fixed height */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer; /* Add pointer cursor only to the button */
    flex-shrink: 0; /* Prevent shrinking */
}

.message.assistant h3:hover::after,
.transcription-text h3:hover::after {
    background: #27a895; /* Darker shade on hover */
    transform: scale(1.1); /* Scale up on hover */
}

body.light-theme .message.assistant h3:hover,
body.light-theme .transcription-text h3:hover {
    background-color: transparent; /* Remove hover background */
    box-shadow: none; /* Remove hover shadow */
}

body.light-theme .message.assistant h3::after,
body.light-theme .transcription-text h3::after {
    color: white;
    background: var(--color-primary);
    border: 1px solid rgba(45, 212, 191, 0.3);
}

.message.assistant h3:hover {
    background: transparent; /* Remove hover background */
}

    .header-main {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 8px;
    }

    .train-info {
        display: flex;
        flex-direction: column;
        gap: 6px;
    }

    .train-title {
        font-size: 18px;
        font-weight: 600;
        color: #fff;
        margin: 0;
    }

    body.light-theme .train-title {
        color: #1a1a2e;
    }

    .train-status {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .status-badge {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        padding: 4px 10px;
        border-radius: 12px;
        font-size: 11px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.3px;
    }

    .status-badge.on-time {
        background: linear-gradient(135deg, rgba(34, 197, 94, 0.15), rgba(34, 197, 94, 0.08));
        color: #22c55e;
        border: 1px solid rgba(34, 197, 94, 0.3);
    }

    .status-badge.delayed {
        background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(239, 68, 68, 0.08));
        color: #ef4444;
        border: 1px solid rgba(239, 68, 68, 0.3);
    }

    .status-badge.early {
        background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(59, 130, 246, 0.08));
        color: #3b82f6;
        border: 1px solid rgba(59, 130, 246, 0.3);
    }

    .status-icon {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: currentColor;
    }

    .status-badge.on-time .status-icon {
        animation: pulse 2s infinite;
    }

    .close-panel {
        all: unset;
        width: 32px;
        height: 32px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.1);
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all 0.2s;
    }

    .close-panel:hover {
        background: rgba(255, 255, 255, 0.2);
        transform: rotate(90deg);
    }

    .route-label {
        font-size: 14px;
        color: rgba(255, 255, 255, 0.6);
        margin-bottom: 16px;
    }

    body.light-theme .route-label {
        color: rgba(26, 26, 46, 0.6);
    }

    .view-selector {
        display: flex;
        gap: 12px;
    }

    .view-btn {
        all: unset;
        padding: 8px 16px;
        border-radius: 10px;
        background: rgba(255, 255, 255, 0.05);
        color: rgba(255, 255, 255, 0.6);
        font-size: 14px;
        cursor: pointer;
        transition: all 0.2s;
        display: flex;
        align-items: center;
        gap: 8px;
    }

    body.light-theme .view-btn {
        background: rgba(26, 26, 46, 0.05);
        color: rgba(26, 26, 46, 0.6);
    }

    .view-btn.active {
        background: #2DD4BF;
        color: #0a0a0a;
    }

    .pulse-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: currentColor;
        animation: pulse 2s infinite;
    }

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

    .panel-body {
        padding: 24px;
        max-height: calc(85vh - 160px);
        overflow-y: auto;
    }

    .current-location-card {
        display: flex;
        gap: 16px;
        padding: 16px;
        background: linear-gradient(135deg, rgba(34, 197, 94, 0.15), rgba(34, 197, 94, 0.05));
        border: 1px solid rgba(34, 197, 94, 0.3);
        border-radius: 12px;
        margin-bottom: 24px;
    }

    .location-icon {
        color: #22c55e;
    }

    .location-details {
        flex: 1;
    }

    .location-status {
        font-size: 12px;
        color: rgba(255, 255, 255, 0.6);
        margin-bottom: 4px;
    }

    body.light-theme .location-status {
        color: rgba(26, 26, 46, 0.6);
    }

    .location-station {
        font-size: 16px;
        font-weight: 600;
        color: #22c55e;
        margin-bottom: 4px;
    }

    .location-time {
        font-size: 14px;
        color: rgba(255, 255, 255, 0.8);
    }

    body.light-theme .location-time {
        color: rgba(26, 26, 46, 0.8);
    }

    .delay-indicator {
        padding: 2px 6px;
        background: rgba(239, 68, 68, 0.15);
        color: #ef4444;
        border-radius: 4px;
        font-size: 12px;
        margin-left: 8px;
    }

    .route-timeline {
        position: relative;
        padding-left: 32px;
    }

    .timeline-node {
        position: relative;
        padding: 16px 0;
        display: flex; /* Use flexbox for alignment */
        align-items: center; /* Vertically center content */
    }

    .node-connector {
        position: absolute;
        left: -26px;
        top: 0;
        bottom: 0;
        width: 2px;
        background: rgba(255, 255, 255, 0.1);
    }

    .timeline-node:first-child .node-connector {
        top: 50%;
    }

    .timeline-node:last-child .node-connector {
        bottom: 50%;
    }

    .timeline-node.completed .node-connector {
        background: #2DD4BF;
    }

    .node-marker {
        position: absolute;
        left: -32px;
        /* top is no longer needed with flexbox */
        width: 14px;
        height: 14px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.1);
        border: 2px solid rgba(255, 255, 255, 0.2);
        z-index: 1; /* Ensure marker is above connector */
    }

    .timeline-node.completed .node-marker {
        background: #2DD4BF;
        border-color: #2DD4BF;
    }

    .timeline-node.active .node-marker {
        width: 18px;
        height: 18px;
        left: -34px;
        background: #22c55e;
        border-color: #22c55e;
        box-shadow: 0 0 20px rgba(34, 197, 94, 0.6);
    }

    .live-indicator {
        position: absolute;
        width: 100%;
        height: 100%;
        border-radius: 50%;
        background: #22c55e;
        animation: ripple 1.5s infinite;
    }

    @keyframes ripple {
        0% { transform: scale(1); opacity: 1; }
        100% { transform: scale(1.5); opacity: 0; }
    }

    .node-content {
        display: flex;
        justify-content: space-between;
        align-items: start;
        width: 100%;
    }

    .station-label {
        font-size: 14px;
        font-weight: 500;
        color: #fff;
        margin-bottom: 4px;
    }

    body.light-theme .station-label {
        color: #1a1a2e;
    }

    .platform-tag {
        padding: 2px 6px;
        background: rgba(255, 255, 255, 0.1);
        border-radius: 4px;
        font-size: 11px;
        color: rgba(255, 255, 255, 0.7);
    }

    body.light-theme .platform-tag {
        background: rgba(26, 26, 46, 0.1);
        color: rgba(26, 26, 46, 0.7);
    }

    .node-timing {
        text-align: right;
        min-width: 100px;
        display: flex;
        flex-direction: column;
        gap: 6px;
    }

    .time-row {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: 8px;
        padding: 4px 8px;
        background: rgba(255, 255, 255, 0.03);
        border-radius: 6px;
        border-left: 2px solid transparent;
    }

    body.light-theme .time-row {
        background: rgba(26, 26, 46, 0.03);
    }

    .time-row.arrival {
        border-left-color: #10b981;
    }

    .time-row.departure {
        border-left-color: #f59e0b;
    }

    .time-type {
        font-size: 10px;
        color: rgba(255, 255, 255, 0.5);
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        min-width: 22px;
        text-align: left;
    }

    body.light-theme .time-type {
        color: rgba(26, 26, 46, 0.5);
    }

    .time-val {
        font-size: 13px;
        font-weight: 600;
        color: rgba(255, 255, 255, 0.95);
        font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
        background: rgba(255, 255, 255, 0.05);
        padding: 2px 6px;
        border-radius: 4px;
        min-width: 52px;
        text-align: center;
    }

    body.light-theme .time-val {
        color: rgba(26, 26, 46, 0.95);
        background: rgba(26, 26, 46, 0.05);
    }

    .delay-indicator {
        padding: 2px 8px;
        background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(239, 68, 68, 0.08));
        color: #ef4444;
        border-radius: 8px;
        font-size: 10px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.3px;
        border: 1px solid rgba(239, 68, 68, 0.2);
        margin-left: 6px;
        display: inline-flex;
        align-items: center;
        gap: 3px;
    }

    .delay-indicator::before {
        content: '⚠';
        font-size: 8px;
    }

    .status-tag {
        padding: 2px 6px;
        border-radius: 4px;
        font-size: 11px;
    }

    .status-tag.on-time {
        background: rgba(34, 197, 94, 0.15);
        color: #22c55e;
    }

    .halt-info {
        font-size: 10px;
        color: rgba(255, 255, 255, 0.4);
    }

    body.light-theme .halt-info {
        color: rgba(26, 26, 46, 0.4);
    }

    .schedule-view {
        display: flex;
        flex-direction: column;
        gap: 16px;
    }

    .schedule-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 12px;
        background: rgba(255, 255, 255, 0.05);
        border-radius: 8px;
    }

    body.light-theme .schedule-row {
        background: rgba(0, 0, 0, 0.05);
    }

    .schedule-station {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .station-name {
        font-size: 14px;
        font-weight: 500;
        color: #fff;
    }

    body.light-theme .station-name {
        color: #1a1a2e;
    }

    /* Light theme fixes for train status modal */
    body.light-theme .node-connector {
        background: rgba(26, 26, 46, 0.1);
    }

    body.light-theme .node-marker {
        background: rgba(26, 26, 46, 0.1);
        border-color: rgba(26, 26, 46, 0.2);
    }

    body.light-theme .close-panel {
        background: rgba(26, 26, 46, 0.1);
        color: #1a1a2e;
    }

    body.light-theme .close-panel:hover {
        background: rgba(26, 26, 46, 0.2);
    }

    /* Mobile responsive styles for train status modal */
    @media (max-width: 768px) {
        .status-panel {
            width: 95vw;
            max-width: none;
            margin: 10px;
        }

        .train-title {
            font-size: 16px;
        }

        .status-badge {
            font-size: 10px;
            padding: 3px 8px;
        }

        .route-label {
            font-size: 13px;
        }

        .panel-body {
            padding: 16px;
            max-height: calc(90vh - 140px);
        }

        .timeline-node {
            padding: 12px 0;
        }

        .node-content {
            flex-direction: column;
            align-items: flex-start;
            gap: 8px;
        }

        .node-timing {
            align-self: flex-end;
            min-width: 90px;
            gap: 4px;
        }

        .time-row {
            gap: 6px;
            padding: 3px 6px;
        }

        .time-type {
            min-width: 20px;
            font-size: 9px;
        }

        .time-val {
            min-width: 48px;
            font-size: 12px;
            padding: 1px 4px;
        }

        .delay-indicator {
            padding: 1px 6px;
            font-size: 9px;
            margin-left: 4px;
        }

        .station-label {
            font-size: 13px;
        }

        .route-timeline {
            padding-left: 28px;
        }

        .node-marker {
            left: -28px;
            width: 12px;
            height: 12px;
        }

        .timeline-node.active .node-marker {
            width: 16px;
            height: 16px;
            left: -30px;
        }

        .node-connector {
            left: -22px;
        }
    }

    .schedule-times {
        font-size: 14px;
        color: rgba(255, 255, 255, 0.8);
        display: flex;
        align-items: center;
        gap: 8px;
    }

    body.light-theme .schedule-times {
        color: rgba(26, 26, 46, 0.8);
    }

    .halt-duration {
        font-size: 12px;
        color: rgba(255, 255, 255, 0.5);
    }

    body.light-theme .halt-duration {
        color: rgba(26, 26, 46, 0.5);
    }

    /* Make train results clickable */
    .message.assistant h3,
    .transcription-text h3 {
        cursor: pointer; /* Change cursor to pointer to indicate clickable */
        padding: 8px;
        margin: -8px -8px var(--space-16) -8px; /* Added margin-bottom */
        border-radius: 8px;
        transition: all 0.2s ease;
        position: relative;
        display: flex;
        justify-content: space-between;
        align-items: center;
        user-select: none; /* Prevent text selection */
    }

    .message.assistant h3:hover,
    .transcription-text h3:hover {
        background-color: rgba(51, 255, 255, 0.05); /* Subtle hover background */
        transform: translateY(-1px); /* Slight lift effect */
        box-shadow: 0 2px 8px rgba(51, 255, 255, 0.1); /* Subtle glow */
    }

    .message.assistant h3:active,
    .transcription-text h3:active {
        transform: translateY(0); /* Press down effect */
        background-color: rgba(51, 255, 255, 0.1); /* Slightly stronger active state */
    }

    /* Loading state for train headers on mobile */
    .message.assistant h3.loading,
    .transcription-text h3.loading {
        opacity: 0.7;
        pointer-events: none;
        background-color: rgba(51, 255, 255, 0.05);
    }

    .message.assistant h3.loading::after,
    .transcription-text h3.loading::after {
        content: '⟳';
        animation: spin 1s linear infinite;
        background-color: rgba(51, 255, 255, 0.3);
    }

    /* Add a small indicator to show it's clickable */
    .message.assistant h3::after,
    .transcription-text h3::after {
        content: '→';
        color: #1a1a2e;
        background: var(--color-primary);
        font-weight: bold;
        font-size: 1.2em; /* Larger arrow */
        margin-left: 12px;
        opacity: 1; /* Always visible */
        transition: all 0.2s ease;
        border-radius: 50%; /* Make it circular */
        width: 28px; /* Fixed width */
        height: 28px; /* Fixed height */
        display: inline-flex;
        align-items: center;
        justify-content: center;
        cursor: pointer; /* Add pointer cursor only to the button */
        flex-shrink: 0; /* Prevent shrinking */
    }

    .message.assistant h3:hover::after,
    .transcription-text h3:hover::after {
        background: #27a895; /* Darker shade on hover */
        transform: scale(1.1); /* Scale up on hover */
    }

    body.light-theme .message.assistant h3:hover,
    body.light-theme .transcription-text h3:hover {
        background-color: transparent; /* Remove hover background */
        box-shadow: none; /* Remove hover shadow */
    }

    body.light-theme .message.assistant h3::after,
    body.light-theme .transcription-text h3::after {
        color: white;
        background: var(--color-primary);
        border: 1px solid rgba(45, 212, 191, 0.3);
    }

    .message.assistant h3:hover {
        background: transparent; /* Remove hover background */
    }
/* Mobile responsive styles for train info icons */
@media (max-width: 480px) {
    .train-info-icon {
        font-size: 14px;
        padding: 1px 3px;
    }
}

/* Detailed Train Modal Styles */
.detailed-train-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(8px);
    z-index: 15000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

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

.detailed-train-modal-content {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border: 2px solid var(--color-primary);
    border-radius: 16px;
    max-width: 90vw;
    max-height: 90vh;
    width: 100%;
    max-width: 800px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.detailed-train-modal.show .detailed-train-modal-content {
    transform: scale(1);
}

.detailed-train-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    background: rgba(51, 255, 255, 0.1);
    border-bottom: 1px solid rgba(51, 255, 255, 0.3);
}

.detailed-train-header h2 {
    margin: 0;
    color: var(--color-primary);
    font-size: 20px;
    font-weight: 600;
}

.close-detailed-modal:hover {
    background: rgba(51, 255, 255, 0.2);
}

.detailed-train-body {
    padding: 24px;
    max-height: 70vh;
    overflow-y: auto;
}

.route-section {
    margin-bottom: 24px;
    padding: 20px;
    background: rgba(51, 255, 255, 0.05);
    border-radius: 12px;
    border: 1px solid rgba(51, 255, 255, 0.2);
}

.route-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.station-info {
    text-align: center;
    flex: 1;
}

.station-info h3 {
    margin: 0 0 8px 0;
    color: #ffffff;
    font-size: 18px;
    font-weight: 600;
}

.station-info .time {
    margin: 0 0 4px 0;
    color: var(--color-primary);
    font-size: 16px;
    font-weight: 600;
}

.station-info .label {
    margin: 0;
    color: #888;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.route-arrow {
    margin: 0 20px;
    color: var(--color-primary);
}

.duration {
    text-align: center;
    color: #888;
    font-size: 14px;
    margin: 0;
}

.train-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
    padding: 16px;
    background: rgba(51, 255, 255, 0.05);
    border-radius: 8px;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.detail-label {
    color: #66B2FF;
    font-size: 14px;
    font-weight: 500;
}

.detail-value {
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
}

.tracking-section {
    border-top: 1px solid rgba(51, 255, 255, 0.2);
    padding-top: 20px;
}

.tracking-toggle {
    display: flex;
    margin-bottom: 20px;
    background: rgba(51, 255, 255, 0.1);
    border-radius: 8px;
    padding: 4px;
}

.tracking-btn {
    flex: 1;
    padding: 12px 20px;
    background: transparent;
    color: #66B2FF;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tracking-btn.active {
    background: var(--color-primary);
    color: #1a1a2e;
}

.tracking-content {
    min-height: 300px;
    max-height: 400px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 16px;
}

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #888;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid rgba(51, 255, 255, 0.3);
    border-top: 2px solid var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 12px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@media (max-width: 768px) {
    .detailed-train-modal-content {
        max-width: 95vw;
        max-height: 95vh;
    }
    
    .detailed-train-header {
        padding: 16px 20px;
    }
    
    .detailed-train-body {
        padding: 20px;
    }
    
    .route-info {
        flex-direction: column;
        gap: 20px;
    }
    
    .route-arrow {
        
        margin: 10px 0;
    }
    
    .train-details-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}
