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

:root {
  --cream: #FBF5EA; --card: #FFFDF8; --border: #E7DCC6; --border-lt: #EFE6D2;
  --ink: #4A3F30; --ink-soft: #5C5140; --muted: #A79A7E; --dash: #DDD1B4;
  --accent: #C08B6E; --accent-2: #7E9670;
  --mood-fill: #F3E4C8; --mood-fill-border: #DCC392; --mood-icon: #8A6A2E;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Poppins', sans-serif;
  background: var(--cream);
  color: var(--ink);
  min-height: 100vh;
  transition: background 0.25s ease;
}

.script { font-family: 'Caveat', cursive; }

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(1rem + env(safe-area-inset-top)) 1.25rem 1rem;
  position: sticky;
  top: 0;
  background: var(--cream);
  z-index: 10;
}

.app-header h1 {
  font-family: 'Caveat', cursive;
  font-size: 26px;
  font-weight: 700;
  margin: 0;
}

.header-actions { display: flex; gap: 8px; }

.icon-btn {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  color: var(--ink-soft);
}

main {
  max-width: 480px;
  margin: 0 auto;
  padding: 0.5rem 1.25rem calc(3rem + env(safe-area-inset-bottom));
}

.progress-card {
  background: var(--card);
  border: 1px solid var(--border-lt);
  border-radius: 16px;
  padding: 1rem 1.1rem;
  margin-bottom: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.progress-card .num { font-size: 22px; font-weight: 500; }
.progress-card .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.progress-bar-track {
  flex: 1; height: 6px; background: var(--border-lt); border-radius: 999px; margin: 0 14px; overflow: hidden;
}
.progress-bar-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.3s ease; }

.day-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.day-card {
  aspect-ratio: 1;
  background: var(--card);
  border: 1px solid var(--border-lt);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
  position: relative;
}

.day-card.done { background: var(--mood-fill); border-color: var(--mood-fill-border); color: var(--mood-icon); }
.day-card .check { position: absolute; top: 3px; right: 5px; font-size: 10px; }

.day-page-card {
  background: var(--card);
  border: 1px solid var(--border-lt);
  border-radius: 18px;
  padding: 1.5rem 1.4rem;
}

.day-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.9rem; }
.day-count { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

.mood-row { display: flex; gap: 6px; }
.mood-btn {
  width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--card);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 14px; color: var(--ink-soft);
}
.mood-btn.selected { background: var(--mood-fill); border-color: var(--mood-fill-border); color: var(--mood-icon); }

.day-title { font-family: 'Caveat', cursive; font-size: 28px; font-weight: 700; margin: 0 0 4px; line-height: 1.15; }

.dash-line { height: 1px; background: repeating-linear-gradient(to right, var(--dash) 0 6px, transparent 6px 11px); margin: 0.9rem 0 1.1rem; }

.day-prompt { font-size: 14px; line-height: 1.6; margin: 0 0 1rem; color: var(--ink-soft); }

textarea.entry {
  width: 100%; min-height: 220px;
  border: 1px solid var(--border-lt); background: var(--cream);
  border-radius: 14px; padding: 0.9rem 1rem;
  font-family: 'Poppins', sans-serif; font-size: 16px; line-height: 1.65;
  color: var(--ink); resize: vertical; outline: none;
}

.entry-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; font-size: 11px; color: var(--muted); }

.closing-line {
  text-align: center; margin-top: 1.4rem; padding-top: 1rem;
  border-top: 1px dashed var(--dash);
  font-family: 'Caveat', cursive; font-size: 18px; font-style: italic; color: var(--ink-soft);
}

.nav-row { display: flex; gap: 8px; margin-top: 1rem; }
.nav-btn {
  flex: 1; padding: 10px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--card); color: var(--ink-soft); font-size: 13px; font-weight: 500;
  cursor: pointer; text-align: center;
}
.nav-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }

.back-link {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 13px; color: var(--muted); cursor: pointer; margin-bottom: 0.75rem; background: none; border: none; padding: 0;
}

.theme-panel {
  background: var(--card); border: 1px solid var(--border-lt); border-radius: 16px;
  padding: 1rem 1.1rem; margin-bottom: 1.1rem;
}
.theme-panel h3 { font-size: 13px; margin: 0 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 500; }
.swatch-row { display: flex; gap: 10px; }
.swatch {
  width: 36px; height: 36px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent;
}
.swatch.active { border-color: var(--ink); }

.backup-heading { margin-top: 1rem; padding-top: 0.9rem; border-top: 1px solid var(--border-lt); }
.backup-panel { display: flex; flex-direction: column; gap: 8px; }
.backup-hint { font-size: 12px; color: var(--muted); line-height: 1.6; margin: 0 0 4px; }
.backup-btn { display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--accent); background: var(--accent); color: #fff; border-radius: 10px; padding: 9px; font-size: 13px; cursor: pointer; text-align: center; }
.backup-btn.secondary { background: var(--card); color: var(--ink-soft); border-color: var(--border); }
.backup-status { font-size: 12px; color: var(--accent-2); min-height: 14px; margin: 0; }

.hidden { display: none !important; }
