:root {
  --bg: #f2f1f8;
  --bg-2: rgba(255,255,255,0.85);
  --bg-3: rgba(245,244,252,0.9);
  --bg-4: #eceaf5;
  --border: rgba(108,71,245,0.12);
  --accent: #6c47f5;
  --accent-light: #ede9ff;
  --accent-2: #8b6ef7;
  --gold: #f0a500;
  --text: #1a1a2e;
  --text-2: #5a5a72;
  --text-3: #9898b0;
  --red: #ef4444;
  --green: #22c55e;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 2px 16px rgba(108,71,245,0.08);
  --shadow-md: 0 6px 32px rgba(108,71,245,0.13);
  --topbar-h: 60px;
  --transition: 0.18s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }

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

/* ─── Animated Background ────────── */
.bg-animation {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background: linear-gradient(135deg, #f0eeff 0%, #faf8ff 50%, #eef5ff 100%);
}

.bg-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.55;
}

.bg-blob-1 {
  width: 600px; height: 600px;
  background: radial-gradient(circle, #c4b0ff 0%, #a78bfa 60%, transparent 100%);
  top: -150px; left: -100px;
  animation: float1 14s ease-in-out infinite;
}

.bg-blob-2 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, #bfdbfe 0%, #93c5fd 60%, transparent 100%);
  bottom: -120px; right: -80px;
  animation: float2 18s ease-in-out infinite;
}

@keyframes float1 {
  0%,100% { transform: translate(0, 0) scale(1); }
  33%      { transform: translate(60px, 40px) scale(1.08); }
  66%      { transform: translate(-30px, 70px) scale(0.95); }
}

@keyframes float2 {
  0%,100% { transform: translate(0, 0) scale(1); }
  33%      { transform: translate(-70px, -50px) scale(1.06); }
  66%      { transform: translate(40px, -30px) scale(0.97); }
}

/* ─── App Layout ─────────────────── */
.app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── Top Navigation Bar ─────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--topbar-h);
  background: rgba(255,255,255,0.75);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  box-shadow: 0 2px 20px rgba(108,71,245,0.06);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Playfair Display', serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  min-width: 120px;
}

.logo-icon { color: var(--accent); font-size: 1.1rem; }
.logo-text { color: var(--text); }

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  justify-content: center;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border: none;
  border-radius: 100px;
  background: none;
  color: var(--text-2);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.nav-btn:hover {
  background: var(--accent-light);
  color: var(--accent);
}

.nav-btn.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 12px rgba(108,71,245,0.3);
}

.nav-icon { font-size: 0.95rem; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 120px;
  justify-content: flex-end;
}

.streak {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(245, 200, 66, 0.15);
  border: 1px solid rgba(240,165,0,0.2);
  padding: 5px 12px;
  border-radius: 100px;
}

.streak-fire { font-size: 1rem; }
.streak-count { font-size: 0.9rem; font-weight: 700; color: var(--gold); }

/* ─── Save Status ────────────────── */
.save-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  color: var(--text-3);
  transition: all var(--transition);
}
.save-status.saving { color: var(--accent); }
.save-status.saved  { color: var(--green); }
.save-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-3);
  transition: background var(--transition);
}
.save-status.saving .save-dot { background: var(--accent); animation: pulse 1s infinite; }
.save-status.saved  .save-dot { background: var(--green); }

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

/* ─── Page Header ────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px 0;
  gap: 16px;
  flex-wrap: wrap;
  max-width: 820px;
  margin: 0 auto;
  width: 100%;
}

.page-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

.page-subtitle { font-size: 0.8rem; color: var(--text-3); margin-top: 2px; }

.page-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.date-btn {
  background: rgba(255,255,255,0.8);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 1.3rem;
  cursor: pointer;
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.date-btn:hover { background: var(--accent-light); color: var(--accent); border-color: var(--accent); }

.current-date {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  background: rgba(255,255,255,0.8);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 100px;
  white-space: nowrap;
}

/* ─── Buttons ────────────────────── */
.btn {
  padding: 8px 18px;
  border-radius: 100px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-outline {
  background: rgba(255,255,255,0.8);
  color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-outline:hover {
  background: var(--accent-light);
  color: var(--accent);
  border-color: var(--accent);
}

/* ─── Main ───────────────────────── */
.main { flex: 1; padding-bottom: 40px; }

/* ─── Views ──────────────────────── */
.view {
  display: none;
  padding: 20px 28px 0;
  max-width: 820px;
  margin: 0 auto;
  animation: fadeIn 0.25s ease;
}
.view.active { display: block; }

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

/* ─── Journal Stack ──────────────── */
.journal-stack { display: flex; flex-direction: column; gap: 16px; margin-top: 16px; }

/* ─── Sections ───────────────────── */
.journal-section {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.section-icon { font-size: 1rem; }

.section-header h2 {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.01em;
}

/* ─── Question Cards ─────────────── */
.q-stack { display: flex; flex-direction: column; gap: 12px; }

.question-card { display: flex; flex-direction: column; gap: 6px; }

.question-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: 0.01em;
}

.question-input {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 0.875rem;
  line-height: 1.6;
  resize: vertical;
  transition: border-color var(--transition), box-shadow var(--transition);
  min-height: 40px;
  backdrop-filter: blur(8px);
}

.question-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108,71,245,0.1);
  background: rgba(255,255,255,0.95);
}

.question-input::placeholder { color: var(--text-3); font-size: 0.82rem; }

/* ─── Energy ─────────────────────── */
.energy-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.energy-slider {
  flex: 1;
  -webkit-appearance: none;
  height: 5px;
  border-radius: 100px;
  background: var(--bg-4);
  outline: none;
  cursor: pointer;
}

.energy-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(108,71,245,0.4);
  cursor: pointer;
  transition: transform var(--transition);
}
.energy-slider::-webkit-slider-thumb:hover { transform: scale(1.15); }

.energy-val {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
  min-width: 32px;
  text-align: center;
}

/* ─── YT Stats ───────────────────── */
.yt-stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.yt-stat-card {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.yt-stat-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 5px;
}

.yt-stat-input {
  width: 100%;
  background: none;
  border: none;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  outline: none;
}
.yt-stat-input::placeholder { color: var(--text-3); font-weight: 400; font-size: 0.85rem; }

/* ─── Images ─────────────────────── */
.image-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 26px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg-3);
}
.image-upload-area:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}
.upload-placeholder { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.upload-icon { font-size: 1.5rem; }
.upload-placeholder p { color: var(--text-2); font-size: 0.85rem; }
.upload-hint { font-size: 0.7rem; color: var(--text-3); }

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.image-item {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 1;
  background: var(--bg-4);
}
.image-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.image-remove {
  position: absolute;
  top: 4px; right: 4px;
  background: rgba(255,255,255,0.9);
  border: none;
  color: var(--text);
  width: 22px; height: 22px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.65rem;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity var(--transition);
  box-shadow: var(--shadow);
}
.image-item:hover .image-remove { opacity: 1; }

/* ─── Calendar ───────────────────── */
.calendar-container {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 520px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  margin-top: 16px;
}
.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.cal-month-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}
.cal-nav-btn {
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text-2);
  width: 32px; height: 32px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all var(--transition);
  display: flex; align-items: center; justify-content: center;
}
.cal-nav-btn:hover { background: var(--accent-light); color: var(--accent); border-color: var(--accent); }
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-day-name {
  text-align: center;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-3);
  padding: 5px 0;
  letter-spacing: 0.05em;
}
.cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-2);
}
.cal-day:hover { background: var(--bg-3); color: var(--text); }
.cal-day.has-entry { background: var(--accent-light); color: var(--accent); font-weight: 700; }
.cal-day.has-entry:hover { background: var(--accent); color: #fff; }
.cal-day.today { background: var(--gold); color: #fff; font-weight: 700; }
.cal-day.today.has-entry { background: var(--accent); }
.cal-day.empty { cursor: default; }
.cal-day.empty:hover { background: none; }

/* ─── Entries ────────────────────── */
.entries-list { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.entry-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}
.entry-card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.entry-card-left { display: flex; align-items: center; gap: 14px; }
.entry-date-badge {
  background: var(--accent-light);
  border-radius: 8px;
  padding: 8px 12px;
  text-align: center;
  min-width: 52px;
}
.entry-date-day { font-size: 1.2rem; font-weight: 700; color: var(--accent); line-height: 1; }
.entry-date-month { font-size: 0.62rem; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 2px; }
.entry-info-title { font-size: 0.82rem; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.entry-preview { font-size: 0.75rem; color: var(--text-3); max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-energy-badge { font-size: 1rem; background: var(--bg-3); padding: 6px 10px; border-radius: 100px; border: 1px solid var(--border); }

/* ─── Toast ──────────────────────── */
.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  background: rgba(255,255,255,0.95);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-size: 0.82rem;
  color: var(--text);
  z-index: 1000;
  transform: translateY(70px);
  opacity: 0;
  transition: all 0.28s ease;
  pointer-events: none;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(12px);
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-color: var(--green); color: var(--green); }
.toast.error   { border-color: var(--red); color: var(--red); }

/* ─── Tages-Revue ────────────────── */
.tagesrevue-card {
  border-left: 3px solid var(--accent);
  background: linear-gradient(135deg, rgba(108,71,245,0.04) 0%, transparent 100%);
}

/* ─── Scrollbar ──────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(108,71,245,0.2); border-radius: 3px; }

/* ─── Responsive ─────────────────── */
@media (max-width: 768px) {
  .topbar { padding: 0 14px; gap: 10px; }
  .topbar-left { min-width: unset; }
  .logo-text { display: none; }
  .nav-btn { padding: 7px 12px; font-size: 0.82rem; gap: 5px; }
  .nav-label { display: none; }
  .topbar-right { min-width: unset; gap: 8px; }
  #saveLabel { display: none; }

  .page-header { padding: 14px 16px 0; }
  .page-title { font-size: 1.2rem; }
  .page-subtitle { font-size: 0.75rem; }

  .view { padding: 12px 16px 0; }
  .journal-section { padding: 16px; }
  .yt-stats-row { gap: 8px; }
  .yt-stat-card { padding: 10px; }

  .calendar-container { padding: 16px; }
  .entry-preview { max-width: 180px; }
  .entry-card { padding: 13px 14px; }

  .btn { padding: 7px 13px; font-size: 0.78rem; }
  .current-date { font-size: 0.78rem; padding: 5px 11px; }
}

@media (max-width: 400px) {
  .nav-btn { padding: 6px 10px; }
  .topbar { height: 52px; }
}
