@import url('https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;1,9..40,300&display=swap');

/* ===== DESIGN TOKENS ===== */
:root {
  --rose:       #C94060;
  --rose-dark:  #9B2D45;
  --rose-soft:  #E8687F;
  --rose-light: #FCEEF1;
  --rose-mid:   #E8A0B0;
  --cream:      #FDFAF8;
  --cream-2:    #F5EFE9;
  --ink:        #1A1410;
  --ink-2:      #3D332C;
  --ink-3:      #7A6E68;
  --border:     rgba(26,20,16,0.08);
  --border-2:   rgba(26,20,16,0.14);
  --white:      #FFFFFF;
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.04);
  --shadow-lg:  0 12px 40px rgba(0,0,0,0.1), 0 4px 12px rgba(0,0,0,0.05);
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-xl: 24px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--cream);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ===== APP HEADER ===== */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 32px;
  height: 64px;
  background: rgba(253,250,248,0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.app-header nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.app-header nav button,
.app-header nav .nav-btn {
  background: transparent;
  border: none;
  color: var(--ink-3);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.875rem;
  font-weight: 400;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.app-header nav button:hover,
.app-header nav .nav-btn:hover {
  background: var(--rose-light);
  color: var(--rose);
}

.app-header nav button.nav-primary {
  background: var(--rose);
  color: var(--white);
  font-weight: 500;
}
.app-header nav button.nav-primary:hover {
  background: var(--rose-dark);
  color: var(--white);
}

/* ===== BACK BUTTON ===== */
.back-bar {
  padding: 16px 32px 0;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--ink-3);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.875rem;
  font-weight: 400;
  cursor: pointer;
  padding: 6px 0;
  transition: color 0.15s;
  text-decoration: none;
}

.back-btn:hover { color: var(--rose); }
.back-btn::before { content: '←'; font-size: 1rem; }

/* ===== PAGE LAYOUT ===== */
.page-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 32px 64px;
}

.page-wrap-narrow {
  max-width: 640px;
  margin: 0 auto;
  padding: 32px 32px 64px;
}

/* ===== CARDS ===== */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}

.card-body { padding: 28px; }

/* ===== TYPOGRAPHY ===== */
.page-title {
  font-family: 'Instrument Serif', serif;
  font-size: 2rem;
  font-weight: 400;
  color: var(--ink);
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 24px;
}

.section-title {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 16px;
}

/* ===== FORM ELEMENTS ===== */
label.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink-2);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}

input.form-input,
textarea.form-input,
select.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  color: var(--ink);
  background: var(--white);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

input.form-input:focus,
textarea.form-input:focus,
select.form-input:focus {
  border-color: var(--rose-soft);
  box-shadow: 0 0 0 3px rgba(201,64,96,0.08);
}

textarea.form-input { resize: vertical; min-height: 88px; }

.form-group { margin-bottom: 16px; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--r-md);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
}

.btn:active { transform: scale(0.98); }

.btn-rose  { background: var(--rose); color: var(--white); }
.btn-rose:hover  { background: var(--rose-dark); }

.btn-ghost {
  background: transparent;
  color: var(--ink-3);
  border: 1px solid var(--border-2);
}
.btn-ghost:hover { background: var(--cream-2); color: var(--ink); }

.btn-danger { background: #FEE2E2; color: #991B1B; }
.btn-danger:hover { background: #FECACA; }

.btn-full { width: 100%; }
.btn-lg { padding: 12px 24px; font-size: 0.95rem; }
.btn-sm { padding: 7px 14px; font-size: 0.8rem; }

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 500;
}
.badge-rose { background: var(--rose-light); color: var(--rose-dark); }
.badge-gray { background: var(--cream-2); color: var(--ink-3); }

/* ===== STAT CHIP ===== */
.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--cream-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 0.875rem;
  color: var(--ink-2);
}

.stat-chip strong {
  font-weight: 600;
  color: var(--rose);
}

/* ===== DIVIDER ===== */
.divider {
  height: 1px;
  background: var(--border);
  margin: 24px 0;
}

/* ===== ALERT ===== */
.alert {
  padding: 12px 16px;
  border-radius: var(--r-md);
  font-size: 0.875rem;
  margin-bottom: 16px;
}
.alert-info { background: #EFF6FF; color: #1E40AF; border: 1px solid #BFDBFE; }
.alert-rose { background: var(--rose-light); color: var(--rose-dark); border: 1px solid var(--rose-mid); }
.alert-success { background: #F0FDF4; color: #166534; border: 1px solid #BBF7D0; }
.alert-error { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }

/* ===== POPUP OVERLAY ===== */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26,20,16,0.45);
  backdrop-filter: blur(4px);
  justify-content: center;
  align-items: center;
  z-index: 9999;
}
.overlay.active { display: flex; }

.modal {
  background: var(--white);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  padding: 36px 32px;
  max-width: 420px;
  width: 90%;
  position: relative;
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { transform: translateY(12px) scale(0.97); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-close {
  position: absolute;
  top: 14px; right: 18px;
  background: none;
  border: none;
  font-size: 1.3rem;
  color: var(--ink-3);
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  border-radius: var(--r-sm);
  transition: background 0.15s;
}
.modal-close:hover { background: var(--cream-2); }

.modal h3 {
  font-family: 'Instrument Serif', serif;
  font-size: 1.4rem;
  font-weight: 400;
  margin-bottom: 10px;
}

.modal p { font-size: 0.9rem; color: var(--ink-3); margin-bottom: 20px; }

/* ===== GRID HELPERS ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px,1fr)); gap: 20px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .app-header { padding: 0 16px; }
  .back-bar { padding: 12px 16px 0; }
  .page-wrap, .page-wrap-narrow { padding: 20px 16px 48px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
