:root {
  color-scheme: dark;
  --bg: #111019;
  --bg-elevated: #171522;
  --panel: #1b1828;
  --panel-soft: #211e30;
  --panel-hover: #27233a;
  --line: rgba(255, 255, 255, .08);
  --line-strong: rgba(255, 255, 255, .15);
  --text: #f4f1fb;
  --muted: #aaa4bc;
  --faint: #6f697e;
  --brand: #8b7cff;
  --brand-strong: #9a8cff;
  --brand-soft: rgba(139, 124, 255, .14);
  --success: #62d0a5;
  --warning: #f3b777;
  --shadow: 0 24px 70px rgba(0, 0, 0, .24);
  --sidebar-width: 284px;
  --radius-lg: 24px;
  --radius-md: 15px;
  --radius-sm: 10px;
  --ease: cubic-bezier(.2, .75, .25, 1);
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f7f6fb;
  --bg-elevated: #fff;
  --panel: #fff;
  --panel-soft: #f5f3fb;
  --panel-hover: #eeebf8;
  --line: rgba(39, 31, 70, .09);
  --line-strong: rgba(39, 31, 70, .16);
  --text: #28243a;
  --muted: #706a80;
  --faint: #9b95a7;
  --brand: #6656e8;
  --brand-strong: #5746dc;
  --brand-soft: rgba(102, 86, 232, .11);
  --success: #279971;
  --shadow: 0 24px 70px rgba(62, 44, 117, .12);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; overflow-x: hidden; }
body {
  margin: 0;
  background: radial-gradient(circle at 12% 8%, rgba(139, 124, 255, .12), transparent 28%), radial-gradient(circle at 88% 84%, rgba(98, 208, 165, .07), transparent 24%), var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans Arabic", system-ui, sans-serif;
  transition: background .15s ease, color .15s ease;
}
button, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }
.app-shell { display: flex; width: 100%; min-height: 100vh; overflow: hidden; position: relative; isolation: isolate; }
.app-shell::before { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: .28; background-image: linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px); background-size: 42px 42px; mask-image: linear-gradient(to bottom, #000, transparent 82%); }

.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  padding: 28px 18px 20px;
  background: var(--bg-elevated);
  border-left: 1px solid var(--line);
  position: relative;
  z-index: 5;
}
.sidebar-top, .topbar, .topbar-actions, .conversation-meta, .section-heading, .side-link, .history-item, .privacy-note, .composer-actions, .suggestion-card, .message-head, .message-actions { display: flex; align-items: center; }
.sidebar-top { justify-content: space-between; margin: 0 8px 36px; }
.brand { display: inline-flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; }
.brand-mark, .bot-avatar { display: grid; place-items: center; background: linear-gradient(145deg, var(--brand-strong), #6254da); color: #fff; font-family: "Space Grotesk", sans-serif; font-weight: 700; box-shadow: 0 7px 20px rgba(115, 96, 240, .28); }
.brand-mark { width: 38px; height: 38px; border-radius: 12px; font-size: 18px; }
.brand-copy { display: grid; gap: 1px; }
.brand-copy strong { font-family: "Space Grotesk", "IBM Plex Sans Arabic", sans-serif; letter-spacing: -.02em; font-size: 17px; }
.brand-copy small { color: var(--faint); font-size: 11px; }
.new-chat-button { width: 100%; border: 1px solid var(--line-strong); border-radius: var(--radius-md); background: var(--brand-soft); padding: 13px 14px; color: var(--text); display: flex; align-items: center; gap: 10px; cursor: pointer; transition: .2s var(--ease); }
.new-chat-button:hover { background: rgba(139, 124, 255, .23); transform: translateY(-1px); }
.new-chat-button kbd { margin-right: auto; }
.plus-icon { color: var(--brand-strong); font-size: 20px; line-height: 1; }
kbd { border: 1px solid var(--line-strong); color: var(--faint); padding: 2px 5px; border-radius: 5px; font-size: 10px; direction: ltr; }
.sidebar-section { margin-top: 34px; }
.section-label { margin: 0 10px 10px; color: var(--faint); font-size: 11px; font-weight: 600; letter-spacing: .06em; }
.side-link, .history-item { width: 100%; gap: 11px; background: transparent; border: 0; padding: 10px; border-radius: 11px; color: var(--muted); text-align: right; cursor: pointer; transition: .2s ease; font-size: 13px; }
.side-link:hover, .history-item:hover, .history-item.active { color: var(--text); background: var(--panel-soft); }
.side-link-icon { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; font-size: 14px; font-weight: 600; }
.side-link-icon.purple { color: #b7adff; background: rgba(139, 124, 255, .15); }
.side-link-icon.blue { color: #91c8ff; background: rgba(89, 168, 255, .14); }
.side-link-icon.green { color: #8be4bc; background: rgba(73, 199, 142, .14); }
.side-link-icon.gray { color: var(--muted); background: var(--panel-soft); }
.history-section { flex: 1; }
.section-heading { justify-content: space-between; }
.live-dot, .status-indicator { border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px rgba(98, 208, 165, .1); }
.live-dot { width: 6px; height: 6px; margin: 0 10px 10px; }
.history-item { font-size: 12px; }
.history-dot { width: 6px; height: 6px; background: var(--brand); border-radius: 50%; }
.sidebar-bottom { border-top: 1px solid var(--line); padding-top: 16px; }
.privacy-note { gap: 10px; padding: 12px 8px 14px; color: var(--muted); }
.privacy-note strong, .privacy-note small { display: block; }
.privacy-note strong { font-size: 11px; color: var(--text); margin-bottom: 2px; }
.privacy-note small { font-size: 10px; color: var(--faint); }
.shield-icon { width: 27px; height: 27px; display: grid; place-items: center; color: var(--success); background: rgba(98, 208, 165, .12); border-radius: 9px; }
.identity-card { display: flex; align-items: center; gap: 10px; margin: 0 0 8px; padding: 9px 8px; border: 1px solid var(--line); border-radius: 11px; color: var(--muted); text-decoration: none; transition: .2s ease; }
.identity-card:hover { color: var(--text); background: var(--panel-soft); border-color: var(--line-strong); }
.identity-card strong, .identity-card small { display: block; }
.identity-card strong { font-size: 11px; margin-bottom: 2px; }
.identity-card small { color: var(--faint); font-size: 10px; }
.identity-seal { width: 27px; height: 27px; display: grid; place-items: center; border: 1px solid rgba(98, 208, 165, .5); border-radius: 50%; color: var(--success); font-size: 13px; font-weight: 700; }
.premium-card { margin: 0 0 10px; padding: 13px; border: 1px solid rgba(139, 124, 255, .34); border-radius: 15px; background: linear-gradient(145deg, rgba(139, 124, 255, .16), rgba(98, 208, 165, .06)); box-shadow: 0 12px 30px rgba(36, 27, 77, .12); }
.premium-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; }
.premium-badge { padding: 3px 7px; border-radius: 999px; color: #fff; background: linear-gradient(135deg, var(--brand), #695bd8); font-size: 10px; font-weight: 700; }
.premium-card p { margin: 9px 0 10px; color: var(--muted); font-size: 10px; line-height: 1.6; }
.premium-price { display: flex; align-items: baseline; gap: 5px; margin-bottom: 10px; }
.premium-price strong { font-family: "Space Grotesk", sans-serif; font-size: 22px; }
.premium-price span { color: var(--faint); font-size: 10px; }
.premium-button { width: 100%; border: 0; border-radius: 9px; padding: 8px 10px; color: #fff; background: var(--brand); cursor: pointer; font-size: 11px; font-weight: 700; transition: .2s var(--ease); }
.premium-button:hover:not(:disabled) { background: var(--brand-strong); transform: translateY(-1px); box-shadow: 0 7px 17px rgba(139, 124, 255, .25); }
.premium-button:disabled { opacity: .55; cursor: wait; }

.main-panel { width: 0; min-width: 0; flex: 1 1 0%; display: flex; flex-direction: column; background: radial-gradient(circle at 47% 0%, rgba(114, 95, 234, .08), transparent 31%), var(--bg); }
.topbar { height: 76px; padding: 0 38px; border-bottom: 1px solid var(--line); justify-content: space-between; }
.conversation-meta { gap: 9px; color: var(--faint); font-size: 11px; }
.status-indicator { width: 7px; height: 7px; }
.meta-separator { color: var(--line-strong); }
.topbar-actions { gap: 10px; }
.language-control { display: inline-flex; align-items: center; gap: 6px; color: var(--faint); font-size: 10px; }
.language-control select { max-width: 118px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-soft); color: var(--text); padding: 5px 7px; font: inherit; cursor: pointer; }
.icon-button, .avatar-button { border: 1px solid var(--line); background: transparent; display: grid; place-items: center; cursor: pointer; transition: .2s ease; }
.icon-button { width: 34px; height: 34px; border-radius: 10px; color: var(--muted); font-size: 18px; }
.icon-button:hover { color: var(--text); background: var(--panel-soft); border-color: var(--line-strong); }
.avatar-button { width: 33px; height: 33px; border-radius: 50%; background: var(--panel-soft); border-color: var(--line-strong); font-size: 12px; font-weight: 600; }
.mobile-only { display: none; }

.chat-area { width: min(100%, 900px); flex: 1; min-height: 0; overflow-y: auto; margin: 0 auto; padding: 42px 28px 24px; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.welcome-panel { max-width: 760px; margin: 0 auto; text-align: center; animation: rise .55s var(--ease) both; }
.welcome-orb { width: 88px; height: 88px; margin: 8px auto 20px; position: relative; display: grid; place-items: center; }
.orb-ring { position: absolute; inset: 0; border: 1px solid rgba(139, 124, 255, .32); border-radius: 34% 66% 48% 52% / 53% 38% 62% 47%; animation: morph 8s ease-in-out infinite; }
.ring-two { inset: 8px -4px -5px 5px; border-color: rgba(98, 208, 165, .22); animation-delay: -2s; animation-direction: reverse; }
.orb-core { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 19px 25px 20px 25px; background: linear-gradient(145deg, #998dff, #5d52d1); color: #fff; font-family: "Space Grotesk", sans-serif; font-size: 25px; font-weight: 700; box-shadow: 0 14px 30px rgba(98, 82, 219, .33); transform: rotate(-7deg); }
.eyebrow { color: var(--brand-strong); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; margin: 0 0 9px; font-weight: 600; }
h1 { font-size: clamp(28px, 4vw, 42px); letter-spacing: -.045em; line-height: 1.2; margin: 0; }
h1 span { color: var(--brand-strong); }
.welcome-copy { max-width: 450px; margin: 13px auto 31px; color: var(--muted); line-height: 1.8; font-size: 14px; }
.suggestions-heading { margin: 0 0 12px; color: var(--text); font-size: 16px; line-height: 1.5; }
.suggestion-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; text-align: right; }
.suggestion-card { gap: 11px; min-height: 71px; text-align: right; padding: 13px 14px; border: 1px solid var(--line); border-radius: 14px; background: color-mix(in srgb, var(--panel) 90%, transparent); cursor: pointer; transition: transform .2s var(--ease), border-color .2s ease, background .2s ease; }
.suggestion-card:hover { transform: translateY(-3px); border-color: rgba(139, 124, 255, .42); background: var(--panel-hover); }
.suggestion-card > span:nth-child(2) { min-width: 0; flex: 1; }
.suggestion-card strong, .suggestion-card small { display: block; }
.suggestion-card strong { font-size: 12px; margin-bottom: 3px; }
.suggestion-card small { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggestion-icon { width: 31px; height: 31px; border-radius: 9px; display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.lavender { color: #c1b8ff; background: rgba(139, 124, 255, .16); }
.mint { color: #93e4bf; background: rgba(98, 208, 165, .14); }
.peach { color: #ffc397; background: rgba(243, 183, 119, .15); }
.sky { color: #a1d4ff; background: rgba(112, 183, 255, .15); }
.arrow { color: var(--faint); font-size: 15px; }

.messages-list { display: grid; gap: 25px; max-width: 780px; margin: 0 auto; }
.message { display: flex; gap: 12px; align-items: flex-start; animation: rise .18s var(--ease) both; contain: content; }
.message.user { flex-direction: row-reverse; }
.message.user .message-content { align-items: flex-start; }
.bot-avatar { flex: 0 0 auto; width: 32px; height: 32px; border-radius: 10px; font-size: 13px; }
.user-avatar { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; flex: 0 0 auto; background: var(--panel-soft); border: 1px solid var(--line-strong); color: var(--brand-strong); font-size: 12px; font-weight: 700; }
.message-content { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; max-width: min(78%, 670px); }
.message-head { gap: 9px; margin: 4px 0 7px; }
.message-author { font-size: 11px; color: var(--text); font-weight: 600; }
.message-time { color: var(--faint); font-size: 10px; }
.message-bubble { border: 1px solid var(--line); border-radius: 5px 16px 16px 16px; background: var(--panel); padding: 13px 16px; color: var(--text); line-height: 1.85; font-size: 13px; white-space: pre-wrap; word-break: break-word; box-shadow: 0 10px 25px rgba(0,0,0,.04); }
.message-link { color: var(--brand-strong); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.message-link:hover { color: var(--brand); }
.message.user .message-bubble { border-radius: 16px 5px 16px 16px; color: #fff; border-color: transparent; background: linear-gradient(135deg, var(--brand), #6d60dd); box-shadow: 0 8px 22px rgba(102, 86, 232, .2); }
.message-actions { opacity: 0; gap: 4px; margin-top: 5px; transition: opacity .2s ease; }
.message:hover .message-actions, .message:focus-within .message-actions { opacity: 1; }
.message-action { border: 0; background: transparent; color: var(--faint); font-size: 10px; cursor: pointer; padding: 3px 6px; }
.message-action:hover { color: var(--brand-strong); }
.typing-row { display: flex; align-items: center; gap: 11px; max-width: 780px; margin: 24px auto 0; }
.typing-bubble { display: flex; align-items: center; gap: 4px; padding: 11px 13px; border: 1px solid var(--line); background: var(--panel); border-radius: 5px 15px 15px 15px; }
.typing-bubble span { width: 5px; height: 5px; background: var(--brand); border-radius: 50%; animation: bounce 1s infinite; }
.typing-bubble span:nth-child(2) { animation-delay: .14s; }.typing-bubble span:nth-child(3) { animation-delay: .28s; }
.typing-bubble em { margin-right: 7px; color: var(--faint); font-size: 10px; font-style: normal; }
.hidden { display: none !important; }

.composer-wrap { width: min(100%, 790px); margin: 0 auto; padding: 0 24px 20px; }
.composer-shell { border: 1px solid var(--line-strong); background: var(--panel); border-radius: 18px; padding: 13px 13px 10px 15px; box-shadow: var(--shadow); transition: border .2s ease, box-shadow .2s ease; }
.composer-shell:focus-within { border-color: rgba(139, 124, 255, .62); box-shadow: 0 0 0 4px rgba(139, 124, 255, .09), var(--shadow); }
textarea { width: 100%; min-height: 30px; max-height: 160px; resize: none; overflow-y: auto; border: 0; outline: 0; background: transparent; color: var(--text); line-height: 1.65; padding: 3px 2px 5px; font-size: 13px; }
textarea::placeholder { color: var(--faint); }
.file-row { display: flex; align-items: center; gap: 8px; width: fit-content; max-width: 100%; margin: 2px 0 8px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel-soft); color: var(--muted); font-size: 11px; }
.file-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.file-remove { border: 0; background: transparent; color: var(--faint); cursor: pointer; font-size: 16px; line-height: 1; padding: 0 2px; }
.file-remove:hover { color: var(--text); }
.composer-actions { justify-content: space-between; }
.composer-hint { color: var(--faint); font-size: 10px; }
.attach-button { color: var(--brand-strong); cursor: pointer; font-weight: 600; }
.attach-button:hover { color: var(--brand); text-decoration: underline; }
.voice-button { border: 0; background: transparent; color: var(--brand-strong); cursor: pointer; padding: 0; font-size: 10px; font-weight: 600; }
.voice-button:hover, .voice-button.active { color: #ef879e; }
.hint-divider { padding: 0 5px; color: var(--line-strong); }
.send-button { width: 34px; height: 34px; border: 0; border-radius: 11px; background: var(--brand); color: #fff; font-size: 20px; line-height: 1; cursor: pointer; transition: .2s var(--ease); }
.send-button:not(:disabled):hover { transform: translateY(-2px); background: var(--brand-strong); box-shadow: 0 7px 17px rgba(139, 124, 255, .3); }
.send-button:disabled { opacity: .35; cursor: not-allowed; }
.composer-disclaimer { color: var(--faint); text-align: center; font-size: 10px; margin: 10px 0 0; }
.toast { position: fixed; bottom: 28px; left: 50%; transform: translate(-50%, 15px); background: var(--text); color: var(--bg); border-radius: 10px; padding: 10px 15px; font-size: 12px; opacity: 0; pointer-events: none; transition: .25s var(--ease); z-index: 20; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes rise { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-4px); opacity: 1; } }
@keyframes morph { 0%,100% { transform: rotate(0) scale(1); } 50% { transform: rotate(16deg) scale(1.06); } }

@media (max-width: 800px) {
  :root { --sidebar-width: 285px; }
  .sidebar { position: fixed; top: 0; bottom: 0; right: 0; transform: translateX(105%); transition: transform .25s var(--ease); box-shadow: -20px 0 55px rgba(0,0,0,.22); }
  .sidebar.open { transform: translateX(0); }
  .mobile-only { display: grid; }
  .topbar { padding: 0 17px; }
  .topbar > .mobile-only { margin-left: auto; margin-right: 0; }
  .topbar .conversation-meta { margin-right: auto; margin-left: 12px; }
  .chat-area { padding: 35px 17px 22px; }
  .composer-wrap { padding: 0 15px 17px; }
  .composer-hint { display: none; }
  .suggestion-grid { gap: 8px; }
  .suggestion-card { min-height: 64px; padding: 10px; }
}
@media (max-width: 500px) {
  .topbar { height: 65px; }
  .conversation-meta { font-size: 10px; }
  .conversation-meta .meta-separator, .conversation-meta #message-count { display: none; }
  .welcome-orb { margin-top: 7px; transform: scale(.84); margin-bottom: 8px; }
  h1 { font-size: 29px; }
  .welcome-copy { font-size: 13px; margin-bottom: 24px; }
  .suggestion-grid { grid-template-columns: 1fr; }
  .suggestion-card { min-height: 58px; }
  .message-content { max-width: 84%; }
  .message-bubble { padding: 11px 13px; font-size: 12px; }
  .composer-shell { border-radius: 15px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
