.chat-shell {
  min-height: 100vh;
}

.chat-panel {
  padding: 0;
  overflow: hidden;
}

.chat-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 70vh;
}

.chat-threads {
  border-right: 1px solid #e5e7eb;
  background: #f9fafb;
  display: flex;
  flex-direction: column;
}

.chat-threads-head {
  padding: 16px;
  border-bottom: 1px solid #e5e7eb;
}

.chat-threads-head h2 {
  margin: 0;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
}

.chat-thread-list {
  list-style: none;
  margin: 0;
  padding: 8px;
  overflow-y: auto;
  flex: 1;
}

.chat-thread-empty {
  color: #9ca3af;
  font-size: 13px;
  padding: 12px;
}

.chat-thread-item {
  display: flex;
  align-items: stretch;
  border-radius: 6px;
  margin-bottom: 4px;
}

.chat-thread-item-active,
.chat-thread-item:hover {
  background: #e5edff;
}

.chat-thread-button {
  flex: 1;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 13px;
  color: #1f2937;
  border-radius: 6px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.chat-thread-delete {
  background: transparent;
  border: 0;
  color: #9ca3af;
  cursor: pointer;
  padding: 0 8px;
  font-size: 16px;
  border-radius: 6px;
}

.chat-thread-delete:hover {
  color: #b91c1c;
  background: #fee2e2;
}

.chat-conversation {
  display: flex;
  flex-direction: column;
  min-height: 70vh;
}

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

.chat-empty {
  color: #9ca3af;
  font-size: 14px;
  text-align: center;
  margin-top: 60px;
}

.chat-message {
  max-width: min(900px, 90%);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-message-user {
  align-self: flex-end;
}

.chat-message-assistant {
  align-self: flex-start;
}

.chat-message-meta {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6b7280;
}

.chat-message-body {
  background: #f3f4f6;
  border-radius: 12px;
  padding: 12px 16px;
  white-space: pre-wrap;
  line-height: 1.55;
  color: #1f2937;
  font-size: 14px;
}

.chat-message-user .chat-message-body {
  background: #2563eb;
  color: #fff;
}

.chat-message-error {
  background: #fee2e2 !important;
  color: #991b1b !important;
}

.chat-tool-note {
  font-size: 12px;
  color: #6b7280;
  font-style: italic;
  min-height: 1em;
}

.chat-tool-log {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 4px;
}

.chat-tool-log-entry {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-tool-log-entry[data-state="running"] {
  color: #2563eb;
}

.chat-tool-log-entry[data-state="done"] {
  color: #15803d;
}

.chat-typing {
  display: inline-flex;
  gap: 4px;
  padding: 4px 0;
}

.chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9ca3af;
  animation: chat-typing-bounce 1.2s infinite ease-in-out both;
}

.chat-typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.chat-typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes chat-typing-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

.status[data-kind="busy"]::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border-radius: 50%;
  border: 2px solid #d1d5db;
  border-top-color: #2563eb;
  animation: chat-spin 0.9s linear infinite;
  vertical-align: -1px;
}

@keyframes chat-spin {
  to { transform: rotate(360deg); }
}

.chat-citation {
  color: #2563eb;
  text-decoration: none;
  font-weight: 600;
  padding: 0 2px;
}

.chat-citation:hover {
  text-decoration: underline;
}

.chat-citation-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.chat-citation-chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: #eef2ff;
  color: #1e40af;
  font-size: 12px;
  text-decoration: none;
  border: 1px solid #c7d2fe;
}

.chat-citation-chip:hover {
  background: #c7d2fe;
}

.chat-composer {
  border-top: 1px solid #e5e7eb;
  padding: 12px 16px;
  background: #fff;
}

.chat-composer-disabled {
  opacity: 0.6;
}

.chat-input {
  width: 100%;
  resize: vertical;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  min-height: 56px;
}

.chat-input:focus {
  outline: 2px solid #2563eb;
  outline-offset: 1px;
}

.chat-composer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}

.chat-meta {
  font-size: 12px;
  color: #6b7280;
}

@media (max-width: 720px) {
  .chat-layout {
    grid-template-columns: 1fr;
  }
  .chat-threads {
    display: none;
  }
}
