:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --border: #2d3a4f;
  --text: #e7ecf3;
  --muted: #8b9cb3;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --human: #1e3a5f;
  --assistant: #1f2937;
  --system: #2a1f0f;
  --success: #22c55e;
  --warning: #f59e0b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app {
  max-width: 820px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

header h1 {
  margin: 0 0 0.75rem;
  font-size: 1.25rem;
  font-weight: 600;
}

.session-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.session-bar label {
  color: var(--muted);
  font-size: 0.875rem;
}

#session-input {
  flex: 1;
  min-width: 180px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}

button {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-size: 0.875rem;
}

button:hover:not(:disabled) { background: var(--accent-hover); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

#approve-btn {
  background: var(--success);
}

.badge {
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge.idle { background: #374151; color: var(--muted); }
.badge.needs_input { background: #78350f; color: #fde68a; }
.badge.completed { background: #14532d; color: #86efac; }
.badge.closed { background: #1e293b; color: var(--muted); }

main {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.msg {
  max-width: 90%;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.assistant { align-self: flex-start; background: var(--assistant); border: 1px solid var(--border); }
.msg.human { align-self: flex-end; background: var(--human); }
.msg.system { align-self: center; background: var(--system); color: #fcd34d; font-size: 0.875rem; max-width: 100%; }

.msg time {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.7rem;
  color: var(--muted);
}

.empty {
  color: var(--muted);
  text-align: center;
  margin-top: 2rem;
}

footer {
  padding: 1rem 1.25rem 1.5rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

#reply-input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  resize: vertical;
  font-family: inherit;
}

.actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.hint {
  margin: 0.75rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.hint code {
  background: var(--bg);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}
