* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: #0f1115;
  color: #e6e6e6;
  height: 100vh;
}

.view { height: 100%; display: flex; flex-direction: column; }
.hidden { display: none !important; }

#login-form {
  margin: auto;
  width: 320px;
  max-width: 90vw;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
}

#login-form h1 { font-size: 1.3rem; margin-bottom: 0; }
.hint { color: #9aa0a6; font-size: 0.85rem; margin-top: 0; }

input, button {
  font-size: 1rem;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #2a2d34;
  background: #1a1d23;
  color: #e6e6e6;
}

button {
  cursor: pointer;
  background: #3a6df0;
  border-color: #3a6df0;
  color: white;
}
button:hover { background: #2f5cd6; }

.error { color: #ff6b6b; min-height: 1.2em; font-size: 0.9rem; }

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg { max-width: 75%; padding: 10px 14px; border-radius: 12px; line-height: 1.4; overflow-wrap: anywhere; }
.msg.plain { white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: #3a6df0; color: white; }
.msg.assistant { align-self: flex-start; background: #1a1d23; border: 1px solid #2a2d34; }
.msg.pending { opacity: 0.6; }

.msg :first-child { margin-top: 0; }
.msg :last-child { margin-bottom: 0; }
.msg p, .msg ul, .msg ol, .msg blockquote, .msg pre, .msg h1, .msg h2, .msg h3, .msg h4 { margin: 0 0 8px; }
.msg ul, .msg ol { padding-left: 1.2em; }
.msg li { margin-bottom: 4px; }
.msg h1, .msg h2, .msg h3, .msg h4 { line-height: 1.3; }
.msg h1 { font-size: 1.25em; }
.msg h2 { font-size: 1.15em; }
.msg h3, .msg h4 { font-size: 1.05em; }
.msg blockquote { border-left: 3px solid #3a6df0; padding-left: 10px; color: #b8bcc4; }
.msg.user blockquote { border-left-color: rgba(255, 255, 255, 0.6); color: rgba(255, 255, 255, 0.85); }
.msg hr { border: none; border-top: 1px solid #2a2d34; margin: 8px 0; }
.msg table { border-collapse: collapse; margin: 0 0 8px; }
.msg th, .msg td { border: 1px solid #2a2d34; padding: 4px 8px; }
.msg code {
  font-family: ui-monospace, Consolas, monospace;
  background: rgba(255, 255, 255, 0.1);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.9em;
}
.msg pre { background: rgba(255, 255, 255, 0.06); padding: 10px 12px; border-radius: 8px; overflow-x: auto; }
.msg pre code { background: none; padding: 0; }
.msg.user code { background: rgba(0, 0, 0, 0.2); }
.msg.user pre { background: rgba(0, 0, 0, 0.15); }
.msg a { color: #7aa2ff; }
.msg.user a { color: #dbe6ff; }

#chat-form {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #2a2d34;
}
#chat-form input { flex: 1; }
