/* ── Reset / Base ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  background: linear-gradient(135deg, #fdf2f8 0%, #fce7f3 40%, #f3e8ff 100%);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
               Helvetica, Arial, sans-serif;
  color: #1d1d1f;
  margin: 0;
  min-height: 100vh;
}

/* ── Outer wrapper ──────────────────────────────────────────────────────────── */
.app-shell {
  min-height: 100vh;
  padding: 2rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ── Card ───────────────────────────────────────────────────────────────────── */
.app-card {
  width: 100%;
  max-width: 760px;
  background: #ffffff;
  border-radius: 22px;
  box-shadow: 0 4px 32px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Header ─────────────────────────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 26px 18px;
  border-bottom: 1px solid #fce7f3;
  background: linear-gradient(135deg, #fdf2f8, #ffffff);
}

.app-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin: 0;
  color: #c2185b;
}

.app-subtitle {
  font-size: 0.72rem;
  color: #8e8e93;
  margin: 2px 0 0;
}

.btn-restart {
  background: none;
  border: 1.5px solid #fce7f3;
  color: #8e8e93;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 6px 13px;
  border-radius: 20px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.btn-restart:hover {
  border-color: #c2185b;
  color: #c2185b;
  background: #fdf2f8;
}

/* ── Category stepper ──────────────────────────────────────────────────────── */
.topic-stepper {
  display: flex;
  align-items: flex-start;
  padding: 16px 28px 14px;
  background: #fefcfd;
  border-bottom: 1px solid #fce7f3;
}

.topic-step-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.topic-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 700;
  transition: all 0.25s cubic-bezier(.4,0,.2,1);
}

.topic-dot.state-done   { background: #34c759; color: #fff; }
.topic-dot.state-active  {
  background: #c2185b;
  color: #fff;
  box-shadow: 0 0 0 5px rgba(194, 24, 91, 0.12);
}
.topic-dot.state-pending { background: #fce7f3; color: #c2185b; }

.topic-label {
  font-size: 0.58rem;
  font-weight: 500;
  white-space: nowrap;
  transition: color 0.2s;
}
.topic-label.state-done    { color: #34c759; }
.topic-label.state-active  { color: #c2185b; }
.topic-label.state-pending { color: #d4a0b0; }

.topic-connector {
  flex: 1;
  height: 2px;
  margin: 14px 4px 0;
  border-radius: 1px;
  background: #fce7f3;
  transition: background 0.3s;
}
.topic-connector.state-done { background: #34c759; }

/* ── Status / progress bar ─────────────────────────────────────────────────── */
.status-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 26px;
  font-size: 0.73rem;
  color: #8e8e93;
  background: #fefcfd;
  border-bottom: 1px solid #fce7f3;
  min-height: 34px;
}

.status-label { font-weight: 500; }

.progress-track {
  flex: 1;
  height: 4px;
  background: #fce7f3;
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #ec407a, #c2185b);
  border-radius: 2px;
  transition: width 0.4s ease;
}

/* ── Chat area ──────────────────────────────────────────────────────────────── */
.chat-area {
  flex: 1;
  height: 420px;
  overflow-y: auto;
  padding: 22px 24px 10px;
  background: #fff;
  scroll-behavior: smooth;
}

.chat-area::-webkit-scrollbar      { width: 4px; }
.chat-area::-webkit-scrollbar-track { background: transparent; }
.chat-area::-webkit-scrollbar-thumb {
  background: #f0c4d8;
  border-radius: 2px;
}

.chat-empty {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #d4a0b0;
  font-size: 0.8rem;
}

/* Bubble rows */
.bubble-row {
  display: flex;
  margin-bottom: 10px;
}
.bubble-row.assistant { justify-content: flex-start; }
.bubble-row.user       { justify-content: flex-end; }

.bubble {
  max-width: 76%;
  padding: 10px 14px;
  font-size: 0.875rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.bubble.assistant {
  background: #fdf2f8;
  color: #1d1d1f;
  border-radius: 4px 18px 18px 18px;
}
.bubble.user {
  background: #c2185b;
  color: #fff;
  border-radius: 18px 4px 18px 18px;
}

/* Error */
.chat-error {
  background: #fff2f2;
  border: 1px solid #ffcdd2;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 0.8rem;
  color: #c0392b;
  margin-bottom: 10px;
}

/* ── Input area ────────────────────────────────────────────────────────────── */
.input-area {
  padding: 13px 20px 17px;
  border-top: 1px solid #fce7f3;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-skip {
  align-self: flex-end;
  background: none;
  border: none;
  color: #aeaeb2;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  padding: 2px 6px;
  transition: color 0.15s;
}
.btn-skip:hover {
  color: #c2185b;
}
.btn-skip:disabled {
  display: none;
}

.input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  background: #fdf2f8;
  border: 1.5px solid #fce7f3;
  border-radius: 18px;
  padding: 9px 9px 9px 15px;
  transition: border-color 0.2s;
}
.input-wrap:focus-within { border-color: #c2185b; }

.input-wrap .form-control,
.input-wrap textarea {
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  resize: none !important;
  outline: none !important;
  padding: 0 !important;
  font-size: 0.875rem !important;
  line-height: 1.5 !important;
  color: #1d1d1f !important;
  min-height: 24px;
  max-height: 110px;
  overflow-y: auto !important;
}
.input-wrap .form-control::placeholder,
.input-wrap textarea::placeholder { color: #d4a0b0 !important; }

.input-wrap .form-control:focus { border: none !important; box-shadow: none !important; }

.btn-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #c2185b;
  border: none;
  color: #fff;
  font-size: 1.05rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
}
.btn-send:hover:not(:disabled)  { background: #ad1457; transform: scale(1.07); }
.btn-send:active:not(:disabled) { transform: scale(0.97); }
.btn-send:disabled               { background: #e0b0c0; cursor: not-allowed; opacity: 0.7; }

/* ── Option pills ──────────────────────────────────────────────────────────── */
.options-container {
  padding: 0 24px 14px;
}

.options-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: #8e8e93;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

.option-pills-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.option-pill {
  background: #fdf2f8;
  border: 1.5px solid #fce7f3;
  border-radius: 20px;
  padding: 8px 18px;
  font-size: 0.82rem;
  font-weight: 500;
  color: #1d1d1f;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
  line-height: 1.4;
}

.option-pill:hover {
  background: #fce7f3;
  border-color: #f48fb1;
  transform: scale(1.03);
}

.option-pill:active { transform: scale(0.97); }

.option-pill.selected {
  background: #c2185b;
  border-color: #c2185b;
  color: #fff;
}

.option-pill.selected:hover {
  background: #ad1457;
  border-color: #ad1457;
}

.option-pill.option-other {
  background: transparent;
  border-style: dashed;
  border-color: #e0b0c0;
  color: #8e8e93;
}

.option-pill.option-other:hover {
  border-color: #c2185b;
  color: #c2185b;
}

.option-pill.option-skip {
  background: transparent;
  border: 1.5px solid #e5e5ea;
  color: #aeaeb2;
  font-size: 0.75rem;
}

.option-pill.option-skip:hover {
  border-color: #c7c7cc;
  color: #8e8e93;
}

.btn-multi-submit {
  margin-top: 12px;
  background: #c2185b;
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 9px 24px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s, transform 0.1s;
}

.btn-multi-submit:hover:not(:disabled) {
  background: #ad1457;
  transform: scale(1.03);
}

.btn-multi-submit:active:not(:disabled) { transform: scale(0.97); }

.btn-multi-submit:disabled {
  background: #e0b0c0;
  cursor: not-allowed;
  opacity: 0.6;
}

/* ── Completion panel ──────────────────────────────────────────────────────── */
.complete-outer {
  border-top: 1px solid #fce7f3;
  background: linear-gradient(135deg, #fdf2f8, #fce7f3);
  padding: 28px 26px 32px;
  text-align: center;
}

.complete-header {
  font-size: 1.05rem;
  font-weight: 700;
  color: #c2185b;
  margin-bottom: 12px;
}

.complete-text {
  font-size: 0.85rem;
  color: #3d3d3d;
  line-height: 1.6;
  margin: 0;
}

.complete-link {
  color: #c2185b;
  font-weight: 600;
  text-decoration: none;
}

.complete-link:hover {
  text-decoration: underline;
}

/* ── Patient ID card ────────────────────────────────────────────────────────── */
.patient-id-card {
  margin-top: 20px;
  padding: 16px 20px;
  background: #ffffff;
  border: 2px solid #c2185b;
  border-radius: 14px;
  display: inline-block;
  min-width: 240px;
}

.patient-id-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.patient-id-value {
  font-size: 1.45rem;
  font-weight: 700;
  color: #c2185b;
  letter-spacing: 0.06em;
  font-family: "SF Mono", "Fira Mono", "Consolas", monospace;
  margin-bottom: 8px;
}

.patient-id-note {
  font-size: 0.75rem;
  color: #666;
  margin: 0;
  line-height: 1.5;
}

/* ── Header actions group ──────────────────────────────────────────────────── */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-privacy {
  background: none;
  border: 1.5px solid #fce7f3;
  color: #8e8e93;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 6px 13px;
  border-radius: 20px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  white-space: nowrap;
}
.btn-privacy:hover {
  border-color: #c2185b;
  color: #c2185b;
  background: #fdf2f8;
}

/* ── Privacy & Security Panel ──────────────────────────────────────────────── */
.privacy-panel {
  border-bottom: 1px solid #fce7f3;
  background: #fefcfd;
  padding: 22px 26px 26px;
  animation: fadeSlideDown 0.2s ease;
}

@keyframes fadeSlideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.privacy-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 18px;
}

.privacy-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.privacy-icon {
  font-size: 1.3rem;
}

.privacy-title {
  font-size: 1rem;
  font-weight: 700;
  color: #c2185b;
  margin: 0;
}

.btn-privacy-close {
  background: none;
  border: 1.5px solid #fce7f3;
  color: #8e8e93;
  font-size: 0.72rem;
  font-weight: 500;
  padding: 4px 11px;
  border-radius: 16px;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s;
}
.btn-privacy-close:hover {
  border-color: #c2185b;
  color: #c2185b;
}

.privacy-section {
  background: #fff;
  border: 1px solid #fce7f3;
  border-radius: 14px;
  padding: 14px 18px;
  margin-bottom: 12px;
}

.privacy-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: #c2185b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}

.privacy-row {
  display: flex;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 0.82rem;
  line-height: 1.5;
}

.privacy-row:last-child {
  margin-bottom: 0;
}

.privacy-row-label {
  font-weight: 600;
  color: #3d3d3d;
  min-width: 120px;
  flex-shrink: 0;
}

.privacy-row-text {
  color: #5a5a60;
}

.privacy-footer {
  font-size: 0.75rem;
  color: #8e8e93;
  text-align: center;
  margin: 14px 0 0;
  font-style: italic;
}

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 580px) {
  .app-shell { padding: 1rem 0.5rem; }
  .app-card  { border-radius: 16px; }
  .topic-label { font-size: 0.52rem; }
  .option-pills-row { gap: 6px; }
  .option-pill { padding: 6px 14px; font-size: 0.78rem; }
}


/* ── Welcome screen ─────────────────────────────────────────────────────────── */
.welcome-screen {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.welcome-card {
  background: #ffffff;
  border-radius: 22px;
  box-shadow: 0 4px 32px rgba(0, 0, 0, 0.08);
  padding: 2.5rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1.25rem;
}

.welcome-icon {
  font-size: 3rem;
  line-height: 1;
}

.welcome-title {
  font-size: 2rem;
  font-weight: 700;
  color: #c2185b;
  margin: 0;
  letter-spacing: -0.04em;
}

.welcome-subtitle {
  font-size: 0.95rem;
  color: #666;
  margin: 0;
  line-height: 1.5;
}

/* Resume section */
.resume-section {
  width: 100%;
  background: #fdf2f8;
  border-radius: 14px;
  padding: 1.25rem;
  text-align: left;
}

.resume-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #444;
  margin: 0 0 0.6rem 0;
}

.resume-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.resume-code-input {
  flex: 1;
  font-family: "SF Mono", "Menlo", "Consolas", monospace !important;
  font-size: 0.9rem !important;
  letter-spacing: 0.05em;
  border: 1.5px solid #e0c9e0 !important;
  border-radius: 10px !important;
  padding: 8px 12px !important;
  background: #fff !important;
  color: #222 !important;
}

.resume-code-input::placeholder {
  color: #bbb !important;
}

.btn-resume {
  background: #7b1fa2;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 8px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.btn-resume:hover { background: #6a1b9a; }

.resume-error {
  color: #c62828;
  font-size: 0.8rem;
  margin-top: 0.4rem;
  min-height: 1.1em;
}

/* Divider */
.welcome-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.divider-line {
  flex: 1;
  height: 1px;
  background: #e8d5e8;
}

.divider-or {
  color: #999;
  font-size: 0.8rem;
}

/* Start button */
.btn-start-new {
  width: 100%;
  background: linear-gradient(135deg, #c2185b, #ad1457);
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 14px 24px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  letter-spacing: -0.01em;
}

.btn-start-new:hover {
  opacity: 0.9;
  transform: scale(1.01);
}

.welcome-privacy-note {
  font-size: 0.78rem;
  color: #999;
  margin: 0;
}

/* ── Session code banner ─────────────────────────────────────────────────────── */
.session-code-banner {
  padding: 0 26px;
}

.session-code-banner-inner {
  background: #fdf2f8;
  border: 1px solid #f3c6dc;
  border-radius: 10px;
  padding: 8px 14px;
  margin: 10px 0 4px;
  font-size: 0.82rem;
  color: #666;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.banner-label { color: #888; }

.banner-code {
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
  font-weight: 700;
  color: #7b1fa2;
  letter-spacing: 0.05em;
}

.banner-note { color: #aaa; font-size: 0.78rem; }
