/* =========================================================
   EKseni — الأنماط
   ========================================================= */
*, *::before, *::after { box-sizing: border-box; }

:root {
  --green: #00b894;
  --green-strong: #00a884;
  --green-deep: #005c4b;
  --bubble-in: #1f2c34;
  --bubble-out: #005c4b;
  --bg: #0b141a;
  --bg-soft: #111b21;
  --panel: #111b21;
  --panel-2: #1b262d;
  --panel-3: #202c33;
  --text: #e9edef;
  --text-soft: #d1d7db;
  --muted: #8696a0;
  --line: rgba(233, 237, 239, 0.09);
  --line-strong: rgba(233, 237, 239, 0.16);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.22);
  --danger: #f15c5c;
  --amber: #f0b429;
  --sky: #53bdeb;
  --radius: 18px;
  --radius-sm: 12px;
  --chat-bg: #0b141a;
  --wave: rgba(255, 255, 255, 0.018);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: "Segoe UI", "Noto Kufi Arabic", "Cairo", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

html.light {
  --bubble-in: #ffffff;
  --bubble-out: #d9fdd3;
  --bg: #efeae2;
  --bg-soft: #f7f5f2;
  --panel: #ffffff;
  --panel-2: #f0f2f5;
  --panel-3: #e9edef;
  --text: #111b21;
  --text-soft: #3b4a54;
  --muted: #667781;
  --line: rgba(17, 27, 33, 0.08);
  --line-strong: rgba(17, 27, 33, 0.14);
  --shadow: 0 18px 50px rgba(11, 20, 26, 0.18);
  --shadow-soft: 0 8px 24px rgba(11, 20, 26, 0.1);
  --chat-bg: #efeae2;
  --wave: rgba(0, 0, 0, 0.018);
  --green-strong: #008069;
  --green-deep: #008069;
}

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, textarea, select {
  font-family: inherit;
  color: inherit;
  font-size: inherit;
}

button { cursor: pointer; }

.hidden { display: none !important; }

.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

svg.ic {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ===================== شاشة التحميل ===================== */
.boot {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background:
    radial-gradient(700px 500px at 50% 0%, rgba(0, 184, 148, 0.16), transparent 70%),
    var(--bg);
  transition: opacity 0.35s ease, visibility 0.35s;
}
.boot.gone { opacity: 0; visibility: hidden; pointer-events: none; }
.boot h1 { margin: 14px 0 0; font-size: 34px; letter-spacing: 1px; }
.boot p { margin: 0; color: var(--muted); font-size: 14px; }
.boot-logo {
  position: relative;
  width: 96px;
  height: 96px;
  display: grid;
  place-items: center;
  border-radius: 30px;
  background: linear-gradient(145deg, #00c9a7, #008069);
  color: #04231d;
  box-shadow: 0 20px 60px rgba(0, 184, 148, 0.35);
  animation: pop 0.7s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.logo-mark { width: 54px; height: 54px; fill: currentColor; stroke: none; }
.logo-heart {
  position: absolute;
  width: 20px;
  height: 20px;
  left: 22px;
  bottom: 22px;
  fill: #00b894;
  stroke: none;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.3));
}
@keyframes pop { from { transform: scale(0.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.boot-dots { display: flex; gap: 6px; margin-top: 22px; }
.boot-dots span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--green); opacity: 0.3;
  animation: blink 1.2s infinite;
}
.boot-dots span:nth-child(2) { animation-delay: 0.2s; }
.boot-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 100% { opacity: 0.25; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-3px); } }

/* ===================== الدخول ===================== */
.auth {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  background:
    radial-gradient(900px 700px at 85% 10%, rgba(0, 184, 148, 0.12), transparent 60%),
    var(--bg);
}
.auth-art {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  padding: 60px clamp(28px, 7vw, 110px);
}
.auth-badge {
  width: fit-content;
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--text);
}
.auth-badge span { color: var(--green); }
.auth-art h2 {
  font-size: clamp(26px, 3.4vw, 44px);
  margin: 6px 0 0;
  line-height: 1.25;
  background: linear-gradient(100deg, var(--text), var(--green));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.auth-art > p { color: var(--muted); font-size: 16px; line-height: 1.85; max-width: 460px; margin: 0; }
.auth-points { list-style: none; padding: 0; margin: 18px 0 0; display: grid; gap: 14px; }
.auth-points li { display: flex; align-items: center; gap: 10px; color: var(--text-soft); font-size: 14.5px; }
.auth-points .ic { color: var(--green); }

.auth-panel {
  margin: auto;
  width: min(430px, 88%);
  padding: 30px;
  border-radius: 26px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.012));
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; background: rgba(0, 0, 0, 0.18); border-radius: 14px; margin-bottom: 22px; }
.auth-tabs button {
  border: 0; background: transparent; color: var(--muted); padding: 10px; border-radius: 10px;
  font-weight: 700; font-size: 14px; transition: 0.18s;
}
.auth-tabs button.active { background: var(--panel-3); color: var(--text); box-shadow: var(--shadow-soft); }
.auth-form { display: grid; gap: 14px; }
.form-error { margin: 0; min-height: 18px; font-size: 13px; color: var(--danger); }
.hint { margin: 0; font-size: 12px; color: var(--muted); text-align: center; }

/* ===================== الحقول ===================== */
.field { display: grid; gap: 7px; }
.field > span { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.field small { color: var(--muted); font-size: 11.5px; }
input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.16);
  border-radius: 12px;
  padding: 11px 13px;
  font-size: 14px;
  transition: border-color 0.15s, background 0.15s;
  color: var(--text);
}
html.light input, html.light textarea { background: #fff; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.8; }
input:focus, textarea:focus { outline: none; border-color: var(--green); background: rgba(0, 184, 148, 0.05); }
textarea { resize: vertical; line-height: 1.65; }

/* ===================== أزرار ===================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 16px;
  font-weight: 700;
  font-size: 13.5px;
  background: var(--panel-3);
  color: var(--text);
  transition: transform 0.12s, filter 0.15s, background 0.15s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: linear-gradient(135deg, #00c9a7, #008069); color: #04231d; }
html.light .btn.primary { color: #fff; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: var(--line-strong); color: var(--text-soft); }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.05); }
html.light .btn.ghost:hover { background: rgba(0, 0, 0, 0.04); }
.btn.danger { background: rgba(241, 92, 92, 0.14); color: var(--danger); border-color: rgba(241, 92, 92, 0.28); }
.btn.small { padding: 7px 12px; font-size: 12.5px; border-radius: 10px; }
.btn.wide { width: 100%; padding: 12px; font-size: 15px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.link-btn { border: 0; background: none; color: var(--green); font-size: 12.5px; font-weight: 700; padding: 0; }
.icon-btn {
  width: 40px; height: 40px; flex: none;
  display: inline-grid; place-items: center;
  border: 0; border-radius: 50%;
  background: transparent; color: var(--text-soft);
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.07); color: var(--text); }
html.light .icon-btn:hover { background: rgba(0, 0, 0, 0.05); }
.chip-btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  border-radius: 999px; padding: 6px 11px; font-size: 11.5px; font-weight: 600;
}
.chip-btn:hover { color: var(--text); border-color: var(--line-strong); }
.chip-btn.danger:hover { color: var(--danger); border-color: rgba(241, 92, 92, 0.4); }
.chip-btn .ic { width: 14px; height: 14px; }

/* ===================== الهيكل ===================== */
.app { display: grid; grid-template-columns: 300px 1fr; height: 100dvh; background: var(--bg); }

.side {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px 16px calc(14px + var(--safe-b));
  background: var(--panel);
  border-inline-end: 1px solid var(--line);
  min-height: 0;
}
.side-brand { display: flex; align-items: center; gap: 11px; padding: 2px 4px; }
.side-brand strong { display: block; font-size: 17px; letter-spacing: 0.4px; }
.side-brand small { display: block; color: var(--muted); font-size: 11px; margin-top: 1px; }
.brand-logo {
  position: relative; width: 40px; height: 40px; flex: none;
  border-radius: 13px; background: linear-gradient(145deg, #00c9a7, #008069);
  display: grid; place-items: center; color: #04231d;
}
.brand-logo .logo-mark { width: 23px; height: 23px; }
.brand-logo .logo-heart { width: 9px; height: 9px; left: 9px; bottom: 9px; }

.pair-card {
  display: flex; align-items: center; gap: 10px;
  padding: 12px; border-radius: 16px;
  background: linear-gradient(140deg, rgba(0, 184, 148, 0.12), rgba(0, 184, 148, 0.02));
  border: 1px solid rgba(0, 184, 148, 0.18);
}
.pair-avatars { display: flex; direction: ltr; }
.pair-avatars .avatar { width: 34px; height: 34px; border: 2px solid var(--panel); margin-left: -10px; }
.pair-avatars .avatar:first-child { margin-left: 0; }
.pair-info { min-width: 0; }
.pair-info strong { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pair-info .status-line { font-size: 11px; }

.side-nav { display: flex; flex-direction: column; gap: 4px; }
.nav-btn {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  border: 0; background: transparent; color: var(--muted);
  padding: 10px 12px; border-radius: 12px; font-weight: 600; font-size: 13.5px;
  transition: background 0.15s, color 0.15s;
  text-align: start;
}
.nav-btn .ic { width: 19px; height: 19px; }
.nav-btn:hover { background: rgba(255, 255, 255, 0.05); color: var(--text); }
html.light .nav-btn:hover { background: rgba(0, 0, 0, 0.04); }
.nav-btn.active { background: rgba(0, 184, 148, 0.14); color: var(--green); }
.nav-btn.active::before {
  content: ""; position: absolute; inset-inline-start: -16px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 3px; background: var(--green);
}
.badge {
  margin-inline-start: auto;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--green); color: #04231d;
  font-size: 10.5px; font-weight: 800;
  display: grid; place-items: center;
}
.side-spacer { flex: 1; }
.peer-mini { padding: 10px 12px; border-radius: 12px; border: 1px dashed var(--line); }
.peer-mini .status-line { font-size: 12px; }
.peer-mini p { margin: 6px 0 0; font-size: 11px; color: var(--muted); line-height: 1.6; }
.side-foot { display: grid; gap: 10px; border-top: 1px solid var(--line); padding-top: 12px; }
.me-row { display: flex; align-items: center; gap: 10px; }
.me-info { min-width: 0; flex: 1; }
.me-info strong { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-info span { display: block; font-size: 11px; color: var(--muted); }
.foot-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.conn-chip {
  display: flex; align-items: center; gap: 7px;
  font-size: 11px; color: var(--muted); padding: 0 2px;
}
.conn-chip .dot { background: var(--green); }
.conn-chip.offline .dot { background: var(--danger); }

.avatar { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; background: var(--panel-3); flex: none; }
.avatar.lg { width: 56px; height: 56px; }
.avatar.xl { width: 84px; height: 84px; }

.main { min-width: 0; height: 100dvh; overflow: hidden; position: relative; }
.view { height: 100%; display: flex; flex-direction: column; }
#view-notes, #view-calls { overflow-y: auto; }

/* ===================== رأس الدردشة ===================== */
.chat-head {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 18px calc(10px + var(--safe-t));
  padding-top: calc(10px + var(--safe-t));
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  z-index: 4;
  min-height: 68px;
}
.who { flex: 1; min-width: 0; }
.who h1 { margin: 0; font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who p { margin: 2px 0 0; font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.who p.online { color: var(--green); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); display: inline-block; flex: none; }
.who p.online .dot, .status-line.online .dot { background: var(--green); box-shadow: 0 0 0 3px rgba(0, 184, 148, 0.16); }
.head-actions { display: flex; gap: 2px; }

/* ===================== الرسائل ===================== */
.msg-wrap {
  position: relative;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  background-color: var(--chat-bg);
  background-image:
    radial-gradient(circle at 20% 20%, var(--wave) 0 2px, transparent 3px),
    radial-gradient(circle at 70% 60%, var(--wave) 0 2px, transparent 3px);
  background-size: 64px 64px, 96px 96px;
  scroll-behavior: smooth;
}
.msg-list {
  padding: 18px clamp(12px, 5vw, 60px) 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-height: 100%;
  justify-content: flex-end;
}

.empty-chat {
  margin: auto;
  text-align: center;
  padding: 34px 20px;
  max-width: 430px;
  color: var(--muted);
}
.empty-logo {
  width: 64px; height: 64px; margin: 0 auto 14px;
  border-radius: 22px; display: grid; place-items: center;
  background: rgba(0, 184, 148, 0.12);
  color: var(--green);
}
.empty-logo .ic { width: 30px; height: 30px; }
.empty-chat h2 { margin: 0 0 8px; font-size: 20px; color: var(--text); }
.empty-chat p { margin: 0 auto; line-height: 1.8; font-size: 13.5px; max-width: 340px; }
.empty-tips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 20px; }
.empty-tips span {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; padding: 6px 10px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--text-soft);
}
.empty-tips .ic { width: 13px; height: 13px; color: var(--green); }

.day-sep { display: flex; align-items: center; justify-content: center; margin: 14px 0 8px; }
.day-sep span {
  font-size: 11px; color: var(--muted); background: var(--panel-2);
  border: 1px solid var(--line); padding: 4px 12px; border-radius: 999px;
  backdrop-filter: blur(6px);
}

.msg {
  position: relative;
  max-width: min(78%, 620px);
  padding: 7px 10px 6px;
  border-radius: 14px;
  background: var(--bubble-in);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  align-self: flex-start;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.14);
  word-break: break-word;
  animation: msg-in 0.18s ease;
}
@keyframes msg-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.msg.out { align-self: flex-end; background: var(--bubble-out); }
html.light .msg.out { color: #111b21; }
.msg + .msg { margin-top: 2px; }
.msg.group-start { margin-top: 10px; }
.msg .msg-text { white-space: pre-wrap; }

.msg .msg-meta {
  display: inline-flex; align-items: center; gap: 4px;
  float: left;
  margin: 4px 0 -2px 4px;
  font-size: 10.5px;
  color: var(--muted);
  direction: ltr;
}
html.light .msg.out .msg-meta { color: rgba(17, 27, 33, 0.55); }
html.light .msg.in .msg-meta { color: var(--muted); }
.msg .msg-meta .ic { width: 15px; height: 15px; stroke-width: 2.3; }
.msg .msg-meta .read { color: var(--sky); }
.msg .msg-meta .pending { color: var(--amber); }

.msg .sender { display: block; font-size: 11.5px; font-weight: 700; color: var(--green); margin-bottom: 2px; }

.msg-image {
  display: block;
  border-radius: 10px;
  max-width: 100%;
  max-height: 380px;
  width: auto;
  height: auto;
  object-fit: cover;
  cursor: zoom-in;
  background: var(--panel-3);
  margin-bottom: 4px;
}
.msg-image.loading { min-width: 160px; min-height: 120px; animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: 0.55; } }
.msg.out .msg-image { margin-inline-start: auto; }

.msg .reply-quote {
  display: block;
  border-inline-start: 3px solid var(--green);
  background: rgba(0, 0, 0, 0.18);
  border-radius: 8px;
  padding: 5px 8px;
  margin-bottom: 4px;
  font-size: 11.5px;
  color: var(--text-soft);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
html.light .msg .reply-quote { background: rgba(0, 0, 0, 0.05); }
.msg .reply-quote b { color: var(--green); }

.msg.deleted { opacity: 0.65; font-style: italic; color: var(--muted); }
.msg.deleted .ic { width: 14px; height: 14px; vertical-align: -3px; }

.msg-call { display: flex; align-items: center; gap: 10px; padding: 2px 0; }
.msg-call .call-ico {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(0, 184, 148, 0.16); color: var(--green);
}
.msg-call .call-ico.missed { background: rgba(241, 92, 92, 0.16); color: var(--danger); }
.msg-call .call-info b { display: block; font-size: 13px; }
.msg-call .call-info span { font-size: 11px; color: var(--muted); }
.msg-call .call-back { margin-inline-start: auto; }

.msg .msg-menu-btn {
  position: absolute; top: 2px; inset-inline-end: 2px;
  width: 26px; height: 26px; border: 0; border-radius: 50%;
  background: rgba(0, 0, 0, 0.18); color: var(--text-soft);
  display: grid; place-items: center; opacity: 0; transition: opacity 0.15s;
}
.msg:hover .msg-menu-btn, .msg:focus-within .msg-menu-btn { opacity: 1; }
.msg .msg-menu-btn .ic { width: 14px; height: 14px; }
html.light .msg .msg-menu-btn { background: rgba(0, 0, 0, 0.06); }

.scroll-down {
  position: absolute; bottom: 16px; inset-inline-end: 22px;
  width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  display: grid; place-items: center; box-shadow: var(--shadow-soft); z-index: 3;
}
.scroll-down b {
  position: absolute; top: -6px; inset-inline-end: -4px;
  min-width: 18px; height: 18px; border-radius: 999px; background: var(--green); color: #04231d;
  font-size: 10px; display: grid; place-items: center; padding: 0 4px;
}

.typing-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 22px 6px;
  font-size: 11.5px; color: var(--green);
  background: var(--bg);
  border-top: 1px solid transparent;
}
.typing-dots { display: inline-flex; gap: 3px; }
.typing-dots i { width: 5px; height: 5px; background: var(--green); border-radius: 50%; animation: tdot 1s infinite; }
.typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.typing-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes tdot { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-3px); opacity: 1; } }

/* ===================== المحرر ===================== */
.reply-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px;
  background: var(--panel-2);
  border-top: 1px solid var(--line);
}
.reply-info { flex: 1; min-width: 0; border-inline-start: 3px solid var(--green); padding-inline-start: 9px; }
.reply-info span { font-size: 11px; color: var(--green); font-weight: 700; }
.reply-info p { margin: 1px 0 0; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.emoji-panel {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 2px;
  padding: 10px 14px;
  max-height: 190px;
  overflow-y: auto;
  background: var(--panel);
  border-top: 1px solid var(--line);
}
.emoji-panel button { border: 0; background: transparent; font-size: 22px; padding: 6px; border-radius: 8px; }
.emoji-panel button:hover { background: var(--panel-3); }

.composer {
  display: flex; align-items: flex-end; gap: 4px;
  padding: 8px 12px calc(8px + var(--safe-b));
  background: var(--panel);
  border-top: 1px solid var(--line);
}
.composer textarea {
  flex: 1;
  resize: none;
  max-height: 132px;
  min-height: 42px;
  padding: 10px 14px;
  border: 0;
  border-radius: 21px;
  background: var(--panel-3);
  font-size: 14px;
  line-height: 1.5;
}
.composer textarea:focus { background: var(--panel-3); border: 0; box-shadow: inset 0 0 0 1px var(--green); }
.send-btn {
  width: 44px; height: 44px; flex: none;
  border: 0; border-radius: 50%;
  background: linear-gradient(135deg, #00c9a7, #008069);
  color: #04231d;
  display: grid; place-items: center;
  transition: transform 0.12s, filter 0.15s;
}
html.light .send-btn { color: #fff; }
.send-btn .ic { width: 20px; height: 20px; transform: rotate(180deg) translateX(1px); }
.send-btn:active { transform: scale(0.94); }
.composer .icon-btn { width: 40px; height: 44px; }

/* ===================== الملاحظات ===================== */
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  padding: calc(20px + var(--safe-t)) clamp(18px, 4vw, 40px) 16px;
  background: linear-gradient(var(--bg), var(--bg) 70%, transparent);
  flex-wrap: wrap;
}
.page-head h2 { margin: 0; font-size: 24px; letter-spacing: -0.3px; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.head-call-actions { display: flex; gap: 8px; }

.chips { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 clamp(18px, 4vw, 40px) 14px; }
.chips.small { padding: 0; }
.chip {
  border: 1px solid var(--line-strong); background: transparent; color: var(--muted);
  padding: 6px 13px; border-radius: 999px; font-size: 12px; font-weight: 600;
  transition: 0.15s;
}
.chip:hover { color: var(--text); }
.chip.active { background: rgba(0, 184, 148, 0.16); border-color: rgba(0, 184, 148, 0.45); color: var(--green); }
.chips.small .chip { padding: 5px 10px; font-size: 11px; }

.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  padding: 4px clamp(18px, 4vw, 40px) 40px;
  align-content: start;
}
.note-card {
  position: relative;
  display: flex; flex-direction: column; gap: 8px;
  padding: 16px 16px 13px;
  border-radius: 18px;
  background: linear-gradient(155deg, color-mix(in srgb, var(--nc) 14%, transparent), rgba(255, 255, 255, 0.015));
  border: 1px solid color-mix(in srgb, var(--nc) 30%, transparent);
  min-height: 128px;
  transition: transform 0.15s, box-shadow 0.15s;
  overflow: hidden;
}
.note-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-soft); }
.note-card::before {
  content: ""; position: absolute; inset-inline-start: 0; top: 16px; bottom: 16px; width: 3px;
  border-radius: 3px; background: var(--nc);
}
.note-card[data-color="green"] { --nc: #00b894; }
.note-card[data-color="teal"] { --nc: #14b8a6; }
.note-card[data-color="sky"] { --nc: #38bdf8; }
.note-card[data-color="violet"] { --nc: #a78bfa; }
.note-card[data-color="rose"] { --nc: #fb7185; }
.note-card[data-color="amber"] { --nc: #fbbf24; }

.note-top { display: flex; align-items: flex-start; gap: 8px; }
.note-top h3 { margin: 0; font-size: 15px; flex: 1; line-height: 1.5; }
.note-top .pin { color: var(--nc); }
.note-body { margin: 0; font-size: 13px; line-height: 1.75; color: var(--text-soft); white-space: pre-wrap; flex: 1; }
.note-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 600;
  padding: 3px 8px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.06); color: var(--muted);
}
html.light .tag { background: rgba(0, 0, 0, 0.05); }
.tag .ic { width: 12px; height: 12px; }
.tag.hot { color: var(--nc, var(--green)); background: color-mix(in srgb, var(--nc, #00b894) 15%, transparent); }
.note-foot { display: flex; align-items: center; gap: 6px; font-size: 10.5px; color: var(--muted); }
.note-foot .spacer { flex: 1; }
.note-actions { display: flex; gap: 2px; opacity: 0; transition: opacity 0.15s; }
.note-card:hover .note-actions, .note-card:focus-within .note-actions { opacity: 1; }
.note-actions .icon-btn { width: 30px; height: 30px; }
.note-actions .ic { width: 15px; height: 15px; }

.note-card.locked { filter: saturate(0.5); }
.note-card.locked .note-body { filter: blur(7px); user-select: none; pointer-events: none; }
.note-lock {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 6px; background: rgba(0, 0, 0, 0.24); border-radius: inherit;
  color: var(--text); font-size: 12px; font-weight: 700; backdrop-filter: blur(2px);
  pointer-events: none;
}
.note-lock .ic { color: var(--amber); }
.note-card.expired { opacity: 0.55; }

.empty-block { text-align: center; padding: 50px 24px; color: var(--muted); }
.empty-block .empty-logo { background: rgba(134, 150, 160, 0.1); color: var(--muted); }
.empty-block h3 { color: var(--text); margin: 10px 0 6px; font-size: 17px; }
.empty-block p { margin: 0 auto 18px; max-width: 360px; font-size: 13px; line-height: 1.8; }

/* ===================== المكالمات ===================== */
.calls-list { display: flex; flex-direction: column; gap: 2px; padding: 0 clamp(14px, 4vw, 36px) 40px; }
.call-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 14px;
  transition: background 0.15s;
}
.call-row:hover { background: rgba(255, 255, 255, 0.035); }
html.light .call-row:hover { background: rgba(0, 0, 0, 0.03); }
.call-row .call-ico { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: rgba(0, 184, 148, 0.14); color: var(--green); flex: none; }
.call-row .call-ico.missed { background: rgba(241, 92, 92, 0.14); color: var(--danger); }
.call-row .call-main { flex: 1; min-width: 0; }
.call-row .call-main b { display: block; font-size: 13.5px; }
.call-row .call-main span { font-size: 11.5px; color: var(--muted); }
.call-row .call-time { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* ===================== النوافذ ===================== */
dialog {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  color: var(--text);
  padding: 0;
  width: min(520px, 92vw);
  max-height: 92dvh;
  box-shadow: var(--shadow);
}
dialog.wide-dialog { width: min(640px, 94vw); }
dialog.narrow { width: min(400px, 92vw); }
dialog::backdrop { background: rgba(4, 10, 14, 0.65); backdrop-filter: blur(4px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.dialog-head h3 { margin: 0; font-size: 17px; }
.dialog-body { padding: 18px 20px; display: grid; gap: 14px; overflow-y: auto; max-height: 65dvh; }
.dialog-foot { display: flex; align-items: center; gap: 8px; padding: 14px 20px calc(14px + var(--safe-b)); border-top: 1px solid var(--line); }
.dialog-foot .spacer { flex: 1; }
.confirm-text { margin: 0; line-height: 1.8; color: var(--text-soft); font-size: 14px; }

.note-colors { display: flex; gap: 9px; }
.color-dot { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; }
.color-dot.green { background: #00b894; }
.color-dot.teal { background: #14b8a6; }
.color-dot.sky { background: #38bdf8; }
.color-dot.violet { background: #a78bfa; }
.color-dot.rose { background: #fb7185; }
.color-dot.amber { background: #fbbf24; }
.color-dot.active { border-color: var(--text); box-shadow: 0 0 0 2px var(--panel); }

.time-grid { display: grid; gap: 12px; }
.time-block { border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: grid; gap: 9px; background: rgba(0, 0, 0, 0.08); }
html.light .time-block { background: rgba(0, 0, 0, 0.02); }
.time-label { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700; color: var(--text-soft); }
.time-label .ic { width: 15px; height: 15px; color: var(--green); }
.time-block input[type="datetime-local"] { font-size: 12.5px; padding: 8px 10px; }
.muted { color: var(--muted); font-size: 11px; line-height: 1.6; }

.switch-row { display: flex; align-items: center; gap: 10px; font-size: 13px; cursor: pointer; }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch { width: 38px; height: 22px; border-radius: 999px; background: var(--panel-3); position: relative; transition: 0.18s; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: 0.18s; }
.switch-row input:checked + .switch { background: var(--green); }
.switch-row input:checked + .switch::after { inset-inline-start: 19px; background: #04231d; }

.settings-profile { display: flex; align-items: center; gap: 14px; }
.settings-profile strong { display: block; font-size: 16px; }
.settings-profile span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.settings-row:last-of-type { border-bottom: 0; }
.settings-row div strong { display: block; font-size: 13px; }
.settings-row div small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; line-height: 1.5; }
.pill { font-size: 10.5px; padding: 4px 9px; border-radius: 999px; background: rgba(0, 184, 148, 0.14); color: var(--green); white-space: nowrap; }
.pill.warn { background: rgba(240, 180, 41, 0.14); color: var(--amber); }
.about { text-align: center; color: var(--muted); font-size: 11.5px; margin: 8px 0 0; }

/* ===================== مكالمة ===================== */
.call-layer {
  position: fixed; inset: 0; z-index: 80;
  background: #06100d;
  overflow: hidden;
  display: flex; flex-direction: column;
}
.call-backdrop {
  position: absolute; inset: 0;
  background:
    radial-gradient(800px 600px at 50% 15%, rgba(0, 184, 148, 0.2), transparent 65%),
    radial-gradient(600px 500px at 50% 100%, rgba(0, 90, 75, 0.4), transparent 70%),
    #06100d;
}
.remote-video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; background: #06100d; z-index: 1;
  opacity: 0; transition: opacity 0.35s;
}
.remote-video.on { opacity: 1; }
.local-video {
  position: absolute; z-index: 3;
  inset-inline-start: 16px; bottom: calc(124px + var(--safe-b));
  width: 104px; height: 150px; object-fit: cover;
  border-radius: 16px; border: 2px solid rgba(255, 255, 255, 0.18);
  box-shadow: var(--shadow);
  background: #0a1a16;
}
.call-top {
  position: relative; z-index: 4;
  padding: calc(22px + var(--safe-t)) 20px 0;
  text-align: center;
  display: flex; justify-content: center;
}
.call-person { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.call-avatar-wrap { position: relative; display: grid; place-items: center; margin-bottom: 6px; }
.call-avatar-wrap .avatar { border: 2px solid rgba(255, 255, 255, 0.16); }
.call-ring {
  position: absolute; inset: -12px; border-radius: 50%;
  border: 1px solid rgba(0, 184, 148, 0.45);
  animation: ring 2.4s ease-out infinite;
}
.call-ring::after {
  content: ""; position: absolute; inset: -14px; border-radius: 50%;
  border: 1px solid rgba(0, 184, 148, 0.2);
  animation: ring 2.4s 1.2s ease-out infinite;
}
@keyframes ring { 0% { transform: scale(0.9); opacity: 0.8; } 100% { transform: scale(1.35); opacity: 0; } }
.call-person h2 { margin: 4px 0 0; font-size: 22px; color: #fff; }
.call-person p { margin: 0; font-size: 13px; color: rgba(255, 255, 255, 0.68); }
.call-timer { font-size: 13px; color: var(--green); font-variant-numeric: tabular-nums; letter-spacing: 0.5px; min-height: 18px; }

.call-quality {
  position: relative; z-index: 4;
  margin: 12px auto 0; padding: 6px 14px; border-radius: 999px;
  background: rgba(240, 180, 41, 0.16); color: #ffd875;
  font-size: 11.5px; font-weight: 700;
  border: 1px solid rgba(240, 180, 41, 0.3);
  backdrop-filter: blur(8px);
}

.call-actions {
  position: relative; z-index: 5;
  margin-top: auto;
  padding: 18px 20px calc(28px + var(--safe-b));
  display: flex; align-items: center; justify-content: center; gap: 10px;
  flex-wrap: wrap;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.55));
}
.call-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  width: 66px; padding: 0; border: 0; background: transparent;
  color: rgba(255, 255, 255, 0.8); font-size: 10.5px;
}
.call-btn .ic {
  width: 52px; height: 52px; padding: 14px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.13); color: #fff;
  backdrop-filter: blur(10px); transition: background 0.15s, transform 0.12s;
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.call-btn:active .ic { transform: scale(0.93); }
.call-btn.off .ic { background: #fff; color: #06100d; }
.call-btn.danger .ic { background: #e5484d; color: #fff; border-color: transparent; }
.call-btn.accept .ic { background: #00b894; color: #04231d; border-color: transparent; animation: pulseAccept 1.4s infinite; }
@keyframes pulseAccept { 50% { box-shadow: 0 0 0 10px rgba(0, 184, 148, 0.16); } }
.call-btn small { display: none; }

/* ===================== عارض الصور ===================== */
.lightbox {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(2, 8, 11, 0.94);
  display: flex; flex-direction: column;
  backdrop-filter: blur(10px);
}
.lb-top { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px calc(12px + var(--safe-t)); color: #fff; font-size: 12px; }
.lb-actions { display: flex; gap: 4px; }
.lightbox .icon-btn { color: #fff; }
#lb-img { max-width: 96vw; max-height: calc(100dvh - 80px); margin: auto; object-fit: contain; border-radius: 8px; }

/* ===================== قوائم وتنبيهات ===================== */
.context-menu {
  position: fixed; z-index: 95;
  min-width: 172px; padding: 6px;
  background: var(--panel-2); border: 1px solid var(--line-strong);
  border-radius: 12px; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  animation: msg-in 0.12s ease;
}
.context-menu button {
  display: flex; align-items: center; gap: 9px;
  border: 0; background: transparent; color: var(--text);
  padding: 9px 11px; border-radius: 8px; font-size: 12.5px; text-align: start;
}
.context-menu button:hover { background: rgba(255, 255, 255, 0.07); }
html.light .context-menu button:hover { background: rgba(0, 0, 0, 0.05); }
.context-menu button.danger { color: var(--danger); }
.context-menu .ic { width: 16px; height: 16px; }

.toasts {
  position: fixed; z-index: 100;
  top: calc(14px + var(--safe-t)); inset-inline-start: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: min(94vw, 420px);
}
.toast {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: 13px;
  background: var(--panel-2); border: 1px solid var(--line-strong);
  box-shadow: var(--shadow); color: var(--text); font-size: 12.5px;
  animation: toast-in 0.24s cubic-bezier(0.2, 1.2, 0.4, 1);
}
.toast.out { animation: toast-out 0.25s forwards; }
.toast .ic { color: var(--green); }
.toast.error .ic { color: var(--danger); }
.toast.reminder { background: linear-gradient(135deg, #1c3a32, #17242b); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-8px); } }

.net-banner {
  position: fixed; z-index: 85; top: 0; inset-inline: 0;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: calc(7px + var(--safe-t)) 12px 7px;
  background: #7a3b12; color: #ffe0bd; font-size: 11.5px; font-weight: 600;
  animation: toast-in 0.2s ease;
}
.net-banner .ic { width: 15px; height: 15px; }

/* ===================== الجوال ===================== */
.bottom-nav { display: none; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { display: none; }
  .main { height: calc(100dvh - 62px - var(--safe-b)); }
  .bottom-nav {
    position: fixed; inset-inline: 0; bottom: 0; z-index: 30;
    height: calc(62px + var(--safe-b));
    padding-bottom: var(--safe-b);
    display: flex; align-items: stretch;
    background: var(--panel);
    border-top: 1px solid var(--line);
  }
  .bottom-nav .nav-btn {
    flex: 1; flex-direction: column; gap: 2px; justify-content: center;
    border-radius: 0; font-size: 10px; padding: 6px 2px; position: relative;
  }
  .bottom-nav .nav-btn.active { background: transparent; color: var(--green); }
  .bottom-nav .nav-btn.active::before { display: none; }
  .bottom-nav .nav-btn.active::after {
    content: ""; position: absolute; top: 0; width: 26px; height: 3px;
    border-radius: 0 0 4px 4px; background: var(--green);
  }
  .bottom-nav .badge {
    position: absolute; top: 4px; inset-inline-start: 50%; margin: 0;
    transform: translateX(6px);
  }
  .page-head { padding: calc(14px + var(--safe-t)) 16px 12px; }
  .page-head h2 { font-size: 21px; }
  .notes-grid { grid-template-columns: 1fr; padding: 4px 14px 30px; gap: 10px; }
  .calls-list { padding: 0 8px 30px; }
  .chat-head { padding: 6px 10px; min-height: 60px; }
  .chat-head .avatar { width: 38px; height: 38px; }
  .who h1 { font-size: 14.5px; }
  .msg { max-width: 86%; font-size: 14px; }
  .msg-list { padding: 12px 12px 8px; }
  .composer { padding: 6px 8px calc(6px + var(--safe-b)); gap: 2px; }
  .composer textarea { min-height: 40px; font-size: 15px; }
  .composer .icon-btn { width: 36px; }
  .send-btn { width: 42px; height: 42px; }
  .local-video { width: 88px; height: 128px; bottom: calc(132px + var(--safe-b)); inset-inline-start: 12px; }
  .call-btn { width: 60px; }
  .call-btn .ic { width: 48px; height: 48px; padding: 12px; }
  .dialog-body { max-height: 60dvh; }
  .auth { grid-template-columns: 1fr; overflow-y: auto; }
  .auth-art { padding: 40px 26px 10px; text-align: center; align-items: center; }
  .auth-art > p { font-size: 13.5px; }
  .auth-points { display: none; }
  .auth-badge { font-size: 38px; }
  .auth-panel { margin: 18px auto 40px; width: min(430px, 92%); padding: 22px; }
  .toasts { top: auto; bottom: calc(76px + var(--safe-b)); }
  .scroll-down { bottom: 14px; }
  .head-actions .icon-btn { width: 38px; height: 38px; }
}

@media (max-width: 420px) {
  .msg { max-width: 90%; }
  .page-head { gap: 10px; }
  .page-head h2 { font-size: 19px; }
  .btn { padding: 9px 12px; }
}

/* أجهزة اللمس لا تعرف hover — اجعل أدوات الرسائل والملاحظات ظاهرة دائماً */
@media (hover: none), (pointer: coarse) {
  .msg .msg-menu-btn { opacity: 0.75; }
  .note-actions { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
