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

:root {
  --bg: #fdf8f3;
  --surface: #ffffff;
  --surface2: #f5efe8;
  --text: #2d2416;
  --text-muted: #8b7355;
  --accent: #c8813a;
  --accent-light: #f0dcc4;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 4px 24px rgba(100, 60, 20, 0.10);
  --shadow-lg: 0 12px 48px rgba(100, 60, 20, 0.15);

  /* Mood colors */
  --happy:    #f9c74f;
  --excited:  #f45b69;
  --calm:     #90dbf4;
  --neutral:  #b8c0cc;
  --sad:      #6b8cff;
  --stressed: #ff7f5c;
  --anxious:  #c77dff;
  --grateful: #52d26f;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* ===== BACKGROUND BLOBS ===== */
.blob {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.35;
  pointer-events: none;
  z-index: 0;
  animation: blobFloat 12s ease-in-out infinite alternate;
}
.blob-1 { width: 500px; height: 500px; background: #f5cfa0; top: -150px; left: -150px; animation-duration: 14s; }
.blob-2 { width: 400px; height: 400px; background: #c8e6f5; bottom: -100px; right: -100px; animation-duration: 10s; animation-delay: 3s; }
.blob-3 { width: 300px; height: 300px; background: #d4f0c8; top: 40%; left: 60%; animation-duration: 16s; animation-delay: 6s; }

@keyframes blobFloat {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(30px, 20px) scale(1.05); }
}

/* ===== LAYOUT ===== */
.app-wrapper {
  position: relative;
  z-index: 1;
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

/* ===== HEADER ===== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 48px;
  flex-wrap: wrap;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-icon { font-size: 1.6rem; }
.logo-text {
  font-family: 'Playfair Display', serif;
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}

.nav-tabs {
  display: flex;
  background: var(--surface);
  border-radius: 50px;
  padding: 5px;
  gap: 2px;
  box-shadow: var(--shadow);
}
.tab {
  border: none;
  background: transparent;
  padding: 9px 20px;
  border-radius: 50px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.25s ease;
  white-space: nowrap;
}
.tab.active {
  background: var(--text);
  color: #fff;
  box-shadow: 0 2px 10px rgba(45,36,22,0.25);
}
.tab:not(.active):hover { color: var(--accent); }

/* ===== TAB CONTENT ===== */
.tab-content { display: none; animation: fadeUp 0.4s ease; }
.tab-content.active { display: block; }

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

/* ===== GREETING ===== */
.greeting-block { margin-bottom: 36px; }
.date-label {
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--accent);
  margin-bottom: 8px;
}
.greeting {
  font-family: 'Playfair Display', serif;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 10px;
}
.sub {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 300;
}

/* ===== MOOD GRID ===== */
.mood-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}

@media (max-width: 560px) { .mood-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 561px) and (max-width: 699px) { .mood-grid { grid-template-columns: repeat(3, 1fr); } }

.mood-btn {
  position: relative;
  background: var(--surface);
  border: 2.5px solid transparent;
  border-radius: var(--radius);
  padding: 22px 12px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
  overflow: hidden;
}
.mood-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.2s ease;
  border-radius: inherit;
}
.mood-btn:hover { transform: translateY(-5px); box-shadow: var(--shadow-lg); }
.mood-btn:hover::before { opacity: 0.07; }

/* Per-mood accent colors */
.mood-btn[data-mood="happy"]    { --mc: var(--happy); }
.mood-btn[data-mood="excited"]  { --mc: var(--excited); }
.mood-btn[data-mood="calm"]     { --mc: var(--calm); }
.mood-btn[data-mood="neutral"]  { --mc: var(--neutral); }
.mood-btn[data-mood="sad"]      { --mc: var(--sad); }
.mood-btn[data-mood="stressed"] { --mc: var(--stressed); }
.mood-btn[data-mood="anxious"]  { --mc: var(--anxious); }
.mood-btn[data-mood="grateful"] { --mc: var(--grateful); }

.mood-btn::before { background: var(--mc); }
.mood-btn:hover, .mood-btn.selected {
  border-color: var(--mc);
}
.mood-btn.selected {
  background: color-mix(in srgb, var(--mc) 12%, white);
  transform: translateY(-5px);
  box-shadow: 0 8px 30px color-mix(in srgb, var(--mc) 35%, transparent);
}

.mood-emoji { font-size: 2rem; line-height: 1; transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); }
.mood-btn:hover .mood-emoji, .mood-btn.selected .mood-emoji { transform: scale(1.25) rotate(-5deg); }

.mood-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.mood-btn.selected .mood-label { color: var(--text); font-weight: 600; }

.mood-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--mc);
  opacity: 0;
  transition: opacity 0.2s;
}
.mood-btn.selected .mood-dot { opacity: 1; }

/* ===== NOTE BLOCK ===== */
.note-block {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  animation: fadeUp 0.4s ease;
  margin-bottom: 20px;
}
.note-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.optional { font-weight: 300; text-transform: none; letter-spacing: 0; }
.note-input {
  width: 100%;
  border: 2px solid var(--surface2);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg);
  resize: none;
  height: 100px;
  transition: border-color 0.2s;
  outline: none;
  margin-bottom: 18px;
}
.note-input:focus { border-color: var(--accent); }
.note-input::placeholder { color: var(--text-muted); opacity: 0.6; }

/* ===== LOG BUTTON ===== */
.log-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--text);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 14px 32px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 16px rgba(45,36,22,0.25);
}
.log-btn:hover { background: var(--accent); transform: translateY(-2px); box-shadow: 0 6px 24px rgba(200,129,58,0.35); }
.log-btn.small { padding: 10px 22px; font-size: 0.85rem; margin-top: 20px; }

/* ===== QUOTE CARD ===== */
.quote-card {
  background: var(--text);
  color: #fff;
  border-radius: var(--radius);
  padding: 36px;
  box-shadow: var(--shadow-lg);
  animation: fadeUp 0.5s ease;
  position: relative;
  overflow: hidden;
}
.quote-card::before {
  content: '"';
  font-family: 'Playfair Display', serif;
  font-size: 12rem;
  color: rgba(255,255,255,0.05);
  position: absolute;
  top: -30px;
  left: 20px;
  line-height: 1;
  pointer-events: none;
}
.quote-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.quote-mood-tag {
  background: rgba(255,255,255,0.12);
  padding: 5px 14px;
  border-radius: 50px;
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: capitalize;
  letter-spacing: 0.5px;
}
.quote-saved-badge {
  color: var(--grateful);
  font-size: 0.85rem;
  font-weight: 500;
  animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes popIn {
  from { transform: scale(0.5); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
.quote-text {
  font-family: 'Playfair Display', serif;
  font-size: clamp(1.1rem, 2.5vw, 1.4rem);
  font-style: italic;
  line-height: 1.65;
  font-weight: 400;
  margin-bottom: 16px;
  position: relative;
  z-index: 1;
}
.quote-author {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.55);
  font-weight: 300;
}

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

.history-item {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px 24px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--mood-color, var(--accent));
  animation: fadeUp 0.35s ease;
  transition: transform 0.2s;
}
.history-item:hover { transform: translateX(4px); }
.history-emoji { font-size: 2rem; flex-shrink: 0; margin-top: 2px; }
.history-info { flex: 1; }
.history-mood {
  font-weight: 600;
  font-size: 1rem;
  text-transform: capitalize;
  margin-bottom: 3px;
}
.history-date { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 6px; }
.history-note { font-size: 0.88rem; color: var(--text-muted); font-style: italic; }
.history-quote { font-size: 0.8rem; color: var(--text-muted); margin-top: 6px; line-height: 1.5; }
.history-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  opacity: 0.4;
  transition: opacity 0.2s, color 0.2s;
  flex-shrink: 0;
  padding: 0 4px;
}
.history-delete:hover { opacity: 1; color: var(--stressed); }

/* ===== STATS ===== */
#stats-content { display: flex; flex-direction: column; gap: 24px; }

.stats-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
@media (max-width: 500px) { .stats-summary { grid-template-columns: repeat(2, 1fr); } }

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px 18px;
  box-shadow: var(--shadow);
  text-align: center;
}
.stat-value {
  font-family: 'Playfair Display', serif;
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 6px;
}
.stat-label { font-size: 0.78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.8px; font-weight: 500; }

.chart-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}
.chart-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.2rem;
  margin-bottom: 20px;
  font-weight: 700;
}

/* Bar chart */
.bar-chart { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: flex; align-items: center; gap: 12px; }
.bar-label { width: 85px; font-size: 0.82rem; color: var(--text-muted); text-transform: capitalize; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.bar-track { flex: 1; height: 12px; background: var(--surface2); border-radius: 50px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 50px; transition: width 1s cubic-bezier(0.16, 1, 0.3, 1); }
.bar-count { font-size: 0.82rem; color: var(--text-muted); min-width: 20px; text-align: right; font-weight: 600; }

/* Donut chart */
.donut-wrap { display: flex; align-items: center; gap: 32px; flex-wrap: wrap; }
.donut-chart { position: relative; width: 160px; height: 160px; flex-shrink: 0; }
.donut-chart canvas { width: 160px !important; height: 160px !important; }
.donut-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  pointer-events: none;
}
.donut-center-value { font-family: 'Playfair Display', serif; font-size: 1.6rem; font-weight: 700; line-height: 1; }
.donut-center-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.donut-legend { display: flex; flex-direction: column; gap: 8px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.legend-name { text-transform: capitalize; color: var(--text); }
.legend-pct { color: var(--text-muted); margin-left: auto; font-weight: 600; }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); font-size: 0.95rem; line-height: 1.8; }
.empty-icon { font-size: 3rem; display: block; margin-bottom: 12px; }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 30px; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--text);
  color: #fff;
  padding: 12px 28px;
  border-radius: 50px;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 999;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.4s ease;
  opacity: 0;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--accent-light); border-radius: 50px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 500px) {
  .header { flex-direction: column; align-items: flex-start; }
  .quote-card { padding: 24px; }
}
