@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700;800&family=Space+Grotesk:wght@500;600;700&display=swap');

:root {
  color-scheme: dark;
  font-family: 'DM Sans', sans-serif;
  background: #101019;
  color: #f4f2fb;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  --muted: #a09cac;
  --violet: #a78bfa;
  --pink: #f0a4d3;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(ellipse at 18% 44%, rgba(108, 74, 167, .14), transparent 33rem),
    radial-gradient(ellipse at 92% 12%, rgba(78, 95, 174, .12), transparent 30rem),
    #101019;
}

button, textarea { font: inherit; }
button { color: inherit; }

.chat-shell { width: min(1192px, calc(100% - 64px)); min-height: 100vh; margin: 0 auto; display: flex; flex-direction: column; }
.chat-header { height: 82px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; border-bottom: 1px solid rgba(255,255,255,.08); }
.back-link, .brand-mark, .header-label { color: #c5c1cf; text-decoration: none; font-size: 13px; }
.back-link { display: flex; align-items: center; gap: 10px; width: max-content; }
.back-link span:first-child { color: var(--violet); font-size: 20px; }
.brand-mark { display: inline-flex; align-items: center; gap: 9px; color: #f5f2fb; font: 700 16px 'Space Grotesk', sans-serif; letter-spacing: .08em; }
.brand-mark img { width: 28px; height: 28px; object-fit: contain; }
.brand-dot { color: #c397ff; }
.header-label { justify-self: end; display: flex; align-items: center; gap: 8px; color: #bab5c7; font-size: 10px; font-weight: 700; letter-spacing: .13em; }
.online-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #74e2ad; box-shadow: 0 0 12px rgba(116,226,173,.55); }

.chat-layout { flex: 1; display: grid; grid-template-columns: .85fr 1.15fr; gap: clamp(42px, 8vw, 112px); align-items: center; padding: 44px 0; }
.mascot-panel { position: relative; align-self: center; padding: 20px 0 36px; }
.mascot-glow { position: absolute; z-index: -1; left: 5%; top: 4%; width: 85%; height: 57%; border-radius: 50%; background: radial-gradient(ellipse, rgba(155,105,220,.27), transparent 70%); filter: blur(20px); }
.mascot-image-wrap { position: relative; width: min(310px, 84%); aspect-ratio: 1; margin: 0 0 29px 20px; display: grid; place-items: center; }
.mascot-image { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 20px 42px rgba(7,4,16,.5)); }
.mascot-spark { position: absolute; color: #d7b6ff; text-shadow: 0 0 22px rgba(203,160,255,.8); }
.spark-one { top: 8%; right: -5%; font-size: 27px; }
.spark-two { bottom: 14%; left: -4%; font-size: 19px; color: #9bdcff; }
.eyebrow { color: #c69aff; font-size: 10px; font-weight: 700; letter-spacing: .17em; }
.mascot-panel h1 { max-width: 420px; margin: 13px 0 12px; font: 600 clamp(29px, 3.2vw, 43px)/1.12 'Space Grotesk', sans-serif; letter-spacing: -.045em; }
.mascot-panel h1 span { color: #c199ff; }
.mascot-panel > p { max-width: 410px; margin: 0; color: #aaa6b5; font-size: 14px; line-height: 1.8; }
.mascot-status { display: flex; align-items: center; gap: 9px; margin-top: 24px; color: #c9c5d1; font-size: 12px; }
.mascot-note { display: flex; gap: 9px; align-items: center; margin-top: 34px; color: #888495; font-size: 12px; }
.mascot-note span { color: #c59bff; font-size: 16px; }

.conversation-panel { height: min(690px, calc(100vh - 145px)); min-height: 530px; display: flex; flex-direction: column; overflow: hidden; border: 1px solid rgba(255,255,255,.095); border-radius: 22px; background: linear-gradient(150deg, rgba(30,29,42,.97), rgba(21,20,30,.98)); box-shadow: 0 30px 100px rgba(0,0,0,.25), inset 0 1px rgba(255,255,255,.035); }
.conversation-top { min-height: 76px; display: flex; justify-content: space-between; align-items: center; padding: 0 23px; border-bottom: 1px solid rgba(255,255,255,.07); }
.conversation-person { display: flex; align-items: center; gap: 11px; }
.conversation-person img, .message-avatar img { width: 100%; height: 100%; object-fit: contain; }
.conversation-person img { width: 39px; height: 39px; padding: 2px; border-radius: 50%; background: rgba(178,138,238,.13); }
.conversation-person div { display: grid; gap: 3px; }
.conversation-person strong { font-size: 12px; letter-spacing: .07em; }
.conversation-person div span { color: #93909e; font-size: 11px; }
.new-chat-button { flex: 0 0 auto; border: 0; background: transparent; color: #aaa5b4; cursor: pointer; font-size: 12px; }
.new-chat-button:hover { color: #e1ccff; }
.version-picker select { max-width: 210px; min-height: 36px; padding: 0 26px 0 10px; color: #e5dcf4; font: 600 10px 'DM Sans',sans-serif; cursor: pointer; border: 1px solid rgba(196,155,255,.3); border-radius: 10px; outline: none; background: #201d2d; }
.version-picker select:focus { border-color: #c49bff; box-shadow: 0 0 0 3px #a78bfa20; }
.version-picker option { color: #f4f2fb; background: #201d2d; }
.version-picker option:disabled { color: #8d879b; }

.messages { flex: 1; overflow-y: auto; padding: 24px 23px 14px; scrollbar-color: #464153 transparent; scrollbar-width: thin; }
.welcome-message, .message-row { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 19px; }
.message-avatar { flex: 0 0 30px; width: 30px; height: 30px; overflow: hidden; border: 1px solid rgba(196,155,255,.18); border-radius: 50%; background: #292539; }
.message-content { min-width: 0; max-width: 86%; }
.message-author { display: flex; align-items: center; gap: 8px; margin: 1px 0 7px; color: #e4d4ff; font-size: 10px; font-weight: 700; letter-spacing: .07em; }
.message-author time { color: #777383; font-size: 10px; font-weight: 400; letter-spacing: 0; }
.message-bubble { padding: 12px 14px; border: 1px solid rgba(255,255,255,.055); border-radius: 4px 14px 14px 14px; background: rgba(255,255,255,.055); color: #e2dfeb; font-size: 13px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.message-sources { margin-top: 7px; color: #a9a4b7; font-size: 11px; line-height: 1.6; overflow-wrap: anywhere; }
.message-sources a { color: #aebeff; text-decoration: underline; text-underline-offset: 2px; }
.user-message { justify-content: flex-end; }
.user-message .message-content { display: flex; flex-direction: column; align-items: flex-end; }
.user-message .message-author { color: #b9c7ff; }
.user-message .message-bubble { border-color: rgba(155,147,247,.16); border-radius: 14px 4px 14px 14px; background: linear-gradient(135deg, rgba(106,99,179,.24), rgba(139,99,175,.2)); }
.typing-indicator { display: flex; align-items: center; gap: 4px; width: max-content; margin: 0 0 16px 40px; padding: 12px; border-radius: 14px; background: rgba(255,255,255,.055); }
.typing-indicator span { width: 5px; height: 5px; border-radius: 50%; background: #c9a5ff; animation: typing 1s infinite ease-in-out; }
.typing-indicator span:nth-child(2) { animation-delay: .15s; }
.typing-indicator span:nth-child(3) { animation-delay: .3s; }
.typing-indicator .typing-label { width: auto; height: auto; margin-left: 5px; color: #c9a5ff; font-size: 10px; background: transparent; animation: none; }
@keyframes typing { 0%, 60%, 100% { opacity: .4; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-4px); } }

.suggestions { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 20px 13px; }
.suggestions button { padding: 7px 10px; border: 1px solid rgba(255,255,255,.1); border-radius: 999px; background: rgba(255,255,255,.025); color: #c6c1d0; cursor: pointer; font-size: 10px; transition: border-color .2s, background .2s; }
.suggestions button:hover { border-color: rgba(191,156,255,.45); background: rgba(178,138,238,.1); }
.suggestions button span { margin-left: 4px; color: #c39bff; }
.message-form { position: relative; display: flex; align-items: flex-end; min-height: 70px; margin: 0 17px 17px; padding: 11px 12px 24px 15px; border: 1px solid rgba(255,255,255,.12); border-radius: 14px; background: rgba(8,8,14,.35); transition: border-color .2s; }
.message-form:focus-within { border-color: rgba(188,149,250,.55); }
.message-form textarea { flex: 1; max-height: 132px; min-height: 24px; resize: none; outline: none; border: 0; background: transparent; color: #f4f0fb; font-size: 12px; line-height: 1.65; }
.message-form textarea::placeholder { color: #777383; }
.voice-picker { flex: 0 0 auto; margin-left: 8px; }
.voice-picker select { max-width: 130px; min-height: 31px; padding: 0 22px 0 8px; color: #e5dcf4; font: 600 9px 'DM Sans',sans-serif; cursor: pointer; border: 1px solid rgba(196,155,255,.25); border-radius: 9px; outline: none; background: #201d2d; }
.voice-picker select:focus { border-color: #c49bff; box-shadow: 0 0 0 3px #a78bfa20; }
.voice-picker option { color: #f4f2fb; background: #201d2d; }
.voice-button { flex: 0 0 31px; width: 31px; height: 31px; margin-left: 8px; border: 1px solid rgba(196,155,255,.25); border-radius: 10px; background: rgba(178,138,238,.1); color: #dbc5ff; cursor: pointer; font-size: 15px; transition: background .2s, border-color .2s, box-shadow .2s; }
.voice-button:hover, .voice-button.is-active { border-color: rgba(196,155,255,.65); background: rgba(178,138,238,.24); }
.voice-button.is-listening { box-shadow: 0 0 0 4px rgba(196,155,255,.13); animation: voice-pulse 1.4s infinite; }
.voice-button:disabled { cursor: not-allowed; opacity: .5; }
@keyframes voice-pulse { 50% { box-shadow: 0 0 0 8px rgba(196,155,255,0); } }
.send-button { flex: 0 0 31px; width: 31px; height: 31px; margin-left: 9px; border: 0; border-radius: 10px; background: linear-gradient(135deg, #c299ff, #9183ed); color: #17131f; cursor: pointer; font-size: 22px; line-height: 1; transition: opacity .2s, transform .2s; }
.send-button:hover { transform: translateY(-1px); }
.send-button:disabled { cursor: wait; opacity: .5; }
.form-hint { position: absolute; left: 15px; right: 48px; bottom: 6px; margin: 0; color: #777383; font-size: 9px; line-height: 1.2; }
.voice-feedback { margin: -7px 20px 8px; padding: 9px 11px; border: 1px solid rgba(255,255,255,.07); border-radius: 10px; background: rgba(255,255,255,.025); transition: border-color .2s, background .2s; }
.voice-feedback[data-state="listening"] { border-color: rgba(116,226,173,.28); background: rgba(116,226,173,.045); }
.voice-feedback[data-state="processing"], .voice-feedback[data-state="thinking"] { border-color: rgba(196,155,255,.32); }
.voice-feedback[data-state="speaking"] { border-color: rgba(196,155,255,.58); background: rgba(178,138,238,.1); box-shadow: 0 0 20px rgba(167,139,250,.1); }
.voice-feedback[data-state="error"] { border-color: rgba(255,120,140,.35); }
.voice-status { display: flex; min-height: 19px; align-items: center; gap: 10px; margin: 0; color: #c9c4d2; font-size: 10px; line-height: 1.45; }
.voice-status-text { flex: 1; }
.voice-visualizer { display: inline-flex; height: 17px; align-items: center; gap: 2px; opacity: .25; }
.voice-visualizer i { display: block; width: 3px; height: 5px; border-radius: 4px; background: #c6a1ff; }
.voice-feedback[data-state="listening"] .voice-visualizer,
.voice-feedback[data-state="speaking"] .voice-visualizer { opacity: 1; }
.voice-feedback[data-state="listening"] .voice-visualizer i { background: #74e2ad; animation: voice-wave .75s ease-in-out infinite alternate; }
.voice-feedback[data-state="speaking"] .voice-visualizer i { animation: voice-wave .55s ease-in-out infinite alternate; }
.voice-visualizer i:nth-child(2) { animation-delay: .12s !important; }
.voice-visualizer i:nth-child(3) { animation-delay: .24s !important; }
.voice-visualizer i:nth-child(4) { animation-delay: .36s !important; }
.voice-visualizer i:nth-child(5) { animation-delay: .48s !important; }
@keyframes voice-wave { to { height: 16px; } }
.voice-transcript { margin-top: 8px; padding-top: 7px; border-top: 1px solid rgba(255,255,255,.07); }
.voice-transcript[hidden] { display: none; }
.voice-transcript > span { color: #8d879b; font-size: 9px; text-transform: uppercase; letter-spacing: .08em; }
.voice-transcript p { margin: 3px 0 0; color: #f0ebf8; font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.voice-note { margin: -7px 20px 12px; color: #918c9e; font-size: 10px; line-height: 1.45; }
.error-message { margin: -7px 20px 16px; color: #ffb3bb; font-size: 11px; line-height: 1.5; }
.chat-footer { display: flex; justify-content: space-between; gap: 20px; padding: 17px 0 21px; border-top: 1px solid rgba(255,255,255,.07); color: #797685; font-size: 10px; }
.chat-footer a { color: #aaa4b6; text-decoration: none; }
.chat-footer a:hover { color: #dac5ff; }
.chat-footer a span { margin-left: 4px; color: #bd94fa; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; clip-path: inset(50%); border: 0; }

@media (max-width: 850px) {
  .chat-shell { width: min(640px, calc(100% - 36px)); }
  .chat-layout { grid-template-columns: 1fr; gap: 25px; padding: 27px 0; }
  .mascot-panel { display: grid; grid-template-columns: 115px 1fr; column-gap: 18px; align-items: center; padding: 0; }
  .mascot-image-wrap { grid-row: 1 / span 4; width: 115px; margin: 0; }
  .mascot-panel .eyebrow { align-self: end; font-size: 9px; }
  .mascot-panel h1 { align-self: center; margin: 7px 0; font-size: clamp(24px, 5vw, 34px); }
  .mascot-panel > p { align-self: start; font-size: 12px; line-height: 1.55; }
  .mascot-status { display: none; }
  .mascot-note { display: none; }
  .conversation-panel { height: min(620px, 70vh); min-height: 450px; }
}

@media (max-width: 520px) {
  .chat-shell { width: calc(100% - 28px); }
  .chat-header { height: 65px; }
  .back-link { gap: 5px; font-size: 11px; }
  .brand-mark { gap: 5px; font-size: 13px; }
  .brand-mark img { width: 23px; height: 23px; }
  .header-label { font-size: 8px; letter-spacing: .08em; }
  .mascot-panel { grid-template-columns: 83px 1fr; column-gap: 12px; }
  .mascot-image-wrap { width: 83px; }
  .mascot-panel .eyebrow { font-size: 7px; letter-spacing: .11em; }
  .mascot-panel h1 { margin: 5px 0; font-size: 24px; }
  .mascot-panel > p { font-size: 11px; }
  .chat-layout { gap: 20px; padding: 22px 0; }
  .conversation-panel { height: calc(100dvh - 235px); min-height: 390px; border-radius: 17px; }
  .conversation-top { min-height: 65px; flex-wrap: wrap; gap: 6px; padding: 8px 10px; }
  .version-picker select { max-width: 170px; min-height: 31px; padding: 0 20px 0 7px; font-size: 8px; }
  .new-chat-button { font-size: 11px; }
  .new-chat-button span { display: none; }
  .messages { padding: 18px 14px 10px; }
  .message-content { max-width: 90%; }
  .suggestions { gap: 6px; padding: 0 13px 11px; }
  .suggestions button { padding: 7px 8px; font-size: 9px; }
  .message-form { margin: 0 11px 11px; }
  .voice-picker { margin-left: 5px; }
  .voice-picker select { max-width: 98px; padding-right: 17px; padding-left: 5px; font-size: 8px; }
  .voice-button { margin-left: 5px; }
  .form-hint { left: 12px; right: 43px; font-size: 8px; }
  .chat-footer { font-size: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
