:root {
  --bg: #fafaf7;
  --fg: #1a1a1a;
  --muted: #555;
  --border: #d4d4d0;
  --user-bg: #eef1f4;
  --ward-bg: #f6f3ed;
  --accent: #2a4a3a;
  --error: #8b1a1a;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

h1 {
  font-size: 1.4rem;
  font-weight: 600;
  margin: 0 0 1rem;
}

label {
  display: block;
  margin-bottom: 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
}

input,
textarea {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem 0.6rem;
  font: inherit;
  color: var(--fg);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
}

textarea {
  resize: vertical;
  min-height: 3.5rem;
}

button {
  font: inherit;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#login-error {
  margin-top: 0.75rem;
  color: var(--error);
  font-size: 0.9rem;
}

.chat-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}

.chat-header button {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 0.3rem 0.7rem;
  font-size: 0.85rem;
}

#chat-messages {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.message-user,
.message-ward,
.message-system {
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.message-user {
  background: var(--user-bg);
  align-self: flex-end;
  max-width: 85%;
}

.message-ward {
  background: var(--ward-bg);
  align-self: flex-start;
  max-width: 95%;
}

.message-system {
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  align-self: center;
}

.message-user pre,
.message-ward pre {
  margin: 0;
  font: inherit;
  white-space: pre-wrap;
  word-wrap: break-word;
}

#chat-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
