/* ===== Design tokens ===== */
:root{
  --bg-app:#0C0D17;
  --bg-panel:#151623;
  --bg-panel-2:#1C1E2F;
  --bg-hover:#242639;
  --bg-input:#1F2233;
  --border:#2A2C42;
  --text-1:#F5F4FA;
  --text-2:#9C9AB0;
  --text-3:#6D6B82;
  --accent:#7C6AFF;
  --accent-soft:#7C6AFF2b;
  --accent-2:#00E5A0;
  --danger:#FF5C7A;
  --bubble-mine:linear-gradient(135deg, #7C6AFF, #5B4FE0);
  --bubble-other:#1C1E2F;
  --accent-gradient:linear-gradient(135deg, #8B7CFF 0%, #7C6AFF 45%, #00E5A0 100%);
  --radius-lg:22px;
  --radius-md:16px;
  --radius-sm:11px;
  --shadow:0 20px 60px rgba(0,0,0,.45);
  --card-shadow:0 4px 18px rgba(10,8,30,.28);
  --font:'Tajawal', system-ui, sans-serif;
  --scrollbar-thumb:#34364e;
}

/* ===== المظهر الفاتح ===== */
html[data-theme="light"]{
  --bg-app:#F5F5FB;
  --bg-panel:#FFFFFF;
  --bg-panel-2:#EEEFF6;
  --bg-hover:#EFF0F9;
  --bg-input:#F2F2FA;
  --border:#E3E4F0;
  --text-1:#1B1C2B;
  --text-2:#65647A;
  --text-3:#9997AC;
  --accent:#7C6AFF;
  --accent-soft:#7C6AFF22;
  --accent-2:#00B389;
  --danger:#E23F63;
  --bubble-mine:linear-gradient(135deg, #8B7CFF, #7C6AFF);
  --bubble-other:#EFF0F9;
  --accent-gradient:linear-gradient(135deg, #8B7CFF 0%, #7C6AFF 45%, #00B389 100%);
  --shadow:0 20px 50px rgba(20,20,50,.10);
  --card-shadow:0 3px 14px rgba(40,30,90,.07);
  --scrollbar-thumb:#DADCEC;
}
html[data-theme="light"] .brand-mark,
html[data-theme="light"] .chat-empty-mark{
  background:linear-gradient(90deg, #4b4a63, var(--accent) 70%);
  -webkit-background-clip:text; background-clip:text; color:transparent;
}

*{box-sizing:border-box;}
html,body{height:100%;}
body{
  margin:0;
  font-family:var(--font);
  background:var(--bg-app);
  color:var(--text-1);
}
input,button{font-family:var(--font);}
button{cursor:pointer;}
.hidden{display:none !important;}

/* subtle ambient glow behind everything */
body::before{
  content:'';
  position:fixed; inset:0;
  background:
    radial-gradient(600px 400px at 15% 10%, #6C5CE71a, transparent 60%),
    radial-gradient(500px 350px at 90% 85%, #00D9A314, transparent 60%);
  pointer-events:none;
  z-index:0;
}

/* ===== Auth screen ===== */
.auth-screen{
  position:relative; z-index:1;
  min-height:100vh;
  display:flex; align-items:center; justify-content:center;
  padding:24px;
  overflow-y:auto;
}
.auth-card{
  width:100%; max-width:400px;
  background:var(--bg-panel);
  border:1px solid var(--border);
  border-radius:var(--radius-lg);
  padding:36px 32px;
  box-shadow:var(--shadow);
}
.brand{ text-align:center; margin-bottom:28px; }
.brand-mark{
  font-size:34px; font-weight:900; color:var(--text-1);
  letter-spacing:-.5px;
  display:inline-block;
  background:linear-gradient(90deg, #E8E6FF, var(--accent) 70%);
  -webkit-background-clip:text; background-clip:text; color:transparent;
}
.brand-tag{ color:var(--text-2); font-size:14px; margin:6px 0 0; }

.auth-tabs{
  display:flex; background:var(--bg-input); border-radius:12px; padding:4px; margin-bottom:22px;
}
.auth-tab{
  flex:1; border:0; background:transparent; padding:10px 0;
  color:var(--text-2); font-weight:700; font-size:14px; border-radius:9px;
  transition:.2s;
}
.auth-tab.active{ background:var(--accent); color:#fff; }

.auth-form{ display:none; flex-direction:column; gap:16px; }
.auth-form.active{ display:flex; }

.field{ display:flex; flex-direction:column; gap:7px; }
.field span{ font-size:13px; color:var(--text-2); font-weight:500; }
.field input{
  background:var(--bg-input); border:1px solid var(--border); color:var(--text-1);
  border-radius:var(--radius-sm); padding:12px 14px; font-size:15px; outline:none;
  transition:.15s border-color;
}
.field input:focus{ border-color:var(--accent); }

.btn-primary{
  background:var(--accent-gradient); color:#fff; border:0; border-radius:var(--radius-sm);
  padding:13px; font-size:15px; font-weight:700; transition:.15s transform, .15s filter;
  box-shadow:0 4px 14px #7C6AFF33;
}
.btn-primary:hover{ filter:brightness(1.08); }
.btn-primary:active{ transform:scale(.98); }

.auth-error{ color:var(--danger); font-size:13px; min-height:16px; margin:0; }

/* ===== App layout ===== */
.app-screen{
  position:relative; z-index:1;
  height:100vh; display:flex;
  overflow:hidden;
}

/* ===== Rail navigation ===== */
.rail{
  width:88px; min-width:88px;
  background:var(--bg-panel);
  border-left:1px solid var(--border);
  display:flex; flex-direction:column; align-items:stretch;
  padding:16px 8px; gap:6px;
  overflow-y:auto;
}
.rail-btn{
  display:flex; flex-direction:column; align-items:center; gap:4px;
  background:transparent; border:0; color:var(--text-2);
  padding:11px 4px; border-radius:14px; font-size:11px; font-weight:700;
  position:relative; transition:.15s;
}
.rail-btn:hover{ background:var(--bg-hover); color:var(--text-1); }
.rail-btn.active{ background:var(--accent-soft); color:var(--accent); }
.rail-icon{ font-size:21px; }
.rail-me{ margin-top:auto; }
.rail-badge{
  position:absolute; top:4px; left:20px;
  background:var(--danger); color:#fff; font-size:10px; font-weight:800;
  min-width:16px; height:16px; border-radius:20px; display:flex; align-items:center; justify-content:center;
  padding:0 4px;
}

/* ===== Sections ===== */
.section{ display:none; flex:1; min-width:0; min-height:0; }
.section.active{ display:flex; flex-direction:column; min-height:0; }
#section-chats.active{ flex-direction:row; }

.section-title{ font-weight:800; font-size:16px; }
.page-title{ padding:18px 4px 4px; }
.page-scroll{ flex:1; overflow-y:auto; min-height:0; }
.page-inner{ max-width:640px; margin:0 auto; padding:0 16px 90px; display:flex; flex-direction:column; gap:16px; }
.block-title{ font-size:14px; font-weight:800; color:var(--text-2); margin:10px 0 -4px; }

/* ===== Feed ===== */
.composer-card{
  background:var(--bg-panel); border:1px solid var(--border); border-radius:var(--radius-md);
  padding:14px; display:flex; flex-direction:column; gap:10px; box-shadow:var(--card-shadow);
}
.composer-card-top{ display:flex; gap:11px; align-items:flex-start; }
.composer-card-top textarea{
  flex:1; background:var(--bg-input); border:1px solid var(--border); color:var(--text-1);
  border-radius:12px; padding:11px 14px; font-size:14.5px; outline:none; resize:none; font-family:var(--font);
}
.composer-card-top textarea:focus{ border-color:var(--accent); }
.composer-card-bottom{ display:flex; align-items:center; justify-content:space-between; }
.btn-post{ padding:9px 26px; font-size:14px; width:auto; }
.post-image-preview{ position:relative; display:inline-block; align-self:flex-start; }
.post-image-preview img{ max-height:180px; border-radius:10px; display:block; }
.post-image-preview video{ max-height:220px; max-width:100%; border-radius:10px; display:block; }
.post-image-preview .icon-btn{
  position:absolute; top:-8px; left:-8px; width:26px; height:26px; font-size:12px;
  background:#000000cc; border-color:transparent;
}

.feed-list{ display:flex; flex-direction:column; gap:14px; }
.post-card{
  background:var(--bg-panel); border:1px solid var(--border); border-radius:var(--radius-md); padding:16px;
  box-shadow:var(--card-shadow); transition:.15s transform;
}
.post-card:hover{ transform:translateY(-1px); }
.post-head{ display:flex; align-items:center; gap:10px; }
.post-head-info{ flex:1; min-width:0; }
.post-author{ font-weight:700; font-size:14.5px; }
.post-time{ font-size:12px; color:var(--text-3); }
.post-delete{ background:transparent; border:0; color:var(--text-3); font-size:16px; }
.post-edit-btn{ background:transparent; border:0; color:var(--text-3); font-size:15px; margin-inline-end:4px; }
.post-edit-btn:hover{ color:var(--accent); }
.edited-tag{ font-size:11px; color:var(--text-3); font-weight:400; }
.edit-box{ display:flex; flex-direction:column; gap:8px; }
.edit-textarea{
  width:100%; background:var(--bg-input); border:1px solid var(--border); color:var(--text-1);
  border-radius:10px; padding:10px 12px; font-size:14px; font-family:var(--font); resize:vertical; min-height:60px;
}
.edit-box-actions{ display:flex; gap:8px; }
.msg-edit-btn{
  background:transparent; border:0; color:inherit; opacity:.6; font-size:12px; margin-inline-end:6px;
  vertical-align:middle; cursor:pointer;
}
.msg-edit-btn:hover{ opacity:1; }
.msg-text{ display:inline; }
.bubble .edit-box{ min-width:200px; }
.bubble .edit-textarea{ color:var(--text-1); background:#00000022; border-color:#ffffff33; }
.msg-row.theirs .edit-textarea{ background:var(--bg-input); border-color:var(--border); }
.post-content{ margin:12px 0 0; font-size:14.5px; line-height:1.75; white-space:pre-wrap; }
.post-image{ max-width:100%; border-radius:12px; margin-top:12px; display:block; }
.post-video{ max-width:100%; border-radius:12px; margin-top:12px; display:block; background:#000; }
.post-actions{ display:flex; gap:8px; margin-top:12px; border-top:1px solid var(--border); padding-top:10px; }
.post-action-btn{
  flex:1; background:transparent; border:0; color:var(--text-2); font-size:13.5px; font-weight:700;
  padding:8px; border-radius:9px; display:flex; align-items:center; justify-content:center; gap:6px;
}
.post-action-btn:hover{ background:var(--bg-hover); }
.post-action-btn.liked{ color:var(--accent-2); }
.comments-block{ margin-top:10px; display:none; flex-direction:column; gap:9px; }
.comments-block.open{ display:flex; }
.comment-row{ display:flex; gap:8px; }
.comment-bubble{ background:var(--bg-input); border-radius:12px; padding:7px 12px; font-size:13.5px; flex:1; }
.comment-author{ font-weight:700; font-size:12.5px; color:var(--accent-2); display:block; }
.comment-form{ display:flex; gap:8px; margin-top:4px; }
.comment-form input{
  flex:1; background:var(--bg-input); border:1px solid var(--border); color:var(--text-1);
  border-radius:20px; padding:8px 14px; font-size:13.5px; outline:none;
}

/* ===== Friends ===== */
.person-row .person-actions{ margin-right:auto; display:flex; gap:6px; }
.notif-row{ cursor:pointer; }
.notif-row.unread{ background:var(--accent-soft); border-radius:12px; }
.notif-row.unread .person-name{ font-weight:800; }
.chip-btn{
  border:0; border-radius:20px; padding:7px 14px; font-size:12.5px; font-weight:700; color:#fff;
  background:var(--accent);
}
.chip-btn.outline{ background:transparent; border:1px solid var(--border); color:var(--text-2); }
.chip-btn.danger{ background:var(--danger); }
.chip-btn:disabled{ opacity:.6; }

/* ===== Store ===== */
.store-card{
  background:var(--bg-panel); border:1px solid var(--border); border-radius:var(--radius-md); padding:16px;
}
.store-form{ display:flex; flex-direction:column; gap:10px; margin-top:10px; }
.store-image-row{ display:flex; align-items:center; gap:12px; }
.store-image-preview{
  width:64px; height:64px; border-radius:14px; background:var(--bg-input); border:1px solid var(--border);
  display:flex; align-items:center; justify-content:center; font-size:26px; overflow:hidden;
}
.store-image-preview img{ width:100%; height:100%; object-fit:cover; }
.store-form-actions{ display:flex; gap:10px; margin-top:4px; }
.store-form-actions .btn-primary{ flex:1; }

.store-directory{ display:flex; flex-direction:column; gap:12px; }

.market-tabs{ display:flex; gap:8px; }
.market-tab{
  flex:1; background:var(--bg-input); border:1px solid var(--border); color:var(--text-2);
  border-radius:var(--radius-sm); padding:12px; font-size:14px; font-weight:700;
}
.market-tab.active{ background:var(--accent); color:#fff; border-color:var(--accent); }
.market-panel.hidden{ display:none; }
.store-item{
  background:var(--bg-panel); border:1px solid var(--border); border-radius:var(--radius-md);
  padding:14px; display:flex; gap:12px; box-shadow:var(--card-shadow);
}
.store-item-thumb{
  width:56px; height:56px; border-radius:12px; flex-shrink:0; overflow:hidden;
  background:var(--bg-input); display:flex; align-items:center; justify-content:center; font-size:22px;
}
.store-item-thumb img{ width:100%; height:100%; object-fit:cover; }
.store-item-main{ flex:1; min-width:0; }
.store-item-top{ display:flex; align-items:center; gap:8px; justify-content:space-between; }
.store-item-name{ font-weight:700; font-size:14.5px; }
.store-category-badge{
  font-size:11px; font-weight:700; padding:3px 9px; border-radius:20px;
  background:var(--accent-soft); color:var(--accent); flex-shrink:0;
}
.store-item-desc{ font-size:13px; color:var(--text-2); margin:5px 0; line-height:1.6; }
.store-item-owner{ font-size:12px; color:var(--text-3); }
.store-item-actions{ margin-top:8px; display:flex; gap:8px; }

.btn-secondary{
  background:var(--bg-input); color:var(--text-1); border:1px solid var(--border); border-radius:var(--radius-sm);
  padding:12px; font-size:14px; font-weight:700; margin-top:8px;
}
.btn-danger{
  background:transparent; color:var(--danger); border:1px solid var(--danger); border-radius:var(--radius-sm);
  padding:12px; font-size:14px; font-weight:700;
}
.profile-avatar-row{ display:flex; align-items:center; gap:12px; margin-bottom:6px; }

.theme-toggle{ display:flex; gap:8px; }
.theme-btn{
  flex:1; background:var(--bg-input); border:1px solid var(--border); color:var(--text-2);
  border-radius:var(--radius-sm); padding:10px; font-size:13.5px; font-weight:700;
}
.theme-btn.active{ background:var(--accent); color:#fff; border-color:var(--accent); }

.lang-toggle{ display:flex; gap:8px; justify-content:center; margin-bottom:16px; }
.lang-btn{
  background:var(--bg-input); border:1px solid var(--border); color:var(--text-2);
  border-radius:20px; padding:6px 16px; font-size:12.5px; font-weight:700;
}
.lang-btn.active{ background:var(--accent); color:#fff; border-color:var(--accent); }

.product-images-row{ display:flex; gap:8px; flex-wrap:wrap; }
.product-image-thumb{
  position:relative; width:56px; height:56px; border-radius:10px; overflow:hidden;
  background:var(--bg-input); border:1px solid var(--border);
}
.product-image-thumb img{ width:100%; height:100%; object-fit:cover; }
.product-image-thumb .remove-thumb-btn{
  position:absolute; top:-2px; left:-2px; width:18px; height:18px; border-radius:50%;
  background:#000000cc; color:#fff; border:0; font-size:10px; display:flex; align-items:center; justify-content:center;
}
.product-price-tag{
  font-size:13px; font-weight:800; color:var(--accent-2); margin-top:2px;
}

.avatar img{ width:100%; height:100%; border-radius:50%; object-fit:cover; }
.ad-slot{ min-height:0; overflow:hidden; border-radius:var(--radius-md); }
.ad-slot:empty{ display:none; }

/* ===== Admin panel ===== */
.stats-grid{ display:grid; grid-template-columns:repeat(3, 1fr); gap:10px; }
.stat-card{
  background:var(--bg-panel); border:1px solid var(--border); border-radius:var(--radius-md);
  padding:14px; text-align:center;
}
.stat-value{ font-size:22px; font-weight:900; color:var(--accent-2); }
.stat-label{ font-size:12px; color:var(--text-2); margin-top:4px; }
.admin-users-list{ display:flex; flex-direction:column; gap:2px; }
.admin-row-name{ display:flex; align-items:center; gap:6px; }
.admin-badge{ font-size:10px; font-weight:800; padding:2px 7px; border-radius:20px; background:var(--accent-soft); color:var(--accent); }
.online-badge{ font-size:10px; font-weight:800; padding:2px 7px; border-radius:20px; background:#00D9A322; color:var(--accent-2); }
@media (max-width:480px){ .stats-grid{ grid-template-columns:repeat(2, 1fr); } }

.sidebar{
  width:360px; min-width:360px;
  background:var(--bg-panel);
  border-left:1px solid var(--border);
  display:flex; flex-direction:column;
}
.sidebar-header{
  display:flex; align-items:center; justify-content:space-between;
  padding:18px 18px 14px;
  border-bottom:1px solid var(--border);
}
.me{ display:flex; align-items:center; gap:11px; cursor:pointer; min-width:0; }
.me-info{ min-width:0; }
.me-name{ font-weight:700; font-size:15px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:150px; }
.me-status{ font-size:12px; color:var(--text-3); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:150px; }

.avatar{
  width:44px; height:44px; border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  font-weight:700; font-size:16px; color:#fff; flex-shrink:0;
  position:relative;
}
.avatar.sm{ width:36px; height:36px; font-size:13px; }

.sidebar-actions{ display:flex; gap:6px; }
.icon-btn{
  width:38px; height:38px; border-radius:50%; border:1px solid var(--border);
  background:var(--bg-input); color:var(--text-1); font-size:16px;
  display:flex; align-items:center; justify-content:center; transition:.15s;
}
.icon-btn:hover{ background:var(--bg-hover); border-color:var(--accent); }
.back-btn{ display:none; }

.search-box{ padding:14px 18px; }
.search-box input{
  width:100%; background:var(--bg-input); border:1px solid var(--border); color:var(--text-1);
  border-radius:12px; padding:10px 14px; font-size:14px; outline:none;
}
.search-box input:focus{ border-color:var(--accent); }

.conv-list{ flex:1; overflow-y:auto; padding:4px 8px 12px; }
.conv-item{
  display:flex; align-items:center; gap:11px; padding:11px 10px; border-radius:14px;
  cursor:pointer; transition:.12s; margin-bottom:2px; position:relative;
}
.conv-item:hover{ background:var(--bg-hover); }
.conv-item.active{ background:var(--accent-soft); }
.conv-main{ flex:1; min-width:0; }
.conv-top{ display:flex; justify-content:space-between; align-items:baseline; gap:8px; }
.conv-name{ font-weight:700; font-size:14.5px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.conv-time{ font-size:11px; color:var(--text-3); flex-shrink:0; }
.conv-bottom{ display:flex; justify-content:space-between; align-items:center; gap:8px; margin-top:2px; }
.conv-preview{ font-size:13px; color:var(--text-2); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.unread-badge{
  background:var(--accent-2); color:#04231A; font-size:11px; font-weight:800;
  border-radius:20px; min-width:19px; height:19px; padding:0 5px;
  display:flex; align-items:center; justify-content:center; flex-shrink:0;
}
.online-dot{
  position:absolute; bottom:-1px; left:-1px; width:11px; height:11px; border-radius:50%;
  background:var(--accent-2); border:2px solid var(--bg-panel);
}
.empty-hint{ text-align:center; color:var(--text-3); font-size:13.5px; padding:30px 20px; line-height:1.9; }

/* ===== Chat area ===== */
.chat-area{ flex:1; display:flex; flex-direction:column; min-width:0; }
.chat-empty{
  flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center;
  color:var(--text-3); gap:10px;
}
.chat-empty-mark{
  font-size:40px; font-weight:900;
  background:linear-gradient(90deg, var(--text-3), var(--accent) 80%);
  -webkit-background-clip:text; background-clip:text; color:transparent;
}
.chat-panel{ flex:1; display:flex; flex-direction:column; min-height:0; }

.chat-header{
  display:flex; align-items:center; gap:12px; padding:14px 20px;
  border-bottom:1px solid var(--border); background:var(--bg-panel);
}
.chat-header-info{ min-width:0; }
.chat-title{ font-weight:700; font-size:15.5px; }
.chat-subtitle{ font-size:12.5px; color:var(--text-3); }

.messages{
  flex:1; overflow-y:auto; padding:22px; display:flex; flex-direction:column; gap:3px;
  background:
    radial-gradient(500px 300px at 20% 0%, #6C5CE70d, transparent 60%);
}
.msg-row{ display:flex; margin:3px 0; max-width:100%; }
.msg-row.mine{ justify-content:flex-start; flex-direction:row-reverse; }
.msg-row.theirs{ justify-content:flex-start; }
.msg-group-sender{ font-size:11.5px; font-weight:700; color:var(--accent-2); margin:10px 4px 3px; }

.bubble{
  max-width:min(480px, 72vw);
  padding:10px 14px; border-radius:var(--radius-md);
  font-size:14.5px; line-height:1.65; position:relative; word-wrap:break-word;
}
.msg-row.mine .bubble{
  background:var(--bubble-mine); color:#fff; border-bottom-left-radius:5px;
}
.msg-row.theirs .bubble{
  background:var(--bubble-other); color:var(--text-1); border-bottom-right-radius:5px;
  border:1px solid var(--border);
}
.bubble img{ max-width:280px; border-radius:10px; display:block; margin-top:4px; cursor:pointer; }
.bubble .file-chip{
  display:flex; align-items:center; gap:8px; background:#00000022; padding:8px 10px; border-radius:9px; margin-top:4px;
  text-decoration:none; color:inherit;
}
.bubble .msg-time{ font-size:10.5px; opacity:.6; margin-top:4px; display:block; text-align:left; }

.day-divider{
  align-self:center; font-size:11.5px; color:var(--text-3); background:var(--bg-panel-2);
  padding:4px 12px; border-radius:20px; margin:14px 0;
}

.typing-indicator{
  font-size:12.5px; color:var(--accent-2); padding:0 22px 6px; min-height:18px;
}

.composer{
  display:flex; align-items:center; gap:10px; padding:14px 18px;
  border-top:1px solid var(--border); background:var(--bg-panel);
}
.composer input[type=text]{
  flex:1; background:var(--bg-input); border:1px solid var(--border); color:var(--text-1);
  border-radius:22px; padding:12px 18px; font-size:14.5px; outline:none;
}
.composer input[type=text]:focus{ border-color:var(--accent); }
.send-btn{
  width:42px; height:42px; border-radius:50%; border:0; background:var(--accent-gradient); color:#fff;
  font-size:16px; display:flex; align-items:center; justify-content:center; transition:.15s;
  box-shadow:0 3px 10px #7C6AFF40;
}
.send-btn:hover{ filter:brightness(1.08); transform:scale(1.04); }

/* ===== Modals ===== */
.modal-backdrop{
  position:fixed; inset:0; background:#00000090; backdrop-filter:blur(3px);
  display:flex; align-items:center; justify-content:center; z-index:50; padding:20px;
}
.modal{
  width:100%; max-width:440px; max-height:80vh; background:var(--bg-panel);
  border:1px solid var(--border); border-radius:var(--radius-lg); box-shadow:var(--shadow);
  display:flex; flex-direction:column; overflow:hidden;
}
.modal.small{ max-width:380px; }
.modal-header{ display:flex; align-items:center; justify-content:space-between; padding:16px 18px; border-bottom:1px solid var(--border); }
.modal-title-text{ font-weight:700; font-size:15.5px; }
.modal-tabs{ display:flex; gap:8px; }
.modal-tab{
  border:0; background:var(--bg-input); color:var(--text-2); padding:8px 14px; border-radius:20px;
  font-size:13px; font-weight:700;
}
.modal-tab.active{ background:var(--accent); color:#fff; }
.modal-body{ padding:16px 18px; overflow-y:auto; display:flex; flex-direction:column; gap:12px; }
.modal-search{
  background:var(--bg-input); border:1px solid var(--border); color:var(--text-1);
  border-radius:12px; padding:11px 14px; font-size:14px; outline:none;
}
.modal-search:focus{ border-color:var(--accent); }

.people-list{ display:flex; flex-direction:column; gap:2px; max-height:320px; overflow-y:auto; }
.person-row{
  display:flex; align-items:center; gap:11px; padding:9px 6px; border-radius:12px; cursor:pointer;
}
.person-row:hover{ background:var(--bg-hover); }
.person-row.selected{ background:var(--accent-soft); }
.person-name{ font-weight:700; font-size:14px; }
.person-sub{ font-size:12px; color:var(--text-3); }
.checkbox{
  margin-right:auto; width:20px; height:20px; border-radius:6px; border:2px solid var(--border);
  display:flex; align-items:center; justify-content:center; font-size:12px; color:#fff;
}
.person-row.selected .checkbox{ background:var(--accent); border-color:var(--accent); }

.color-row{ display:flex; gap:10px; }
.color-dot{ width:30px; height:30px; border-radius:50%; border:2px solid transparent; cursor:pointer; }
.color-dot.selected{ border-color:var(--text-1); }

/* ===== Scrollbars ===== */
::-webkit-scrollbar{ width:7px; }
::-webkit-scrollbar-thumb{ background:var(--scrollbar-thumb); border-radius:10px; }
::-webkit-scrollbar-track{ background:transparent; }

/* ===== Responsive ===== */
@media (max-width: 820px){
  .app-screen{ flex-direction:column; }
  .rail{
    order:2; width:100%; min-width:0; height:64px;
    flex-direction:row; align-items:stretch; justify-content:space-around;
    border-left:0; border-top:1px solid var(--border);
    position:fixed; bottom:0; right:0; left:0; z-index:30; padding:6px 4px;
  }
  .rail-btn{ flex:1; padding:6px 2px; border-radius:12px; }
  .rail-label{ font-size:9.5px; }
  .rail-me{ margin-top:0; }
  .rail-badge{ top:0; left:calc(50% - 4px); }

  #section-chats{ order:1; }
  .section{ order:1; padding-bottom:64px; }
  #section-chats.active{ padding-bottom:0; }

  .sidebar{ width:100%; min-width:0; position:absolute; inset:0; bottom:64px; z-index:5; }
  .chat-area{ width:100%; padding-bottom:0; }
  .chat-panel{ padding-bottom:0; }
  .app-screen.chat-open .sidebar{ display:none; }
  .app-screen.chat-open .rail{ display:none; }
  .app-screen.chat-open .section{ padding-bottom:0; }
  .app-screen.chat-open .chat-area{ position:fixed; inset:0; z-index:40; background:var(--bg-app); }
  .back-btn{ display:flex; }
  .bubble{ max-width:82vw; }

  .page-inner{ padding-bottom:80px; }
}
