:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #18202a;
  --muted: #6a7482;
  --line: #dfe4ea;
  --accent: #167c80;
  --accent-dark: #0d5f62;
  --warn: #8a5a00;
  --source: #eef7f5;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
textarea {
  font: inherit;
}

.shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  border-left: 1px solid var(--line);
  background: #fbfcfd;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: white;
  border-radius: 8px;
  font-weight: 800;
  font-size: 22px;
}

h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
}

p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.status {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 14px;
}

.status div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  min-width: 0;
}

.status span {
  color: var(--muted);
  font-size: 13px;
}

.status strong {
  overflow-wrap: anywhere;
  text-align: left;
  direction: ltr;
  font-size: 13px;
}

.examples {
  display: grid;
  gap: 10px;
}

.examples button {
  text-align: right;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
}

.examples button:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.chat {
  min-width: 0;
  display: grid;
  grid-template-rows: 1fr auto;
  height: 100vh;
}

.messages {
  overflow-y: auto;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message {
  display: flex;
}

.message.user {
  justify-content: flex-start;
}

.message.assistant {
  justify-content: flex-end;
}

.bubble {
  width: min(780px, 100%);
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 16px;
  line-height: 1.75;
  white-space: pre-wrap;
}

.message.user .bubble {
  background: #eaf3ff;
  border-color: #cfe2fb;
}

.sources {
  margin-top: 14px;
  display: grid;
  gap: 8px;
}

.source {
  background: var(--source);
  border: 1px solid #cce5df;
  border-radius: 8px;
  padding: 10px;
  font-size: 13px;
}

.source strong {
  display: block;
  margin-bottom: 4px;
}

.source p {
  font-size: 12px;
  line-height: 1.6;
}

.composer {
  display: grid;
  grid-template-columns: 1fr 96px;
  gap: 12px;
  padding: 18px 28px 24px;
  border-top: 1px solid var(--line);
  background: rgba(251, 252, 253, 0.92);
}

.followups {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 0;
}

.followups:empty {
  display: none;
}

.followups button {
  border: 1px solid #cce5df;
  background: var(--source);
  color: var(--accent-dark);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 13px;
}

.followups button:hover {
  border-color: var(--accent);
}

textarea {
  resize: none;
  min-height: 52px;
  max-height: 160px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
  outline: none;
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(22, 124, 128, 0.12);
}

.composer button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  cursor: pointer;
}

.composer button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.error .bubble {
  border-color: #e6c56f;
  background: #fff8e7;
  color: var(--warn);
}

@media (max-width: 820px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-left: 0;
    border-bottom: 1px solid var(--line);
    padding: 16px;
  }

  .examples {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chat {
    height: calc(100vh - 310px);
    min-height: 520px;
  }

  .messages {
    padding: 18px;
  }

  .composer {
    grid-template-columns: 1fr;
    padding: 14px 18px 18px;
  }

  .composer button {
    height: 44px;
  }
}
