:root {
  color-scheme: light;
  --bg: #eef2f3;
  --panel: #fbfcfc;
  --ink: #16201f;
  --muted: #667370;
  --line: #d7dfdd;
  --user: #0f766e;
  --assistant: #ffffff;
  --accent: #d97706;
  --shadow: 0 18px 60px rgba(22, 32, 31, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.14), transparent 38%),
    linear-gradient(315deg, rgba(217, 119, 6, 0.14), transparent 42%),
    var(--bg);
  color: var(--ink);
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 980px);
  justify-content: center;
  align-items: center;
  gap: 18px;
  padding: 24px;
}

.documents-panel {
  width: 100%;
  height: min(820px, calc(100vh - 48px));
  min-height: 560px;
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(251, 252, 252, 0.94);
  box-shadow: var(--shadow);
}

.documents-panel header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.2;
}

.upload-form {
  display: grid;
  grid-template-columns: 1fr 44px;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.file-picker {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font: inherit;
  font-size: 13px;
  background: #ffffff;
  cursor: pointer;
  overflow: hidden;
}

.file-picker input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.file-picker span {
  display: block;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-form button,
.document-item button {
  width: 44px;
  height: 44px;
}

.document-status {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.document-list {
  overflow-y: auto;
  padding: 10px;
}

.document-item {
  display: grid;
  grid-template-columns: 1fr 36px;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  margin-bottom: 8px;
}

.document-item strong,
.document-item span {
  display: block;
  overflow-wrap: anywhere;
}

.document-item strong {
  font-size: 13px;
}

.document-item span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.document-item button {
  width: 36px;
  height: 36px;
  background: #edf3f1;
  color: #314541;
}

.chat-panel {
  width: min(980px, 100%);
  height: min(820px, calc(100vh - 48px));
  min-height: 560px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(251, 252, 252, 0.94);
  box-shadow: var(--shadow);
}

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #132826;
}

.brand-mark span {
  width: 22px;
  height: 22px;
  border: 4px solid var(--accent);
  border-left-color: #2dd4bf;
  transform: rotate(45deg);
}

h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

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

.status {
  min-width: 84px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  background: #f7faf9;
}

.messages {
  overflow-y: auto;
  padding: 22px;
}

.message {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  align-items: flex-end;
}

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

.avatar {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #e8efed;
  color: #304340;
  font-weight: 700;
  font-size: 12px;
}

.message.user .avatar {
  order: 2;
  background: #cce9e5;
  color: #0f5f59;
}

.bubble {
  max-width: min(720px, 78%);
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--assistant);
  white-space: pre-wrap;
  line-height: 1.5;
  font-size: 15px;
}

.message.user .bubble {
  border-color: transparent;
  background: var(--user);
  color: #ffffff;
}

.composer {
  display: grid;
  grid-template-columns: 1fr 48px;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: #ffffff;
}

textarea {
  width: 100%;
  max-height: 160px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
  color: var(--ink);
  font: inherit;
  line-height: 1.4;
  outline: none;
}

textarea:focus {
  border-color: var(--user);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

button {
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--user);
  color: #ffffff;
  cursor: pointer;
}

.icon-button {
  width: 34px;
  height: 34px;
}

.icon-button svg {
  width: 20px;
  height: 20px;
}

.subtle {
  border: 1px solid var(--line);
  background: #f7faf9;
  color: #314541;
}

button:disabled {
  cursor: wait;
  opacity: 0.55;
}

button svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.sources {
  max-width: min(720px, 78%);
  margin: -6px 0 16px 40px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf9;
}

.sources-title {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.source-item {
  color: #304340;
  font-size: 12px;
  line-height: 1.4;
}

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

  .documents-panel {
    height: auto;
    min-height: 0;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    box-shadow: none;
  }

  .chat-panel {
    height: calc(100vh - 238px);
    min-height: 520px;
    border: 0;
    border-radius: 0;
  }

  .topbar {
    grid-template-columns: auto 1fr auto;
  }

  .status {
    min-width: 72px;
  }

  .messages {
    padding: 16px;
  }

  .bubble {
    max-width: 82%;
  }
}
