:root {
  --bg: #f5f6fb;
  --bg-accent: #eef0fb;
  --card-bg: #ffffff;
  --text: #1c2033;
  --muted: #6b7183;
  --border: #e6e8f0;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0fe;
  --accent-contrast: #ffffff;
  --success: #16a34a;
  --success-soft: #e9f8ef;
  --error: #dc2626;
  --error-soft: #fdecec;
  --user-bubble: #4f46e5;
  --user-bubble-text: #ffffff;
  --assistant-bubble: #f1f2f8;
  --assistant-bubble-text: #1c2033;
  --shadow-sm: 0 1px 2px rgba(20, 22, 40, 0.05);
  --shadow-md: 0 10px 30px rgba(20, 22, 40, 0.06);
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-full: 999px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(180deg, var(--bg-accent) 0%, var(--bg) 320px);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.1rem 1.75rem;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.user-info { display: flex; align-items: center; gap: 0.9rem; font-size: 0.9rem; }
.participant-id {
  color: var(--muted);
  font-size: 0.78rem;
  padding: 0.15rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
}
.user-name { color: var(--muted); }
.logout-link { color: var(--muted); text-decoration: none; }
.logout-link:hover { color: var(--text); text-decoration: underline; }

/* Progress stepper / breadcrumb */
.stepper {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.9rem 1.75rem;
  background: rgba(255, 255, 255, 0.6);
  border-bottom: 1px solid var(--border);
}

.step {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.step-icon { width: 0.85rem; height: 0.85rem; flex-shrink: 0; }

.step-active {
  background: var(--accent);
  color: var(--accent-contrast);
  box-shadow: var(--shadow-sm);
}

.step-completed {
  background: var(--success-soft);
  color: var(--success);
}
a.step-completed:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }

.step-locked {
  background: transparent;
  color: #a3a7b7;
  cursor: not-allowed;
}

.step-sep {
  width: 1.1rem;
  height: 1px;
  background: var(--border);
  flex-shrink: 0;
}

.container {
  max-width: 760px;
  margin: 2.5rem auto;
  padding: 0 1.25rem;
}

/* Chat page gets a much wider container - the chat card itself fills it. */
.chat-page .container {
  max-width: 80vw;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 2rem 2.25rem;
}

.card.centered {
  max-width: 420px;
  margin: 4rem auto;
}

/* Login/signup: no topbar, so center the card in the full viewport. */
body.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

body.auth-page .container {
  margin: 0;
}

body.auth-page .card.centered {
  margin: 0;
}

.eyebrow {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.4rem;
}

h1 { margin-top: 0; font-size: 1.6rem; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; color: var(--muted); font-weight: 500; }

form label {
  display: block;
  margin-bottom: 1.1rem;
  font-weight: 500;
  font-size: 0.92rem;
}

input, textarea, button {
  font: inherit;
}

input[type="text"], input[type="email"], input[type="password"], textarea {
  width: 100%;
  margin-top: 0.4rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fbfbfe;
  color: var(--text);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: #fff;
}

button {
  padding: 0.65rem 1.25rem;
  border: none;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease, transform 0.05s ease;
}

button:hover { background: var(--accent-hover); }
button:active { transform: translateY(1px); }

button.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  white-space: nowrap;
}
button.secondary:hover { background: var(--bg-accent); }

.link-button {
  display: inline-block;
  margin-top: 0.75rem;
  padding: 0.65rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.link-button:hover { background: var(--bg-accent); }

fieldset {
  border: none;
  padding: 1rem 0 1.1rem;
  margin: 0 0 0.25rem;
  border-bottom: 1px solid var(--border);
}
fieldset:first-of-type { padding-top: 0; }

legend {
  font-weight: 500;
  margin-bottom: 0.6rem;
  padding: 0;
  width: 100%;
}

.likert {
  display: flex;
  gap: 0.6rem;
}

.likert-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-weight: 400;
  margin-bottom: 0;
}

.likert-option input {
  accent-color: var(--accent);
  width: 1.1rem;
  height: 1.1rem;
}

.google-form-embed {
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 1.25rem;
}

.confirm-checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 400;
  margin-bottom: 1rem;
}

.likert-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.35rem;
}

.muted { color: var(--muted); }

.flash-list { margin-bottom: 1rem; }

.flash {
  padding: 0.65rem 0.95rem;
  border-radius: var(--radius-md);
  margin-bottom: 0.5rem;
  background: var(--assistant-bubble);
  font-size: 0.9rem;
}

.flash-error { background: var(--error-soft); color: var(--error); }

/* Chat */
.chat-card {
  max-width: 100%;
  display: flex;
  flex-direction: column;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}
.chat-header h1 { margin-bottom: 0.15rem; }
.chat-header form { margin: 0; }

.chat-log {
  flex: 1;
  min-height: 60vh;
  max-height: 68vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
  margin-bottom: 1rem;
  background: #fafbfe;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.chat-msg { display: flex; flex-direction: column; max-width: 78%; }
.chat-user { align-self: flex-end; align-items: flex-end; }
.chat-assistant { align-self: flex-start; align-items: flex-start; }

.chat-role {
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
  padding: 0 0.2rem;
}

.chat-bubble {
  padding: 0.7rem 1rem;
  border-radius: 14px;
  white-space: pre-wrap;
  line-height: 1.5;
  font-size: 0.95rem;
}

.chat-user .chat-bubble {
  background: var(--user-bubble);
  color: var(--user-bubble-text);
  border-bottom-right-radius: 4px;
}
.chat-assistant .chat-bubble {
  background: var(--assistant-bubble);
  color: var(--assistant-bubble-text);
  border-bottom-left-radius: 4px;
}

.chat-time {
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 0.2rem;
  padding: 0 0.2rem;
}

#chat-form {
  display: flex;
  gap: 0.6rem;
  align-items: flex-end;
}

#chat-form textarea { flex: 1; resize: vertical; min-height: 3rem; }
