:root{
  --navy:#0f3a4d; --teal:#157f8f; --teal-d:#0e5f6c; --gold:#c39a3b; --sand:#f6f4ef;
  --ink:#1d2b33; --muted:#6b7a83; --card:#ffffff; --line:#e3e7ea;
}
*{box-sizing:border-box;margin:0;padding:0}
html,body{height:100%}
body{
  font-family:'Cairo',system-ui,'Segoe UI',Tahoma,sans-serif;
  background:var(--sand); color:var(--ink);
}
/* loading */
#gc-loading{min-height:100%;display:flex;align-items:center;justify-content:center;padding:20px}
.gc-loadcard{background:var(--card);border:1px solid var(--line);border-radius:18px;padding:32px 28px;max-width:420px;width:100%;text-align:center;box-shadow:0 8px 30px rgba(15,58,77,.08)}
.gc-loadcard h1{font-size:22px;margin:12px 0 6px;color:var(--navy)}
.gc-loadcard p{color:var(--muted);font-size:14px;margin-bottom:16px}
.gc-logo{display:inline-block;background:linear-gradient(135deg,var(--navy),var(--teal));color:#fff;font-weight:800;letter-spacing:2px;padding:8px 18px;border-radius:12px;border-bottom:3px solid var(--gold);font-size:15px}
.gc-barwrap{height:8px;background:var(--line);border-radius:99px;overflow:hidden}
#gc-bar{height:100%;width:0;background:linear-gradient(90deg,var(--teal),var(--gold));border-radius:99px;transition:width .3s}
/* app layout */
#gc-app{height:100%;display:flex;flex-direction:column;max-width:880px;margin:0 auto}
.gc-header{background:var(--navy);color:#fff;padding:14px 16px 10px;border-radius:0 0 22px 22px;box-shadow:0 4px 18px rgba(15,58,77,.18)}
.gc-headrow{display:flex;justify-content:space-between;align-items:center;gap:10px}
.gc-header h1{font-size:19px;font-weight:800}
.gc-sub{font-size:12.5px;color:#bcd6de;margin-top:2px}
.gc-sub strong{color:var(--gold)}
.gc-header .gc-logo{background:rgba(255,255,255,.1);border-bottom-color:var(--gold);font-size:12px;padding:6px 12px}
#gc-chips{display:flex;gap:6px;overflow-x:auto;padding:10px 2px 4px;scrollbar-width:thin}
.gc-chip{flex:0 0 auto;font-family:inherit;font-size:12px;padding:6px 12px;border-radius:99px;border:1px solid rgba(255,255,255,.28);background:transparent;color:#dcebf0;cursor:pointer;white-space:nowrap}
.gc-chip.on{background:var(--gold);border-color:var(--gold);color:var(--navy);font-weight:700}
/* chat */
#gc-chat{flex:1;overflow-y:auto;padding:16px 12px;display:flex;flex-direction:column;gap:12px}
.gc-msg{display:flex}
.gc-user{justify-content:flex-start}
.gc-bot{justify-content:flex-start}
.gc-bubble{font-family:'Cairo',system-ui,sans-serif;max-width:92%;padding:10px 14px;border-radius:16px;line-height:1.75;font-size:15px;box-shadow:0 1px 4px rgba(15,58,77,.06)}
.gc-user .gc-bubble{background:var(--teal);color:#fff;border-bottom-left-radius:4px;margin-right:auto}
.gc-bot .gc-bubble{background:var(--card);border:1px solid var(--line);border-bottom-right-radius:4px;width:100%}
.gc-intro{font-weight:700;color:var(--teal-d);margin-bottom:8px;font-size:14px}
.gc-notfound{color:var(--muted);font-size:14.5px}
.gc-card{border:1px solid var(--line);border-right:4px solid var(--gold);border-radius:12px;padding:10px 12px;margin:8px 0;background:#fbfaf7}
.gc-passage{font-size:14px;white-space:pre-wrap;word-break:break-word}
.gc-passage.gc-ltr{direction:ltr;text-align:left}
.gc-cite{margin-top:8px;font-size:12px;color:var(--teal-d);font-weight:700;border-top:1px dashed var(--line);padding-top:6px}
.gc-note{font-size:11.5px;color:var(--muted);margin-top:4px}
/* footer */
.gc-footer{background:var(--card);border-top:1px solid var(--line);padding:10px 12px calc(10px + env(safe-area-inset-bottom))}
#gc-form{display:flex;gap:8px}
#gc-input{flex:1;font-family:'Cairo',system-ui,sans-serif;font-size:15px;padding:12px 14px;border:1.5px solid var(--line);border-radius:14px;outline:none}
#gc-input:focus{border-color:var(--teal)}
.gc-send{font-family:inherit;font-weight:700;font-size:15px;background:var(--teal);color:#fff;border:none;border-radius:14px;padding:0 22px;cursor:pointer}
.gc-send:active{background:var(--teal-d)}
.gc-newbtn{font-family:inherit;font-size:12.5px;background:transparent;border:1px solid var(--line);color:var(--muted);border-radius:14px;padding:0 12px;cursor:pointer;white-space:nowrap}
.gc-dbstat{font-size:11px;color:var(--muted);text-align:center;margin-top:7px}
@media (min-width:768px){
  .gc-header h1{font-size:22px}
  #gc-chat{padding:20px 24px}
  .gc-bubble{font-size:15.5px}
}
/* ---- v5 polish ---- */
body{background:linear-gradient(180deg,#e9f1f3 0%,var(--sand) 260px)}
.gc-header{background:linear-gradient(135deg,var(--navy) 0%,#11495e 55%,var(--teal-d) 100%);border-radius:0 0 26px 26px;box-shadow:0 6px 24px rgba(15,58,77,.28)}
.gc-header h1{letter-spacing:.2px}
.gc-chip{transition:background .2s,color .2s,border-color .2s}
.gc-chip:hover{background:rgba(255,255,255,.14)}
#gc-chat{scrollbar-width:thin;scrollbar-color:#b9cdd4 transparent}
#gc-chat::-webkit-scrollbar{width:6px}
#gc-chat::-webkit-scrollbar-thumb{background:#b9cdd4;border-radius:99px}
.gc-msg{animation:gcUp .28s ease both}
@keyframes gcUp{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none}}
.gc-bubble{border-radius:18px;box-shadow:0 2px 10px rgba(15,58,77,.08)}
.gc-user .gc-bubble{background:linear-gradient(135deg,var(--teal),var(--teal-d));border-bottom-left-radius:6px}
.gc-bot .gc-bubble{border-bottom-right-radius:6px}
.gc-card{box-shadow:0 1px 5px rgba(15,58,77,.05);transition:border-color .2s}
.gc-card:hover{border-color:#cfdde2}
.gc-footer{background:rgba(255,255,255,.88);backdrop-filter:blur(8px);box-shadow:0 -4px 18px rgba(15,58,77,.06);border-top:none}
#gc-form{align-items:center}
#gc-input{border-radius:26px;padding:13px 18px;transition:border-color .2s,box-shadow .2s}
#gc-input:focus{border-color:var(--teal);box-shadow:0 0 0 4px rgba(21,127,143,.14)}
.gc-send{border-radius:26px;background:linear-gradient(135deg,var(--teal),var(--teal-d));box-shadow:0 3px 10px rgba(21,127,143,.3);transition:transform .12s,box-shadow .2s}
.gc-send:hover{box-shadow:0 5px 14px rgba(21,127,143,.38)}
.gc-send:active{transform:scale(.96);background:linear-gradient(135deg,var(--teal-d),var(--teal-d))}
#gc-mic{flex:0 0 auto;width:46px;height:46px;border-radius:50%;border:1.5px solid var(--teal);background:#fff;color:var(--teal);cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all .2s}
#gc-mic:hover{background:#eef7f8}
#gc-mic.on{background:var(--gold);border-color:var(--gold);color:var(--navy);animation:gcPulse 1.2s ease-in-out infinite}
@keyframes gcPulse{0%,100%{box-shadow:0 0 0 0 rgba(195,154,59,.45)}50%{box-shadow:0 0 0 9px rgba(195,154,59,0)}}
.gc-voicenote{font-size:11.5px;color:var(--gold);text-align:center;margin-top:5px;min-height:0}
.gc-voicenote:empty{display:none}

/* ---- logo images ---- */
.gc-logoimg{display:block;width:96px;height:96px;border-radius:22px;box-shadow:0 4px 14px rgba(15,58,77,.18)}
.gc-header .gc-logoimg{width:52px;height:52px;border-radius:14px;box-shadow:none}

/* ---- subtitle removed: keep header row centered ---- */
.gc-headrow{align-items:center}

/* ---- desktop frame around the app ---- */
@media (min-width:768px){
  #gc-app{margin:20px auto;height:calc(100% - 40px);border:1.5px solid #d5dfe3;border-radius:26px;overflow:hidden;box-shadow:0 14px 44px rgba(15,58,77,.12);background:var(--sand)}
  .gc-header{border-radius:0}
}

/* ---- mobile UX ---- */
.gc-newbtn{display:flex;align-items:center;gap:6px}
.gc-newbtn svg{display:none}
#gc-chat{overscroll-behavior:contain}
body{-webkit-tap-highlight-color:transparent}
.gc-welcome{background:var(--card);border:1px solid var(--line);border-radius:18px;padding:16px 14px;box-shadow:0 2px 10px rgba(15,58,77,.07);animation:gcUp .3s ease both}
.gc-welcome h2{font-size:16px;color:var(--navy);margin-bottom:6px}
.gc-welcome p{font-size:13.5px;color:var(--muted);line-height:1.8;margin-bottom:10px}
.gc-sugs{display:flex;flex-direction:column;gap:8px}
.gc-sug{font-family:inherit;text-align:right;font-size:13.5px;color:var(--teal-d);background:#f2f8f9;border:1px solid #d7e8eb;border-radius:12px;padding:10px 12px;cursor:pointer;display:flex;align-items:center;gap:8px}
.gc-sug:active{background:#e2f0f2}
.gc-sug::before{content:"؟";flex:0 0 auto;width:22px;height:22px;border-radius:50%;background:var(--teal);color:#fff;font-size:13px;font-weight:700;display:flex;align-items:center;justify-content:center}
@media (max-width:767px){
  .gc-header{padding:10px 14px 6px;border-radius:0 0 20px 20px}
  .gc-header h1{font-size:16.5px}
  .gc-sub{font-size:11.5px}
  .gc-header .gc-logoimg{width:42px;height:42px;border-radius:12px}
  #gc-chips{padding:8px 2px 2px;gap:5px}
  .gc-chip{font-size:11.5px;padding:7px 13px;min-height:32px}
  #gc-chips{scrollbar-width:none}
  #gc-chips::-webkit-scrollbar{display:none}
  #gc-chat{padding:12px 10px;gap:10px}
  .gc-bubble{max-width:94%;font-size:14.5px;padding:10px 12px}
  .gc-passage{font-size:13.5px}
  .gc-footer{padding:8px 10px calc(8px + env(safe-area-inset-bottom))}
  #gc-form{gap:6px}
  #gc-input{font-size:16px;padding:11px 14px}
  .gc-send{padding:0 15px;font-size:14px;min-height:46px}
  #gc-mic{width:44px;height:44px}
  .gc-newbtn{width:44px;height:44px;border-radius:50%;padding:0;justify-content:center;flex:0 0 auto}
  .gc-newbtn span{display:none}
  .gc-newbtn svg{display:block}
}
