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

:root {
  --bg: #f8f8fa;
  --surface: #ffffff;
  --surface-2: #f0f0f4;
  --border: #e2e2ea;
  --text: #1a1a2e;
  --text-muted: #6b6b80;
  --accent: #BF2020;
  --accent-glow: rgba(191, 32, 32, 0.12);
  --accent-soft: rgba(191, 32, 32, 0.06);
  --radius: 14px;
  --radius-sm: 8px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── App Shell ────────────────────────────────────────────────── */
#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 20px 100px;
  position: relative;
}

/* ── Header ───────────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 12px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 100;
}

.header-logo {
  height: 32px;
  width: auto;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  font-size: 16px;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

/* ── Views ────────────────────────────────────────────────────── */
.view { display: none; animation: fadeIn 0.3s ease; }
.view.active { display: block; }

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

/* ── Home ─────────────────────────────────────────────────────── */
.greeting {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 16px 0 4px;
  letter-spacing: -0.02em;
}

.greeting-sub {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 24px;
}

/* Insight Engine */
#insight-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 28px;
}

#insight-container:empty {
  display: none;
}

.insight-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  opacity: 0;
  transform: translateY(10px);
  animation: insightIn 0.5s ease forwards;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  transition: var(--transition);
}

.insight-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 12px var(--accent-glow);
}

.insight-card:nth-child(1) { animation-delay: 0.1s; }
.insight-card:nth-child(2) { animation-delay: 0.25s; }
.insight-card:nth-child(3) { animation-delay: 0.4s; }

@keyframes insightIn {
  to { opacity: 1; transform: translateY(0); }
}

.insight-icon {
  font-size: 1.1rem;
  line-height: 1.4;
  flex-shrink: 0;
}

.insight-text {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text);
  font-weight: 450;
}

/* Mic Button */
.mic-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 32px 0;
}

.mic-btn {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  color: white;
  font-size: 28px;
  cursor: pointer;
  position: relative;
  transition: var(--transition);
  box-shadow: 0 0 0 0 var(--accent-glow);
  display: flex;
  align-items: center;
  justify-content: center;
}

.mic-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 30px var(--accent-glow);
}

.mic-btn.recording {
  animation: pulse-ring 1.5s ease-in-out infinite;
  background: #e02020;
}

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(224, 32, 32, 0.5); }
  70% { box-shadow: 0 0 0 20px rgba(224, 32, 32, 0); }
  100% { box-shadow: 0 0 0 0 rgba(224, 32, 32, 0); }
}

.mic-label {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 12px;
  transition: var(--transition);
}

/* Text Input */
.text-input-section {
  margin-bottom: 28px;
}

.text-input-row {
  display: flex;
  gap: 8px;
}

.text-input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: var(--transition);
  resize: none;
  font-family: inherit;
}

.text-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.text-input::placeholder {
  color: var(--text-muted);
}

.send-btn {
  background: var(--accent);
  border: none;
  color: white;
  width: 48px;
  min-width: 48px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 18px;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.send-btn:hover { opacity: 0.85; }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Section Titles */
.section-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 12px;
  font-weight: 600;
}

/* People List */
.people-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 28px;
}

.person-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.person-card:hover {
  background: var(--surface-2);
  border-color: var(--accent);
  transform: translateX(4px);
}

.person-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #ff4444);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  color: white;
  flex-shrink: 0;
}

.person-info { flex: 1; min-width: 0; }

.person-name {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.person-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.person-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
}

/* Ask Section */
.ask-section {
  margin-bottom: 28px;
}

.ask-input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.ask-input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: var(--transition);
  font-family: inherit;
}

.ask-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.ask-input::placeholder { color: var(--text-muted); }

.ask-answer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text);
  display: none;
  white-space: pre-wrap;
}

.ask-answer.visible { display: block; }

/* ── People View ──────────────────────────────────────────────── */
.view-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 8px 0 20px;
}

/* ── Profile View ─────────────────────────────────────────────── */
.profile-header {
  text-align: center;
  padding: 20px 0;
}

.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #ff4444);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.6rem;
  color: white;
  margin: 0 auto 14px;
}

.profile-name {
  font-size: 1.4rem;
  font-weight: 700;
}

.profile-role {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

.profile-relation {
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-top: 4px;
  font-style: italic;
}

/* ── Field Badges ─────────────────────────────────────────────── */
.profile-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 16px 0 8px;
}

.field-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  line-height: 1.3;
  transition: var(--transition);
  cursor: default;
}

.field-badge.verified {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
}

.field-badge.verified:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.field-badge.verified .field-badge-check {
  color: #22c55e;
  font-size: 0.7rem;
  font-weight: 700;
}

.field-badge.unverified {
  background: #fff8f0;
  border: 1px dashed #e8a850;
  color: #9a6b30;
  cursor: pointer;
}

.field-badge.unverified:hover {
  background: #fff3e3;
  border-color: #d4893a;
}

.field-badge.unverified .field-badge-action {
  font-size: 0.68rem;
  font-weight: 600;
  color: #d4893a;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.field-badge.empty {
  background: var(--surface);
  border: 1px dashed var(--border);
  color: var(--text-muted);
  cursor: pointer;
}

.field-badge.empty:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.field-badge-label {
  font-weight: 600;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  opacity: 0.65;
}

.field-badge-value {
  font-weight: 500;
}

.field-badge-value.add-hint {
  font-weight: 500;
  opacity: 0.5;
}

/* Unverified dot on person cards */
.unverified-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #e8a850;
  margin-left: 6px;
  vertical-align: middle;
}

/* Field editor input */
.field-edit-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  background: var(--bg);
  color: var(--text);
  margin: 12px 0 16px;
  outline: none;
  transition: var(--transition);
}

.field-edit-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.profile-stats {
  display: flex;
  justify-content: center;
  gap: 28px;
  margin: 20px 0;
  padding: 16px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.profile-stat {
  text-align: center;
}

.profile-stat-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
}

.profile-stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}

.profile-summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text-muted);
  margin-bottom: 24px;
  white-space: pre-wrap;
}

.interaction-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
}

.interaction-meta {
  font-size: 0.78rem;
  color: var(--accent);
  margin-bottom: 8px;
  font-weight: 500;
}

.interaction-transcript {
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text-muted);
}

/* ── Processing Modal ─────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-overlay.visible {
  display: flex;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  animation: modalIn 0.3s ease;
  box-shadow: 0 8px 40px rgba(0,0,0,0.12);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal h3 {
  font-size: 1.1rem;
  margin-bottom: 8px;
}

.modal p {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 20px;
}

.modal-person-name {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}

.modal-person-detail {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.modal-match-info {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin: 16px 0;
  font-size: 0.85rem;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.btn {
  flex: 1;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover { opacity: 0.85; }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover { background: var(--border); }

/* ── Spinner ──────────────────────────────────────────────────── */
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

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

/* ── Back Button ──────────────────────────────────────────────── */
.back-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 0;
  transition: var(--transition);
  font-family: inherit;
}

.back-btn:hover { color: var(--text); }

/* ── Fullscreen Button ────────────────────────────────────────── */
.fullscreen-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  z-index: 50;
  transition: var(--transition);
}

.fullscreen-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

/* ── Toast ────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  border: none;
  color: var(--bg);
  padding: 12px 24px;
  border-radius: 30px;
  font-size: 0.85rem;
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 2000;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Empty State ──────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  opacity: 0.5;
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 360px) {
  .greeting { font-size: 1.4rem; }
}

/* ── Confirm Modal: Simplified ─────────────────────────────────── */
.modal-person-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.modal-last-seen {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 6px;
  margin-bottom: 4px;
}

.modal-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
  margin-bottom: 8px;
}

/* ── Candidate List ────────────────────────────────────────────── */
.candidate-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
}

.candidate-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.candidate-card:hover {
  border-color: var(--accent);
  background: rgba(191, 32, 32, 0.04);
}

.candidate-card:active {
  transform: scale(0.98);
}

.candidate-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.candidate-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.candidate-last-seen {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.new-person-card {
  border-style: dashed;
  border-color: var(--text-muted);
}

.new-person-card:hover {
  border-color: var(--accent);
  border-style: solid;
}

.new-person-card .candidate-name {
  color: var(--accent);
}
