
:root {
    --bg-color: #f3f4f6;
    --card-bg: #ffffff;
    --text-color: #1f2937;
    --text-muted: #6b7280;
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --input-border: #d1d5db;
    --input-bg: #ffffff;

    --peer-msg-bg: #e5e7eb;          
    --peer-msg-text: #1f2937;       
    --peer-msg-time: #6b7280;      
    
    --my-msg-bg: #0077ff;           
    --my-msg-text: #ffffff;
    --my-msg-time: rgba(255, 255, 255, 0.75);
}


:root.dark-theme,
:root.dark,
body.dark,
[data-theme="dark"] {
    --bg-color: #111827;
    --card-bg: #1f2937;
    --text-color: #f9fafb;
    --text-muted: #9ca3af;
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --input-border: #374151;
    --input-bg: #111827;


    --peer-msg-bg: #2a3749;         
    --peer-msg-text: #ffffff;        
    --peer-msg-time: rgba(255, 255, 255, 0.65);
    
    --my-msg-bg: #0077ff;
    --my-msg-text: #ffffff;
    --my-msg-time: rgba(255, 255, 255, 0.75);
}


@media (prefers-color-scheme: dark) {
    :root:not(.light-theme) {
        --bg-color: #111827;
        --card-bg: #1f2937;
        --text-color: #f9fafb;
        --text-muted: #9ca3af;
        --primary-color: #3b82f6;
        --input-border: #374151;
        --input-bg: #111827;

        --peer-msg-bg: #2a3749;
        --peer-msg-text: #ffffff;
        --peer-msg-time: rgba(255, 255, 255, 0.65);

        --my-msg-bg: #0077ff;
        --my-msg-text: #ffffff;
        --my-msg-time: rgba(255, 255, 255, 0.75);
    }
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    position: fixed; 
    top: 0;
    left: 0;
    overflow: hidden !important;
    overscroll-behavior: none !important; 
    touch-action: none; 
    background-color: var(--bg-color);
    color: var(--text-color);
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
}

.theme-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--input-border, rgba(255, 255, 255, 0.1));
    background: var(--card-bg, #1e293b);
    cursor: pointer;
    z-index: 999;
    

    display: flex;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;          
    margin: 0 !important;
    line-height: 1 !important;       
    font-size: 20px;                
    
    transition: transform 0.2s ease, background-color 0.3s ease;
}

.theme-btn:hover {
    transform: scale(1.08);
}
.screen {
    display: flex;
    width: 100%;
    padding: 20px;
    justify-content: center;
}

.card {
    background-color: var(--card-bg);
    padding: 40px 30px;
    border-radius: 20px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.05);
    text-align: center;
    max-width: 440px;
    width: 100%;
    transition: background-color 0.3s;
}

.logo-image {
    display: block;
    width: 120px;
    height: 120px;
    object-fit: contain;
    margin: 0 auto 15px;
    background: none !important;
    border: none !important;
    box-shadow: none !important;
}

h1 {
    font-size: 22px;
    margin-bottom: 12px;
    white-space: nowrap;
    word-break: keep-all;
}

p { color: var(--text-muted); font-size: 15px; margin-bottom: 25px; line-height: 1.5; }


.code-input-style {
    font-size: 28px;
    letter-spacing: 12px;
    text-align: center;
    font-family: monospace;
    font-weight: bold;
    padding-left: 25px;
}

.input-field {
    width: 100%;
    padding: 15px;
    border: 1px solid var(--input-border);
    border-radius: 12px;
    background-color: var(--input-bg);
    color: var(--text-color);
    font-size: 16px;
    margin-bottom: 20px;
    outline: none;
}
.input-field:focus { border-color: var(--primary-color); }

button:focus,
input:focus {
    outline: none !important;
}

button:focus-visible,
input:focus-visible {
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5);
    outline: none;
}

.hint-message {
    display: none;
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.4;
    text-align: center;
    background-color: rgba(239, 68, 68, 0.1);
    color: #EF4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

.input-error {
    border-color: #EF4444 !important;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.4) !important;
    animation: pulse-shake 0.5s ease-in-out infinite alternate;
}

@keyframes pulse-shake {
    0% { transform: translateX(0); box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.6) !important; }
    25% { transform: translateX(-4px); }
    50% { transform: translateX(4px); }
    75% { transform: translateX(-2px); }
    100% { transform: translateX(0); box-shadow: 0 0 0 5px rgba(239, 68, 68, 0.1) !important; }
}

button:active {
    opacity: 0.8;
    transform: scale(0.98);
}

.primary-btn {
    width: 100%;
    padding: 15px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}
.primary-btn:hover { background-color: var(--primary-hover); }
.hint { font-size: 12px; margin-top: 15px; margin-bottom: 0;}


#app-screen { display: none; }
#dashboard-step { display: none; } 
#chat-window-step { display: none; } 

@media (display-mode: standalone) {
    #install-screen { display: none !important; }
    #app-screen { display: flex; }
}


.chat-header {
    width: 100%;
    padding: 10px 15px;
    border-bottom: 1px solid var(--input-border);
    background: var(--bg-color);
    box-sizing: border-box;
}

.search-input {
    width: 100%;
    padding: 10px 15px;
    border-radius: 20px;
    border: 1px solid var(--input-border);
    background: var(--input-bg);
    color: var(--text-color);
    font-size: 14px;
    outline: none;
}

.chat-list {
    flex: 1;
    width: 100%;
    overflow-y: auto;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 12px; 
    padding: 10px 14px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.chat-item:hover {
    background-color: rgba(255, 255, 255, 0.04);
}

.chat-avatar-container {
    position: relative;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}

.chat-avatar {
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    flex-shrink: 0;
    border-radius: 50%;
    background: #0077FF;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 16px;
}


.chat-avatar-container .chat-avatar {
    width: 100%;
    height: 100%;
    min-width: auto;
    min-height: auto;
}
.chat-info {
    flex: 1;
    min-width: 0;
}

.chat-top-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 4px;
}

.chat-name {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-time {
    font-size: 12px;
    color: var(--text-muted);
    margin-left: 8px;
}

.chat-bottom-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-last-message {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.unread-badge {
    background: #0077FF;
    color: white;
    font-size: 11px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 8px;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 30px;
    font-size: 14px;
}



.chat-window-layout {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    height: 100vh;
    height: 100dvh; 
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}


#chat-window-step {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    position: fixed;
    top: 0;
    left: 0;
    background: var(--bg-color);
    box-sizing: border-box;
    touch-action: none; 
}

.chat-room-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    padding: 12px 15px;
    background: var(--bg-color);
    border-bottom: 1px solid var(--input-border);
    width: 100%;
    box-sizing: border-box;
    z-index: 10;
    touch-action: none; 
}
.back-btn {
    background: none;
    border: none;
    color: #0077FF;
    font-size: 22px;
    cursor: pointer;
    margin-right: 15px;
    padding: 0 5px;
}

.chat-room-name {
    font-weight: 600;
    font-size: 16px;
    color: var(--text-color);
}

.chat-room-tag {
    font-size: 12px;
    color: var(--text-muted);
}


#messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain; 
    touch-action: pan-y !important; 
}

.message-bubble {
    max-width: 75%;
    padding: 8px 12px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.4;
    word-break: break-word;
    box-sizing: border-box;
}

.chat-input-area {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    padding: 10px 15px;
    background: var(--bg-color);
    border-top: 1px solid var(--input-border);
    width: 100%;
    box-sizing: border-box;
    z-index: 10;
    touch-action: none; 
}

.msg-status {
    font-size: 11px;
    margin-left: 4px;
    display: inline-block;
    vertical-align: middle;
}

.msg-status.read {
    color: #38bdf8;
    font-weight: bold;
}

.msg-status.unread {
    color: var(--my-msg-time, rgba(255, 255, 255, 0.7)); 
}


.message-bubble.my-msg {
    align-self: flex-end !important;
    margin-left: auto !important;
    margin-right: 0 !important;
    background-color: var(--my-msg-bg) !important;
    color: var(--my-msg-text) !important;
    border-bottom-right-radius: 2px;
}


.message-bubble.peer-msg {
    align-self: flex-start !important;
    margin-right: auto !important;
    margin-left: 0 !important;
    background-color: var(--peer-msg-bg) !important;
    color: var(--peer-msg-text) !important;
    border-bottom-left-radius: 2px;
}

.peer-msg .msg-time { color: var(--peer-msg-time); }

.my-msg .msg-time { color: var(--my-msg-time); }

.msg-time {
    font-size: 10px;
    margin-left: 8px;
    float: right;
    margin-top: 4px;
}

.message-input-area {
    display: flex;
    padding: 10px 15px;
    border-top: 1px solid var(--input-border);
    background: var(--bg-color);
    gap: 10px;
    width: 100%;
    box-sizing: border-box;
}

.message-input-area input {
    flex: 1;
    padding: 10px 15px;
    border-radius: 20px;
    border: 1px solid var(--input-border);
    background: var(--input-bg);
    color: var(--text-color);
    outline: none;
}

.send-btn {
    background: #0077FF;
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}



.dashboard-header-row {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 10px 15px;
    gap: 10px;
    background: var(--bg-color);
    border-bottom: 1px solid var(--input-border);
    box-sizing: border-box;
}

.search-input-wrapper {
    flex: 1;
}

.dots-menu-btn {
    background: var(--card-bg);
    border: 1px solid var(--input-border);
    color: var(--text-color);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background-color 0.2s;
}

.dots-menu-btn:hover {
    background: rgba(0, 119, 255, 0.1);
}

.menu-dropdown-container {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 48px;
    background-color: var(--card-bg);
    min-width: 170px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    border: 1px solid var(--input-border);
    border-radius: 12px;
    z-index: 1000;
    overflow: hidden;
    flex-direction: column;
}

.dropdown-item {
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    padding: 12px 16px;
    font-size: 14px;
    color: var(--text-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}

.dropdown-item:hover {
    background: rgba(0, 119, 255, 0.08);
}


.modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.6) !important;
    z-index: 99999 !important; 
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}
.modal-card {
    position: relative;
    z-index: 100000;
    background: var(--card-bg, #1e1e1e); 
    border-radius: 20px;
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    padding: 24px;
    box-sizing: border-box;
    color: var(--text-color, #ffffff);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h2 {
    font-size: 18px;
    margin: 0;
    color: var(--text-color);
}

.close-modal-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
}

.modal-label {
    display: block;
    text-align: left;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 6px;
    margin-top: 10px;
}

.modal-divider {
    border: none;
    border-top: 1px solid var(--input-border);
    margin: 20px 0;
}

.secondary-btn {
    width: 100%;
    padding: 12px;
    background-color: transparent;
    color: var(--text-color);
    border: 1px solid var(--input-border);
    border-radius: 12px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    margin-bottom: 10px;
    transition: all 0.2s;
}

.secondary-btn:hover {
    background: rgba(0, 119, 255, 0.05);
    border-color: #0077FF;
}

.danger-btn {
    width: 100%;
    padding: 12px;
    background-color: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.danger-btn:hover {
    background-color: #ef4444;
    color: white;
}



.peer-online-status {
    margin-left: 8px;
    font-size: 13px;
    font-weight: normal;
}
.peer-online-status.online {
    color: #10b981; 
}
.peer-online-status.offline {
    color: var(--text-muted, #9ca3af);
}


.typing-indicator-container {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 13px;
    color: var(--text-muted, #9ca3af);
    font-style: italic;
}


.typing-dots {
    display: inline-flex;
}


.typing-dots span {
    display: inline-block;
    animation: typingAnimation 1.4s infinite; 
    opacity: 0.2;
    font-style: normal;
    font-weight: bold;
}
.typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingAnimation {
    0% { opacity: 0.2; }
    50% { opacity: 1; }
    100% { opacity: 0.2; }
}




.online-badge {
    position: absolute;
    bottom: 0px;
    right: 0px;
    width: 13px;
    height: 13px;
    background-color: #10b981;
    border: 2px solid var(--card-bg, #1f2937); 
    border-radius: 50%;
    display: none;
    z-index: 5;
}
.online-badge.active {
    display: block !important;
}


.chat-item-typing {
    color: #3b82f6;
    font-size: 13.5px;
    font-weight: 400;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    animation: typingPulse 1.5s infinite;
}

.chat-list-typing {
    color: #3b82f6; 
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
    animation: pulseTyping 1.5s infinite;
}

@keyframes typingPulse {
    0% { opacity: 0.5; }
    50% { opacity: 1; }
    100% { opacity: 0.5; }
}


.date-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 16px 0 12px 0;
    position: relative;
    width: 100%;
}

.date-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 8%;
    right: 8%;
    height: 1px;
    background: var(--input-border, rgba(255, 255, 255, 0.08));
    z-index: 1;
}

.date-divider span {
    position: relative;
    z-index: 2;
    background-color: var(--card-bg, #1e293b);  
    color: var(--text-muted, #9ca3af);         
    font-size: 12px;
    font-weight: 500;
    padding: 3px 12px;
    border-radius: 12px;
    border: 1px solid var(--input-border, rgba(255, 255, 255, 0.06));
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}


.unread-messages-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 18px 0 12px 0;
    position: relative;
    width: 100%;
}

.unread-messages-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: rgba(59, 130, 246, 0.4);
    z-index: 1;
}

.unread-messages-divider span {
    position: relative;
    z-index: 2;
    background-color: #1e3a8a;
    color: #60a5fa;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 14px;
    border-radius: 12px;
    border: 1px solid rgba(96, 165, 250, 0.3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}


.message-bubble.new-message-highlight {
    animation: highlightPulse 3.5s ease-out forwards;
}

@keyframes highlightPulse {
    0% {
        background-color: rgba(59, 130, 246, 0.28);
        box-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
    }
    60% {
        background-color: rgba(59, 130, 246, 0.14);
    }
    100% {
        background-color: inherit;
        box-shadow: none;
    }
}



.context-menu {
    position: fixed;
    z-index: 10000;
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    padding: 4px;
    min-width: 140px;
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    background: transparent;
    border: none;
    color: #e2e8f0;
    padding: 8px 12px;
    font-size: 14px;
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease;
}

.context-menu-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #38bdf8;
}


@keyframes pulseHighlight {
    0% { background-color: rgba(56, 189, 248, 0.4); }
    100% { background-color: transparent; }
}

.highlight-message {
    animation: pulseHighlight 1.5s ease-out;
}




.reply-preview-bar {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border-left: 3px solid #3b82f6; 
    padding: 6px 12px;
    margin: 6px 12px 0 12px;
    border-radius: 6px;
    gap: 10px;
    box-sizing: border-box;
}

.reply-preview-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    text-align: left;
}

.reply-preview-sender {
    font-size: 12px;
    font-weight: 600;
    color: #3b82f6; 
    line-height: 1.2;
}

.reply-preview-text {
    font-size: 13px;
    color: var(--text-muted, #9ca3af);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.cancel-reply-btn {
    background: transparent !important;
    border: none !important;
    color: #94a3b8 !important;
    font-size: 16px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cancel-reply-btn:hover {
    color: #ef4444 !important;
}




.message-quote {
    display: flex;
    background: rgba(255, 255, 255, 0.1);
    border-left: 3px solid #60a5fa; 
    border-radius: 4px;
    padding: 4px 8px;
    margin-bottom: 6px;
    cursor: pointer;
    font-size: 13px;
    user-select: none;
    transition: background 0.2s ease;
    text-align: left;
}


.message-quote:hover {
    background: rgba(255, 255, 255, 0.18);
}

.message-quote-content {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    width: 100%;
}

.message-quote-sender {
    font-weight: 600;
    font-size: 12px;
    color: #93c5fd; 
    line-height: 1.2;
    margin-bottom: 2px;
}

.message-quote-text {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.85);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}


.message-bubble.my-msg .message-quote {
    background: rgba(0, 0, 0, 0.15);
    border-left-color: #ffffff;
}

.message-bubble.my-msg .message-quote-sender {
    color: #ffffff;
}

.message-bubble.my-msg .message-quote-text {
    color: rgba(255, 255, 255, 0.8);
}



.input-field.readonly-field {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--text-muted, #9ca3af);
}

.input-field.readonly-field:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: none;
}