:root {
  --brand: #6E56F8;
  --brand-hover: #5B43EC;
  --brand-soft: #EFEBFF;
  --navy: #17195C;
  --navy-2: #22257A;
  --night: #050507;
  --ink: #16131F;
  --muted: #6B6684;
  --line: #E8E7EF;
  --bot-bg: #F3F3F7;
  --font: "Inter", "Helvetica Neue", Arial, sans-serif;
  --font-ar: "Noto Sans Arabic", "Inter", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--night); color: #fff; font-family: var(--font);
  -webkit-font-smoothing: antialiased; display: flex; flex-direction: column; min-height: 100vh;
}
[dir="rtl"] body, [dir="rtl"] button, [dir="rtl"] input, [dir="rtl"] textarea, [dir="rtl"] select {
  font-family: var(--font-ar);
}
button, input, textarea, select { font: inherit; }
[hidden] { display: none !important; }

.topline { height: 4px; background: linear-gradient(90deg, #3B2BB8, var(--brand), #9B8BFF); }

/* ---------- Nav ---------- */
.nav {
  display: flex; align-items: center; gap: 48px;
  padding: 22px clamp(16px, 2.8vw, 56px); background: #000; position: relative; z-index: 2;
}
.brand { display: flex; align-items: baseline; gap: 10px; color: #fff; text-decoration: none; }
.wordmark { font-weight: 500; font-size: 26px; letter-spacing: .32em; direction: ltr; }
.brand-sub { font-size: 13px; color: #A9A3C9; letter-spacing: .04em; }
.nav-links { display: flex; gap: 36px; font-size: 19px; font-weight: 500; }
.nav-links .active { color: #9C8CFF; }
.nav-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 12px; }
.lang-select { display: flex; align-items: center; gap: 10px; margin-inline-end: 16px; }
.flag {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  background: linear-gradient(90deg, #E2231A 0 28%, transparent 28%),
              linear-gradient(180deg, #00843D 0 33.3%, #fff 33.3% 66.6%, #111 66.6%);
}
.lang-select select {
  background: transparent; color: #fff; border: 0; font-size: 19px; font-weight: 500;
  cursor: pointer; padding: 4px 22px 4px 0; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath d='M1 1l6 6 6-6' stroke='white' stroke-width='2' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right center;
}
[dir="rtl"] .lang-select select { padding: 4px 0 4px 22px; background-position: left center; }
.lang-select option { color: var(--ink); }

/* ---------- Buttons ---------- */
.btn {
  border: 0; border-radius: 6px; padding: 12px 30px; font-size: 18px; font-weight: 500;
  cursor: pointer; transition: background .15s, box-shadow .15s; white-space: nowrap;
}
.btn:focus-visible, .icon-btn:focus-visible, .launcher:focus-visible { outline: 2px solid #B7A9FF; outline-offset: 2px; }
.btn-brand { background: var(--brand); color: #fff; }
.btn-brand:hover { background: var(--brand-hover); box-shadow: 0 6px 24px rgba(110, 86, 248, .35); }
.btn-light { background: #fff; color: var(--brand); }
.btn-light:hover { background: #F1EEFF; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--ink); }
.btn-lg { padding: 15px 36px; font-size: 20px; }
.hero-ctas .btn-light { color: #000; }

/* ---------- Hero ---------- */
.hero {
  flex: 1; position: relative; overflow: hidden;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  grid-template-rows: 1fr auto; column-gap: 40px;
  padding: 56px clamp(16px, 2.8vw, 56px) 48px;
  background:
    radial-gradient(ellipse at 15% 85%, rgba(255,255,255,.05), transparent 45%),
    radial-gradient(ellipse at 90% 30%, rgba(110,86,248,.10), transparent 50%),
    linear-gradient(180deg, #121118 0%, #0E0D14 55%, #08080B 100%);
}
.streaks {
  position: absolute; inset: 0; pointer-events: none; filter: blur(2px);
  background:
    linear-gradient(160deg, transparent 18%, rgba(255,255,255,.07) 19%, transparent 23%),
    linear-gradient(160deg, transparent 52%, rgba(255,255,255,.05) 53%, transparent 56%),
    linear-gradient(20deg, transparent 70%, rgba(255,255,255,.04) 71%, transparent 75%);
}
.hero-copy { position: relative; z-index: 1; align-self: center; }
.hero h1 {
  font-size: clamp(36px, 3.6vw, 62px); line-height: 1.12; font-weight: 600;
  letter-spacing: -.02em; margin: 0 0 30px; max-width: 640px;
}
.lede { font-size: clamp(18px, 1.6vw, 27px); line-height: 1.4; color: #EDEBF5; margin: 0 0 40px; max-width: 620px; letter-spacing: -.01em; }
.hero-ctas { display: flex; gap: 12px; flex-wrap: wrap; }
.stats { position: relative; z-index: 1; grid-row: 2; margin: 40px 0 0; font-size: 16px; }
.stats .dot { margin: 0 8px; }
[dir="rtl"] .hero h1, [dir="rtl"] .lede { letter-spacing: 0; line-height: 1.5; }

/* ---------- Decorative dashboard ---------- */
.device {
  grid-column: 2; grid-row: 1 / span 2; align-self: end; position: relative; z-index: 1;
  padding: 14px; border-radius: 34px; margin-bottom: -90px;
  background: linear-gradient(145deg, #3A3A42, #0B0B0E 40%, #26262C);
  box-shadow: 0 0 0 2px #55555E inset, 0 40px 80px rgba(0,0,0,.6);
  transform: perspective(1800px) rotateY(-8deg) rotateZ(-2deg);
}
[dir="rtl"] .device { transform: perspective(1800px) rotateY(8deg) rotateZ(2deg); }
.screen { display: flex; border-radius: 22px; overflow: hidden; background: #F7F6FB; color: var(--ink); height: 560px; direction: ltr; }
.rail { width: 86px; flex: none; background: linear-gradient(180deg, #1B1745, #2A2470); display: flex; flex-direction: column; align-items: center; gap: 13px; padding: 18px 0; }
.rail-logo { color: #fff; font-size: 10px; letter-spacing: .25em; font-weight: 600; margin-bottom: 14px; }
.rail-item { width: 46px; height: 7px; border-radius: 4px; background: rgba(255,255,255,.18); }
.rail-item.on { background: rgba(255,255,255,.75); }
.dash { flex: 1; min-width: 0; padding: 18px 22px; display: flex; flex-direction: column; gap: 14px; font-size: 11px; }
.dash-title { font-size: 18px; font-weight: 600; }
.dash-banner { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; display: flex; flex-direction: column; gap: 2px; }
.dash-banner b { font-size: 13px; } .dash-banner span { color: var(--muted); }
.wallets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.wallet { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.wallet small { color: var(--muted); font-size: 9px; } .wallet b { font-size: 14px; } .wallet i { color: var(--brand); font-style: normal; font-size: 9px; }
.panels { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; flex: 1; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto 1fr; gap: 10px 14px; align-items: center; }
.panel b { grid-column: 1 / -1; font-size: 12px; }
.panel ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; color: var(--muted); font-size: 10px; }
.panel li::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 2px; background: #6E56F8; margin-inline-end: 6px; }
.panel li + li::before { background: #CFC6FF; }
.donut { width: 74px; height: 74px; border-radius: 50%; position: relative; }
.donut::after { content: ""; position: absolute; inset: 13px; border-radius: 50%; background: #fff; }
.d1 { background: conic-gradient(#6E56F8 0 47%, #CFC6FF 47% 55%, #E8E5F7 55%); }
.d2 { background: conic-gradient(#6E56F8 0 16%, #E8E5F7 16%); }
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.metrics div { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.metrics small { color: var(--muted); } .metrics b { font-size: 16px; }

/* ---------- Chat widget ---------- */
.widget {
  position: fixed; z-index: 50; bottom: 112px; inset-inline-end: 28px;
  width: 460px; height: min(760px, calc(100vh - 140px));
  background: #fff; color: var(--ink); border-radius: 26px;
  box-shadow: 0 24px 70px rgba(0,0,0,.45), 0 2px 8px rgba(0,0,0,.2);
  display: flex; flex-direction: column; overflow: hidden;
  transform-origin: bottom right; animation: pop .22s ease-out;
}
[dir="rtl"] .widget { transform-origin: bottom left; }
.widget { transition: width .25s ease, height .25s ease; }
/* Expanded: most of the screen, still anchored above the launcher. */
.widget.expanded { width: min(1000px, calc(100vw - 56px)); height: calc(100vh - 140px); }
.widget.expanded .messages { padding-inline: max(24px, calc((100% - 760px) / 2)); }
.widget.expanded .composer { margin-inline: max(16px, calc((100% - 760px) / 2)); }
.widget.expanded .bubble { max-width: 78%; }
#w-expand .ic-shrink, #w-expand[aria-pressed="true"] .ic-grow { display: none; }
#w-expand[aria-pressed="true"] .ic-shrink { display: block; }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }

.w-head {
  display: flex; align-items: center; gap: 10px; padding: 16px 14px 14px;
  border-bottom: 1px solid var(--line); background: #fff; position: relative;
}
.icon-btn {
  width: 36px; height: 36px; flex: none; border: 0; border-radius: 10px; background: transparent;
  color: #3A3850; display: grid; place-items: center; cursor: pointer;
}
.icon-btn:hover { background: #F2F1F7; }
[dir="rtl"] #w-new svg { transform: scaleX(-1); }
.w-logo {
  width: 46px; height: 46px; flex: none; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--navy-2), var(--navy));
}
.w-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.w-title strong { font-size: 19px; font-weight: 600; letter-spacing: -.01em; }
.w-title span { font-size: 15px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-menu-wrap { position: relative; }
.w-menu {
  position: absolute; top: 42px; inset-inline-end: 0; z-index: 5; min-width: 190px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 6px;
  box-shadow: 0 12px 32px rgba(22,19,31,.16); display: flex; flex-direction: column;
}
.w-menu button {
  border: 0; background: transparent; text-align: start; padding: 10px 12px; border-radius: 8px;
  font-size: 14px; color: var(--ink); cursor: pointer;
}
.w-menu button:hover { background: #F2F1F7; }

.messages { flex: 1; overflow-y: auto; padding: 18px 24px 12px; display: flex; flex-direction: column; gap: 8px; }
.messages::-webkit-scrollbar { width: 6px; } .messages::-webkit-scrollbar-thumb { background: #D9D8E2; border-radius: 3px; }
.day { align-self: center; font-size: 15px; color: var(--muted); margin: 14px 0 10px; }

.msg { display: flex; align-items: flex-end; gap: 8px; max-width: 100%; }
.msg.user { justify-content: flex-end; }
.msg + .msg.bot, .msg.bot + .msg.user { margin-top: 8px; }
.avatar {
  width: 28px; height: 28px; flex: none; border-radius: 8px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--navy-2), var(--navy));
}
.bubble { border-radius: 22px; padding: 12px 18px; font-size: 16px; line-height: 1.55; max-width: 84%; overflow-wrap: anywhere; }
.msg.user .bubble { background: var(--navy); color: #fff; white-space: pre-wrap; padding: 14px 22px; }
.msg.bot .bubble { background: var(--bot-bg); border-end-start-radius: 6px; max-width: calc(100% - 36px); }
.bubble p { margin: 0 0 8px; } .bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 4px 0 8px; padding-inline-start: 20px; }
.bubble a { color: var(--brand-hover); font-weight: 500; }
.bubble table { border-collapse: collapse; margin: 8px 0; font-size: 13px; display: block; overflow-x: auto; background: #fff; border-radius: 8px; }
.bubble th, .bubble td { border: 1px solid var(--line); padding: 6px 9px; text-align: start; }
.bubble th { background: #FAFAFD; }
.bubble code { background: #fff; border-radius: 4px; padding: 1px 5px; font-size: 13px; }
.bubble.error { background: #FFF1F1; color: #8A1C1C; }

.chips { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; margin: 6px 0 4px; }
.chip {
  border: 1.5px solid var(--navy); background: #fff; color: var(--navy); border-radius: 999px;
  padding: 9px 16px; font-size: 14px; font-weight: 500; cursor: pointer; text-align: start; max-width: 90%;
  transition: background .15s, color .15s;
}
.chip:hover { background: var(--navy); color: #fff; }

.meta { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.cache-badge { align-self: flex-start; font-size: 12px; font-weight: 600; color: #0F7A4A; background: #E2F5EA; padding: 3px 10px; border-radius: 999px; }
details.step { border: 1px solid var(--line); border-radius: 10px; background: #fff; font-size: 13px; }
details.step summary { cursor: pointer; padding: 7px 12px; color: var(--navy); font-weight: 600; list-style: none; }
details.step summary::-webkit-details-marker { display: none; }
details.step summary::before { content: "▸"; display: inline-block; margin-inline-end: 6px; transition: transform .15s; }
[dir="rtl"] details.step summary::before { content: "◂"; }
details.step[open] summary::before { transform: rotate(90deg); }
[dir="rtl"] details.step[open] summary::before { transform: rotate(-90deg); }
.step-body { padding: 4px 12px 10px; color: var(--muted); }
.src { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-top: 1px dashed var(--line); }
.src a { color: var(--brand-hover); text-decoration: none; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.src span { flex: none; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; }
.kv dt { font-weight: 600; color: var(--ink); } .kv dd { margin: 0; }

.typing-row { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 15px; align-self: center; margin: 10px 0; }
.typing { display: inline-flex; gap: 4px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--navy); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.composer {
  margin: 8px 16px 6px; padding: 14px 14px 10px 22px; border: 1px solid var(--line);
  border-radius: 18px; background: #fff; box-shadow: 0 2px 10px rgba(22,19,31,.05);
}
[dir="rtl"] .composer { padding: 14px 22px 10px 14px; }
.composer:focus-within { border-color: #C7C5DA; box-shadow: 0 2px 14px rgba(22,19,31,.10); }
.composer textarea {
  width: 100%; border: 0; outline: 0; resize: none; background: transparent; color: var(--ink);
  font-size: 17px; line-height: 1.5; padding: 0; max-height: 130px;
}
.composer textarea::placeholder { color: #6E6C80; }
.composer-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.hint { font-size: 12px; font-weight: 600; color: var(--navy); background: #EEEEF8; padding: 3px 10px; border-radius: 999px; }
.send {
  width: 46px; height: 46px; flex: none; border: 0; border-radius: 50%; cursor: pointer;
  background: var(--navy); color: #fff; display: grid; place-items: center; transition: background .15s;
}
.send:disabled { background: #EDEDF2; color: #B4B3C2; cursor: default; }
.footnote { text-align: center; font-size: 11px; color: var(--muted); margin: 0 20px 10px; }

.launcher {
  position: fixed; z-index: 51; bottom: 24px; inset-inline-end: 28px;
  width: 72px; height: 72px; border-radius: 50%; border: 0; cursor: pointer;
  background: linear-gradient(135deg, var(--navy-2), var(--navy));
  box-shadow: 0 10px 30px rgba(0,0,0,.45); display: grid; place-items: center;
  transition: transform .15s;
}
.launcher:hover { transform: scale(1.05); }
.launcher svg { grid-area: 1 / 1; transition: opacity .15s, transform .2s; }
.launcher .ic-close { opacity: 0; transform: rotate(-90deg); }
.launcher[aria-expanded="true"] .ic-open { opacity: 0; transform: rotate(90deg); }
.launcher[aria-expanded="true"] .ic-close { opacity: 1; transform: none; }

/* ---------- Login dialog ---------- */
dialog.login { border: 0; border-radius: 18px; padding: 28px; width: min(420px, calc(100vw - 32px)); color: var(--ink); box-shadow: 0 30px 80px rgba(0,0,0,.5); }
dialog.login::backdrop { background: rgba(5,5,7,.7); backdrop-filter: blur(3px); }
.login h3 { margin: 0 0 6px; font-size: 22px; }
.login .muted { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
.login label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 14px; }
.login input { display: block; width: 100%; margin-top: 6px; padding: 11px 12px; border-radius: 8px; border: 1px solid var(--line); font-size: 15px; color: var(--ink); }
.login input:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(110,86,248,.15); }
.login .btn { font-size: 16px; padding: 10px 22px; }
.login-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; }
.error { color: #B42318; font-size: 13px; margin: 0 0 10px; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .nav-links { display: none; }
  .hero { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; padding-bottom: 0; }
  .stats { grid-row: auto; }
  .device { grid-column: 1; grid-row: auto; margin: 48px 0 -60px; }
}
@media (max-width: 640px) {
  .nav { gap: 12px; padding-block: 14px; flex-wrap: wrap; }
  .nav-actions { gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
  .wordmark { font-size: 20px; }
  .brand-sub, .flag, #nav-chat { display: none; }
  .lang-select { margin-inline-end: 4px; }
  .lang-select select { font-size: 15px; }
  .nav .btn { padding: 8px 14px; font-size: 15px; }
  .hero { padding: 28px 16px 0; }
  .lede { margin-bottom: 24px; }
  .btn-lg { padding: 12px 22px; font-size: 17px; }
  .device { display: none; }
  .stats { margin-bottom: 120px; }
  /* Widget takes the whole screen on phones. */
  .widget, .widget.expanded { inset: 0; width: auto; height: auto; border-radius: 0; animation: none; }
  #w-expand { display: none; } /* already full screen */
  .launcher { width: 60px; height: 60px; bottom: 16px; inset-inline-end: 16px; }
  .launcher[aria-expanded="true"] { display: none; }
  .messages { padding: 14px 16px 10px; }
  .composer { margin: 6px 12px; }
}
