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

/* ─── Tokens ─────────────────────────────────────────────────── */
:root {
  --bg:          #0a0a0a;
  --bg-card:     #111111;
  --bg-card-alt: #161616;
  --border:      #1e1e1e;
  --border-mid:  #2a2a2a;
  --text:        #e8e8e8;
  --text-muted:  #666;
  --text-dim:    #333;
  --accent:      #5b8def;
  --accent-glow: rgba(91,141,239,0.15);
  --accent-dark: #3b6dcf;
  --green:       #3ecf8e;
  --amber:       #f0a04b;
  --radius:      10px;
  --radius-sm:   6px;
  --shadow:      0 1px 3px rgba(0,0,0,0.4), 0 4px 16px rgba(0,0,0,0.3);
  --font-sans:   -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --max-w:       740px;

  /* Persona accent colours */
  --p0: #5b8def;
  --p1: #3ecf8e;
  --p2: #f0a04b;
}

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── App shell ───────────────────────────────────────────── */
.app { display: flex; flex-direction: column; min-height: 100vh; }

/* ─── Header ──────────────────────────────────────────────── */
.header {
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  position: sticky; top: 0;
  background: rgba(10,10,10,0.92);
  backdrop-filter: blur(12px);
  z-index: 10;
}

.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.logo { display: flex; align-items: center; gap: 8px; }
.logo-icon { font-size: 18px; color: var(--accent); }
.logo-text { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }

.header-nav { display: flex; align-items: center; flex-shrink: 0; gap: 0; }

/* Phase tracker */
.phase-track {
  display: flex;
  align-items: center;
  gap: 0;
  flex-shrink: 1;
  overflow: hidden;
}

.phase-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--border-mid);
  transition: background 0.3s;
  flex-shrink: 0;
}

.phase-dot.active   { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.phase-dot.complete { background: var(--green); }

.phase-line {
  width: 24px; height: 1px;
  background: var(--border-mid);
  flex-shrink: 0;
}

/* ─── Main ────────────────────────────────────────────────── */
.main {
  flex: 1;
  max-width: var(--max-w);
  width: 100%;
  margin: 0 auto;
  padding: 48px 24px 64px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ─── Phase sections ──────────────────────────────────────── */
.phase { display: flex; flex-direction: column; gap: 20px; }

.phase-header { display: flex; flex-direction: column; gap: 8px; margin-bottom: 4px; }

.phase-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
}

.phase-title {
  font-size: clamp(22px, 4vw, 32px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.phase-sub {
  font-size: 14px;
  color: var(--text-muted);
  max-width: 520px;
}

/* ─── Card ────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

/* ─── Fields ──────────────────────────────────────────────── */
.field-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.field-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1.5;
}

.textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.15s;
  resize: vertical;
  line-height: 1.6;
  min-height: 60px;
}

.textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ─── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  white-space: nowrap;
  font-family: var(--font-sans);
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-mid);
}
.btn-ghost:hover { background: var(--bg-card-alt); color: var(--text); }

.btn-row { display: flex; justify-content: flex-end; margin-top: 14px; }

.error-msg { font-size: 12px; color: #e05a5a; margin-top: 8px; }

/* ─── Persona grid ────────────────────────────────────────── */
.persona-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.persona-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  overflow: hidden;
}

.persona-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}

.persona-avatar {
  font-size: 32px;
  line-height: 1;
}

.persona-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.persona-role {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: -8px;
}

.persona-detail-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 4px;
}

.persona-detail-text {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

.persona-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.persona-tag {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid;
  font-weight: 600;
}

/* ─── Active persona card ─────────────────────────────────── */
.active-persona-card {
  display: flex;
  align-items: center;
  gap: 20px;
  border-left: 3px solid var(--accent);
}

.active-persona-avatar { font-size: 40px; flex-shrink: 0; }

.active-persona-info { flex: 1; }
.active-persona-name { font-size: 18px; font-weight: 700; }
.active-persona-role { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.active-persona-context { font-size: 12px; color: var(--text-muted); margin-top: 6px; line-height: 1.5; }

/* ─── Interview thread ────────────────────────────────────── */
.interview-thread {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.interview-bubble {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.interview-bubble-role {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
}

.bubble-persona .interview-bubble-role { color: var(--accent); }
.bubble-you .interview-bubble-role     { color: var(--green); }

.interview-bubble-body {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  font-size: 14px;
  line-height: 1.75;
}

.bubble-persona .interview-bubble-body { border-left: 3px solid var(--accent); }
.bubble-you .interview-bubble-body {
  border-left: 3px solid var(--green);
  background: var(--bg-card-alt);
  color: var(--text-muted);
  font-style: italic;
}

.followup-card { margin-top: 4px; }

/* ─── Loading ─────────────────────────────────────────────── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 40px;
  color: var(--text-muted);
  font-size: 14px;
}

.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border-mid);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Output ──────────────────────────────────────────────── */
.output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.output-content {
  font-size: 14px;
  line-height: 1.8;
}

.output-content h2 {
  font-size: 20px; font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.output-content h3 {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
  margin: 22px 0 8px;
}

.output-content p { color: var(--text); margin-bottom: 10px; }

.output-content ul, .output-content ol {
  padding-left: 20px;
  margin-bottom: 10px;
}

.output-content li { color: var(--text); margin-bottom: 4px; }

.output-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
  font-size: 13px;
}

.output-content th {
  background: var(--bg-card-alt);
  color: var(--text-muted);
  font-weight: 600;
  text-align: left;
  padding: 8px 12px;
  border: 1px solid var(--border);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.output-content td {
  padding: 8px 12px;
  border: 1px solid var(--border);
  color: var(--text);
  vertical-align: top;
}

.output-content tr:nth-child(even) td { background: rgba(255,255,255,0.02); }
.output-content strong { color: var(--text); font-weight: 600; }

.output-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  gap: 12px;
}

/* ─── Footer ──────────────────────────────────────────────── */
.footer {
  text-align: center;
  padding: 24px;
  font-size: 12px;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
}

.footer a { color: var(--text-muted); }
.footer a:hover { color: var(--text); }

/* ─── Utility ─────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ─── Responsive ──────────────────────────────────────────── */
@media (max-width: 860px) {
  .phase-track { display: none; }
}

@media (max-width: 640px) {
  .main { padding: 32px 16px 48px; }
  .persona-grid { grid-template-columns: 1fr; }
  .active-persona-card { flex-direction: column; align-items: flex-start; }
}
