@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;600;700&family=DM+Sans:wght@300;400;500;600&display=swap');

:root {
  --sunflower-1: #1A237E;
  --sunflower-2: #303F9F;
  --sunflower-3: #3F51B5;
  --sunflower-4: #7986CB;
  --sunflower-5: #C5CAE9;

  --primary: #5D4037;
  --primary-light: #8D6E63;
  --accent: #F9A825;
  --accent-light: #FDD835;
  --warm-bg: #FFFDE7;
  --warm-bg-alt: #FFF8E1;
  --card-bg: #FFFFFF;
  --text: #3E2723;
  --text-secondary: #6D4C41;
  --text-light: #8D6E63;
  --border: #EFEBE9;
  --border-dark: #D7CCC8;
  --danger: #E53935;
  --danger-light: #FFEBEE;

  --mood-awful: #BCAAA4;
  --mood-bad: #D7CCC8;
  --mood-okay: #FFF176;
  --mood-good: #FFEE58;
  --mood-great: #FDD835;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(93, 64, 55, 0.08);
  --shadow-md: 0 4px 12px rgba(93, 64, 55, 0.1);
  --shadow-lg: 0 8px 24px rgba(93, 64, 55, 0.12);
}

::selection {
  background: var(--accent);
  color: var(--primary);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--warm-bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.app-container {
  min-height: 100vh;
  padding-bottom: 80px;
  max-width: 640px;
  margin: 0 auto;
}

/* Header */
.app-header {
  padding: 24px 20px 16px;
  text-align: center;
  background: linear-gradient(135deg, var(--sunflower-1) 0%, var(--sunflower-2) 50%, var(--sunflower-3) 100%);
  border-bottom: 3px solid var(--sunflower-4);
  position: relative;
  overflow: hidden;
}

.app-header::before {
  content: '';
  position: absolute;
  top: -30px;
  right: -30px;
  width: 120px;
  height: 120px;
  background: radial-gradient(circle, rgba(249, 168, 37, 0.3) 0%, transparent 70%);
  border-radius: 50%;
}

.app-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.5px;
  position: relative;
}

.app-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 300;
  margin-top: 2px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* Main */
.app-main {
  padding: 16px;
}

/* Tab Bar */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 4px;
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  padding: 8px 16px;
  z-index: 100;
  box-shadow: 0 -2px 12px rgba(93, 64, 55, 0.08);
}

.tab-btn {
  flex: 1;
  max-width: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--text-light);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.7rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.tab-btn.active {
  color: var(--primary);
  background: var(--warm-bg-alt);
}

.tab-btn:hover {
  background: var(--warm-bg);
}

.tab-icon {
  font-size: 1.25rem;
}

.tab-label {
  letter-spacing: 0.3px;
}

/* Field Labels */
.field-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 8px;
}

/* Journal Entry */
.journal-entry-container {
  animation: fadeInUp 0.4s ease both;
}

.entry-date-display {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--card-bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.date-icon {
  font-size: 1.1rem;
}

.date-text {
  font-weight: 500;
  color: var(--text);
  font-size: 0.95rem;
}

.today-exists-notice {
  background: var(--sunflower-1);
  border: 1px solid var(--sunflower-3);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 0.85rem;
  color: var(--primary);
}

/* Mood Selector */
.mood-selector {
  margin-bottom: 20px;
}

.mood-options {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.mood-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 14px;
  border: 2px solid var(--border);
  background: var(--card-bg);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 60px;
}

.mood-btn:hover {
  border-color: var(--border-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.mood-btn.selected {
  border-color: var(--accent);
  background: var(--warm-bg-alt);
  box-shadow: 0 0 0 3px rgba(249, 168, 37, 0.2);
  transform: translateY(-2px);
}

.mood-emoji {
  font-size: 1.5rem;
}

.mood-label-text {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Title Input */
.title-field {
  margin-bottom: 16px;
}

.title-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  color: var(--text);
  background: var(--card-bg);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  outline: none;
}

.title-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(249, 168, 37, 0.15);
}

.title-input::placeholder {
  color: var(--text-light);
}

/* Editor */
.editor-section {
  margin-bottom: 20px;
}

.editor-wrapper {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  min-height: 200px;
  box-shadow: var(--shadow-sm);
}

.editor-wrapper [contenteditable] {
  min-height: 180px;
  padding: 16px;
  font-size: 0.95rem;
  line-height: 1.7;
  outline: none;
  color: var(--text);
}

.editor-wrapper [contenteditable]:empty::before {
  color: var(--text-light);
}

/* Buttons */
.entry-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.btn-primary {
  padding: 12px 28px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.3px;
}

.btn-primary:hover {
  background: var(--primary-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-primary:disabled {
  background: var(--border-dark);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  padding: 12px 24px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: var(--warm-bg);
  border-color: var(--text-light);
}

/* Calendar */
.calendar-container {
  animation: fadeInUp 0.4s ease both;
}

.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.nav-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  font-size: 1.3rem;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-btn:hover {
  background: var(--warm-bg-alt);
  border-color: var(--accent);
}

.month-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--primary);
}

.month-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px;
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-value {
  font-weight: 600;
  font-size: 1rem;
  color: var(--primary);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-divider {
  color: var(--border-dark);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 16px;
}

.calendar-header-cell {
  text-align: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 0;
}

.calendar-cell {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  border: 1px solid var(--border);
  cursor: default;
  transition: all 0.2s ease;
  position: relative;
}

.calendar-cell.empty {
  background: transparent;
  border-color: transparent;
}

.calendar-cell.today {
  border-color: var(--accent);
  border-width: 2px;
}

.calendar-cell.has-entry {
  background: var(--cell-mood, var(--sunflower-1));
  border-color: transparent;
  cursor: pointer;
}

.calendar-cell.has-entry:hover {
  transform: scale(1.08);
  box-shadow: var(--shadow-md);
  z-index: 2;
}

.cell-day {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text);
}

.cell-mood-dot {
  font-size: 0.7rem;
  line-height: 1;
}

.calendar-legend {
  display: flex;
  justify-content: center;
  gap: 16px;
  padding: 12px;
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(93, 64, 55, 0.15);
}

/* Entry List */
.entry-list-container {
  animation: fadeInUp 0.4s ease both;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease;
}

.search-bar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(249, 168, 37, 0.15);
}

.search-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  color: var(--text);
  outline: none;
}

.search-input::placeholder {
  color: var(--text-light);
}

.search-clear {
  border: none;
  background: none;
  color: var(--text-light);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 4px;
}

.date-filter-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--sunflower-1);
  border: 1px solid var(--sunflower-3);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  font-size: 0.85rem;
  color: var(--primary);
}

.clear-filter-btn {
  border: none;
  background: var(--primary);
  color: #fff;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

/* Entry Cards */
.entries-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.entry-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  animation: fadeInUp 0.4s ease both;
}

.entry-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-dark);
}

.entry-card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  margin-bottom: 8px;
}

.entry-mood-badge {
  font-size: 1.6rem;
  flex-shrink: 0;
  line-height: 1;
}

.entry-card-meta {
  flex: 1;
  min-width: 0;
}

.entry-card-date {
  font-size: 0.75rem;
  color: var(--text-light);
  font-weight: 500;
  letter-spacing: 0.3px;
}

.entry-card-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  margin-top: 2px;
  line-height: 1.3;
}

.entry-card-preview {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
  cursor: pointer;
  padding-left: 44px;
}

.entry-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  padding-left: 44px;
}

.action-btn {
  border: none;
  background: transparent;
  color: var(--text-light);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.action-btn:hover {
  background: var(--warm-bg);
  color: var(--text);
}

.action-btn.edit-btn:hover {
  color: var(--accent);
}

.action-btn.delete-btn:hover {
  color: var(--danger);
}

.confirm-delete {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--danger);
}

.action-btn.delete-confirm {
  color: var(--danger);
  font-weight: 600;
}

.entry-count {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-light);
  margin-top: 16px;
  padding: 8px;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 48px 24px;
}

.empty-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 12px;
}

.empty-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.empty-text {
  font-size: 0.9rem;
  color: var(--text-light);
  line-height: 1.5;
}

/* Entry Detail */
.entry-detail-container {
  animation: fadeInUp 0.4s ease both;
}

.detail-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.back-btn {
  border: none;
  background: transparent;
  color: var(--primary);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
}

.back-btn:hover {
  background: var(--warm-bg-alt);
}

.detail-top-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}

.confirm-delete-inline {
  display: flex;
  gap: 4px;
  align-items: center;
}

.detail-mood-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: var(--banner-color, var(--sunflower-1));
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  box-shadow: var(--shadow-md);
}

.detail-mood-emoji {
  font-size: 2.5rem;
}

.detail-mood-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.detail-mood-label {
  font-family: 'Playfair Display', serif;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--primary);
}

.detail-date {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.detail-time {
  font-size: 0.75rem;
  color: var(--text-light);
}

.detail-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
  line-height: 1.3;
}

.detail-content {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  min-height: 120px;
}

.detail-content p {
  margin-bottom: 12px;
}

.detail-content p:last-child {
  margin-bottom: 0;
}

.detail-updated {
  text-align: right;
  font-size: 0.75rem;
  color: var(--text-light);
  margin-top: 12px;
  font-style: italic;
}

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

.skeleton-search {
  height: 48px;
  margin-bottom: 12px;
}

.skeleton-entry-card {
  height: 100px;
  margin-bottom: 10px;
}

.skeleton-calendar {
  height: 380px;
}

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

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

/* Focus styles */
input:focus,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Mobile responsive */
@media (max-width: 640px) {
  .app-header {
    padding: 20px 16px 12px;
  }

  .app-title {
    font-size: 1.5rem;
  }

  .mood-options {
    gap: 6px;
  }

  .mood-btn {
    padding: 10px 10px;
    min-width: 52px;
  }

  .mood-emoji {
    font-size: 1.3rem;
  }

  .mood-label-text {
    font-size: 0.6rem;
  }

  .calendar-cell {
    border-radius: 6px;
  }

  .cell-day {
    font-size: 0.7rem;
  }

  .cell-mood-dot {
    font-size: 0.6rem;
  }

  .entry-card-preview {
    padding-left: 0;
  }

  .entry-card-actions {
    padding-left: 0;
  }

  .detail-mood-banner {
    padding: 16px;
    gap: 12px;
  }

  .detail-mood-emoji {
    font-size: 2rem;
  }

  .detail-title {
    font-size: 1.3rem;
  }

  .detail-content {
    padding: 16px;
  }

  .legend-item {
    font-size: 0.7rem;
    gap: 3px;
  }

  .calendar-legend {
    gap: 10px;
    padding: 10px;
  }
}

@media (max-width: 380px) {
  .mood-btn {
    padding: 8px 6px;
    min-width: 46px;
  }

  .mood-emoji {
    font-size: 1.1rem;
  }

  .mood-label-text {
    display: none;
  }
}

<!-- WALKTHROUGH_SCRIPT:
[
  {"step": 1, "narration": "Welcome to your private daily journal with mood tracking. Let's write your first entry.", "view": "user", "highlight_selector": ".tab-btn:first-child", "wait_for": "tap_to_continue"},
  {"step": 2, "narration": "First, select how you're feeling today by tapping one of the mood emojis.", "view": "user", "highlight_selector": ".mood-options", "wait_for": "user_interaction"},
  {"step": 3, "narration": "Give your entry an optional title, then write your thoughts in the rich text editor below.", "view": "user", "highlight_selector": ".editor-wrapper", "wait_for": "user_interaction"},
  {"step": 4, "narration": "Tap 'Save Entry' to store your journal entry securely.", "view": "user", "highlight_selector": ".save-btn", "wait_for": "user_interaction"},
  {"step": 5, "narration": "Switch to the Calendar tab to see your mood history visualized with colors and emojis for each day.", "view": "user", "highlight_selector": ".tab-btn:nth-child(2)", "wait_for": "user_interaction"},
  {"step": 6, "narration": "Each day with an entry shows your mood emoji. Tap any day to read that entry.", "view": "user", "highlight_selector": ".calendar-grid", "wait_for": "tap_to_continue"},
  {"step": 7, "narration": "The Entries tab shows all your past entries. Use the search bar to find specific entries by title, content, or mood.", "view": "user", "highlight_selector": ".tab-btn:nth-child(3)", "wait_for": "user_interaction"},
  {"step": 8, "narration": "Tap any entry card to read the full entry, or use the edit and delete buttons to manage your journal.", "view": "user", "highlight_selector": ".entries-list", "wait_for": "tap_to_continue"}
]
-->

.auth-screen {
  display: flex;
  flex-direction: column;
}

.auth-main {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 24px;
  text-align: center;
}

.auth-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.35rem;
  color: var(--primary);
  margin-bottom: 10px;
}

.auth-text {
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 10px;
}

.auth-hint {
  font-size: 0.85rem;
  color: var(--text-light);
}

.auth-spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  margin: 0 auto 14px;
  animation: spin 0.8s linear infinite;
}

.app-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: relative;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  text-align: left;
}

.user-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(93, 64, 55, 0.15);
  box-shadow: var(--shadow-sm);
  background: var(--card-bg);
}

.user-avatar.fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--primary);
  background: var(--warm-bg-alt);
}

.user-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.user-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary);
}

.logout-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0;
  cursor: pointer;
}

.logout-btn:hover {
  color: var(--danger);
}

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

@media (max-width: 640px) {
  .app-header-row {
    flex-direction: column;
    align-items: center;
  }

  .user-menu {
    margin-left: 0;
  }
}

.charts-toggle-row {
  display: flex;
  justify-content: flex-end;
  margin: 8px 0 12px;
}

.charts-toggle-btn {
  border: 1px solid var(--border-dark);
  background: var(--card-bg);
  color: var(--primary);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.charts-toggle-btn:hover {
  background: var(--warm-bg-alt);
  border-color: var(--accent);
}

.entry-charts {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.chart-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--shadow-sm);
}

.chart-card-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.chart-card-header h3 {
  font-family: 'Playfair Display', serif;
  font-size: 1.02rem;
  color: var(--primary);
}

.chart-subtitle {
  font-size: 0.78rem;
  color: var(--text-light);
}

.chart-wrapper {
  width: 100%;
  position: relative;
}

.chart-wrapper-line {
  height: 220px;
}

.chart-wrapper-bar {
  height: 240px;
}

.trend-chart-canvas {
  width: 100% !important;
  height: 100% !important;
}

.chart-legend-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  margin-top: 10px;
}

.mini-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.mini-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.entry-card-meta-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
  padding-left: 44px;
}

.entry-word-count {
  font-size: 0.75rem;
  color: var(--text-light);
  background: var(--warm-bg);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 999px;
}

@media (max-width: 640px) {
  .chart-wrapper-line {
    height: 200px;
  }

  .chart-wrapper-bar {
    height: 220px;
  }

  .entry-card-meta-row {
    padding-left: 0;
  }
}

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

.attachment-field input[type='file'] {
  width: 100%;
  padding: 10px 12px;
  border: 1px dashed var(--border-dark);
  border-radius: var(--radius-sm);
  background: var(--warm-bg-alt);
  color: var(--text-secondary);
  font-family: 'DM Sans', sans-serif;
}

.attachment-status {
  margin-top: 8px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.attachment-preview-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.attachment-preview-item {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  box-shadow: var(--shadow-sm);
}

.attachment-preview-item img {
  width: 100%;
  height: 96px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
  margin-bottom: 8px;
}

.attachment-remove-btn {
  width: 100%;
  border: none;
  background: var(--danger-light);
  color: var(--danger);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.attachment-remove-btn:hover {
  background: #ffd7db;
}

.entry-attachments {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.entry-attachment {
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--card-bg);
  box-shadow: var(--shadow-sm);
}

.entry-attachment img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
}

.entry-attachment-caption {
  padding: 8px 10px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.monthly-export-panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
}

.monthly-export-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.monthly-export-header h3 {
  font-family: 'Playfair Display', serif;
  font-size: 1.02rem;
  color: var(--primary);
  margin-bottom: 2px;
}

.monthly-export-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.monthly-export-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.monthly-export-select {
  border: 1px solid var(--border-dark);
  background: var(--warm-bg-alt);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  outline: none;
}

.monthly-export-count {
  font-size: 0.8rem;
  color: var(--text-light);
}

.monthly-export-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.monthly-pdf-hidden {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  left: 0;
  top: 0;
  width: 100%;
  height: 0;
  overflow: hidden;
}

.monthly-pdf-page {
  width: 794px;
  min-height: 1123px;
  background: #fff;
  color: #3E2723;
  padding: 40px;
  font-family: 'DM Sans', sans-serif;
}

.monthly-pdf-report {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.monthly-pdf-header {
  border-bottom: 2px solid #F9A825;
  padding-bottom: 12px;
}

.monthly-pdf-header h1 {
  font-family: 'Playfair Display', serif;
  font-size: 28px;
  color: #5D4037;
  margin-bottom: 6px;
}

.monthly-pdf-header p {
  font-size: 14px;
  color: #6D4C41;
  line-height: 1.5;
}

.monthly-pdf-entries {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.monthly-pdf-empty {
  font-size: 14px;
  color: #6D4C41;
}

.monthly-pdf-entry {
  border: 1px solid #EFEBE9;
  border-radius: 12px;
  padding: 14px 16px;
  background: #FFFDE7;
}

.monthly-pdf-entry-top,
.monthly-pdf-entry-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.monthly-pdf-entry-top strong {
  font-family: 'Playfair Display', serif;
  font-size: 18px;
  color: #3E2723;
}

.monthly-pdf-entry-top span,
.monthly-pdf-entry-meta {
  font-size: 12px;
  color: #6D4C41;
}

.monthly-pdf-entry-content {
  margin-top: 10px;
  font-size: 13px;
  line-height: 1.7;
  color: #3E2723;
  white-space: pre-wrap;
}

@media (max-width: 640px) {
  .monthly-export-header,
  .monthly-export-controls,
  .monthly-pdf-entry-top,
  .monthly-pdf-entry-meta {
    flex-direction: column;
    align-items: flex-start;
  }
}

.data-export-panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
}

.data-export-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.data-export-header h3 {
  font-family: 'Playfair Display', serif;
  font-size: 1.02rem;
  color: var(--primary);
  margin-bottom: 2px;
}

.data-export-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.data-export-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.data-export-count {
  font-size: 0.8rem;
  color: var(--text-light);
  line-height: 1.5;
}

@media (max-width: 640px) {
  .data-export-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .data-export-actions {
    width: 100%;
  }

  .data-export-actions .data-export-btn {
    flex: 1;
  }
}
