/* 5K Every Day — sunrise orange/coral + deep teal on warm cream */
:root {
  --coral: #FF6B4A;
  --coral-soft: #FF8A5C;
  --coral-light: #FFE3D8;
  --teal: #0F5257;
  --teal-soft: #17706F;
  --cream: #FFF8F0;
  --white: #FFFFFF;
  --ink: #22302E;
  --muted: #6B7A78;
  --border: #F0DDCF;
  --gold: #FFB627;
  --green: #2E9E6B;
  --red: #D64545;
  --radius: 18px;
  --shadow: 0 4px 16px rgba(15, 82, 87, 0.10);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--cream);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
#app { max-width: 560px; margin: 0 auto; min-height: 100dvh; }
img { max-width: 100%; }
h1, h2, h3 { margin: 0; color: var(--teal); }
h2 { font-size: 1.15rem; font-weight: 800; }
p { margin: 0; }
button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; font-size: 1rem; }
a { color: var(--teal); }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }
[hidden] { display: none !important; }

/* ---------- Buttons & forms ---------- */
.btn {
  display: inline-block; border: none; border-radius: 999px;
  padding: 12px 22px; font-size: 1rem; font-weight: 800;
  text-decoration: none; text-align: center; transition: transform .08s ease, opacity .15s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: wait; }
.btn-primary { background: var(--coral); color: #fff; box-shadow: 0 4px 0 #E04E2E; }
.btn-primary:active { box-shadow: 0 1px 0 #E04E2E; }
.btn-secondary { background: var(--white); color: var(--teal); border: 2px solid var(--border); box-shadow: none; }
.btn-block { display: block; width: 100%; }
.btn-small { padding: 8px 16px; font-size: 0.9rem; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-weight: 800; color: var(--teal); margin-bottom: 6px; font-size: 0.95rem; }
.field input, .field textarea {
  width: 100%; border: 2px solid var(--border); border-radius: 14px;
  padding: 12px 14px; background: var(--white); color: var(--ink); outline: none;
}
.field input:focus, .field textarea:focus { border-color: var(--coral-soft); box-shadow: 0 0 0 3px var(--coral-light); }
.field textarea { resize: vertical; }
.hint { color: var(--muted); font-size: 0.8rem; font-weight: 400; }
.form-error {
  background: #FDECEC; color: var(--red); border-radius: 12px;
  padding: 10px 14px; margin: 0 0 14px; font-weight: 700; font-size: 0.92rem;
}
.form-row { display: flex; gap: 12px; }
.form-row .field { flex: 1; min-width: 0; }
.unit-row { display: flex; gap: 8px; }
.unit-row input { flex: 1; min-width: 0; }
.seg { display: flex; background: #FBEFE7; border-radius: 999px; padding: 3px; gap: 2px; }
.seg-wide { width: 100%; }
.seg-btn {
  flex: 1; border: none; background: transparent; border-radius: 999px;
  padding: 8px 10px; font-weight: 800; color: var(--teal); font-size: 0.92rem; white-space: nowrap;
}
.seg-btn.active { background: var(--teal); color: #fff; }

/* ---------- Auth ---------- */
.auth-wrap { padding: 48px 24px 32px; text-align: center; }
.auth-logo { width: 120px; height: 120px; border-radius: 28px; box-shadow: var(--shadow); }
.auth-title { font-size: 2rem; font-weight: 900; margin: 16px 0 6px; }
.auth-tag { color: var(--muted); margin-bottom: 24px; }
.auth-tabs { display: flex; background: #FBEFE7; border-radius: 999px; padding: 4px; margin-bottom: 20px; }
.auth-tab {
  flex: 1; border: none; background: transparent; border-radius: 999px;
  padding: 10px; font-weight: 800; font-size: 1rem; color: var(--teal);
}
.auth-tab.active { background: var(--teal); color: #fff; }
#auth-form { text-align: left; }
.auth-fine { color: var(--muted); font-size: 0.85rem; margin-top: 16px; }

/* ---------- App shell ---------- */
.app-header {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px 10px; position: sticky; top: 0; z-index: 20;
  background: var(--cream); background: color-mix(in srgb, var(--cream) 92%, transparent);
}
.header-logo { width: 36px; height: 36px; border-radius: 10px; }
.header-name { font-weight: 900; font-size: 1.15rem; color: var(--teal); flex: 1; }
.header-day { font-size: 0.82rem; font-weight: 800; color: var(--coral); background: var(--coral-light); padding: 4px 10px; border-radius: 999px; }
#views { padding: 4px 16px 110px; }
.view { animation: fadein .2s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.view-head { display: flex; align-items: center; justify-content: space-between; margin: 8px 0 14px; }
.view-head h2 { font-size: 1.4rem; }

.card {
  background: var(--white); border-radius: var(--radius);
  padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.card h2 { margin-bottom: 10px; }

/* ---------- Home ---------- */
.streak-card {
  background: linear-gradient(160deg, var(--teal) 0%, #176B66 100%);
  color: #fff; border-radius: 24px; padding: 26px 20px 20px;
  text-align: center; margin-bottom: 16px; box-shadow: var(--shadow);
}
.streak-card .flame { font-size: 3.4rem; line-height: 1; }
.streak-card .flame.hot { animation: flicker 1.1s ease-in-out infinite alternate; }
@keyframes flicker { from { transform: scale(1) rotate(-2deg); } to { transform: scale(1.12) rotate(2deg); } }
.streak-num { margin-top: 6px; font-size: 3rem; font-weight: 900; line-height: 1; }
.streak-num small { display: block; font-size: 1rem; font-weight: 700; opacity: .85; margin-top: 4px; }
.streak-msg { margin-top: 10px; opacity: .95; font-weight: 600; }
.freeze-note { margin-top: 8px; background: rgba(255, 182, 39, .25); border: 1px solid rgba(255, 182, 39, .6); border-radius: 10px; padding: 6px 10px; font-size: 0.88rem; font-weight: 700; }
.badges-row { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 14px; }
.badge { background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .35); border-radius: 999px; padding: 4px 10px; font-size: 0.8rem; font-weight: 800; }
.milestone-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.milestone-head span { color: var(--muted); font-weight: 700; }
.progress { height: 12px; background: #FBEFE7; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--coral-soft), var(--coral)); border-radius: 999px; transition: width .5s ease; }
.milestone-card p { margin-top: 8px; }
.week-strip { display: flex; gap: 6px; }
.week-day { flex: 1; text-align: center; padding: 8px 2px; border-radius: 12px; background: #FBEFE7; }
.week-day .wd-name { display: block; font-size: 0.72rem; font-weight: 800; color: var(--muted); text-transform: uppercase; }
.week-day .wd-num { display: block; font-weight: 900; color: var(--teal); }
.week-day.done { background: var(--teal); }
.week-day.done .wd-name, .week-day.done .wd-num { color: #fff; }
.week-day.today { outline: 2px solid var(--coral); outline-offset: 1px; }
.week-day .wd-check { display: block; font-size: 0.8rem; }
#week-note { margin-top: 10px; }
.checkin-done { background: #E7F6EE; color: var(--green); border-radius: 12px; padding: 12px 14px; font-weight: 700; margin-bottom: 14px; }
#note-count { font-weight: 700; }

/* ---------- Feed ---------- */
.feed-card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; overflow: hidden; }
.feed-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; }
.feed-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--coral-light); display: flex; align-items: center; justify-content: center; font-size: 1.2rem; font-weight: 900; color: var(--coral); flex-shrink: 0; }
.feed-who { flex: 1; min-width: 0; }
.feed-who strong { display: block; color: var(--teal); }
.feed-who span { font-size: 0.82rem; color: var(--muted); }
.feed-menu-btn { border: none; background: transparent; font-size: 1.3rem; color: var(--muted); padding: 4px 8px; line-height: 1; }
.feed-photo { width: 100%; display: block; max-height: 420px; object-fit: cover; background: #FBEFE7; }
.feed-body { padding: 12px 16px 14px; }
.feed-stats { display: flex; gap: 16px; font-weight: 800; color: var(--teal); margin-bottom: 6px; flex-wrap: wrap; }
.feed-stats span small { color: var(--muted); font-weight: 700; }
.feed-note { margin-bottom: 10px; }
.feed-actions { display: flex; gap: 10px; align-items: center; }
.cheer-btn { border: 2px solid var(--border); background: var(--white); border-radius: 999px; padding: 7px 16px; font-weight: 800; color: var(--teal); }
.cheer-btn.cheered { background: var(--coral-light); border-color: var(--coral); color: var(--coral); }
.cheer-count { font-size: 0.85rem; color: var(--muted); font-weight: 700; }

/* ---------- Learn ---------- */
.learn-intro { margin-bottom: 14px; }
.lesson-row {
  display: flex; gap: 14px; align-items: center; width: 100%; text-align: left;
  background: var(--white); border: none; border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.lesson-row.locked { opacity: 0.65; }
.lesson-num {
  width: 46px; height: 46px; flex-shrink: 0; border-radius: 50%;
  background: var(--coral-light); color: var(--coral); font-weight: 900; font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
}
.lesson-row.locked .lesson-num { background: #EFE9E4; color: var(--muted); }
.lesson-row.done .lesson-num { background: var(--teal); color: #fff; }
.lesson-info { flex: 1; min-width: 0; }
.lesson-info strong { display: block; color: var(--teal); font-size: 1rem; }
.lesson-info span { font-size: 0.88rem; color: var(--muted); display: block; }
.lesson-lock { font-size: 0.8rem; font-weight: 800; color: var(--muted); white-space: nowrap; }
.lesson-detail-card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-top: 12px; }
.lesson-detail-card video { width: 100%; border-radius: 14px; background: #111; margin: 12px 0; }
.lesson-body p { margin-bottom: 12px; }
.lesson-meta { color: var(--muted); font-size: 0.88rem; margin-bottom: 6px; }
.lesson-complete-note { background: #E7F6EE; color: var(--green); border-radius: 12px; padding: 10px 14px; font-weight: 700; margin-top: 14px; }

/* ---------- Profile ---------- */
.profile-head { display: flex; align-items: center; gap: 12px; margin: 8px 0 16px; }
.profile-avatar { width: 56px; height: 56px; border-radius: 50%; }
.profile-head h2 { font-size: 1.3rem; }
.profile-head > div { flex: 1; }
.premium-badge { background: var(--gold); color: #5A3A00; font-weight: 900; font-size: 0.8rem; padding: 5px 10px; border-radius: 999px; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.stat { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; text-align: center; }
.stat strong { display: block; font-size: 1.5rem; font-weight: 900; color: var(--teal); }
.stat span { font-size: 0.85rem; color: var(--muted); font-weight: 700; }
.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 120px; padding-top: 8px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.bar-val { font-size: 0.78rem; font-weight: 800; color: var(--teal); }
.bar { width: 100%; max-width: 34px; min-height: 6px; background: var(--coral-soft); border-radius: 6px 6px 0 0; }
.bar.today { background: var(--coral); }
.bar-label { font-size: 0.72rem; font-weight: 800; color: var(--muted); }
.perks { margin: 0 0 16px; padding-left: 4px; list-style: none; }
.perks li { padding: 3px 0; }
#premium-status { margin-bottom: 12px; }
.challenge { margin-bottom: 14px; }
.challenge:last-child { margin-bottom: 0; }
.challenge-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.challenge-head strong { color: var(--teal); }
.challenge p { font-size: 0.9rem; color: var(--muted); margin: 2px 0 8px; }
.challenge .progress { margin-bottom: 4px; }
.challenge-tag { font-size: 0.72rem; font-weight: 900; background: var(--gold); color: #5A3A00; border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.challenge-tag.free { background: #E7F6EE; color: var(--green); }

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 560px; z-index: 30;
  display: flex; background: var(--white);
  border-top: 1px solid var(--border);
  padding: 6px 4px calc(8px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 16px rgba(15, 82, 87, 0.08);
}
.nav-btn {
  flex: 1; border: none; background: transparent; display: flex; flex-direction: column;
  align-items: center; gap: 2px; padding: 6px 0; color: var(--muted); font-weight: 800; font-size: 0.78rem;
}
.nav-btn .nav-ico { font-size: 1.35rem; line-height: 1; }
.nav-btn.active { color: var(--coral); }

/* ---------- States / toast / overlays ---------- */
.state { text-align: center; padding: 48px 20px; color: var(--muted); }
.state .spinner { margin: 0 auto 14px; }
.spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 4px solid var(--coral-light); border-top-color: var(--coral);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty-emoji { font-size: 2.6rem; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 60;
  background: var(--teal); color: #fff; font-weight: 700;
  padding: 12px 20px; border-radius: 999px; box-shadow: var(--shadow);
  max-width: calc(100vw - 32px); text-align: center;
}
.celebrate {
  position: fixed; inset: 0; z-index: 50; background: rgba(15, 82, 87, 0.55);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.celebrate-card { background: var(--cream); border-radius: 24px; padding: 28px 22px; text-align: center; max-width: 360px; width: 100%; box-shadow: var(--shadow); animation: pop .25s ease; }
@keyframes pop { from { transform: scale(.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.celebrate-emoji { font-size: 3rem; }
.celebrate-card h2 { font-size: 1.5rem; margin: 8px 0; }
.celebrate-card p { margin-bottom: 14px; }
.confetti-piece { position: fixed; top: -12px; z-index: 55; width: 10px; height: 14px; border-radius: 2px; pointer-events: none; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); opacity: .8; } }
.install-banner {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(88px + env(safe-area-inset-bottom)); z-index: 40;
  width: calc(100% - 24px); max-width: 520px;
  background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 10px; padding: 12px;
}
.install-logo { width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0; }
.install-text { flex: 1; min-width: 0; }
.install-text strong { display: block; font-size: 0.92rem; color: var(--teal); }
.install-text span { font-size: 0.82rem; color: var(--muted); }
.install-dismiss { border: none; background: transparent; color: var(--muted); font-size: 1rem; padding: 6px; }

@media (min-width: 560px) {
  .streak-num { font-size: 3.4rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
