:root {
  --color-bg: #FBF6F2;
  --color-surface: #FFFFFF;
  --color-primary: #C97B84;
  --color-primary-dark: #A85D68;
  --color-primary-light: #F3D9DC;
  --color-accent: #8A9A7E;
  --color-accent-light: #E4EAD9;
  --color-text: #4A3F3D;
  --color-text-soft: #8A7A77;
  --color-border: #EFE1DB;
  --color-gold: #D8B472;
  --shadow-soft: 0 8px 24px rgba(169, 120, 120, 0.12);
  --shadow-card: 0 4px 14px rgba(169, 120, 120, 0.08);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --font-heading: 'Fraunces', Georgia, serif;
  --font-body: 'Nunito Sans', 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html {
  color-scheme: light;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

#app {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
  min-height: 100vh;
  background: var(--color-bg);
  position: relative;
}

img { max-width: 100%; display: block; }

h1, h2, h3 {
  font-family: var(--font-heading);
  color: var(--color-primary-dark);
  margin: 0 0 8px;
  font-weight: 600;
}

p { line-height: 1.6; margin: 0 0 12px; color: var(--color-text); }

a { color: inherit; }

button {
  font-family: var(--font-body);
  cursor: pointer;
  border: none;
  background: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 15px;
  transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  color: #fff;
  box-shadow: var(--shadow-soft);
}
.btn-primary:disabled {
  opacity: .45;
  box-shadow: none;
  cursor: not-allowed;
}

.btn-ghost {
  background: var(--color-surface);
  color: var(--color-primary-dark);
  border: 1.5px solid var(--color-border);
}

.btn-text {
  color: var(--color-primary-dark);
  font-weight: 700;
  padding: 8px;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 24px 20px 100px;
  animation: fadeIn .35s ease;
}

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

.hidden { display: none !important; }

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
}
.topbar .logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-heading);
  font-size: 18px;
  color: var(--color-primary-dark);
  font-weight: 600;
}
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
  color: var(--color-primary-dark);
  font-size: 18px;
}

/* Bottom nav */
.bottom-nav {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--color-text-soft);
  padding: 6px 0;
  border-radius: 12px;
}
.nav-item .nav-icon { font-size: 20px; }
.nav-item.active { color: var(--color-primary-dark); }

/* Cards */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-card);
  margin-bottom: 16px;
}

/* Welcome / Onboarding */
.welcome-hero {
  text-align: center;
  padding: 40px 8px 20px;
}
.welcome-hero .badge {
  display: inline-block;
  background: var(--color-accent-light);
  color: var(--color-accent);
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: 18px;
}
.welcome-hero h1 {
  font-size: 30px;
  line-height: 1.25;
}
.welcome-hero p {
  color: var(--color-text-soft);
  font-size: 15.5px;
  margin-top: 10px;
}
.hero-flourish {
  width: 100%;
  margin: 20px 0;
}

.onboard-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 18px 0;
}
.onboard-dots span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--color-border);
  transition: all .2s ease;
}
.onboard-dots span.active {
  background: var(--color-primary);
  width: 22px;
  border-radius: 4px;
}

.sticky-footer {
  position: sticky;
  bottom: 0;
  padding: 16px 20px calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--color-bg) 60%, transparent);
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}
.sticky-footer .btn { width: 100%; }

/* Progress ring / bar */
.progress-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: var(--color-primary-light);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-gold));
  border-radius: 999px;
  transition: width .4s ease;
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 26px 0 12px;
}
.section-title h2 { font-size: 19px; margin: 0; }
.section-title .link { font-size: 13px; font-weight: 700; color: var(--color-primary-dark); }

/* Day path (home) */
.day-path {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.day-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-card);
  position: relative;
  border: 1.5px solid transparent;
}
.day-row.today {
  border-color: var(--color-primary);
}
.day-row.locked { opacity: .55; }
.day-circle {
  width: 46px; height: 46px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 17px;
  flex-shrink: 0;
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
}
.day-row.done .day-circle {
  background: var(--color-accent);
  color: #fff;
}
.day-row.today .day-circle {
  background: var(--color-primary);
  color: #fff;
}
.day-info { flex: 1; min-width: 0; }
.day-info .day-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--color-text-soft);
  font-weight: 700;
}
.day-info .day-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.day-check { font-size: 20px; color: var(--color-accent); flex-shrink: 0; }
.day-lock { font-size: 16px; color: var(--color-text-soft); flex-shrink: 0; }

/* Stats row */
.stats-row {
  display: flex;
  gap: 12px;
}
.stat-card {
  flex: 1;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow-card);
}
.stat-card .stat-value {
  font-family: var(--font-heading);
  font-size: 24px;
  color: var(--color-primary-dark);
  font-weight: 700;
}
.stat-card .stat-label {
  font-size: 11px;
  color: var(--color-text-soft);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* Day detail screen */
.day-hero {
  border-radius: var(--radius-lg);
  padding: 24px;
  background: linear-gradient(155deg, var(--color-primary-light), var(--color-bg));
  margin-bottom: 20px;
}
.day-hero .day-label {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-primary-dark);
}
.day-hero h1 { font-size: 24px; margin-top: 6px; }
.day-hero .day-quote {
  font-style: italic;
  color: var(--color-text-soft);
  font-size: 14px;
  margin-top: 10px;
  border-left: 3px solid var(--color-primary);
  padding-left: 12px;
}

.block { margin-bottom: 18px; }
.block h3 {
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.block h3 .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--color-primary);
  display: inline-block;
}

textarea.journal-input, input.journal-input {
  width: 100%;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-family: var(--font-body);
  font-size: 14.5px;
  background: var(--color-surface);
  resize: vertical;
  min-height: 90px;
  color: var(--color-text);
}
textarea.journal-input:focus, input.journal-input:focus {
  outline: none;
  border-color: var(--color-primary);
}

input[type="radio"] {
  accent-color: var(--color-primary);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  accent-color: var(--color-primary);
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: var(--color-primary-light);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  margin-top: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-primary);
  border: 3px solid #fff;
  box-shadow: 0 2px 6px rgba(169, 120, 120, 0.35);
}
input[type="range"]::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: var(--color-primary-light);
}
input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-primary);
  border: 3px solid #fff;
  box-shadow: 0 2px 6px rgba(169, 120, 120, 0.35);
}

.checklist { display: flex; flex-direction: column; gap: 10px; }
.check-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  padding: 14px;
  box-shadow: var(--shadow-card);
}
.check-box {
  width: 24px; height: 24px;
  border-radius: 7px;
  border: 2px solid var(--color-border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
  transition: all .15s ease;
}
.check-item.checked .check-box {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
}
.check-item.checked .check-label {
  text-decoration: line-through;
  color: var(--color-text-soft);
}
.check-label { font-size: 14.5px; line-height: 1.45; }

/* Empty / celebratory states */
.empty-state {
  text-align: center;
  padding: 40px 16px;
  color: var(--color-text-soft);
}
.empty-state .emoji { font-size: 40px; margin-bottom: 10px; }

/* Toast */
#toast {
  position: fixed;
  left: 50%;
  bottom: 100px;
  transform: translateX(-50%) translateY(20px);
  background: var(--color-text);
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: all .25s ease;
  z-index: 50;
  max-width: 90%;
  text-align: center;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Journal / Diary list */
.journal-entry {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-card);
  margin-bottom: 12px;
}
.journal-entry .je-day {
  font-size: 11px;
  font-weight: 800;
  color: var(--color-primary-dark);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 6px;
}
.journal-entry .je-q {
  font-size: 12.5px;
  color: var(--color-text-soft);
  margin-bottom: 4px;
}
.journal-entry .je-a {
  font-size: 14.5px;
  color: var(--color-text);
}

/* Profile */
.profile-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}
.avatar {
  width: 60px; height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary-light), var(--color-primary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-size: 22px;
  color: #fff;
  font-weight: 700;
}
.settings-list { display: flex; flex-direction: column; gap: 10px; }
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  box-shadow: var(--shadow-card);
  font-size: 14.5px;
  font-weight: 600;
}

/* Splash */
#splash {
  position: fixed;
  inset: 0;
  background: linear-gradient(160deg, var(--color-primary-light), var(--color-bg));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: opacity .5s ease;
}
#splash h1 {
  font-size: 26px;
  text-align: center;
  padding: 0 30px;
}
#splash .flower {
  font-size: 46px;
  margin-bottom: 14px;
}

@media (min-width: 481px) {
  #app { border-radius: 28px; box-shadow: 0 20px 60px rgba(0,0,0,0.12); margin: 20px auto; min-height: calc(100vh - 40px); overflow: hidden; }
}
