/* ============================================
   Second Chapter — App Styles
   Matches landing page design tokens (warm, premium)
   ============================================ */

:root {
  --bg: #FAF9F6;
  --bg-warm: #F5F0E8;
  --bg-deeper: #EDE5D8;
  --text: #1C1C1E;
  --text-mid: #4A4540;
  --text-light: #8A8078;
  --accent: #B8745A;
  --accent-light: #D4A98A;
  --accent-muted: #E8D8C8;
  --sage: #8B9E8B;
  --green-flag: #6B8E6B;
  --red-flag: #B8745A;
  --border: #E0D8CC;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'DM Sans', -apple-system, sans-serif;
  --space-xs: 0.5rem;
  --space-sm: 0.75rem;
  --space-md: 1.25rem;
  --space-lg: 2rem;
  --space-xl: 3rem;
  --space-2xl: 5rem;
  --max-w: 1100px;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img { display: block; max-width: 100%; }
button { cursor: pointer; font-family: inherit; }
a { color: var(--accent); text-decoration: none; }

/* ===== NAV ===== */
.app-nav {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 1.25rem var(--space-lg);
  max-width: var(--max-w);
  margin: 0 auto;
  border-bottom: 1px solid var(--border);
}
.wordmark {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--text);
}
.wordmark a { color: inherit; }
.nav-actions { display: flex; gap: 1rem; align-items: center; }
.nav-user { font-size: 0.85rem; color: var(--text-light); }

/* ===== LAYOUT ===== */
.app-container { max-width: var(--max-w); margin: 0 auto; padding: var(--space-lg); }
.app-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-lg); flex-wrap: wrap; gap: 1rem; }
.app-header h1 { font-family: var(--font-display); font-size: 1.8rem; font-weight: 500; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.55rem 1.2rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem; font-weight: 500;
  border: none; transition: all 0.15s;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: #a06548; }
.btn-secondary { background: var(--bg-deeper); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-ghost { background: transparent; color: var(--text-mid); padding: 0.4rem 0.8rem; }
.btn-ghost:hover { color: var(--text); }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.82rem; }
.btn-danger { background: var(--red-flag); color: white; }
.btn-danger:hover { background: #a0624a; }
.btn-icon { padding: 0.5rem; border-radius: 50%; width: 36px; height: 36px; justify-content: center; }
.btn-icon svg { width: 16px; height: 16px; }

/* ===== FORMS ===== */
.form-group { display: flex; flex-direction: column; gap: 0.35rem; }
.form-label { font-size: 0.82rem; font-weight: 500; color: var(--text-mid); }
.form-input, .form-select, .form-textarea {
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
  font-family: inherit; font-size: 0.9rem; color: var(--text);
  transition: border-color 0.15s;
  width: 100%;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--accent-light);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-error { font-size: 0.8rem; color: var(--red-flag); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.form-inline { display: flex; gap: 0.5rem; align-items: center; }

/* ===== FILTER BAR ===== */
.filter-bar {
  display: flex; align-items: center; gap: 0.75rem;
  margin-bottom: 1.5rem; flex-wrap: wrap;
}
.filter-bar .form-input, .filter-bar .form-select {
  padding: 0.5rem 0.75rem; font-size: 0.85rem; width: auto; min-width: 160px;
}
.search-wrap { position: relative; flex: 1; min-width: 200px; }
.search-wrap svg { position: absolute; left: 0.65rem; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: var(--text-light); }
.search-wrap .form-input { padding-left: 2rem; }

.view-toggle { display: flex; gap: 0.25rem; }
.view-toggle button { padding: 0.4rem; border: 1px solid var(--border); background: white; border-radius: var(--radius-sm); }
.view-toggle button.active { background: var(--bg-deeper); }
.view-toggle svg { width: 16px; height: 16px; color: var(--text-mid); }

/* ===== PEOPLE LIST ===== */
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.25rem; }
.people-list { display: flex; flex-direction: column; gap: 0.75rem; }

.person-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  color: inherit;
  display: block;
}
.person-card:hover { border-color: var(--accent-light); box-shadow: 0 2px 12px rgba(0,0,0,0.06); }

.person-card-header { display: flex; gap: 1rem; margin-bottom: 0.85rem; }
.person-avatar {
  width: 60px; height: 60px; border-radius: 50%; object-fit: cover;
  background: var(--accent-muted); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 1.4rem; color: var(--accent);
}
.person-avatar img { border-radius: 50%; }
.person-meta { flex: 1; }
.person-name { font-family: var(--font-display); font-size: 1.1rem; font-weight: 500; margin-bottom: 0.15rem; }
.person-sub { font-size: 0.82rem; color: var(--text-light); }
.person-sub span { margin-right: 0.5rem; }

.person-stats { display: flex; gap: 0.75rem; margin: 0.85rem 0; flex-wrap: wrap; }
.stat-chip {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.25rem 0.65rem; background: var(--bg-warm);
  border-radius: 20px; font-size: 0.78rem; color: var(--text-mid);
}
.stat-chip.sage { background: rgba(139,158,139,0.15); color: var(--sage); }
.stat-chip.accent { background: rgba(184,116,90,0.1); color: var(--accent); }

.person-vibe { font-size: 0.82rem; color: var(--text-mid); font-style: italic; }
.person-next-step { font-size: 0.78rem; color: var(--accent); margin-top: 0.5rem; font-weight: 500; }

.list-card { display: flex; align-items: center; gap: 1rem; }
.list-card .person-avatar { width: 48px; height: 48px; font-size: 1.1rem; }
.list-card .person-stats { margin: 0; }
.list-card .person-actions { margin-left: auto; display: flex; gap: 0.5rem; }

/* Rating bars */
.rating-bar { display: flex; align-items: center; gap: 0.5rem; font-size: 0.78rem; color: var(--text-mid); }
.rating-bar .bar { flex: 1; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.rating-bar .bar-fill { height: 100%; background: var(--accent); border-radius: 2px; }

/* ===== PERSON PROFILE ===== */
.profile-back { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; color: var(--text-light); margin-bottom: var(--space-lg); }
.profile-back:hover { color: var(--text); }

.profile-header { display: flex; gap: 2rem; align-items: flex-start; margin-bottom: var(--space-xl); flex-wrap: wrap; }
.profile-avatar {
  width: 100px; height: 100px; border-radius: 50%; object-fit: cover;
  background: var(--accent-muted); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 2.2rem; color: var(--accent);
}
.profile-avatar img { border-radius: 50%; }
.profile-name-block { flex: 1; }
.profile-name { font-family: var(--font-display); font-size: 2rem; font-weight: 500; }
.profile-sub { font-size: 0.9rem; color: var(--text-light); margin-top: 0.25rem; }
.profile-actions { display: flex; gap: 0.5rem; margin-top: 1rem; }

.profile-sections { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }
@media (max-width: 700px) { .profile-sections { grid-template-columns: 1fr; } }

.profile-section { background: white; border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1.5rem; }
.section-title { font-family: var(--font-display); font-size: 1rem; font-weight: 500; margin-bottom: 1.25rem; padding-bottom: 0.75rem; border-bottom: 1px solid var(--border); color: var(--text-mid); }

.facts-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.85rem; }
@media (max-width: 500px) { .facts-grid { grid-template-columns: 1fr; } }
.fact-item { display: flex; flex-direction: column; gap: 0.15rem; }
.fact-label { font-size: 0.75rem; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.04em; }
.fact-value { font-size: 0.92rem; color: var(--text); font-weight: 500; }
.fact-value.missing { color: var(--text-light); font-weight: 400; font-style: italic; }

/* Your Read */
.read-scores { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; margin-bottom: 1.25rem; }
.score-item { display: flex; flex-direction: column; gap: 0.2rem; }
.score-label { font-size: 0.75rem; color: var(--text-light); }
.score-row { display: flex; gap: 0.25rem; }
.score-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border); }
.score-dot.filled { background: var(--accent); }

.flags-section { display: flex; flex-direction: column; gap: 0.75rem; }
.flag-row { display: flex; gap: 0.5rem; }
.flag-icon { font-size: 0.9rem; flex-shrink: 0; }
.flag-text { font-size: 0.88rem; color: var(--text-mid); }
.flag-green .flag-icon { color: var(--green-flag); }
.flag-red .flag-icon { color: var(--red-flag); }

/* Interest level display */
.interest-level { margin-top: 1rem; }
.interest-dots { display: flex; gap: 0.25rem; }
.interest-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--border); }
.interest-dot.filled { background: var(--accent); }
.interest-label { font-size: 0.78rem; color: var(--text-light); margin-top: 0.25rem; }

/* Next step */
.next-step-box {
  margin-top: 1.25rem; padding: 1rem; background: var(--bg-warm);
  border-radius: var(--radius-sm); border-left: 3px solid var(--accent);
}
.next-step-box .label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-light); margin-bottom: 0.25rem; }
.next-step-box .value { font-size: 0.9rem; color: var(--text); }

/* ===== DATE TIMELINE ===== */
.timeline-section { grid-column: 1 / -1; margin-top: var(--space-lg); }
.timeline-section .section-title { display: flex; align-items: center; justify-content: space-between; }

.timeline { display: flex; flex-direction: column; gap: 0; border-left: 2px solid var(--border); margin-left: 0.75rem; padding-left: 1.5rem; }
.timeline-entry { position: relative; padding-bottom: 1.75rem; }
.timeline-entry::before {
  content: ''; position: absolute; left: -1.65rem; top: 0.25rem;
  width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: 2px solid white;
}
.timeline-date { font-size: 0.75rem; color: var(--text-light); margin-bottom: 0.25rem; }
.timeline-location { font-size: 0.82rem; color: var(--accent); font-weight: 500; margin-bottom: 0.5rem; }
.timeline-what { font-size: 0.88rem; color: var(--text-mid); margin-bottom: 0.5rem; }
.timeline-reflection { font-size: 0.85rem; color: var(--text); font-style: italic; padding: 0.6rem 0.85rem; background: var(--bg-warm); border-radius: var(--radius-sm); margin-bottom: 0.5rem; }
.timeline-outcome { font-size: 0.8rem; color: var(--text-light); }
.timeline-actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; }

/* ===== MODAL ===== */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 1rem;
}
.modal {
  background: white; border-radius: var(--radius-lg);
  padding: 2rem; max-width: 560px; width: 100%; max-height: 90vh; overflow-y: auto;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.modal-title { font-family: var(--font-display); font-size: 1.4rem; font-weight: 500; }
.modal-close { background: none; border: none; font-size: 1.5rem; color: var(--text-light); cursor: pointer; padding: 0.25rem; line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-footer { display: flex; gap: 0.75rem; justify-content: flex-end; margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--border); }

/* ===== AUTH PAGES ===== */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg-warm); padding: 1rem; }
.auth-card { background: white; border-radius: var(--radius-lg); padding: 2.5rem; width: 100%; max-width: 420px; box-shadow: 0 4px 24px rgba(0,0,0,0.06); }
.auth-title { font-family: var(--font-display); font-size: 1.8rem; font-weight: 500; margin-bottom: 0.35rem; }
.auth-subtitle { font-size: 0.9rem; color: var(--text-light); margin-bottom: 2rem; }
.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.auth-footer { margin-top: 1.5rem; text-align: center; font-size: 0.88rem; color: var(--text-light); }
.auth-error { padding: 0.75rem; background: rgba(184,116,90,0.1); border: 1px solid var(--accent-muted); border-radius: var(--radius-sm); color: var(--red-flag); font-size: 0.88rem; margin-bottom: 1rem; }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: var(--space-2xl) var(--space-lg); }
.empty-state-icon { font-size: 3rem; margin-bottom: 1rem; opacity: 0.4; }
.empty-state h2 { font-family: var(--font-display); font-size: 1.4rem; margin-bottom: 0.5rem; }
.empty-state p { color: var(--text-light); font-size: 0.9rem; margin-bottom: 1.5rem; }

/* ===== UTILITY ===== */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-sm { font-size: 0.85rem; }
.text-muted { color: var(--text-light); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.flex { display: flex; }
.gap-1 { gap: 0.5rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }

/* ===== PRE-DATE ENTRIES ===== */
.pre-date-section { grid-column: 1 / -1; }
.pre-date-section .section-title { display: flex; align-items: center; justify-content: space-between; }

.pre-date-list { display: flex; flex-direction: column; gap: 1rem; }
.pre-date-entry {
  padding: 1.25rem; background: var(--bg-warm);
  border-radius: var(--radius-sm); border: 1px solid var(--border);
}
.pre-date-fields { display: flex; flex-direction: column; gap: 0.85rem; }
.pre-date-field { display: flex; flex-direction: column; gap: 0.15rem; }
.pre-date-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-light); }
.pre-date-value { font-size: 0.9rem; color: var(--text); line-height: 1.5; }
.pre-date-date { font-size: 0.75rem; color: var(--text-light); margin-top: 0.75rem; }
.pre-date-actions { display: flex; gap: 0.5rem; margin-top: 0.75rem; }

/* ===== MODAL ===== */
.modal-intro { font-size: 0.88rem; color: var(--text-mid); margin-bottom: 1.25rem; line-height: 1.5; }