/* Style.css for OncoCrew - Modern healthcare design */

:root {
    --primary-color: #4a90e2; /* Soft blue */
    --secondary-color: #f8fbff; /* Nearly white */
    --accent-color: #e3f2fd; /* Very light blue */
    --message-sent-bg: #d4e8fc; /* Lighter blue for sent messages */
    --message-received-bg: #f1f3f4; /* Light gray for received messages */
    --text-color: #2c3e50; /* Dark blue-gray for text */
    --text-light: #636e72; /* Gray for secondary text */
    --border-color: #dfe6e9; /* Light gray border */
    --success-color: #00b894; /* Green for online indicator */
    --warning-color: #fdcb6e; /* Yellow */
    --danger-color: #e17055; /* Red */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --radius: 18px;
}

/* ===== DARK MODE ===== */
[data-theme="dark"] {
    --primary-color: #4ECDC4;
    --secondary-color: #1a1a1a;
    --accent-color: #2d2d2d;
    --message-sent-bg: #2d6e6a;
    --message-received-bg: #2d2d2d;
    --text-color: #e0e0e0;
    --text-light: #a0a0a0;
    --border-color: #404040;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.3);
}

[data-theme="dark"] body {
    background-color: #1a1a1a !important;
    color: #e0e0e0 !important;
}

[data-theme="dark"] .container {
    background-color: #1a1a1a !important;
}

[data-theme="dark"] input,
[data-theme="dark"] select {
    background-color: #2d2d2d !important;
    color: #e0e0e0 !important;
    border-color: #404040 !important;
}

/* ===== GLOBAL STYLES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    width: 100%;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--secondary-color);
    color: var(--text-color);
    line-height: 1.6;
}

.container {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--secondary-color);
}

/* ===== HEADER ===== */
.app-header {
    background: var(--primary-color);
    color: white;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-md);
    flex-shrink: 0;
    z-index: 100;
}

.app-header h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.profile-photo-btn {
    background: transparent;
    border: 2px solid white;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.3s ease;
    padding: 0;
    flex-shrink: 0;
}

.profile-photo-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.profile-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

#user-name-display {
    font-weight: 600;
    font-size: 0.95rem;
}

.privacy-link {
    font-size: 0.85em;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: text-decoration 0.2s;
}

.privacy-link:hover {
    text-decoration: underline;
}

.status-indicator {
    width: 8px;
    height: 8px;
    background-color: var(--success-color);
    border-radius: 50%;
    display: inline-block;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

.theme-toggle {
    background: transparent;
    border: 2px solid white;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    padding: 0;
}

.theme-toggle:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

#logout-button {
    background-color: var(--danger-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: background-color 0.3s;
}

#logout-button:hover {
    background-color: #d63031;
}

/* ===== MAIN CONTENT AREA ===== */
.main-content {
    flex: 1;
    display: flex;
    overflow: hidden;
    background-color: var(--secondary-color);
}

/* ===== USER LIST ===== */
.user-list-container {
    background-color: var(--secondary-color);
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    max-height: 120px;
    overflow-y: auto;
}

.user-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.user-list li {
    display: flex;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-color);
    padding: 0.5rem 0.75rem;
    background-color: white;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--border-color);
}

.user-list li:hover {
    background-color: var(--accent-color);
    border-color: var(--primary-color);
}

.user-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.5rem;
    flex-shrink: 0;
}

.user-status-dot.online {
    background-color: var(--success-color);
}

.user-status-dot.offline {
    background-color: var(--text-light);
}

.user-avatar-small {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    font-weight: bold;
    font-size: 10px;
    margin-right: 0.4rem;
    flex-shrink: 0;
    overflow: hidden;
}

.user-avatar-small img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

[data-theme="dark"] .user-list li {
    background-color: #2d2d2d;
    border-color: #404040;
}

[data-theme="dark"] .user-list li:hover {
    background-color: #3a3a3a;
}

/* ===== CHATS LIST VIEW ===== */
.chats-list-view {
    width: 300px;
    background-color: white;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
}

.chats-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.chats-list-header h2 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--text-color);
}

.create-group-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: background-color 0.3s;
    white-space: nowrap;
}

.create-group-btn:hover {
    background-color: #357ab8;
}

.chats-list {
    flex: 1;
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
}

.chat-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color 0.2s;
}

.chat-item:hover {
    background-color: var(--accent-color);
}

.chat-item.active {
    background-color: var(--primary-color);
    color: white;
}

.chat-item-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin-right: 0.75rem;
    flex-shrink: 0;
    overflow: hidden;
}

.chat-item-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-item-avatar-group {
    background: linear-gradient(135deg, #4ECDC4 0%, #4a90e2 100%);
}

.chat-item-info {
    flex: 1;
    min-width: 0;
}

.chat-item-name {
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item.active .chat-item-name {
    color: white;
}

.chat-item-preview {
    font-size: 0.8rem;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 0.25rem;
}

.chat-item.active .chat-item-preview {
    color: rgba(255, 255, 255, 0.8);
}

.chat-item-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 0.25rem;
}

.chat-item-time {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-left: 0.5rem;
    white-space: nowrap;
}

.chat-item.active .chat-item-time {
    color: rgba(255, 255, 255, 0.7);
}

.chat-item-group {
    background: linear-gradient(135deg, rgba(78, 205, 196, 0.1) 0%, rgba(74, 144, 226, 0.1) 100%);
}

[data-theme="dark"] .chats-list-view {
    background-color: #2d2d2d;
    border-right-color: #404040;
}

[data-theme="dark"] .chats-list-header {
    border-bottom-color: #404040;
}

[data-theme="dark"] .chat-item {
    border-bottom-color: #404040;
}

[data-theme="dark"] .chat-item:hover {
    background-color: #3a3a3a;
}

/* ===== CHAT VIEW (CONVERSATION) ===== */
.chat-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: white;
    overflow: hidden;
}

.chat-view.hidden {
    display: none;
}

.chat-header {
    display: flex;
    align-items: center;
    padding: 1rem;
    background-color: white;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.back-btn {
    display: none;
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    margin-right: 0.5rem;
    border-radius: 6px;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

.back-btn:hover {
    background-color: var(--accent-color);
}

.chat-header-info {
    flex: 1;
}

.chat-header-name {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-color);
}

.chat-header-status {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 0.25rem;
}

.chat-details-btn {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

.chat-details-btn:hover {
    background-color: var(--accent-color);
}

.chat-details-btn.hidden {
    display: none;
}

[data-theme="dark"] .chat-header {
    background-color: #2d2d2d;
    border-bottom-color: #404040;
}

[data-theme="dark"] .back-btn:hover {
    background-color: #3a3a3a;
}

[data-theme="dark"] .chat-details-btn:hover {
    background-color: #3a3a3a;
}

/* ===== MESSAGES AREA ===== */
.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    background-color: var(--accent-color);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message-bubble {
    max-width: 70%;
    word-wrap: break-word;
    animation: fadeInUp 0.3s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-sent {
    align-self: flex-end;
    background-color: var(--message-sent-bg);
    border-radius: 18px 18px 4px 18px;
    padding: 0.75rem 1rem;
    box-shadow: var(--shadow-sm);
}

.message-received {
    align-self: flex-start;
    background-color: var(--message-received-bg);
    border-radius: 18px 18px 18px 4px;
    padding: 0.75rem 1rem;
    box-shadow: var(--shadow-sm);
}

.message-content {
    margin-bottom: 0.5rem;
    line-height: 1.5;
    color: var(--text-color);
}

.message-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 0.25rem;
}

.message-received .message-meta {
    justify-content: flex-start;
    gap: 0.75rem;
}

.sender-name {
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
    display: block;
}

.tick {
    font-size: 12px;
    margin-left: 6px;
    float: right;
    margin-top: 4px;
}

.tick-sent {
    color: #999;
}

.tick-read {
    color: #4fc3f7;
    font-weight: bold;
}

/* Message Media Display */
.message-image {
    max-width: 300px;
    max-height: 300px;
    border-radius: 8px;
    margin: 0.5rem 0;
    cursor: pointer;
    transition: transform 0.2s;
}

.message-image:hover {
    transform: scale(1.02);
}

.message-audio {
    margin: 0.5rem 0;
    width: 100%;
    max-width: 300px;
}

.message-audio audio {
    width: 100%;
    border-radius: 8px;
}

.typing-indicator {
    font-size: 13px;
    font-style: italic;
    color: #888;
    padding: 8px 16px;
    min-height: 24px;
    display: flex;
    align-items: center;
    animation: fadeIn 0.3s ease-in;
}

.typing-indicator::after {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-left: 4px;
    background-color: #888;
    border-radius: 50%;
    animation: typingDots 1.5s infinite;
}

@keyframes typingDots {
    0%, 20% {
        width: 8px;
        height: 8px;
        opacity: 0;
        transform: translateY(0);
    }
    40% {
        width: 8px;
        height: 8px;
        opacity: 1;
        transform: translateY(0);
    }
    80%, 100% {
        width: 4px;
        height: 4px;
        opacity: 0.5;
        transform: translateY(4px);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

[data-theme="dark"] .messages-area {
    background-color: #1a1a1a;
}

/* ===== MESSAGE FORM ===== */
.message-form {
    display: flex;
    padding: 1rem;
    background-color: white;
    border-top: 1px solid var(--border-color);
    gap: 0.75rem;
    align-items: center;
    flex-shrink: 0;
}

.media-btn {
    background-color: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    padding: 0;
    flex-shrink: 0;
}

.media-btn:hover {
    background-color: var(--primary-color);
    color: white;
    transform: scale(1.1);
}

.media-btn:active {
    transform: scale(0.95);
}

.voice-btn.recording {
    background-color: var(--danger-color);
    border-color: var(--danger-color);
    color: white;
    animation: pulse-recording 0.6s infinite;
}

@keyframes pulse-recording {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(225, 112, 85, 0.7);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(225, 112, 85, 0);
    }
}

#message-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 25px;
    font-size: 1rem;
    transition: border-color 0.3s, box-shadow 0.3s;
}

#message-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.25);
}

.message-form button[type="submit"] {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 25px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.1s;
    white-space: nowrap;
    flex-shrink: 0;
    font-weight: 600;
}

.message-form button[type="submit"]:hover {
    background-color: #357ab8;
    transform: translateY(-2px);
}

.message-form button[type="submit"]:active {
    transform: translateY(0);
}

.voice-warning {
    background-color: var(--warning-color);
    color: var(--text-color);
    padding: 0.75rem 1rem;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

[data-theme="dark"] .message-form {
    background-color: #2d2d2d;
    border-top-color: #404040;
}

/* ===== MODALS ===== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.4);
}

.modal.show-modal {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: white;
    padding: 2rem;
    border: 1px solid var(--border-color);
    width: 90%;
    max-width: 500px;
    border-radius: 12px;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.close-button {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
}

.close-button:hover,
.close-button:focus {
    color: black;
}

.modal-content h2 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    color: var(--text-color);
    font-size: 1.5rem;
}

.modal-content h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    color: var(--text-color);
    font-size: 1rem;
}

.modal-content input[type="text"],
.modal-content select {
    width: 100%;
    padding: 0.75rem;
    margin: 0.75rem 0;
    display: block;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-sizing: border-box;
    background-color: white;
    color: var(--text-color);
    font-size: 1rem;
}

.modal-content input[type="text"]:focus,
.modal-content select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.2);
}

.modal-content select[multiple] {
    height: 150px;
}

.modal-content button {
    background-color: var(--primary-color);
    color: white;
    padding: 0.75rem 1.5rem;
    margin: 0.75rem 0;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    width: 100%;
    font-size: 1rem;
    font-weight: 600;
    transition: background-color 0.3s;
}

.modal-content button:hover {
    background-color: #357ab8;
}

.modal-button {
    background-color: var(--primary-color);
    color: white;
    padding: 0.75rem 1.5rem;
    margin: 0.75rem 0;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    width: 100%;
    font-size: 1rem;
    font-weight: 600;
    transition: background-color 0.3s;
}

.modal-button:hover {
    background-color: #357ab8;
}

.modal-button-danger {
    background-color: var(--danger-color) !important;
}

.modal-button-danger:hover {
    background-color: #d63031 !important;
}

.leave-group-btn {
    background-color: var(--danger-color) !important;
    margin-top: 1.5rem !important;
}

.leave-group-btn:hover {
    background-color: #d63031 !important;
}

#group-members-list {
    background-color: var(--accent-color);
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    max-height: 150px;
    overflow-y: auto;
    list-style: none;
}

#group-members-list li {
    padding: 0.5rem 0;
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
}

#group-members-list li:last-child {
    border-bottom: none;
}

#group-management-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

#group-management-section select {
    width: 100%;
    margin-bottom: 0.75rem;
}

#group-management-section button {
    width: 100%;
    margin-bottom: 0.75rem;
}

#group-management-section.hidden {
    display: none;
}

.profile-preview {
    width: 120px;
    height: 120px;
    margin: 1.5rem auto;
    border-radius: 50%;
    background-color: var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    border: 3px solid var(--primary-color);
    overflow: hidden;
}

.preview-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.preview-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

[data-theme="dark"] .modal-content {
    background-color: #2d2d2d;
    border-color: #404040;
    color: #e0e0e0;
}

[data-theme="dark"] .modal-content input,
[data-theme="dark"] .modal-content select {
    background-color: #1a1a1a;
    color: #e0e0e0;
    border-color: #404040;
}

[data-theme="dark"] #group-members-list {
    background-color: #1a1a1a;
}

/* ===== LOGIN / SIGNUP PAGE STYLES ===== */

/* Login/Signup page container - centered card */
body:has(#login-form) {
    background: linear-gradient(135deg, #4ECDC4 0%, #2196F3 100%);
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

body:has(#login-form) .container {
    background: white;
    max-width: 420px;
    height: auto;
    padding: 3rem 2.5rem;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    margin: 2rem auto;
    display: flex;
    flex-direction: column;
}

body:has(#login-form) .container h1 {
    color: #4ECDC4;
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

body:has(#login-form) .container > p {
    text-align: center;
    color: var(--text-light);
    margin-bottom: 2.5rem;
    font-size: 1rem;
}

body:has(#login-form) h2 {
    color: #4ECDC4;
    text-align: center;
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    margin-top: 1rem;
    font-weight: 600;
}

body:has(#login-form) .form-group {
    margin-bottom: 1.5rem;
}

body:has(#login-form) .form-group label {
    display: block;
    margin-bottom: 0.75rem;
    color: var(--text-color);
    font-weight: 600;
    font-size: 0.95rem;
}

body:has(#login-form) .form-group input {
    width: 100%;
    padding: 0.9rem 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background-color: #f9f9f9;
}

body:has(#login-form) .form-group input:focus {
    outline: none;
    border-color: #4ECDC4;
    background-color: white;
    box-shadow: 0 0 0 3px rgba(78, 205, 196, 0.1);
}

body:has(#login-form) #login-form button[type="submit"],
body:has(#login-form) #register-form button[type="submit"] {
    width: 100%;
    background: linear-gradient(135deg, #4ECDC4 0%, #2196F3 100%);
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 1rem;
    box-shadow: 0 4px 15px rgba(78, 205, 196, 0.3);
}

body:has(#login-form) #login-form button[type="submit"]:hover,
body:has(#login-form) #register-form button[type="submit"]:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(78, 205, 196, 0.4);
}

body:has(#login-form) #login-form button[type="submit"]:active,
body:has(#login-form) #register-form button[type="submit"]:active {
    transform: translateY(0);
}

body:has(#login-form) #login-form p,
body:has(#login-form) #register-form p {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--text-light);
    font-size: 0.9rem;
}

body:has(#login-form) #login-form a,
body:has(#login-form) #register-form a {
    color: #4ECDC4;
    text-decoration: none;
    font-weight: 700;
    transition: color 0.3s ease;
}

body:has(#login-form) #login-form a:hover,
body:has(#login-form) #register-form a:hover {
    color: #2196F3;
    text-decoration: underline;
}

#signup-form.hidden {
    display: none !important;
}

[data-theme="dark"] body:has(#login-form) {
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
}

[data-theme="dark"] body:has(#login-form) .container {
    background-color: #2d2d2d;
}

[data-theme="dark"] body:has(#login-form) .container h1 {
    color: #4ECDC4;
}

[data-theme="dark"] body:has(#login-form) .form-group input {
    background-color: #1a1a1a;
    color: #e0e0e0;
    border-color: #404040;
}

[data-theme="dark"] body:has(#login-form) .form-group input:focus {
    background-color: #2d2d2d;
    border-color: #4ECDC4;
}

/* ===== UTILITY CLASSES ===== */
.hidden {
    display: none !important;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    .chats-list-view {
        width: 250px;
    }

    .message-bubble {
        max-width: 85%;
    }

    .app-header {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .header-right {
        gap: 0.5rem;
    }

    #user-name-display {
        font-size: 0.85rem;
    }

    .modal-content {
        width: 95%;
    }
}

@media (max-width: 600px) {
    .back-btn {
        display: inline-flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        width: auto !important;
        height: auto !important;
        background: var(--primary-color, #6366f1) !important;
        color: white !important;
        padding: 0.5rem 0.8rem !important;
        border-radius: 6px !important;
    }
    .chats-list-view {
        display: flex;
        position: absolute;
        left: 0;
        top: 60px;
        width: 100%;
        height: calc(100% - 60px);
        z-index: 50;
        background: var(--bg-color, #fff);
    }

    .chats-list-view.hidden {
        display: none;
    }

    .chat-view {
        display: flex;
        flex-direction: column;
        position: fixed;
        left: 0;
        top: 0;
        width: 100%;
        height: 100dvh;
        z-index: 60;
        background: var(--bg-color, #fff);
        overflow: hidden;
    }

    .chat-view .messages-area {
        flex: 1 1 auto;
        overflow-y: auto;
        min-height: 0;
    }

    .chat-view .message-form {
        flex: 0 0 auto;
        padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    }

    .chat-view.hidden {
        display: none;
    }

    .message-bubble {
        max-width: 90%;
    }

    .app-header h1 {
        font-size: 1.25rem;
    }

    .header-right {
        gap: 0.25rem;
    }

    .profile-photo-btn,
    .theme-toggle {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    #logout-button {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }

    .modal-content {
        width: 95%;
        padding: 1.5rem;
    }
}

/* ===== NOTIFICATION BELL BUTTON STYLING ===== */
.notifications-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    transition: all 0.3s ease;
}

.notifications-btn.notifications-on {
    color: #4ECDC4;
    opacity: 1;
}

.notifications-btn.notifications-off {
    color: #999;
    opacity: 0.6;
}

.notifications-btn:hover {
    transform: scale(1.1);
}

/* ===== T002: TAB NAVIGATION & LAYOUT ===== */

/* Tab Content Container - holds all three tabs */
.tab-content-container {
    flex: 1;
    display: flex;
    overflow: hidden;
    background-color: var(--secondary-color);
}

/* Individual tab content */
.tab-content {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
    background-color: var(--secondary-color);
}

.tab-content.active {
    display: flex;
}

/* Bottom Navigation Bar */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background-color: white;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 200;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
}

.nav-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-light);
    transition: all 0.3s ease;
    padding: 0.5rem;
    height: 100%;
}

.nav-tab:hover {
    color: var(--primary-color);
    background-color: rgba(74, 144, 226, 0.05);
}

.nav-tab.active {
    color: #4ECDC4;
    border-top: 3px solid #4ECDC4;
}

.nav-icon {
    font-size: 1.5rem;
    display: block;
}

.nav-label {
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
}

[data-theme="dark"] .bottom-nav {
    background-color: #2d2d2d;
    border-top-color: #404040;
}

[data-theme="dark"] .nav-tab {
    color: #a0a0a0;
}

[data-theme="dark"] .nav-tab:hover {
    background-color: rgba(78, 205, 196, 0.1);
}

/* Contacts List View */
.contacts-list-view {
    width: 100%;
    background-color: white;
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.contacts-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.contacts-list-header h2 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--text-color);
}

.contacts-list {
    flex: 1;
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
}

.contact-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color 0.2s;
}

.contact-item:hover {
    background-color: var(--accent-color);
}

.contact-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin-right: 0.75rem;
    flex-shrink: 0;
    overflow: hidden;
}

.contact-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.contact-info {
    flex: 1;
    min-width: 0;
}

.contact-name {
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-status {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 0.25rem;
}

.contact-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 0.5rem;
}

.contact-status-dot.online {
    background-color: var(--success-color);
}

.contact-status-dot.offline {
    background-color: var(--text-light);
}

[data-theme="dark"] .contacts-list-view {
    background-color: #2d2d2d;
}

[data-theme="dark"] .contacts-list-header {
    border-bottom-color: #404040;
}

[data-theme="dark"] .contact-item {
    border-bottom-color: #404040;
}

[data-theme="dark"] .contact-item:hover {
    background-color: #3a3a3a;
}

/* Profile View */
.profile-view {
    width: 100%;
    background-color: white;
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.profile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.profile-header h2 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--text-color);
}

.profile-content {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
}

[data-theme="dark"] .profile-view {
    background-color: #2d2d2d;
}

[data-theme="dark"] .profile-header {
    border-bottom-color: #404040;
}

/* ===== T002: MESSAGE BUBBLE ENHANCEMENTS ===== */

/* Message grouping - hide avatar/timestamp on grouped messages */
.message-bubble.grouped {
    margin-top: -0.5rem;
}

.message-bubble.grouped .sender-name {
    display: none;
}

.message-bubble.grouped .message-meta {
    display: none;
}

/* Date separator for messages from different days */
.date-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 1rem 0;
    gap: 0.75rem;
}

.date-separator::before,
.date-separator::after {
    content: '';
    flex: 1;
    height: 1px;
    background-color: var(--border-color);
}

.date-separator-text {
    font-size: 0.75rem;
    color: var(--text-light);
    font-weight: 600;
    white-space: nowrap;
}

[data-theme="dark"] .date-separator::before,
[data-theme="dark"] .date-separator::after {
    background-color: #404040;
}

/* ===== RESPONSIVE: SHOW BOTTOM NAV ON MOBILE ===== */
@media (max-width: 600px) {
    .bottom-nav {
        display: flex !important;
    }

    .main-content {
        padding-bottom: 60px;
    }

    .tab-content-container {
        flex-direction: column;
    }

    .chats-list-view {
        width: 100%;
    }

    .contacts-list-view {
        width: 100%;
    }

    .profile-view {
        width: 100%;
    }
}

/* T016: BOTTOM NAVIGATION BAR STYLING */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    padding-bottom: env(safe-area-inset-bottom);
    background-color: white;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 100;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
}

.bottom-nav button {
    flex: 1;
    height: 60px;
    border: none;
    background: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: #999;
    font-size: 12px;
    transition: color 0.2s ease;
    position: relative;
}

.bottom-nav button:hover {
    color: #666;
}

.bottom-nav button .nav-icon {
    font-size: 24px;
}

.bottom-nav button .nav-label {
    font-size: 11px;
    font-weight: 500;
}

/* T017: ACTIVE TAB INDICATOR */
.bottom-nav button.active {
    color: #4ECDC4;
    border-top: 3px solid #4ECDC4;
}

.bottom-nav button.active .nav-icon {
    font-size: 24px;
}

/* T024: New chat list styles */
#new-chat-search {
    width: 100%;
    padding: 10px 14px;
    border: none;
    border-radius: 8px;
    background: #f0f0f0;
    margin: 8px;
    box-sizing: border-box;
}

#new-chat-list {
    display: flex;
    flex-direction: column;
}

.new-chat-row {
    display: flex;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
}

.new-chat-row .row-content {
    flex: 1;
    margin-left: 12px;
    overflow: hidden;
}

.new-chat-row .row-name {
    font-weight: bold;
}

.new-chat-row .row-preview {
    color: #888;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.new-chat-row .row-meta {
    text-align: right;
}

.new-chat-row .row-time {
    font-size: 12px;
    color: #888;
}

.new-chat-row .unread-badge {
    background: #4ECDC4;
    color: white;
    border-radius: 10px;
    min-width: 20px;
    height: 20px;
    line-height: 20px;
    padding: 0 6px;
    font-size: 12px;
    display: inline-block;
    margin-top: 4px;
}

/* VISIBILITY FIX: Hide old chat list sidebar, show new WhatsApp-style chat list */
#chats-tab .chats-list-view {
    display: none !important;
}

#chats-tab {
    display: flex !important;
    flex-direction: column;
    height: 100%;
}

#new-chat-search {
    position: sticky;
    top: 0;
    background-color: white;
    z-index: 10;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    width: 100%;
    box-sizing: border-box;
}

#new-chat-list {
    flex: 1;
    width: 100%;
    overflow-y: auto;
    background-color: white;
}

[data-theme="dark"] #new-chat-search {
    background-color: #2d2d2d;
    border-bottom-color: #404040;
    color: #e0e0e0;
}

[data-theme="dark"] #new-chat-list {
    background-color: #2d2d2d;
}

/* VISIBILITY FIX 2: Hide user-list-container (sibling of #chats-tab) and ensure main-content flex layout */
.user-list-container {
    display: none !important;
}

.main-content {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding-bottom: 70px;
}

/* MOBILE FIX: When conversation is open, chat-view covers top header & bottom nav */
@media (max-width: 768px) {
  #chat-view:not(.hidden) {
    z-index: 200;
  }
}

/* MOBILE FIX: Send button compact size so it fits within viewport on phones */
@media (max-width: 768px) {
  .chat-view .message-form button[type="submit"] {
    width: 44px;
    height: 44px;
    min-width: 44px;
    padding: 0;
    border-radius: 50%;
    flex-shrink: 0;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .chat-view .message-form {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    gap: 0.5rem;
  }
  .chat-view #message-input {
    min-width: 0;
    flex: 1;
  }
}


/* DESKTOP/TABLET LAYOUT: Two-column split (chat list left, conversation right) for screens >= 769px */
@media (min-width: 769px) {
  /* Hide bottom nav on desktop - it's a mobile pattern */
  .bottom-nav {
    display: none !important;
  }

  /* Remove mobile bottom padding */
  .main-content {
    padding-bottom: 0 !important;
  }

  /* Make chats-tab a horizontal flex container */
  #chats-tab.tab-content.active {
    display: flex !important;
    flex-direction: row !important;
    height: calc(100vh - 80px);
    overflow: hidden;
    padding: 0;
  }

  /* LEFT COLUMN: search + chat list, fixed width */
  .chats-left-panel {
    display: flex;
    flex-direction: column;
    width: 360px;
    flex-shrink: 0;
    border-right: 1px solid var(--border-color);
    height: 100%;
    overflow: hidden;
  }

  .chats-left-panel #new-chat-search {
    height: 40px;
    margin: 10px;
    padding: 8px 14px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background-color: #f5f5f5;
    font-size: 14px;
    box-sizing: border-box;
    flex-shrink: 0;
  }

  .chats-left-panel #new-chat-list {
    flex: 1;
    overflow-y: auto;
  }

  /* RIGHT COLUMN: conversation area, takes remaining space */
  #chats-tab > #chat-view {
    flex: 1;
    height: 100%;
    min-width: 0;
    position: relative !important;
    z-index: auto !important;
    display: flex;
  }

  /* When no conversation is selected, show placeholder */
  #chats-tab > #chat-view.hidden {
    display: flex !important;
    align-items: center;
    justify-content: center;
    background-color: #f0f2f5;
  }

  #chats-tab > #chat-view.hidden > * {
    display: none !important;
  }

  #chats-tab > #chat-view.hidden::before {
    content: "Select a chat to start messaging";
    color: #888;
    font-size: 1.1rem;
  }

  /* Hide back button on desktop - both panels always visible */
  #chats-tab > #chat-view .back-btn {
    display: none !important;
  }

  /* Hide the old chats-list-view on desktop */
  #chats-tab > #chats-list-view {
    display: none !important;
  }
}

/* ONCO: Floating Action Button for new chat (anchored to chat list area) */
.new-chat-fab {
  position: fixed;
  bottom: 90px;
  left: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4a7bf7 0%, #6b5dd6 100%);
  color: white;
  border: none;
  font-size: 28px;
  font-weight: 300;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.new-chat-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 16px rgba(0,0,0,0.3);
}

.new-chat-fab:active {
  transform: scale(0.96);
}

/* On desktop, anchor it inside the left panel instead of bottom-left of screen */
@media (min-width: 769px) {
  .new-chat-fab {
    bottom: 24px;
    left: 290px;  /* sits at bottom of 360px-wide left panel */
  }
}

/* Hide FAB when a conversation is open on mobile (chat-view full-screen) */
@media (max-width: 768px) {
  body:has(#chat-view:not(.hidden)) .new-chat-fab {
    display: none;
  }
}

/* ONCO FAB POSITION FIX: Move to bottom-right on mobile to avoid covering chat rows */
@media (max-width: 768px) {
  .new-chat-fab {
    left: auto !important;
    right: 16px !important;
    bottom: 80px !important;  /* Above bottom nav */
  }
}

/* FIX: chats-tab should only be visible when active (was being forced visible by desktop layout rules) */
#chats-tab:not(.active) {
  display: none !important;
}

/* FIX: FAB only on Chats tab */
.new-chat-fab {
  display: none !important;
}
#chats-tab.active ~ .new-chat-fab,
body:has(#chats-tab.active) .new-chat-fab {
  display: flex !important;
}

/* FIX: FAB only visible when Chats tab is active (FAB is inside .chats-left-panel inside #chats-tab) */
.new-chat-fab {
  display: none !important;
}
#chats-tab.active .new-chat-fab {
  display: flex !important;
}

/* PATCH 4 - Mute button */
.mute-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.3);
  color: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 4px 10px;
  margin-right: 6px;
  border-radius: 12px;
  transition: background 0.2s;
}
.mute-btn:hover {
  background: rgba(0,0,0,0.08);
}
.mute-btn.hidden {
  display: none !important;
}

/* PATCH 4 - B2: Rejoin banner */
.rejoin-banner {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: #fff8e1;
  border-top: 1px solid #f0d878;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 50;
}
.rejoin-text {
  color: #5d4e1a;
  font-weight: 500;
  flex: 1;
}
.rejoin-btn {
  background: linear-gradient(135deg, #4a7bf7 0%, #6b5dd6 100%);
  color: #fff;
  border: none;
  padding: 10px 24px;
  border-radius: 24px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  flex-shrink: 0;
}
.rejoin-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.25);
}

/* PATCH 4 - BLOCK 2.1: Styling for left-group rows */
.new-chat-row.left-group-row {
  opacity: 0.55;
  background: rgba(255, 200, 100, 0.05);
}
.new-chat-row.left-group-row .row-name {
  font-style: italic;
}
.new-chat-row.left-group-row .row-preview {
  color: #d97706;
  font-weight: 500;
}

/* ===== FEATURE 5 - EMOJI PICKER ===== */
#emoji-btn {
    background: transparent;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0 8px;
    line-height: 1;
}
#emoji-btn:hover {
    transform: scale(1.15);
    transition: transform 0.12s ease;
}

.emoji-panel {
    position: absolute;
    bottom: 70px;
    right: 10px;
    z-index: 1000;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    border-radius: 8px;
    --background: #ffffff;
    --border-color: #e0e0e0;
    --indicator-color: #4a90e2;
}

.emoji-panel.hidden {
    display: none !important;
}

/* Mobile: full width, anchored to bottom of viewport */
@media (max-width: 600px) {
    .emoji-panel {
        left: 0;
        right: 0;
        bottom: 60px;
        width: 100%;
        border-radius: 8px 8px 0 0;
    }
}

/* Dark mode */
body.dark-mode .emoji-panel {
    --background: #2a2a2a;
    --border-color: #444;
    --input-background-color: #1e1e1e;
    --input-border-color: #555;
    --category-emoji-active-background: #4a90e2;
}
/* ===== END FEATURE 5 ===== */

/* ===== FEATURE 6 - REPLY-TO-MESSAGE (2026-06-02) ===== */

/* Reply Preview Bar */
.reply-preview-bar {
  background: var(--accent-color);
  border-top: 2px solid var(--primary-color);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.reply-preview-bar.hidden {
  display: none !important;
}

.reply-preview-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.reply-preview-sender {
  font-weight: 600;
  color: var(--primary-color);
  font-size: 0.85rem;
}

.reply-preview-text {
  color: var(--text-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.reply-preview-cancel {
  background: transparent;
  border: none;
  color: var(--text-color);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  transition: color 0.2s;
}

.reply-preview-cancel:hover {
  color: var(--danger-color);
}

/* Message Action Popup */
.message-action-popup {
  position: fixed;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 2000;
  min-width: 120px;
  overflow: hidden;
}

.message-action-popup.hidden {
  display: none !important;
}

.action-popup-btn {
  display: block;
  width: 100%;
  padding: 12px 16px;
  background: transparent;
  border: none;
  color: var(--text-color);
  font-size: 1rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}

.action-popup-btn:hover {
  background: var(--accent-color);
}

.action-popup-btn:active {
  background: var(--message-sent-bg);
}

/* Reply Quote Block (inside message bubble) */
.reply-quote-block {
  background: var(--accent-color);
  border-left: 3px solid var(--primary-color);
  padding: 8px 12px;
  margin-bottom: 8px;
  border-radius: 4px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 0.9rem;
}

.reply-quote-sender {
  font-weight: 600;
  color: var(--primary-color);
  font-size: 0.85rem;
}

.reply-quote-text {
  color: var(--text-color);
  word-break: break-word;
  flex: 1;
}

.reply-quote-thumb {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
}

/* Message Flash Animation (highlight when scrolled to) */
@keyframes message-flash {
  0% {
    background-color: rgba(74, 144, 226, 0.3);
  }
  100% {
    background-color: transparent;
  }
}

.message-flash {
  animation: message-flash 1.5s ease-out;
}

/* Dark Mode - Reply Preview Bar */
[data-theme="dark"] .reply-preview-bar {
  background: var(--accent-color);
  border-top-color: var(--primary-color);
}

[data-theme="dark"] .reply-preview-sender {
  color: var(--primary-color);
}

[data-theme="dark"] .reply-preview-text {
  color: var(--text-color);
}

[data-theme="dark"] .reply-preview-cancel {
  color: var(--text-color);
}

[data-theme="dark"] .reply-preview-cancel:hover {
  color: var(--danger-color);
}

/* Dark Mode - Message Action Popup */
[data-theme="dark"] .message-action-popup {
  background: var(--accent-color);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .action-popup-btn {
  color: var(--text-color);
}

[data-theme="dark"] .action-popup-btn:hover {
  background: #3d3d3d;
}

[data-theme="dark"] .action-popup-btn:active {
  background: var(--message-sent-bg);
}

/* Dark Mode - Reply Quote Block */
[data-theme="dark"] .reply-quote-block {
  background: #3d3d3d;
  border-left-color: var(--primary-color);
}

[data-theme="dark"] .reply-quote-sender {
  color: var(--primary-color);
}

[data-theme="dark"] .reply-quote-text {
  color: var(--text-color);
}

/* Mobile Media Query (max-width: 600px) */
@media (max-width: 600px) {
  .reply-preview-bar {
    padding: 10px 12px;
    font-size: 0.85rem;
  }

  .reply-preview-sender {
    font-size: 0.8rem;
  }

  .reply-preview-text {
    font-size: 0.85rem;
  }

  .reply-preview-cancel {
    font-size: 1rem;
    padding: 2px 6px;
  }

  .message-action-popup {
    min-width: 100px;
    font-size: 0.95rem;
  }

  .action-popup-btn {
    padding: 10px 14px;
    font-size: 0.95rem;
  }

  .reply-quote-block {
    padding: 6px 10px;
    margin-bottom: 6px;
    font-size: 0.85rem;
    gap: 6px;
  }

  .reply-quote-thumb {
    width: 36px;
    height: 36px;
  }
}

/* ===== END FEATURE 6 ===== */

/* ============================================================
   ===== FEATURE 7 -- Edit / Delete / Forward =====
   ============================================================ */

/* --- Popup buttons (Edit / Forward / Delete) --- */
.action-popup-btn-danger {
  color: #c0392b;
}
.action-popup-btn-danger:hover {
  background: rgba(192, 57, 43, 0.1);
}

/* --- Deleted message bubble --- */
.message-bubble.message-deleted .message-content,
.message-bubble.message-deleted .message-image,
.message-bubble.message-deleted .message-audio {
  display: none !important;
}
.message-bubble.message-deleted .message-deleted-text {
  font-style: italic;
  opacity: 0.65;
  font-size: 0.92em;
  padding: 4px 0;
}
.message-bubble.message-deleted .quote-block {
  display: none !important;
}

/* --- Edited label --- */
.message-edited-label {
  font-size: 0.72em;
  opacity: 0.6;
  margin-right: 6px;
  font-style: italic;
}

/* --- Forwarded label --- */
.message-forwarded-label {
  font-size: 0.78em;
  opacity: 0.7;
  font-style: italic;
  margin-bottom: 4px;
  display: block;
}

/* --- Inline edit textarea --- */
.message-edit-textarea {
  width: 100%;
  min-height: 50px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  padding: 6px 8px;
  font: inherit;
  resize: vertical;
  box-sizing: border-box;
  background: rgba(255, 255, 255, 0.7);
}
.message-edit-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  margin-top: 4px;
}
.message-edit-actions button {
  border: none;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 0.85em;
  cursor: pointer;
}
.message-edit-save {
  background: #25d366;
  color: white;
}
.message-edit-cancel {
  background: #e0e0e0;
  color: #333;
}

/* --- Forward modal --- */
.forward-modal-content {
  max-width: 420px;
  width: 90%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}
.forward-modal-header {
  padding: 16px 20px 8px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}
.forward-modal-header h3 {
  margin: 0 0 4px;
  font-size: 1.1em;
}
.forward-modal-subtitle {
  font-size: 0.85em;
  opacity: 0.65;
}
.forward-modal-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 8px 0;
  min-height: 100px;
  max-height: 50vh;
}
.forward-modal-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  cursor: pointer;
  transition: background 0.15s;
}
.forward-modal-item:hover {
  background: rgba(0, 0, 0, 0.04);
}
.forward-modal-item.selected {
  background: rgba(37, 211, 102, 0.12);
}
.forward-modal-item.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.forward-modal-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  flex-shrink: 0;
}
.forward-modal-item .forward-item-name {
  flex: 1;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.forward-modal-footer {
  padding: 12px 20px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.forward-modal-count {
  font-size: 0.85em;
  opacity: 0.65;
}
.forward-modal-actions {
  display: flex;
  gap: 8px;
}
.modal-button-primary {
  background: #25d366;
  color: white;
}
.modal-button-primary:disabled {
  background: #c0c0c0;
  cursor: not-allowed;
}

/* --- Dark theme overrides --- */
[data-theme="dark"] .action-popup-btn-danger {
  color: #ff6b6b;
}
[data-theme="dark"] .action-popup-btn-danger:hover {
  background: rgba(255, 107, 107, 0.15);
}
[data-theme="dark"] .message-edit-textarea {
  background: rgba(255, 255, 255, 0.1);
  color: #eaeaea;
  border-color: rgba(255, 255, 255, 0.2);
}
[data-theme="dark"] .message-edit-cancel {
  background: #444;
  color: #eaeaea;
}
[data-theme="dark"] .forward-modal-header {
  border-bottom-color: rgba(255, 255, 255, 0.1);
}
[data-theme="dark"] .forward-modal-footer {
  border-top-color: rgba(255, 255, 255, 0.1);
}
[data-theme="dark"] .forward-modal-item:hover {
  background: rgba(255, 255, 255, 0.06);
}
[data-theme="dark"] .forward-modal-item.selected {
  background: rgba(37, 211, 102, 0.18);
}

/* --- Mobile: popup wraps when 4 buttons get tight --- */
@media (max-width: 480px) {
  .message-action-popup {
    flex-wrap: wrap;
    max-width: 280px;
  }
  .forward-modal-content {
    width: 95%;
    max-height: 90vh;
  }
}

/* ===== SCROLLFIX-2026-06-03: chat list scroll bug ===== */
/* Make .chats-left-panel a proper flex column so #new-chat-list */
/* can be constrained by the parent and scroll its overflow. */
/* Bug: parent was display:block, so flex:1 on children was ignored. */
.chats-left-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}
#new-chat-list {
  min-height: 0;
}
/* ===== END SCROLLFIX-2026-06-03 ===== */

/* ============================================================
   PATCH-P1-PROFILE-CSS (2026-06-03)
   Styles for the Profile tab populated by PATCH-P1-PROFILE-TAB.
   Matches existing card style / teal accent palette.
   ============================================================ */
.p1-profile-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 20px 40px;
  gap: 12px;
  max-width: 420px;
  margin: 0 auto;
}

.p1-avatar-wrap {
  margin-top: 8px;
  margin-bottom: 4px;
}

.p1-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  min-height: 36px;
  flex-wrap: wrap;
  justify-content: center;
}

.p1-name-text {
  font-size: 22px;
  font-weight: 600;
  color: inherit;
  word-break: break-word;
  max-width: 280px;
}

.p1-icon-btn {
  background: transparent;
  border: 1px solid rgba(128, 128, 128, 0.3);
  color: inherit;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  padding: 0;
  transition: background 0.15s;
}

.p1-icon-btn:hover {
  background: rgba(78, 205, 196, 0.15);
  border-color: #4ECDC4;
}

.p1-email {
  font-size: 14px;
  color: #888;
  margin-bottom: 16px;
  word-break: break-all;
  text-align: center;
}

.p1-name-input {
  font-size: 18px;
  padding: 6px 10px;
  border: 1px solid #4ECDC4;
  border-radius: 8px;
  outline: none;
  min-width: 180px;
  max-width: 240px;
  background: var(--input-bg, #fff);
  color: inherit;
}

.p1-name-input:focus {
  box-shadow: 0 0 0 3px rgba(78, 205, 196, 0.25);
}

.p1-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  margin-top: 16px;
}

.p1-action-btn {
  width: 100%;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 500;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  background: #4ECDC4;
  color: #fff;
  transition: filter 0.15s, transform 0.05s;
}

.p1-action-btn:hover { filter: brightness(0.95); }
.p1-action-btn:active { transform: scale(0.98); }
.p1-action-btn:disabled { opacity: 0.6; cursor: wait; }

.p1-action-btn.p1-danger {
  background: #FF6B6B;
}

.p1-action-btn.p1-secondary {
  background: transparent;
  color: inherit;
  border: 1px solid rgba(128, 128, 128, 0.4);
}

.p1-action-btn.p1-small {
  width: auto;
  padding: 6px 14px;
  font-size: 14px;
  border-radius: 8px;
}

.p1-footer {
  margin-top: 28px;
  font-size: 12px;
  color: #999;
  text-align: center;
}

.p1-empty {
  text-align: center;
  padding: 40px 20px;
  color: #888;
}

/* Dark mode adjustments */
body.dark-mode .p1-email,
.dark-mode .p1-email { color: #aaa; }

body.dark-mode .p1-icon-btn,
.dark-mode .p1-icon-btn {
  border-color: rgba(255, 255, 255, 0.2);
}

body.dark-mode .p1-name-input,
.dark-mode .p1-name-input {
  background: #2a2a2a;
  color: #fff;
}

body.dark-mode .p1-footer,
.dark-mode .p1-footer { color: #666; }

/* Make the profile tab itself scrollable if content is tall */
/* removed by layoutfix: #profile-tab.tab-content override was breaking bottom nav */
/* ===== END PATCH-P1-PROFILE-CSS ===== */

/* ============================================================
   PATCH-P2-CONTACTS-CSS (2026-06-03)
   Styles for the Contacts tab populated by PATCH-P2-CONTACTS-TAB.
   Matches existing chat-item card style and teal accent palette.
   ============================================================ */

/* Make the Contacts tab itself scroll if list is tall */
/* removed by layoutfix: #contacts-tab.tab-content override was breaking bottom nav */

/* Search input row, inserted just below the Contacts header */
.p2-search-wrap {
  padding: 8px 12px 4px;
  position: sticky;
  top: 0;
  background: inherit;
  z-index: 2;
}

.p2-search-input {
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  border: 1px solid rgba(128, 128, 128, 0.3);
  border-radius: 10px;
  outline: none;
  background: var(--input-bg, #fff);
  color: inherit;
  box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.p2-search-input:focus {
  border-color: #4ECDC4;
  box-shadow: 0 0 0 3px rgba(78, 205, 196, 0.18);
}

/* Reset list defaults inside contacts-list */
#contacts-list {
  list-style: none;
  margin: 0;
  padding: 4px 8px 24px;
}

.p2-section-label {
  list-style: none;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #888;
  padding: 14px 8px 6px;
  margin-top: 4px;
}

.p2-contact-row {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.12s;
}

.p2-contact-row:hover {
  background: rgba(78, 205, 196, 0.10);
}

.p2-contact-row:active {
  background: rgba(78, 205, 196, 0.18);
}

.p2-contact-avatar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.p2-avatar-fallback {
  border-radius: 50%;
  background: #4ECDC4;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

.p2-contact-text {
  flex: 1 1 auto;
  min-width: 0;
}

.p2-contact-name {
  font-size: 15px;
  font-weight: 500;
  color: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.p2-contact-email {
  font-size: 12px;
  color: #888;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.p2-empty {
  list-style: none;
  text-align: center;
  padding: 32px 24px;
  color: #888;
  font-size: 14px;
  line-height: 1.5;
}

/* Dark mode adjustments */
body.dark-mode .p2-search-input,
.dark-mode .p2-search-input {
  background: #2a2a2a;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.15);
}

body.dark-mode .p2-section-label,
.dark-mode .p2-section-label { color: #aaa; }

body.dark-mode .p2-contact-row:hover,
.dark-mode .p2-contact-row:hover {
  background: rgba(78, 205, 196, 0.16);
}

body.dark-mode .p2-contact-email,
.dark-mode .p2-contact-email { color: #aaa; }

body.dark-mode .p2-empty,
.dark-mode .p2-empty { color: #aaa; }

/* ===== END PATCH-P2-CONTACTS-CSS ===== */

/* PATCH-LAYOUTFIX-2026-06-03 - fix bottom nav off-screen on mobile */
/* Override the duplicate .main-content height:100vh at line 1829 */
/* Container is already 100vh + flex column; main-content should just flex:1 */
.main-content {
    height: auto !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    padding-bottom: 0 !important;
    overflow: hidden;
}

/* Ensure bottom nav stays inside viewport */
.bottom-nav {
    flex: 0 0 auto;
}

/* Use dynamic viewport height for mobile (handles address bar) */
.container {
    height: 100dvh;
}
/* Fallback for older browsers that don't support dvh */
@supports not (height: 100dvh) {
    .container {
        height: 100vh;
    }
}
/* END PATCH-LAYOUTFIX-2026-06-03 */

/* PATCH-LAYOUTFIX2-2026-06-03 - polish: fix 0.33px overshoot + nav background */
.container {
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    overflow: hidden;
}

.bottom-nav {
    flex: 0 0 60px;
    background-color: var(--secondary-color, #ffffff);
    border-top: 1px solid var(--border-color, #e0e0e0);
    z-index: 100;
    position: relative;
}

[data-theme="dark"] .bottom-nav {
    background-color: #1a1a1a;
    border-top: 1px solid #333;
}
/* END PATCH-LAYOUTFIX2-2026-06-03 */

/* PATCH-FCM-UX-2026-06-03 - Styled toast banner replacing alert() in FCM flow */
.fcm-toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 90%;
  min-width: 280px;
  padding: 14px 18px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 10000;
  font-size: 14px;
  line-height: 1.5;
  animation: fcm-toast-in 0.3s ease-out;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.fcm-toast-icon { font-size: 20px; flex-shrink: 0; }
.fcm-toast-body { flex: 1; }
.fcm-toast-title { font-weight: 600; margin-bottom: 4px; }
.fcm-toast-close {
  background: transparent; border: none; cursor: pointer;
  font-size: 18px; color: inherit; opacity: 0.6; padding: 0 4px;
}
.fcm-toast-close:hover { opacity: 1; }
.fcm-toast.info    { background: #e7f3fe; color: #084298; border-left: 4px solid #0d6efd; }
.fcm-toast.success { background: #d1e7dd; color: #0a3622; border-left: 4px solid #198754; }
.fcm-toast.warning { background: #fff3cd; color: #664d03; border-left: 4px solid #ffc107; }
.fcm-toast.error   { background: #f8d7da; color: #58151c; border-left: 4px solid #dc3545; }
@keyframes fcm-toast-in {
  from { opacity: 0; transform: translate(-50%, -20px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes fcm-toast-out {
  from { opacity: 1; transform: translate(-50%, 0); }
  to   { opacity: 0; transform: translate(-50%, -20px); }
}
.fcm-toast.fcm-toast-leaving { animation: fcm-toast-out 0.3s ease-in forwards; }
/* END PATCH-FCM-UX-2026-06-03 */

/* PATCH-FCM-FOREGROUND-2026-06-04 - In-app notification (foreground messages) */
.fcm-in-app-notification {
  position: fixed;
  top: 20px;
  right: 20px;
  max-width: 360px;
  min-width: 280px;
  background: #1976d2;
  color: #fff;
  padding: 14px 16px;
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
  z-index: 10000;
  animation: fcm-in-app-slide-in 0.3s ease-out;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  cursor: pointer;
}
.fcm-in-app-notification .fcm-notification-content strong {
  display: block;
  font-size: 15px;
  margin-bottom: 4px;
}
.fcm-in-app-notification .fcm-notification-content p {
  margin: 0;
  font-size: 14px;
  line-height: 1.4;
  opacity: 0.95;
}
@keyframes fcm-in-app-slide-in {
  from { transform: translateX(110%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
@media (max-width: 480px) {
  .fcm-in-app-notification {
    top: 10px;
    right: 10px;
    left: 10px;
    max-width: none;
  }
}
/* END PATCH-FCM-FOREGROUND-2026-06-04 */

/* PATCH-IOS-INSTALL-BANNER-2026-06-04 */
.ios-install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(135deg, #1976d2 0%, #1565c0 100%);
  color: #fff;
  padding: 14px 16px 18px;
  z-index: 9999;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.25);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  animation: ios-banner-slide-up 0.35s ease-out;
  display: flex;
  align-items: center;
  gap: 12px;
}
.ios-install-banner .ios-banner-icon {
  font-size: 28px;
  flex-shrink: 0;
}
.ios-install-banner .ios-banner-text {
  flex: 1;
  font-size: 14px;
  line-height: 1.4;
}
.ios-install-banner .ios-banner-text strong {
  display: block;
  font-size: 15px;
  margin-bottom: 2px;
}
.ios-install-banner .ios-banner-text small {
  opacity: 0.9;
}
.ios-install-banner .ios-banner-close {
  background: rgba(255,255,255,0.2);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ios-install-banner .ios-banner-close:active {
  background: rgba(255,255,255,0.35);
}
@keyframes ios-banner-slide-up {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
/* Push bottom-nav up while banner is visible */
body.ios-banner-visible .bottom-nav {
  bottom: 90px;
}
/* END PATCH-IOS-INSTALL-BANNER-2026-06-04 */

/* PATCH-DESKTOP-TABS-2026-06-04 */
.desktop-tab-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 6px;
    transition: background 0.2s;
}
.desktop-tab-btn:hover {
    background: rgba(0, 0, 0, 0.08);
}
@media (min-width: 768px) {
    .desktop-tab-btn {
        display: inline-block;
    }
}
/* END PATCH-DESKTOP-TABS-2026-06-04 */
/* PATCH-AUDIO-WIDTH-2026-06-04 — ensure voice messages render with full controls on Android */
.message-content audio,
.message audio {
    width: 240px !important;
    min-width: 240px !important;
    max-width: 100% !important;
    display: block !important;
    height: 40px;
}
@media (max-width: 480px) {
    .message-content audio,
    .message audio {
        width: 220px !important;
        min-width: 220px !important;
    }
}
/* END PATCH-AUDIO-WIDTH-2026-06-04 */
/* PATCH-AUDIO-WIDTH-V2-2026-06-04 — force voice messages to render with full controls */
.message-audio {
    min-width: 260px !important;
    width: 260px !important;
    max-width: 100% !important;
    display: block !important;
}
.message-audio audio {
    width: 100% !important;
    min-width: 240px !important;
    height: 40px !important;
    display: block !important;
}
@media (max-width: 480px) {
    .message-audio {
        min-width: 220px !important;
        width: 220px !important;
    }
    .message-audio audio {
        min-width: 200px !important;
    }
}
/* END PATCH-AUDIO-WIDTH-V2-2026-06-04 */
/* PATCH-PRIVACY-GATE-2026-06-04 */
#privacy-gate-modal.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
}
#privacy-gate-modal.modal.show {
    display: flex !important;
}
.privacy-gate-content {
    background: #fff;
    border-radius: 12px;
    max-width: 560px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 28px 32px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    color: #333;
}
.privacy-gate-title {
    margin: 0 0 12px;
    font-size: 1.6rem;
    color: #1a73e8;
    text-align: center;
}
.privacy-gate-intro {
    margin: 0 0 18px;
    font-size: 1rem;
    line-height: 1.5;
    text-align: center;
    color: #555;
}
.privacy-gate-summary {
    background: #f8f9fa;
    border-left: 4px solid #1a73e8;
    border-radius: 6px;
    padding: 14px 18px;
    margin-bottom: 18px;
}
.privacy-gate-summary h3 {
    margin: 0 0 10px;
    font-size: 1rem;
    color: #1a73e8;
}
.privacy-gate-summary ul {
    margin: 0 0 12px;
    padding-left: 20px;
    font-size: 0.9rem;
    line-height: 1.5;
    color: #444;
}
.privacy-gate-summary li {
    margin-bottom: 8px;
}
.privacy-gate-summary li strong {
    color: #d33;
}
.privacy-gate-fulllink {
    margin: 8px 0 0;
    font-size: 0.9rem;
    text-align: center;
}
.privacy-gate-fulllink a {
    color: #1a73e8;
    text-decoration: none;
    font-weight: 500;
}
.privacy-gate-fulllink a:hover {
    text-decoration: underline;
}
.privacy-gate-checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    margin-bottom: 18px;
    background: #fffbe6;
    border: 1px solid #f0e0a0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    line-height: 1.4;
    color: #333;
}
.privacy-gate-checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-top: 2px;
    flex-shrink: 0;
    cursor: pointer;
}
.privacy-gate-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}
.privacy-gate-actions .modal-button {
    flex: 1;
    padding: 12px 18px;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 6px;
    border: 1px solid #ccc;
    background: #fff;
    color: #333;
    cursor: pointer;
    transition: all 0.2s;
}
.privacy-gate-actions .modal-button:hover {
    background: #f0f0f0;
}
.privacy-gate-actions .modal-button-primary {
    background: #1a73e8;
    color: #fff;
    border-color: #1a73e8;
}
.privacy-gate-actions .modal-button-primary:hover:not(:disabled) {
    background: #1557b0;
}
.privacy-gate-actions .modal-button-primary:disabled {
    background: #aac4ec;
    border-color: #aac4ec;
    cursor: not-allowed;
}
@media (max-width: 600px) {
    .privacy-gate-content {
        padding: 20px 18px;
        max-height: 95vh;
    }
    .privacy-gate-title {
        font-size: 1.3rem;
    }
    .privacy-gate-actions {
        flex-direction: column-reverse;
    }
    .privacy-gate-actions .modal-button {
        width: 100%;
    }
}
body.dark-mode .privacy-gate-content {
    background: #2a2a2a;
    color: #e0e0e0;
}
body.dark-mode .privacy-gate-summary {
    background: #1e1e1e;
    border-left-color: #4a9eff;
}
body.dark-mode .privacy-gate-summary ul {
    color: #ccc;
}
body.dark-mode .privacy-gate-checkbox-label {
    background: #3a3520;
    border-color: #5a5230;
    color: #e0e0e0;
}
body.dark-mode .privacy-gate-intro {
    color: #bbb;
}
body.dark-mode .privacy-gate-actions .modal-button {
    background: #3a3a3a;
    color: #e0e0e0;
    border-color: #555;
}
body.dark-mode .privacy-gate-actions .modal-button:hover {
    background: #4a4a4a;
}
/* END PATCH-PRIVACY-GATE-2026-06-04 */

/* ===== PATCH-PHI-DETECTOR-2026-06-04 ===== */
#phi-warning-modal.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 99998;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
}
#phi-warning-modal.modal.show {
    display: flex !important;
}
.phi-warning-content {
    background: #fff;
    max-width: 520px;
    width: 100%;
    padding: 28px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    border-top: 5px solid #e74c3c;
}
.phi-warning-title {
    color: #c0392b;
    margin: 0 0 12px 0;
    font-size: 1.4rem;
}
.phi-warning-intro {
    margin: 0 0 12px 0;
    color: #333;
    font-size: 0.95rem;
}
.phi-warning-list {
    background: #fff5f5;
    border: 1px solid #fadbd8;
    border-radius: 6px;
    padding: 12px 12px 12px 32px;
    margin: 0 0 14px 0;
    color: #c0392b;
    font-size: 0.9rem;
    list-style-type: disc;
}
.phi-warning-list li {
    margin: 4px 0;
}
.phi-warning-reminder {
    background: #fef9e7;
    border-left: 3px solid #f39c12;
    padding: 10px 12px;
    margin: 0 0 14px 0;
    font-size: 0.88rem;
    color: #7e5109;
    border-radius: 4px;
}
.phi-warning-preview {
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 10px 12px;
    margin: 0 0 18px 0;
    font-size: 0.85rem;
    color: #444;
    max-height: 100px;
    overflow-y: auto;
    word-break: break-word;
    font-family: monospace;
}
.phi-warning-preview mark {
    background: #ffe066;
    color: #000;
    padding: 1px 3px;
    border-radius: 2px;
}
.phi-warning-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}
.phi-warning-actions .modal-button {
    padding: 10px 18px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #f5f5f5;
    cursor: pointer;
    font-size: 0.95rem;
}
.phi-warning-actions .modal-button-primary {
    background: #4ECDC4;
    color: #fff;
    border-color: #4ECDC4;
    font-weight: 600;
}
.phi-warning-actions .modal-button:hover {
    opacity: 0.9;
}
[data-theme="dark"] .phi-warning-content {
    background: #2a2a2a;
    color: #eee;
}
[data-theme="dark"] .phi-warning-intro,
[data-theme="dark"] .phi-warning-preview {
    color: #ddd;
    background: #1e1e1e;
    border-color: #444;
}
[data-theme="dark"] .phi-warning-list {
    background: #3a1e1e;
    border-color: #5a2a2a;
    color: #ff8a80;
}
[data-theme="dark"] .phi-warning-reminder {
    background: #3a2e1e;
    color: #ffd54f;
}
@media (max-width: 600px) {
    .phi-warning-content {
        padding: 20px;
    }
    .phi-warning-actions {
        flex-direction: column;
    }
    .phi-warning-actions .modal-button {
        width: 100%;
    }
}
/* ===== END PATCH-PHI-DETECTOR-2026-06-04 ===== */

/* ===== PATCH-WELCOME-TUTORIAL-2026-06-05 START ===== */

/* ---- Modal container ---- */
.welcome-tutorial-modal {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: linear-gradient(135deg, #0f2027 0%, #203a43 50%, #2c5364 100%);
  transition: background 0.8s ease;
  animation: welcomeFadeIn 0.5s ease;
}

@keyframes welcomeFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ---- Per-slide gradients (applied via active-slide class on modal) ---- */
.welcome-tutorial-modal.slide-bg-1 { background: linear-gradient(135deg, #0f2027 0%, #203a43 50%, #2c5364 100%); }
.welcome-tutorial-modal.slide-bg-2 { background: linear-gradient(135deg, #134e5e 0%, #71b280 100%); }
.welcome-tutorial-modal.slide-bg-3 { background: linear-gradient(135deg, #614385 0%, #f857a6 100%); }
.welcome-tutorial-modal.slide-bg-4 { background: linear-gradient(135deg, #ff512f 0%, #f09819 100%); }
.welcome-tutorial-modal.slide-bg-5 { background: linear-gradient(135deg, #00c6ff 0%, #0072ff 100%); }
.welcome-tutorial-modal.slide-bg-6 { background: linear-gradient(135deg, #4568dc 0%, #b06ab3 100%); }
.welcome-tutorial-modal.slide-bg-7 { background: linear-gradient(135deg, #232526 0%, #414345 100%); }
.welcome-tutorial-modal.slide-bg-8 { background: linear-gradient(135deg, #f7971e 0%, #c0392b 100%); }

/* ---- Skip button (low contrast, top-right) ---- */
.welcome-tutorial-skip {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.75);
  border: 1px solid rgba(255,255,255,0.2);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  z-index: 10;
}
.welcome-tutorial-skip:hover {
  background: rgba(255,255,255,0.2);
  color: white;
}

/* ---- Progress bar (top) ---- */
.welcome-tutorial-progress-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: rgba(255,255,255,0.15);
}
#welcome-tutorial-progress-fill {
  height: 100%;
  width: 12.5%;
  background: linear-gradient(90deg, #ffd700, #ffffff);
  transition: width 0.4s ease;
  box-shadow: 0 0 10px rgba(255,255,255,0.5);
}

/* ---- Stage (slide container) ---- */
.welcome-tutorial-stage {
  position: relative;
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* ---- Individual slides ---- */
.welcome-slide {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateX(60px);
  pointer-events: none;
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.welcome-slide.active {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}
.welcome-slide.exit-left {
  opacity: 0;
  transform: translateX(-60px);
}

.welcome-slide-content {
  max-width: 600px;
  padding: 30px;
  text-align: center;
  color: white;
}

.welcome-title {
  font-size: 56px;
  font-weight: 800;
  margin: 24px 0 16px;
  text-shadow: 0 2px 20px rgba(0,0,0,0.3);
  letter-spacing: -0.5px;
  animation: welcomeTitlePop 0.6s ease;
}
@keyframes welcomeTitlePop {
  0%   { opacity: 0; transform: translateY(20px) scale(0.95); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.welcome-subtitle {
  font-size: 22px;
  line-height: 1.5;
  opacity: 0.92;
  margin: 0;
  animation: welcomeSubtitleFade 0.8s ease 0.2s both;
}
@keyframes welcomeSubtitleFade {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 0.92; transform: translateY(0); }
}

/* ---- Illustrations ---- */
.welcome-illustration {
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin-bottom: 16px;
}

/* Slide 1 - Logo */
.welcome-logo-circle {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffd700, #ff9500);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 72px;
  font-weight: 900;
  color: white;
  box-shadow: 0 10px 60px rgba(255,215,0,0.5), inset 0 -8px 20px rgba(0,0,0,0.15);
  animation: welcomeLogoPulse 2s ease-in-out infinite;
}
@keyframes welcomeLogoPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 10px 60px rgba(255,215,0,0.5), inset 0 -8px 20px rgba(0,0,0,0.15); }
  50%      { transform: scale(1.05); box-shadow: 0 10px 80px rgba(255,215,0,0.8), inset 0 -8px 20px rgba(0,0,0,0.15); }
}

/* Slide 2 - Chat bubbles */
.welcome-illu-bubbles {
  flex-direction: column;
  gap: 12px;
  height: 240px;
}
.welcome-bubble {
  background: rgba(255,255,255,0.95);
  color: #134e5e;
  padding: 12px 20px;
  border-radius: 20px;
  font-size: 18px;
  font-weight: 600;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  opacity: 0;
  animation: welcomeBubbleIn 0.5s ease forwards;
}
.welcome-bubble-1 { animation-delay: 0.2s; align-self: flex-start; border-bottom-left-radius: 4px; }
.welcome-bubble-2 { animation-delay: 0.6s; align-self: flex-end; border-bottom-right-radius: 4px; }
.welcome-bubble-3 { animation-delay: 1.0s; align-self: flex-start; border-bottom-left-radius: 4px; }
@keyframes welcomeBubbleIn {
  0%   { opacity: 0; transform: translateY(20px) scale(0.8); }
  60%  { transform: translateY(-4px) scale(1.05); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* Slide 3 - DM avatars */
.welcome-illu-dm {
  gap: 0;
  position: relative;
}
.welcome-avatar {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  font-weight: 800;
  color: white;
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
}
.welcome-avatar-left  { background: linear-gradient(135deg, #f857a6, #ff5858); animation: welcomeSlideLeft 0.8s ease; }
.welcome-avatar-right { background: linear-gradient(135deg, #43cea2, #185a9d); animation: welcomeSlideRight 0.8s ease; }
@keyframes welcomeSlideLeft  { from { transform: translateX(-120px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes welcomeSlideRight { from { transform: translateX(120px);  opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.welcome-dm-line {
  width: 80px;
  height: 4px;
  background: linear-gradient(90deg, #f857a6, #43cea2);
  margin: 0 -10px;
  border-radius: 2px;
  box-shadow: 0 0 20px rgba(255,255,255,0.6);
  animation: welcomeLineGlow 1.5s ease-in-out infinite;
}
@keyframes welcomeLineGlow {
  0%, 100% { opacity: 0.6; }
  50%      { opacity: 1; }
}

/* Slide 4 - Groups (orbit) */
.welcome-illu-groups {
  position: relative;
  width: 280px;
  height: 280px;
}
.welcome-group-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: white;
  color: #ff512f;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  font-weight: 800;
  box-shadow: 0 8px 40px rgba(0,0,0,0.3);
  z-index: 2;
}
.welcome-orbit {
  position: absolute;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(255,255,255,0.95);
  color: #ff512f;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 20px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  top: 50%;
  left: 50%;
  margin: -25px 0 0 -25px;
  animation: welcomeOrbitIn 0.6s ease forwards;
  opacity: 0;
}
.welcome-orbit-1 { animation-delay: 0.1s; --tx:  100px; --ty:    0px; }
.welcome-orbit-2 { animation-delay: 0.2s; --tx:   30px; --ty:  -95px; }
.welcome-orbit-3 { animation-delay: 0.3s; --tx:  -80px; --ty:  -60px; }
.welcome-orbit-4 { animation-delay: 0.4s; --tx:  -80px; --ty:   60px; }
.welcome-orbit-5 { animation-delay: 0.5s; --tx:   30px; --ty:   95px; }
@keyframes welcomeOrbitIn {
  0%   { opacity: 0; transform: translate(0,0) scale(0.5); }
  100% { opacity: 1; transform: translate(var(--tx), var(--ty)) scale(1); }
}

/* Slide 5 - Media (mic + waveform + camera) */
.welcome-illu-media {
  gap: 24px;
  align-items: center;
}
.welcome-media-icon {
  font-size: 64px;
  filter: drop-shadow(0 4px 20px rgba(0,0,0,0.3));
  animation: welcomeMediaPulse 1.8s ease-in-out infinite;
}
.welcome-media-icon:nth-child(3) { animation-delay: 0.4s; }
@keyframes welcomeMediaPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.12); }
}
.welcome-waveform {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 60px;
}
.welcome-waveform span {
  display: block;
  width: 5px;
  background: white;
  border-radius: 3px;
  animation: welcomeWaveBounce 1s ease-in-out infinite;
}
.welcome-waveform span:nth-child(1) { height: 20px; animation-delay: 0.0s; }
.welcome-waveform span:nth-child(2) { height: 40px; animation-delay: 0.1s; }
.welcome-waveform span:nth-child(3) { height: 55px; animation-delay: 0.2s; }
.welcome-waveform span:nth-child(4) { height: 40px; animation-delay: 0.3s; }
.welcome-waveform span:nth-child(5) { height: 20px; animation-delay: 0.4s; }
@keyframes welcomeWaveBounce {
  0%, 100% { transform: scaleY(0.5); }
  50%      { transform: scaleY(1); }
}

/* Slide 6 - Bell + ripple */
.welcome-illu-bell {
  position: relative;
}
.welcome-bell {
  font-size: 100px;
  filter: drop-shadow(0 8px 30px rgba(0,0,0,0.3));
  animation: welcomeBellShake 1.4s ease-in-out infinite;
  transform-origin: 50% 10%;
}
@keyframes welcomeBellShake {
  0%, 50%, 100% { transform: rotate(0deg); }
  10%, 30%      { transform: rotate(15deg); }
  20%, 40%      { transform: rotate(-15deg); }
}
.welcome-online-dot {
  position: absolute;
  top: 30%;
  right: 25%;
  width: 22px;
  height: 22px;
  background: #2ecc71;
  border: 4px solid white;
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.7);
  animation: welcomeDotPulse 1.6s ease-out infinite;
}
@keyframes welcomeDotPulse {
  0%   { box-shadow: 0 0 0 0   rgba(46, 204, 113, 0.7); }
  100% { box-shadow: 0 0 0 25px rgba(46, 204, 113, 0); }
}

/* Slide 7 - Theme toggle */
.welcome-theme-toggle {
  display: flex;
  background: rgba(255,255,255,0.15);
  border-radius: 100px;
  padding: 12px 20px;
  gap: 30px;
  font-size: 56px;
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.2);
}
.welcome-sun, .welcome-moon {
  filter: drop-shadow(0 4px 12px rgba(255,255,255,0.4));
  animation: welcomeThemeBounce 2s ease-in-out infinite;
}
.welcome-moon { animation-delay: 1s; }
@keyframes welcomeThemeBounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}

/* Slide 8 - Shield (critical) */
.welcome-slide-critical .welcome-shield {
  font-size: 130px;
  filter: drop-shadow(0 0 30px rgba(255,255,255,0.6));
  animation: welcomeShieldPulse 1.8s ease-in-out infinite;
}
@keyframes welcomeShieldPulse {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 30px rgba(255,255,255,0.6)); }
  50%      { transform: scale(1.08); filter: drop-shadow(0 0 50px rgba(255,255,255,0.9)); }
}
.welcome-slide-critical .welcome-subtitle strong {
  display: inline-block;
  background: rgba(0,0,0,0.25);
  padding: 4px 12px;
  border-radius: 6px;
  margin-bottom: 8px;
}

/* ---- Footer (dots, counter, buttons) ---- */
.welcome-tutorial-footer {
  width: 100%;
  padding: 24px 30px 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  background: linear-gradient(to top, rgba(0,0,0,0.3), transparent);
}

.welcome-tutorial-dots {
  display: flex;
  gap: 10px;
}
.welcome-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  transition: all 0.3s;
}
.welcome-dot.active {
  background: white;
  transform: scale(1.4);
  box-shadow: 0 0 12px rgba(255,255,255,0.8);
}
.welcome-dot.done {
  background: rgba(255,255,255,0.7);
}

.welcome-tutorial-counter {
  font-size: 13px;
  color: rgba(255,255,255,0.7);
  letter-spacing: 0.5px;
}

.welcome-tutorial-buttons {
  display: flex;
  gap: 14px;
  align-items: center;
}

.welcome-btn {
  font-size: 16px;
  font-weight: 600;
  padding: 14px 28px;
  border-radius: 50px;
  border: none;
  cursor: pointer;
  transition: all 0.25s;
  font-family: inherit;
}

.welcome-btn-back {
  background: rgba(255,255,255,0.15);
  color: white;
  border: 1px solid rgba(255,255,255,0.25);
}
.welcome-btn-back:hover:not(:disabled) {
  background: rgba(255,255,255,0.25);
}
.welcome-btn-back:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.welcome-btn-next, .welcome-btn-finish {
  background: white;
  color: #134e5e;
  padding: 14px 36px;
  font-weight: 700;
  box-shadow: 0 6px 24px rgba(0,0,0,0.25);
  animation: welcomeBtnGlow 2s ease-in-out infinite;
}
.welcome-btn-next:hover, .welcome-btn-finish:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 32px rgba(0,0,0,0.35);
}
.welcome-btn-finish {
  background: linear-gradient(135deg, #ffd700, #ff9500);
  color: white;
  font-size: 18px;
}
@keyframes welcomeBtnGlow {
  0%, 100% { box-shadow: 0 6px 24px rgba(0,0,0,0.25); }
  50%      { box-shadow: 0 8px 32px rgba(255,255,255,0.4); }
}

/* ---- Confetti canvas ---- */
.welcome-confetti-canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

/* ---- Mobile responsive ---- */
@media (max-width: 768px) {
  .welcome-title { font-size: 36px; }
  .welcome-subtitle { font-size: 17px; }
  .welcome-illustration { height: 160px; }
  .welcome-logo-circle { width: 110px; height: 110px; font-size: 56px; }
  .welcome-illu-groups { width: 220px; height: 220px; }
  .welcome-orbit-1 { --tx:   80px; --ty:    0px; }
  .welcome-orbit-2 { --tx:   25px; --ty:  -75px; }
  .welcome-orbit-3 { --tx:  -65px; --ty:  -48px; }
  .welcome-orbit-4 { --tx:  -65px; --ty:   48px; }
  .welcome-orbit-5 { --tx:   25px; --ty:   75px; }
  .welcome-bell { font-size: 80px; }
  .welcome-slide-critical .welcome-shield { font-size: 100px; }
  .welcome-btn { font-size: 14px; padding: 12px 22px; }
  .welcome-btn-finish { font-size: 16px; padding: 12px 28px; }
  .welcome-tutorial-skip { top: 12px; right: 12px; font-size: 12px; padding: 6px 12px; }
}

/* ===== PATCH-WELCOME-TUTORIAL-2026-06-05 END ===== */
/* ===== PATCH-WELCOME-TUTORIAL-WIRE-2026-06-05 ===== */
.profile-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.replay-tutorial-btn {
  background: linear-gradient(135deg, #00c6ff, #0072ff);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 8px rgba(0, 114, 255, 0.3);
}
.replay-tutorial-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 114, 255, 0.5);
}
.replay-tutorial-btn:active {
  transform: translateY(0);
}
/* ===== END PATCH-WELCOME-TUTORIAL-WIRE-2026-06-05 ===== */