:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --border: #2d3a4d;
  --text: #e7ecf3;
  --muted: #8b9cb3;
  --accent: #3d9eff;
  --accent-dim: #2563b8;
  --user-bg: #243044;
  --bot-bg: #1e2a3a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 1rem 2rem;
}

h1 {
  font-size: 1.35rem;
  font-weight: 600;
  margin: 0 0 0.25rem;
  letter-spacing: -0.02em;
}

.sub {
  color: var(--muted);
  font-size: 0.875rem;
  margin-bottom: 1.25rem;
}

.panel {
  width: 100%;
  max-width: 640px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  min-height: 420px;
  max-height: min(70vh, 560px);
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.toolbar {
  display: flex;
  justify-content: flex-end;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  gap: 0.5rem;
}

.toolbar a {
  color: var(--muted);
  font-size: 0.8125rem;
  text-decoration: none;
}

.toolbar a:hover {
  color: var(--accent);
}

#log {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.msg {
  max-width: 92%;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  line-height: 1.45;
  font-size: 0.9375rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.user {
  align-self: flex-end;
  background: var(--user-bg);
  border: 1px solid var(--border);
}

.msg.bot {
  align-self: flex-start;
  background: var(--bot-bg);
  border: 1px solid var(--border);
}

.msg .label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.composer {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
}

#input {
  flex: 1;
  resize: none;
  min-height: 44px;
  max-height: 120px;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

#input:focus {
  outline: none;
  border-color: var(--accent-dim);
}

#send {
  padding: 0 1.1rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #0a0e14;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.875rem;
}

#send:hover:not(:disabled) {
  filter: brightness(1.08);
}

#send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.err {
  color: #f87171;
  font-size: 0.8125rem;
  padding: 0 0.75rem 0.75rem;
  display: none;
}

.err.visible {
  display: block;
}

.hint {
  margin-top: 1rem;
  font-size: 0.8125rem;
  color: var(--muted);
  max-width: 640px;
  text-align: center;
  line-height: 1.5;
}
