:root {
  color-scheme: light;
  --ink: #101828;
  --muted: #667085;
  --line: #e4e7ec;
  --surface: #ffffff;
  --soft: #f7f8fb;
  --violet: #6558e8;
  --violet-dark: #5044d7;
  --violet-soft: #f0efff;
  --green: #12b76a;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --shadow: 0 24px 70px rgba(16, 24, 40, .13);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 4%, rgba(117, 101, 244, .16), transparent 25rem),
    radial-gradient(circle at 96% 96%, rgba(61, 207, 144, .12), transparent 28rem),
    #f3f5f9;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app-shell {
  display: grid;
  grid-template-columns: minmax(18rem, 24rem) minmax(0, 46rem);
  width: min(74rem, calc(100% - 3rem));
  height: min(49rem, calc(100vh - 3rem));
  min-height: 39rem;
  margin: 1.5rem auto;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid rgba(208, 213, 221, .85);
  border-radius: 1.75rem;
  box-shadow: var(--shadow);
}

.sidebar {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 2rem;
  color: #fff;
  background:
    radial-gradient(circle at 100% 0, rgba(126, 114, 255, .55), transparent 19rem),
    linear-gradient(155deg, #171d35 0%, #0a1020 62%, #0d1428 100%);
}

.sidebar::after {
  position: absolute;
  right: -6rem;
  bottom: -8rem;
  width: 20rem;
  height: 20rem;
  content: "";
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 50%;
  box-shadow: 0 0 0 3rem rgba(255, 255, 255, .025), 0 0 0 6rem rgba(255, 255, 255, .018);
}

.brand {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: .8rem;
  width: fit-content;
  color: #fff;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 2.9rem;
  height: 2.9rem;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, #8073ff, #5b4ee6);
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: .9rem;
  box-shadow: 0 12px 25px rgba(91, 78, 230, .35);
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: .98rem; letter-spacing: -.01em; }
.brand small { margin-top: .15rem; color: #aeb6cc; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; }

.sidebar-copy {
  position: relative;
  z-index: 1;
  margin: clamp(4rem, 11vh, 7rem) 0 2rem;
}

.eyebrow {
  display: inline-flex;
  padding: .4rem .7rem;
  color: #c8c3ff;
  background: rgba(117, 101, 244, .15);
  border: 1px solid rgba(157, 147, 255, .2);
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.sidebar h1 {
  max-width: 18rem;
  margin: 1rem 0 .9rem;
  font-size: clamp(2rem, 3.7vw, 2.8rem);
  line-height: 1.08;
  letter-spacing: -.045em;
}

.sidebar-copy p {
  max-width: 19rem;
  margin: 0;
  color: #adb5ca;
  font-size: .95rem;
  line-height: 1.7;
}

.service-card {
  position: relative;
  z-index: 1;
  margin-top: auto;
  padding: 1rem;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 1rem;
  backdrop-filter: blur(8px);
}

.status-line { font-size: .82rem; font-weight: 700; }
.status-dot { display: inline-block; width: .48rem; height: .48rem; margin-right: .45rem; background: #3ddc97; border-radius: 50%; box-shadow: 0 0 0 .24rem rgba(61, 220, 151, .12); }
.service-card p { margin: .6rem 0 0; color: #aeb6ca; font-size: .76rem; line-height: 1.55; }

.privacy-note {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: .45rem;
  margin: 1rem 0 0;
  color: #8993aa;
  font-size: .7rem;
}

.chat-panel { display: grid; min-width: 0; grid-template-rows: auto 1fr auto; background: var(--surface); }

.chat-header {
  display: flex;
  align-items: center;
  gap: .8rem;
  min-height: 5.25rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--line);
}

.agent-avatar {
  display: grid;
  flex: 0 0 auto;
  width: 3rem;
  height: 3rem;
  overflow: hidden;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, #7f72ff, #5044d7);
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 8px 18px rgba(52, 64, 84, .2), 0 0 0 1px rgba(101, 88, 232, .12);
}
.agent-avatar img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center; }

.agent-info { min-width: 0; }
.agent-info strong { display: block; overflow: hidden; font-size: .92rem; text-overflow: ellipsis; white-space: nowrap; }
.agent-info span { display: flex; align-items: center; gap: .35rem; margin-top: .25rem; color: var(--muted); font-size: .72rem; }
.agent-info i { display: inline-block; width: .42rem; height: .42rem; background: var(--green); border-radius: 50%; }

.icon-button {
  display: grid;
  width: 2.6rem;
  height: 2.6rem;
  margin-left: auto;
  padding: 0;
  place-items: center;
  color: #667085;
  background: transparent;
  border: 1px solid transparent;
  border-radius: .75rem;
  cursor: pointer;
}
.icon-button:hover { color: var(--ink); background: var(--soft); border-color: var(--line); }

.messages {
  overflow-x: hidden;
  overflow-y: auto;
  padding: 1.5rem clamp(1rem, 4vw, 2rem);
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: #d0d5dd transparent;
}

.welcome { max-width: 34rem; margin: clamp(2rem, 10vh, 5.5rem) auto 1rem; text-align: center; }
.welcome-icon { display: grid; width: 3.6rem; height: 3.6rem; margin: 0 auto 1.15rem; place-items: center; color: var(--violet); background: var(--violet-soft); border: 1px solid #dedaff; border-radius: 1.2rem; font-size: 1.45rem; }
.welcome h2 { margin: 0; font-size: clamp(1.45rem, 4vw, 1.85rem); letter-spacing: -.035em; }
.welcome > p { margin: .65rem auto 1.4rem; color: var(--muted); font-size: .9rem; line-height: 1.55; }

.suggestions { display: flex; flex-wrap: wrap; justify-content: center; gap: .55rem; }
.suggestions button { padding: .65rem .85rem; color: #475467; background: #fff; border: 1px solid var(--line); border-radius: 999px; font-size: .76rem; cursor: pointer; transition: transform .15s, border-color .15s, color .15s; }
.suggestions button:hover { color: var(--violet-dark); border-color: #bbb4ff; transform: translateY(-1px); }

.message-row { display: flex; width: 100%; margin: 0 0 1rem; animation: rise .22s ease-out; }
.message-row.user { justify-content: flex-end; }
.message-content { display: flex; width: fit-content; min-width: 0; max-width: min(82%, 33rem); flex-direction: column; align-items: flex-start; }
.message-row.user .message-content { align-items: flex-end; }
.message-bubble { width: fit-content; min-width: 3.5rem; max-width: 100%; padding: .8rem 1rem; border-radius: .35rem 1.1rem 1.1rem 1.1rem; font-size: .88rem; line-height: 1.62; white-space: pre-wrap; overflow-wrap: break-word; word-break: normal; }
.message-row.assistant .message-bubble { color: #344054; background: var(--soft); border: 1px solid #eaecf0; }
.message-row.user .message-bubble { color: #fff; background: linear-gradient(135deg, #6f61ed, #584adc); border-radius: 1.1rem 1.1rem .35rem 1.1rem; box-shadow: 0 8px 20px rgba(88, 74, 220, .16); }
.message-meta { margin-top: .3rem; color: #98a2b3; font-size: .65rem; }
.message-row.user .message-meta { text-align: right; }
.message-actions { margin-top: .55rem; }
.support-link { display: inline-flex; align-items: center; padding: .58rem .78rem; color: #fff; background: var(--violet); border-radius: .72rem; font-size: .74rem; font-weight: 700; text-decoration: none; box-shadow: 0 6px 14px rgba(101, 88, 232, .18); transition: background .15s, transform .15s; }
.support-link:hover { background: var(--violet-dark); transform: translateY(-1px); }
.support-link:focus-visible { outline: .18rem solid rgba(101, 88, 232, .28); outline-offset: .16rem; }

.typing { display: flex; align-items: center; gap: .28rem; min-height: 2.9rem; }
.typing span { width: .4rem; height: .4rem; background: #98a2b3; border-radius: 50%; animation: bounce 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }

.composer-wrap { padding: .75rem clamp(1rem, 4vw, 2rem) 1rem; background: linear-gradient(0deg, #fff 80%, rgba(255, 255, 255, .75)); }
.composer { position: relative; display: flex; align-items: flex-end; gap: .65rem; padding: .65rem .65rem .65rem 1rem; background: #fff; border: 1px solid #d0d5dd; border-radius: 1rem; box-shadow: 0 5px 18px rgba(16, 24, 40, .06); transition: border-color .15s, box-shadow .15s; }
.composer:focus-within { border-color: #9b8ff8; box-shadow: 0 0 0 .25rem rgba(101, 88, 232, .09), 0 5px 18px rgba(16, 24, 40, .06); }
.composer textarea { width: 100%; max-height: 8rem; min-height: 2.5rem; padding: .55rem 3.6rem .3rem 0; resize: none; color: var(--ink); background: transparent; border: 0; outline: 0; font-size: .88rem; line-height: 1.5; }
.composer textarea::placeholder { color: #98a2b3; }
.char-count { position: absolute; right: 4.15rem; bottom: 1.15rem; color: #98a2b3; font-size: .62rem; }
.char-count.near-limit { color: #b54708; }
.send-button { display: grid; flex: 0 0 auto; width: 2.7rem; height: 2.7rem; padding: 0; place-items: center; color: #fff; background: var(--violet); border: 0; border-radius: .8rem; cursor: pointer; box-shadow: 0 8px 16px rgba(101, 88, 232, .22); transition: background .15s, transform .15s, opacity .15s; }
.send-button:hover { background: var(--violet-dark); transform: translateY(-1px); }
.send-button:disabled { cursor: not-allowed; opacity: .45; transform: none; }
.disclaimer { margin: .55rem 0 0; color: #98a2b3; font-size: .65rem; text-align: center; }

.error-banner { margin: 0 0 .55rem; padding: .65rem .8rem; color: var(--danger); background: var(--danger-soft); border: 1px solid #fecdca; border-radius: .7rem; font-size: .76rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .55; } 30% { transform: translateY(-.25rem); opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(.35rem); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 760px) {
  body { background: #fff; }
  .app-shell { display: block; width: 100%; height: 100dvh; min-height: 0; margin: 0; border: 0; border-radius: 0; box-shadow: none; }
  .sidebar { display: none; }
  .chat-panel { height: 100dvh; }
  .chat-header { min-height: 4.6rem; padding: .8rem 1rem; }
  .messages { padding: 1rem; }
  .welcome { margin-top: clamp(2rem, 12vh, 5rem); }
  .composer-wrap { padding: .65rem .8rem .75rem; }
  .message-content { max-width: 88%; }
}

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

.not-found-page { display: grid; min-height: 100vh; padding: 1.5rem; place-items: center; }
.not-found-card { width: min(100%, 30rem); padding: 2.5rem; text-align: center; background: #fff; border: 1px solid var(--line); border-radius: 1.5rem; box-shadow: var(--shadow); }
.not-found-icon { display: grid; width: 3.6rem; height: 3.6rem; margin: 0 auto 1rem; place-items: center; color: var(--violet); background: var(--violet-soft); border: 1px solid #dedaff; border-radius: 1.1rem; font-size: 1.2rem; font-weight: 800; }
.not-found-card h1 { margin: 0; font-size: 1.6rem; letter-spacing: -.035em; }
.not-found-card p { margin: .7rem 0 1.5rem; color: var(--muted); font-size: .9rem; line-height: 1.6; }
.not-found-link { display: inline-flex; padding: .75rem 1rem; color: #fff; background: var(--violet); border-radius: .8rem; font-size: .85rem; font-weight: 700; text-decoration: none; }
.not-found-link:hover { background: var(--violet-dark); }
