:root {
  --fg: #1b1b1f;
  --muted: #5c5f66;
  --bg: #fafafa;
  --card: #ffffff;
  --border: #e2e3e7;
  --accent: #2f6feb;
  --danger: #c0392b;
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--fg);
  background: var(--bg);
  margin: 0;
  line-height: 1.5;
}

nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

nav a { color: var(--accent); text-decoration: none; font-weight: 600; }
nav .spacer { flex: 1; }
nav form { margin: 0; }

main { max-width: 1600px; margin: 0 auto; padding: 1.5rem; }
main.shell { max-width: none; padding: 0; margin: 0; display: flex; height: calc(100vh - 53px); overflow: hidden; }

/* Shell panels */
.shell-chat {
  width: 50%;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  overflow: hidden;
}
#chat-transcript {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.chat-msg { display: flex; flex-direction: column; gap: 0.15rem; }
.chat-msg.user { align-items: flex-end; }
.chat-msg.assistant { align-items: flex-start; }
.chat-bubble {
  max-width: 90%;
  padding: 0.5rem 0.75rem;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
}
.chat-msg.user .chat-bubble { background: var(--accent); color: #fff; border-bottom-right-radius: 3px; }
.chat-msg.assistant .chat-bubble { background: #f0f2f5; color: var(--fg); border-bottom-left-radius: 3px; }

/* Assistant bubbles render markdown — block layout instead of pre-wrap. */
.chat-msg.assistant .chat-bubble { white-space: normal; }
/* Error line on a failed turn — shown even after partial output. */
.chat-msg.assistant .chat-bubble p.chat-error { color: var(--danger); font-size: 0.85rem; }
.chat-msg.assistant .chat-bubble p.chat-recovery {
  color: var(--muted);
  font-size: 0.85rem;
}
.turn-progress {
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.78rem;
  white-space: normal;
}
.turn-recover {
  margin-left: 0.45rem;
  padding: 0.18rem 0.45rem;
  font-size: 0.75rem;
}
.turn-recovery-detail {
  color: var(--muted);
  font-size: 0.8rem;
}
.chat-msg.assistant .chat-bubble p { margin: 0 0 0.55rem; }
.chat-msg.assistant .chat-bubble p:last-child { margin-bottom: 0; }
.chat-msg.assistant .chat-bubble h1,
.chat-msg.assistant .chat-bubble h2,
.chat-msg.assistant .chat-bubble h3,
.chat-msg.assistant .chat-bubble h4 { font-size: 0.95rem; margin: 0.7rem 0 0.3rem; }
.chat-msg.assistant .chat-bubble h1:first-child,
.chat-msg.assistant .chat-bubble h2:first-child,
.chat-msg.assistant .chat-bubble h3:first-child { margin-top: 0; }
.chat-msg.assistant .chat-bubble ul,
.chat-msg.assistant .chat-bubble ol { margin: 0 0 0.55rem; padding-left: 1.25rem; }
.chat-msg.assistant .chat-bubble li { margin: 0.15rem 0; }
.chat-msg.assistant .chat-bubble code { background: #e4e7ec; border-radius: 3px; padding: 0.05em 0.3em; font-size: 0.85em; }
.chat-msg.assistant .chat-bubble pre { margin: 0 0 0.55rem; padding: 0.5rem; font-size: 0.8rem; }
.chat-msg.assistant .chat-bubble pre code { background: none; padding: 0; }
.chat-msg.assistant .chat-bubble hr { border: none; border-top: 1px solid var(--border); margin: 0.7rem 0; }
.chat-msg.assistant .chat-bubble a { color: var(--accent); }
.chat-suggestions {
  padding: 0.4rem 0.75rem 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.chat-suggestions[hidden] { display: none; }
.suggestion-chip {
  font-size: 0.82rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-input-area {
  border-top: 1px solid var(--border);
  padding: 0.75rem;
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}
.chat-mic-status {
  padding: 0 0.75rem 0.75rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.chat-mic-indicator {
  flex-shrink: 0;
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.chat-mic-indicator[hidden] { display: none; }
.chat-mic-dot {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: #d3382f;
  animation: chat-mic-pulse 1.2s ease-in-out infinite;
}
@keyframes chat-mic-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.75); }
}
.chat-mic-timer {
  color: var(--muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}
#chat-input {
  flex: 1;
  min-height: 2.5rem;
  max-height: 8rem;
  resize: none;
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font: inherit;
  border: 1px solid var(--border);
  overflow-y: auto;
}
#chat-mic {
  align-items: center;
  flex-shrink: 0;
  justify-content: center;
  align-self: flex-end;
  display: inline-flex;
  min-width: 2.5rem;
  padding-left: 0.7rem;
  padding-right: 0.7rem;
}
#chat-send { flex-shrink: 0; align-self: flex-end; }

.shell-content {
  width: 50%;
  overflow-y: auto;
  padding: 1.5rem 2rem;
}
.shell-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  color: var(--muted);
  gap: 0.5rem;
}
.shell-welcome p { font-size: 1rem; margin: 0; }

/* Right panel content types */
.panel-section { margin-bottom: 1.5rem; }
.panel-title { font-size: 1.4rem; font-weight: 700; margin: 0 0 0.25rem; }
.panel-subtitle { color: var(--muted); margin: 0 0 1rem; font-size: 0.95rem; }
.panel-downloads { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.75rem; }
.panel-downloads a { display: inline-flex; align-items: center; gap: 0.4rem; font-weight: 600; }

@media (max-width: 900px) {
  main.shell { flex-direction: column; height: auto; }
  .shell-chat { width: 100%; height: 55dvh; min-height: 20rem; border-right: none; border-bottom: 1px solid var(--border); }
  .shell-content { width: 100%; min-height: 14rem; padding: 1rem; }

  nav { flex-wrap: wrap; gap: 0.5rem 0.85rem; padding: 0.6rem 0.85rem; }
  nav .spacer { display: none; }
  nav form { margin-left: auto; }

  .chat-bubble { max-width: 96%; }
  .panel-title { font-size: 1.2rem; }

  /* iOS zooms the page when a focused input's font is under 16px. */
  #chat-input, input[type="text"], input[type="password"] { font-size: 16px; }
}

h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; margin-top: 1.5rem; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin: 1rem 0;
}

label { display: block; margin: 0.5rem 0; font-weight: 600; }
input[type="text"], input[type="password"], textarea, input:not([type]) {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
}
textarea { min-height: 8rem; resize: vertical; }

button, .btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
button.secondary, .btn.secondary { background: #6b7280; }

ul.list { list-style: none; padding: 0; }
ul.list li { padding: 0.5rem 0; border-bottom: 1px solid var(--border); }

pre {
  background: #f4f4f6;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem;
  overflow-x: auto;
  white-space: pre-wrap;
}

.error { color: var(--danger); font-weight: 600; }
.muted { color: var(--muted); }

/* Rich prose rendering for the profile (profile page + live interview panel) */
.profile-prose { line-height: 1.7; }
.profile-prose h1 { font-size: 1.8rem; margin: 1.5rem 0 0.5rem; border-bottom: 2px solid var(--border); padding-bottom: 0.4rem; }
.profile-prose h2 { font-size: 1.35rem; margin: 2rem 0 0.4rem; color: var(--fg); }
.profile-prose h3 { font-size: 1.1rem; margin: 1.25rem 0 0.3rem; color: var(--muted); font-weight: 700; }
.profile-prose h4 { font-size: 1rem; margin: 1rem 0 0.25rem; font-weight: 700; }
.profile-prose p { margin: 0.5rem 0 0.75rem; }
.profile-prose ul, .profile-prose ol { padding-left: 1.5rem; margin: 0.5rem 0 0.75rem; }
.profile-prose li { margin: 0.3rem 0; }
.profile-prose li + li { margin-top: 0.25rem; }
.profile-prose strong { color: var(--fg); }
.profile-prose hr { border: none; border-top: 1px solid var(--border); margin: 1.75rem 0; }
.profile-prose code { background: #f4f4f6; border-radius: 3px; padding: 0.1em 0.35em; font-size: 0.9em; }
.profile-prose blockquote { border-left: 3px solid var(--accent); margin: 1rem 0; padding: 0.5rem 1rem; color: var(--muted); background: #f7f9ff; border-radius: 0 6px 6px 0; }

/* Chat progress states */
.typing { display: inline-flex; gap: 4px; align-items: center; padding: 2px 0; }
.typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--muted); opacity: 0.4;
  animation: typing-bounce 1.2s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}
.stream-cursor { animation: cursor-blink 1s steps(1) infinite; color: var(--muted); }
@keyframes cursor-blink { 50% { opacity: 0; } }

/* Fit analysis structured sections */
.fit-section { margin: 1rem 0; padding: 0.75rem 1rem; border-radius: 6px; border-left: 4px solid; }
.fit-section .fit-label { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 0.4rem; }
.fit-summary  { border-color: var(--accent); background: #f0f5ff; }
.fit-summary .fit-label { color: var(--accent); }
.fit-strengths { border-color: #16a34a; background: #f0fdf4; }
.fit-strengths .fit-label { color: #16a34a; }
.fit-gaps     { border-color: #d97706; background: #fffbeb; }
.fit-gaps .fit-label { color: #d97706; }
.fit-disqualifiers { border-color: var(--danger); background: #fff5f5; }
.fit-disqualifiers .fit-label { color: var(--danger); }
.fit-section .profile-prose { margin: 0; }
.fit-section .profile-prose p:last-child,
.fit-section .profile-prose ul:last-child { margin-bottom: 0; }

/* Interview split-screen layout */
.interview-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 760px) {
  .interview-split { grid-template-columns: 1fr; }
}
.interview-right h2 { margin-top: 0; font-size: 1rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
#live-profile { min-height: 6rem; }

#transcript {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  min-height: 12rem;
  max-height: 50vh;
  overflow-y: auto;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}
.msg { margin: 0.5rem 0; }
.msg .role { font-weight: 700; text-transform: capitalize; }
.msg.user { color: #1b1b1f; }
.msg.assistant { color: #16407a; }

