*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #ffffff;
  --text: #111111;
  --muted: #666666;
  --border: #e0e0e0;
  --accent: #1a1a1a;
  --radius: 10px;
  --gap: 1.5rem;
}

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  padding: 0;
  min-height: 100vh;
}

/* ── Layout ─────────────────────────────────────────────────────────────────── */
.page {
  max-width: 680px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

/* ── Header ─────────────────────────────────────────────────────────────────── */
.site-header {
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
}
.back-link {
  display: inline-block;
  font-size: 0.8rem;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 0.5rem;
}
.back-link:hover { color: var(--accent); }
.site-header h1 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--accent);
}
.site-header .sub {
  font-size: 0.875rem;
  color: var(--muted);
  margin-top: 0.2rem;
}
.session-badge {
  display: inline-block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

/* ── Greeting ───────────────────────────────────────────────────────────────── */
.greeting {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  letter-spacing: -0.02em;
}

/* ── Fluency badge ───────────────────────────────────────────────────────────── */
.fluency-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: #f0f0f0;
  color: #444;
  border-radius: 4px;
  padding: 0.2rem 0.55rem;
  margin-bottom: 1.5rem;
}
.fluency-badge.hidden { display: none; }

/* ── Trio rows (DREAM / PROTOTYPE / DEMO) ────────────────────────────────────── */
.trio-section { margin-bottom: 1rem; }
.trio-row {
  display: flex;
  gap: 1rem;
  align-items: baseline;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
}
.trio-row:first-child { border-top: 1px solid var(--border); }
.trio-label {
  flex: 0 0 100px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding-top: 0.1rem;
}
.trio-value {
  flex: 1;
  font-size: 0.95rem;
  color: var(--text);
}
.trio-setup-link {
  font-size: 0.9rem;
  color: var(--muted);
  font-style: italic;
}
.trio-setup-link a { color: inherit; }

/* ── Card ───────────────────────────────────────────────────────────────────── */
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1.25rem;
  margin-bottom: 0.9rem;
}
.card h2 {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.75rem;
}
.card-body {
  font-size: 0.95rem;
  color: var(--text);
  margin-bottom: 1rem;
  white-space: pre-wrap;
}
.card-empty {
  font-size: 0.9rem;
  color: var(--muted);
  font-style: italic;
}
.card-locked {
  font-size: 0.9rem;
  color: var(--muted);
}
.card-locked strong { color: var(--text); }

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn-row { display: flex; gap: 0.75rem; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 8px;
  padding: 0.55rem 1.1rem;
  cursor: pointer;
  border: 1px solid transparent;
  background: none;
  transition: background 0.12s, box-shadow 0.12s;
  line-height: 1;
  text-decoration: none;
  color: inherit;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
}
.btn-primary:hover { background: #333; }
.btn-secondary {
  background: #f3f3f3;
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: #e8e8e8; }
.btn-ghost {
  font-size: 0.8rem;
  color: var(--muted);
  padding: 0.3rem 0.5rem;
  text-decoration: underline;
  cursor: pointer;
  background: none;
  border: none;
}

/* ── What you came in with ──────────────────────────────────────────────────── */
details.came-in-with {
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}
details.came-in-with summary {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  list-style: none;
}
details.came-in-with summary::-webkit-details-marker { display: none; }
details.came-in-with summary::before { content: '+ '; }
details[open].came-in-with summary::before { content: '- '; }
.came-in-item {
  margin-top: 0.75rem;
  font-size: 0.9rem;
}
.came-in-item .label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  display: block;
  margin-bottom: 0.15rem;
}

/* ── Past sessions ──────────────────────────────────────────────────────────── */
.past-sessions { margin-bottom: 0.75rem; }
.past-sessions summary {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  list-style: none;
  margin-bottom: 0.4rem;
}
.past-sessions summary::-webkit-details-marker { display: none; }
.past-sessions summary::before { content: '+ '; }
details[open].past-sessions summary::before { content: '- '; }
.past-obj {
  font-size: 0.875rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 0.75rem;
}
.past-obj-n {
  flex: 0 0 40px;
  font-weight: 600;
  color: var(--muted);
  font-size: 0.75rem;
}

/* ── Chat ───────────────────────────────────────────────────────────────────── */
#chat-panel {
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 0.75rem;
}
#messages {
  padding: 1.25rem;
  min-height: 180px;
  max-height: 50vh;
  overflow-y: auto;
  background: #fafafa;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.msg {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  max-width: 90%;
}
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.assistant { align-self: flex-start; }
.msg-role {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.msg-text {
  font-size: 0.9rem;
  background: #f0f0f0;
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  white-space: pre-wrap;
  line-height: 1.55;
}
.msg.user .msg-text { background: var(--accent); color: #fff; }
.msg-stream .msg-text::after {
  content: '▋';
  animation: blink 0.9s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* Submit confirm card */
#submit-confirm {
  display: none;
  margin: 0.75rem 1.25rem;
  background: #fffbf0;
  border: 1px solid #e8d58a;
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}
#submit-confirm.show { display: block; }
#submit-confirm p { font-size: 0.9rem; margin-bottom: 0.75rem; }
#submit-confirm .btn-row { gap: 0.5rem; }

/* Chat input area */
.chat-input-area {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  background: #fff;
}
#chat-input {
  flex: 1;
  font-family: inherit;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.8rem;
  resize: none;
  outline: none;
  min-height: 2.5rem;
  max-height: 8rem;
  overflow-y: auto;
  line-height: 1.4;
}
#chat-input:focus { border-color: #999; }
#chat-send {
  flex: 0 0 auto;
  align-self: flex-end;
}
.btn-mic {
  flex: 0 0 auto;
  align-self: flex-end;
  background: #fff;
  color: #333;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
}
.btn-mic:hover { background: #f5f5f5; }
.btn-mic.recording {
  background: #c0392b;
  color: #fff;
  border-color: #c0392b;
  animation: mic-pulse 1.2s ease-in-out infinite;
}
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(192, 57, 43, 0.5); }
  50%      { box-shadow: 0 0 0 6px rgba(192, 57, 43, 0); }
}

/* Build Plan heading (introduces the plan+prompt report) */
.build-plan-heading {
  margin: 0 0 1.25rem;
  padding: 0.9rem 1rem;
  border-left: 3px solid #111;
  background: #fafafa;
  border-radius: 0 8px 8px 0;
}
.build-plan-title {
  font-size: 1rem;
  margin: 0 0 0.25rem;
  color: #111;
  letter-spacing: -0.005em;
}
.build-plan-blurb {
  font-size: 0.85rem;
  color: #555;
  margin: 0;
  line-height: 1.45;
}

/* Handoff prompt (post-lock copy-to-LLM panel) */
.handoff-prompt {
  margin-top: 2rem;
  padding: 1.25rem 1.25rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fafafa;
  text-align: left;
}
.handoff-title {
  font-size: 1rem;
  margin: 0 0 0.5rem;
  color: #222;
}
.handoff-blurb {
  font-size: 0.85rem;
  color: #555;
  margin: 0 0 0.85rem;
  line-height: 1.45;
}
.handoff-actions {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.handoff-copy-btn.copied {
  background: #2e7d32;
  border-color: #2e7d32;
}
.handoff-pre {
  background: #1e1e1e;
  color: #eaeaea;
  padding: 0.9rem 1rem;
  border-radius: 8px;
  font-size: 0.78rem;
  line-height: 1.5;
  max-height: 20rem;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

/* Chat done state */
#chat-done {
  padding: 2rem 1.5rem 2.5rem;
  text-align: center;
  border-top: 1px solid var(--border);
  background: #fff;
}
.chat-done-icon {
  font-size: 2rem;
  color: #2a7a2a;
  margin-bottom: 0.75rem;
  line-height: 1;
}
.chat-done-heading {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.6rem;
  letter-spacing: -0.01em;
}
.chat-done-text {
  font-size: 0.95rem;
  color: var(--muted);
  font-style: italic;
  margin-bottom: 0.75rem;
  line-height: 1.5;
}
.chat-done-sub {
  font-size: 0.875rem;
  color: var(--muted);
}

/* ── Builder name list (landing page) ───────────────────────────────────────── */
.builder-list {
  list-style: none;
  max-width: 400px;
  margin: 0 auto;
  padding: 0;
}
.builder-list-item {
  border-bottom: 1px solid var(--border);
}
.builder-list-item:first-child {
  border-top: 1px solid var(--border);
}
.builder-list-item a {
  display: block;
  padding: 0.9rem 0.5rem;
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  transition: background 0.1s;
}
.builder-list-item a:hover {
  background: #f5f5f5;
  padding-left: 1rem;
}

/* ── Landing page ───────────────────────────────────────────────────────────── */
.landing-hero {
  text-align: center;
  padding: 3rem 1rem 2rem;
}
.landing-hero h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 0.4rem;
}
.landing-hero p {
  font-size: 1rem;
  color: var(--muted);
  margin-bottom: 2rem;
}
.email-form {
  max-width: 400px;
  margin: 0 auto;
}
.email-form input[type="email"] {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  outline: none;
}
.email-form input[type="email"]:focus { border-color: #999; }
.email-form button {
  width: 100%;
  font-size: 1rem;
  padding: 0.75rem;
}
.form-status {
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--muted);
  text-align: center;
}
.form-status.error { color: #c00; }

/* ── Footer ─────────────────────────────────────────────────────────────────── */
footer {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--muted);
}

/* ── Utility ────────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
