/* ── Reset ────────────────────────────────────────────────── */

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

:root {
  --bg: #fafaf9;
  --surface: #ffffff;
  --border: #e7e5e4;
  --text: #1c1917;
  --muted: #a8a29e;
  --accent: #1c1917;
  --blue: #2563eb;
  --green: #16a34a;
  --amber: #f59e0b;
  --mono: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Menlo', monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --max-w: 800px;
}

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ───────────────────────────────────────────────── */

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

.header-content {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

h1 {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.brand {
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

/* ── Pipeline ─────────────────────────────────────────────── */

.pipeline {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  overflow-x: auto;
}

.phase {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.375rem;
  min-width: 70px;
  padding: 0 0.25rem;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  transition: all 0.3s;
}

.label {
  font-size: 0.5625rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-align: center;
}

.hitl {
  font-size: 0.4375rem;
  padding: 0.0625rem 0.25rem;
  border-radius: 2px;
  background: #dbeafe;
  color: #1e40af;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.connector {
  width: 20px;
  height: 2px;
  background: var(--border);
  margin-bottom: 1.5rem;
  flex-shrink: 0;
}

.phase.active .dot { border-color: var(--blue); background: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,0.15); }
.phase.active .label { color: var(--blue); font-weight: 600; }
.phase.complete .dot { border-color: var(--green); background: var(--green); }
.phase.complete .label { color: var(--green); }
.phase.inactive .dot { background: var(--bg); }

/* ── Main ─────────────────────────────────────────────────── */

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: var(--max-w);
  width: 100%;
  margin: 0 auto;
  padding: 0 2rem;
}

/* ── Status ───────────────────────────────────────────────── */

.status-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 0;
  font-size: 0.8125rem;
  color: var(--muted);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}

.status-dot.active {
  background: var(--blue);
  animation: pulse 2s infinite;
}

@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.3; } }

/* ── Conversation ─────────────────────────────────────────── */

.conversation {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Empty state */
.empty-state {
  margin: 4rem 0;
  text-align: center;
}

.empty-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.375rem;
}

.empty-sub {
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
}

/* Messages */
.msg {
  max-width: 100%;
}

.msg-who {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.msg-body {
  font-size: 0.9375rem;
  line-height: 1.75;
}

.msg-body h3 { font-size: 1rem; font-weight: 600; margin: 1rem 0 0.375rem; }
.msg-body h4 { font-size: 0.9375rem; font-weight: 600; margin: 0.75rem 0 0.25rem; }
.msg-body strong { font-weight: 600; }
.msg-body li { margin-left: 1.25rem; list-style: disc; }
.msg-body p { margin-bottom: 0.5rem; }

.msg-user {
  background: var(--accent);
  color: white;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  max-width: 80%;
  align-self: flex-end;
  margin-left: auto;
}

.msg-user .msg-who { color: rgba(255,255,255,0.5); }
.msg-user .msg-body { font-size: 0.875rem; }

.msg-assistant {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.msg-system {
  text-align: center;
  padding: 0.5rem 0;
}

.msg-system-text {
  font-size: 0.75rem;
  color: var(--muted);
  font-family: var(--mono);
}

/* ── Input ────────────────────────────────────────────────── */

.input-area {
  border-top: 1px solid var(--border);
  padding: 1rem 0 1.5rem;
  background: var(--bg);
  position: sticky;
  bottom: 0;
}

.input-area textarea {
  width: 100%;
  font-family: var(--sans);
  font-size: 0.9375rem;
  line-height: 1.6;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  resize: none;
  outline: none;
  transition: border-color 0.2s;
}

.input-area textarea:focus {
  border-color: var(--blue);
}

.input-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.5rem;
}

.input-hint {
  font-size: 0.6875rem;
  color: var(--muted);
}

/* ── Button ───────────────────────────────────────────────── */

.btn {
  font-family: var(--sans);
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.5rem 1.25rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn:hover { opacity: 0.85; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Responsive ───────────────────────────────────────────── */

@media (max-width: 640px) {
  main { padding: 0 1rem; }
  .header-content { padding: 0 1rem; }
  .phase { min-width: 50px; }
  .label { font-size: 0.5rem; }
  .hitl { display: none; }
  .msg-user { max-width: 90%; }
}
