:root {
  color: #17242c;
  background: #edf2f4;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  --blue: #0b5b82;
  --blue-dark: #103f5e;
  --line: #d5e0e5;
  --muted: #5d6b73;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body { margin: 0; }

button, textarea, input { font: inherit; }

button { cursor: pointer; }

.topbar {
  height: 64px;
  padding: 0 max(20px, calc((100% - 980px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--blue-dark);
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
}

.secondary {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 13px;
  color: var(--blue-dark);
  background: #fff;
  border: 1px solid #b9cbd3;
  border-radius: 9px;
  font-weight: 600;
}

.secondary:hover { background: #f2f7f9; }
.secondary:disabled { cursor: default; opacity: .45; }
.secondary svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 2; }

.chat-shell {
  height: calc(100% - 64px);
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
}

.messages {
  width: min(900px, 100%);
  margin: 0 auto;
  padding: 42px 22px 30px;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.welcome {
  display: flex;
  gap: 17px;
  max-width: 760px;
  margin: 8vh auto 30px;
  padding: 28px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 14px 40px rgba(16, 63, 94, .07);
}

.welcome h1 { margin: 1px 0 10px; color: var(--blue-dark); font-size: clamp(23px, 4vw, 30px); }
.welcome p { margin: 0; color: #44545d; line-height: 1.6; }

.assistant-avatar {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 12px;
  object-fit: cover;
}

.message-row { display: flex; gap: 12px; margin: 0 0 25px; }
.message-row.user { justify-content: flex-end; }

.bubble {
  max-width: min(720px, 88%);
  padding: 13px 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.55;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 5px 17px 17px 17px;
}

.user .bubble {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
  border-radius: 17px 17px 5px 17px;
}

.bubble.pending::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 17px;
  margin-left: 3px;
  vertical-align: -3px;
  background: var(--blue);
  animation: blink 1s steps(2, start) infinite;
}

@keyframes blink { 50% { opacity: 0; } }

.composer-wrap {
  padding: 8px 20px 14px;
  background: linear-gradient(0deg, #edf2f4 75%, rgba(237, 242, 244, 0));
}

.composer {
  width: min(850px, 100%);
  min-height: 58px;
  margin: 0 auto;
  padding: 8px;
  display: flex;
  align-items: flex-end;
  gap: 7px;
  background: #fff;
  border: 1px solid #bdccd3;
  border-radius: 17px;
  box-shadow: 0 8px 28px rgba(16, 63, 94, .1);
}

.composer:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(11, 91, 130, .12), 0 8px 28px rgba(16, 63, 94, .1); }

#files { display: none; }

.attach, .send {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  border-radius: 11px;
}

.attach { color: var(--blue-dark); cursor: pointer; }
.attach:hover { background: #eef5f7; }
.attach svg, .send svg { width: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

#message {
  max-height: 180px;
  min-height: 41px;
  flex: 1;
  padding: 9px 5px 7px;
  resize: none;
  color: #17242c;
  background: transparent;
  border: 0;
  outline: 0;
  line-height: 1.45;
}

#message::placeholder { color: #78858c; }

.send { color: #fff; background: var(--blue); border: 0; }
.send:hover:not(:disabled) { background: var(--blue-dark); }
.send:disabled { cursor: default; opacity: .35; }

.file-list {
  width: min(850px, 100%);
  margin: 0 auto 7px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.file-chip {
  max-width: 260px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  color: #31434d;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
}

.file-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip button { padding: 0; color: var(--muted); background: none; border: 0; font-size: 18px; line-height: 1; }

.hint { margin: 7px auto 0; color: var(--muted); font-size: 11px; text-align: center; }

.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;
}

@media (max-width: 600px) {
  .topbar { height: 58px; padding: 0 14px; }
  .chat-shell { height: calc(100% - 58px); }
  .secondary { padding: 8px; }
  #new-chat { font-size: 0; }
  #new-chat svg { width: 21px; }
  .messages { padding: 22px 13px 20px; }
  .welcome { margin-top: 3vh; padding: 20px; }
  .welcome .assistant-avatar { display: none; }
  .composer-wrap { padding: 7px 10px 10px; }
  .bubble { max-width: 93%; }
}

@media (prefers-reduced-motion: reduce) {
  .bubble.pending::after { animation: none; }
}
