:root {
  color-scheme: light;
  --accent: #69b4bd;
  --accent-dark: #438f99;
  --text: #27333a;
  --muted: #7a878d;
  --line: #e5eaec;
  --surface: #ffffff;
  --background: #f6f8f9;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--text);
  background: var(--background);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

.chat-shell {
  width: 100%;
  height: 100%;
  min-height: 560px;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  background: var(--surface);
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 14px 66px 14px 20px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  color: white;
  background: var(--accent);
  font-size: 13px;
  font-weight: 750;
  letter-spacing: .4px;
}

.chat-header h1 { margin: 0 0 2px; font-size: 17px; }
.chat-header p { margin: 0; color: var(--muted); font-size: 13px; }
.chat-header p.context-ready { color: var(--accent-dark); }
.context-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: #b5bec2;
}
.context-ready .context-dot { background: #38a46b; }
.context-empty .context-dot { background: #df9b35; }
.context-banner {
  width: min(760px, 100%);
  margin: 0 auto 20px;
  padding: 10px 14px;
  border: 1px solid #dce7e9;
  border-radius: 10px;
  color: #68777d;
  background: #f7fafb;
  font-size: 13px;
  text-align: center;
}
.context-banner.ready {
  color: #327a59;
  border-color: #cce8d9;
  background: #f1faf5;
}
.new-chat {
  margin-left: auto;
  flex: 0 0 auto;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  background: white;
  cursor: pointer;
}
.new-chat:hover { border-color: var(--accent); color: var(--accent-dark); }

.mode-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 20px 0;
  border-bottom: 1px solid var(--line);
  background: white;
}
.mode-tab {
  position: relative;
  padding: 10px 13px 12px;
  border: 0;
  color: var(--muted);
  background: transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.mode-tab::after {
  content: '';
  position: absolute;
  right: 10px;
  bottom: -1px;
  left: 10px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: transparent;
}
.mode-tab:hover { color: var(--text); }
.mode-tab.active { color: var(--accent-dark); }
.mode-tab.active::after { background: var(--accent); }

.messages {
  overflow-y: auto;
  padding: 28px max(24px, calc((100% - 760px) / 2));
  scroll-behavior: smooth;
}

.welcome { margin: 8vh auto 0; max-width: 440px; text-align: center; }
.welcome-icon { color: var(--accent-dark); font-size: 34px; }
.welcome h2 { margin: 12px 0 8px; font-size: 25px; }
.welcome p { margin: 0; color: var(--muted); line-height: 1.55; }

.message { display: flex; margin: 0 0 22px; }
.message.user { justify-content: flex-end; }
.bubble {
  max-width: 82%;
  padding: 12px 15px;
  border-radius: 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.52;
  font-size: 15px;
}
.user .bubble { color: #1f383c; background: #dff1f3; border-bottom-right-radius: 5px; }
.assistant .bubble { padding-left: 0; background: transparent; }
.assistant.loading .bubble { color: var(--muted); }
.message-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.message-sources a {
  padding: 5px 8px;
  border: 1px solid #dce7e9;
  border-radius: 8px;
  color: var(--accent-dark);
  background: #f7fafb;
  font-size: 12px;
  text-decoration: none;
}
.message-sources a:hover { border-color: var(--accent); }

.composer {
  position: relative;
  width: min(760px, calc(100% - 32px));
  margin: 0 auto 18px;
  padding: 12px 52px 27px 15px;
  border: 1px solid #d8dfe2;
  border-radius: 17px;
  background: white;
  box-shadow: 0 5px 20px rgba(31, 52, 60, .07);
}
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(105,180,189,.14); }
textarea {
  display: block;
  width: 100%;
  max-height: 150px;
  resize: none;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font: inherit;
  line-height: 1.45;
}
textarea::placeholder { color: #98a3a8; }
#send {
  position: absolute;
  right: 10px;
  bottom: 22px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  color: white;
  background: var(--accent);
  cursor: pointer;
}
#send:hover { background: var(--accent-dark); }
#send:disabled { opacity: .45; cursor: default; }
#send svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.hint { position: absolute; left: 15px; bottom: 7px; color: #9aa5a9; font-size: 11px; }

@media (max-width: 600px) {
  .chat-header { padding: 12px 58px 12px 14px; }
  .new-chat { font-size: 12px; }
  .mode-tabs { padding-left: 10px; }
  .messages { padding: 22px 16px; }
  .bubble { max-width: 92%; }
}
