:root {
  color-scheme: dark;
  --bg: #07101c;
  --panel: #0d1a2a;
  --panel-soft: #101f31;
  --text: #f3f8fa;
  --muted: #8fa4b3;
  --cyan: #55d6e8;
  --cyan-strong: #85e7f1;
  --border: rgba(85, 214, 232, 0.18);
  --danger: #ff8c8c;
  --radius-card: 24px;
  --radius-bubble: 18px;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.38), 0 2px 12px rgba(85, 214, 232, 0.06);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 15% 10%, rgba(24, 166, 185, 0.16), transparent 32rem),
    radial-gradient(circle at 85% 90%, rgba(85, 214, 232, 0.08), transparent 28rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}

button, textarea { font: inherit; }
button { cursor: pointer; }

.skip-link {
  position: fixed;
  left: 12px;
  top: 12px;
  z-index: 10;
  transform: translateY(-180%);
  border-radius: 8px;
  background: var(--cyan-strong);
  color: var(--bg);
  padding: 10px 14px;
}
.skip-link:focus { transform: translateY(0); }

.shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.chat-card {
  width: min(100%, 760px);
  min-height: min(780px, calc(100dvh - 32px));
  max-height: calc(100dvh - 32px);
  display: grid;
  grid-template-rows: auto minmax(180px, 1fr) auto auto auto;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(16, 31, 49, 0.98), rgba(11, 22, 37, 0.98));
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(7, 16, 28, 0.56);
}

.brand-mark, .avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--bg);
  background: linear-gradient(145deg, var(--cyan-strong), #18a6b9);
  font-weight: 800;
  letter-spacing: -0.04em;
}
.brand-mark { width: 48px; height: 48px; border-radius: 15px; }
.avatar { width: 32px; height: 32px; border-radius: 10px; font-size: 11px; }

.brand-copy { min-width: 0; }
.eyebrow { margin: 0 0 4px; color: var(--cyan); font-size: 11px; font-weight: 800; letter-spacing: 0.16em; }
h1 { margin: 0; font-size: clamp(18px, 3vw, 23px); line-height: 1.2; text-wrap: balance; }
.presence { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.presence-dot { display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 50%; background: #70d8aa; box-shadow: 0 0 0 3px rgba(112, 216, 170, 0.12); }

.messages {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 24px;
  scroll-behavior: smooth;
}
.message { display: flex; gap: 10px; align-items: flex-end; margin-bottom: 20px; }
.message-user { justify-content: flex-end; }
.bubble { max-width: min(84%, 560px); padding: 14px 16px; border-radius: var(--radius-bubble); overflow-wrap: anywhere; line-height: 1.55; }
.bubble p { margin: 0; }
.bubble p + p { margin-top: 8px; }
.message-agent .bubble { background: var(--panel-soft); border: 1px solid rgba(255, 255, 255, 0.06); border-bottom-left-radius: 5px; }
.message-user .bubble { background: var(--cyan-strong); color: var(--bg); border-bottom-right-radius: 5px; }
.message-error .bubble { border-color: rgba(255, 140, 140, 0.4); color: #ffd0d0; }

.suggestions { display: flex; gap: 8px; overflow-x: auto; padding: 0 24px 14px; scrollbar-width: none; }
.suggestion { min-height: 44px; flex: 0 0 auto; border: 1px solid var(--border); border-radius: 999px; padding: 9px 14px; color: var(--cyan-strong); background: rgba(85, 214, 232, 0.06); }
.suggestion:hover { background: rgba(85, 214, 232, 0.12); border-color: rgba(85, 214, 232, 0.38); }

.composer { display: flex; align-items: flex-end; gap: 10px; margin: 0 16px; padding: 10px; background: rgba(7, 16, 28, 0.84); border: 1px solid var(--border); border-radius: 18px; }
textarea { min-height: 44px; max-height: 144px; width: 100%; resize: none; border: 0; outline: 0; padding: 11px 10px; color: var(--text); background: transparent; font-size: 16px; line-height: 1.4; }
textarea::placeholder { color: #718796; }
.send-button { width: 44px; height: 44px; flex: 0 0 auto; display: grid; place-items: center; border: 0; border-radius: 13px; background: var(--cyan-strong); color: var(--bg); transition: transform 160ms ease, background-color 160ms ease, opacity 160ms ease; }
.send-button:hover { background: #a7eff5; transform: translateY(-1px); }
.send-button:active { transform: translateY(0); }
.send-button:disabled { cursor: wait; opacity: 0.55; transform: none; }
.send-button svg { width: 22px; height: 22px; fill: currentColor; }

.status { min-height: 36px; margin: 0; padding: 8px 24px 12px; color: var(--muted); text-align: center; font-size: 11px; line-height: 1.4; }
.status-error { color: var(--danger); }

button:focus-visible, textarea:focus-visible, .skip-link:focus-visible { outline: 3px solid var(--cyan-strong); outline-offset: 3px; }
.composer:focus-within { border-color: rgba(85, 214, 232, 0.62); box-shadow: 0 0 0 3px rgba(85, 214, 232, 0.1); }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.typing { display: inline-flex; gap: 5px; align-items: center; min-height: 20px; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: pulse 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: 140ms; }
.typing span:nth-child(3) { animation-delay: 280ms; }
@keyframes pulse { 0%, 60%, 100% { opacity: 0.35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

@media (max-width: 640px) {
  .shell { padding: 0; }
  .chat-card { min-height: 100dvh; max-height: 100dvh; border: 0; border-radius: 0; }
  .chat-header { padding: max(16px, env(safe-area-inset-top)) 16px 14px; }
  .messages { padding: 18px 16px; }
  .suggestions { padding: 0 16px 12px; }
  .status { padding-right: 16px; padding-bottom: max(10px, env(safe-area-inset-bottom)); padding-left: 16px; }
  .bubble { max-width: 88%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
