/* ============================================================
   LIFEOS DESIGN SYSTEM
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Outfit:wght@400;600;700;800&display=swap');

/* --- CSS Variables --- */
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #111118;
  --bg-card: #16161e;
  --bg-card-hover: #1e1e28;
  --bg-input: #1a1a24;

  --border: rgba(255,255,255,0.07);
  --border-active: rgba(255,255,255,0.15);

  --text-primary: #f0f0f5;
  --text-secondary: #8888aa;
  --text-muted: #555570;

  /* Category Colors */
  --spend-color: #f97316;
  --spend-glow: rgba(249, 115, 22, 0.2);
  --task-color: #6366f1;
  --task-glow: rgba(99, 102, 241, 0.2);
  --journal-color: #10b981;
  --journal-glow: rgba(16, 185, 129, 0.2);
  --cbd-color: #8b5cf6;
  --cbd-glow: rgba(139, 92, 246, 0.2);
  --habit-color: #f59e0b;
  --habit-glow: rgba(245, 158, 11, 0.2);

  --accent: #6366f1;
  --accent-glow: rgba(99, 102, 241, 0.3);

  --success: #10b981;
  --danger: #f43f5e;
  --warning: #f59e0b;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --shadow-card: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-glow: 0 0 40px rgba(99,102,241,0.15);

  --nav-height: 64px;
  --nav-bottom-height: 68px;
  --font-main: 'Inter', sans-serif;
  --font-display: 'Outfit', sans-serif;
}

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

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

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

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

/* ============================================================
   LAYOUT
   ============================================================ */

#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  z-index: 100;
}

.top-nav .logo {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 22px;
  background: linear-gradient(135deg, #6366f1, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

.sync-badge {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  transition: all 0.3s;
}

.sync-badge.synced { color: var(--success); border-color: rgba(16,185,129,0.3); }
.sync-badge.syncing { color: var(--warning); border-color: rgba(245,158,11,0.3); }
.sync-badge.error { color: var(--danger); border-color: rgba(244,63,94,0.3); }

.sync-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.sync-badge.syncing .sync-dot {
  animation: pulse 1s infinite;
}

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

.main-content {
  padding-top: var(--nav-height);
  padding-bottom: calc(var(--nav-bottom-height) + 16px);
  flex: 1;
}

/* Bottom Nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-bottom-height);
  background: rgba(10, 10, 15, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 4px;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 100;
  overflow-x: auto;
  scrollbar-width: none;
  gap: 2px;
}
.bottom-nav::-webkit-scrollbar { display: none; }

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.25s;
  color: var(--text-muted);
  position: relative;
  border: none;
  background: none;
  min-width: 56px;
}

.nav-item svg {
  width: 22px;
  height: 22px;
  transition: all 0.25s;
}

.nav-item span {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.3px;
}

.nav-item:hover { color: var(--text-primary); }

.nav-item.active {
  color: var(--accent);
}

.nav-item.active svg {
  filter: drop-shadow(0 0 8px var(--accent-glow));
}

.nav-item.capture-btn {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white;
  border-radius: var(--radius-lg);
  padding: 10px 16px;
  box-shadow: 0 4px 20px rgba(99,102,241,0.4);
}

.nav-item.capture-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(99,102,241,0.5);
  color: white;
}

.nav-item.capture-btn svg { width: 24px; height: 24px; }

/* ============================================================
   VIEWS — Shared
   ============================================================ */

.view {
  display: none;
  padding: 20px 16px;
  animation: fadeIn 0.3s ease;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

.view.active { display: block; }

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

.view-header {
  margin-bottom: 24px;
}

.view-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.view-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ============================================================
   CAPTURE VIEW
   ============================================================ */

.capture-view {
  display: none;
  flex-direction: column;
  padding: 20px 16px;
  animation: fadeIn 0.3s ease;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

.capture-view.active { display: flex; }

.capture-prompt {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
  margin-bottom: 8px;
}

.capture-prompt span {
  background: linear-gradient(135deg, #6366f1, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.capture-hint {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.capture-input-wrap {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#captureInput {
  width: 100%;
  min-height: 160px;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 16px;
  line-height: 1.6;
  padding: 20px;
  resize: none;
  transition: border-color 0.25s, box-shadow 0.25s;
  outline: none;
}

#captureInput::placeholder { color: var(--text-muted); }

#captureInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.example-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.submit-btn {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white;
  border: none;
  border-radius: var(--radius-lg);
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 4px 20px rgba(99,102,241,0.35);
}

.submit-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(99,102,241,0.5);
}

.submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.submit-btn .btn-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: none;
}

.submit-btn.loading .btn-spinner { display: block; }
.submit-btn.loading .btn-text { display: none; }

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

/* AI Response Cards */
.response-area {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 20px;
}

.response-card {
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid var(--border);
  animation: slideIn 0.4s ease;
  position: relative;
  overflow: hidden;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: translateX(0); }
}

.response-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
}

.response-card.spend { background: linear-gradient(135deg, rgba(249,115,22,0.1), var(--bg-card)); border-color: rgba(249,115,22,0.25); }
.response-card.spend::before { background: linear-gradient(90deg, var(--spend-color), transparent); }

.response-card.task { background: linear-gradient(135deg, rgba(99,102,241,0.1), var(--bg-card)); border-color: rgba(99,102,241,0.25); }
.response-card.task::before { background: linear-gradient(90deg, var(--task-color), transparent); }

.response-card.journal { background: linear-gradient(135deg, rgba(16,185,129,0.1), var(--bg-card)); border-color: rgba(16,185,129,0.25); }
.response-card.journal::before { background: linear-gradient(90deg, var(--journal-color), transparent); }

.response-card.cbd { background: linear-gradient(135deg, rgba(139,92,246,0.1), var(--bg-card)); border-color: rgba(139,92,246,0.25); }
.response-card.cbd::before { background: linear-gradient(90deg, var(--cbd-color), transparent); }

.response-card.habit { background: linear-gradient(135deg, rgba(245,158,11,0.1), var(--bg-card)); border-color: rgba(245,158,11,0.25); }
.response-card.habit::before { background: linear-gradient(90deg, var(--habit-color), transparent); }

.card-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: 12px;
}

.card-label .label-icon { font-size: 16px; }

.spend .card-label { color: var(--spend-color); }
.task .card-label { color: var(--task-color); }
.journal .card-label { color: var(--journal-color); }
.cbd .card-label { color: var(--cbd-color); }
.habit .card-label { color: var(--habit-color); }

/* ============================================================
   SPEND CARDS
   ============================================================ */

.spend-amount {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -1px;
}

.spend-amount .currency { font-size: 20px; color: var(--text-secondary); }

.spend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}

.spend-description {
  font-size: 15px;
  color: var(--text-secondary);
}

.badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge.debit { background: rgba(244,63,94,0.15); color: #f43f5e; border: 1px solid rgba(244,63,94,0.3); }
.badge.credit { background: rgba(16,185,129,0.15); color: #10b981; border: 1px solid rgba(16,185,129,0.3); }
.badge.high { background: rgba(244,63,94,0.15); color: #f43f5e; }
.badge.medium { background: rgba(245,158,11,0.15); color: #f59e0b; }
.badge.low { background: rgba(16,185,129,0.15); color: #10b981; }
.badge.todo { background: rgba(99,102,241,0.15); color: var(--task-color); }
.badge.done { background: rgba(16,185,129,0.15); color: var(--success); }

.spend-category-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  background: rgba(249,115,22,0.1);
  color: var(--spend-color);
  border: 1px solid rgba(249,115,22,0.2);
  margin-top: 10px;
}

/* ============================================================
   SUMMARY STRIP (Spend View Top)
   ============================================================ */

.summary-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.summary-label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.8px; }
.summary-value { font-family: var(--font-display); font-size: 24px; font-weight: 800; letter-spacing: -0.5px; }
.summary-value.debit-total { color: var(--danger); }
.summary-value.credit-total { color: var(--success); }

/* ============================================================
   TASK VIEW
   ============================================================ */

.tasks-section { margin-bottom: 24px; }
.tasks-section-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.task-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  cursor: pointer;
  transition: all 0.25s;
  margin-bottom: 10px;
}

.task-card:hover { background: var(--bg-card-hover); border-color: var(--border-active); }

.task-check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border-active);
  flex-shrink: 0;
  margin-top: 1px;
  transition: all 0.25s;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  cursor: pointer;
}

.task-card.done .task-check {
  background: var(--success);
  border-color: var(--success);
}

.task-check-icon { display: none; font-size: 12px; }
.task-card.done .task-check-icon { display: block; }

.task-info { flex: 1; }
.task-title { font-size: 15px; font-weight: 500; color: var(--text-primary); line-height: 1.4; }
.task-card.done .task-title { text-decoration: line-through; color: var(--text-muted); }
.task-meta { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.task-due { font-size: 12px; color: var(--text-muted); }

/* ============================================================
   JOURNAL VIEW
   ============================================================ */

.journal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 14px;
  transition: all 0.25s;
  position: relative;
  overflow: hidden;
}

.journal-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--journal-color);
}

.journal-card:hover { border-color: rgba(16,185,129,0.3); }

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

.mood-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--journal-glow);
  border: 1px solid rgba(16,185,129,0.2);
  font-size: 13px;
  color: var(--journal-color);
  font-weight: 500;
}

.journal-date { font-size: 13px; color: var(--text-muted); }

.journal-text {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.7;
}

.journal-themes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.theme-tag {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  background: rgba(16,185,129,0.08);
  color: var(--text-muted);
  border: 1px solid rgba(16,185,129,0.15);
}

/* ============================================================
   CBD VIEW
   ============================================================ */

.cbd-card {
  background: linear-gradient(135deg, rgba(139,92,246,0.08), var(--bg-card));
  border: 1px solid rgba(139,92,246,0.2);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 14px;
  position: relative;
  overflow: hidden;
}

.cbd-card::after {
  content: '';
  position: absolute;
  top: -40px;
  right: -40px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(139,92,246,0.12) 0%, transparent 70%);
}

.cbd-emotion {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
  text-transform: capitalize;
}

.cbd-severity-bar {
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin-bottom: 16px;
  overflow: hidden;
}

.cbd-severity-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 1s ease;
}

.severity-low .cbd-severity-fill { width: 33%; background: var(--success); }
.severity-medium .cbd-severity-fill { width: 66%; background: var(--warning); }
.severity-high .cbd-severity-fill { width: 100%; background: var(--danger); }

.cbd-action {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 14px;
}

.cbd-technique-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  background: rgba(139,92,246,0.12);
  border: 1px solid rgba(139,92,246,0.25);
  color: var(--cbd-color);
  font-size: 13px;
  font-weight: 500;
}

/* Breathing Animation */
.breathe-circle {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(139,92,246,0.3), rgba(139,92,246,0.05));
  border: 2px solid rgba(139,92,246,0.4);
  margin: 16px auto;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--cbd-color);
  font-weight: 600;
}

.breathe-circle.animating {
  animation: breathe 8s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  37.5% { transform: scale(1.5); opacity: 1; }
  62.5% { transform: scale(1.5); opacity: 1; }
}

/* ============================================================
   HABIT VIEW
   ============================================================ */

.habit-overview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.habit-stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  text-align: center;
}

.habit-stat-value {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 800;
  color: var(--habit-color);
  letter-spacing: -1px;
}

.habit-stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.habit-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 12px;
}

.habit-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.habit-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  text-transform: capitalize;
}

.streak-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 12px;
  background: rgba(245,158,11,0.1);
  border: 1px solid rgba(245,158,11,0.2);
  color: var(--habit-color);
  font-size: 13px;
  font-weight: 600;
}

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

.habit-progress-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--habit-color), #fbbf24);
  transition: width 0.8s ease;
}

.habit-heatmap {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 4px;
}

.heatmap-day {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  background: var(--border);
  flex-shrink: 0;
  transition: background 0.3s;
}

.heatmap-day.done { background: var(--habit-color); }
.heatmap-day.partial { background: rgba(245,158,11,0.4); }

.habit-consistency { font-size: 12px; color: var(--text-muted); }

/* ============================================================
   EMPTY STATES
   ============================================================ */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}

.empty-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.4; }
.empty-title { font-size: 17px; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; }
.empty-hint { font-size: 14px; line-height: 1.6; }

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */

#toast-container {
  position: fixed;
  top: 80px;
  right: 16px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  animation: toastIn 0.3s ease;
  backdrop-filter: blur(20px);
  pointer-events: auto;
  max-width: 300px;
}

.toast.success { background: rgba(16,185,129,0.15); border: 1px solid rgba(16,185,129,0.3); color: var(--success); }
.toast.error { background: rgba(244,63,94,0.15); border: 1px solid rgba(244,63,94,0.3); color: var(--danger); }
.toast.info { background: rgba(99,102,241,0.15); border: 1px solid rgba(99,102,241,0.3); color: var(--accent); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (min-width: 768px) {
  .view, .capture-view {
    padding: 32px 24px;
    max-width: 680px;
  }

  .main-content { padding-bottom: calc(var(--nav-bottom-height) + 24px); }

  .nav-item span { font-size: 11px; }
}

/* ============================================================
   LOADING SKELETON
   ============================================================ */

.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

.skeleton-line { height: 16px; margin-bottom: 10px; }
.skeleton-line:last-child { width: 60%; }

/* ============================================================
   DIALOG / MODAL
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.modal-overlay.open { opacity: 1; pointer-events: auto; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-xl) var(--radius-xl) var(--radius-md) var(--radius-md);
  padding: 28px 24px;
  width: 100%;
  max-width: 560px;
  transform: translateY(30px);
  transition: transform 0.3s ease;
}

.modal-overlay.open .modal { transform: translateY(0); }

.modal-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 20px;
}

.modal-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
  margin-bottom: 12px;
}

.modal-input:focus { border-color: var(--accent); }

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

.btn-secondary {
  flex: 1;
  padding: 13px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover { border-color: var(--border-active); color: var(--text-primary); }

.btn-primary {
  flex: 2;
  padding: 13px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border: none;
  border-radius: var(--radius-md);
  color: white;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s;
}

.btn-primary:hover { box-shadow: 0 4px 20px rgba(99,102,241,0.4); }

/* ============================================================
   DATE TIME HELPER
   ============================================================ */

.timestamp {
  font-size: 12px;
  color: var(--text-muted);
}

/* ============================================================
   LOGIN SCREEN
   ============================================================ */

#loginScreen {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: hidden;
}

#loginScreen.hidden { display: none; }

/* Animated background orbs */
.login-bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.25;
  animation: orbFloat 8s ease-in-out infinite;
  pointer-events: none;
}

.login-bg-orb:nth-child(1) {
  width: 400px; height: 400px;
  background: #6366f1;
  top: -100px; left: -100px;
  animation-delay: 0s;
}

.login-bg-orb:nth-child(2) {
  width: 300px; height: 300px;
  background: #8b5cf6;
  bottom: -80px; right: -80px;
  animation-delay: -4s;
}

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(30px, -30px) scale(1.08); }
}

.login-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: rgba(22, 22, 30, 0.85);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-xl);
  padding: 40px 32px;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 32px 80px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.04);
  animation: loginCardIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes loginCardIn {
  from { opacity: 0; transform: translateY(40px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.login-logo {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 800;
  background: linear-gradient(135deg, #6366f1, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -1px;
  margin-bottom: 6px;
}

.login-tagline {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 36px;
}

.login-field {
  margin-bottom: 16px;
}

.login-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 8px;
}

.login-input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

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

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

.login-btn {
  width: 100%;
  padding: 15px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
  transition: all 0.25s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 20px rgba(99,102,241,0.35);
}

.login-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(99,102,241,0.5);
}

.login-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.login-btn .btn-spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: none;
}

.login-btn.loading .btn-spinner { display: block; }
.login-btn.loading .btn-label { display: none; }

.login-error {
  display: none;
  margin-top: 14px;
  padding: 12px 16px;
  background: rgba(244,63,94,0.1);
  border: 1px solid rgba(244,63,94,0.25);
  border-radius: var(--radius-md);
  color: var(--danger);
  font-size: 13px;
  line-height: 1.5;
}

.login-error.visible { display: block; animation: fadeIn 0.3s ease; }

/* Logout button in top nav */
.logout-btn {
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 5px;
}

.logout-btn:hover {
  border-color: rgba(244,63,94,0.4);
  color: var(--danger);
}

/* ============================================================
   REPORT VIEW
   ============================================================ */

/* Period tabs */
.report-period-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 4px;
  border: 1px solid var(--border);
}

.report-period-tab {
  flex: 1;
  padding: 9px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.report-period-tab.active {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white;
  box-shadow: 0 2px 12px rgba(99,102,241,0.35);
}

/* Stats grid */
.report-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.report-stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.report-stat-icon { font-size: 20px; margin-bottom: 6px; }
.report-stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-muted); margin-bottom: 4px; }
.report-stat-value {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  line-height: 1;
}
.report-stat-value span { font-size: 14px; color: var(--text-muted); font-weight: 500; }
.report-stat-sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.report-progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 8px 0 4px;
  overflow: hidden;
}
.report-progress-fill { height: 100%; border-radius: 2px; transition: width 0.8s ease; }
.task-fill  { background: linear-gradient(90deg, #6366f1, #a78bfa); }
.habit-fill { background: linear-gradient(90deg, #f59e0b, #fbbf24); }

.report-task-list { margin-top: 10px; display: flex; flex-direction: column; gap: 5px; }
.report-task-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-secondary);
}
.report-task-item.done { color: var(--text-muted); text-decoration: line-through; }
.report-task-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--border-active);
  flex-shrink: 0;
}
.report-task-item.done .report-task-dot { background: var(--success); }
.report-task-item.todo .report-task-dot { background: var(--accent); }

.report-mood-row { font-size: 20px; margin-top: 8px; letter-spacing: 3px; }
.report-food-note { font-size: 11px; color: var(--journal-color); margin-top: 4px; }
.report-empty-note { font-size: 12px; color: var(--text-muted); margin-top: 8px; }

/* Habit timing items */
.report-timing-list { margin-top: 10px; display: flex; flex-direction: column; gap: 7px; }
.report-timing-item {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  font-size: 11px;
}
.timing-status-icon { font-size: 13px; flex-shrink: 0; margin-top: 1px; }
.timing-habit-name { font-weight: 600; color: var(--text-primary); font-size: 11px; }
.timing-note { color: var(--text-muted); font-size: 10px; margin-top: 1px; }

/* AI insights */
.ai-insights-wrap { display: flex; flex-direction: column; gap: 14px; margin-bottom: 24px; }

.ai-section-header {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.ai-insight-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  position: relative;
  overflow: hidden;
}

.ai-insight-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, #6366f1, #a78bfa, transparent);
}

.overall-card { border-color: rgba(99,102,241,0.3); background: linear-gradient(135deg, rgba(99,102,241,0.07), var(--bg-card)); }

.ai-insight-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
  margin-bottom: 8px;
}

.ai-insight-text {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin: 0;
}

.ai-tip {
  margin-top: 10px;
  padding: 10px 12px;
  background: rgba(99,102,241,0.08);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.ai-health-note {
  margin-top: 10px;
  padding: 10px 12px;
  background: rgba(16,185,129,0.07);
  border-left: 3px solid var(--journal-color);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.ai-mood-note {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
}

.ai-timing-note {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 8px;
  padding: 6px 10px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
}

.report-loading, .ai-insight-loading {
  text-align: center;
  padding: 32px 20px;
  color: var(--text-muted);
  font-size: 14px;
  animation: pulse 1.5s ease-in-out infinite;
}
