:root {
  color-scheme: dark;
  --space: #030916;
  --panel: rgba(8, 22, 46, .94);
  --panel-2: rgba(12, 32, 62, .92);
  --ink: #ecf8ff;
  --muted: #9fb6ca;
  --line: rgba(117, 205, 255, .2);
  --cyan: #62ddff;
  --cyan-2: #16a7e8;
  --violet: #9c7cff;
  --gold: #ffd36b;
  --green: #6df5b1;
  --danger: #ff9e99;
  --shadow: 0 28px 90px rgba(0, 5, 20, .58);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-family: "Nirmala UI", "Shruti", "Segoe UI", system-ui, sans-serif;
  background:
    radial-gradient(circle at 14% 8%, rgba(49, 102, 230, .25), transparent 28rem),
    radial-gradient(circle at 88% 90%, rgba(117, 61, 203, .2), transparent 32rem),
    linear-gradient(145deg, #020611 0%, #06152a 52%, #030916 100%);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .24;
  background-image:
    linear-gradient(rgba(98, 221, 255, .075) 1px, transparent 1px),
    linear-gradient(90deg, rgba(98, 221, 255, .075) 1px, transparent 1px);
  background-size: 38px 38px;
  -webkit-mask-image: linear-gradient(to bottom, #000, transparent 85%);
  mask-image: linear-gradient(to bottom, #000, transparent 85%);
}

button, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.chat-shell {
  position: relative;
  isolation: isolate;
  width: min(calc(100% - 30px), 1080px);
  height: min(calc(100dvh - 30px), 940px);
  min-height: 610px;
  margin: 15px auto;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto auto;
  overflow: hidden;
  border: 1px solid rgba(98, 221, 255, .25);
  border-radius: 26px;
  background: linear-gradient(180deg, rgba(8, 23, 46, .98), rgba(4, 13, 29, .98));
  box-shadow: var(--shadow), inset 0 1px rgba(255,255,255,.05);
}
.chat-shell::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(120deg, rgba(98,221,255,.06), transparent 36%, rgba(156,124,255,.06));
}

.chat-header {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0,1fr) auto auto;
  align-items: center;
  gap: 14px;
  padding: 17px 21px;
  border-bottom: 1px solid rgba(98,221,255,.22);
  background: linear-gradient(110deg, rgba(5, 19, 43, .98), rgba(17, 48, 86, .96));
}
.chat-header::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--cyan), var(--violet), transparent);
  box-shadow: 0 0 14px rgba(98,221,255,.55);
}
.brand-copy { min-width: 0; }
.brand-copy .eyebrow { margin: 0 0 3px; color: var(--cyan); font-size: 10px; font-weight: 800; letter-spacing: .15em; }
.brand-copy h1 { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: clamp(17px, 2.8vw, 24px); line-height: 1.15; }
.brand-copy > p:last-child { margin: 4px 0 0; color: var(--muted); font-size: 12px; }

.robot {
  position: relative;
  flex: 0 0 auto;
  overflow: visible;
  border: 1px solid rgba(174, 222, 255, .7);
  background: linear-gradient(180deg, #f5fbff 0%, #b9d0e5 58%, #7892ac 100%);
  box-shadow: 0 0 0 4px rgba(98,221,255,.09), 0 5px 16px rgba(0,0,0,.38), inset 0 2px 2px #fff;
}
.brand-mark { width: 51px; height: 51px; border-radius: 46% 46% 48% 48% / 48% 48% 52% 52%; }
.avatar { width: 38px; height: 38px; border-radius: 46%; }
.robot::before {
  content: "";
  position: absolute;
  z-index: 1;
  left: 11%; right: 11%; top: 21%; bottom: 25%;
  border-radius: 42% 42% 48% 48%;
  background-image:
    radial-gradient(ellipse 15% 20% at 33% 42%, #9df0ff 0 99%, transparent 100%),
    radial-gradient(ellipse 15% 20% at 67% 42%, #9df0ff 0 99%, transparent 100%),
    radial-gradient(ellipse 25% 16% at 50% 67%, transparent 0 56%, #9df0ff 58% 76%, transparent 78%),
    linear-gradient(180deg,#16416d 0%,#07172f 100%);
  box-shadow: inset 0 2px 6px rgba(0,0,0,.75), 0 0 9px rgba(98,221,255,.7);
  animation: robotGlow 3.2s ease-in-out infinite;
}
.robot::after {
  content: "";
  position: absolute;
  left: 50%; top: -9px;
  width: 2px; height: 10px;
  border-radius: 2px;
  background: #badcf0;
  box-shadow: 0 -2px 0 2px var(--cyan), 0 -2px 8px 2px rgba(98,221,255,.8);
}
.robot span::before, .robot span::after {
  content: "";
  position: absolute;
  top: 39%;
  width: 5px; height: 13px;
  border-radius: 5px;
  background: #9bb5ca;
}
.robot span::before { left: -6px; }
.robot span::after { right: -6px; }
@keyframes robotGlow { 50% { filter: brightness(1.14) drop-shadow(0 0 6px rgba(98,221,255,.75)); } }

.status-wrap { display: flex; align-items: center; gap: 8px; color: #c6d8e6; font-size: 11px; white-space: nowrap; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #8a9aab; box-shadow: 0 0 0 3px rgba(255,255,255,.05); }
.status-dot.online { background: var(--green); box-shadow: 0 0 9px rgba(109,245,177,.75); }
.status-dot.offline { background: #ff7f78; }
.status-dot.checking { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.new-chat {
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid rgba(98,221,255,.28);
  border-radius: 11px;
  color: var(--ink);
  background: rgba(98,221,255,.08);
  font-weight: 700;
}
.new-chat:hover { background: rgba(98,221,255,.17); border-color: rgba(98,221,255,.55); }

.tool-strip {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 9px 16px;
  border-bottom: 1px solid rgba(98,221,255,.12);
  background: rgba(2, 11, 25, .72);
  scrollbar-width: thin;
}
.tool-strip button, .tool-strip a {
  flex: 0 0 auto;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 11px;
  border: 1px solid rgba(98,221,255,.2);
  border-radius: 999px;
  color: #d9f5ff;
  background: rgba(11, 49, 84, .58);
  text-decoration: none;
  font-size: 11px;
  font-weight: 800;
}
.tool-strip button:hover, .tool-strip a:hover { color: #fff; border-color: var(--cyan); background: rgba(24,108,159,.5); }

.messages {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 22px clamp(13px, 4vw, 38px);
  scroll-behavior: smooth;
  background:
    linear-gradient(rgba(5,16,34,.88), rgba(5,16,34,.92)),
    repeating-linear-gradient(0deg, transparent, transparent 34px, rgba(98,221,255,.04) 35px);
}
.message { display: flex; align-items: flex-start; gap: 11px; margin: 0 0 18px; }
.message.user { justify-content: flex-end; }
.message.user .avatar { display: none; }
.bubble {
  max-width: min(82%, 760px);
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 7px 18px 18px 18px;
  background: linear-gradient(145deg, rgba(16,43,76,.97), rgba(8,27,53,.97));
  box-shadow: 0 8px 28px rgba(0,0,0,.26), inset 0 1px rgba(255,255,255,.03);
}
.user .bubble { color: #fff; border-color: rgba(156,124,255,.45); border-radius: 18px 7px 18px 18px; background: linear-gradient(135deg, #604dc9, #3267c7); }
.bubble p { margin: 0; line-height: 1.62; white-space: pre-wrap; overflow-wrap: anywhere; }
.welcome-bubble { max-width: min(94%, 820px); }
.welcome-topline { margin-bottom: 9px; color: var(--cyan); font-size: 9px; font-weight: 900; letter-spacing: .14em; }
.signal-dot { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px rgba(109,245,177,.8); }
.welcome-greeting { color: #fff; font-size: clamp(17px, 3vw, 22px); font-weight: 800; }
.pre-chat-line { min-height: 24px; margin-top: 4px !important; color: var(--gold); font-weight: 700; transition: opacity .24s ease, transform .24s ease; }
.pre-chat-line.changing { opacity: 0; transform: translateY(4px); }
.capability-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; margin-top: 14px; }
.capability-grid button {
  min-height: 66px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: 10px 12px;
  border: 1px solid rgba(98,221,255,.18);
  border-radius: 13px;
  color: var(--ink);
  background: rgba(98,221,255,.055);
  text-align: left;
}
.capability-grid button:hover { border-color: rgba(98,221,255,.55); background: rgba(98,221,255,.1); transform: translateY(-1px); }
.capability-grid strong { color: var(--cyan); font-size: 12px; }
.capability-grid span { margin-top: 3px; color: var(--muted); font-size: 10px; line-height: 1.35; }
.example-list { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.example-list button {
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid rgba(156,124,255,.3);
  border-radius: 999px;
  color: #ded6ff;
  background: rgba(156,124,255,.08);
  text-align: left;
  font-size: 10px;
}
.example-list button:hover { border-color: var(--violet); background: rgba(156,124,255,.15); }
.small-note { margin-top: 12px !important; padding-top: 10px; border-top: 1px solid rgba(159,182,202,.15); color: var(--muted); font-size: 11px; }
.sources { margin-top: 10px; padding-top: 8px; border-top: 1px dashed rgba(159,182,202,.18); color: var(--muted); font-size: 10px; line-height: 1.45; }
.answer-actions, .report-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.answer-actions a, .report-actions button {
  min-height: 39px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border: 1px solid var(--cyan-2);
  border-radius: 10px;
  color: #d9f8ff;
  background: rgba(22,167,232,.09);
  text-decoration: none;
  font-size: 11px;
  font-weight: 800;
}
.answer-actions a.primary, .report-actions button:first-child { color: #03101f; background: linear-gradient(135deg, var(--cyan), #7af3da); border-color: transparent; }
.answer-actions a:hover, .report-actions button:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(22,167,232,.18); }

.typing .bubble { min-width: 76px; padding: 14px 17px; }
.typing-dots { display: inline-flex; gap: 5px; padding: 4px 1px; }
.typing-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); animation: bounce 1s infinite alternate; box-shadow: 0 0 7px rgba(98,221,255,.6); }
.typing-dots i:nth-child(2) { animation-delay: .18s; }
.typing-dots i:nth-child(3) { animation-delay: .36s; }
@keyframes bounce { to { transform: translateY(-5px); opacity: .42; } }

.notice { margin: 0 18px 9px; padding: 9px 12px; border: 1px solid rgba(255,158,153,.38); border-radius: 10px; color: #ffd1ce; background: rgba(153,45,42,.24); font-size: 12px; }
.composer {
  display: grid;
  grid-template-columns: auto minmax(0,1fr) auto;
  gap: 9px;
  align-items: end;
  margin: 0 15px;
  padding: 10px 11px;
  border: 1px solid rgba(98,221,255,.26);
  border-radius: 17px;
  background: rgba(7, 24, 48, .95);
  box-shadow: 0 9px 28px rgba(0,0,0,.32);
}
.composer:focus-within { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(98,221,255,.09), 0 9px 28px rgba(0,0,0,.32); }
.attach-pdf {
  align-self: center;
  min-width: 48px; min-height: 42px;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  padding: 0 8px;
  border: 1px solid rgba(98,221,255,.28);
  border-radius: 10px;
  color: var(--cyan);
  background: rgba(98,221,255,.07);
  font-size: 10px;
  font-weight: 900;
}
.attach-pdf svg { width: 16px; height: 16px; fill: currentColor; }
.attach-pdf:hover { border-color: var(--cyan); background: rgba(98,221,255,.13); }
.attach-pdf:disabled { cursor: wait; opacity: .55; }
textarea { width: 100%; max-height: 130px; resize: none; padding: 7px 5px; border: 0; outline: 0; color: var(--ink); background: transparent; line-height: 1.5; }
textarea::placeholder { color: #6f8ba2; }
#sendButton {
  min-height: 43px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 15px;
  border: 0;
  border-radius: 11px;
  color: #03101f;
  background: linear-gradient(135deg, var(--cyan), #80f0dc);
  font-weight: 900;
  box-shadow: 0 0 16px rgba(98,221,255,.17);
}
#sendButton:hover { filter: brightness(1.08); }
#sendButton:disabled { cursor: wait; opacity: .55; }
#sendButton svg { width: 17px; height: 17px; fill: currentColor; }
.chat-footer { padding: 9px 18px 12px; color: #7892a8; text-align: center; font-size: 9px; letter-spacing: .02em; }

@media (max-width: 720px) {
  body { background: var(--space); }
  .chat-shell { width: 100%; height: 100dvh; min-height: 0; margin: 0; border: 0; border-radius: 0; box-shadow: none; }
  .chat-header { grid-template-columns: auto minmax(0,1fr) auto; gap: 10px; padding: calc(12px + env(safe-area-inset-top)) 12px 12px; }
  .brand-mark { width: 42px; height: 42px; }
  .brand-copy .eyebrow, .brand-copy > p:last-child, #statusText { display: none; }
  .status-wrap { position: absolute; right: 99px; top: calc(27px + env(safe-area-inset-top)); }
  .new-chat { min-height: 38px; padding: 7px 9px; font-size: 11px; }
  .tool-strip { padding: 8px 9px; }
  .messages { padding: 17px 10px; }
  .bubble { max-width: 90%; }
  .welcome-bubble { max-width: calc(100% - 4px); }
  .composer { margin: 0 8px; }
  .chat-footer { padding-bottom: calc(9px + env(safe-area-inset-bottom)); }
}
@media (max-width: 460px) {
  .brand-copy h1 { font-size: 15px; }
  .capability-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
  .capability-grid button { min-height: 61px; padding: 9px; }
  .composer { grid-template-columns: 43px minmax(0,1fr) 45px; gap: 6px; padding: 8px; }
  .attach-pdf { min-width: 43px; width: 43px; padding: 0; }
  .attach-pdf span { display: none; }
  #sendButton { width: 45px; padding: 0; }
  #sendButton span { display: none; }
  textarea { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
