:root {
  color-scheme: light;
  --bg: #eef2f5;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #627386;
  --line: #d7e0e8;
  --accent: #0e7c66;
  --accent-dark: #075949;
  --bot: #f4f7f9;
  --user: #0e7c66;
  --danger: #a33b2f;
}

* {
  box-sizing: border-box;
}

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

.app-shell {
  width: min(1120px, calc(100vw - 32px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
  align-items: center;
  padding: 24px 0;
}

.chat-panel,
.api-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 45px rgba(31, 48, 66, 0.08);
}

.chat-panel {
  height: min(760px, calc(100vh - 48px));
  min-height: 560px;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  overflow: hidden;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 22px;
}

h2 {
  font-size: 18px;
}

.status {
  flex: 0 0 auto;
  color: var(--accent-dark);
  background: #e5f4ef;
  border: 1px solid #b9dfd4;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 13px;
}

.status.error {
  color: var(--danger);
  background: #fff1ef;
  border-color: #f0c2bc;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 20px;
  overflow-y: auto;
}

.message {
  max-width: min(78%, 680px);
  border-radius: 8px;
  padding: 10px 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message p {
  margin: 0;
}

.message.bot {
  align-self: flex-start;
  background: var(--bot);
  border: 1px solid var(--line);
}

.message.user {
  align-self: flex-end;
  background: var(--user);
  color: #ffffff;
}

.composer {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: #fbfcfd;
}

.composer input,
.composer button,
.file-button {
  min-height: 44px;
  border-radius: 8px;
  font: inherit;
}

.composer input {
  width: 100%;
  border: 1px solid var(--line);
  padding: 0 12px;
  outline: none;
}

.composer input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 124, 102, 0.14);
}

.composer button,
.file-button {
  border: 0;
  padding: 0 18px;
  color: #ffffff;
  background: var(--accent);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.clear-button {
  background: #52616f;
}

.composer button:disabled,
.file-button:has(input:disabled) {
  opacity: 0.6;
  cursor: wait;
}

.attachment-preview {
  padding: 0 14px 12px;
  color: var(--muted);
  background: #fbfcfd;
  font-size: 13px;
}

.api-panel {
  padding: 18px;
}

.api-panel p {
  color: var(--muted);
  line-height: 1.5;
}

pre {
  margin: 16px 0 0;
  padding: 14px;
  overflow-x: auto;
  background: #17202a;
  color: #f8fafc;
  border-radius: 8px;
  font-size: 13px;
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .chat-panel {
    height: calc(100vh - 48px);
  }

  .api-panel {
    display: none;
  }

  .message {
    max-width: 88%;
  }

  .composer {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .clear-button {
    display: none;
  }
}
