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

body {
    font-family: 'Courier New', 'Monaco', 'Lucida Console', monospace;
    background-color: #000000;
    color: #00ff00;
    height: 100vh;
}

/* Only hide overflow when in terminal context */
body:has(.terminal-container) {
    overflow: hidden;
}

/* Terminal Container */
.terminal-container {
    background-color: #000000;
    color: #00ff00;
    font-size: 16px;
    line-height: 1.4;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh; /* Use dynamic viewport height for better mobile support */
    overflow: hidden;
    position: relative;
    contain: layout style paint; /* CSS containment for better performance */
}

/* Terminal Header */
.terminal-header {
    background-color: #e0e0e0;
    color: #000000;
    padding: 5px 15px;
    font-size: 12px;
    border-bottom: 1px solid #333333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0; /* Prevent header from shrinking */
}

.terminal-title {
    font-weight: bold;
}

.terminal-status {
    font-size: 0.9em;
    color: #000;
}

.user-activity {
    font-size: 1em;
    color: #000;
    margin-top: 5px;
    border-top: 1px solid #999;
    padding-top: 5px;
}

.user-last-seen {
    font-size: 1.1em;
    color: #000;
    font-weight: bold;
    display: block;
    margin-top: 2px;
}

.user-last-message {
    font-size: 1.1em;
    color: #000;
    font-weight: bold;
    display: block;
    margin-top: 2px;
}

.user-status {
    margin-bottom: 3px;
}

/* Messages Area */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 10px 15px;
    background-color: #000000;
    scrollbar-width: thin;
    scrollbar-color: #333333 #000000;
    contain: layout style paint; /* CSS containment for better performance */
    will-change: scroll-position; /* Optimize for scrolling */
    position: relative;
    z-index: 1;
}

.messages-container::-webkit-scrollbar {
    width: 8px;
}

.messages-container::-webkit-scrollbar-track {
    background: #000000;
}

/* Enhanced URL Styles */
.enhanced-link {
    color: #00ccff;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 6px;
    background-color: rgba(0, 204, 255, 0.1);
    border: 1px solid rgba(0, 204, 255, 0.3);
    transition: all 0.2s ease;
    margin: 2px 4px;
    font-size: 0.9em;
    max-width: 300px;
    vertical-align: middle;
}

.enhanced-link:hover {
    background-color: rgba(0, 204, 255, 0.2);
    border-color: rgba(0, 204, 255, 0.5);
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 204, 255, 0.2);
}

.enhanced-link.secure {
    border-color: rgba(0, 255, 0, 0.3);
    background-color: rgba(0, 255, 0, 0.1);
}

.enhanced-link.secure:hover {
    border-color: rgba(0, 255, 0, 0.5);
    background-color: rgba(0, 255, 0, 0.2);
    box-shadow: 0 2px 4px rgba(0, 255, 0, 0.2);
}

.enhanced-link.insecure {
    border-color: rgba(255, 165, 0, 0.3);
    background-color: rgba(255, 165, 0, 0.1);
    color: #ffaa00;
}

.enhanced-link.insecure:hover {
    border-color: rgba(255, 165, 0, 0.5);
    background-color: rgba(255, 165, 0, 0.2);
    box-shadow: 0 2px 4px rgba(255, 165, 0, 0.2);
}

/* Platform-specific styling */
.enhanced-link.platform-youtube {
    border-color: rgba(255, 0, 0, 0.3);
    background-color: rgba(255, 0, 0, 0.1);
    color: #ff6b6b;
}

.enhanced-link.platform-youtube:hover {
    background-color: rgba(255, 0, 0, 0.2);
    box-shadow: 0 2px 4px rgba(255, 0, 0, 0.2);
}

.enhanced-link.platform-spotify {
    border-color: rgba(30, 215, 96, 0.3);
    background-color: rgba(30, 215, 96, 0.1);
    color: #1ed760;
}

.enhanced-link.platform-spotify:hover {
    background-color: rgba(30, 215, 96, 0.2);
    box-shadow: 0 2px 4px rgba(30, 215, 96, 0.2);
}

.enhanced-link.platform-github {
    border-color: rgba(240, 246, 252, 0.3);
    background-color: rgba(240, 246, 252, 0.1);
    color: #f0f6fc;
}

.enhanced-link.platform-github:hover {
    background-color: rgba(240, 246, 252, 0.2);
    box-shadow: 0 2px 4px rgba(240, 246, 252, 0.2);
}

.platform-icon {
    font-size: 1.1em;
    flex-shrink: 0;
}

.security-indicator {
    font-size: 0.7em;
    opacity: 0.6;
    flex-shrink: 0;
}

.link-text {
    color: inherit;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

/* URL Media Previews */
.url-media-preview {
    margin-top: 8px;
    margin-bottom: 4px;
    border-radius: 6px;
    overflow: hidden;
    max-width: 400px;
    border: 1px solid #333;
}

.url-preview-image {
    max-width: 100%;
    max-height: 300px;
    width: auto;
    height: auto;
    display: block;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.url-preview-image:hover {
    transform: scale(1.02);
}

.url-preview-video {
    max-width: 100%;
    max-height: 300px;
    width: auto;
    height: auto;
    display: block;
    background-color: #000;
}

.messages-container::-webkit-scrollbar-thumb {
    background-color: #333333;
    border-radius: 4px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
    background-color: #555555;
}

/* Message Styling */
.message {
    margin: 3px 0;
    word-wrap: break-word;
    white-space: pre-wrap;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.message.unread {
    background-color: #003300;
    padding: 2px 5px;
    border-radius: 3px;
    animation: highlight 1s ease-in-out;
}

.message.notification {
    color: #ffff00;
    font-style: italic;
    opacity: 0.8;
}

.message.system {
    color: #888888;
    font-style: italic;
}

.message-prompt {
    color: #00ffff;
    margin-right: 5px;
    font-weight: bold;
}

.message-content {
    color: #00ff00;
    flex: 1;
    font-size: 16px;
    font-family: 'Tahoma', 'Verdana', Arial, sans-serif;
}

.edited-indicator {
    color: #666666;
    font-size: 12px;
    font-style: italic;
    margin-left: 6px;
    opacity: 0.7;
}

.message-content.single-emoji,
.grouped-message-item .message-content.single-emoji {
    font-size: 34px;
    line-height: 1.2;
}

.grouped-content-wrapper {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.message-time {
    font-size: 13px;
    color: #000;
    margin-top: 2px;
    opacity: 1;
    align-self: flex-start;
}


/* Grouped Messages */
.message.grouped-message {
    flex-direction: column;
    align-items: stretch;
}

.grouped-message-item {
    display: flex;
    flex-direction: column;
    margin: 2px 0;
}

.grouped-message-item .message-prompt-wrapper {
    display: flex;
    align-items: baseline;
}

/* Only indent subsequent messages for current user (user1) to align with prompt */
.message.grouped-message.user1 .grouped-message-item:not(.first) {
    margin-left: 2ch; /* Indent subsequent messages to align with first message content */
}

.grouped-message-item .message-prompt {
    color: #00ffff;
    margin-right: 5px;
    font-weight: bold;
}

.grouped-message-item .message-content {
    color: #00ff00;
    flex: 1;
    font-size: 16px;
    font-family: 'Tahoma', 'Verdana', Arial, sans-serif;
}

.grouped-message .message-time {
    font-size: 13px;
    color: #000;
    margin-top: 5px;
    opacity: 1;
    align-self: flex-start;
}

/* User-specific colors and alignment for grouped messages */
.message.grouped-message.user1 {
    align-items: flex-end;
    text-align: right;
}

.message.grouped-message.user1 .grouped-content-wrapper {
    align-items: flex-end;
}

.message.grouped-message.user1 .message-time {
    align-self: flex-end;
    text-align: right;
}

.message.grouped-message.user1 .grouped-message-item {
    justify-content: flex-end;
}

.message.grouped-message.user1 .message-content {
    color: #00ff00;
}

.message.grouped-message.user2 {
    align-items: flex-start;
    text-align: left;
}

.message.grouped-message.user2 .grouped-content-wrapper {
    align-items: flex-start;
}

.message.grouped-message.user2 .message-content {
    color: #00ffff;
}

.message.grouped-message.user2 .message-time {
    align-self: flex-start;
    text-align: left;
}

.message.grouped-message.user2 .grouped-message-item {
    justify-content: flex-start;
}

/* Typing Indicator */
.typing-indicator {
    color: #ffff00;
    font-style: italic;
    animation: blink 1.5s infinite;
    padding: 5px 0;
    margin-bottom: 10px; /* Ensure spacing from any content below */
    position: relative;
    z-index: 1; /* Ensure it's above other content */
}

/* Loading Messages Indicator */
.loading-messages-indicator {
    color: #ffff00;
    font-style: italic;
    animation: blink 1.5s infinite;
    padding: 20px 30px;
    display: none;
    text-align: center;
    background-color: rgba(0, 0, 0, 0.85);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 0, 0.5);
    z-index: 1000;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.3; }
}

@keyframes highlight {
    0% { background-color: #003300; }
    50% { background-color: #005500; }
    100% { background-color: #003300; }
}

@keyframes highlight-light {
    0% { background-color: #d0d0d0; }
    50% { background-color: #c0c0c0; }
    100% { background-color: #d0d0d0; }
}

/* Input Area */
.input-container {
    background-color: #1a1a1a;
    border-top: 1px solid #333333;
    padding: 10px 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
    z-index: 10;
    flex-shrink: 0; /* Prevent input area from shrinking */
}

.input-form {
    width: 100%;
}

.button-row {
    display: flex;
    gap: 10px;
    width: 100%;
}

.input-prompt {
    color: #00ffff;
    margin-right: 5px;
    font-weight: bold;
}

.terminal-input {
    background-color: transparent;
    border: none;
    color: #00ff00;
    font-family: 'Tahoma', 'Verdana', Arial, sans-serif;
    font-size: 16px; /* Changed from 14px to 16px to prevent iOS zoom */
    outline: none;
    width: 100%;
    caret-color: #00ff00;
    transition: background-color 0.3s ease, border-color 0.3s ease;
    padding: 8px 12px;
    border-radius: 4px;
}

/* MessageInput status colors */
.terminal-input.status-offline {
    background-color: #f0f0f0 !important;
    border: 1px solid #ccc !important;
    color: #666 !important;
    caret-color: #666 !important;
}

.terminal-input.status-online {
    background-color: #f0fff0 !important;
    border: 1px solid #90EE90 !important;
    color: #006400 !important;
    caret-color: #006400 !important;
}

.terminal-input.status-typing {
    background-color: #fff0f0 !important;
    border: 1px solid #FFB6C1 !important;
    color: #8B0000 !important;
    caret-color: #8B0000 !important;
}

.terminal-input::placeholder {
    color: #666666;
}

.terminal-input.status-offline::placeholder {
    color: #999 !important;
}

.terminal-input.status-online::placeholder {
    color: #90EE90 !important;
}

.terminal-input.status-typing::placeholder {
    color: #FFB6C1 !important;
}

/* Button styles */
.btn {
    background-color: #003300;
    border: 1px solid #00ff00;
    color: #00ff00;
    font-family: inherit;
    font-size: 16px;
    padding: 12px 20px;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.btn:hover {
    background-color: #005500;
    box-shadow: 0 0 5px #00ff00;
}

.btn:active {
    background-color: #007700;
}

/* Send button specific styling */
.btn-send {
    background-color: #004400;
    border-color: #00dd00;
    color: #00dd00;
    font-weight: bold;
}

.btn-send:hover {
    background-color: #006600;
    box-shadow: 0 0 8px #00dd00;
}

.btn-send:active {
    background-color: #008800;
}


/* Upload button wrapper */
.upload-btn-wrapper {
    position: relative;
    overflow: hidden;
    display: flex;
    flex: 1;
}

.upload-btn-wrapper input[type=file] {
    position: absolute;
    left: -9999px;
}

.upload-btn-wrapper:hover .btn {
    background-color: #005500;
    box-shadow: 0 0 5px #00ff00;
}

/* Channel Key Entry Page */
.login-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #f0f2f5;
    color: #333;
    padding: 20px;
    font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

.login-title {
    font-size: 48px;
    font-weight: 700;
    margin-bottom: 30px;
    text-align: center;
    color: #003366; /* Corporate Blue */
    letter-spacing: -0.5px;
}

.login-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    background-color: #ffffff;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 450px;
}

.input-row {
    display: flex;
    gap: 10px;
    align-items: center;
    width: 100%;
}

.login-input {
    background-color: #fff;
    border: 1px solid #ced4da;
    color: #495057;
    font-family: inherit;
    font-size: 16px;
    padding: 12px 15px;
    border-radius: 4px;
    outline: none;
    width: 100%;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.login-input:focus {
    border-color: #80bdff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.login-button {
    background-color: #007bff;
    border: 1px solid #007bff;
    color: #fff;
    font-family: inherit;
    font-size: 16px;
    padding: 12px 20px;
    border-radius: 4px;
    cursor: pointer;
    transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    width: auto;
    font-weight: 600;
    white-space: nowrap;
}

.login-button:hover {
    background-color: #0056b3;
    border-color: #0056b3;
}

.login-button:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.secure-login-button {
    background-color: #6f42c1 !important;
    border-color: #6f42c1 !important;
}

.secure-login-button:hover {
    background-color: #59359a !important;
    border-color: #59359a !important;
}

.error-message {
    color: #dc3545;
    font-size: 14px;
    margin-top: 10px;
    text-align: center;
}

/* Connection Status */
.connection-status {
    position: fixed;
    top: 60px;
    right: 10px;
    padding: 5px 10px;
    border-radius: 3px;
    font-size: 12px;
    z-index: 1000;
}

.connection-status.connected {
    background-color: #003300;
    color: #00ff00;
    border: 1px solid #00ff00;
}

.connection-status.disconnected {
    background-color: #330000;
    color: #ff0000;
    border: 1px solid #ff0000;
    animation: blink 1s infinite;
}

.connection-status.fade-out {
    opacity: 0;
    transition: opacity 0.5s ease-out;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .terminal-container {
        font-size: 16px; /* Increased font size for mobile */
    }
    
    .messages-container {
        padding: 5px 10px;
    }
    
    .input-container {
        padding: 8px 10px;
    }
    
    .input-row {
        flex-wrap: wrap;
        justify-content: center;
    }

    .login-input {
        width: 250px;
        font-size: 16px; /* Prevent iOS zoom on focus */
    }

    .terminal-input {
        font-size: 16px; /* Prevent iOS zoom on focus */
    }
    
    .login-title {
        font-size: 36px;
    }
    
    .terminal-header {
        padding: 3px 10px;
        font-size: 14px; /* Increased from 11px for better iPhone readability */
        background-color: #e0e0e0;
    }
}

@media (max-width: 480px) {
    .terminal-container {
        font-size: 12px; /* Increased font size for small mobile */
        height: 100vh;
        height: 100dvh; /* Use dynamic viewport height */
    }

    .terminal-header {
        font-size: 15px; /* Even larger for iPhone */
        padding: 5px 10px;
        background-color: #e0e0e0;
    }

    .terminal-status {
        font-size: 1em; /* Slightly larger status text */
        color: #000;
    }

    .user-last-seen,
    .user-last-message {
        font-size: 1.15em; /* Increase from 0.75em for better iPhone readability */
        color: #000;
        font-weight: bold;
    }

    .input-row {
        flex-direction: column;
        width: 100%;
        gap: 15px;
    }

    .login-input {
        width: 100%;
        font-size: 16px; /* Prevent iOS zoom on focus */
    }

    .login-button {
        font-size: 14px;
        padding: 12px;
        width: 100%;
        max-width: none;
    }

    .terminal-input {
        font-size: 16px; /* Prevent iOS zoom on focus */
    }

    .login-title {
        font-size: 32px;
    }

    /* Messages container takes remaining space with proper flexbox */
    .messages-container {
        padding: 5px 8px;
        padding-bottom: 10px; /* Small consistent padding */
        flex: 1; /* Take all available space */
        min-height: 0; /* Important for flexbox scrolling */
        overflow-y: auto;
    }

    /* Input container stays at bottom with natural flow */
    .input-container {
        position: relative; /* Use natural document flow instead of fixed */
        padding: 10px 15px;
        padding-bottom: max(10px, env(safe-area-inset-bottom)); /* Account for safe area */
        background-color: #1a1a1a;
        border-top: 1px solid #333333;
        z-index: 10;
    }
}

/* Landscape mode on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .messages-container {
        padding-bottom: 10px; /* Consistent padding for landscape */
    }

    .input-container {
        padding: 8px 10px;
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }
}

/* Specific adjustments for iPhone 15 Pro Max */
@media only screen and (device-width: 430px) and (device-height: 932px) and (-webkit-device-pixel-ratio: 3) {
    .message-content {
        font-size: 16px; /* Same font size as input for consistency */
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .typing-indicator {
        animation: none;
    }
    
    .message.unread {
        animation: none;
    }
    
    .connection-status.disconnected {
        animation: none;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .terminal-container {
        background-color: #000000;
        color: #ffffff;
    }
    
    .message.unread {
        background-color: #ffffff;
        color: #000000;
    }
    
    .terminal-input {
        color: #ffffff;
    }
}

/* Focus indicators */
.terminal-input:focus {
    outline: none;
}

.login-input:focus {
    outline: 2px solid #00ff00;
    outline-offset: 2px;
}

.login-button:focus {
    outline: 2px solid #00ff00;
    outline-offset: 2px;
}

/* Loading spinner */
.loading-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid #333333;
    border-radius: 50%;
    border-top-color: #00ff00;
    animation: spin 1s ease-in-out infinite;
    margin-right: 5px;
}

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

/* Loading indicator for messages */
.loading-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(26, 26, 26, 0.95);
    color: #00ff00;
    padding: 20px 30px;
    border-radius: 8px;
    border: 1px solid #333333;
    z-index: 2000;
    font-size: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

/* Notification styles */
.notification {
    position: fixed;
    top: 110px;
    right: 10px;
    padding: 10px 15px;
    border-radius: 3px;
    font-size: 12px;
    z-index: 1000;
}

.notification.success {
    background-color: #003300;
    color: #00ff00;
    border: 1px solid #00ff00;
    animation: slideIn 0.3s ease-out;
}

.notification.error {
    background-color: #330000;
    color: #ff0000;
    border: 1px solid #ff0000;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Logout Button */
.logout-container {
    padding: 0 15px 10px;
    background-color: #1a1a1a;
}

.logout-button {
    background-color: #520c0c;
    border: 1px solid #ff0000;
    color: #ff0000;
    font-family: inherit;
    font-size: 12px;
    padding: 5px 10px;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
}

.logout-button:hover {
    background-color: #b11a1a;
    box-shadow: 0 0 8px #ff0000;
}


/* Light Theme */
body[data-theme='light'] {
    background-color: #f0f0f0;
    color: #333;
}

body[data-theme='light'] .terminal-container {
    background-color: #f0f0f0;
    color: #333;
}

body[data-theme='light'] .terminal-header {
    background-color: #ccc;
    color: #000;
    border-bottom: 1px solid #999;
}

body[data-theme='light'] .messages-container {
    background-color: #f0f0f0;
}

body[data-theme='light'] .message-prompt {
    color: #00008b; /* Dark Blue */
}

body[data-theme='light'] .message.user1 {
    align-items: flex-end;
    text-align: right;
}

body[data-theme='light'] .message.user1 .message-content-wrapper {
    justify-content: flex-end;
    text-align: right;
}

body[data-theme='light'] .message.user1 .message-content {
    color: #006400; /* Dark Green */
}

body[data-theme='light'] .message.user2 {
    align-items: flex-start;
    text-align: left;
}

body[data-theme='light'] .message.user2 .message-content-wrapper {
    justify-content: flex-start;
    text-align: left;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

body[data-theme='light'] .message.user2 .message-content {
    color: #00008b; /* Dark Blue */
}

/* Media alignment for light theme */
/* Media alignment for light theme */
body[data-theme='light'] .message.user1 .thumbnail,
body[data-theme='light'] .message.user1 video {
    display: block;
    margin-left: auto;
    margin-right: 0;
}

body[data-theme='light'] .message.user2 .thumbnail,
body[data-theme='light'] .message.user2 video,
body[data-theme='light'] .message.user2 .encrypted-file {
    display: block;
    margin-left: 0 !important;
    margin-right: auto !important;
    text-align: left !important;
}

body[data-theme='light'] .message.user1 .message-content-wrapper .encrypted-file,
body[data-theme='light'] .message.user1 .encrypted-file {
    display: inline-block;
    margin-left: auto;
    margin-right: 0;
    text-align: right;
}

body[data-theme='light'] .message.user2 .message-content-wrapper .encrypted-file,
body[data-theme='light'] .message.user2 .encrypted-file {
    display: inline-block;
    margin-left: 0;
    margin-right: auto;
    text-align: left;
}

body[data-theme='light'] .typing-indicator {
    color: #333;
}

body[data-theme='light'] .loading-messages-indicator {
    color: #333;
    background-color: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.3);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

body[data-theme='light'] .message-content {
    color: #333;
    font-family: 'Tahoma', 'Verdana', Arial, sans-serif;
}

body[data-theme='light'] .edited-indicator {
    color: #999999;
    opacity: 0.8;
}

body[data-theme='light'] .input-container {
    background-color: #ccc;
    border-top: 1px solid #999;
}

body[data-theme='light'] .terminal-input {
    color: #333;
    caret-color: #333;
    border: 1px solid #aaa;
    border-radius: 4px;
    background-color: #fff;
    padding: 2px 5px;
    font-family: 'Tahoma', 'Verdana', Arial, sans-serif;
    font-size: 16px; /* Changed from 14px to 16px to prevent iOS zoom */
}

body[data-theme='light'] .message.unread {
    background-color: #e0e0e0;
    animation-name: highlight-light;
}

body[data-theme='light'] .login-container {
    background-color: #f0f0f0;
    color: #333;
}

body[data-theme='light'] .login-input {
    background-color: #fff;
    border: 1px solid #ccc;
    color: #333;
}

body[data-theme='light'] .login-input:focus {
    border-color: #007bff;
    box-shadow: 0 0 5px rgba(0, 123, 255, 0.5);
}

body[data-theme='light'] .login-button {
    background-color: #007bff;
    border: 1px solid #007bff;
    color: #fff;
}

body[data-theme='light'] .login-button:hover {
    background-color: #0056b3;
}

body[data-theme='light'] .dashboard-link {
    background-color: #6c757d;
    border: 1px solid #6c757d;
    color: #fff;
}

body[data-theme='light'] .dashboard-link:hover {
    background-color: #5a6268;
}

/* Light theme button overrides */
body[data-theme='light'] .btn {
    background-color: #007bff;
    border: 1px solid #007bff;
    color: #fff;
}

body[data-theme='light'] .btn:hover {
    background-color: #0056b3;
    border-color: #0056b3;
    box-shadow: 0 0 5px rgba(0, 123, 255, 0.3);
}

body[data-theme='light'] .btn:active {
    background-color: #004085;
    border-color: #003d82;
}

body[data-theme='light'] .upload-btn-wrapper:hover .btn {
    background-color: #0056b3;
    border-color: #0056b3;
    box-shadow: 0 0 5px rgba(0, 123, 255, 0.3);
}

/* Light theme logout button */
body[data-theme='light'] .logout-button {
    background-color: #dc3545;
    border: 1px solid #dc3545;
    color: #fff;
}

body[data-theme='light'] .logout-button:hover {
    background-color: #c82333;
    border-color: #bd2130;
    box-shadow: 0 0 8px rgba(220, 53, 69, 0.3);
}

/* Base reply message styles */
.message .original-message-ref {
    background: #f8f9fa;
    border-left: 3px solid #007bff;
    padding: 1px 1px;
    margin-bottom: 4px;
    margin-top: 4px;
    border-radius: 0 1px 1px 0;
    color: #495057;
    cursor: pointer;
    display: flex;flex-direction: column;
    width: 100%;
    height: 60%;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.message .original-message-ref:hover {
    background: #e9ecef;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.message .original-message-ref .original-author {
    font-weight: bold;
    color: #007bff;
    margin-bottom: 1px;
    font-size: 14px;
}

.message .original-message-ref .original-content {
    color: #6c757d;
    word-wrap: normal;
    white-space: pre-wrap;
    max-height: fit-content;
    overflow: visible;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    font-size: 14px;
    line-height: 1.2;
}

.message .original-message-ref .original-image {
    max-width: 120px;
    max-height: 120px;
    border-radius: 4px;
    margin-right: 8px;
    vertical-align: middle;
}

/* Light theme reply message styles */
body[data-theme='light'] .message .original-message-ref {
    background: #f8f9fa;
    border-left: 3px solid #007bff;
    color: #495057;

}

body[data-theme='light'] .message .original-message-ref:hover {
    background: #e9ecef;
}

body[data-theme='light'] .message .original-message-ref .original-author {
    color: #007bff;
    margin-bottom: 1px;
    font-size: 14px;
    font-family: 'Tahoma', 'Verdana', Arial, sans-serif;
}

body[data-theme='light'] .message .original-message-ref .original-content {
    color: #6c757d;
    font-size: 14px;
    font-family: 'Tahoma', 'Verdana', Arial, sans-serif;

}

body[data-theme='light'] .loading-indicator {
    background-color: rgba(240, 240, 240, 0.95);
    color: #333;
    border-color: #ccc;
}

body[data-theme='light'] .loading-spinner {
    border-color: #ccc;
    border-top-color: #007bff;
}

/* Light theme image masking */
body[data-theme='light'] .thumbnail.masked::after {
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    border: 1px solid #ddd;
}


/* Dashboard Link */
.dashboard-link {
    display: inline-block;
    background-color: #003300;
    border: 1px solid #00ff00;
    color: #00ff00;
    font-family: inherit;
    font-size: 16px;
    padding: 10px 20px;
    border-radius: 3px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.3s ease;
}

.dashboard-link:hover {
    background-color: #005500;
    box-shadow: 0 0 10px #00ff00;
}

/* Encrypted File Styling */
.encrypted-file {
    display: inline-block;
    background-color: #2a2a2a;
    border: 1px solid #666;
    color: #ffaa00;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 5px;
    transition: all 0.3s ease;
    font-size: 16px;
}

.encrypted-file:hover {
    background-color: #333;
    border-color: #ffaa00;
    box-shadow: 0 0 5px rgba(255, 170, 0, 0.3);
}


/* Performance Optimizations for Media */
.thumbnail {
    max-width: 300px;
    max-height: 300px;
    margin-top: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    will-change: transform; /* Optimize for transitions */
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Image Masking Functionality */
.thumbnail.masked {
    filter: blur(12px) brightness(0.6);
    position: relative;
}

.thumbnail.masked::after {
    content: "🔒 Click any image to reveal all";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
    text-align: center;
    white-space: nowrap;
    pointer-events: none;
    z-index: 1;
}

.thumbnail.masked:hover {
    filter: blur(4px) brightness(0.6);
}

/* Ensure smooth transition when unmasking */
.thumbnail.unmasking {
    filter: none;
    transition: filter 0.5s ease;
}

/* Media alignment for user messages */
.message.user1 .thumbnail,
.message.user1 video {
    display: block;
    margin-left: auto;
    margin-right: 0;
}

.message.user2 .thumbnail,
.message.user2 video,
.message.user2 .encrypted-file {
    display: block;
    margin-left: 0 !important;
    margin-right: auto !important;
    text-align: left !important;
}

.message.user1 .message-content-wrapper .encrypted-file,
.message.user1 .encrypted-file {
    display: inline-block;
    margin-left: auto;
    margin-right: 0;
    text-align: right;
}

.message.user2 .message-content-wrapper .encrypted-file,
.message.user2 .encrypted-file {
    display: inline-block;
    margin-left: 0;
    margin-right: auto;
    text-align: left;
}

/* .thumbnail.expanded styles removed - replaced with .image-overlay */

/* Fullscreen image overlay */
.image-overlay {
    /* Positioning - completely cover the viewport */
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;

    /* Background - completely black out everything behind */
    background-color: rgba(0, 0, 0, 0.95) !important;
    backdrop-filter: blur(5px);

    /* Layout - center the image */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;

    /* Clip panned/zoomed image to viewport */
    overflow: hidden !important;

    /* Stacking - above everything else */
    z-index: 2147483647 !important;

    /* Interaction - clickable to close */
    cursor: pointer !important;

    /* Animation - fade in/out */
    opacity: 0 !important;
    transition: opacity 0.3s ease !important;

    /* Block all pointer events when hidden */
    pointer-events: none;

    /* Prevent native browser zoom from interfering */
    touch-action: none !important;
}

.image-overlay.show {
    opacity: 1 !important;
    pointer-events: auto !important;
}

.image-overlay img {
    /* Size constraints - fit to screen initially */
    max-width: 95vw !important;
    max-height: 95vh !important;
    width: auto !important;
    height: auto !important;

    /* Scaling and appearance */
    object-fit: contain !important;
    border-radius: 8px !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.8) !important;
    cursor: grab !important;

    /* Animation - scale in effect (JS overrides this after open) */
    transform: scale(0.9);
    transition: transform 0.3s ease;

    /* Prevent any other styles from interfering */
    position: relative !important;
    z-index: 2147483647 !important;

    /* Prevent text selection while panning */
    user-select: none !important;
    -webkit-user-select: none !important;

    /* JS controls touch handling */
    touch-action: none !important;
}

.image-overlay.show img {
    transform: scale(1);
}

/* Lazy Loading States */
.lazy-load {
    opacity: 0.6;
    transition: opacity 0.3s ease, transform 0.2s ease;
    background-color: #222;
    border-radius: 4px;
    position: relative;
}

/* Show loading placeholder for images */
.lazy-load.thumbnail {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='200'%3E%3Crect width='100%25' height='100%25' fill='%23333'/%3E%3Ctext x='50%25' y='50%25' text-anchor='middle' dy='0.3em' font-family='Arial' font-size='14' fill='%23888'%3E📷 Loading...%3C/text%3E%3C/svg%3E");
    background-size: cover;
    background-position: center;
    min-height: 100px;
    min-width: 150px;
}

/* Loading state for videos */
.lazy-load video {
    background-color: #111;
}

/* Smooth transition when loaded */
.lazy-load.loaded {
    opacity: 1;
    transform: scale(1);
}

.lazy-load:not(.thumbnail) {
    opacity: 1;
}

/* Video Performance Optimizations */
video {
    contain: layout style paint; /* CSS containment for videos */
}

/* Message Performance Optimizations */
.message {
    contain: layout; /* CSS containment for messages */
    transform: translateZ(0); /* Force GPU acceleration */
}

/* iOS Safari fixes for address bar and viewport issues */
@supports (-webkit-touch-callout: none) {
    /* iOS-specific styles */
    body {
        height: 100vh;
        height: 100dvh;
    }

    .terminal-container {
        height: 100vh;
        height: 100dvh;
    }

    .input-container {
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }
}

/* General mobile optimizations */
@media screen and (max-width: 768px) {
    html {
        height: 100%;
        height: 100dvh;
    }

    body {
        min-height: 100vh;
        min-height: 100dvh;
        position: relative;
    }

    /* Typing indicator gets natural spacing within messages container */
    .typing-indicator {
        margin-bottom: 10px;
    }

    /* Smaller buttons on mobile to save space */
    .btn {
        min-height: 36px;
        padding: 8px 16px;
        font-size: 14px;
    }
}

/* Progress Container and Upload Indicators */
.progress-container {
    width: 100%;
    background-color: #e0e0e0;
    border-radius: 5px;
    display: none;
    align-items: center;
    padding: 5px;
    margin-top: 5px;
}

.upload-indicator {
    margin-left: 10px;
    font-style: italic;
    color: #333;
}

.progress-bar {
    width: 0%;
    height: 10px;
    background-color: #2196F3;
    transition: width 0.3s;
    border-radius: 5px;
}

.user-info, .other-user-info {
    padding: 5px 10px;
}

/* Reply Menu Styles */
.message-popup-menu {
    position: absolute;
    background: #2c2c2c;
    border: 1px solid #444;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 100;
    min-width: 120px;
    display: none;
}

.message-popup-menu .menu-item {
    padding: 10px 15px;
    cursor: pointer;
    color: #fff;
    font-size: 14px;
    border-bottom: 1px solid #444;
    display: flex;
    align-items: center;
    gap: 8px;
}

.message-popup-menu .menu-item:last-child {
    border-bottom: none;
}

.message-popup-menu .menu-item:hover {
    background: #404040;
}

/* Reply Preview Styles */
.reply-preview {
    background: #333;
    border-left: 3px solid #555;
    padding: 8px 12px;
    margin-bottom: 8px;
    border-radius: 0 4px 4px 0;
    position: relative;
}

.reply-preview .reply-to-text {
    color: #aaa;
    font-size: 12px;
    margin-bottom: 4px;
}

.reply-preview .reply-content {
    color: #ddd;
    font-size: 13px;
    max-height: 60px;
    overflow: hidden;
    word-wrap: break-word;
    white-space: pre-wrap;
    line-height: 1.3;
}

.reply-preview .reply-image {
    max-width: 30px;
    max-height: 30px;
    border-radius: 4px;
    margin-right: 8px;
    vertical-align: middle;
}

.reply-preview .close-reply {
    position: absolute;
    top: 5px;
    right: 8px;
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 16px;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reply-preview .close-reply:hover {
    color: #fff;
}

/* Replied message styles */
.message.has-reply {
    position: relative;
}

.message-content-wrapper {
    display: flex;
    flex-direction: column;
}

.message-content {
    display: block;
    word-wrap: break-word;
}

/* Unread Message Marker */
.unread-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 15px 0;
    opacity: 0.8;
}

.unread-marker-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, transparent, #444444, transparent);
}

.unread-marker-text {
    padding: 0 15px;
    font-size: 12px;
    color: #444444;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    background-color: #000000;
    white-space: nowrap;
}

/* Theme variations for unread marker - light theme only */
.unread-marker-line {
    background: linear-gradient(to right, transparent, #444444, transparent);
}

.unread-marker-text {
    color: #444444;
    background-color: #ffffff;
}

/* File download links */
.file-download {
    color: #007bff;
    text-decoration: none;
    padding: 8px 12px;
    border: 1px solid #007bff;
    border-radius: 4px;
    display: inline-block;
    margin-top: 5px;
    transition: all 0.3s ease;
}

.file-download:hover {
    background-color: #007bff;
    color: white;
    text-decoration: none;
}

/* Terminals Grid in Login Page */
.terminals-grid-container {
    margin: 15px auto;
    max-width: 800px;
    background-color: #1a1a1a;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #333333;
}

/* Background state classes - affecting border too */
.terminals-grid-container.bg-light-violet {
    border-color: #4a1a4a !important;
}
.terminals-grid-container.bg-soft-blue {
    border-color: #1a2a4a !important;
}
.terminals-grid-container.bg-soft-gray {
    border-color: #333333;
}

.terminals-grid-container .server-info {
    background-color: #2a2a2a;
    border: 1px solid #444444;
    border-radius: 5px;
    padding: 10px 15px;
    margin-bottom: 20px;
    font-size: 14px;
    color: #00ff00;
    transition: background-color 0.5s ease;
}

.terminals-grid-container .server-info p {
    margin: 0;
    color: #00ff00;
}

.terminals-grid-container #dashboard-table {
    background-color: #1a1a1a;
    color: #00ff00;
}

.terminals-grid-container #dashboard-table th {
    background-color: #2a2a2a;
    color: #00ff00;
    border-bottom: 1px solid #444444;
    transition: background-color 0.5s ease;
}

/* Header colors based on container state (Dark Theme) */
.terminals-grid-container.bg-light-violet .server-info,
.terminals-grid-container.bg-light-violet #dashboard-table th {
    background-color: #4a1a4a !important; /* Dark Violet */
}

.terminals-grid-container.bg-soft-blue .server-info,
.terminals-grid-container.bg-soft-blue #dashboard-table th {
    background-color: #1a2a4a !important; /* Soft Blue */
}

.terminals-grid-container.bg-soft-gray .server-info,
.terminals-grid-container.bg-soft-gray #dashboard-table th {
    background-color: #2a2a2a !important; /* Soft Gray */
}

.terminals-grid-container #dashboard-table td {
    border-bottom: 1px solid #333333;
    color: #00ff00;
}

.terminals-grid-container #dashboard-table tbody tr:hover {
    background-color: #2a2a2a;
}

/* User activity row colors matching headers */
@keyframes gradient-scan {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.terminals-grid-container #dashboard-table tbody tr.user1-active {
    background: linear-gradient(90deg, #1a2a4a, #0088cc, #00ffcc, #1a2a4a);
    background-size: 400% 100% !important;
    animation: gradient-scan 3s ease infinite;
    will-change: background-position;
    color: #ffffff;
}

.terminals-grid-container #dashboard-table tbody tr.user2-active {
    background: linear-gradient(90deg, #4a1a4a, #d90429, #ffb703, #4a1a4a);
    background-size: 400% 100% !important;
    animation: gradient-scan 3s ease infinite;
    will-change: background-position;
    color: #ffffff;
}

.terminals-grid-container #dashboard-table tbody tr.user1-active.user2-active {
    background: linear-gradient(90deg, #ff0000, #ff7f00, #ffff00, #00ff00, #0000ff, #4b0082, #9400d3, #ff0000);
    background-size: 600% 100% !important;
    animation: gradient-scan 2s linear infinite;
    will-change: background-position;
}

/* Light theme row colors */
body[data-theme='light'] .terminals-grid-container #dashboard-table tbody tr.user1-active {
    background: linear-gradient(90deg, #e3f2fd, #90caf9, #42a5f5, #e3f2fd) !important;
    background-size: 400% 100% !important;
    animation: gradient-scan 3s ease infinite;
    will-change: background-position;
    color: #0d47a1;
}

body[data-theme='light'] .terminals-grid-container #dashboard-table tbody tr.user2-active {
    background: linear-gradient(90deg, #f3e5f5, #ce93d8, #ab47bc, #f3e5f5) !important;
    background-size: 400% 100% !important;
    animation: gradient-scan 3s ease infinite;
    will-change: background-position;
    color: #4a148c;
}

body[data-theme='light'] .terminals-grid-container #dashboard-table tbody tr.user1-active.user2-active {
    background: linear-gradient(90deg, #ffcdd2, #fff9c4, #c8e6c9, #bbdefb, #e1bee7, #ffcdd2) !important;
    background-size: 600% 100% !important;
    animation: gradient-scan 3s linear infinite;
    will-change: background-position;
}

/* Ensure hover works */
.terminals-grid-container #dashboard-table tbody tr.user1-active:hover,
.terminals-grid-container #dashboard-table tbody tr.user2-active:hover {
    filter: brightness(1.1);
}

/* Light theme for terminals grid */
body[data-theme='light'] .terminals-grid-container {
    background-color: #fff;
    border: 1px solid #ddd;
}

body[data-theme='light'] .terminals-grid-container.bg-light-violet {
    border-color: #e6e6fa !important;
}
body[data-theme='light'] .terminals-grid-container.bg-soft-blue {
    border-color: #e3f2fd !important;
}
body[data-theme='light'] .terminals-grid-container.bg-soft-gray {
    border-color: #f7f7f7 !important;
}

/* Header colors based on container state (Light Theme) */
body[data-theme='light'] .terminals-grid-container.bg-light-violet .server-info,
body[data-theme='light'] .terminals-grid-container.bg-light-violet #dashboard-table th {
    background-color: #e6e6fa !important; /* Light Violet (Lavender) */
}

body[data-theme='light'] .terminals-grid-container.bg-soft-blue .server-info,
body[data-theme='light'] .terminals-grid-container.bg-soft-blue #dashboard-table th {
    background-color: #e3f2fd !important; /* Soft Blue */
}

body[data-theme='light'] .terminals-grid-container.bg-soft-gray .server-info,
body[data-theme='light'] .terminals-grid-container.bg-soft-gray #dashboard-table th {
    background-color: #f7f7f7 !important; /* Soft Gray */
}

body[data-theme='light'] .terminals-grid-container .server-info {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    color: #495057;
}

body[data-theme='light'] .terminals-grid-container .server-info p {
    color: #495057;
}

body[data-theme='light'] .terminals-grid-container #dashboard-table {
    background-color: #fff;
    color: #333;
}

body[data-theme='light'] .terminals-grid-container #dashboard-table th {
    background-color: #f7f7f7;
    color: #4b4f56;
    border-bottom: 1px solid #ddd;
}

body[data-theme='light'] .terminals-grid-container #dashboard-table td {
    border-bottom: 1px solid #ddd;
    color: #333;
}

body[data-theme='light'] .terminals-grid-container #dashboard-table tbody tr:hover {
    background-color: #f5f5f5;
}

/* Secure Mode Styles */
.secure-hidden {
    opacity: 0 !important;
    pointer-events: none !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    visibility: hidden !important;
}

.secure-temporary-visible {
    opacity: 1 !important;
    pointer-events: auto !important;
    visibility: visible !important;
    animation: fadeOut 5s ease-in forwards;
}

@keyframes fadeOut {
    0%, 80% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}

/* Secure Login Button Styling */
.secure-login-button {
    background-color: #330033 !important;
    border: 1px solid #ff00ff !important;
    color: #ff00ff !important;
}

.secure-login-button:hover {
    background-color: #550055 !important;
    box-shadow: 0 0 10px #ff00ff !important;
}

/* Light theme secure login button */
body[data-theme='light'] .secure-login-button {
    background-color: #6a1b9a !important;
    border: 1px solid #6a1b9a !important;
    color: #fff !important;
}

body[data-theme='light'] .secure-login-button:hover {
    background-color: #8e24aa !important;
    box-shadow: 0 0 10px rgba(106, 27, 154, 0.5) !important;
}

.auth-hidden {
    display: none !important;
}

/* Files overlay panel */
#files-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-color, #1a1a1a);
    z-index: 1000;
    flex-direction: column;
    overflow: hidden;
}

#files-overlay.active {
    display: flex;
}

.files-overlay-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid #333;
    font-weight: bold;
    font-size: 14px;
    flex-shrink: 0;
}

.files-overlay-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    opacity: 0.7;
}

.files-overlay-close:hover {
    opacity: 1;
}

.files-overlay-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.files-overlay-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.files-overlay-item.user1 {
    align-items: flex-end;
}

.files-overlay-item.user2 {
    align-items: flex-start;
}

.files-overlay-meta {
    font-size: 11px;
    opacity: 0.55;
}

.files-overlay-loading,
.files-overlay-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 8px;
    opacity: 0.6;
    font-size: 14px;
    text-align: center;
}

body[data-theme='light'] #files-overlay {
    background: #f5f5f5;
    color: #222;
}

body[data-theme='light'] .files-overlay-header {
    border-bottom-color: #ddd;
}

/* Help overlay */
#help-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-color, #1a1a1a);
    z-index: 200;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.help-overlay-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid #333;
    font-weight: bold;
    font-size: 14px;
    flex-shrink: 0;
}

.help-overlay-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.help-overlay-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.help-overlay-table tr + tr td {
    border-top: 1px solid rgba(255,255,255,0.06);
}

.help-overlay-cmd {
    padding: 8px 12px 8px 0;
    font-family: monospace;
    color: var(--accent-color, #00ff88);
    white-space: nowrap;
    width: 1%;
}

.help-overlay-desc {
    padding: 8px 0;
    opacity: 0.8;
}

body[data-theme='light'] #help-overlay {
    background: #f5f5f5;
    color: #222;
}

body[data-theme='light'] .help-overlay-header {
    border-bottom-color: #ddd;
}

body[data-theme='light'] .help-overlay-table tr + tr td {
    border-top-color: rgba(0,0,0,0.08);
}

body[data-theme='light'] .help-overlay-cmd {
    color: #007a44;
}

/* Map overlay */
#map-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-color, #1a1a1a);
    z-index: 200;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.map-overlay-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid #333;
    font-weight: bold;
    font-size: 14px;
    flex-shrink: 0;
}

.map-overlay-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.map-overlay-list {
    display: flex;
    flex-direction: column;
}

.map-overlay-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    text-decoration: none;
    color: inherit;
    transition: background 0.15s;
    gap: 12px;
}

.map-overlay-item:hover {
    background: rgba(255,255,255,0.05);
}

.map-overlay-item-left {
    flex: 1;
    min-width: 0;
}

.map-overlay-item-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.map-overlay-location {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.map-overlay-time {
    font-size: 11px;
    opacity: 0.5;
    margin-top: 2px;
}

.map-overlay-nick {
    font-weight: 600;
    opacity: 0.8;
}

.map-overlay-arrow {
    font-size: 18px;
    opacity: 0.4;
}

.map-mood-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    letter-spacing: 0.3px;
}

.map-mood-good {
    background: rgba(52, 168, 83, 0.2);
    color: #34a853;
}

.map-mood-bad {
    background: rgba(234, 67, 53, 0.2);
    color: #ea4335;
}

.map-overlay-loading,
.map-overlay-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 8px;
    padding: 40px 20px;
    opacity: 0.6;
    font-size: 14px;
    text-align: center;
    height: 100%;
}

body[data-theme='light'] #map-overlay {
    background: #f5f5f5;
    color: #222;
}

body[data-theme='light'] .map-overlay-header {
    border-bottom-color: #ddd;
}

body[data-theme='light'] .map-overlay-item {
    border-bottom-color: rgba(0,0,0,0.08);
}

body[data-theme='light'] .map-overlay-item:hover {
    background: rgba(0,0,0,0.04);
}

body[data-theme='light'] .map-mood-good {
    background: rgba(52, 168, 83, 0.12);
}

body[data-theme='light'] .map-mood-bad {
    background: rgba(234, 67, 53, 0.12);
}
