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

:root {
  --bg: #FDFAF6;
  --bg-card: #ffffff;
  --primary: #E85D4A;
  --primary-light: #FFF1ED;
  --primary-dark: #C94432;
  --primary-gradient: linear-gradient(135deg, #E85D4A 0%, #F0845C 100%);
  --secondary: #1A8C7B;
  --secondary-light: #E6F5F2;
  --secondary-dark: #14705F;
  --accent: #E5983E;
  --accent-light: #FEF3E2;
  --success: #2D9B6E;
  --success-light: #E3F5ED;
  --warning: #E5983E;
  --danger: #E85D4A;
  --text: #2C2A27;
  --text-light: #6B6560;
  --text-muted: #B5AFA8;
  --border: #EDE8E3;
  --shadow: 0 2px 16px rgba(44,42,39,0.06);
  --shadow-lg: 0 8px 32px rgba(44,42,39,0.1);
  --shadow-glow: 0 4px 20px rgba(232,93,74,0.25);
  --radius: 20px;
  --radius-sm: 14px;
  --nav-height: 72px;
  --header-height: 60px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* === Header === */
#header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: rgba(253,250,246,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
  border-bottom: 1px solid rgba(237,232,227,0.6);
}

#header h1 {
  font-size: 1.25rem;
  font-weight: 800;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

#btn-settings {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  padding: 8px;
  border-radius: 12px;
  transition: background 0.2s;
}

#btn-settings:active {
  background: var(--border);
}

/* === Main content === */
#main {
  padding: calc(var(--header-height) + 16px) 16px calc(var(--nav-height) + 24px);
  max-width: 480px;
  margin: 0 auto;
}

.screen { display: none; }
.screen.active { display: block; animation: screenIn 0.35s cubic-bezier(0.16, 1, 0.3, 1); }

/* === Bottom nav === */
#bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  display: flex;
  justify-content: space-around;
  align-items: center;
  border-top: 1px solid rgba(237,232,227,0.5);
  padding-bottom: env(safe-area-inset-bottom, 0);
  z-index: 100;
}

.nav-btn {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 500;
  cursor: pointer;
  padding: 8px 14px;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.nav-btn.active {
  color: var(--primary);
  transform: translateY(-1px);
}

.nav-btn.active::after {
  content: '';
  position: absolute;
  top: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 3px;
  background: var(--primary-gradient);
  border-radius: 0 0 3px 3px;
}

.nav-btn svg { width: 22px; height: 22px; }

/* === Greeting === */
.greeting {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 24px;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

.greeting span {
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.greeting small {
  display: block;
  font-size: 0.82rem !important;
  font-weight: 500;
  color: var(--text-light);
  margin-top: 4px;
  -webkit-text-fill-color: var(--text-light);
  background: none;
  -webkit-background-clip: unset;
}

/* === Cards === */
.summary-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 28px;
}

.summary-card {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid rgba(237,232,227,0.5);
}

.summary-card:active { transform: scale(0.97); }
.summary-card .card-icon { font-size: 1.5rem; }
.summary-card .card-label { font-size: 0.73rem; color: var(--text-light); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.summary-card .card-value { font-size: 1.05rem; font-weight: 700; }
.summary-card.empty {
  opacity: 0.45;
  border: 2px dashed var(--border);
  box-shadow: none;
  background: transparent;
}

/* === Buttons === */
.quick-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 32px;
}

.btn-primary, .btn-secondary, .btn-accent, .btn-text {
  border: none;
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  width: 100%;
  justify-content: center;
  letter-spacing: -0.01em;
}

.btn-primary {
  background: var(--primary-gradient);
  color: white;
  box-shadow: var(--shadow-glow);
}

.btn-primary:active {
  transform: scale(0.97);
  box-shadow: 0 2px 12px rgba(232,93,74,0.2);
}

.btn-secondary {
  background: var(--secondary-light);
  color: var(--secondary-dark);
}

.btn-secondary:active { transform: scale(0.97); }

.btn-accent {
  background: var(--accent-light);
  color: #9B6B1F;
}

.btn-accent:active { transform: scale(0.97); }

.btn-text {
  background: none;
  color: var(--text-light);
  padding: 10px;
  font-weight: 600;
}

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

.btn-sm {
  padding: 10px 16px;
  font-size: 0.9rem;
  border-radius: 10px;
}

/* === Section headers === */
.insights-preview, .suggestions-preview, .science-preview { margin-bottom: 32px; }
.insights-preview h2, .suggestions-preview h2, .science-preview h2, .screen h2 {
  font-size: 1.15rem;
  font-weight: 800;
  margin-bottom: 14px;
  color: var(--text);
  letter-spacing: -0.02em;
}

/* === Insight card === */
.insight-card {
  background: var(--primary-light);
  border-radius: var(--radius-sm);
  padding: 18px;
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--primary-dark);
  border-left: 4px solid var(--primary);
}

.insight-card.empty {
  background: var(--border);
  color: var(--text-light);
  border-left-color: var(--text-muted);
}

/* === Science card === */
.science-card {
  background: linear-gradient(135deg, #E6F5F2 0%, #F0FAFA 100%);
  border-radius: var(--radius-sm);
  padding: 18px;
  font-size: 0.88rem;
  line-height: 1.7;
  color: var(--secondary-dark);
  border-left: 4px solid var(--secondary);
}

.science-card .science-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--secondary);
  margin-bottom: 6px;
}

.science-card .science-source {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 8px;
  font-style: italic;
}

/* === Suggestions === */
.suggestion-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.suggestion-item {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  gap: 14px;
  align-items: flex-start;
  transition: transform 0.2s;
  border: 1px solid rgba(237,232,227,0.5);
}

.suggestion-item:active { transform: scale(0.98); }
.suggestion-icon { font-size: 1.6rem; flex-shrink: 0; }

.suggestion-text {
  font-size: 0.88rem;
  line-height: 1.5;
}

.suggestion-text strong {
  display: block;
  margin-bottom: 3px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* === Check-in === */
.checkin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.btn-close-checkin {
  background: var(--border);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-light);
  font-size: 1.1rem;
  transition: all 0.15s;
}

.btn-close-checkin:active {
  background: var(--text-muted);
  color: white;
}

.checkin-progress { margin-bottom: 24px; text-align: center; }

.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-fill {
  height: 100%;
  background: var(--primary-gradient);
  border-radius: 3px;
  transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  width: 0%;
}

#checkin-step-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

.checkin-content {
  min-height: 300px;
}

.checkin-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 28px;
  gap: 12px;
}

.checkin-nav .btn-primary { flex: 1; }
.checkin-nav .btn-text { flex: 0 0 auto; width: auto; }

/* Check-in question */
.checkin-question {
  margin-bottom: 24px;
}

.checkin-question h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 4px;
  letter-spacing: -0.02em;
}

.checkin-question p {
  font-size: 0.85rem;
  color: var(--text-light);
}

/* Slider */
.slider-group {
  margin: 24px 0;
  text-align: center;
}

.slider-value {
  font-size: 3rem;
  font-weight: 800;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
  letter-spacing: -0.04em;
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 6px;
  font-weight: 500;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 32px;
  height: 32px;
  background: var(--primary-gradient);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: var(--shadow-glow);
  transition: transform 0.15s;
}

input[type="range"]::-webkit-slider-thumb:active {
  transform: scale(1.15);
}

/* Emoji picker row */
.emoji-row {
  display: flex;
  justify-content: center;
  margin: 20px 0;
  flex-wrap: wrap;
  gap: 8px;
}

.emoji-btn {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 12px;
  font-size: 1.7rem;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  min-width: 64px;
}

.emoji-btn span {
  font-size: 0.65rem;
  color: var(--text-light);
  font-weight: 600;
}

.emoji-btn.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: scale(1.08);
  box-shadow: 0 4px 16px rgba(232,93,74,0.15);
}

.emoji-btn:active { transform: scale(0.95); }

/* Chip select */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.chip {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 24px;
  padding: 10px 18px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  font-weight: 500;
}

.chip.selected {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(232,93,74,0.1);
}

.chip:active { transform: scale(0.95); }

/* Time input */
.time-input-group {
  display: flex;
  gap: 12px;
  margin: 14px 0;
  align-items: center;
}

.time-input-group label {
  font-size: 0.85rem;
  color: var(--text-light);
  min-width: 80px;
  font-weight: 600;
}

.time-input-group input[type="time"] {
  flex: 1;
  padding: 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-card);
  transition: border-color 0.2s;
}

.time-input-group input[type="time"]:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(232,93,74,0.1);
}

/* Counter */
.counter-group {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  margin: 20px 0;
}

.counter-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2.5px solid var(--primary);
  background: var(--bg-card);
  color: var(--primary);
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.counter-btn:active {
  background: var(--primary);
  color: white;
  transform: scale(0.9);
}

.counter-value {
  font-size: 3rem;
  font-weight: 800;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  min-width: 64px;
  text-align: center;
  letter-spacing: -0.04em;
}

.counter-label {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-light);
  font-weight: 500;
}

/* Toggle */
.toggle-group {
  display: flex;
  gap: 8px;
  margin: 14px 0;
}

.toggle-btn {
  flex: 1;
  padding: 14px 8px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-size: 0.85rem;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  font-weight: 500;
}

.toggle-btn.selected {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(232,93,74,0.1);
}

.toggle-btn:active { transform: scale(0.96); }

/* Textarea */
.note-input {
  width: 100%;
  min-height: 100px;
  padding: 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.92rem;
  color: var(--text);
  resize: vertical;
  margin: 14px 0;
  line-height: 1.6;
  transition: border-color 0.2s;
}

.note-input:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(232,93,74,0.1);
}

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

/* === Cycle === */
.cycle-calendar {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  border: 1px solid rgba(237,232,227,0.5);
}

.cal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.cal-header h3 { font-size: 1rem; font-weight: 700; letter-spacing: -0.01em; }

.cal-nav {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--primary);
  padding: 6px 10px;
  border-radius: 8px;
  transition: background 0.15s;
}

.cal-nav:active { background: var(--primary-light); }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  text-align: center;
}

.cal-day-name {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 700;
  padding: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.cal-day:active { transform: scale(0.88); }

.cal-day.today {
  font-weight: 800;
  border: 2.5px solid var(--primary);
}

.cal-day.period {
  background: var(--primary);
  color: white;
  font-weight: 700;
}

.cal-day.predicted {
  background: var(--primary-light);
  color: var(--primary);
  border: 1.5px dashed var(--primary);
}

.cal-day.other-month { color: var(--text-muted); }

.cycle-info {
  background: linear-gradient(135deg, var(--primary-light) 0%, #FEF3E2 100%);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 16px;
  font-size: 0.9rem;
  line-height: 1.6;
  border-left: 4px solid var(--accent);
}

.cycle-symptoms {
  margin-top: 16px;
}

.cycle-symptoms h3 {
  font-size: 0.95rem;
  margin-bottom: 10px;
  font-weight: 700;
}

/* === Charts === */
.time-filter {
  display: flex;
  gap: 8px;
  margin-bottom: 22px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.time-filter::-webkit-scrollbar { display: none; }

.filter-btn {
  padding: 9px 18px;
  border: 1.5px solid var(--border);
  border-radius: 24px;
  background: var(--bg);
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  font-weight: 600;
}

.filter-btn.active {
  background: var(--primary-gradient);
  color: white;
  border-color: transparent;
  box-shadow: var(--shadow-glow);
}

.filter-btn:active { transform: scale(0.95); }

.charts-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

.chart-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(237,232,227,0.5);
}

.chart-card h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 14px;
  letter-spacing: -0.01em;
}

.chart-card canvas {
  max-height: 200px;
}

.chart-insight {
  font-size: 0.84rem;
  color: var(--text-light);
  margin-top: 12px;
  line-height: 1.6;
  padding: 12px;
  background: var(--bg);
  border-radius: 10px;
}

/* === Data details === */
.data-details {
  margin-top: 20px;
}

.data-details summary {
  font-size: 0.88rem;
  color: var(--primary);
  cursor: pointer;
  padding: 14px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.data-details summary:active { background: var(--primary-light); }

.raw-data {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-size: 0.78rem;
  font-family: 'SF Mono', 'Menlo', monospace;
  overflow-x: auto;
  max-height: 400px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text-light);
  border: 1px solid var(--border);
}

/* === History === */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-item {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s;
  border: 1px solid rgba(237,232,227,0.5);
}

.history-item:active { transform: scale(0.98); }

.history-date {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-bottom: 8px;
  font-weight: 700;
  text-transform: capitalize;
}

.history-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.history-badge {
  font-size: 0.73rem;
  padding: 5px 12px;
  border-radius: 14px;
  font-weight: 600;
}

.history-badge.sleep { background: #dbeafe; color: #1d4ed8; }
.history-badge.mood { background: var(--primary-light); color: var(--primary-dark); }
.history-badge.food { background: var(--success-light); color: #1a6b43; }
.history-badge.hydration { background: #e0f2fe; color: #0369a1; }
.history-badge.energy { background: var(--accent-light); color: #8B5E14; }
.history-badge.work { background: #fef2f2; color: #991b1b; }
.history-badge.cycle { background: #fce7f3; color: #9d174d; }

.history-expand {
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--text-light);
  line-height: 1.6;
  display: none;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.history-item.expanded .history-expand { display: block; }

/* === Empty state === */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-light);
}

.empty-state .empty-icon {
  font-size: 3.5rem;
  margin-bottom: 16px;
  display: block;
}

.empty-state p {
  font-size: 0.92rem;
  line-height: 1.6;
  max-width: 280px;
  margin: 0 auto;
}

/* === Toast === */
.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: white;
  padding: 14px 28px;
  border-radius: 28px;
  font-size: 0.9rem;
  font-weight: 600;
  z-index: 1000;
  opacity: 0;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
  box-shadow: var(--shadow-lg);
}

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

/* === Animations === */
@keyframes screenIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

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

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Staggered card animations */
.summary-card { animation: fadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) backwards; }
.summary-card:nth-child(1) { animation-delay: 0.04s; }
.summary-card:nth-child(2) { animation-delay: 0.08s; }
.summary-card:nth-child(3) { animation-delay: 0.12s; }
.summary-card:nth-child(4) { animation-delay: 0.16s; }
.summary-card:nth-child(5) { animation-delay: 0.2s; }
.summary-card:nth-child(6) { animation-delay: 0.24s; }

.suggestion-item { animation: fadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) backwards; }
.suggestion-item:nth-child(1) { animation-delay: 0.06s; }
.suggestion-item:nth-child(2) { animation-delay: 0.12s; }
.suggestion-item:nth-child(3) { animation-delay: 0.18s; }
.suggestion-item:nth-child(4) { animation-delay: 0.24s; }

/* === Utilities === */
.hidden { display: none !important; }
.mt-12 { margin-top: 12px; }
.mb-12 { margin-bottom: 12px; }
.text-center { text-align: center; }

/* === Scrollbar === */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* === Login screen === */
.login-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

.login-container {
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.login-icon {
  font-size: 4rem;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.login-title {
  font-size: 2rem;
  font-weight: 800;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
}

.login-subtitle {
  font-size: 0.95rem;
  color: var(--text-light);
  line-height: 1.5;
  margin-bottom: 36px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-input {
  padding: 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-card);
  text-align: center;
  transition: border-color 0.2s;
}

.login-input:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(232,93,74,0.1);
}

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

.login-btn {
  padding: 16px;
}

.login-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.login-check-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.login-check-text {
  font-size: 0.95rem;
  color: var(--text-light);
  line-height: 1.6;
}

.login-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 8px;
  font-weight: 600;
}

.login-skip {
  margin-top: 28px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* === Settings menu === */
.settings-menu {
  position: fixed;
  top: calc(var(--header-height) + 4px);
  right: 12px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  min-width: 280px;
  overflow: hidden;
  border: 1px solid var(--border);
  animation: fadeInUp 0.2s ease;
}

.settings-user {
  padding: 14px 18px;
  font-size: 0.82rem;
  color: var(--text-light);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  word-break: break-all;
}

.settings-option {
  display: block;
  width: 100%;
  padding: 14px 18px;
  border: none;
  background: none;
  text-align: left;
  font-size: 0.9rem;
  font-family: var(--font);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
}

.settings-option:active { background: var(--bg); }

.settings-danger { color: var(--danger); }

.settings-login-section {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.settings-login-hint {
  font-size: 0.8rem;
  color: var(--text-light);
  margin: 0 0 10px;
}

.settings-login-section .settings-login-input {
  display: block;
  width: 100%;
  margin-bottom: 8px;
  box-sizing: border-box;
}

.settings-login-row {
  display: flex;
  gap: 8px;
}

.settings-login-input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-family: var(--font);
  background: var(--bg);
}

.settings-login-btn {
  flex: 1;
  padding: 8px 12px;
  font-size: 0.8rem;
  white-space: nowrap;
  border-radius: var(--radius-sm);
  border: none;
  font-family: var(--font);
  font-weight: 600;
  cursor: pointer;
}

.settings-login-btn.btn-secondary {
  background: var(--secondary);
  color: white;
}

/* === AI Section === */
.ai-section {
  margin-top: 20px;
  padding: 0 2px;
}

.ai-section h2 {
  font-size: 1.05rem;
  margin-bottom: 12px;
}

.ai-ask-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.ai-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: var(--font);
  background: var(--bg-card);
}

.ai-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.ai-ask-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: var(--radius-sm);
  font-size: 1.2rem;
  flex-shrink: 0;
}

.ai-answer {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 12px;
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text);
  animation: fadeInUp 0.3s ease;
}

.ai-answer p {
  margin: 0 0 8px;
}

.ai-answer p:last-child {
  margin-bottom: 0;
}

.ai-loading {
  color: var(--text-light);
  font-style: italic;
}

.ai-error {
  color: var(--danger);
  font-size: 0.85rem;
}

.ai-deep-btn {
  font-size: 0.85rem;
  margin-bottom: 10px;
  color: var(--secondary);
  font-weight: 600;
}

.insight-card.ai-powered {
  border-left: 3px solid var(--secondary);
  padding-left: 14px;
}

/* === Haptic feedback hint (visual) for important taps === */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
