:root{
  --bg:#050608;
  --bg2:#0a0c10;
  --bg3:#101317;
  --sidebar:#0b0e13;
  --panel:#0d1117;
  --panel2:#121821;
  --panel3:#171d27;
  --text:#f8fafc;
  --muted:#8d97a7;
  --stroke:rgba(255,255,255,.08);
  --stroke2:rgba(255,255,255,.12);
  --shadow:0 22px 60px rgba(0,0,0,.45);

  --accent:#22c55e;
  --accent2:#16a34a;
  --accentSoft:rgba(34,197,94,.14);

  --danger:#ef4444;
  --warn:#f59e0b;

  --r12:12px;
  --r14:14px;
  --r16:16px;
  --r18:18px;
  --r20:20px;
  --r24:24px;

  --sidebar-w:320px;
}

body.theme-delivery{
  --accent:#22c55e;
  --accent2:#16a34a;
  --accentSoft:rgba(34,197,94,.14);
}

body.theme-green{
  --accent:#10b981;
  --accent2:#059669;
  --accentSoft:rgba(16,185,129,.14);
}

body.theme-blue{
  --accent:#3b82f6;
  --accent2:#2563eb;
  --accentSoft:rgba(59,130,246,.14);
}

*{
  box-sizing:border-box;
}

html,body{
  margin:0;
  padding:0;
  min-height:100%;
  background:
    radial-gradient(circle at top, #11151a 0%, #090b0f 40%, #030405 100%);
  color:var(--text);
  font-family:Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,input,textarea,select{
  font:inherit;
}

a{
  color:inherit;
  text-decoration:none;
}

.hidden{
  display:none !important;
}

/* intro */
.intro-overlay{
  position:fixed;
  inset:0;
  z-index:9999;
  overflow:hidden;
  background:
    radial-gradient(circle at top, #13181f 0%, #0b0e13 45%, #040506 100%);
  display:flex;
  align-items:center;
  justify-content:center;
}

.intro-overlay.hide{
  animation:introFadeOut .65s ease forwards;
}

.intro-center{
  position:relative;
  z-index:2;
  text-align:center;
}

.intro-title{
  font-size:clamp(2rem, 3vw, 3.2rem);
  font-weight:900;
  letter-spacing:.4px;
}

.intro-sub{
  margin-top:10px;
  color:var(--muted);
  font-size:1rem;
}

.fall-logo{
  position:absolute;
  top:-120px;
  min-width:92px;
  height:42px;
  padding:0 14px;
  border-radius:999px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight:900;
  color:#fff;
  box-shadow:0 12px 30px rgba(0,0,0,.35);
  animation:fallDown 1.7s linear forwards;
  opacity:.95;
}

.logo-uber{ left:12%; background:#111827; animation-delay:.05s; }
.logo-glovo{ left:28%; background:#facc15; color:#111827; animation-delay:.22s; }
.logo-stuart{ left:67%; background:#ef4444; animation-delay:.4s; }
.logo-wolt{ left:83%; background:#38bdf8; animation-delay:.58s; }

.delay-2{ left:20%; animation-delay:.8s; }
.delay-3{ left:40%; animation-delay:1s; }
.delay-4{ left:58%; animation-delay:1.15s; }
.delay-5{ left:76%; animation-delay:1.28s; }

@keyframes fallDown{
  0%{
    transform:translateY(-120px) rotate(-8deg);
    opacity:0;
  }
  12%{
    opacity:1;
  }
  100%{
    transform:translateY(calc(100vh + 100px)) rotate(9deg);
    opacity:.92;
  }
}

@keyframes introFadeOut{
  to{
    opacity:0;
    visibility:hidden;
  }
}

/* layout */
.app-shell{
  display:grid;
  grid-template-columns:var(--sidebar-w) 1fr;
  min-height:100vh;
}

.sidebar{
  border-right:1px solid var(--stroke);
  background:rgba(10,12,16,.88);
  backdrop-filter:blur(18px);
  -webkit-backdrop-filter:blur(18px);
  padding:18px 14px;
  display:flex;
  flex-direction:column;
  gap:16px;
  overflow:auto;
}

.sidebar-top{
  display:flex;
  flex-direction:column;
  gap:12px;
}

.brand-box{
  display:flex;
  gap:12px;
  align-items:flex-start;
  padding:12px;
  border-radius:18px;
  background:rgba(255,255,255,.03);
  border:1px solid var(--stroke);
}

.brand-dot{
  width:14px;
  height:14px;
  border-radius:999px;
  background:linear-gradient(135deg,var(--accent),var(--accent2));
  margin-top:5px;
  box-shadow:0 0 0 5px var(--accentSoft);
}

.brand-title{
  font-weight:900;
  font-size:1rem;
}

.brand-sub{
  color:var(--muted);
  margin-top:4px;
  font-size:.9rem;
  line-height:1.4;
}

.sidebar-actions{
  display:grid;
  gap:10px;
}

.sidebar-btn{
  min-height:46px;
  border-radius:16px;
  border:1px solid var(--stroke);
  background:rgba(255,255,255,.04);
  color:var(--text);
  font-weight:800;
  cursor:pointer;
  transition:.18s ease;
}

.sidebar-btn:hover{
  transform:translateY(-1px);
  border-color:var(--stroke2);
  background:rgba(255,255,255,.07);
}

.sidebar-btn.primary{
  background:linear-gradient(135deg,var(--accent),var(--accent2));
  border:none;
  color:#fff;
}

.home-btn{
  text-decoration:none;
  display:flex;
  align-items:center;
  justify-content:center;
}

.sidebar-section{
  display:flex;
  flex-direction:column;
  gap:10px;
}

.sidebar-heading{
  font-size:.82rem;
  text-transform:uppercase;
  letter-spacing:.1em;
  color:#8e99aa;
  padding:0 4px;
  font-weight:800;
}

.conversation-list{
  display:flex;
  flex-direction:column;
  gap:10px;
}

.conversation-item{
  width:100%;
  text-align:left;
  border:1px solid var(--stroke);
  background:rgba(255,255,255,.04);
  color:var(--text);
  border-radius:18px;
  padding:12px;
  cursor:pointer;
  transition:.18s ease;
}

.conversation-item:hover{
  background:rgba(255,255,255,.07);
  border-color:var(--stroke2);
}

.conversation-item.active-thread{
  border-color:rgba(34,197,94,.28);
  background:rgba(34,197,94,.08);
}

.conversation-title{
  font-weight:800;
  line-height:1.35;
  margin-bottom:6px;
}

.conversation-date{
  color:var(--muted);
  font-size:.83rem;
}

.conversation-actions{
  margin-top:10px;
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}

.mini-link{
  font-size:.84rem;
  color:#d7dde7;
}

.danger-link{
  color:#fca5a5;
}

.sidebar-empty{
  color:var(--muted);
  font-size:.94rem;
  padding:8px 4px;
}

.sidebar-empty.error{
  color:#fecaca;
}

/* chat */
.chat-area{
  display:flex;
  flex-direction:column;
  min-width:0;
  min-height:100vh;
  background:linear-gradient(180deg, rgba(9,11,15,.88), rgba(7,9,12,.96));
}

.chat-header{
  padding:22px 28px 12px;
  border-bottom:1px solid rgba(255,255,255,.04);
}

.chat-header h1{
  margin:0;
  font-size:clamp(1.45rem, 2vw, 2rem);
}

.header-sub{
  margin-top:8px;
  color:var(--muted);
  max-width:860px;
  line-height:1.55;
}

.chat-messages{
  flex:1;
  overflow:auto;
  padding:22px 28px 170px;
  display:flex;
  flex-direction:column;
  gap:18px;
}

.message{
  display:flex;
  gap:12px;
  align-items:flex-start;
  max-width:960px;
  width:100%;
}

.message.user{
  margin-left:auto;
  flex-direction:row-reverse;
}

.avatar{
  flex:0 0 auto;
  width:38px;
  height:38px;
  border-radius:999px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight:900;
  font-size:.88rem;
}

.assistant-avatar{
  background:linear-gradient(135deg,var(--accent),var(--accent2));
  color:#fff;
}

.user-avatar{
  background:#1f2937;
  color:#fff;
}

.bubble{
  max-width:min(860px, 100%);
  border-radius:20px;
  padding:14px 16px;
  border:1px solid var(--stroke);
  box-shadow:var(--shadow);
}

.assistant-bubble{
  background:linear-gradient(180deg, rgba(15,18,23,.98), rgba(17,22,29,.96));
}

.user-bubble{
  background:linear-gradient(180deg, rgba(18,70,42,.96), rgba(18,86,45,.92));
  border-color:rgba(34,197,94,.18);
}

.bubble-label{
  font-size:.8rem;
  color:#a7b4c8;
  margin-bottom:8px;
  font-weight:800;
}

.bubble-content{
  line-height:1.72;
  word-break:break-word;
}

.bubble-content strong{
  color:#fff;
}

.clarify-panel{
  margin-top:14px;
  padding:14px;
  border-radius:18px;
  border:1px solid var(--stroke);
  background:rgba(255,255,255,.035);
}

.clarify-title{
  font-size:.9rem;
  font-weight:800;
  color:#d9e2ef;
  margin-bottom:10px;
}

.clarify-buttons{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
}

.clarify-btn{
  min-height:42px;
  padding:10px 14px;
  border-radius:14px;
  border:1px solid var(--stroke);
  background:rgba(255,255,255,.05);
  color:var(--text);
  font-weight:800;
  cursor:pointer;
  transition:.16s ease;
}

.clarify-btn:hover{
  transform:translateY(-1px);
  border-color:var(--stroke2);
  background:rgba(255,255,255,.09);
}

.bubble-article-wrap{
  margin-top:16px;
  padding-top:14px;
  border-top:1px solid rgba(255,255,255,.08);
}

.bubble-article-label{
  font-size:.82rem;
  font-weight:800;
  color:var(--muted);
  margin-bottom:10px;
  text-transform:uppercase;
  letter-spacing:.08em;
}

.bubble-article-box{
  display:flex;
  flex-direction:column;
  gap:12px;
}

/* article card inside chat */
.ai-article-card{
  display:grid;
  grid-template-columns:280px 1fr;
  gap:0;
  margin-top:12px;
  border:1px solid var(--stroke);
  border-radius:24px;
  overflow:hidden;
  background:linear-gradient(180deg, rgba(18,22,29,.98), rgba(14,18,23,.98));
  box-shadow:0 18px 40px rgba(0,0,0,.28);
}

.ai-article-card:hover{
  border-color:var(--stroke2);
  transform:translateY(-1px);
}

.ai-article-media{
  min-height:190px;
  background:#0f1115;
}

.ai-article-media img{
  display:block;
  width:100%;
  height:100%;
  object-fit:cover;
}

.ai-article-content{
  padding:20px 20px 18px;
  display:flex;
  flex-direction:column;
  justify-content:center;
}

.ai-article-title{
  font-size:1.05rem;
  font-weight:900;
  line-height:1.35;
  margin-bottom:10px;
}

.ai-article-excerpt{
  color:var(--muted);
  line-height:1.6;
  margin-bottom:14px;
}

.ai-article-link{
  color:#dbeafe;
  font-weight:800;
}

.ai-article-card.no-image{
  grid-template-columns:1fr;
}

.ai-article-card.no-image .ai-article-media{
  display:none;
}

/* composer */
.composer-wrap{
  position:fixed;
  left:calc(var(--sidebar-w) + 24px);
  right:24px;
  bottom:18px;
  z-index:40;
}

.composer{
  max-width:980px;
  margin:0 auto;
  border:1px solid var(--stroke);
  background:rgba(10,12,16,.92);
  backdrop-filter:blur(18px);
  -webkit-backdrop-filter:blur(18px);
  border-radius:26px;
  padding:12px 12px 12px 16px;
  box-shadow:0 18px 60px rgba(0,0,0,.35);
}

.composer-input{
  width:100%;
  border:none;
  outline:none;
  resize:none;
  background:transparent;
  color:var(--text);
  min-height:28px;
  max-height:180px;
  line-height:1.6;
  font-size:1rem;
  padding:4px 0;
}

.composer-input::placeholder{
  color:#8390a1;
}

.composer-actions{
  display:flex;
  justify-content:flex-end;
  align-items:center;
  gap:10px;
  margin-top:10px;
}

.icon-btn{
  width:42px;
  height:42px;
  border-radius:999px;
  border:1px solid var(--stroke);
  background:rgba(255,255,255,.05);
  color:var(--text);
  cursor:pointer;
  font-size:1.15rem;
}

.icon-btn:hover{
  background:rgba(255,255,255,.1);
}

.send-btn{
  min-height:42px;
  padding:0 18px;
  border:none;
  border-radius:999px;
  background:linear-gradient(135deg,var(--accent),var(--accent2));
  color:#fff;
  font-weight:900;
  cursor:pointer;
}

.send-btn:disabled{
  opacity:.65;
  cursor:not-allowed;
}

/* thinking */
.thinking{
  display:flex;
  align-items:center;
  gap:8px;
  min-height:18px;
}

.thinking span{
  width:8px;
  height:8px;
  border-radius:999px;
  background:#cbd5e1;
  animation:blinkDot 1.2s infinite ease-in-out;
}

.thinking span:nth-child(2){
  animation-delay:.15s;
}
.thinking span:nth-child(3){
  animation-delay:.3s;
}

@keyframes blinkDot{
  0%, 80%, 100%{
    opacity:.3;
    transform:translateY(0);
  }
  40%{
    opacity:1;
    transform:translateY(-3px);
  }
}

/* modal */
.modal-backdrop{
  position:fixed;
  inset:0;
  z-index:300;
  background:rgba(2,6,23,.74);
  backdrop-filter:blur(10px);
  -webkit-backdrop-filter:blur(10px);
  display:flex;
  align-items:center;
  justify-content:center;
  padding:18px;
}

.modal-card{
  width:min(100%, 520px);
  border-radius:24px;
  border:1px solid var(--stroke);
  background:linear-gradient(180deg, rgba(15,18,23,.99), rgba(17,22,29,.99));
  box-shadow:0 26px 70px rgba(0,0,0,.45);
}

.modal-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:20px 20px 10px;
}

.modal-head h2{
  margin:0;
  font-size:1.2rem;
}

.modal-close{
  width:38px;
  height:38px;
  border-radius:999px;
  border:1px solid var(--stroke);
  background:rgba(255,255,255,.05);
  color:#fff;
  cursor:pointer;
  font-size:1.4rem;
}

.modal-body{
  padding:10px 20px 20px;
}

.memory-toggle{
  display:flex;
  align-items:flex-start;
  gap:10px;
  margin-bottom:16px;
  color:var(--text);
}

.memory-toggle input{
  width:18px;
  height:18px;
  accent-color:var(--accent);
  margin-top:3px;
}

.modal-label{
  display:block;
  margin:12px 0 8px;
  font-weight:800;
  font-size:.95rem;
}

.modal-input{
  width:100%;
  min-height:48px;
  border-radius:16px;
  border:1px solid var(--stroke);
  background:rgba(255,255,255,.04);
  color:var(--text);
  padding:12px 14px;
  outline:none;
}

.modal-input:focus{
  border-color:rgba(255,255,255,.22);
  box-shadow:0 0 0 4px var(--accentSoft);
}

.modal-save{
  width:100%;
  min-height:48px;
  margin-top:18px;
  border:none;
  border-radius:16px;
  background:linear-gradient(135deg,var(--accent),var(--accent2));
  color:#fff;
  font-weight:900;
  cursor:pointer;
}

/* responsive */
@media (max-width: 980px){
  :root{
    --sidebar-w:270px;
  }

  .ai-article-card{
    grid-template-columns:220px 1fr;
  }
}

@media (max-width: 860px){
  .app-shell{
    grid-template-columns:1fr;
  }

  .sidebar{
    min-height:auto;
    max-height:46vh;
    border-right:none;
    border-bottom:1px solid var(--stroke);
  }

  .composer-wrap{
    left:12px;
    right:12px;
    bottom:12px;
  }

  .chat-messages{
    padding:18px 14px 170px;
  }

  .chat-header{
    padding:18px 14px 12px;
  }

  .ai-article-card{
    grid-template-columns:1fr;
  }

  .ai-article-media{
    min-height:180px;
  }
}

@media (max-width: 640px){
  .conversation-actions{
    flex-direction:column;
    align-items:flex-start;
    gap:6px;
  }

  .message,
  .message.user{
    max-width:100%;
  }

  .bubble{
    max-width:100%;
  }

  .fall-logo{
    min-width:74px;
    height:36px;
    font-size:.86rem;
  }

  .ai-article-content{
    padding:16px;
  }

  .clarify-buttons{
    flex-direction:column;
  }

  .clarify-btn{
    width:100%;
  }
}
.message.user.message-option-pick .user-bubble{
  background:linear-gradient(180deg, rgba(37,99,235,.95), rgba(29,78,216,.9));
  border-color:rgba(96,165,250,.35);
  box-shadow:0 12px 34px rgba(37,99,235,.18);
}

.message.user.message-option-pick .bubble-label{
  color:#bfdbfe;
}

.message.user.message-option-pick .bubble-content{
  display:flex;
  align-items:center;
  gap:8px;
}

.message.user.message-option-pick .bubble-content::before{
  content:"✓";
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:20px;
  height:20px;
  border-radius:999px;
  background:rgba(255,255,255,.18);
  color:#fff;
  font-size:.78rem;
  font-weight:900;
  flex:0 0 auto;
}