/* ============================================================
   MukRun – Happy Wealth Health 2026
   style.css  (shared across all pages)
   Thumb-first mobile design — all primary actions in bottom half
   ============================================================ */

:root {
  --green:      #06C755;
  --green-dark: #04a844;
  --green-bg:   #E8F9EE;
  --orange:     #FF6B35;
  --blue:       #2F80ED;
  --purple:     #9B51E0;
  --red:        #EB5757;
  --gold:       #F2C94C;
  --gray-bg:    #F4F6F5;
  --text-dark:  #1a1a1a;
  --text-mid:   #666;
  --text-light: #aaa;
  --radius:     18px;
  --nav-h:      62px;
  --action-h:   80px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; margin: 0; padding: 0; }

html, body {
  background: var(--gray-bg);
  font-family: "Noto Sans Thai", "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  color: var(--text-dark);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

/* ── App shell ── */
.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
}

/* ── Top bar ── */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px 14px;
  background: linear-gradient(135deg, var(--green), var(--green-dark));
  color: #fff;
  border-radius: 0 0 22px 22px;
  box-shadow: 0 4px 16px rgba(6,199,85,.25);
}
.topbar .avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.7);
  object-fit: cover;
  background: #ddd;
  flex-shrink: 0;
}
.topbar .greet { font-size: 19px; font-weight: 700; }
.topbar .sub   { font-size: 14px; opacity: .88; margin-top: 2px; }
.topbar .score-pill {
  margin-left: auto;
  background: rgba(255,255,255,.2);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 15px;
  font-weight: 800;
  white-space: nowrap;
  flex-shrink: 0;
}
.back-btn {
  background: none; border: none;
  color: #fff; font-size: 26px;
  padding: 4px 8px; cursor: pointer;
  flex-shrink: 0;
}

/* ── Scrollable content ── */
.container {
  padding: 16px 16px 0;
  /* leave room for bottom-action + nav */
  padding-bottom: calc(var(--action-h) + var(--nav-h) + 16px);
}
.container.no-action {
  padding-bottom: calc(var(--nav-h) + 20px);
}

/* ── Section title ── */
.section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-mid);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin: 20px 0 10px;
}
.section-title:first-child { margin-top: 16px; }

/* ── Card ── */
.card {
  background: #fff;
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: 0 2px 12px rgba(0,0,0,.06);
}
.card-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 14px;
}
.card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #f0f0f0;
}
.card-row:last-child { border-bottom: none; }
.card-row .label { font-size: 15px; color: var(--text-mid); }
.card-row .value { font-size: 20px; font-weight: 800; }
.trend-up   { color: var(--red); }
.trend-down { color: var(--green-dark); }

/* ── Action grid (thumb zone) ── */
.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}
.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 22px 10px;
  border-radius: var(--radius);
  border: none;
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  min-height: 100px;
  box-shadow: 0 4px 12px rgba(0,0,0,.13);
  text-decoration: none;
  -webkit-user-select: none;
}
.action-btn:active { transform: scale(.97); }
.action-btn .icon { font-size: 36px; line-height: 1; }
.bg-green  { background: linear-gradient(135deg,#06C755,#04a844); }
.bg-orange { background: linear-gradient(135deg,#FF6B35,#e0531c); }
.bg-blue   { background: linear-gradient(135deg,#2F80ED,#1565c0); }
.bg-purple { background: linear-gradient(135deg,#9B51E0,#7b3bbf); }
.bg-gold   { background: linear-gradient(135deg,#F2C94C,#d4a017); }

/* ── Stat mini cards (horizontal strip) ── */
.stat-strip {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}
.stat-card {
  flex: 1;
  background: #fff;
  border-radius: 14px;
  padding: 14px 10px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.stat-card .num  { font-size: 26px; font-weight: 800; color: var(--green-dark); }
.stat-card .lbl  { font-size: 12px; color: var(--text-mid); margin-top: 2px; }

/* ── Buttons ── */
.btn {
  display: block;
  width: 100%;
  text-align: center;
  padding: 17px;
  font-size: 19px;
  font-weight: 800;
  border: none;
  border-radius: var(--radius);
  background: var(--green);
  color: #fff;
  cursor: pointer;
  min-height: 58px;
  letter-spacing: .02em;
  box-shadow: 0 4px 14px rgba(6,199,85,.35);
}
.btn:active    { transform: scale(.98); filter: brightness(.92); }
.btn:disabled  { opacity: .5; }
.btn.secondary {
  background: #fff;
  color: var(--green-dark);
  border: 2px solid var(--green);
  box-shadow: none;
}
.btn.orange { background: var(--orange); box-shadow: 0 4px 14px rgba(255,107,53,.35); }

/* ── Fixed bottom action ── */
.bottom-action {
  position: fixed;
  bottom: var(--nav-h);
  left: 0; right: 0;
  max-width: 480px;
  margin: 0 auto;
  padding: 8px 16px 10px;
  background: linear-gradient(to top, var(--gray-bg) 85%, transparent);
  z-index: 90;
}

/* ── Score preview pill ── */
.score-preview {
  background: var(--green-bg);
  border-radius: 12px;
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 15px;
}
.score-preview .num {
  font-size: 26px;
  font-weight: 800;
  color: var(--green-dark);
}

/* ── Form fields ── */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 14px;
  color: var(--text-mid);
  margin-bottom: 6px;
  font-weight: 600;
}
.field input[type="text"],
.field input[type="number"],
.field input[type="date"],
.field select {
  width: 100%;
  font-size: 20px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 2px solid #e8e8e8;
  background: #fafafa;
  color: var(--text-dark);
  font-family: inherit;
  -webkit-appearance: none;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--green);
  background: #fff;
}

/* ── Duration big input ── */
.dur-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
}
.dur-wrap input {
  flex: 1;
  font-size: 36px;
  font-weight: 800;
  text-align: center;
  padding: 10px;
  border-radius: 14px;
  border: 2px solid #e8e8e8;
  background: #fafafa;
  min-width: 0;
}
.dur-wrap .step-btn {
  width: 56px; height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--green-bg);
  color: var(--green-dark);
  font-size: 28px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  line-height: 1;
}
.dur-wrap .step-btn:active { background: var(--green); color: #fff; }

/* ── Choice chips ── */
.chip-group { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 4px; }
.chip {
  padding: 12px 18px;
  border-radius: 999px;
  border: 2px solid #e0e0e0;
  font-size: 16px;
  background: #fff;
  cursor: pointer;
  font-family: inherit;
  color: var(--text-dark);
  -webkit-user-select: none;
}
.chip.selected {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
  font-weight: 700;
}
.chip:active { transform: scale(.96); }

/* ── Toggle behavior row ── */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid #f2f2f2;
  cursor: pointer;
  -webkit-user-select: none;
}
.toggle-row:last-child { border-bottom: none; }
.toggle-row .icon-wrap {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: #f2f2f2;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.toggle-row.active .icon-wrap { background: var(--green-bg); }
.toggle-row .info { flex: 1; min-width: 0; }
.toggle-row .info .name  { font-size: 16px; font-weight: 600; }
.toggle-row .info .desc  { font-size: 13px; color: var(--text-mid); margin-top: 2px; }
.toggle-row .pts  { font-size: 13px; font-weight: 700; color: var(--text-mid); flex-shrink: 0; }
.toggle-row.active .pts  { color: var(--green-dark); }
.toggle-check {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid #ddd;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.toggle-row.active .toggle-check {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

/* ── Camera box ── */
.camera-box {
  border: 2.5px dashed #ccc;
  border-radius: var(--radius);
  text-align: center;
  padding: 24px 16px;
  color: var(--text-mid);
  cursor: pointer;
  margin-bottom: 14px;
}
.camera-box .icon { font-size: 36px; display: block; margin-bottom: 6px; }
.camera-box img.preview {
  max-width: 100%;
  border-radius: 12px;
  margin-top: 12px;
  display: none;
}

/* ── Medal ── */
.medal-big {
  text-align: center;
  padding: 24px 0 16px;
}
.medal-big .icon   { font-size: 80px; line-height: 1; display: block; }
.medal-big .name   { font-size: 26px; font-weight: 800; margin-top: 8px; }
.medal-big .score  { font-size: 16px; color: var(--text-mid); margin-top: 4px; }

.progress-bar {
  width: 100%;
  height: 18px;
  background: #eee;
  border-radius: 999px;
  overflow: hidden;
  margin: 10px 0;
}
.progress-bar .fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--green-dark));
  border-radius: 999px;
  transition: width .5s ease;
}

/* ── Leaderboard rows ── */
.lb-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #f2f2f2;
}
.lb-row:last-child { border-bottom: none; }
.lb-row .rank  { width: 26px; text-align: center; font-weight: 800; color: var(--text-mid); flex-shrink: 0; }
.lb-row .rank.top3 { color: var(--gold); font-size: 18px; }
.lb-row .name  { flex: 1; font-size: 15px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-row .pts   { font-weight: 800; font-size: 15px; flex-shrink: 0; }
.lb-row.me     { background: var(--green-bg); margin: 0 -18px; padding: 10px 18px; }

/* ── Tag / badge ── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: #FFE8CC;
  color: #B8641A;
}
.badge.green { background: var(--green-bg); color: var(--green-dark); }

/* ── History log row ── */
.log-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid #f2f2f2;
}
.log-row:last-child { border-bottom: none; }
.log-row .log-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--green-bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.log-row .log-info { flex: 1; min-width: 0; }
.log-row .log-name { font-size: 15px; font-weight: 600; }
.log-row .log-sub  { font-size: 12px; color: var(--text-mid); }
.log-row .log-pts  { font-size: 16px; font-weight: 800; color: var(--green-dark); flex-shrink: 0; }

/* ── Bottom navigation ── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  max-width: 480px;
  margin: 0 auto;
  height: var(--nav-h);
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  background: #fff;
  border-top: 1px solid #ebebeb;
  box-shadow: 0 -2px 12px rgba(0,0,0,.08);
  z-index: 100;
}
.bottom-nav a {
  text-decoration: none;
  color: var(--text-light);
  font-size: 11px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex: 1;
  padding: 6px 0 max(6px, env(safe-area-inset-bottom));
  cursor: pointer;
  -webkit-user-select: none;
}
.bottom-nav a .nav-icon { font-size: 23px; line-height: 1; }
.bottom-nav a.active { color: var(--green-dark); }
.bottom-nav a.active .nav-icon {
  filter: drop-shadow(0 0 3px rgba(4,168,68,.4));
}

/* ── Toast & Cheer ── */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--action-h) + 10px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30,30,30,.92);
  color: #fff;
  padding: 13px 20px;
  border-radius: 14px;
  font-size: 15px;
  max-width: 88%;
  text-align: center;
  z-index: 200;
  opacity: 0;
  transition: opacity .25s;
  pointer-events: none;
  backdrop-filter: blur(6px);
}
.toast.show { opacity: 1; }

.cheer-toast {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--action-h) + 70px);
  left: 16px; right: 16px;
  max-width: 448px;
  margin: 0 auto;
  background: linear-gradient(135deg, #1DB446, var(--green-dark));
  color: #fff;
  padding: 16px 18px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.55;
  z-index: 201;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity .35s, transform .35s;
  pointer-events: none;
  box-shadow: 0 6px 24px rgba(4,168,68,.4);
}
.cheer-toast.show { opacity: 1; transform: translateY(0); }

/* ── Loading / Spinner ── */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 14px;
  color: var(--text-mid);
  font-size: 16px;
}
.loading-screen .app-name {
  font-size: 28px;
  font-weight: 800;
  color: var(--green-dark);
}
.spinner {
  width: 44px; height: 44px;
  border: 5px solid #e0e0e0;
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading { text-align: center; padding: 28px 0; color: var(--text-mid); }
.loading .spinner { margin: 0 auto 12px; }

/* ── Center message ── */
.center-msg {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-mid);
  font-size: 16px;
  line-height: 1.6;
}
.center-msg .big { font-size: 52px; }

/* ── Error card ── */
.error-card {
  margin: 20px 16px;
  background: #fff5f5;
  border: 2px solid var(--red);
  border-radius: var(--radius);
  padding: 18px;
}
.error-card .err-title { font-weight: 800; color: var(--red); margin-bottom: 8px; }
.error-card .err-msg   { font-size: 14px; color: #555; line-height: 1.5; white-space: pre-wrap; word-break: break-all; }
