/* style.css */
/* Modern, clean, and highly professional messaging stylesheet */
/* Theme: Slate Dark & Corporate Blue (Enterprise Secure Chat styling) */

:root {
    --bg-color: #030804;
    --bg-sidebar: #050d06;
    --bg-panel: #071409;
    --bg-input: #020703;
    
    --primary-color: #3dfc5c; /* Phosphor Green */
    --primary-hover: #50ff6d;
    --primary-dim: #154d20;
    --primary-glow: rgba(61, 252, 92, 0.45);
    
    --border-color: #1a4220;
    --border-hover: #2e6936;
    
    --text-main: #adffbc;
    --text-muted: #4e9759;
    --text-dark: #020703;
    
    --bubble-sent: rgba(61, 252, 92, 0.05);
    --bubble-received: rgba(255, 255, 255, 0.02);
    
    --success-green: #3dfc5c;
    --alert-red: #ff3333;
    --alert-amber: #ffaa00;
    
    --font-sans: 'Outfit', 'Fira Code', 'Inter', sans-serif;
    --font-mono: 'Fira Code', monospace;
    
    --transition-speed: 0.18s;
    --border-radius: 4px; /* Shorter radius is more retro-hardware styled */
    --border-radius-sm: 2px;
}

/* Global Reset */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) var(--bg-sidebar);
    -webkit-tap-highlight-color: transparent;
}

/* iOS safe area support */
:root {
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-left: env(safe-area-inset-left, 0px);
    --safe-area-right: env(safe-area-inset-right, 0px);
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: var(--font-sans);
    height: 100%;
    min-height: 100vh;
    width: 100vw;
    overflow: hidden;
    position: relative;
    letter-spacing: -0.01em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html {
    height: 100%;
    font-size: 16px;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-sidebar);
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Background soft vignette overlay */
.vignette-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999;
    background: radial-gradient(circle at center, transparent 60%, rgba(0, 0, 0, 0.35) 100%);
    pointer-events: none;
}

/* Main Container */
#app-container {
    position: relative;
    z-index: 10;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}

/* Core glassmorphic card classes */
.glassmorphic {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    border-radius: var(--border-radius);
    transition: border-color var(--transition-speed);
}
.glassmorphic:hover {
    border-color: var(--border-hover);
}

/* ================= AUTHENTICATION PANEL ================= */
.auth-card {
    width: 100%;
    max-width: 420px;
    padding: 35px;
    animation: fadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-sizing: border-box;
    overflow-y: auto;
    max-height: 100vh;
    max-height: 100dvh;
}

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

.auth-header {
    text-align: center;
    margin-bottom: 25px;
}

.terminal-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 8px;
}

.logo-icon {
    font-size: 2.2rem;
    color: var(--primary-color);
    margin-bottom: 6px;
}

.terminal-logo h1 {
    font-family: var(--font-sans);
    font-size: 1.8rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.5px;
}

.terminal-logo h1 span {
    color: var(--primary-color);
}

.logo-version {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
    background: var(--bg-sidebar);
    padding: 2px 8px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    margin-top: 4px;
    display: inline-block;
}

.auth-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.4;
    margin-top: 8px;
}

/* Tab Navigation */
.auth-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
    gap: 4px;
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-weight: 600;
    padding: 10px 4px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: color var(--transition-speed), border-bottom var(--transition-speed);
    text-align: center;
    border-bottom: 2px solid transparent;
}

.tab-btn i {
    margin-right: 5px;
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
}

.form-container {
    display: none;
}

.form-container.active {
    display: block;
}

.input-group {
    margin-bottom: 15px;
}

.input-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.input-wrapper input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    padding: 12px 12px 12px 38px;
    border-radius: var(--border-radius);
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    transition: border-color var(--transition-speed);
}

.input-wrapper input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Submit Buttons */
.submit-btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: var(--border-radius);
    font-family: var(--font-sans);
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    transition: background 0.15s, transform 0.1s;
    background: var(--primary-color);
    color: #ffffff;
}

.submit-btn:hover {
    background: var(--primary-hover);
}

.submit-btn:active {
    transform: scale(0.98);
}

/* Demo Keys box */
.seeded-keys-box {
    margin-top: 20px;
    border-top: 1px dashed var(--border-color);
    padding-top: 15px;
}

.seeded-keys-box h3 {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 8px;
}

.seeded-keys-box ul {
    list-style-type: none;
}

.seeded-keys-box li {
    font-size: 0.8rem;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.demo-key {
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    padding: 2px 6px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    color: var(--primary-color);
    font-family: var(--font-mono);
    font-weight: 600;
}

.demo-key:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--primary-color);
}

.demo-desc {
    color: var(--text-muted);
}

.seeded-keys-box .hint {
    display: block;
    margin-top: 8px;
    font-size: 0.7rem;
    color: var(--text-muted);
    font-style: italic;
}

.encryption-warning {
    margin-top: 20px;
    background: rgba(239, 68, 68, 0.04);
    border: 1px solid rgba(239, 68, 68, 0.15);
    padding: 12px;
    border-radius: var(--border-radius);
    font-size: 0.78rem;
    line-height: 1.4;
    color: var(--text-muted);
}

.encryption-warning i {
    color: var(--alert-red);
}

/* Alert box */
.alert-box {
    margin-top: 15px;
    padding: 10px 14px;
    border-radius: var(--border-radius);
    font-size: 0.8rem;
    font-weight: 600;
}

.alert-box.error {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid var(--alert-red);
    color: #f87171;
}

.alert-box.success {
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid var(--success-green);
    color: #34d399;
}

/* ================= CHAT DASHBOARD WINDOW ================= */
#chat-dashboard {
    width: 100%;
    max-width: 1100px;
    height: 85vh;
    height: 85dvh;
    min-height: 560px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    border: 1px solid var(--border-color);
    animation: dashboardFade 0.3s ease;
    box-sizing: border-box;
}

@keyframes dashboardFade {
    from { opacity: 0; transform: scale(0.98); }
    to { opacity: 1; transform: scale(1); }
}

/* Sidebar panel */
#chat-sidebar {
    width: 280px;
    min-width: 250px;
    border-right: 1px solid var(--border-color);
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
}

.sidebar-user-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.user-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.user-status-dot.online {
    background-color: var(--success-green);
}

.user-status-dot.offline {
    background-color: var(--text-muted);
}

.user-details {
    min-width: 0;
}

.user-details h2 {
    font-size: 0.9rem;
    font-weight: 600;
    color: #ffffff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.uuid-badge-container {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 1px;
}

.uuid-text {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-muted);
}

#btn-copy-uuid, #btn-disconnect, #btn-mobile-back, .attachment-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    font-size: 0.82rem;
    border-radius: 4px;
    transition: color 0.15s, background-color 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#btn-copy-uuid:hover {
    color: var(--primary-color);
    background-color: rgba(255, 255, 255, 0.05);
}

#btn-disconnect:hover {
    color: var(--alert-red);
    background-color: rgba(255, 255, 255, 0.05);
}

.user-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Global Statistics Bar */
.global-stats-bar {
    padding: 6px 16px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    font-family: var(--font-sans);
    font-size: 0.68rem;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-item i {
    font-size: 0.6rem;
    color: var(--success-green);
}

/* Contact Search */
.search-contact-box {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 10px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

#contact-search-input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 8px 8px 30px;
    color: var(--text-main);
    font-size: 0.82rem;
    transition: border-color 0.15s;
}

#contact-search-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.search-results {
    position: absolute;
    top: 50px;
    left: 12px;
    right: 12px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    z-index: 50;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

.search-result-item {
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.82rem;
}

.search-result-item:last-child {
    border-bottom: none;
}

.res-profile {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.res-name {
    font-weight: 600;
    color: #ffffff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-add-contact {
    background: var(--primary-color);
    border: none;
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-add-contact:hover {
    background: var(--primary-hover);
}

.no-results {
    padding: 12px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Contacts List Panel */
.contacts-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.section-title {
    padding: 12px 16px 6px;
}

.section-title h3 {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.contacts-list-container {
    list-style: none;
    overflow-y: auto;
    flex: 1;
    padding: 0 8px 8px;
}

.contact-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    margin-bottom: 3px;
    transition: background-color var(--transition-speed);
}

.contact-item:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

.contact-item.active {
    background-color: rgba(59, 130, 246, 0.16);
    border-left: 3px solid var(--primary-color);
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    padding-left: 9px;
}

.contact-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.contact-details {
    min-width: 0;
}

.contact-username {
    font-size: 0.85rem;
    font-weight: 600;
    color: #ffffff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.contact-uuid-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 1px;
}

.contact-uuid-sub.msg-preview {
    color: #9ca3af;
}

.contact-item.active .contact-uuid-sub.msg-preview {
    color: #cbd5e1;
}

.unread-badge {
    background: var(--alert-red);
    color: #ffffff;
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ================= MAIN CHAT PANE ================= */
#chat-window {
    flex: 1;
    background: var(--bg-panel);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-state-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Centered clean welcome card, no terminal theme */
.welcome-card {
    width: 85%;
    max-width: 480px;
    margin: auto;
    text-align: center;
    padding: 40px 30px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: fadeIn 0.3s ease;
}

.welcome-logo {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 20px;
}

.welcome-card h2 {
    font-size: 1.4rem;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 12px;
}

.welcome-card p {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 25px;
}

.security-standards {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.security-standards span {
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--primary-color);
    background: rgba(59, 130, 246, 0.08);
    padding: 4px 10px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Active Room Header */
#chat-room-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-sidebar);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.recipient-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.recipient-profile .user-status-dot {
    width: 8px;
    height: 8px;
}

.recipient-details h3 {
    font-size: 0.9rem;
    font-weight: 700;
    color: #ffffff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.encryption-tag {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--success-green);
    border: 1px solid rgba(16, 185, 129, 0.2);
    padding: 3px 8px;
    border-radius: 12px;
    background: rgba(16, 185, 129, 0.05);
}

.encryption-tag i {
    font-size: 0.65rem;
    margin-right: 3px;
}

#btn-mobile-back {
    display: none;
    font-size: 1.1rem;
    padding: 6px 10px 6px 0;
    color: var(--primary-color);
}

/* Chat Messages Feed */
.messages-feed {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Message Bubbles */
.message-bubble {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.9rem;
    line-height: 1.48;
    position: relative;
    word-break: break-word;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.message-bubble.sent {
    align-self: flex-end;
    background: var(--bubble-sent);
    color: #ffffff;
    border-bottom-right-radius: 2px;
}

.message-bubble.received {
    align-self: flex-start;
    background: var(--bubble-received);
    color: #ffffff;
    border-bottom-left-radius: 2px;
}

.msg-timestamp {
    font-family: var(--font-sans);
    font-weight: 500;
    font-size: 0.62rem;
    align-self: flex-end;
    margin-top: 1px;
}

.message-bubble.sent .msg-timestamp {
    color: rgba(255, 255, 255, 0.6);
}

.message-bubble.received .msg-timestamp {
    color: rgba(255, 255, 255, 0.45);
}

/* Inline Attachment Bubbles Rendering - Image Gallery / Collage Grid */
.message-img-attachment-group {
    display: grid;
    gap: 4px;
    border-radius: var(--border-radius);
    overflow: hidden;
    margin-bottom: 6px;
    width: 280px; /* fixed comfortable width for collage */
    max-width: 100%;
}

.message-img-item {
    position: relative;
    overflow: hidden;
    border-radius: 4px;
    cursor: pointer;
}

.message-img-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: opacity 0.15s ease-in-out, transform 0.2s ease-in-out;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.message-img-item img:hover {
    opacity: 0.9;
    transform: scale(1.03);
}

/* Grid count layouts */
.message-img-attachment-group.grid-count-1 {
    grid-template-columns: 1fr;
}
.message-img-attachment-group.grid-count-1 .message-img-item img {
    max-height: 220px;
}

.message-img-attachment-group.grid-count-2 {
    grid-template-columns: 1fr 1fr;
}
.message-img-attachment-group.grid-count-2 .message-img-item {
    height: 130px;
}

.message-img-attachment-group.grid-count-3 {
    grid-template-columns: 1fr 1fr;
}
.message-img-attachment-group.grid-count-3 .message-img-item:first-child {
    grid-column: span 2;
    height: 150px;
}
.message-img-attachment-group.grid-count-3 .message-img-item:not(:first-child) {
    height: 90px;
}

.message-img-attachment-group.grid-count-4 {
    grid-template-columns: 1fr 1fr;
}
.message-img-attachment-group.grid-count-4 .message-img-item {
    height: 90px;
}

.message-img-attachment-group.grid-count-5 {
    grid-template-columns: repeat(6, 1fr);
}
.message-img-attachment-group.grid-count-5 .message-img-item:nth-child(1),
.message-img-attachment-group.grid-count-5 .message-img-item:nth-child(2) {
    grid-column: span 3;
    height: 110px;
}
.message-img-attachment-group.grid-count-5 .message-img-item:nth-child(3),
.message-img-attachment-group.grid-count-5 .message-img-item:nth-child(4),
.message-img-attachment-group.grid-count-5 .message-img-item:nth-child(5) {
    grid-column: span 2;
    height: 80px;
}

.message-doc-attachment {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.18);
    border-radius: var(--border-radius);
    padding: 8px 12px;
    margin-bottom: 4px;
    gap: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.doc-attachment-details {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.doc-attachment-icon {
    font-size: 1.2rem;
    color: var(--primary-color);
}

.doc-attachment-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.doc-attachment-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: #ffffff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.doc-attachment-size {
    font-size: 0.68rem;
    color: var(--text-muted);
}

.doc-attachment-download {
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 4px;
    border-radius: 4px;
    transition: color 0.15s, background-color 0.15s;
}

.doc-attachment-download:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.08);
}

/* Chat Input Footer Controls */
#chat-input-footer {
    padding: 12px 16px;
    padding-bottom: calc(12px + var(--safe-area-bottom));
    border-top: 1px solid var(--border-color);
    background: var(--bg-sidebar);
    flex-shrink: 0;
}

.chat-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

#chat-message-input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 10px 14px;
    color: var(--text-main);
    font-size: 0.85rem;
    transition: border-color var(--transition-speed);
}

#chat-message-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

#chat-message-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.attachment-btn {
    font-size: 1.1rem;
    padding: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, background-color 0.15s;
}

.attachment-btn:hover {
    color: var(--primary-color);
    background-color: rgba(255, 255, 255, 0.05);
}

.send-btn {
    background: var(--primary-color);
    color: #ffffff;
    border: none;
    border-radius: var(--border-radius);
    padding: 10px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: background 0.15s, transform 0.1s;
}

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

.send-btn:active {
    transform: scale(0.97);
}

.send-btn:disabled {
    background: var(--border-color);
    color: var(--text-muted);
    cursor: not-allowed;
    transform: none;
}

/* ================= ATTACHMENTS PREVIEW DRAWER ================= */
.attachments-preview {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 10px;
    max-height: 180px;
    overflow-y: auto;
}

.attachment-preview-badge {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 6px 12px;
    gap: 12px;
}

.attachment-preview-details {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.attachment-preview-icon {
    font-size: 1rem;
    color: var(--primary-color);
}

.attachment-preview-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.attachment-preview-name {
    font-size: 0.78rem;
    font-weight: 600;
    color: #ffffff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-preview-size {
    font-size: 0.65rem;
    color: var(--text-muted);
}

.attachment-preview-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.quality-select {
    background: var(--bg-input);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 0.68rem;
    padding: 2px 4px;
    outline: none;
    cursor: pointer;
}

.quality-select:focus {
    border-color: var(--primary-color);
}

.attachment-preview-remove {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    transition: color 0.15s;
    line-height: 1;
}

.attachment-preview-remove:hover {
    color: var(--alert-red);
}

/* ================= TOASTS & PHOTO OVERLAYS ================= */
.toast {
    position: fixed;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    color: var(--primary-color);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 8px 18px;
    border-radius: var(--border-radius);
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    animation: toastFadeUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes toastFadeUp {
    from { opacity: 0; transform: translate(-50%, 15px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

.msg-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 10005;
    width: 300px;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    transition: opacity 0.2s, transform 0.2s;
}

.msg-toast.fade-out {
    opacity: 0;
    transform: translateY(-10px) scale(0.96);
}

.toast-icon {
    font-size: 1.3rem;
    color: var(--primary-color);
}

.toast-body {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.toast-text {
    font-size: 0.72rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.toast-close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    align-self: flex-start;
    line-height: 1;
}

.toast-close-btn:hover {
    color: #ffffff;
}

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

/* Fullscreen Photo Modal Overlay */
.fullscreen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    z-index: 20000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
    animation: overlayFadeIn 0.2s ease;
}

.overlay-container {
    position: relative;
    max-width: 90%;
    max-height: 90%;
}

.overlay-img {
    max-width: 100%;
    max-height: 85vh;
    border-radius: var(--border-radius);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    display: block;
}

.overlay-close-btn {
    position: absolute;
    top: -40px;
    right: 0;
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
}

.overlay-close-btn:hover {
    color: var(--primary-color);
}

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

/* ================= RESPONSIVE DESIGN BREAKPOINTS ================= */
/* Mobile-first approach: base styles apply to all, overridden upward */

/* ── Large Desktops (1200px+) ── */
@media (min-width: 1200px) {
    #chat-dashboard {
        max-width: 1200px;
    }
    #chat-sidebar {
        width: 300px;
    }
}

/* ── Standard Desktops / Large Tablets (900px–1199px) ── */
@media (max-width: 1100px) {
    #chat-dashboard {
        max-width: 100%;
        height: 90vh;
        height: 90dvh;
    }
    #chat-sidebar {
        width: 260px;
    }
}

/* ── Tablets (769px–900px) ── */
@media (max-width: 900px) {
    #app-container {
        padding: 0;
    }
    #chat-dashboard {
        width: 100%;
        height: 100vh;
        height: 100dvh;
        border-radius: 0;
        border: none;
        min-height: 0;
    }
    #chat-sidebar {
        width: 240px;
        min-width: 200px;
    }
    .terminal-sys-header {
        padding: 6px 10px;
        font-size: 0.65rem;
    }
    .sys-info {
        gap: 10px;
    }
    .sys-toggles {
        gap: 4px;
    }
}

/* ── Mobile Devices (≤768px) ── */
@media (max-width: 768px) {
    /* App wrapper */
    #app-container {
        padding: 0;
        align-items: flex-start;
        overflow-y: auto;
        overflow-x: hidden;
    }

    /* Auth card - scrollable on small screens */
    .auth-card {
        border-radius: 0;
        max-width: 100%;
        max-height: none;
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;
        padding: 28px 20px;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    /* Dashboard */
    #chat-dashboard {
        width: 100%;
        height: 100vh;
        height: 100dvh;
        border-radius: 0;
        border: none;
        min-height: 0;
    }

    /* Mobile sidebar takes full width */
    #chat-sidebar {
        width: 100%;
        min-width: 0;
        display: flex;
        height: 100%;
    }

    /* Chat window is hidden until contact is selected */
    #chat-window {
        width: 100%;
        display: none;
    }

    /* When chat is active on mobile */
    .mobile-chat-active #chat-sidebar {
        display: none;
    }
    .mobile-chat-active #chat-window {
        display: flex;
    }

    /* Show mobile back button */
    #btn-mobile-back {
        display: inline-flex;
    }

    /* System header - simplified for mobile */
    .terminal-sys-header {
        padding: 6px 10px;
        font-size: 0.6rem;
        flex-wrap: wrap;
        gap: 4px;
    }
    .sys-title {
        font-size: 0.6rem;
    }
    .sys-info {
        display: none; /* hide verbose info on mobile */
    }
    .sys-toggles {
        gap: 3px;
    }
    .toggle-btn {
        padding: 3px 6px;
        font-size: 0.7rem;
    }

    /* Contacts list */
    .contact-item {
        padding: 12px 14px;
    }
    .contact-username {
        font-size: 0.9rem;
    }

    /* Search input */
    #contact-search-input {
        font-size: 0.9rem;
        padding: 10px 10px 10px 32px;
    }
    
    /* Hide send text label, show icon only */
    .send-text {
        display: none;
    }
    .send-btn {
        padding: 10px 14px;
        min-width: 44px;
        min-height: 44px;
    }

    /* Chat input */
    #chat-message-input {
        font-size: 0.9rem;
        padding: 10px 12px;
        min-height: 44px;
    }
    .attachment-btn {
        min-width: 44px;
        min-height: 44px;
        font-size: 1.2rem;
    }

    /* Chat header */
    #chat-room-header {
        padding: 10px 12px;
    }
    .encryption-tag {
        font-size: 0.65rem;
        padding: 2px 6px;
    }

    /* Messages feed */
    .messages-feed {
        padding: 12px;
        gap: 10px;
    }
    .message-bubble {
        max-width: 85%;
        font-size: 0.85rem;
    }
    .message-img-attachment-group {
        width: 220px;
    }

    /* Terminal logs panel */
    .terminal-logs-panel {
        height: 160px;
    }

    /* Toast notifications */
    .msg-toast {
        right: 10px;
        left: 10px;
        width: auto;
        top: 10px;
    }
    .toast {
        bottom: 15px;
        left: 50%;
        width: calc(100% - 30px);
        text-align: center;
    }

    /* Boot screen */
    .boot-terminal {
        padding: 12px;
        max-height: 85vh;
        max-height: 85dvh;
    }
    .boot-header {
        font-size: 0.7rem;
    }
    .boot-log-content {
        font-size: 0.7rem;
    }
    .boot-progress-wrapper {
        font-size: 0.7rem;
        gap: 8px;
    }

    /* Auth form elements */
    .input-wrapper input {
        font-size: 0.9rem;
        padding: 13px 12px 13px 38px;
        min-height: 48px;
    }
    .submit-btn {
        padding: 14px;
        font-size: 0.9rem;
        min-height: 48px;
    }
    .tab-btn {
        padding: 12px 4px;
        font-size: 0.8rem;
    }
    .terminal-logo h1 {
        font-size: 1.6rem;
    }
    .logo-icon {
        font-size: 2rem;
    }

    /* Sidebar user header */
    .sidebar-user-header {
        padding: 12px 14px;
    }
    .user-details h2 {
        font-size: 0.95rem;
    }
}

/* ── Small Mobile (≤480px) ── */
@media (max-width: 480px) {
    .auth-card {
        padding: 22px 16px;
    }
    .terminal-logo h1 {
        font-size: 1.4rem;
    }
    .logo-icon {
        font-size: 1.8rem;
    }
    .auth-subtitle {
        font-size: 0.78rem;
    }
    .seeded-keys-box li {
        flex-direction: column;
        align-items: flex-start;
        gap: 3px;
    }
    .message-bubble {
        max-width: 90%;
        font-size: 0.82rem;
    }
    .message-img-attachment-group {
        width: 180px;
    }
    .messages-feed {
        padding: 10px;
    }
    .terminal-sys-header {
        padding: 5px 8px;
    }
    .sys-title {
        font-size: 0.55rem;
    }
    /* Compact contact items */
    .contact-item {
        padding: 10px 12px;
    }
    .search-contact-box {
        padding: 8px 10px;
    }
    .contacts-panel .section-title {
        padding: 8px 12px 4px;
    }
    /* Compact stats bar */
    .global-stats-bar {
        font-size: 0.62rem;
        padding: 5px 12px;
    }
    /* Boot screen */
    .boot-screen {
        padding: 15px;
    }
    .boot-progress-label {
        display: none;
    }
}

/* ── Extra Small (≤360px) – very small phones ── */
@media (max-width: 360px) {
    .auth-card {
        padding: 18px 12px;
    }
    .terminal-logo h1 {
        font-size: 1.25rem;
    }
    .logo-icon {
        font-size: 1.6rem;
    }
    .tab-btn {
        font-size: 0.72rem;
    }
    .tab-btn i {
        display: none;
    }
    .submit-btn {
        font-size: 0.82rem;
        padding: 12px;
    }
    .input-wrapper input {
        font-size: 0.82rem;
    }
    .sys-title i {
        display: none;
    }
    .toggle-btn {
        padding: 2px 5px;
    }
}

/* ── Landscape Mobile (height < 500px) ── */
@media (max-height: 500px) and (orientation: landscape) {
    .auth-card {
        padding: 16px 24px;
        justify-content: flex-start;
        overflow-y: auto;
    }
    .auth-header {
        margin-bottom: 12px;
    }
    .terminal-logo {
        flex-direction: row;
        gap: 10px;
        margin-bottom: 4px;
    }
    .logo-icon {
        font-size: 1.4rem;
        margin-bottom: 0;
    }
    .terminal-logo h1 {
        font-size: 1.2rem;
    }
    .logo-version {
        display: none;
    }
    .auth-subtitle {
        font-size: 0.72rem;
        margin-top: 4px;
    }
    .seeded-keys-box {
        margin-top: 10px;
        padding-top: 10px;
    }
    #chat-dashboard {
        height: 100dvh;
    }
    .terminal-logs-panel {
        height: 120px;
    }
}

/* ── Touch device enhancements ── */
@media (hover: none) and (pointer: coarse) {
    /* Increase tap targets */
    .contact-item {
        min-height: 52px;
    }
    .tab-btn {
        min-height: 44px;
    }
    .toggle-btn {
        min-width: 36px;
        min-height: 36px;
    }
    #btn-copy-uuid,
    #btn-disconnect {
        min-width: 36px;
        min-height: 36px;
    }
    .log-tab-btn {
        min-height: 32px;
        padding: 4px 8px;
    }
    .demo-key {
        padding: 5px 10px;
        font-size: 0.8rem;
    }
}

/* Helper hidden utility */
.hidden {
    display: none !important;
}

/* Verified Account Blue Checkmark Badge */
/* Verified Account Green Checkmark Badge */
.verified-badge {
    color: var(--primary-color);
    font-size: 0.9em;
    margin-left: 5px;
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    filter: drop-shadow(0 0 2px var(--primary-glow));
}

.verified-badge i {
    animation: verifiedPulse 2.5s infinite ease-in-out;
}

@keyframes verifiedPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.08);
    }
}

/* ================= RETRO OVERLAY & CHAT SCREEN OVERHAUL ================= */

/* CRT scanlines */
.crt-scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(
        rgba(18, 16, 16, 0) 50%, 
        rgba(0, 0, 0, 0.15) 50%
    );
    background-size: 100% 3.5px;
    z-index: 99999;
    pointer-events: none;
}
body.scanlines-active .crt-scanlines {
    display: block;
}
body:not(.scanlines-active) .crt-scanlines {
    display: none;
}

/* Screen flicker simulation */
.crt-flicker {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(18, 16, 16, 0.08);
    opacity: 0;
    z-index: 99998;
    pointer-events: none;
    animation: crt-flicker-anim 0.25s infinite;
}
body.scanlines-active .crt-flicker {
    display: block;
}
body:not(.scanlines-active) .crt-flicker {
    display: none;
}
@keyframes crt-flicker-anim {
    0% { opacity: 0.012; }
    50% { opacity: 0.006; }
    100% { opacity: 0.012; }
}

/* Matrix canvas */
#matrix-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
    pointer-events: none;
    opacity: 0.07;
    transition: opacity 0.3s ease;
}
body.matrix-inactive #matrix-canvas {
    opacity: 0;
}

/* Boot Screen Overlay */
.boot-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #010402;
    z-index: 999999;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: var(--font-mono);
    color: var(--primary-color);
    padding: 30px;
    box-sizing: border-box;
}
.boot-terminal {
    width: 100%;
    max-width: 800px;
    height: 100%;
    max-height: 520px;
    border: 1px solid var(--border-color);
    background-color: #020703;
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-shadow: 0 0 30px rgba(61, 252, 92, 0.15);
    border-radius: var(--border-radius);
}
.boot-header {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    margin-bottom: 15px;
    font-size: 0.8rem;
}
.boot-title {
    font-weight: bold;
    text-shadow: 0 0 5px var(--primary-glow);
}
.boot-status {
    animation: blink-caret 1s infinite steps(1);
}
.boot-log-content {
    flex: 1;
    overflow-y: auto;
    font-size: 0.78rem;
    line-height: 1.45;
    white-space: pre-wrap;
    margin-bottom: 20px;
    color: #adffbc;
    scrollbar-width: none;
}
.boot-log-content::-webkit-scrollbar {
    display: none;
}
.boot-footer {
    border-top: 1px solid var(--border-color);
    padding-top: 15px;
}
.boot-progress-wrapper {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 0.78rem;
}
.boot-progress-label {
    flex-shrink: 0;
}
.boot-progress-bar-container {
    flex: 1;
    height: 10px;
    background: #010301;
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}
.boot-progress-bar {
    height: 100%;
    background: var(--primary-color);
    width: 0%;
    transition: width 0.05s linear;
    box-shadow: 0 0 8px var(--primary-color);
}
#boot-progress-percentage {
    width: 45px;
    text-align: right;
    font-weight: bold;
}

/* System Header Bar inside Dashboard */
.terminal-sys-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-color);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--primary-color);
    flex-shrink: 0;
    box-sizing: border-box;
}
.sys-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: bold;
    text-shadow: 0 0 5px var(--primary-glow);
}
.pulse-indicator {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: var(--primary-color);
    box-shadow: 0 0 8px var(--primary-color);
    animation: sysPulse 2s infinite ease-in-out;
}
@keyframes sysPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.4; }
}
.sys-info {
    display: flex;
    gap: 20px;
}
.sys-info-item {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--text-muted);
}
.sys-toggles {
    display: flex;
    gap: 6px;
}
.toggle-btn {
    background: #010301;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 3px 7px;
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}
.toggle-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    box-shadow: 0 0 4px var(--primary-glow);
}
.toggle-btn.active {
    color: var(--primary-color);
    border-color: var(--primary-color);
    box-shadow: 0 0 6px var(--primary-glow);
    background: rgba(61, 252, 92, 0.08);
}

/* Dashboard body sub-grid container */
.dashboard-body {
    display: flex;
    flex: 1;
    width: 100%;
    overflow: hidden;
    position: relative;
}

/* Sidebar Live Logs Feed styling */
.terminal-logs-panel {
    height: 220px;
    border-top: 1px solid var(--border-color);
    background: #020603;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 8px 12px;
    box-sizing: border-box;
}
.terminal-logs-panel .section-title {
    padding: 0 0 6px 0;
}
.terminal-logs-container {
    flex: 1;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    line-height: 1.4;
    color: #4e9759;
    padding-right: 4px;
}
.terminal-log-line {
    margin-bottom: 3px;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}
.terminal-log-line .log-time {
    color: #1b5324;
    margin-right: 6px;
}
.terminal-log-line.info {
    color: #4e9759;
}
.terminal-log-line.success {
    color: var(--primary-color);
    text-shadow: 0 0 3px rgba(61, 252, 92, 0.3);
}
.terminal-log-line.warn {
    color: var(--alert-amber);
    text-shadow: 0 0 3px rgba(255, 170, 0, 0.3);
}

/* Retro styling adjustments for message bubbles */
.message-bubble {
    border-radius: var(--border-radius) !important;
    border: 1px solid var(--border-color) !important;
    font-family: var(--font-mono);
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}
.message-bubble.sent {
    background: rgba(61, 252, 92, 0.05) !important;
    border-color: rgba(61, 252, 92, 0.25) !important;
    box-shadow: 0 0 8px rgba(61, 252, 92, 0.04) !important;
    color: #adffbc !important;
}
.message-bubble.received {
    background: rgba(255, 255, 255, 0.015) !important;
    border-color: var(--border-color) !important;
    color: #adffbc !important;
}
.message-bubble.sent .msg-timestamp {
    color: #4e9759 !important;
}
.message-bubble.received .msg-timestamp {
    color: #2b5f33 !important;
}

/* Glowing text shadows */
.neon-text-green, .terminal-logo h1, .welcome-logo, #active-contact-name, .logo-icon {
    text-shadow: 0 0 8px var(--primary-glow);
}

/* Glassmorphism overrides to fit retro-terminal look */
.glassmorphic {
    background: var(--bg-panel) !important;
    border: 1px solid var(--border-color) !important;
    box-shadow: 0 0 25px rgba(61, 252, 92, 0.08) !important;
}
.glassmorphic:hover {
    border-color: var(--border-hover) !important;
    box-shadow: 0 0 30px rgba(61, 252, 92, 0.12) !important;
}

/* Inputs and interactive elements */
input[type="text"], input[type="password"] {
    font-family: var(--font-mono) !important;
    text-shadow: 0 0 3px rgba(61, 252, 92, 0.2);
}
input[type="text"]::placeholder {
    color: rgba(78, 151, 89, 0.5) !important;
}

/* Glow buttons */
.glowing-btn-green {
    box-shadow: 0 0 10px rgba(61, 252, 92, 0.15);
}
.glowing-btn-green:hover {
    box-shadow: 0 0 15px rgba(61, 252, 92, 0.35);
}
.glowing-btn-purple {
    background: #7c3aed !important;
    box-shadow: 0 0 10px rgba(124, 58, 237, 0.15);
}
.glowing-btn-purple:hover {
    background: #8b5cf6 !important;
    box-shadow: 0 0 15px rgba(124, 58, 237, 0.35);
}

/* Scramble effect overlay */
.scramble-letter {
    display: inline-block;
    transition: transform 0.1s ease;
}

/* Sound chime loader alerts */
@keyframes blink-caret {
    0%, 100% { border-color: transparent; }
    50% { border-color: var(--primary-color); }
}

/* ================= AMBER & CYBERPUNK THEMES ================= */

body.theme-amber {
    --bg-color: #080300;
    --bg-sidebar: #0e0600;
    --bg-panel: #140800;
    --bg-input: #060200;
    
    --primary-color: #ff8800; /* Warm Amber */
    --primary-hover: #ffa533;
    --primary-dim: #5c2c00;
    --primary-glow: rgba(255, 136, 0, 0.45);
    
    --border-color: #4c1d00;
    --border-hover: #753000;
    
    --text-main: #ffca80;
    --text-muted: #995c2b;
    --text-dark: #060200;
    
    --bubble-sent: rgba(255, 136, 0, 0.05);
    --bubble-received: rgba(255, 255, 255, 0.015);
    
    --success-green: #ff8800;
    --alert-red: #ff3333;
    --alert-amber: #ffaa00;
}

body.theme-cyberpunk {
    --bg-color: #0c0214;
    --bg-sidebar: #13031f;
    --bg-panel: #1b042b;
    --bg-input: #09010f;
    
    --primary-color: #ff007f; /* Neon Magenta */
    --primary-hover: #ff3399;
    --primary-dim: #660033;
    --primary-glow: rgba(255, 0, 127, 0.45);
    
    --border-color: #00f0ff; /* Neon Cyan */
    --border-hover: #33f3ff;
    
    --text-main: #e0d0f0;
    --text-muted: #a080c0;
    --text-dark: #09010f;
    
    --bubble-sent: rgba(255, 0, 127, 0.08);
    --bubble-received: rgba(0, 240, 255, 0.03);
    
    --success-green: #00ff66;
    --alert-red: #ff3333;
    --alert-amber: #ffaa00;
}

/* Theme overrides for specific styling components */
body.theme-amber .terminal-input-wrapper {
    background: #040100;
}
body.theme-cyberpunk .terminal-input-wrapper {
    background: #05000a;
}
body.theme-amber .log-tab-btn.active {
    background: rgba(255, 136, 0, 0.08);
}
body.theme-cyberpunk .log-tab-btn.active {
    background: rgba(255, 0, 127, 0.08);
}

/* ================= TABS & CLI LAYOUTS ================= */

.log-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 4px;
    margin-bottom: 6px;
    flex-shrink: 0;
}
.log-tabs {
    display: flex;
    gap: 8px;
}
.log-tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.65rem;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 2px;
    transition: all 0.15s ease;
}
.log-tab-btn:hover {
    color: var(--primary-color);
}
.log-tab-btn.active {
    color: var(--primary-color);
    background: rgba(61, 252, 92, 0.08);
    box-shadow: 0 0 4px var(--primary-glow);
    border: 1px solid var(--border-color);
}

/* Console tab wrapper */
.terminal-console-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}
.terminal-console-output {
    flex: 1;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    line-height: 1.4;
    color: var(--text-main);
    margin-bottom: 4px;
    padding-right: 4px;
}
.terminal-console-line {
    margin-bottom: 3px;
    word-break: break-word;
}
.terminal-console-line.input-echo {
    color: var(--text-muted);
}
.terminal-console-line.response {
    color: var(--primary-color);
    text-shadow: 0 0 3px var(--primary-glow);
}
.terminal-console-line.error {
    color: var(--alert-red);
}

/* Input prompt line */
.terminal-input-wrapper {
    display: flex;
    align-items: center;
    background: #010301;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 2px 6px;
    flex-shrink: 0;
}
.terminal-prompt-prefix {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--primary-color);
    margin-right: 6px;
    user-select: none;
}
#cli-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 0.65rem;
    outline: none;
    padding: 0;
}

/* ================= CROSS-BROWSER & DEVICE FIXES ================= */

/* Prevent iOS Safari auto-zoom on input focus (requires font-size >= 16px on focus) */
@media (max-width: 768px) {
    input[type="text"],
    input[type="password"],
    input[type="search"],
    textarea,
    select {
        font-size: 16px !important;
    }
}

/* Smooth momentum scrolling on iOS */
.contacts-list-container,
.messages-feed,
.terminal-logs-container,
.terminal-console-output,
.boot-log-content,
.auth-card {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Prevent text selection on UI elements */
.tab-btn,
.toggle-btn,
.log-tab-btn,
.submit-btn,
.send-btn,
#btn-mobile-back,
#btn-disconnect,
#btn-copy-uuid {
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

/* Prevent double-tap zoom on interactive elements */
button, a, [role="button"] {
    touch-action: manipulation;
}

/* Fix overscroll/bounce effect on mobile */
body {
    overscroll-behavior: none;
}

/* Better input appearance on mobile */
input, button, select, textarea {
    -webkit-appearance: none;
    appearance: none;
}

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

/* Fix backdrop-filter for Safari */
.boot-screen {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

/* Ensure the boot terminal renders well on small screens */
@media (max-width: 480px) {
    .boot-terminal {
        padding: 10px;
        border-radius: 0;
    }
    .boot-screen {
        padding: 10px;
    }
}

/* Print media query - hide decorative elements */
@media print {
    .crt-scanlines,
    .crt-flicker,
    #matrix-canvas,
    .vignette-overlay,
    .boot-screen {
        display: none !important;
    }
}
