/* Heebo — hosted locally (no Google Fonts request) */
@font-face {
  font-family: 'Heebo';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/fonts/heebo-hebrew.woff2') format('woff2');
  unicode-range: U+0307-0308, U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F;
}
@font-face {
  font-family: 'Heebo';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/fonts/heebo-math.woff2') format('woff2');
  unicode-range: U+0302-0303, U+0305, U+0307-0308, U+0310, U+0312, U+0315, U+031A, U+0326-0327, U+032C, U+032F-0330, U+0332-0333, U+0338, U+033A, U+0346, U+034D, U+0391-03A1, U+03A3-03A9, U+03B1-03C9, U+03D1, U+03D5-03D6, U+03F0-03F1, U+03F4-03F5, U+2016-2017, U+2034-2038, U+203C, U+2040, U+2043, U+2047, U+2050, U+2057, U+205F, U+2070-2071, U+2074-209F, U+20D0-20DC, U+20E1, U+20E5-20EF, U+2100-2112, U+2114-2115, U+2117-2121, U+2123-214F, U+2190, U+2192, U+2194-21AE, U+21B0-21E5, U+21F1-21F2, U+21F4-2211, U+2213-2214, U+2216-22FF, U+2308-230B, U+2310, U+2319, U+231C-2321, U+2336-237A, U+237C, U+2395, U+239B-23B7, U+23D0, U+23DC-23E1, U+2474-2475, U+25AF, U+25B3, U+25B7, U+25BD, U+25C1, U+25CA, U+25CC, U+25FB, U+266D-266F, U+27C0-27FF, U+2900-2AFF, U+2B0E-2B11, U+2B30-2B4C, U+2BFE, U+3030, U+FF5B, U+FF5D, U+1D400-1D7FF, U+1EE00-1EEFF;
}
@font-face {
  font-family: 'Heebo';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/fonts/heebo-symbols.woff2') format('woff2');
  unicode-range: U+0001-000C, U+000E-001F, U+007F-009F, U+20DD-20E0, U+20E2-20E4, U+2150-218F, U+2190, U+2192, U+2194-2199, U+21AF, U+21E6-21F0, U+21F3, U+2218-2219, U+2299, U+22C4-22C6, U+2300-243F, U+2440-244A, U+2460-24FF, U+25A0-27BF, U+2800-28FF, U+2921-2922, U+2981, U+29BF, U+29EB, U+2B00-2BFF, U+4DC0-4DFF, U+FFF9-FFFB, U+10140-1018E, U+10190-1019C, U+101A0, U+101D0-101FD, U+102E0-102FB, U+10E60-10E7E, U+1D2C0-1D2D3, U+1D2E0-1D37F, U+1F000-1F0FF, U+1F100-1F1AE, U+1F1E6-1F1FF, U+1F30D-1F30F, U+1F315, U+1F31C, U+1F31E, U+1F320-1F32C, U+1F336, U+1F378, U+1F37D, U+1F382, U+1F393-1F39F, U+1F3A7-1F3A8, U+1F3AC-1F3AF, U+1F3C2, U+1F3C4-1F3C6, U+1F3CA-1F3CE, U+1F3D4-1F3E0, U+1F3ED, U+1F3F1-1F3F3, U+1F3F5-1F3F7, U+1F408, U+1F415, U+1F41F, U+1F426, U+1F43F, U+1F441-1F442, U+1F444, U+1F446-1F449, U+1F44C-1F44E, U+1F453, U+1F46A, U+1F47D, U+1F4A3, U+1F4B0, U+1F4B3, U+1F4B9, U+1F4BB, U+1F4BF, U+1F4C8-1F4CB, U+1F4D6, U+1F4DA, U+1F4DF, U+1F4E3-1F4E6, U+1F4EA-1F4ED, U+1F4F7, U+1F4F9-1F4FB, U+1F4FD-1F4FE, U+1F503, U+1F507-1F50B, U+1F50D, U+1F512-1F513, U+1F53E-1F54A, U+1F54F-1F5FA, U+1F610, U+1F650-1F67F, U+1F687, U+1F68D, U+1F691, U+1F694, U+1F698, U+1F6AD, U+1F6B2, U+1F6B9-1F6BA, U+1F6BC, U+1F6C6-1F6CF, U+1F6D3-1F6D7, U+1F6E0-1F6EA, U+1F6F0-1F6F3, U+1F6F7-1F6FC, U+1F700-1F80B, U+1F810-1F847, U+1F850-1F859, U+1F860-1F887, U+1F890-1F8AD, U+1F8B0-1F8BB, U+1F8C0-1F8C1, U+1F8D0-1F8D8, U+1F900-1F90B, U+1F93B, U+1F946, U+1F984, U+1F996, U+1F9E9, U+1FA00-1FA6F, U+1FA70-1FA7C, U+1FA80-1FAC6, U+1FAC8, U+1FACC-1FADD, U+1FADF-1FAEB, U+1FAEF-1FAFA, U+1FB00-1FBFF;
}
@font-face {
  font-family: 'Heebo';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/fonts/heebo-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Heebo';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/fonts/heebo-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

* { box-sizing: border-box; }

html, body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    overscroll-behavior: none;
}

body {
    font-family: 'Heebo', sans-serif;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    color: #333;
}

/* ========== AUTH SCREEN ========== */
.auth-container {
    width: 100%;
    max-width: 440px;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 24px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.12);
    padding: 40px 36px;
    position: relative;
    z-index: 1;
    animation: cardEntrance 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.auth-logo { text-align: center; margin-bottom: 28px; }

.auth-logo .pulse {
    display: inline-block;
    width: 14px;
    height: 14px;
    background: #00d084;
    border-radius: 50%;
    box-shadow: 0 0 10px #00d084;
    animation: pulse 2s infinite;
    margin-left: 8px;
    vertical-align: middle;
}

.auth-logo h1 {
    font-size: 1.7rem;
    font-weight: 700;
    background: linear-gradient(135deg, #6b7280, #4b5563);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: inline;
}

.auth-logo p { color: #6b6b6b; font-size: 0.9rem; margin: 6px 0 0; }

.auth-tabs {
    display: flex;
    background: rgba(107, 114, 128, 0.08);
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 24px;
}

.auth-tab {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    border-radius: 9px;
    font-family: 'Heebo', sans-serif;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    color: #6b6b6b;
    transition: all 0.2s;
    min-height: 44px;
}

.auth-tab.active {
    background: white;
    color: #6b7280;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.auth-form { display: flex; flex-direction: column; gap: 14px; }

.auth-form input {
    padding: 13px 16px;
    background: rgba(255, 255, 255, 0.85);
    border: 1.5px solid rgba(107, 114, 128, 0.15);
    border-radius: 12px;
    font-family: 'Heebo', sans-serif;
    font-size: 16px;
    outline: none;
    transition: all 0.2s;
    direction: ltr;
    text-align: right;
}

.auth-form input:focus {
    background: white;
    border-color: #6b7280;
    box-shadow: 0 0 0 3px rgba(107, 114, 128, 0.12);
}

.auth-form input::placeholder { color: #6b6b6b; text-align: right; }

.auth-submit {
    padding: 13px;
    background: linear-gradient(135deg, #6b7280, #4b5563);
    color: white;
    border: none;
    border-radius: 12px;
    font-family: 'Heebo', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 15px rgba(107, 114, 128, 0.35);
    margin-top: 4px;
}

.auth-submit:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(107, 114, 128, 0.45); }
.auth-submit:active { transform: translateY(0); }
.auth-submit:disabled { opacity: 0.7; cursor: not-allowed; transform: none; }

.auth-message {
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 0.88rem;
    text-align: center;
    display: none;
}

.auth-message.error  { background: rgba(239, 68, 68, 0.1);  color: #dc2626; display: block; }
.auth-message.success { background: rgba(0, 208, 132, 0.1); color: #059669; display: block; }

/* ========== APP LAYOUT ========== */
.app-layout {
    /* RTL: first child (sidebar) renders on right, chat fills left */
    display: flex;
    flex-direction: row;
    width: 95%;
    max-width: 1200px;
    height: 90vh;
    gap: 12px;
}

/* ========== SIDEBAR ========== */
.sidebar {
    width: 255px;
    min-width: 255px;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 20px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    padding: 14px 10px;
    gap: 10px;
    overflow: hidden;
}

.new-chat-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 10px 20px;
    min-height: 44px;
    align-self: center;
    background: transparent;
    color: #fb923c;
    border: 1.5px solid #fb923c;
    border-radius: 4px;
    font-family: 'Heebo', sans-serif;
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s;
    box-shadow: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(251, 146, 60, 0.2);
    user-select: none;
}

.new-chat-btn:hover { opacity: 0.85; transform: translateY(-1px); }
.new-chat-btn:active { transform: scale(0.96); opacity: 1; }

.conv-list-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: #6b6b6b;
    letter-spacing: 0.06em;
    padding: 0 6px;
}

.conv-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.conv-list::-webkit-scrollbar { width: 3px; }
.conv-list::-webkit-scrollbar-track { background: transparent; }
.conv-list::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 4px; }

.conv-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 10px;
    border-radius: 10px;
    cursor: pointer;
    border: 1.5px solid transparent;
    transition: background 0.15s, border-color 0.15s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(107, 114, 128, 0.2);
}

.conv-item:hover { background: rgba(107, 114, 128, 0.07); }

.conv-item.active {
    background: rgba(107, 114, 128, 0.13);
    border-color: rgba(107, 114, 128, 0.28);
}

.conv-title {
    flex: 1;
    font-size: 0.85rem;
    font-weight: 500;
    color: #444;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: right;
}

.conv-item.active .conv-title { color: #374151; font-weight: 600; }

.conv-delete-btn {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    color: #6b6b6b;
    font-size: 0.72rem;
    border-radius: 5px;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s, background 0.15s;
    padding: 0;
    line-height: 1;
}

.conv-item:hover .conv-delete-btn { opacity: 1; }
.conv-delete-btn:hover { color: #ef4444; background: rgba(239, 68, 68, 0.1); }

.conv-empty {
    font-size: 0.82rem;
    color: #6b6b6b;
    text-align: center;
    padding: 24px 8px;
}

/* ========== CHAT SCREEN ========== */
.chat-container {
    flex: 1;
    min-width: 0;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 20px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.chat-header {
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.4);
    padding: 16px 20px;
    padding-top: max(16px, env(safe-area-inset-top));
    font-size: 1.1rem;
    font-weight: 600;
    border-bottom: 1px solid rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header-right { display: flex; align-items: center; gap: 10px; }

.status-pulse {
    display: none;
}

.user-info { display: flex; align-items: center; gap: 10px; font-size: 0.85rem; color: #666; }

.user-email {
    background: rgba(107, 114, 128, 0.08);
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 500;
    color: #6b7280;
}

.logout-btn {
    background: transparent;
    border: 1.5px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
    padding: 5px 12px;
    min-height: 44px;
    border-radius: 20px;
    font-family: 'Heebo', sans-serif;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s;
}

.logout-btn:hover { background: rgba(239, 68, 68, 0.08); border-color: #ef4444; }

@keyframes pulse {
    0%   { box-shadow: 0 0 0 0 rgba(0, 208, 132, 0.7); }
    70%  { box-shadow: 0 0 0 10px rgba(0, 208, 132, 0); }
    100% { box-shadow: 0 0 0 0 rgba(0, 208, 132, 0); }
}

.chat-messages {
    flex: 1;
    min-height: 0;
    padding: 25px;
    overflow-y: auto;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.message {
    max-width: 75%;
    padding: 14px 20px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.6;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.user-msg {
    background: #e8e8e8;
    color: #2d2d2d;
    align-self: flex-start;
    margin-right: 8px;
    padding: 8px 14px;
    border-radius: 4px;
    width: fit-content;
}

.bot-msg {
    background: white;
    color: #333;
    align-self: flex-end;
    border-top-left-radius: 4px;
    width: 100%;
}

/* markdown rendered inside bot messages */
.bot-msg p  { margin: 0 0 8px; }
.bot-msg p:last-child { margin-bottom: 0; }
.bot-msg ul, .bot-msg ol { margin: 6px 0; padding-right: 20px; }
.bot-msg li { margin-bottom: 4px; }
.bot-msg strong { font-weight: 700; }
.bot-msg code { background: rgba(0,0,0,0.05); border-radius: 4px; padding: 1px 5px; font-size: 0.88em; }
.greeting-hint {
 background: transparent !important;
 box-shadow: none !important;
 color: #6b6b6b;
 font-size: 0.82rem;
 text-align: center;
 padding: 6px 0 !important;
     }
.typing-dots { display: inline-flex; gap: 4px; align-items: center; padding: 0; direction: ltr; }
.typing-dots span { width: 5px; height: 5px; border-radius: 50%; background: #fb923c; animation: typingBounce 1.2s infinite ease-in-out; }
.bot-msg:has(.typing-dots) { background: transparent; box-shadow: none; padding: 4px 8px; }
.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 typingBounce {
0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
30%           { transform: translateY(-6px); opacity: 1; }
    }

.history-divider {
    text-align: center;
    color: #6b6b6b;
    font-size: 0.8rem;
    margin: 4px 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.history-divider::before, .history-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(0,0,0,0.08);
}

.chat-input-area {
    flex-shrink: 0;
    display: flex;
    padding: 20px;
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    background: transparent;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: none;
    gap: 15px;
    align-items: flex-end;
}

.chat-input-area textarea {
    flex: 1;
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    font-family: 'Heebo', sans-serif;
    font-size: 16px;
    line-height: 1.4;
    outline: none;
    transition: background 0.3s ease, border 0.3s ease, box-shadow 0.3s ease;
    direction: rtl;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.02);
    resize: none;
    overflow-y: auto;
    min-height: 44px;
    max-height: 140px;
}

.chat-input-area textarea:focus {
    background: white;
    border: 1px solid #6b7280;
    box-shadow: 0 0 10px rgba(107, 114, 128, 0.2);
}

.chat-input-area button {
    background: #6b7280;
    color: white;
    border: none;
    padding: 10px 22px;
    border-radius: 30px;
    cursor: pointer;
    font-family: 'Heebo', sans-serif;
    font-weight: 600;
    font-size: 0.95rem;
    transition: transform 0.2s, background 0.2s;
    box-shadow: 0 4px 10px rgba(107, 114, 128, 0.3);
}

.chat-input-area button:hover { background: #4b5563; transform: translateY(-2px); }

.chat-input-area button:not(.image-btn) {
    background: none;
    color: #6b7280;
    padding: 0;
    min-width: 44px;
    min-height: 44px;
    border-radius: 6px;
    box-shadow: none;
    font-size: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.chat-input-area button:not(.image-btn)::after {
    content: '↑';
    font-size: 1.3rem;
    line-height: 1;
}
.chat-input-area button:not(.image-btn):hover {
    background: none;
    transform: none;
    color: #4b5563;
}

.video-container {
    position: relative;
    aspect-ratio: 16 / 9;
    width: 100%;
    max-width: 100%;
    min-height: 200px;
    overflow: hidden;
    border-radius: 12px;
    margin-top: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    background: #000;
}

.video-container iframe {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    border: none;
}

/* ========== ADMIN PANEL ========== */
.admin-container {
    flex: 1;
    min-width: 0;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 20px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.admin-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.admin-table th {
    background: rgba(107, 114, 128, 0.08);
    padding: 10px 12px;
    text-align: right;
    font-weight: 600;
    color: #555;
    border-bottom: 2px solid rgba(107, 114, 128, 0.15);
    white-space: nowrap;
}

.admin-table td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    color: #444;
    white-space: nowrap;
}

.admin-table tr:hover td { background: rgba(107, 114, 128, 0.03); }

.toggle-btn {
    padding: 4px 12px;
    min-height: 44px;
    border: none;
    border-radius: 8px;
    font-family: 'Heebo', sans-serif;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
}

.toggle-btn.btn-block   { background: rgba(239, 68, 68, 0.1);  color: #dc2626; }
.toggle-btn.btn-block:hover   { background: rgba(239, 68, 68, 0.2); }
.toggle-btn.btn-unblock { background: rgba(0, 208, 132, 0.1); color: #059669; }
.toggle-btn.btn-unblock:hover { background: rgba(0, 208, 132, 0.2); }

.user-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-active  { background: rgba(0, 208, 132, 0.12); color: #059669; }
.badge-blocked { background: rgba(239, 68, 68, 0.12);  color: #dc2626; }
.badge-admin   { background: rgba(107, 114, 128, 0.12); color: #6b7280; }

.sidebar-footer {
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    padding-top: 8px;
}

.admin-nav-btn {
    width: 100%;
    padding: 9px 14px;
    min-height: 44px;
    background: transparent;
    color: #6b6b6b;
    border: 1.5px solid rgba(0, 0, 0, 0.08);
    border-radius: 10px;
    font-family: 'Heebo', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: right;
}

.admin-nav-btn:hover {
    background: rgba(107, 114, 128, 0.07);
    border-color: rgba(107, 114, 128, 0.2);
    color: #6b7280;
}

.invite-code-field { display: none; }

.google-divider {
    display: none;
    align-items: center;
    gap: 8px;
    color: #6b6b6b;
    font-size: 0.82rem;
    margin: 2px 0;
}

.google-divider::before, .google-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(0, 0, 0, 0.1);
}

.google-btn-wrapper {
    display: none;
    justify-content: center;
}

/* ========== SPLASH SCREEN ========== */
#splashScreen {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.45s ease, visibility 0.45s;
}
#splashScreen.hidden { opacity: 0; visibility: hidden; }
.splash-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    text-align: center;
    padding: 0 24px;
}
.splash-logo-row { display: flex; align-items: center; gap: 12px; }
.splash-title {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #6b7280, #4b5563);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
}
.splash-spinner {
    width: 46px;
    height: 46px;
    border: 3.5px solid rgba(107, 114, 128, 0.22);
    border-top-color: #6b7280;
    border-radius: 50%;
    animation: spin 0.85s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#splashMsg { font-size: 1.05rem; font-weight: 500; color: #555; margin: 0; }
#splashSub { font-size: 0.87rem; color: #6b6b6b; margin: 0; }

/* ========== IMAGE UPLOAD ========== */
.chat-input-area .image-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 0;
    min-width: 44px;
    min-height: 44px;
    color: #6b6b6b;
    border-radius: 0;
    transition: color 0.15s;
    flex-shrink: 0;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.chat-input-area .image-btn:hover { background: none; color: #6b7280; }
.image-btn.has-image { color: #00d084; }

.image-preview-bar {
    display: none;
    flex-shrink: 0;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.5);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}
.image-preview-bar.visible { display: flex; }
.image-preview-bar img {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid rgba(107, 114, 128, 0.25);
    flex-shrink: 0;
}
.image-preview-info { flex: 1; min-width: 0; }
.image-preview-name {
    font-size: 0.82rem;
    color: #555;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}
.image-preview-size { font-size: 0.75rem; color: #6b6b6b; display: block; }
.image-privacy-note { font-size: 0.72rem; color: #6b6b6b; display: block; }
.remove-image-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #ef4444;
    font-size: 1.1rem;
    padding: 4px 8px;
    border-radius: 6px;
    flex-shrink: 0;
}
.remove-image-btn:hover { background: rgba(239, 68, 68, 0.08); }

.msg-image-badge {
    display: inline-block;
    font-size: 0.75rem;
    background: rgba(107, 114, 128, 0.12);
    color: #6b7280;
    border-radius: 10px;
    padding: 2px 8px;
    margin-bottom: 5px;
}

/* ========== HAMBURGER BUTTON ========== */
.hamburger-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.35rem;
    color: #555;
    padding: 4px 8px;
    border-radius: 8px;
    line-height: 1;
    transition: background 0.15s;
}
.hamburger-btn:hover { background: rgba(0, 0, 0, 0.06); }

/* ========== SIDEBAR OVERLAY ========== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.42);
    z-index: 99;
    cursor: pointer;
}
.sidebar-overlay.open { display: block; }

/* ========== RESPONSIVE — MOBILE ========== */
@media (max-width: 768px) {
    body { align-items: flex-start; }

    .auth-container {
        width: calc(100% - 32px);
        max-width: 440px;
        margin: 16px;
        padding: 28px 20px;
    }

    /* App layout: fill the full viewport */
    .app-layout {
        position: fixed;
        inset: 0;
        width: 100%;
        max-width: 100%;
        height: 100vh;
        height: 100dvh;
        gap: 0;
    }

    /* Sidebar becomes a slide-in drawer from the right (RTL) */
    .sidebar {
        position: fixed;
        top: 0;
        right: -280px;
        height: 100%;
        width: 280px;
        min-width: 280px;
        border-radius: 0;
        z-index: 100;
        padding-top: max(14px, env(safe-area-inset-top));
        transition: right 0.27s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .sidebar.open { right: 0; }

    /* Chat and admin fill full width */
    .chat-container,
    .admin-container {
        width: 100%;
        flex: 1;
        border-radius: 0;
    }

    /* Show hamburger */
    .hamburger-btn { display: inline-flex; align-items: center; justify-content: center; }

    /* Tighter message area */
    .chat-messages { padding: 14px 12px; gap: 14px; }
    .chat-input-area {
        padding: 10px 12px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
        gap: 8px;
    }
    .message { max-width: 88%; }

    /* Truncate long email on small screens */
    .user-email { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

    /* YouTube iframes scale to container width (already responsive via padding-bottom trick) */
    .video-container { margin-top: 8px; }
}

/* ========== AUTH SCREEN BACKGROUND ORBS ========== */
.auth-bg {
    position: fixed;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}

.auth-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(55px);
    opacity: 0.38;
    will-change: transform;
}

.auth-orb-1 {
    width: 360px;
    height: 360px;
    background: radial-gradient(circle, rgba(102,126,234,0.9), rgba(118,75,162,0.6));
    top: -100px;
    right: -90px;
    animation: orbFloat1 14s ease-in-out infinite;
}

.auth-orb-2 {
    width: 270px;
    height: 270px;
    background: radial-gradient(circle, rgba(161,140,209,0.8), rgba(251,194,235,0.5));
    bottom: 8%;
    left: -60px;
    animation: orbFloat2 19s ease-in-out infinite;
}

.auth-orb-3 {
    width: 210px;
    height: 210px;
    background: radial-gradient(circle, rgba(79,172,254,0.7), rgba(102,126,234,0.55));
    top: 38%;
    left: 8%;
    animation: orbFloat3 11s ease-in-out infinite;
}

@keyframes orbFloat1 {
    0%, 100% { transform: translate(0, 0); }
    33%      { transform: translate(28px, 32px); }
    66%      { transform: translate(-18px, 16px); }
}

@keyframes orbFloat2 {
    0%, 100% { transform: translate(0, 0); }
    40%      { transform: translate(32px, -26px); }
    70%      { transform: translate(-12px, 12px); }
}

@keyframes orbFloat3 {
    0%, 100% { transform: translate(0, 0); }
    50%      { transform: translate(-22px, -28px); }
}

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

@media (prefers-reduced-motion: reduce) {
    .auth-orb { animation: none; }
    .auth-container { animation: none !important; }
}

/* ========== KEYBOARD FOCUS ========== */
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
    outline: 2px solid #4b5563;
    outline-offset: 2px;
}

/* ========== TOUCH SCREENS: delete button always visible ========== */
@media (hover: none) {
    .conv-delete-btn { opacity: 1; }
}

/* ========== TOUCH TARGET: remove-image-btn ========== */
.remove-image-btn {
    min-width: 44px;
    min-height: 44px;
}

/* ========== TOUCH TARGET: resend button ========== */
#resendBtn {
    min-height: 44px;
    padding-top: 8px;
    padding-bottom: 8px;
}

/* ========== VERIFY CODE INPUT ========== */
#verifyCodeInput {
    text-align: center;
    font-size: 1.5rem;
    letter-spacing: 0.25em;
    padding-top: 9px;
    padding-bottom: 9px;
}
#verifyCodeInput::placeholder {
    font-size: 1rem;
    letter-spacing: normal;
}

/* ========== EMAIL INLINE FEEDBACK ========== */
.field-hint {
    font-size: 0.82rem;
    padding: 2px 4px;
    margin-top: -6px;
}
#emailError    { color: #dc2626; display: none; }
#emailSuggestion { color: #6b7280; display: none; }
#emailSuggestion button {
    background: none;
    border: none;
    color: #4b5563;
    font-family: 'Heebo', sans-serif;
    font-size: 0.82rem;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
}

/* ========== CHANGE EMAIL LINK ========== */
#changeEmailBtn {
    background: none;
    border: none;
    color: #6b7280;
    font-family: 'Heebo', sans-serif;
    font-size: 0.82rem;
    cursor: pointer;
    text-decoration: underline;
    margin-top: 2px;
    min-height: 44px;
    padding-top: 8px;
    padding-bottom: 8px;
}

/* ========== LEGAL FOOTER LINKS ========== */
.legal-links {
    text-align: center;
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid rgba(0,0,0,0.06);
    font-size: 0.77rem;
    color: #9ca3af;
    line-height: 1.9;
}

.legal-links a {
    color: #9ca3af;
    text-decoration: none;
}

.legal-links a:hover {
    color: #6b7280;
    text-decoration: underline;
}

.sidebar .legal-links {
    margin-top: 0;
    font-size: 0.73rem;
    padding: 8px 6px;
}

/* ========== TERMS CHECKBOX (registration form) ========== */
.terms-checkbox-row {
    padding: 4px 0 2px;
    font-size: 0.86rem;
    color: #4b5563;
    line-height: 1.5;
}
.terms-checkbox-row label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    cursor: pointer;
}
.terms-checkbox-row input[type="checkbox"] {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
    margin-top: 2px;
    cursor: pointer;
    accent-color: #6b7280;
}
.terms-checkbox-row a {
    color: #6b7280;
    text-decoration: underline;
}

/* ========== TERMS / DELETE ACCOUNT MODAL ========== */
.terms-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.terms-modal {
    background: #fff;
    border-radius: 16px;
    padding: 32px 28px;
    max-width: 440px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    text-align: center;
    direction: rtl;
}
.terms-modal h2 {
    margin: 0 0 14px;
    font-size: 1.25rem;
    color: #1f2937;
}
.terms-modal p {
    color: #4b5563;
    font-size: 0.92rem;
    line-height: 1.6;
    margin: 0 0 22px;
}
.terms-modal a {
    color: #6b7280;
    text-decoration: underline;
}
.terms-modal-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.terms-modal-logout-btn {
    background: none;
    border: 1.5px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    padding: 10px 16px;
    font-family: 'Heebo', sans-serif;
    font-size: 0.9rem;
    color: #6b7280;
    cursor: pointer;
    min-height: 44px;
}
.terms-modal-logout-btn:hover {
    background: rgba(0, 0, 0, 0.04);
}

/* ========== DELETE ACCOUNT BUTTON (sidebar footer) ========== */
.delete-account-btn {
    width: 100%;
    padding: 9px 14px;
    min-height: 44px;
    background: transparent;
    color: #9ca3af;
    border: 1.5px solid rgba(0, 0, 0, 0.06);
    border-radius: 8px;
    font-family: 'Heebo', sans-serif;
    font-size: 0.83rem;
    cursor: pointer;
    text-align: center;
}
.delete-account-btn:hover {
    color: #c0392b;
    border-color: rgba(192, 57, 43, 0.3);
    background: rgba(192, 57, 43, 0.04);
}
