/* =========================================================
   SALMA AI – سلمى | style.css
   الهوية: بنفسجي ملكي + ذهبي فاخر
   ========================================================= */

:root{
  --bg-1:#1B0A2B;
  --bg-2:#2A1042;
  --bg-3:#3A1259;
  --card:#2A1042;
  --card-soft:#331452;
  --gold:#D4AF37;
  --gold-light:#F3DC9A;
  --gold-line:rgba(212,175,55,.35);
  --gold-soft:rgba(212,175,55,.14);
  --cream:#F6EEDD;
  --muted:#C8B6D8;
  --bubble-salma:#FBF3E4;
  --bubble-salma-text:#2A1042;
  --user-a:#4B1F72;
  --user-b:#3A1259;
  --danger:#E4736B;
  --ok:#8FD9AE;
  --r-lg:24px;
  --r-md:18px;
  --r-sm:14px;
  --chat-font:16px;
}

*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;padding:0;height:100%}
body{
  font-family:'Cairo',system-ui,-apple-system,'Segoe UI',sans-serif;
  background:var(--bg-1);
  color:var(--cream);
  overflow:hidden;
  -webkit-font-smoothing:antialiased;
  text-rendering:optimizeLegibility;
}
button{font-family:inherit;color:inherit;background:none;border:none;cursor:pointer;user-select:none;-webkit-user-select:none}
input,textarea,select{font-family:inherit}
h1,h2,h3,p{margin:0}
.hidden{display:none !important}
.amiri{font-family:'Amiri',serif}
.muted{color:var(--muted)}
.small{font-size:12.5px;line-height:1.7}

/* ---------------- التخطيط العام ---------------- */
.app{
  position:relative;
  height:100vh;
  height:100dvh;
  display:flex;
  flex-direction:column;
  overflow:hidden;
  background:linear-gradient(180deg,#1B0A2B 0%,#250E3D 38%,#331050 70%,#3A1259 100%);
}
.bg-layer{position:absolute;inset:0;pointer-events:none;z-index:0;overflow:hidden}
.bg-layer::before{
  content:'';position:absolute;inset:0;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='88' viewBox='0 0 88 88'%3E%3Cg fill='none' stroke='%23D4AF37' stroke-width='1'%3E%3Cpath d='M44 4 84 44 44 84 4 44Z'/%3E%3Cpath d='M44 18 70 44 44 70 18 44Z'/%3E%3Ccircle cx='44' cy='44' r='5.5'/%3E%3Cpath d='M0 0 10 10M88 0 78 10M0 88 10 78M88 88 78 78'/%3E%3C/g%3E%3C/svg%3E");
  background-size:88px 88px;
  opacity:.06;
}
.bg-layer::after{
  content:'';position:absolute;top:-140px;left:50%;transform:translateX(-50%);
  width:420px;height:360px;border-radius:50%;
  background:radial-gradient(circle,rgba(212,175,55,.20),transparent 68%);
  filter:blur(18px);
}

/* ---------------- الرأس ---------------- */
.app-header{
  position:relative;z-index:3;
  display:flex;align-items:center;justify-content:space-between;gap:12px;
  padding:12px 16px 10px;
  background:linear-gradient(180deg,rgba(27,10,43,.96),rgba(27,10,43,.72));
  border-bottom:1px solid rgba(212,175,55,.18);
  backdrop-filter:blur(14px);
  -webkit-backdrop-filter:blur(14px);
}
.brand{display:flex;align-items:center;gap:11px;min-width:0}

.logo{
  position:relative;flex:0 0 auto;
  width:46px;height:46px;border-radius:50%;
  display:grid;place-items:center;
  background:linear-gradient(160deg,#F3DC9A,#D4AF37 55%,#A8842A);
  box-shadow:0 0 0 1px rgba(243,220,154,.55),0 6px 18px rgba(212,175,55,.28),inset 0 1px 2px rgba(255,255,255,.5);
}
.logo::after{
  content:'';position:absolute;inset:4px;border-radius:50%;
  border:1px solid rgba(58,18,89,.42);
  box-shadow:inset 0 0 0 2px rgba(255,255,255,.18);
}
.logo-letter{
  font-family:'Amiri',serif;font-weight:700;font-size:25px;line-height:1;
  color:#2A1042;transform:translateY(-1px);
  text-shadow:0 1px 0 rgba(255,255,255,.35);
}
.logo.small{width:38px;height:38px}
.logo.small .logo-letter{font-size:20px}

.brand-text{min-width:0}
.brand-name{
  font-family:'Tajawal',sans-serif;font-weight:800;font-size:16px;line-height:1.25;
  color:var(--cream);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
  display:flex;align-items:baseline;gap:5px;
}
.brand-name .latin{letter-spacing:.2px}
.brand-name .sep{color:var(--gold);opacity:.8}
.brand-name .amiri{font-size:19px;color:var(--gold-light)}
.status-line{
  display:flex;align-items:center;gap:6px;
  font-size:11px;color:var(--muted);margin-top:1px;
}
.status-dot{
  width:7px;height:7px;border-radius:50%;flex:0 0 auto;
  background:var(--gold);box-shadow:0 0 0 3px rgba(212,175,55,.16);
  animation:dotPulse 2.4s ease-in-out infinite;
}
.status-line.st-listening .status-dot{background:#8FD9AE;box-shadow:0 0 0 3px rgba(143,217,174,.2)}
.status-line.st-thinking .status-dot{background:var(--gold-light);animation-duration:1s}
.status-line.st-speaking .status-dot{background:#B3A0FF;box-shadow:0 0 0 3px rgba(179,160,255,.2)}
.status-line.st-sorry .status-dot{background:var(--danger);box-shadow:0 0 0 3px rgba(228,115,107,.18);animation:none}
@keyframes dotPulse{0%,100%{opacity:1;transform:scale(1)}50%{opacity:.45;transform:scale(.82)}}

.avatar-btn{padding:0;background:none;border:none;flex:0 0 auto}
.avatar-ring{
  position:relative;display:grid;place-items:center;
  width:42px;height:42px;border-radius:50%;overflow:hidden;
  background:linear-gradient(160deg,#4A1E74,#2A1042);
  border:1.5px solid var(--gold);
  box-shadow:0 0 0 3px rgba(212,175,55,.10);
  transition:box-shadow .25s ease;
}
.avatar-ring img{width:100%;height:100%;object-fit:cover;object-position:center 18%}
.avatar-fallback{
  position:absolute;font-family:'Amiri',serif;font-size:20px;color:var(--gold-light);
}
.avatar-ring.listening{box-shadow:0 0 0 3px rgba(143,217,174,.3),0 0 18px rgba(143,217,174,.4)}
.avatar-ring.speaking{animation:ringPulse 1.1s ease-in-out infinite}
.avatar-ring.thinking{box-shadow:0 0 0 3px rgba(243,220,154,.35),0 0 16px rgba(212,175,55,.4)}
@keyframes ringPulse{0%,100%{box-shadow:0 0 0 3px rgba(212,175,55,.35),0 0 14px rgba(212,175,55,.35)}50%{box-shadow:0 0 0 6px rgba(212,175,55,.14),0 0 22px rgba(212,175,55,.55)}}

/* ---------------- الشاشات ---------------- */
.screens{position:relative;z-index:1;flex:1 1 auto;min-height:0;display:flex}
.screen{position:absolute;inset:0;display:flex;flex-direction:column;min-height:0}
.screen-scroll{
  flex:1 1 auto;overflow-y:auto;overscroll-behavior:contain;
  padding:16px 16px 28px;display:flex;flex-direction:column;gap:16px;
}
.screen-head{display:flex;flex-direction:column;gap:5px}
.screen-title{font-family:'Tajawal',sans-serif;font-weight:700;font-size:22px;color:var(--cream)}
.screen-sub{font-size:13px;line-height:1.7;color:var(--muted)}

/* ---------------- المحادثة ---------------- */
.chat-scroll{
  flex:1 1 auto;overflow-y:auto;overscroll-behavior:contain;
  padding:16px 14px 8px;scroll-behavior:smooth;
}
.welcome{display:flex;flex-direction:column;align-items:center;text-align:center;gap:10px;padding:8px 4px 6px}

.hero-orb{position:relative;width:132px;height:132px;margin-bottom:2px}
.hero-orb .halo{
  position:absolute;inset:-10px;border-radius:50%;
  background:conic-gradient(from 0deg,rgba(212,175,55,0),rgba(243,220,154,.55),rgba(212,175,55,0),rgba(243,220,154,.4),rgba(212,175,55,0));
  filter:blur(6px);opacity:.7;
  animation:haloSpin 9s linear infinite;
}
@keyframes haloSpin{to{transform:rotate(360deg)}}
.hero-orb .portrait{
  position:absolute;inset:0;border-radius:50%;overflow:hidden;
  display:grid;place-items:center;
  background:radial-gradient(circle at 50% 20%,#4A1E74,#250E3D 75%);
  border:2px solid var(--gold);
  box-shadow:0 0 0 5px rgba(212,175,55,.10),0 14px 34px rgba(0,0,0,.45),inset 0 0 24px rgba(212,175,55,.14);
}
.hero-orb .portrait img{width:100%;height:100%;object-fit:cover;object-position:center 14%}
.hero-orb .portrait-fallback{position:absolute;font-family:'Amiri',serif;font-size:56px;color:var(--gold-light)}

.think-dots{
  position:absolute;bottom:2px;left:50%;transform:translateX(-50%);
  display:none;gap:5px;padding:5px 10px;border-radius:999px;
  background:rgba(27,10,43,.9);border:1px solid var(--gold-line);
}
.think-dots i{width:6px;height:6px;border-radius:50%;background:var(--gold-light);animation:thinkBounce 1s infinite}
.think-dots i:nth-child(2){animation-delay:.15s}
.think-dots i:nth-child(3){animation-delay:.3s}
@keyframes thinkBounce{0%,100%{transform:translateY(0);opacity:.5}50%{transform:translateY(-4px);opacity:1}}

.sound-waves{
  position:absolute;bottom:-6px;display:none;align-items:flex-end;gap:3px;
  height:20px;padding:4px 10px;border-radius:999px;
  background:rgba(27,10,43,.9);border:1px solid var(--gold-line);
}
.sound-waves i{width:3px;border-radius:3px;background:var(--gold-light);height:6px;animation:waveBounce .9s ease-in-out infinite}
.sound-waves i:nth-child(2){animation-delay:.1s}
.sound-waves i:nth-child(3){animation-delay:.2s}
.sound-waves i:nth-child(4){animation-delay:.3s}
@keyframes waveBounce{0%,100%{height:5px;opacity:.6}50%{height:15px;opacity:1}}

.hero-orb.listening .sound-waves{display:flex}
.hero-orb.listening .portrait{animation:tiltHead 2.4s ease-in-out infinite;box-shadow:0 0 0 5px rgba(143,217,174,.12),0 0 30px rgba(143,217,174,.35)}
.hero-orb.thinking .think-dots{display:flex}
.hero-orb.speaking .halo{opacity:1;animation-duration:2.2s}
.hero-orb.speaking .portrait{box-shadow:0 0 0 5px rgba(243,220,154,.18),0 0 34px rgba(212,175,55,.45)}
.hero-orb.sorry .portrait{filter:saturate(.7) brightness(.85);transform:translateY(3px)}
@keyframes tiltHead{0%,100%{transform:rotate(-2.5deg)}50%{transform:rotate(2.5deg)}}

.welcome-title{font-size:26px;color:var(--gold-light);font-weight:700;line-height:1.4}
.welcome-sub{font-size:13.5px;line-height:1.8;color:var(--muted);max-width:330px}
.quick-chips{display:flex;flex-wrap:wrap;gap:8px;justify-content:center;margin-top:6px}
.chip{
  padding:9px 14px;border-radius:999px;font-size:12.5px;font-weight:600;
  color:var(--gold-light);background:rgba(212,175,55,.08);
  border:1px solid var(--gold-line);
  transition:transform .15s ease,background .2s ease;
  min-height:38px;
}
.chip:active{transform:scale(.96);background:rgba(212,175,55,.18)}

/* فقاعات الرسائل */
.messages{display:flex;flex-direction:column;gap:12px;padding-bottom:6px}
.msg-row{display:flex;gap:8px;align-items:flex-end;animation:msgIn .25s ease-out both}
@keyframes msgIn{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none}}
.msg-row.salma{justify-content:flex-start}
.msg-row.user{justify-content:flex-end}
.msg-row.error{justify-content:center}

.mini-avatar{
  position:relative;flex:0 0 auto;width:30px;height:30px;border-radius:50%;overflow:hidden;
  display:grid;place-items:center;background:#3A1259;border:1px solid var(--gold-line);
  margin-bottom:14px;
}
.mini-avatar img{width:100%;height:100%;object-fit:cover;object-position:center 16%}
.mini-avatar .avatar-fallback{font-size:14px}

.bubble{
  max-width:84%;padding:11px 14px;border-radius:var(--r-md);
  font-size:var(--chat-font);line-height:1.75;position:relative;
  word-break:break-word;
}
.user-bubble{
  background:linear-gradient(160deg,var(--user-a),var(--user-b));
  color:var(--cream);border:1px solid var(--gold-line);
  border-end-start-radius:6px;
  box-shadow:0 6px 18px rgba(0,0,0,.25);
}
.salma-bubble{
  background:var(--bubble-salma);color:var(--bubble-salma-text);
  border:1px solid rgba(212,175,55,.45);
  border-end-end-radius:6px;
  box-shadow:0 8px 22px rgba(0,0,0,.3),inset 0 1px 0 rgba(255,255,255,.7);
}
.bubble-text{white-space:pre-wrap;overflow-wrap:anywhere}
.bubble-img{display:block;max-width:210px;width:100%;border-radius:12px;margin-bottom:8px;border:1px solid rgba(212,175,55,.35)}
.bubble-meta{font-size:10.5px;color:rgba(42,16,66,.5);margin-top:5px;text-align:end;user-select:none}
.user-bubble .bubble-meta{color:rgba(246,238,221,.55)}

.bubble-foot{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-top:6px}
.speak-btn{
  display:inline-flex;align-items:center;gap:5px;
  padding:5px 11px;border-radius:999px;font-size:11.5px;font-weight:700;
  color:#3A1259;background:rgba(212,175,55,.22);
  border:1px solid rgba(212,175,55,.55);
  min-height:29px;
}
.speak-btn:active{background:rgba(212,175,55,.4)}
.speak-btn svg{width:13px;height:13px}

.sources{margin-top:10px;padding-top:9px;border-top:1px dashed rgba(42,16,66,.22)}
.sources-title{font-size:11.5px;font-weight:700;color:#6B4A8C;margin-bottom:4px}
.sources ol{margin:0;padding-inline-start:18px;display:flex;flex-direction:column;gap:3px}
.sources li{font-size:12px;line-height:1.6}
.sources a{color:#5B2E8F;text-decoration:underline;text-underline-offset:3px;word-break:break-all}

.error-bubble{
  max-width:88%;padding:11px 14px;border-radius:var(--r-md);
  background:rgba(228,115,107,.12);border:1px solid rgba(228,115,107,.45);
  color:#FFD9D5;font-size:13px;line-height:1.7;text-align:center;
}
.error-bubble .retry-btn{
  display:inline-block;margin-top:8px;padding:7px 16px;border-radius:999px;
  background:rgba(228,115,107,.2);border:1px solid rgba(228,115,107,.6);
  color:#FFE7E4;font-size:12px;font-weight:700;min-height:34px;
}
.typing-row{display:flex;gap:8px;align-items:flex-end}
.typing-bubble{
  background:var(--bubble-salma);border:1px solid rgba(212,175,55,.45);
  padding:12px 16px;border-radius:var(--r-md);border-end-end-radius:6px;
  display:flex;gap:5px;align-items:center;
}
.typing-bubble i{width:7px;height:7px;border-radius:50%;background:#8A6BB0;animation:thinkBounce 1.1s infinite}
.typing-bubble i:nth-child(2){animation-delay:.16s}
.typing-bubble i:nth-child(3){animation-delay:.32s}

/* ---------------- صندوق الكتابة ---------------- */
.composer-wrap{
  position:relative;z-index:2;flex:0 0 auto;
  padding:8px 12px 10px;
  background:linear-gradient(180deg,rgba(27,10,43,0),rgba(27,10,43,.9) 26%);
}
.composer{
  background:linear-gradient(180deg,#2E1149,#260E3F);
  border:1px solid var(--gold-line);
  border-radius:22px;
  padding:8px 10px 8px;
  box-shadow:0 10px 26px rgba(0,0,0,.35),inset 0 1px 0 rgba(255,255,255,.05);
}
#msgInput{
  width:100%;border:none;outline:none;background:transparent;
  color:var(--cream);font-size:16px;line-height:1.6;
  resize:none;max-height:120px;padding:6px 6px 2px;
}
#msgInput::placeholder{color:rgba(200,182,216,.6)}
.composer-row{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-top:4px}
.composer-start{display:flex;align-items:center;gap:8px;min-width:0;flex:1 1 auto}
.composer-end{display:flex;align-items:center;gap:8px;flex:0 0 auto}

.round-btn{
  width:44px;height:44px;border-radius:50%;
  display:grid;place-items:center;
  background:rgba(212,175,55,.1);
  border:1px solid var(--gold-line);
  color:var(--gold-light);
  transition:transform .14s ease,background .2s ease;
  flex:0 0 auto;
}
.round-btn:active{transform:scale(.93);background:rgba(212,175,55,.22)}
.round-btn svg{width:21px;height:21px}

.cost-hint{
  font-size:11px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
  min-width:0;
}

.mic-btn{
  width:56px;height:56px;border-radius:50%;
  display:grid;place-items:center;flex:0 0 auto;
  color:#2A1042;
  background:linear-gradient(160deg,#F3DC9A,#D4AF37 60%,#B8912C);
  border:1px solid rgba(255,255,255,.5);
  box-shadow:0 0 0 3px rgba(212,175,55,.14),0 8px 22px rgba(212,175,55,.3);
  animation:micPulse 2.8s ease-in-out infinite;
  transition:transform .14s ease;
}
.mic-btn svg{width:24px;height:24px}
.mic-btn:active{transform:scale(.94)}
.mic-btn.recording{
  background:linear-gradient(160deg,#E4736B,#C24A42);
  color:#FFF3F1;animation:recPulse 1s ease-in-out infinite;
}
@keyframes micPulse{0%,100%{box-shadow:0 0 0 3px rgba(212,175,55,.14),0 8px 22px rgba(212,175,55,.26)}50%{box-shadow:0 0 0 8px rgba(212,175,55,.06),0 8px 28px rgba(212,175,55,.42)}}
@keyframes recPulse{0%,100%{box-shadow:0 0 0 3px rgba(228,115,107,.25),0 0 18px rgba(228,115,107,.4)}50%{box-shadow:0 0 0 10px rgba(228,115,107,.08),0 0 30px rgba(228,115,107,.55)}}

.send-btn{
  width:46px;height:46px;border-radius:50%;
  display:grid;place-items:center;flex:0 0 auto;
  background:linear-gradient(160deg,#4B1F72,#2A1042);
  border:1px solid var(--gold);
  color:var(--gold-light);
  transition:transform .14s ease,background .2s ease;
}
.send-btn svg{width:20px;height:20px;transform:scaleX(-1)}
.send-btn:active{transform:scale(.93)}
.send-btn.busy{opacity:.5;pointer-events:none}

.attach-preview{
  display:flex;align-items:center;gap:10px;
  padding:8px;margin-bottom:6px;border-radius:14px;
  background:rgba(212,175,55,.08);border:1px solid var(--gold-line);
}
.attach-preview img{width:48px;height:48px;object-fit:cover;border-radius:10px}
.attach-preview .attach-text{font-size:12px;color:var(--muted);flex:1 1 auto;min-width:0}
.attach-preview .attach-x{
  width:32px;height:32px;border-radius:50%;display:grid;place-items:center;
  background:rgba(228,115,107,.15);border:1px solid rgba(228,115,107,.4);color:#FFD9D5;font-size:14px;
}

/* تنبيه تعذّر خدمة الذكاء الاصطناعي */
.svc-banner{
  display:flex;align-items:flex-start;gap:10px;
  margin-bottom:8px;padding:10px 12px;border-radius:16px;
  background:rgba(228,115,107,.14);
  border:1px solid rgba(228,115,107,.5);
  color:#FFE3DF;font-size:12.5px;line-height:1.7;
  animation:msgIn .22s ease-out both;
}
.svc-banner-text{flex:1 1 auto;min-width:0;overflow-wrap:anywhere}
.svc-banner-x{
  flex:0 0 auto;width:28px;height:28px;border-radius:50%;
  display:grid;place-items:center;
  background:rgba(228,115,107,.18);border:1px solid rgba(228,115,107,.45);
  color:#FFE3DF;font-size:12px;min-height:28px;
}
.svc-banner-x:active{background:rgba(228,115,107,.34)}

/* شريط التسجيل */
.rec-bar{
  display:flex;align-items:center;gap:10px;flex-wrap:wrap;
  padding:10px 12px;margin-bottom:8px;border-radius:18px;
  background:linear-gradient(180deg,#31134F,#260E3F);
  border:1px solid var(--gold-line);
}
.rec-info{display:flex;align-items:center;gap:8px;flex:1 1 auto;min-width:0}
.rec-dot{width:9px;height:9px;border-radius:50%;background:var(--danger);animation:dotPulse 1s infinite;flex:0 0 auto}
.rec-time{font-size:12.5px;color:var(--cream);font-variant-numeric:tabular-nums}
.rec-wave{display:flex;align-items:center;gap:2.5px;height:20px}
.rec-wave i{width:2.5px;border-radius:3px;background:var(--gold-light);height:6px;animation:waveBounce .9s ease-in-out infinite}
.rec-wave i:nth-child(2n){animation-delay:.14s}
.rec-wave i:nth-child(3n){animation-delay:.28s}
.rec-bar audio{height:34px;flex:1 1 100%;min-width:0}

.audio-dock{
  display:flex;align-items:center;gap:10px;flex-wrap:wrap;
  padding:10px 12px;margin-bottom:8px;border-radius:18px;
  background:linear-gradient(180deg,#31134F,#260E3F);
  border:1px solid var(--gold-line);
}
.audio-dock audio{height:36px;flex:1 1 160px;min-width:0}
.audio-dock a{
  font-size:12px;color:var(--gold-light);text-decoration:underline;
  padding:8px 10px;border-radius:10px;border:1px solid var(--gold-line);
}
.audio-dock .dock-x{
  width:32px;height:32px;border-radius:50%;display:grid;place-items:center;
  background:rgba(212,175,55,.1);border:1px solid var(--gold-line);color:var(--gold-light);
}

/* ---------------- الشريط السفلي ---------------- */
.bottom-nav{
  position:relative;z-index:4;flex:0 0 auto;
  display:grid;grid-template-columns:repeat(4,1fr);
  background:linear-gradient(180deg,#260E3F,#1B0A2B);
  border-top:1px solid rgba(212,175,55,.2);
  padding:6px 4px 8px;
}
.nav-btn{
  display:flex;flex-direction:column;align-items:center;gap:3px;
  padding:6px 2px;border-radius:14px;
  color:rgba(200,182,216,.75);font-size:10.5px;font-weight:600;
  transition:color .2s ease,background .2s ease;
  min-height:52px;justify-content:center;
}
.nav-btn svg{width:21px;height:21px}
.nav-btn.active{color:var(--gold-light)}
.nav-btn.active svg{filter:drop-shadow(0 0 6px rgba(212,175,55,.5))}
.nav-btn:active{background:rgba(212,175,55,.08)}

/* ---------------- بطاقات وأدوات ---------------- */
.card{
  background:linear-gradient(180deg,#2E1149,#27103F);
  border:1px solid var(--gold-line);
  border-radius:var(--r-lg);
  padding:16px;
  box-shadow:0 12px 30px rgba(0,0,0,.28),inset 0 1px 0 rgba(255,255,255,.05);
  display:flex;flex-direction:column;gap:12px;
}
.card-head{display:flex;align-items:center;justify-content:space-between;gap:10px}
.card-title{font-family:'Tajawal',sans-serif;font-weight:700;font-size:15.5px;color:var(--cream)}
.pill{
  font-size:10.5px;padding:4px 10px;border-radius:999px;
  background:rgba(212,175,55,.12);border:1px solid var(--gold-line);color:var(--gold-light);
  white-space:nowrap;
}
.divider{height:1px;background:rgba(212,175,55,.16);margin:2px 0}

.tool-grid{display:grid;grid-template-columns:1fr;gap:10px}
.tool-card{
  display:flex;align-items:center;gap:12px;
  padding:13px 14px;border-radius:var(--r-md);
  background:linear-gradient(160deg,#2E1149,#260E3F);
  border:1px solid var(--gold-line);
  text-align:start;
  transition:transform .15s ease,border-color .2s ease;
  min-height:72px;
  box-shadow:0 8px 22px rgba(0,0,0,.22);
}
.tool-card:active{transform:scale(.985);border-color:rgba(212,175,55,.7)}
.tool-icon{
  flex:0 0 auto;width:44px;height:44px;border-radius:14px;
  display:grid;place-items:center;
  background:rgba(212,175,55,.1);border:1px solid var(--gold-line);
  color:var(--gold-light);
}
.tool-icon svg{width:22px;height:22px}
.tool-body{display:flex;flex-direction:column;gap:2px;flex:1 1 auto;min-width:0}
.tool-title{font-family:'Tajawal',sans-serif;font-weight:700;font-size:14.5px;color:var(--cream)}
.tool-desc{font-size:11.5px;line-height:1.6;color:var(--muted)}
.badge{
  flex:0 0 auto;font-size:10px;padding:3px 8px;border-radius:999px;
  background:rgba(200,182,216,.12);border:1px solid rgba(200,182,216,.25);color:var(--muted);
  white-space:nowrap;
}
.badge.on{background:rgba(143,217,174,.14);border-color:rgba(143,217,174,.4);color:#B7EBCB}
.badge.off{background:rgba(228,115,107,.12);border-color:rgba(228,115,107,.38);color:#FFC3BE}

/* الحقول والأزرار */
.field{
  width:100%;padding:12px 14px;border-radius:14px;
  background:rgba(27,10,43,.55);
  border:1px solid rgba(212,175,55,.28);
  color:var(--cream);font-size:15px;line-height:1.5;outline:none;
  transition:border-color .2s ease,box-shadow .2s ease;
}
.field::placeholder{color:rgba(200,182,216,.55)}
.field:focus{border-color:var(--gold);box-shadow:0 0 0 3px rgba(212,175,55,.16)}
select.field{appearance:none;-webkit-appearance:none;background-image:linear-gradient(45deg,transparent 50%,var(--gold-light) 50%),linear-gradient(135deg,var(--gold-light) 50%,transparent 50%);background-position:calc(0% + 14px) calc(50% - 2px),calc(0% + 19px) calc(50% - 2px);background-size:5px 5px,5px 5px;background-repeat:no-repeat;padding-inline-start:34px}

.btn-gold{
  padding:12px 18px;border-radius:14px;font-weight:700;font-size:14px;
  color:#2A1042;background:linear-gradient(160deg,#F3DC9A,#D4AF37 62%,#B8912C);
  border:1px solid rgba(255,255,255,.4);
  box-shadow:0 8px 22px rgba(212,175,55,.25);
  transition:transform .14s ease,opacity .2s ease;
  min-height:46px;
}
.btn-gold:active{transform:scale(.97)}
.btn-gold:disabled{opacity:.5;pointer-events:none}
.btn-outline{
  padding:11px 16px;border-radius:14px;font-weight:600;font-size:13.5px;
  color:var(--gold-light);background:rgba(212,175,55,.06);
  border:1px solid var(--gold-line);
  min-height:44px;transition:background .2s ease;
}
.btn-outline:active{background:rgba(212,175,55,.18)}
.btn-danger{
  padding:12px 16px;border-radius:14px;font-weight:600;font-size:13.5px;
  color:#FFD3CF;background:rgba(228,115,107,.1);
  border:1px solid rgba(228,115,107,.42);
  min-height:46px;
}
.btn-danger:active{background:rgba(228,115,107,.2)}
.wide{width:100%}
.price-tag{font-size:11.5px;font-weight:600;opacity:.85;margin-inline-start:4px}

/* المهام */
.task-form{display:flex;flex-direction:column;gap:8px}
.task-form-row{display:flex;gap:8px}
.task-form-row .field{flex:1 1 auto;min-width:0}
.task-form-row .btn-gold{flex:0 0 auto;padding:12px 20px}
.task-list{display:flex;flex-direction:column;gap:8px}
.task{
  display:flex;align-items:flex-start;gap:10px;
  padding:10px 12px;border-radius:14px;
  background:rgba(27,10,43,.45);border:1px solid rgba(212,175,55,.2);
  animation:msgIn .22s ease-out both;
}
.task.done{opacity:.55}
.task.done .task-title{text-decoration:line-through}
.task-check{
  flex:0 0 auto;width:26px;height:26px;border-radius:8px;margin-top:1px;
  border:1.5px solid var(--gold-line);background:rgba(212,175,55,.06);
  color:var(--gold-light);font-size:13px;font-weight:700;display:grid;place-items:center;
}
.task-main{flex:1 1 auto;min-width:0;display:flex;flex-direction:column;gap:2px}
.task-title{font-size:13.5px;color:var(--cream);line-height:1.5;overflow-wrap:anywhere}
.task-time{font-size:11px;color:var(--muted)}
.task-time.overdue{color:#FFC3BE}
.task-del{
  flex:0 0 auto;width:28px;height:28px;border-radius:50%;
  color:rgba(228,115,107,.9);background:rgba(228,115,107,.1);
  border:1px solid rgba(228,115,107,.3);font-size:12px;display:grid;place-items:center;
}

/* السجل */
.history-tools{display:flex;gap:8px;align-items:center}
.history-tools .field{flex:1 1 auto;min-width:0}
.history-tools .btn-outline{flex:0 0 auto;white-space:nowrap;padding:11px 12px;font-size:12.5px}
.session-list{display:flex;flex-direction:column;gap:9px}
.session-item{
  display:flex;align-items:center;gap:10px;
  padding:12px 14px;border-radius:var(--r-md);
  background:linear-gradient(160deg,#2E1149,#260E3F);
  border:1px solid var(--gold-line);
  transition:border-color .2s ease,transform .15s ease;
}
.session-item:active{transform:scale(.99)}
.session-main{flex:1 1 auto;min-width:0;text-align:start;display:flex;flex-direction:column;gap:3px}
.session-title{
  font-size:14px;font-weight:600;color:var(--cream);
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.session-meta{font-size:11px;color:var(--muted)}
.session-actions{display:flex;gap:6px;flex:0 0 auto}
.icon-mini{
  width:34px;height:34px;border-radius:50%;display:grid;place-items:center;
  background:rgba(212,175,55,.08);border:1px solid var(--gold-line);
  color:var(--gold-light);font-size:13px;
}
.icon-mini.danger{background:rgba(228,115,107,.1);border-color:rgba(228,115,107,.35);color:#FFC3BE}
.empty-state{
  text-align:center;padding:26px 18px;border-radius:var(--r-md);
  border:1px dashed rgba(212,175,55,.3);color:var(--muted);font-size:13px;line-height:1.7;
}

/* الإعدادات */
.setting-row{display:flex;align-items:center;justify-content:space-between;gap:14px}
.setting-text{flex:1 1 auto;min-width:0;display:flex;flex-direction:column;gap:3px}
.switch{
  position:relative;flex:0 0 auto;width:52px;height:30px;border-radius:999px;
  background:rgba(200,182,216,.16);border:1px solid rgba(200,182,216,.3);
  transition:background .22s ease,border-color .22s ease;
}
.switch span{
  position:absolute;top:3px;right:3px;width:22px;height:22px;border-radius:50%;
  background:#C8B6D8;transition:transform .22s cubic-bezier(.3,1.4,.5,1),background .22s ease;
}
.switch[aria-checked="true"]{background:linear-gradient(90deg,#B8912C,#D4AF37);border-color:rgba(243,220,154,.7)}
.switch[aria-checked="true"] span{transform:translateX(-22px);background:#2A1042}
.seg{
  display:flex;flex:0 0 auto;border-radius:12px;overflow:hidden;
  border:1px solid var(--gold-line);background:rgba(27,10,43,.5);
}
.seg button{
  padding:8px 11px;font-size:11.5px;color:var(--muted);font-weight:600;
  transition:background .2s ease,color .2s ease;
}
.seg button.active{background:rgba(212,175,55,.2);color:var(--gold-light)}
.seg button:active{background:rgba(212,175,55,.12)}

.services-body{display:flex;flex-direction:column;gap:8px}
.svc-row{
  display:flex;align-items:center;justify-content:space-between;gap:10px;
  padding:9px 11px;border-radius:12px;background:rgba(27,10,43,.4);
  border:1px solid rgba(212,175,55,.14);font-size:12.5px;
}
.svc-row span:first-child{color:var(--cream)}
.svc-state{font-size:11px;white-space:nowrap;padding:2px 8px;border-radius:999px}
.svc-state.ok{color:#B7EBCB;background:rgba(143,217,174,.12);border:1px solid rgba(143,217,174,.32)}
.svc-state.no{color:#FFC3BE;background:rgba(228,115,107,.1);border:1px solid rgba(228,115,107,.3)}

.rights-card{align-items:center;text-align:center;gap:8px}
.rights-owner{font-size:12px;line-height:1.8;color:var(--muted)}
.rights-copy{font-size:11.5px;letter-spacing:.3px;color:rgba(212,175,55,.85);direction:ltr}

/* ---------------- الطبقات السفلية ---------------- */
.sheet-backdrop{
  position:fixed;inset:0;z-index:65;
  background:rgba(10,3,18,.66);
  backdrop-filter:blur(3px);-webkit-backdrop-filter:blur(3px);
  animation:fadeIn .2s ease both;
}
@keyframes fadeIn{from{opacity:0}to{opacity:1}}
.sheet{
  position:fixed;bottom:0;left:0;right:0;margin-inline:auto;z-index:70;
  width:100%;max-width:560px;max-height:90dvh;
  display:flex;flex-direction:column;
  background:linear-gradient(180deg,#331452,#1E0B33);
  border:1px solid var(--gold-line);border-bottom:none;
  border-radius:26px 26px 0 0;
  box-shadow:0 -22px 60px rgba(0,0,0,.6);
  animation:sheetUp .28s cubic-bezier(.2,.9,.3,1) both;
}
@keyframes sheetUp{from{transform:translateY(28px);opacity:0}to{transform:none;opacity:1}}
.sheet-head{
  display:flex;align-items:center;justify-content:space-between;gap:10px;
  padding:16px 18px 12px;border-bottom:1px solid rgba(212,175,55,.16);
  flex:0 0 auto;
}
.sheet-head h3{font-family:'Tajawal',sans-serif;font-weight:700;font-size:17px;color:var(--cream)}
.close-btn{
  width:36px;height:36px;border-radius:50%;display:grid;place-items:center;
  background:rgba(212,175,55,.08);border:1px solid var(--gold-line);color:var(--gold-light);font-size:14px;
}
.sheet-body{
  padding:16px 18px 24px;display:flex;flex-direction:column;gap:12px;
  overflow-y:auto;overscroll-behavior:contain;flex:1 1 auto;
}
.lang-row{display:flex;align-items:flex-end;gap:8px}
.lang-field{display:flex;flex-direction:column;gap:5px;flex:1 1 0;min-width:0}
.lang-field span{font-size:11.5px;color:var(--muted)}
.swap-btn{
  flex:0 0 auto;width:44px;height:44px;border-radius:50%;
  background:rgba(212,175,55,.1);border:1px solid var(--gold-line);
  color:var(--gold-light);font-size:17px;display:grid;place-items:center;
  transition:transform .2s ease;
}
.swap-btn:active{transform:rotate(180deg) scale(.94)}
.result-box{
  padding:14px;border-radius:var(--r-md);
  background:var(--bubble-salma);color:var(--bubble-salma-text);
  font-size:14px;line-height:1.85;white-space:pre-wrap;overflow-wrap:anywhere;
  border:1px solid rgba(212,175,55,.4);
}
.result-box .sources{margin-top:12px}
.result-box .sources a{color:#5B2E8F}
.result-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:12px}
.result-actions button{
  padding:8px 13px;border-radius:999px;font-size:12px;font-weight:700;
  background:rgba(58,18,89,.1);border:1px solid rgba(58,18,89,.28);color:#3A1259;
  min-height:36px;
}
.result-actions button:active{background:rgba(58,18,89,.2)}
.about-body{align-items:center;text-align:center}
.about-portrait{
  position:relative;width:120px;height:120px;border-radius:50%;overflow:hidden;
  display:grid;place-items:center;background:#3A1259;border:2px solid var(--gold);
  box-shadow:0 0 0 5px rgba(212,175,55,.1),0 14px 30px rgba(0,0,0,.4);
}
.about-portrait img{width:100%;height:100%;object-fit:cover;object-position:center 14%}
.about-portrait .avatar-fallback{font-size:46px}
.about-state{font-size:12.5px;color:var(--gold-light);font-weight:600}
.dialog-msg{font-size:14px;line-height:1.8;color:var(--cream);white-space:pre-wrap}
.dialog-actions{display:flex;gap:10px;margin-top:4px}
.dialog-actions button{flex:1 1 0}

/* ---------------- التوست ---------------- */
.toast{
  position:fixed;bottom:calc(86px);left:50%;transform:translate(-50%,12px);
  z-index:90;max-width:min(90vw,380px);
  padding:11px 18px;border-radius:999px;
  background:rgba(42,16,66,.97);border:1px solid var(--gold-line);
  color:var(--cream);font-size:12.5px;line-height:1.5;text-align:center;
  box-shadow:0 12px 30px rgba(0,0,0,.5);
  opacity:0;pointer-events:none;
  transition:opacity .22s ease,transform .22s ease;
}
.toast.show{opacity:1;transform:translate(-50%,0)}

/* ---------------- استجابة الشاشات ---------------- */
@media (min-width:520px){
  .tool-grid{grid-template-columns:1fr 1fr}
  .bubble{max-width:76%}
  .welcome-sub{font-size:14px}
}
@media (min-width:760px){
  .app{max-width:820px;margin:0 auto;border-inline:1px solid rgba(212,175,55,.14)}
  .hero-orb{width:150px;height:150px}
  .welcome-title{font-size:30px}
  .brand-name{font-size:17px}
}
@media (max-height:640px){
  .hero-orb{width:104px;height:104px}
  .welcome-title{font-size:22px}
  .welcome-sub{display:none}
  .chat-scroll{padding-top:10px}
}
@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{animation-duration:.001ms !important;animation-iteration-count:1 !important;transition-duration:.001ms !important}
}