/* لاماسو — هوية عراقية عصرية */
:root {
  --river-blue: #0F4C81;
  --tigris-teal: #00B7A8;
  --sumer-gold: #D4A017;
  --white: #FFFFFF;
  --mist: #F5F7FA;
  --night: #101820;
  --frame-gold: linear-gradient(135deg, #f0d27a, #D4A017 45%, #a97c0c);

  /* الوضع النهاري */
  --bg: var(--mist);
  --panel: var(--white);
  --panel-2: #eef3f8;
  --panel-glass: rgba(255, 255, 255, .72);
  --line: #d7e0ea;
  --text: #15263a;
  --muted: #5f7286;
  --accent: var(--river-blue);
  --accent-strong: #0a385f;
  --accent-soft: #e4f1fb;
  --danger: #d64545;
  --bubble: var(--white);
  --bubble-mine: linear-gradient(135deg, #0F4C81, #00B7A8);
  --bubble-theirs: var(--white);
  --shadow: 0 18px 42px rgba(15, 76, 129, .12);
  --shadow-soft: 0 8px 20px rgba(15, 76, 129, .08);
  --gold-glow: 0 0 18px rgba(212, 160, 23, .35);
  --radius: 22px;
  --transition: 300ms cubic-bezier(.2, .8, .2, 1);
}

body.night {
  --bg: var(--night);
  --panel: #172432;
  --panel-2: #1d3040;
  --panel-glass: rgba(23, 36, 50, .76);
  --line: #2a4053;
  --text: #e8f1f7;
  --muted: #8fa8ba;
  --accent: #1f9bb4;
  --accent-strong: #00B7A8;
  --accent-soft: #153b46;
  --danger: #ff7a7a;
  --bubble: #1c2d3d;
  --bubble-mine: linear-gradient(135deg, #00B7A8, #0F9C8F);
  --bubble-theirs: #1a2938;
  --shadow: 0 18px 42px rgba(0, 0, 0, .35);
  --shadow-soft: 0 8px 20px rgba(0, 0, 0, .28);
  --gold-glow: 0 0 22px rgba(212, 160, 23, .7);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .6; }

.hidden { display: none !important; }
.ui-icon, .btn-icon, .section-icon { object-fit: contain; }
.btn-icon { width: 20px; height: 20px; vertical-align: -4px; }
.section-icon { width: 20px; height: 20px; vertical-align: -4px; margin-inline-end: 6px; }

/* موجة/sumerian pattern shared */
.auth-pattern, .chat-header::before, .messages::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='60' viewBox='0 0 120 60'%3E%3Cg fill='none' stroke='%23D4A017' stroke-width='1.4' opacity='.12'%3E%3Cpath d='M10 50V20l10-10 10 10v30M30 50V20l10-10 10 10v30M50 50V20l10-10 10 10v30M70 50V20l10-10 10 10v30M90 50V20l10-10 10 10v30'/%3E%3Cpath d='M10 30h20M30 30h20M50 30h20M70 30h20M90 30h20'/%3E%3Cpath d='M5 52h110'/%3E%3C/g%3E%3C/svg%3E");
  background-repeat: repeat;
  opacity: .45;
}

/* ---------- المصادقة ---------- */
.auth-card {
  position: relative;
  width: min(470px, calc(100% - 32px));
  margin: 7vh auto;
  padding: 30px;
  overflow: hidden;
  background: linear-gradient(160deg, var(--panel), var(--panel-2));
  border: 1px solid rgba(212, 160, 23, .35);
  border-radius: 24px;
  box-shadow: var(--shadow), var(--gold-glow);
}

.auth-card > *:not(.auth-pattern) { position: relative; z-index: 1; }

.brand { display: flex; gap: 14px; align-items: center; }
.brand.small { gap: 10px; }

.brand-mark {
  position: relative;
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
  padding: 4px;
  border-radius: 16px;
  background: var(--frame-gold);
  box-shadow: 0 0 0 3px rgba(212, 160, 23, .16), var(--gold-glow);
  display: grid;
  place-items: center;
}
.brand.small .brand-mark { width: 42px; height: 42px; flex-basis: 42px; border-radius: 12px; }
.brand-mark img { width: 100%; height: 100%; border-radius: 12px; object-fit: cover; background: #fff; }
.brand.small .brand-mark img { border-radius: 9px; }
.winged-mark {
  position: absolute;
  inset: auto 2px -6px 2px;
  width: calc(100% - 4px);
  height: 24px;
  fill: #ffe6a1;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.4));
}
.brand h1 { margin: 0; color: var(--accent); font-size: 27px; letter-spacing: .3px; }
.brand small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.brand p { margin: 4px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }

.tabs { display: flex; gap: 8px; margin: 24px 0 14px; }
.tab {
  flex: 1; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 12px; background: transparent; color: var(--muted);
  transition: var(--transition);
}
.tab:hover { border-color: var(--tigris-teal); color: var(--text); }
.tab.active {
  background: linear-gradient(135deg, var(--river-blue), var(--tigris-teal));
  border-color: transparent; color: #fff; font-weight: 700;
}

.auth-card form { display: grid; gap: 13px; }
.auth-card label, dialog label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.auth-card input, dialog input, dialog select, .message-input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--panel-2); color: var(--text);
  outline: none; transition: var(--transition);
}
.auth-card input:focus, dialog input:focus, .message-input:focus {
  border-color: var(--tigris-teal);
  box-shadow: 0 0 0 3px rgba(0,183,168,.16);
}

.primary, .ghost, .danger {
  position: relative; overflow: hidden; padding: 11px 16px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--panel-2); color: var(--text); font-weight: 700;
  transition: var(--transition);
}
.primary {
  border-color: transparent; color: #fff;
  background: linear-gradient(135deg, var(--river-blue), var(--tigris-teal));
  box-shadow: 0 8px 18px rgba(15, 76, 129, .24);
}
.primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.ghost:hover { border-color: var(--accent); }
.danger { background: var(--danger); color: #fff; border-color: transparent; }
.wide { width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; }

/* Ripple */
.primary::after, .ghost::after, .round-btn::after, .send-btn::after, .bubble::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: radial-gradient(circle, rgba(255,255,255,.45), transparent 60%);
  opacity: 0; transform: scale(.4); pointer-events: none;
  transition: opacity var(--transition), transform var(--transition);
}
.primary:active::after, .ghost:active::after, .round-btn:active::after,
.send-btn:active::after, .bubble:active::after { opacity: .5; transform: scale(1); }

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

/* ---------- التخطيط ---------- */
.app { display: flex; height: 100vh; height: 100dvh; }

.sidebar {
  width: 290px; flex: 0 0 290px; display: flex; flex-direction: column; gap: 12px;
  padding: 16px; overflow-y: auto;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border-inline-end: 1px solid var(--line);
}
.sidebar header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sidebar header .ghost { padding: 7px 11px; font-size: 12px; }
.sidebar-section h3 { margin: 6px 2px 8px; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.badge { margin-inline-start: auto; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 1px 8px; font-size: 11px; }
.sidebar-footer { margin-top: auto; text-align: center; font-size: 11px; color: var(--muted); padding: 10px 0; }

.room-item, .member-item, .notification-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 11px; margin-bottom: 6px;
  border: 1px solid transparent; border-radius: 14px; background: transparent;
  color: var(--text); width: 100%; text-align: start; transition: var(--transition);
}
.room-item:hover, .member-item:hover, .notification-item:hover { background: var(--panel-2); border-color: var(--line); }
.room-item.active { background: var(--accent-soft); border-color: rgba(0,183,168,.4); }
.room-item .room-symbol { width: 30px; height: 30px; border-radius: 9px; object-fit: contain; }
.room-item .room-copy { min-width: 0; }
.room-item strong, .member-item strong { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-item small, .member-item small, .notification-item small { display: block; color: var(--muted); font-size: 11px; }
.member-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--tigris-teal); box-shadow: 0 0 8px var(--tigris-teal); }
.notification-item.unread { border-inline-start: 3px solid var(--sumer-gold); }
.members, .notifications { max-height: 190px; overflow-y: auto; }

/* ---------- المحادثة ---------- */
.chat { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }

.chat-header {
  position: relative; height: 72px; flex: 0 0 72px; display: flex; align-items: center;
  justify-content: space-between; gap: 12px; padding: 0 18px;
  background: linear-gradient(90deg, var(--river-blue), #0b5f78 70%, var(--tigris-teal));
  color: #fff; box-shadow: var(--shadow-soft); z-index: 3;
}
body.night .chat-header { background: linear-gradient(90deg, #0a385f, #0d5f69 70%, #007f78); }
.chat-header > * { position: relative; z-index: 1; }
.header-actions { display: flex; align-items: center; gap: 8px; }

.room-heading { display: flex; align-items: center; gap: 12px; min-width: 0; }
.peer-avatar {
  position: relative; width: 46px; height: 46px; flex: 0 0 46px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 800; color: #fff;
  background: var(--frame-gold); padding: 3px; box-shadow: var(--gold-glow);
}
.peer-avatar > span {
  width: 100%; height: 100%; border-radius: 50%; display: grid; place-items: center;
  background: var(--river-blue); font-size: 18px;
}
.peer-avatar .chat-icon { position: absolute; width: 18px; height: 18px; inset: auto -3px -3px auto; }
.peer-info { min-width: 0; }
.peer-info h2 { margin: 0; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.peer-info p { margin: 2px 0 0; font-size: 11px; color: rgba(255,255,255,.78); }
.peer-info .presence { display: flex; align-items: center; gap: 5px; }
.presence-dot { width: 7px; height: 7px; border-radius: 50%; background: #7df7cb; box-shadow: 0 0 8px #7df7cb; }
.presence.typing .presence-dot { background: var(--sumer-gold); box-shadow: var(--gold-glow); animation: pulse 1s infinite; }

.round-btn {
  position: relative; width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.12);
  color: #fff; font-size: 17px; display: grid; place-items: center;
  transition: var(--transition); backdrop-filter: blur(6px);
}
.round-btn:hover { background: rgba(255,255,255,.24); transform: translateY(-2px); }
.call-btn { color: #ffe6a1; }

.options-wrap { position: relative; }
.options-menu {
  position: absolute; top: 46px; inset-inline-end: 0; width: 250px; padding: 12px;
  border-radius: 16px; background: var(--panel); color: var(--text);
  border: 1px solid rgba(212,160,23,.35); box-shadow: var(--shadow); z-index: 20;
}
.options-menu button {
  width: 100%; padding: 9px 10px; margin-bottom: 4px; text-align: start;
  border: 0; border-radius: 10px; background: transparent; color: var(--text); transition: var(--transition);
}
.options-menu button:hover { background: var(--accent-soft); }
.menu-label { font-size: 11px; color: var(--muted); margin: 8px 0 6px; }
.background-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.background-picker button { display: grid; justify-items: center; gap: 4px; font-size: 10px; margin: 0; padding: 6px 2px; }
.bg-swatch { width: 100%; height: 26px; border-radius: 8px; display: block; border: 1px solid var(--line); }
.swatch-euphrates { background: linear-gradient(180deg, #cfe6f7, #fff); }
.swatch-shatt { background: linear-gradient(160deg, #bfe3df, #eaf6f4); }
.swatch-ur { background: linear-gradient(160deg, #e6c996, #fff7e8); }
.swatch-ishtar { background: linear-gradient(160deg, #1b4670, #00B7A8); }
.swatch-marshes { background: linear-gradient(160deg, #9dc7a2, #e3f1d9); }
.swatch-freedom { background: linear-gradient(160deg, #d6b06b, #f5e4bd); }

.messages {
  position: relative; flex: 1; min-height: 0; overflow-y: auto; padding: 22px 24px 30px;
  display: flex; flex-direction: column; gap: 14px;
  background-size: cover; background-position: center; transition: background var(--transition);
}
.messages::before { z-index: 0; opacity: .22; }
.messages > * { position: relative; z-index: 1; }

.bg-euphrates { background-image: linear-gradient(180deg, rgba(15,76,129,.16), rgba(255,255,255,.86)), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='800' height='500'%3E%3Cdefs%3E%3ClinearGradient id='s' x2='0' y2='1'%3E%3Cstop stop-color='%23cfe6f7'/%3E%3Cstop offset='1' stop-color='%23eaf5fb'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect width='800' height='500' fill='url(%23s)'/%3E%3Cpath d='M0 330 Q180 240 360 320 T800 290 L800 500 0 500Z' fill='%230F4C81' opacity='.14'/%3E%3Cpath d='M0 370 Q200 290 400 360 T800 330' fill='none' stroke='%2300B7A8' stroke-width='3' opacity='.25'/%3E%3C/svg%3E"); }
.bg-shatt { background-image: linear-gradient(180deg, rgba(0,183,168,.14), rgba(255,255,255,.86)), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='800' height='500'%3E%3Crect width='800' height='500' fill='%23eaf6f4'/%3E%3Cpath d='M0 300 Q160 250 320 300 T640 300 T960 300 L960 500 0 500Z' fill='%2300B7A8' opacity='.16'/%3E%3Cpath d='M0 380 Q160 330 320 380 T640 380 T960 380' fill='none' stroke='%230F4C81' stroke-width='3' opacity='.18'/%3E%3C/svg%3E"); }
.bg-ur { background-image: linear-gradient(180deg, rgba(212,160,23,.14), rgba(255,255,255,.88)), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='800' height='500'%3E%3Crect width='800' height='500' fill='%23fff7e8'/%3E%3Cpath d='M280 420h240l30-260h-60l-20 180h-40l-10-140h-60l-10 140h-40l-20-180h-60z' fill='%23D4A017' opacity='.2'/%3E%3C/svg%3E"); }
.bg-ishtar { background-image: linear-gradient(180deg, rgba(15,76,129,.55), rgba(0,183,168,.35)), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='800' height='500'%3E%3Crect width='800' height='500' fill='%231b4670'/%3E%3Cg fill='none' stroke='%23D4A017' stroke-width='4' opacity='.35'%3E%3Cpath d='M120 440V120l80-80 80 80v320M520 440V120l80-80 80 80v320'/%3E%3Cpath d='M120 220h160M520 220h160M140 440h120M540 440h120'/%3E%3C/g%3E%3C/svg%3E"); }
.bg-marshes { background-image: linear-gradient(180deg, rgba(0,183,168,.12), rgba(255,255,255,.88)), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='800' height='500'%3E%3Crect width='800' height='500' fill='%23e3f1d9'/%3E%3Cg stroke='%2300B7A8' stroke-width='2' opacity='.25'%3E%3Cpath d='M80 420q40-180 80 0M200 420q40-220 80 0M340 420q40-160 80 0M480 420q40-200 80 0M620 420q40-180 80 0' fill='none'/%3E%3C/g%3E%3C/svg%3E"); }
.bg-freedom { background-image: linear-gradient(180deg, rgba(212,160,23,.18), rgba(255,255,255,.86)), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='800' height='500'%3E%3Crect width='800' height='500' fill='%23f5e4bd'/%3E%3Cpath d='M370 440h60l-10-180h-40zM330 270l70-140 70 140zM300 150h200M350 110h100' fill='none' stroke='%23D4A017' stroke-width='8' opacity='.3'/%3E%3C/svg%3E"); }

body.night .messages {
  background-color: var(--night);
  background-blend-mode: multiply;
  filter: brightness(.62);
}
body.night .messages > * { filter: brightness(1.55); }

.empty { margin: auto; color: var(--muted); font-size: 14px; text-align: center; }

.day-sep { align-self: center; padding: 4px 12px; border-radius: 999px; background: var(--panel-glass); color: var(--muted); font-size: 11px; backdrop-filter: blur(6px); }

.bubble-row { display: flex; width: 100%; }
/* في RTL: الهامش التلقائي في جهة النهاية (يسار) يدفع الفقاعة يميناً، والعكس صحيح */
.bubble-row.mine .bubble { margin-inline-end: auto; }
.bubble-row.theirs .bubble { margin-inline-start: auto; }

.bubble {
  position: relative; max-width: min(74%, 560px); padding: 11px 14px 9px;
  border-radius: var(--radius); box-shadow: var(--shadow-soft);
  font-size: 14px; line-height: 1.65; overflow: hidden;
  animation: slide-in var(--transition) both;
}
.bubble.fresh { animation: shake .42s ease, slide-in var(--transition) both; }
.mine .bubble { background: var(--bubble-mine); color: #fff; border-bottom-left-radius: 6px; }
.theirs .bubble { background: var(--bubble-theirs); color: var(--text); border: 1px solid var(--line); border-bottom-right-radius: 6px; }
body.night .mine .bubble { color: #04231f; box-shadow: 0 0 16px rgba(0,183,168,.32); }
.theirs .bubble.sender-name { padding-top: 8px; }
.sender-label { display: block; font-size: 11px; font-weight: 700; color: var(--sumer-gold); margin-bottom: 3px; }
.bubble-text { white-space: pre-wrap; word-break: break-word; }
.bubble-meta { display: flex; align-items: center; justify-content: flex-end; gap: 4px; margin-top: 4px; font-size: 10px; opacity: .82; direction: ltr; }
.tick { font-size: 12px; line-height: 1; color: inherit; }
.tick.read { color: #55d8ff; text-shadow: 0 0 6px #55d8ff; }
.mine .tick.read { color: #bff4ff; }
body.night .mine .tick.read { color: #064f66; text-shadow: none; }
.edited-flag { font-size: 9px; opacity: .85; direction: rtl; }
.bubble-actions { display: inline-flex; gap: 2px; margin-inline-start: 6px; opacity: .72; transition: opacity var(--transition); }
.bubble-row:hover .bubble-actions, .bubble-actions:focus-within { opacity: 1; }
.bubble-action {
  border: 0; border-radius: 6px; background: rgba(255,255,255,.18); color: inherit;
  cursor: pointer; font-size: 11px; line-height: 1; padding: 3px 5px; transition: var(--transition);
}
.bubble-action:hover { background: rgba(212,160,23,.85); color: #101820; transform: translateY(-1px); }
.bubble-action.danger:hover { background: #d94b4b; color: #fff; }
.edit-box { display: grid; gap: 6px; min-width: 220px; }
.edit-input {
  width: 100%; resize: vertical; border: 1px solid rgba(212,160,23,.6); border-radius: 10px;
  padding: 8px 10px; font: inherit; color: var(--text); background: rgba(255,255,255,.92); direction: rtl;
}
body.night .edit-input { background: #172634; color: #e8f7f5; }
.edit-actions { display: flex; gap: 6px; justify-content: flex-end; }
.edit-actions button {
  border: 0; border-radius: 8px; padding: 5px 12px; cursor: pointer; font-size: 11px; font-weight: 700;
  transition: var(--transition);
}
.edit-save { background: var(--sumer-gold); color: #101820; }
.edit-cancel { background: rgba(255,255,255,.25); color: inherit; }
.edit-actions button:hover { filter: brightness(1.1); }

.bubble.important { box-shadow: var(--shadow), var(--gold-glow); border-color: var(--sumer-gold) !important; }

/* صوت */
.voice { display: flex; align-items: center; gap: 10px; min-width: 250px; }
.voice-play {
  width: 38px; height: 38px; flex: 0 0 38px; border-radius: 50%; border: 0;
  background: var(--frame-gold); color: #4a3500; font-size: 15px;
  box-shadow: var(--gold-glow); display: grid; place-items: center; transition: var(--transition);
}
.voice-play:hover { transform: scale(1.08); }
.voice-wave { flex: 1; display: flex; align-items: center; gap: 2px; height: 26px; }
.voice-wave i {
  width: 3px; border-radius: 2px; background: var(--tigris-teal); opacity: .85;
  animation: wave 1.1s ease-in-out infinite alternate; transform-origin: bottom;
}
body.night .voice-wave i { background: #7df7cb; box-shadow: 0 0 6px #00B7A8; }
.voice.playing .voice-wave i { animation-play-state: running; }
.voice:not(.playing) .voice-wave i { animation-play-state: paused; opacity: .55; }
.voice-info { display: grid; gap: 2px; font-size: 10px; }
.voice-speed { background: rgba(255,255,255,.2); border: 0; border-radius: 6px; color: inherit; font-size: 10px; padding: 1px 4px; }
.theirs .voice-speed { background: var(--accent-soft); }

/* رموز لاماسو المضافة */
.peer-icon {
  position: absolute; inset: 3px; width: calc(100% - 6px); height: calc(100% - 6px);
  border-radius: 50%; object-fit: cover; background: #f4ece4; z-index: 2;
}
.sticker-picker {
  position: absolute; bottom: 50px; inset-inline-start: 0; width: 330px; padding: 12px;
  border-radius: 16px; background: var(--panel); border: 1px solid rgba(212,160,23,.35);
  box-shadow: var(--shadow); z-index: 21;
}
.sticker-grid, .avatar-icon-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px;
  max-height: 220px; overflow-y: auto;
}
.sticker-grid button, .avatar-icon-grid button {
  padding: 4px; border: 1px solid var(--line); border-radius: 10px;
  background: #f7f0e9; transition: var(--transition); display: grid; place-items: center;
}
.sticker-grid button:hover, .avatar-icon-grid button:hover {
  border-color: var(--sumer-gold); box-shadow: var(--gold-glow); transform: translateY(-2px);
}
.sticker-grid img, .avatar-icon-grid img { width: 100%; aspect-ratio: 1; object-fit: contain; display: block; }
.avatar-icon-grid { grid-template-columns: repeat(7, 1fr); max-height: 160px; }
.avatar-icon-grid img { border-radius: 6px; }
.bubble-image.sticker-sent { background: #f7f0e9; }

/* صور */
.image-bubble { padding: 6px; background: var(--panel-glass); border: 1px solid rgba(212,160,23,.4); backdrop-filter: blur(8px); box-shadow: var(--shadow), var(--gold-glow); }
.bubble-image { display: block; max-width: 100%; max-height: 420px; border-radius: 18px; cursor: zoom-in; }
.image-viewer { width: min(92vw, 1100px); max-height: 92vh; border: 0; border-radius: 18px; background: rgba(8,18,28,.94); padding: 20px; box-shadow: var(--shadow); }
.image-viewer::backdrop { background: rgba(0,0,0,.7); backdrop-filter: blur(4px); }
.image-viewer img { max-width: 100%; max-height: 82vh; border-radius: 12px; display: block; margin: auto; }
.image-viewer button { position: absolute; top: 8px; inset-inline-end: 12px; border: 0; background: transparent; color: #fff; font-size: 28px; }

/* ملفات */
.file-card { display: flex; align-items: center; gap: 11px; min-width: 230px; }
.file-icon { width: 40px; height: 40px; flex: 0 0 40px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 20px; }
.file-copy { flex: 1; min-width: 0; }
.file-copy strong { display: block; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-copy small { font-size: 10px; opacity: .8; }
.file-download { text-decoration: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--frame-gold); color: #4a3500; }

/* شريط الكتابة */
.composer {
  position: relative; margin: 12px 18px 16px; padding: 8px 10px;
  display: flex; align-items: center; gap: 8px;
  border: 1px solid rgba(212,160,23,.35); border-radius: 999px;
  background: var(--panel-glass); box-shadow: var(--shadow); backdrop-filter: blur(12px);
  z-index: 4;
}
.composer-icon {
  width: 36px; height: 36px; flex: 0 0 36px; border: 0; border-radius: 50%;
  background: transparent; font-size: 17px; transition: var(--transition);
}
.composer-icon:hover { background: var(--accent-soft); transform: scale(1.08); }
.message-input { flex: 1; border: 0; background: transparent; border-radius: 999px; padding: 10px 16px; box-shadow: none !important; }
.message-input:focus { background: transparent; }

.send-btn {
  position: relative; width: 42px; height: 42px; flex: 0 0 42px; border: 0; border-radius: 50%;
  background: var(--frame-gold); color: #4a3500; font-size: 16px;
  box-shadow: var(--gold-glow); transition: var(--transition); display: grid; place-items: center;
}
.send-btn:hover { transform: scale(1.08) rotate(-6deg); }
.send-btn.success { background: linear-gradient(135deg, #00B7A8, #0F4C81); color: #fff; }
.send-check { display: none; }
.send-btn.success .send-arrow { display: none; }
.send-btn.success .send-check { display: block; }

.emoji-wrap, .options-wrap, .sticker-wrap { position: relative; }
.emoji-picker {
  position: absolute; bottom: 50px; inset-inline-start: 0; width: 270px; padding: 12px;
  border-radius: 16px; background: var(--panel); border: 1px solid rgba(212,160,23,.35);
  box-shadow: var(--shadow); z-index: 20;
}
.emoji-title { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.emoji-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.emoji-grid button { padding: 8px 4px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); color: var(--text); font-size: 11px; transition: var(--transition); }
.emoji-grid button:hover { border-color: var(--sumer-gold); transform: translateY(-2px); box-shadow: var(--gold-glow); }

.recording-bar {
  margin: 0 18px 8px; padding: 8px 14px; border-radius: 14px;
  display: flex; align-items: center; gap: 10px; font-size: 12px;
  background: var(--panel-glass); border: 1px solid var(--danger); box-shadow: var(--shadow);
}
.recording-bar button { margin-inline-start: auto; border: 0; border-radius: 8px; padding: 5px 10px; background: var(--panel-2); color: var(--text); }
.recording-bar button:last-child { background: var(--frame-gold); color: #4a3500; font-weight: 700; }
.recording-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--danger); animation: pulse 1s infinite; }

/* مكالمات/نوافذ */
.incoming-call {
  position: fixed; bottom: 18px; inset-inline-end: 18px; z-index: 50;
  display: flex; align-items: center; gap: 10px; padding: 12px;
  border-radius: 16px; background: var(--panel); border: 1px solid var(--sumer-gold); box-shadow: var(--shadow), var(--gold-glow);
}
.incoming-icon { width: 38px; height: 38px; }
.incoming-call strong, .incoming-call small { display: block; }
.incoming-call small { color: var(--muted); }
.incoming-call .primary, .incoming-call .danger { padding: 7px 12px; font-size: 12px; }
.call-overlay { position: fixed; inset: 0; z-index: 40; background: rgba(6,16,24,.92); }
dialog { background: var(--panel); color: var(--text); border: 1px solid rgba(212,160,23,.35); border-radius: 18px; box-shadow: var(--shadow); padding: 20px; }
dialog::backdrop { background: rgba(0,0,0,.55); backdrop-filter: blur(3px); }
dialog form { display: grid; gap: 12px; }
dialog h3 { margin: 0; color: var(--accent); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* حركات */
@keyframes slide-in { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@keyframes pulse { 50% { opacity: .35; transform: scale(.85); } }
@keyframes wave { 0% { height: 6px; } 100% { height: 24px; } }

/* ---------- قائمة الجوال (مثل تليكرام) ---------- */
.nav-toggle { display: none; }
.nav-backdrop {
  position: fixed; inset: 0; z-index: 44;
  background: rgba(6, 16, 24, .55); backdrop-filter: blur(2px);
}

@media (max-width: 720px) {
  html, body { height: 100%; overflow: hidden; }
  .app { height: 100vh; height: 100dvh; }

  .sidebar {
    position: fixed; top: 0; bottom: 0; inset-inline-start: 0;
    width: min(86vw, 340px); flex-basis: auto;
    padding: 14px; gap: 10px; z-index: 45;
    transform: translateX(-100%);
    transition: transform var(--transition), visibility var(--transition);
    visibility: hidden;
    box-shadow: -18px 0 48px rgba(6, 16, 24, .3);
    overscroll-behavior: contain;
  }
  html[dir="rtl"] .sidebar {
    transform: translateX(100%);
    box-shadow: 18px 0 48px rgba(6, 16, 24, .3);
  }
  body.nav-open .sidebar { transform: translateX(0); visibility: visible; }

  .nav-toggle { display: grid; flex: 0 0 auto; }
  .chat-header { height: 64px; flex-basis: 64px; padding: 0 8px; gap: 8px; }
  .room-heading { flex: 1 1 auto; gap: 8px; }
  .header-actions { gap: 4px; flex: 0 0 auto; }
  .round-btn { width: 34px; height: 34px; font-size: 15px; }
  .peer-avatar { width: 40px; height: 40px; flex: 0 0 40px; }
  .peer-avatar > span { font-size: 16px; }
  .peer-info h2 { font-size: 14px; }
  .peer-info p { font-size: 10px; }
  #roomMeta { display: none; }

  .messages { padding: 14px 10px 18px; gap: 11px; }
  .bubble { max-width: 90%; }
  .empty { font-size: 13px; padding: 0 12px; }

  .composer {
    margin: 8px 8px calc(8px + env(safe-area-inset-bottom));
    padding: 6px; gap: 3px;
  }
  .composer-icon { width: 34px; height: 34px; flex: 0 0 34px; font-size: 16px; }
  .message-input { min-width: 0; padding: 9px 10px; font-size: 16px; }
  .send-btn { width: 40px; height: 40px; flex: 0 0 40px; font-size: 15px; }

  .stories-bar { padding: 6px 8px; gap: 8px; }
  .story-circle, .story-ring { font-size: 10px; }
  .story-circle > span, .story-ring > span { width: 44px; height: 44px; font-size: 19px; }

  .options-menu { width: min(260px, calc(100vw - 20px)); }
  .emoji-picker, .sticker-picker { width: min(300px, calc(100vw - 24px)); }
  .emoji-grid { grid-template-columns: repeat(3, 1fr); }
  .sticker-grid { grid-template-columns: repeat(5, 1fr); }

  .auth-card {
    width: calc(100% - 20px); margin: 4vh auto;
    padding: 22px 18px; border-radius: 20px;
  }
  .brand h1 { font-size: 24px; }
  .brand-mark { width: 50px; height: 50px; flex-basis: 50px; }

  .feature-dialog, .wide-dialog, .story-viewer { width: 96vw; max-height: 92dvh; }
  .feature-dialog .dialog-body { padding: 12px 14px; }
  .dialog-head { padding: 12px 14px; }
  .miniapp-dialog { width: 96vw; height: 92dvh; }
  .incoming-call { inset-inline: 10px; bottom: 10px; }
  .wallet-balance strong { font-size: 32px; }
}

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

/* ---------------- الميزات الجديدة ---------------- */
.quick-actions { display: flex; gap: 6px; margin: 0 0 10px; }
.quick-btn {
  flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--panel);
  color: var(--text); border-radius: 14px; padding: 8px 2px; cursor: pointer;
  font-size: 17px; line-height: 1.2; transition: var(--transition);
}
.quick-btn small { display: block; font-size: 10px; color: var(--muted); margin-top: 2px; }
.quick-btn:hover { border-color: var(--sumer-gold); transform: translateY(-2px); box-shadow: var(--shadow-soft); }
.mini-add {
  border: 0; background: var(--accent-soft); color: var(--accent); border-radius: 8px;
  width: 22px; height: 22px; line-height: 18px; cursor: pointer; font-weight: 800; margin-inline-start: 4px;
}
.voice-room-item {
  display: flex; align-items: center; gap: 7px; padding: 8px; border-radius: 12px;
  border: 1px solid transparent; cursor: pointer; transition: var(--transition);
}
.voice-room-item:hover { background: var(--panel-2); }
.voice-room-item.active { border-color: var(--sumer-gold); background: var(--accent-soft); }
.voice-room-item .voice-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.voice-room-item .voice-count { font-size: 10px; color: var(--muted); }
.voice-join, .voice-kill { border: 0; border-radius: 8px; padding: 4px 7px; font-size: 11px; cursor: pointer; }
.voice-join { background: var(--accent); color: #fff; }
.voice-kill { background: transparent; color: var(--danger); }

.stories-bar {
  display: flex; align-items: center; gap: 10px; padding: 9px 14px;
  background: var(--panel-glass); border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px); overflow-x: auto; scrollbar-width: thin; flex: none;
}
.story-circle, .story-ring {
  display: flex; flex-direction: column; align-items: center; gap: 4px; flex: none;
  border: 0; background: transparent; color: var(--text); cursor: pointer; padding: 0; font-size: 11px;
}
.story-circle > span, .story-ring > span {
  width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center;
  border: 2px solid var(--sumer-gold); box-shadow: var(--gold-glow); background: var(--panel-2);
  font-size: 22px; overflow: hidden;
}
.story-circle > span img, .story-ring > span img { width: 100%; height: 100%; object-fit: cover; }
.story-ring.seen > span { border-color: var(--line); box-shadow: none; opacity: .72; }
.story-ring .story-initial { font-weight: 800; color: #fff; }
.stories-list { display: flex; gap: 10px; min-width: 0; }

.feature-dialog { width: min(520px, 94vw); max-height: 88vh; padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.wide-dialog { width: min(760px, 95vw); }
.feature-dialog[open] { display: flex; }
.feature-dialog:not([open]) { display: none; }
.dialog-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, var(--accent), var(--tigris-teal)); color: #fff;
}
.dialog-head h3 { color: #fff; margin: 0; font-size: 16px; }
.dialog-head button { border: 0; background: #ffffff28; color: #fff; width: 28px; height: 28px; border-radius: 50%; cursor: pointer; font-size: 18px; line-height: 1; }
.dialog-body { padding: 16px 18px; overflow: auto; display: grid; gap: 12px; }
.feature-dialog > .dialog-actions { padding: 12px 18px; border-top: 1px solid var(--line); background: var(--panel); }
.feature-dialog label { display: grid; gap: 5px; font-size: 12px; font-weight: 700; color: var(--muted); }
.feature-dialog input, .feature-dialog textarea, .feature-dialog select {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 9px 11px;
  font: inherit; font-size: 13px; color: var(--text); background: var(--panel-2); outline: none;
}
.feature-dialog input:focus, .feature-dialog textarea:focus, .feature-dialog select:focus { border-color: var(--tigris-teal); }
.form-row { display: flex; gap: 10px; }
.form-row label { flex: 1; }
.wide { width: 100%; }
.hint { font-size: 11px; color: var(--muted); margin-inline-end: auto; word-break: break-all; }
.bot-link-status {
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
  background: var(--panel-2); font-size: 12px; line-height: 1.9; color: var(--text);
}
.token-box {
  border: 1px dashed var(--sumer-gold); border-radius: 12px; padding: 12px;
  background: linear-gradient(135deg, #d4a01718, #00b7a818); display: grid; gap: 8px;
}
.token-box small { font-size: 11px; color: var(--muted); }
.token-box code {
  display: block; padding: 10px; border-radius: 10px; background: #101820; color: #7ff3e4;
  font-size: 12px; word-break: break-all; direction: ltr; text-align: left; user-select: all;
}
.choice-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.choice-row > span { font-size: 12px; font-weight: 700; color: var(--muted); }
.color-picks, .icon-picks { display: flex; gap: 7px; flex-wrap: wrap; }
.color-picks button {
  width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent;
  background: var(--swatch); cursor: pointer;
}
.color-picks button.selected { border-color: var(--text); box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--sumer-gold); }
.icon-picks button {
  width: 32px; height: 32px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel-2); cursor: pointer; font-size: 17px;
}
.icon-picks button.selected { border-color: var(--sumer-gold); background: var(--accent-soft); }
.check-line { display: flex !important; align-items: center; gap: 8px; flex-direction: row !important; }
.check-line input { width: auto !important; }
.share-link { font-size: 11px; color: var(--accent); word-break: break-all; margin: 0; }

.files-toolbar { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.files-path { font-size: 12px; color: var(--muted); margin-inline-start: auto; }
.files-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; padding: 14px 16px; overflow: auto; min-height: 180px; }
.file-tile {
  border: 1px solid var(--line); border-radius: 14px; padding: 12px 8px; text-align: center;
  background: var(--panel-2); cursor: pointer; position: relative; transition: var(--transition);
}
.file-tile:hover { transform: translateY(-3px); border-color: var(--sumer-gold); box-shadow: var(--shadow-soft); }
.file-tile .tile-icon { font-size: 30px; display: block; line-height: 1.2; }
.file-tile strong { display: block; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 6px; }
.file-tile small { color: var(--muted); font-size: 10px; }
.file-tile .fav { position: absolute; inset-inline-start: 6px; top: 5px; font-size: 12px; }
.file-tile .tile-actions { display: flex; justify-content: center; gap: 5px; margin-top: 7px; }
.file-tile .tile-actions button { border: 0; border-radius: 8px; padding: 3px 7px; font-size: 11px; cursor: pointer; background: var(--panel); color: var(--text); }

.store-tabs { display: flex; gap: 6px; padding: 10px 16px 0; flex-wrap: wrap; }
.store-tabs button { border: 0; border-radius: 10px; padding: 6px 12px; background: var(--panel-2); color: var(--muted); cursor: pointer; font-size: 12px; }
.store-tabs button.active { background: var(--accent); color: #fff; }
.apps-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; padding: 14px 16px; overflow: auto; min-height: 180px; }
.app-card { border: 1px solid var(--line); border-radius: 14px; padding: 12px; background: var(--panel-2); display: flex; flex-direction: column; gap: 7px; }
.app-icon { font-size: 26px; }
.app-card strong { font-size: 13px; }
.app-card p { margin: 0; font-size: 11px; color: var(--muted); line-height: 1.6; flex: 1; }
.app-card .price { font-size: 11px; color: var(--sumer-gold); font-weight: 800; }
.app-actions { display: flex; gap: 5px; flex-wrap: wrap; }
.app-actions button { border: 0; border-radius: 8px; padding: 5px 8px; font-size: 11px; cursor: pointer; background: var(--accent); color: #fff; }
.app-actions button.ghost { background: var(--panel); color: var(--text); border: 1px solid var(--line); }
.miniapp-dialog { width: min(920px, 96vw); height: min(680px, 92vh); padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.miniapp-dialog[open] { display: flex; }
.miniapp-dialog:not([open]) { display: none; }
.miniapp-dialog iframe { flex: 1; width: 100%; border: 0; background: var(--panel); }

.wallet-balance {
  display: grid; justify-items: center; gap: 2px; padding: 18px; border-radius: 16px;
  background: linear-gradient(135deg, var(--river-blue), var(--tigris-teal)); color: #fff;
}
.wallet-balance small { opacity: .85; font-size: 12px; }
.wallet-balance strong { font-size: 40px; line-height: 1.2; }
.wallet-balance span { font-size: 11px; opacity: .8; }
.transaction-list { display: grid; gap: 6px; max-height: 210px; overflow: auto; }
.transaction { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 11px; font-size: 12px; }
.transaction .t-copy { flex: 1; }
.transaction .t-copy small { display: block; color: var(--muted); font-size: 10px; }
.transaction.in strong { color: var(--tigris-teal); }
.transaction.out strong { color: var(--danger); }

.story-viewer { width: min(520px, 94vw); padding: 0; overflow: hidden; position: relative; }
.story-viewer[open] { display: block; }
.story-viewer:not([open]) { display: none; }
.viewer-close { position: absolute; inset-inline-end: 10px; top: 10px; z-index: 2; border: 0; background: #0006; color: #fff; width: 30px; height: 30px; border-radius: 50%; cursor: pointer; font-size: 18px; }
.story-view-content { min-height: 260px; display: grid; place-items: center; padding: 20px; position: relative; color: #fff; background: linear-gradient(135deg, var(--river-blue), var(--tigris-teal)); }
.story-view-content .story-text { font-size: 20px; font-weight: 700; line-height: 1.9; text-align: center; max-width: 92%; }
.story-view-content .story-meta { position: absolute; inset-inline-start: 14px; bottom: 10px; font-size: 11px; opacity: .9; }
.story-view-content img, .story-view-content video { max-width: 100%; max-height: 48vh; border-radius: 12px; }
.story-view-content .story-remove { position: absolute; inset-inline-end: 14px; bottom: 10px; border: 0; background: #0005; color: #fff; border-radius: 8px; padding: 4px 9px; cursor: pointer; font-size: 11px; }
.story-comments { padding: 12px 14px; }
.comments-title { font-size: 12px; font-weight: 800; color: var(--accent); margin-bottom: 6px; }
.story-comment-list { max-height: 160px; overflow: auto; display: grid; gap: 6px; }
.story-comment { background: var(--panel-2); border-radius: 10px; padding: 6px 9px; font-size: 12px; }
.story-comment strong { color: var(--accent); margin-inline-end: 5px; }
.comment-compose { display: flex; gap: 6px; margin-top: 9px; }
.comment-compose input { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--panel-2); color: var(--text); font: inherit; font-size: 12px; }
.comment-compose button { padding: 7px 12px; font-size: 12px; }

.upload-progress { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: #06101a99; backdrop-filter: blur(3px); }
.upload-card { width: min(400px, 92vw); background: var(--panel); border: 1px solid var(--sumer-gold); border-radius: 18px; padding: 18px; box-shadow: var(--shadow), var(--gold-glow); display: grid; gap: 9px; }
.upload-card strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-card > span { font-size: 11px; color: var(--muted); }
.progress-track { height: 10px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.progress-track span { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--river-blue), var(--tigris-teal), var(--sumer-gold)); transition: width 200ms linear; }
.upload-actions { display: flex; align-items: center; justify-content: space-between; font-size: 12px; font-weight: 800; color: var(--accent); }
.upload-actions button { padding: 5px 10px; font-size: 11px; }

@media (max-width: 820px) {
  .stories-bar { padding: 7px 9px; }
  .story-circle > span, .story-ring > span { width: 44px; height: 44px; }
  .feature-dialog, .wide-dialog { width: 96vw; }
}

/* ---------------- أيقونات ثلاثية الأبعاد وتأثيرات بريميوم ---------------- */
:root {
  --glow: rgba(0, 183, 168, .55);
  --glow-soft: rgba(0, 183, 168, .22);
}

.ui-icon, .room-symbol, .btn-icon, .section-icon, .chat-icon, .peer-icon,
.incoming-icon, .call-title-icon, .app-icon, .file-icon, .tile-icon,
.quick-btn, .voice-room-item > span:first-child, .story-add > span {
  filter: drop-shadow(0 2px 0 rgba(6, 16, 24, .28)) drop-shadow(0 5px 9px rgba(15, 76, 129, .24));
  transform: perspective(320px) rotateX(7deg) rotateY(-4deg) translateY(-1px);
  transform-style: preserve-3d;
  transition: transform var(--transition), filter var(--transition);
}
.ui-icon:hover, .room-symbol:hover, .btn-icon:hover, .section-icon:hover,
.chat-icon:hover, .app-icon:hover, .tile-icon:hover, .quick-btn:hover {
  transform: perspective(320px) rotateX(0) rotateY(0) translateY(-3px) scale(1.08);
}

/* النيون يُفعّل من إعدادات المظهر؛ يعمل مع الوضعين النهاري والليلي. */
body.premium .ui-icon, body.premium .room-symbol, body.premium .btn-icon,
body.premium .section-icon, body.premium .chat-icon, body.premium .peer-icon,
body.premium .incoming-icon, body.premium .call-title-icon, body.premium .app-icon,
body.premium .file-icon, body.premium .tile-icon, body.premium .quick-btn,
body.premium .voice-room-item > span:first-child, body.premium .story-add > span {
  filter: drop-shadow(0 0 5px var(--glow)) drop-shadow(0 0 15px var(--glow-soft))
         drop-shadow(0 4px 7px rgba(6, 16, 24, .35));
}
body.premium .send-btn {
  box-shadow: 0 0 12px var(--glow), 0 0 30px var(--glow-soft), inset 0 0 8px rgba(255, 255, 255, .7);
  animation: lamassu-neon 2.6s ease-in-out infinite alternate;
}
body.premium .room-item.active {
  box-shadow: 0 0 0 1px var(--glow), 0 0 20px var(--glow-soft);
}
body.premium .story-circle > span, body.premium .story-ring > span,
body.premium .peer-avatar, body.premium .wallet-balance,
body.premium .quick-btn:hover, body.premium .app-card:hover {
  box-shadow: 0 0 18px var(--glow-soft), var(--gold-glow);
}
body.premium .bubble-row.mine .bubble {
  box-shadow: 0 0 16px var(--glow-soft), 0 8px 20px rgba(15, 76, 129, .18);
}
body.premium .chat-header {
  background: linear-gradient(90deg, var(--river-blue), var(--tigris-teal) 70%, var(--sumer-gold));
  box-shadow: 0 4px 26px var(--glow-soft);
}
@keyframes lamassu-neon {
  from { filter: brightness(1); }
  to { filter: brightness(1.16) saturate(1.1); }
}

/* ---------------- لوحة الألوان ---------------- */
.premium-line { font-size: 12px !important; color: var(--text) !important; }
.color-search-focus { border-color: var(--tigris-teal) !important; box-shadow: 0 0 0 3px var(--glow-soft) !important; }
.color-palette { display: flex; flex-wrap: wrap; gap: 8px; min-height: 34px; }
.color-chip {
  display: flex; align-items: center; gap: 6px; border: 1px solid var(--line);
  border-radius: 12px; padding: 5px 9px 5px 6px; background: var(--panel-2);
  color: var(--text); cursor: pointer; font: inherit; font-size: 11px; transition: var(--transition);
}
.color-chip:hover { transform: translateY(-2px); border-color: var(--sumer-gold); }
.color-chip.active { border-color: var(--sumer-gold); box-shadow: 0 0 12px var(--glow-soft); }
.color-chip .swatch {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  box-shadow: inset 0 1px 3px rgba(255, 255, 255, .65), 0 2px 6px rgba(0, 0, 0, .3);
}
.color-chip .chip-hex { color: var(--muted); font-size: 9px; direction: ltr; }
.color-chip .chip-del { border: 0; background: transparent; color: var(--danger); cursor: pointer; padding: 0 2px; }
.color-add-row { display: flex; gap: 8px; align-items: center; }
.color-add-row #customColorName { flex: 1; min-width: 0; }
.color-add-row input[type="color"] {
  width: 46px; height: 38px; padding: 3px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--panel-2); cursor: pointer;
}
.color-add-row button { white-space: nowrap; font-size: 12px; padding: 8px 12px; }

/* ---------------- جهات الاتصال ---------------- */
.contacts-toolbar { display: flex; align-items: center; gap: 8px; padding: 12px 16px 8px; flex-wrap: wrap; }
.contacts-toolbar input { flex: 1; min-width: 170px; }
.filter-chips { display: flex; gap: 5px; flex-wrap: wrap; }
.filter-chips button {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--muted);
  border-radius: 9px; padding: 6px 10px; font: inherit; font-size: 11px; cursor: pointer;
}
.filter-chips button.active { background: var(--accent); color: #fff; border-color: transparent; box-shadow: 0 0 12px var(--glow-soft); }
.contacts-import { display: flex; gap: 6px; padding: 0 16px 10px; flex-wrap: wrap; }
.contacts-import button, .contact-form button { font-size: 11px; padding: 7px 10px; white-space: nowrap; }
.contact-form { display: flex; gap: 6px; padding: 0 16px 12px; flex-wrap: wrap; }
.contact-form input { flex: 1; min-width: 110px; }
.contact-form select { width: auto; min-width: 88px; }
.contacts-list { overflow: auto; min-height: 200px; max-height: 46vh; padding: 0 16px 14px; display: grid; gap: 7px; align-content: start; }
.contact-row {
  display: flex; align-items: center; gap: 9px; border: 1px solid var(--line);
  border-radius: 13px; padding: 8px 10px; background: var(--panel-2);
}
.contact-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--river-blue), var(--tigris-teal)); color: #fff; font-weight: 800; font-size: 14px;
}
.contact-copy { flex: 1; min-width: 0; }
.contact-copy strong { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact-copy small { display: block; color: var(--muted); font-size: 11px; direction: ltr; text-align: right; }
.source-badge { font-size: 9px; border-radius: 7px; padding: 2px 6px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.contact-row .edit-contact, .contact-row .delete-contact {
  border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 4px 6px; font-size: 14px;
}
.contact-row .delete-contact:hover { color: var(--danger); }

@media (max-width: 520px) {
  .quick-btn { font-size: 15px; }
  .quick-btn small { font-size: 9px; }
  .contact-form input { min-width: 100%; }
}

/* ---------- تابلت: عمودان مريحان ---------- */
@media (min-width: 721px) and (max-width: 1000px) {
  .sidebar { width: 252px; flex-basis: 252px; padding: 12px; gap: 10px; }
  .room-item { padding: 9px; }
  .chat-header { height: 68px; flex-basis: 68px; padding: 0 14px; }
  .bubble { max-width: 84%; }
  .composer { margin: 10px 12px 12px; }
  .quick-btn { font-size: 16px; }
}

/* ---------- شاشات كبيرة: تكبير متناسب مثل تليكرام ---------- */
@media (min-width: 1400px) {
  .sidebar { width: 340px; flex-basis: 340px; padding: 20px; gap: 14px; }
  .sidebar header .ghost { padding: 8px 13px; font-size: 13px; }
  .brand.small .brand-mark { width: 46px; height: 46px; flex-basis: 46px; }
  .brand.small strong { font-size: 17px; }
  .brand small { font-size: 13px; }
  .quick-btn { font-size: 20px; padding: 10px 2px; }
  .quick-btn small { font-size: 11px; }
  .sidebar-section h3 { font-size: 14px; }
  .room-item, .member-item, .notification-item { padding: 12px; gap: 12px; }
  .room-item strong, .member-item strong { font-size: 14.5px; }
  .room-item small, .member-item small, .notification-item small { font-size: 12px; }
  .room-item .room-symbol { width: 34px; height: 34px; }
  .badge { font-size: 12px; padding: 2px 9px; }
  .voice-room-item .voice-name { font-size: 13px; }
  .voice-room-item .voice-count { font-size: 11px; }

  .chat-header { height: 84px; flex-basis: 84px; padding: 0 24px; gap: 16px; }
  .peer-avatar { width: 54px; height: 54px; flex-basis: 54px; }
  .peer-avatar > span { font-size: 20px; }
  .peer-info h2 { font-size: 19px; }
  .peer-info p { font-size: 12px; }
  .round-btn { width: 42px; height: 42px; font-size: 18px; }
  .options-menu { width: 280px; }

  .stories-bar { padding: 11px 20px; }
  .story-circle, .story-ring { font-size: 12px; }
  .story-circle > span, .story-ring > span { width: 62px; height: 62px; font-size: 26px; }

  .messages { padding: 26px 34px 34px; gap: 16px; }
  .bubble { max-width: min(72%, 720px); padding: 13px 16px 10px; font-size: 15.5px; }
  .bubble-meta { font-size: 11px; }
  .sender-label { font-size: 12px; }
  .day-sep { font-size: 12px; padding: 5px 14px; }
  .bubble-image { max-height: 520px; }

  .composer { margin: 14px 26px 22px; padding: 9px 12px; gap: 9px; }
  .composer-icon { width: 40px; height: 40px; flex-basis: 40px; font-size: 19px; }
  .message-input { font-size: 16px; padding: 11px 18px; }
  .send-btn { width: 46px; height: 46px; flex-basis: 46px; font-size: 18px; }

  .feature-dialog { width: min(600px, 94vw); }
  .wide-dialog { width: min(880px, 95vw); }
  .auth-card { width: min(520px, calc(100% - 32px)); padding: 36px; }
  .brand h1 { font-size: 32px; }
}

@media (min-width: 1900px) {
  .sidebar { width: 400px; flex-basis: 400px; padding: 24px; }
  .quick-btn { font-size: 22px; }
  .quick-btn small { font-size: 12px; }
  .room-item strong, .member-item strong { font-size: 16px; }
  .room-item small, .member-item small, .notification-item small { font-size: 13px; }
  .room-item .room-symbol { width: 38px; height: 38px; }

  .chat-header { height: 96px; flex-basis: 96px; padding: 0 32px; }
  .peer-avatar { width: 62px; height: 62px; flex-basis: 62px; }
  .peer-avatar > span { font-size: 23px; }
  .peer-info h2 { font-size: 22px; }
  .peer-info p { font-size: 13px; }
  .round-btn { width: 48px; height: 48px; font-size: 20px; }
  .options-menu { width: 310px; }

  .story-circle > span, .story-ring > span { width: 72px; height: 72px; }
  .messages { padding: 32px 48px 40px; gap: 18px; }
  .bubble { max-width: min(68%, 900px); font-size: 17px; padding: 15px 18px 11px; }
  .composer { margin: 18px 38px 28px; }
  .composer-icon { width: 44px; height: 44px; flex-basis: 44px; font-size: 21px; }
  .message-input { font-size: 17px; }
  .send-btn { width: 52px; height: 52px; flex-basis: 52px; font-size: 20px; }
  .auth-card { width: min(600px, calc(100% - 32px)); }
  .brand h1 { font-size: 36px; }
}
