:root {
  --bg: #fafaf8;
  --text: #1a1a1a;
  --muted: #6b6b6b;
  --accent: #2d5a4a;
  --accent-soft: #e8f0ed;
  --border: #e5e2dc;
  --serif: "Lora", Georgia, serif;
  --sans: "Inter", system-ui, sans-serif;
  --fail: #8b3a3a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  padding-bottom: 2.5rem;
}

.hidden { display: none !important; }

.app, .gate {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 0;
}

h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.5rem;
  margin: 0;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.header-actions { display: flex; gap: 0.75rem; }

.conversation {
  min-height: 40vh;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding-bottom: 1rem;
}

.msg-user {
  align-self: flex-end;
  max-width: 85%;
  background: var(--accent-soft);
  padding: 0.75rem 1rem;
  border-radius: 12px 12px 4px 12px;
  font-family: var(--serif);
}

.msg-assistant { width: 100%; }

.consensus-block {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  margin-bottom: 0.75rem;
}

.consensus-block h3 {
  font-family: var(--serif);
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.consensus-text {
  font-family: var(--serif);
  white-space: pre-wrap;
}

.mind-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0.5rem;
  overflow: hidden;
}

.mind-header {
  padding: 0.6rem 0.9rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  background: #fff;
}

.mind-header:hover { background: #fafafa; }

.mind-meta { color: var(--muted); font-size: 12px; }

.mind-body {
  display: none;
  padding: 0 0.9rem 0.9rem;
  font-family: var(--serif);
  white-space: pre-wrap;
}

.mind-card.open .mind-body { display: block; }

.mind-card.failed .mind-header { color: var(--fail); }

.single-reply {
  font-family: var(--serif);
  white-space: pre-wrap;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
}

.composer {
  position: sticky;
  bottom: 2.5rem;
  background: var(--bg);
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.composer-controls {
  display: flex;
  gap: 1.25rem;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 13px;
  color: var(--muted);
}

.minds-picker button {
  border: 1px solid var(--border);
  background: white;
  border-radius: 4px;
  width: 1.75rem;
  height: 1.75rem;
  margin: 0 0.1rem;
  cursor: pointer;
  font-family: var(--sans);
}

.minds-picker button.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.composer-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

#messageInput {
  flex: 1;
  font-family: var(--serif);
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  resize: vertical;
  min-height: 2.5rem;
  background: white;
}

button.primary {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 0.55rem 1.1rem;
  cursor: pointer;
  font-family: var(--sans);
}

button.secondary {
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
}

button.text-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
  padding: 0;
}

button.burn { color: var(--fail); }

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

.status-line {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 0.45rem 1rem;
}

.status-line.busy { color: var(--accent); }
.status-line.error { color: var(--fail); }

.feedback-section, .history-controls {
  margin-top: 1.25rem;
  font-size: 14px;
}

.feedback-body label {
  display: block;
  margin: 0.5rem 0;
}

.feedback-actions { margin-top: 0.75rem; display: flex; gap: 1rem; }

.gate {
  min-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gate-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  width: min(360px, 90vw);
}

.gate-card input {
  width: 100%;
  margin: 1rem 0;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.error { color: var(--fail); font-size: 13px; }
.muted { color: var(--muted); }

.meta details {
  margin-top: 0.5rem;
  font-size: 12px;
  color: var(--muted);
}

.timing { font-size: 12px; color: var(--muted); margin-top: 0.35rem; }

dialog {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  max-width: 480px;
}

#historyList { list-style: none; padding: 0; max-height: 300px; overflow: auto; }
#historyList li { padding: 0.4rem 0; border-bottom: 1px solid var(--border); cursor: pointer; }

.working {
  color: var(--muted);
  font-style: italic;
  padding: 0.5rem 0;
}
