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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f0f2f5;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 680px;
  height: 80vh;
  min-height: 400px;
  overflow: hidden;
}

/* ── Header ── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid #e5e7eb;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

/* Change 1: TF logo mark */
.logo-mark {
  width: 30px;
  height: 30px;
  background: #2563eb;
  color: #fff;
  border-radius: 7px;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

header h1 {
  font-size: 1.05rem;
  font-weight: 600;
  color: #111827;
}

.header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

#end-sim-btn {
  font-size: 0.8rem;
  padding: 0.35rem 0.75rem;
  border: 1px solid #f97316;
  border-radius: 6px;
  background: transparent;
  color: #ea580c;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

#end-sim-btn.hidden {
  display: none;
}

#end-sim-btn:hover {
  background: #fff7ed;
  color: #c2410c;
}

#reset-btn {
  font-size: 0.8rem;
  padding: 0.35rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

#reset-btn:hover {
  background: #f3f4f6;
  color: #374151;
}

/* ── Message row with clarify button ── */
.message-row {
  display: flex;
  align-items: flex-start;
  align-self: flex-start;
  gap: 0.35rem;
  max-width: 80%;
}

.message-row .message.assistant {
  align-self: auto;
  max-width: 100%;
}

.clarify-btn {
  flex-shrink: 0;
  width: 1.35rem;
  height: 1.35rem;
  margin-top: 0.5rem;
  background: #e5e7eb;
  color: #6b7280;
  border: none;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
}

.message-row:hover .clarify-btn {
  opacity: 1;
}

.clarify-btn:hover {
  background: #d1d5db;
  color: #374151;
}

/* ── Chat log ── */
#chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.message {
  max-width: 75%;
  padding: 0.65rem 0.9rem;
  border-radius: 12px;
  line-height: 1.5;
  font-size: 0.95rem;
  white-space: pre-wrap;
}

.message.user {
  align-self: flex-end;
  background: #2563eb;
  color: #fff;
  border-bottom-right-radius: 3px;
}

.message.assistant {
  align-self: flex-start;
  background: #f3f4f6;
  color: #111827;
  border-bottom-left-radius: 3px;
}

/* ── Status bar ── */
#status-bar {
  padding: 0.4rem 1.25rem;
  font-size: 0.8rem;
  color: #6b7280;
  border-top: 1px solid #f3f4f6;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

#status-bar.hidden {
  display: none;
}

#status-bar::before {
  content: '🔊';
  font-size: 0.85rem;
}

/* ── Input area (Change 1: pill layout) ── */
.input-row {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.65rem 1rem 0.75rem;
  border-top: 1px solid #e5e7eb;
}

/* Side buttons outside the pill */
#upload-trigger-btn,
#mic-btn {
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  padding: 0;
}

#upload-trigger-btn:hover,
#mic-btn:hover {
  background: #e5e7eb;
}

#mic-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Pill form */
#chat-form {
  flex: 1;
  display: flex;
  align-items: flex-end;
  gap: 0.35rem;
  background: #f3f4f6;
  border: 1.5px solid #e5e7eb;
  border-radius: 24px;
  padding: 0.45rem 0.45rem 0.45rem 1rem;
  transition: border-color 0.15s;
}

#chat-form:focus-within {
  border-color: #2563eb;
}

#user-input {
  flex: 1;
  resize: none;
  border: none;
  background: transparent;
  padding: 0.3rem 0;
  font-size: 0.95rem;
  font-family: inherit;
  line-height: 1.5;
  outline: none;
  max-height: 120px;
  overflow-y: auto;
}

#send-btn {
  flex-shrink: 0;
  padding: 0.4rem 0.9rem;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 18px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
  align-self: flex-end;
}

#send-btn:hover {
  background: #1d4ed8;
}

#send-btn:disabled {
  background: #93c5fd;
  cursor: not-allowed;
}

#stop-btn {
  flex-shrink: 0;
  padding: 0.4rem 0.65rem;
  background: #fee2e2;
  color: #b91c1c;
  border: none;
  border-radius: 18px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
  align-self: flex-end;
}

#stop-btn:hover {
  background: #fecaca;
}

#stop-btn.hidden {
  display: none;
}

/* Change 5: upload confirm banner */
#upload-confirm-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  background: #eff6ff;
  border-top: 1px solid #bfdbfe;
  font-size: 0.875rem;
  color: #1e40af;
  gap: 0.75rem;
}

#upload-confirm-banner.hidden {
  display: none;
}

#upload-confirm-filename {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-confirm-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

#upload-confirm-yes,
#upload-confirm-cancel {
  padding: 0.3rem 0.75rem;
  border-radius: 6px;
  border: none;
  font-size: 0.8rem;
  cursor: pointer;
  font-weight: 500;
}

#upload-confirm-yes {
  background: #2563eb;
  color: #fff;
}

#upload-confirm-yes:hover {
  background: #1d4ed8;
}

#upload-confirm-cancel {
  background: #e5e7eb;
  color: #374151;
}

#upload-confirm-cancel:hover {
  background: #d1d5db;
}

/* ── Decision buttons (A/B/C options) ── */
#decision-buttons {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.5rem 0 0.25rem 0.25rem;
}

.decision-btn {
  padding: 0.5rem 1.1rem;
  background: #fff;
  color: #2563eb;
  border: 1.5px solid #2563eb;
  border-radius: 20px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: normal;
  text-align: left;
}

.decision-btn:hover {
  background: #2563eb;
  color: #fff;
}

/* ── Panic bar ── */
#panic-bar {
  padding: 0.5rem 1rem;
  border-top: 1px solid #fee2e2;
  background: #fff5f5;
  display: flex;
  justify-content: center;
}

#panic-bar.hidden {
  display: none;
}

#panic-btn {
  padding: 0.45rem 1.2rem;
  background: #fff;
  color: #dc2626;
  border: 1.5px solid #dc2626;
  border-radius: 20px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

#panic-btn:hover {
  background: #dc2626;
  color: #fff;
}

/* ── Panic suggestions ── */
#panic-suggestions {
  padding: 0.5rem 1rem 0.25rem;
  background: #fff5f5;
  border-top: 1px solid #fecaca;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

#panic-suggestions.hidden {
  display: none;
}

.panic-option {
  padding: 0.45rem 1rem;
  background: #fff;
  color: #dc2626;
  border: 1px solid #fca5a5;
  border-radius: 20px;
  font-size: 0.875rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

.panic-option:hover {
  background: #fee2e2;
}

/* ── In-chat score button ── */
.score-btn-wrapper {
  display: flex;
  justify-content: center;
  padding: 0.5rem 0;
}

.score-btn {
  padding: 0.6rem 1.4rem;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 20px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.score-btn:hover {
  background: #1d4ed8;
}

/* ── Grade placeholder card ── */
.grade-card {
  align-self: center;
  width: 100%;
  max-width: 480px;
  border: 1.5px solid #d1d5db;
  border-radius: 10px;
  background: #f8fafc;
  padding: 1rem 1.2rem;
  font-size: 0.95rem;
  color: #374151;
  text-align: center;
}

/* ── Simulation scenario card ── */
.scenario-card {
  align-self: center;
  width: 100%;
  max-width: 480px;
  border: 1.5px solid #d1d5db;
  border-radius: 10px;
  background: #f8fafc;
  padding: 1rem 1.2rem;
  font-size: 0.9rem;
  line-height: 1.6;
}

.scenario-header {
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #374151;
  margin-bottom: 0.65rem;
}

.scenario-field {
  color: #374151;
  margin-bottom: 0.25rem;
}

.scenario-label {
  font-weight: 600;
  color: #111827;
}

.scenario-pickup {
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid #e5e7eb;
  color: #6b7280;
  font-style: italic;
}
