/* ── Design tokens ────────────────────────────────────────────────────────── */
:root {
  --bg:            #F2EFE9;
  --card:          #FFFFFF;
  --primary:       #4D7FA8;
  --primary-light: #7BAFD4;
  --primary-dark:  #3A6487;
  --text:          #1C2B3A;
  --text-muted:    #6B7C8D;
  --border:        #D8D3C8;
  --success:       #7BAE89;
  --error-bg:      #FEF2F2;
  --error-border:  #FECACA;
  --error-text:    #B91C1C;
  --info-bg:       #EFF6FF;
  --info-border:   #BFDBFE;
  --radius-card:   20px;
  --radius-btn:    100px;
  --radius-bubble: 16px;
  --radius-input:  10px;
  --shadow-card:   0 4px 40px rgba(28,43,58,0.10);
  --shadow-btn:    0 2px 8px rgba(77,127,168,0.28);
}

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: 'DM Sans', sans-serif;
  font-weight: 400;
  background: var(--bg);
  color: var(--text);
  line-height: 1.72;
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem 4rem;
}

/* ── Card layout ──────────────────────────────────────────────────────────── */
main.card {
  width: 100%;
  max-width: 680px;
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 2.5rem 3rem;
  animation: pageIn 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes pageIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Step dots ────────────────────────────────────────────────────────────── */
.step-dots {
  display: flex;
  justify-content: center;
  gap: 7px;
  margin-bottom: 2rem;
}

.step-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--primary);
  background: transparent;
  transition: background 0.2s;
}

.step-dot.active {
  background: var(--primary);
}

/* ── Privacy hint ─────────────────────────────────────────────────────────── */
.privacy-hint {
  position: absolute;
  bottom: 1.5rem;
  right: 1.5rem;
}

.privacy-hint__btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s;
}

.privacy-hint__btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.privacy-hint__body {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  width: 240px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(28,43,58,0.12);
  padding: 0.85rem 1rem;
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--text);
  z-index: 100;
}

.privacy-hint__body p { margin: 0; }

/* ── Typography ───────────────────────────────────────────────────────────── */
h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text);
  margin-bottom: 0.6rem;
}

h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

p { margin-bottom: 0.85rem; font-size: 0.9375rem; }
p:last-child { margin-bottom: 0; }

.text-muted { color: var(--text-muted); font-size: 0.84rem; }
.hi { color: var(--primary); font-weight: 600; }

hr.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-btn);
  padding: 0.65rem 1.5rem;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, transform 0.15s, opacity 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-btn);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
  box-shadow: 0 4px 14px rgba(77,127,168,0.38);
  transform: translateY(-1px);
}

.btn-secondary {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(77,127,168,0.06);
  transform: translateY(-1px);
}

.btn-danger {
  background: transparent;
  color: #B91C1C;
  border: 1.5px solid #FECACA;
}

.btn-danger:hover:not(:disabled) { background: var(--error-bg); }

.btn-full { width: 100%; }

.btn-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1.25rem;
}

/* ── Form fields ──────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }

input[type="text"],
input[type="email"],
textarea,
select {
  width: 100%;
  font-family: inherit;
  font-size: 0.9375rem;
  color: var(--text);
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-input);
  padding: 0.65rem 0.875rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
}

input[type="text"]:focus,
input[type="email"]:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(77,127,168,0.18);
}

input[type="text"] { height: 2.75rem; }

textarea { resize: vertical; min-height: 80px; }

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.checkbox-row input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  margin-top: 0.25rem;
  flex-shrink: 0;
}

/* ── Alert / notice ───────────────────────────────────────────────────────── */
.alert {
  border-radius: 8px;
  padding: 0.7rem 1rem;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.alert-error {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--error-text);
}

.alert-info {
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  color: #1D4ED8;
}

/* ── Landing page ─────────────────────────────────────────────────────────── */
.landing-hero {
  text-align: center;
  margin-bottom: 2.25rem;
}

.landing-wordmark {
  display: inline-flex;
  margin-bottom: 1.25rem;
}

.landing-form {
  text-align: left;
}

.landing-meta {
  color: var(--text-muted);
  font-size: 0.875rem;
  text-align: center;
  margin-top: 1.25rem;
}

/* ── FAQ accordion ────────────────────────────────────────────────────────── */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 1.25rem 0;
}

.faq-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.faq-item summary {
  list-style: none;
  padding: 0.75rem 1rem;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

.faq-item summary::-webkit-details-marker { display: none; }

.faq-item summary::after {
  content: '+';
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
  margin-left: 0.5rem;
}

.faq-item[open] summary::after {
  transform: rotate(45deg);
}

.faq-body {
  padding: 0 1rem 0.85rem;
  font-size: 0.875rem;
  line-height: 1.65;
  color: var(--text);
}

.faq-body p { margin-bottom: 0.5rem; }
.faq-body p:last-child { margin-bottom: 0; }
.faq-body ul { margin: 0.4rem 0 0.4rem 1.2rem; }

/* ── Chat interface ───────────────────────────────────────────────────────── */
#chat-messages {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.msg {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
}

.msg.user { flex-direction: row-reverse; }

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  background-size: 16px 16px;
  background-repeat: no-repeat;
  background-position: center;
}

/* AI avatar: sparkle icon */
.msg.assistant .msg-avatar {
  background-color: #E8F0F7;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%234D7FA8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 2l2.4 7.4H22l-6.2 4.5 2.4 7.4L12 17l-6.2 4.3 2.4-7.4L2 9.4h7.6z'/%3E%3C/svg%3E");
}

/* User avatar: person silhouette */
.msg.user .msg-avatar {
  background-color: #D4E6F3;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%234D7FA8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='8' r='4'/%3E%3Cpath d='M4 20c0-4 3.6-7 8-7s8 3 8 7'/%3E%3C/svg%3E");
}

.msg-bubble {
  max-width: 80%;
  padding: 0.7rem 1rem;
  border-radius: var(--radius-bubble);
  font-size: 0.9375rem;
  line-height: 1.65;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.assistant .msg-bubble {
  background: #EDEAE3;
  border-bottom-left-radius: 4px;
}

.msg.user .msg-bubble {
  background: var(--primary-light);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Thinking dots */
.thinking-dots {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 0;
}

.thinking-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: thinkPulse 1.2s ease-in-out infinite;
}

.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes thinkPulse {
  0%, 80%, 100% { opacity: 0.25; transform: scale(0.8); }
  40%           { opacity: 1;    transform: scale(1); }
}

/* Typing cursor */
.typing-cursor::after {
  content: '▍';
  display: inline-block;
  animation: blink 0.9s step-end infinite;
  font-size: 0.85em;
  vertical-align: text-bottom;
  margin-left: 1px;
  opacity: 0.7;
}

@keyframes blink { 0%, 100% { opacity: 0.7; } 50% { opacity: 0; } }

/* Chat input bar */
#input-area {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding-top: 0.25rem;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

#chat-input {
  flex: 1;
  height: 2.75rem;
  border-radius: 100px;
  padding: 0 1rem;
}

#send-btn {
  height: 2.75rem;
  padding: 0 1.25rem;
  border-radius: 100px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
  flex-shrink: 0;
}

#send-btn:hover:not(:disabled) {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

#send-btn:disabled { opacity: 0.45; cursor: not-allowed; }

#record-btn {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color 0.15s, background 0.15s;
}

#record-btn:hover:not(:disabled) { border-color: var(--primary); }
#record-btn.recording { border-color: #DC2626; background: #FEF2F2; }
#record-btn:disabled { opacity: 0.45; cursor: not-allowed; }

#near-end-notice {
  font-size: 0.84rem;
  color: var(--text-muted);
  text-align: center;
  padding: 0.5rem 0 0.25rem;
}

#finish-bar {
  text-align: center;
  padding-top: 0.5rem;
}

/* ── Narrative loading ─────────────────────────────────────────────────────── */
.loading-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0;
}

.spinner-ring {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2.5px solid var(--border);
  border-top-color: var(--primary);
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

.loading-label {
  font-size: 0.875rem;
  color: var(--text-muted);
}

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

/* ── Done page ────────────────────────────────────────────────────────────── */
.done-mark {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
}

.done-mark svg {
  display: block;
  background: #EDF5EF;
  border-radius: 50%;
  padding: 10px;
  width: 52px;
  height: 52px;
}

/* Approve bar */
#approve-bar { margin: 1rem 0; }

/* ── Spinner (legacy, keep for any existing use) ──────────────────────────── */
.spinner {
  display: flex;
  gap: 6px;
  justify-content: center;
  padding: 0.5rem 0;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  main.card {
    padding: 2rem;
    margin: 0 0.5rem;
  }
}

@media (max-width: 480px) {
  body {
    padding: 0;
    align-items: stretch;
  }

  main.card {
    border-radius: 0;
    margin: 0;
    min-height: 100dvh;
    padding: 1.5rem 1.25rem;
    box-shadow: none;
  }

  h1 { font-size: 1.3rem; }

  input[type="text"],
  input[type="email"],
  textarea,
  select {
    font-size: 1rem; /* prevent iOS auto-zoom */
  }

  #chat-input { font-size: 1rem; }

  .btn-full { min-height: 44px; }

  .privacy-hint { bottom: 1rem; right: 1rem; }
}
