#chat-wrapper {
  display: flex;
  flex-direction: column;
  max-width: 820px;
  margin: 0 auto;
  padding: 1rem 0 0;
  height: calc(100vh - 260px);
  min-height: 400px;
}

#setup-panel {
  padding-bottom: 1rem;
}

#webgpu-status {
  margin-bottom: 0.4rem;
  font-size: 0.9em;
}

#kb-status {
  font-size: 0.83em;
  color: #555;
  margin-bottom: 0.75rem;
}

#webgpu-ok  { color: #2a7a2a; }
#webgpu-err { color: #c00; }

#model-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

#model-select {
  flex: 1;
  min-width: 220px;
  padding: 0.45rem 0.6rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.95em;
  background: #fff;
}

#load-btn,
#send-btn {
  background: #A7A1F4;
  color: #363644;
  border: none;
  border-radius: 6px;
  padding: 0.5rem 1.3rem;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95em;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.15s;
}

#load-btn:hover:not(:disabled),
#send-btn:hover:not(:disabled) {
  background: #C1F7AE;
}

#load-btn:disabled,
#send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#progress-container {
  margin-top: 0.75rem;
}

#progress-track {
  width: 100%;
  height: 8px;
  background: #e0e0e0;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.35rem;
}

#progress-fill {
  height: 100%;
  background: #A7A1F4;
  width: 0%;
  transition: width 0.25s ease;
}

#progress-text {
  font-size: 0.83em;
  color: #555;
  margin: 0;
}

#messages {
  flex: 1;
  overflow-y: auto;
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 1rem;
  background: #fafafa;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.message {
  display: flex;
  flex-direction: column;
}

.message.user      { align-items: flex-end; }
.message.assistant { align-items: flex-start; }

.bubble {
  max-width: 75%;
  padding: 0.6rem 0.95rem;
  border-radius: 14px;
  font-size: 0.95em;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.message.user .bubble {
  background: #A7A1F4;
  color: #363644;
  border-bottom-right-radius: 4px;
}

.message.assistant .bubble {
  background: #C1F7AE;
  color: #363644;
  border-bottom-left-radius: 4px;
}

.sources {
  max-width: 75%;
  font-size: 0.75em;
  color: #777;
  margin-top: 0.15rem;
  padding: 0 0.3rem;
}

.sources summary {
  cursor: pointer;
  list-style: none;
  color: #999;
}

.sources summary::-webkit-details-marker { display: none; }

.sources-list {
  margin-top: 0.2rem;
  padding: 0.3rem 0.6rem;
  border-left: 2px solid #A7A1F4;
  line-height: 1.6;
}

#input-area {
  display: none;
  gap: 0.5rem;
  padding-top: 0.75rem;
  align-items: flex-end;
}

#user-input {
  flex: 1;
  padding: 0.55rem 0.8rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95em;
  resize: none;
  min-height: 44px;
  max-height: 120px;
  line-height: 1.45;
  overflow-y: auto;
}

#user-input:focus {
  outline: none;
  border-color: #A7A1F4;
  box-shadow: 0 0 0 2px rgba(167,161,244,0.3);
}
