*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, sans-serif;
  background: #f4f6f9;
  height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: stretch;
}

#app {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 720px;
  background: #fff;
  box-shadow: 0 0 20px rgba(0,0,0,.08);
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #e5e7eb;
}

header h1 { font-size: 1.1rem; font-weight: 600; }

#clear-btn {
  font-size: .8rem;
  padding: .35rem .75rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}

#clear-btn:hover { background: #f3f4f6; }

#chat-window {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.msg {
  max-width: 80%;
  padding: .65rem 1rem;
  border-radius: 12px;
  line-height: 1.5;
  font-size: .9rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.user {
  align-self: flex-end;
  background: #2563eb;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg.assistant {
  align-self: flex-start;
  background: #f1f5f9;
  color: #1e293b;
  border-bottom-left-radius: 4px;
}

.msg.loading { opacity: .5; font-style: italic; }

#chat-form {
  display: flex;
  gap: .5rem;
  padding: .75rem 1rem;
  border-top: 1px solid #e5e7eb;
}

#input {
  flex: 1;
  resize: none;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: .6rem .8rem;
  font-size: .9rem;
  font-family: inherit;
  line-height: 1.4;
}

#input:focus { outline: none; border-color: #2563eb; }

#send-btn {
  padding: .6rem 1.2rem;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: .9rem;
  cursor: pointer;
  align-self: flex-end;
}

#send-btn:hover { background: #1d4ed8; }
#send-btn:disabled { background: #93c5fd; cursor: not-allowed; }
