:root { --brand: #f1776c; --brand-dark: #e06358; --ink: #2d2f31; --page-w: 1200px; }
* { box-sizing: border-box; font-family: 'Cairo', sans-serif; margin: 0; padding: 0; }
body { background-color: #f4f6f9; color: #333; padding-bottom: 70px; }

.nav {
    background: #ffffff; border-bottom: 1px solid #eef2f5;
    padding: 12px max(20px, calc((100% - var(--page-w)) / 2));
    display: flex; justify-content: space-between; align-items: center; box-shadow: 0 2px 10px rgba(0,0,0,0.03);
    flex-wrap: wrap; gap: 10px;
}
.nav-title h2 { color: var(--brand); font-size: 22px; cursor: pointer; }
.nav-links { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.nav-links a { text-decoration: none; color: #666; font-size: 14px; font-weight: 600; cursor: pointer; }
.nav-links a.active, .nav-links a:hover { color: var(--brand); }

.nav-search-box {
    display: flex; align-items: center; background: #f4f6f9; border-radius: 20px; padding: 4px 12px; border: 1px solid #ddd;
}
.nav-search-box input { border: none; background: transparent; outline: none; font-size: 13px; padding: 4px; width: 140px; }
.nav-search-box button { background: none; border: none; color: var(--brand); cursor: pointer; font-size: 13px; }

.auth-container, .setup-container, .send-container, .search-results-container {
    width: calc(100% - 30px); margin: 40px auto; background: #fff;
    padding: 34px; border-radius: 15px; box-shadow: 0 4px 20px rgba(0,0,0,0.05); text-align: center;
}
.auth-container, .send-container { max-width: 560px; }
.setup-container, .search-results-container { max-width: 760px; }
.auth-container h3, .setup-container h3, .send-container h3, .search-results-container h3 { margin-bottom: 20px; color: #333; }

.page-wrap { width: 100%; max-width: var(--page-w); margin: 0 auto; padding: 22px 20px 0; }
.page-wrap.narrow { max-width: 960px; }
.page-wrap.wide { max-width: 1320px; }

.form-group { margin-bottom: 15px; text-align: right; }
.form-group label { display: block; font-size: 13px; margin-bottom: 5px; color: #666; }
.form-control { width: 100%; padding: 12px; border: 1px solid #ddd; border-radius: 8px; outline: none; font-size: 14px; }
.form-control:focus { border-color: var(--brand); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.form-grid .span-2 { grid-column: 1 / -1; }

.btn-group { display: flex; gap: 10px; margin-top: 15px; }
.btn-primary, .btn-secondary, .btn-danger {
    border: none; padding: 12px; border-radius: 8px; flex: 1;
    font-size: 14px; font-weight: bold; cursor: pointer; transition: all 0.2s ease;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { background: var(--ink); color: #fff; }
.btn-secondary:hover { background: #1e2022; }
.btn-danger { background: #e74c3c; color: #fff; }
.btn-danger:hover { background: #c0392b; }
.btn-primary:disabled { background: #ccc; cursor: not-allowed; }

.app-section { display: none; }

.messages-layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 20px; align-items: start; }
.profile-card {
    background: #fff; padding: 28px 25px; border-radius: 15px; text-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.04); position: relative;
}
.messages-layout .profile-card { position: sticky; top: 16px; }
.avatar-preview {
    width: 90px; height: 90px; border-radius: 50%; object-fit: cover;
    margin: 0 auto 10px; border: 3px solid var(--brand); display: block; background: #eee;
}
.user-header-flex { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 5px; }
.user-name { font-size: 20px; font-weight: bold; }
.user-link { display: block; color: #888; font-size: 13px; margin-bottom: 15px; word-break: break-all; }
.btn-share { background: var(--brand); color: #fff; border: none; padding: 10px 20px; border-radius: 20px; font-size: 14px; font-weight: bold; cursor: pointer; width: 100%; max-width: 250px; }
.meta-line { color: #888; font-size: 12px; margin-bottom: 10px; }

.admin-card { background: #fff; padding: 24px; border-radius: 12px; margin-bottom: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.03); }
.messages-layout .admin-card { margin-bottom: 0; min-height: 280px; }
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 15px; margin-bottom: 20px; }
.stat-box { background: #f8f9fa; padding: 15px; border-radius: 10px; text-align: center; }
.stat-box h4 { font-size: 20px; color: var(--brand); }

.table-responsive { width: 100%; overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 13px; white-space: nowrap; }
.admin-table th, .admin-table td { padding: 12px 10px; text-align: right; border-bottom: 1px solid #eee; }
.admin-table td.wrap { white-space: normal; min-width: 220px; }
.user-badge { padding: 3px 8px; border-radius: 12px; font-size: 11px; background: #e8f5e9; color: #2e7d32; }

.message-box { background: #fdfdfd; border: 1px solid #eee; padding: 15px; border-radius: 10px; margin-bottom: 12px; text-align: right; }
.message-box p { font-size: 15px; color: #444; margin-bottom: 8px; }
.message-box span { font-size: 12px; color: #888; }
.message-actions { display: flex; gap: 8px; margin-top: 10px; }
.btn-delete { background: #e74c3c; color: #fff; border: none; padding: 6px 14px; border-radius: 6px; font-size: 12px; cursor: pointer; }

.btn-logout { background: #e74c3c; color: white; border: none; padding: 6px 12px; border-radius: 6px; font-size: 12px; cursor: pointer; }
.status-msg { font-size: 13px; margin-top: 15px; padding: 12px; border-radius: 8px; font-weight: 600; display: none; text-align: right; }

.avatar-edit { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 22px; }
.avatar-large { width: 120px; height: 120px; border-radius: 50%; object-fit: cover; border: 3px solid var(--brand); background: #eee; }
.avatar-change {
    display: inline-flex; align-items: center; gap: 7px; background: #fff; border: 1px solid #e3e6ea; color: #555;
    border-radius: 20px; padding: 7px 16px; font-size: 13px; font-weight: 600; cursor: pointer; user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.avatar-change:hover { border-color: var(--brand); color: var(--brand); }
.avatar-change i { font-size: 14px; }

body.is-admin .admin-hidden { display: none !important; }

.search-user-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px; border-bottom: 1px solid #eee; text-align: right; gap: 15px;
}
.search-user-info { display: flex; align-items: center; gap: 12px; }
.search-user-avatar { width: 45px; height: 45px; border-radius: 50%; object-fit: cover; border: 2px solid var(--brand); }

.ticker-bar {
    position: fixed; bottom: 0; left: 0; width: 100%;
    background: var(--ink); color: #fff; height: 42px;
    display: flex; align-items: center; overflow: hidden;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.15); z-index: 1000;
}
.ticker-title {
    background: var(--brand); color: #fff; padding: 0 15px; height: 100%;
    display: flex; align-items: center; font-size: 13px; font-weight: bold;
    white-space: nowrap; z-index: 3;
}
.ticker-wrapper { position: relative; width: 100%; height: 100%; overflow: hidden; display: flex; align-items: center; }
.ticker-text { position: absolute; white-space: nowrap; animation: marquee-rtl 25s linear infinite; font-size: 13px; display: inline-flex; align-items: center; will-change: transform; }
.ticker-text span { margin-left: 50px; color: #f8f9fa; display: inline-flex; align-items: center; gap: 6px; }
.ticker-text i { color: var(--brand); }
@keyframes marquee-rtl { 0% { transform: translateX(0%); } 100% { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) { .ticker-text { animation-duration: 90s; } }

@media (max-width: 900px) {
    .messages-layout { grid-template-columns: minmax(0, 1fr); }
    .messages-layout .profile-card { position: static; }
}
@media (max-width: 640px) {
    .form-grid { grid-template-columns: minmax(0, 1fr); }
    .auth-container, .setup-container, .send-container, .search-results-container { padding: 24px 18px; margin: 24px auto; }
    .page-wrap { padding: 16px 12px 0; }
    .nav-links { gap: 10px; }
}