:root{
  --bg: #0b1220;
  --panel: rgba(255,255,255,.06);
  --panel2: rgba(255,255,255,.08);
  --stroke: rgba(255,255,255,.10);
  --text: rgba(255,255,255,.92);
  --muted: rgba(255,255,255,.65);
  --muted2: rgba(255,255,255,.45);

  --user: rgba(96,165,250,.18);
  --userStroke: rgba(96,165,250,.35);

  --bot: rgba(34,197,94,.14);
  --botStroke: rgba(34,197,94,.30);

  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --radius: 18px;

  /* ✅ تكبير/تصغير الخط */
  --fontScale: 1;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }

body{
  margin:0;
  font-family: "Readex Pro", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Tahoma", Arial;
  font-size: calc(14px * var(--fontScale));
  background:
    radial-gradient(900px 500px at 20% 10%, rgba(99,102,241,.35), transparent 55%),
    radial-gradient(800px 500px at 80% 30%, rgba(34,197,94,.25), transparent 55%),
    radial-gradient(700px 500px at 50% 100%, rgba(56,189,248,.18), transparent 60%),
    var(--bg);
  color:var(--text);
  overflow:hidden;
}

/* Topbar */
.topbar{
  position:sticky;
  top:0;
  z-index:10;
  backdrop-filter: blur(14px);
  background: linear-gradient(to bottom, rgba(0,0,0,.55), rgba(0,0,0,.15));
  border-bottom:1px solid var(--stroke);
}
.topbar__inner{
  max-width:980px;
  margin:0 auto;
  padding:12px 14px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}
.brand{ display:flex; align-items:center; gap:10px; min-width:0; }
.brand__logo{
  width:38px; height:38px; border-radius:14px;
  display:grid; place-items:center;
  background: linear-gradient(135deg, rgba(99,102,241,.25), rgba(34,197,94,.20));
  border:1px solid var(--stroke);
  box-shadow: var(--shadow);
  flex:0 0 auto;
}
.brand__text{ min-width:0; }
.brand__title{
  font-weight:800;
  letter-spacing:.2px;
  font-size:16px;
  line-height:1.1;
}
.brand__sub{
  font-size:12px;
  color:var(--muted);
  margin-top:3px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.topbar__actions{ display:flex; gap:8px; }
.iconBtn{
  width:38px; height:38px;
  border-radius:14px;
  border:1px solid var(--stroke);
  background: var(--panel);
  color:var(--text);
  cursor:pointer;
  transition:.15s transform, .15s background;
}
.iconBtn:hover{ background: var(--panel2); transform: translateY(-1px); }

/* App */
.app{
  height:calc(100% - 64px);
  display:flex;
  justify-content:center;
}
.chat{
  width:100%;
  max-width:980px;
  height:100%;
  display:flex;
  flex-direction:column;
}

/* Chat body */
.chat__body{
  flex:1;
  overflow:auto;
  padding:18px 14px 120px;
  scroll-behavior:smooth;
}
.chat__body::-webkit-scrollbar{ width:10px; }
.chat__body::-webkit-scrollbar-thumb{
  background: rgba(255,255,255,.10);
  border-radius:999px;
  border:2px solid rgba(0,0,0,.25);
}

/* Message rows */
.msgRow{
  display:flex;
  margin:10px 0;
}
.msgRow--user{ justify-content:flex-end; }
.msgRow--bot{ justify-content:flex-start; }

.bubble{
  max-width: min(720px, 92%);
  border-radius: var(--radius);
  padding:12px 12px;
  border:1px solid var(--stroke);
  background: var(--panel);
  box-shadow: 0 10px 25px rgba(0,0,0,.18);
  position:relative;
}
.bubble--user{
  background: linear-gradient(180deg, var(--user), rgba(255,255,255,.04));
  border-color: var(--userStroke);
}
.bubble--bot{
  background: linear-gradient(180deg, var(--bot), rgba(255,255,255,.04));
  border-color: var(--botStroke);
}

/* Bubble header */
.bubbleHead{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-bottom:8px;
}
.badge{
  font-size:12px;
  color:var(--muted);
  display:flex;
  align-items:center;
  gap:8px;
}
.badge strong{
  color:var(--text);
  font-weight:800;
}

.pill{
  padding:3px 8px;
  border-radius:999px;
  border:1px solid var(--stroke);
  background: rgba(0,0,0,.18);
  font-size:11px;
  color: rgba(255,255,255,.75);
}

.copyMini{
  border:1px solid var(--stroke);
  background: rgba(0,0,0,.22);
  color:var(--text);
  padding:6px 10px;
  border-radius:12px;
  cursor:pointer;
  font-size:12px;
}
.copyMini:hover{ background: rgba(0,0,0,.30); }

/* Text formatting */
.bubble p{ margin:0 0 10px; line-height:1.9; }
.bubble p:last-child{ margin-bottom:0; }
.bubble ul{ margin:8px 0 0; padding:0 18px 0 0; }
.bubble li{ margin:6px 0; }
hr.sep{
  border:none;
  border-top:1px dashed rgba(255,255,255,.14);
  margin:10px 0;
}

/* Typing indicator */
.typing{
  display:inline-flex;
  gap:6px;
  align-items:center;
  padding:10px 12px;
  border-radius: 999px;
  border:1px solid var(--stroke);
  background: rgba(0,0,0,.20);
  color: var(--muted);
  font-size:12px;
}
.dot{
  width:6px; height:6px; border-radius:999px;
  background: rgba(255,255,255,.45);
  animation: bounce 1s infinite ease-in-out;
}
.dot:nth-child(2){ animation-delay:.15s; }
.dot:nth-child(3){ animation-delay:.30s; }
@keyframes bounce{
  0%, 80%, 100%{ transform: translateY(0); opacity:.55; }
  40%{ transform: translateY(-4px); opacity:1; }
}

/* Composer */
.composerWrap{
  position:sticky;
  bottom:0;
  padding:12px 12px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(0,0,0,.70), rgba(0,0,0,.10));
  backdrop-filter: blur(14px);
  border-top:1px solid var(--stroke);
}
.composer{
  max-width:980px;
  margin:0 auto;
}
.composer__box{
  display:flex;
  gap:10px;
  align-items:flex-end;
  border-radius: 22px;
  padding:10px;
  border:1px solid var(--stroke);
  background: rgba(255,255,255,.06);
  box-shadow: var(--shadow);
}
.composer__input{
  width:100%;
  resize:none;
  outline:none;
  border:none;
  background: transparent;
  color:var(--text);
  font-size:14px;
  line-height:1.7;
  max-height:150px;
  padding:6px 6px;
}
.composer__input::placeholder{ color: rgba(255,255,255,.45); }

.composer__tools{ display:flex; gap:8px; align-items:center; }
.toolBtn{
  width:42px; height:42px;
  border-radius: 16px;
  border:1px solid var(--stroke);
  background: rgba(0,0,0,.20);
  color:var(--text);
  cursor:pointer;
}
.toolBtn:hover{ background: rgba(0,0,0,.28); }

.sendBtn{
  height:42px;
  padding:0 16px;
  border-radius: 16px;
  border:1px solid rgba(96,165,250,.40);
  background: rgba(96,165,250,.18);
  color:var(--text);
  font-weight:800;
  cursor:pointer;
}
.sendBtn:hover{ background: rgba(96,165,250,.26); }

.chips{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin-top:10px;
}
.chip{
  border:1px solid var(--stroke);
  background: rgba(0,0,0,.18);
  color:var(--text);
  padding:8px 10px;
  border-radius: 999px;
  cursor:pointer;
  font-size:12px;
}
.chip:hover{ background: rgba(0,0,0,.26); }

.composer__hint{
  margin-top:8px;
  font-size:11px;
  color:var(--muted2);
  padding-inline:6px;
}

/* ✅ زر (المزيد) + تدرّج */
.moreBtn{
  margin-top:10px;
  display:inline-flex;
  gap:8px;
  align-items:center;
  border:1px solid var(--stroke);
  background: rgba(0,0,0,.18);
  color: var(--text);
  padding:8px 12px;
  border-radius: 14px;
  cursor:pointer;
  font-size:12px;
}
.moreBtn:hover{ background: rgba(0,0,0,.26); }

.snippetFade{
  position:relative;
}
.snippetFade::after{
  content:"";
  position:absolute;
  left:0; right:0; bottom:0;
  height:48px;
  background: linear-gradient(to top, rgba(11,18,32,1), rgba(11,18,32,0));
  pointer-events:none;
  border-radius: 0 0 var(--radius) var(--radius);
}

/* Mobile tweaks */
@media (max-width: 520px){
  .brand__sub{ display:none; }
  .chat__body{ padding:14px 10px 128px; }
  .bubble{ max-width: 94%; }
  .composer__box{ border-radius: 18px; }
}
