 
:root {
  --bg: #F3F6F4;
  --card: #FFFFFF;
  --ink: #33423B;
  --ink-soft: #7C8A83;
  --ink-faint: #A9B3AD;
  --line: #E6ECE8;

  --mint: #8FD6A6;
  --mint-deep: #4FAE73;
  --mint-bg: #EAF8EF;

  --sky: #8FCBE0;
  --sky-deep: #4C93AC;
  --sky-bg: #EAF5F9;

  --amber: #F0C36B;
  --amber-deep: #C99A3C;
  --amber-bg: #FBF3E1;

  --coral: #F0A090;
  --coral-deep: #C96B58;
  --coral-bg: #FBEBE7;

  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;

  --shadow-card: 0 2px 0 var(--line), 0 10px 24px -18px rgba(51,66,59,0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Nunito', sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  justify-content: center;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ---------- User Select Screen ---------- */
.user-select-screen {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 32px 20px;
}

.user-select-prompt {
  font-family: 'Baloo 2', sans-serif;
  font-weight: 800;
  font-size: 22px;
  color: var(--ink);
  text-align: center;
  margin: 0 0 22px;
}

.user-select-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.user-select-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 14px 14px;
  cursor: pointer;
  user-select: none;
  transition: transform 0.15s ease;
}
.user-select-card:active { transform: scale(0.98); }

.user-select-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.user-select-name {
  font-family: 'Baloo 2', sans-serif;
  font-weight: 700;
  font-size: 16px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-select-username {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-faint);
  margin-top: 1px;
}

.user-select-joined {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-faint);
  margin-top: 3px;
}

.user-select-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  color: var(--mint-deep);
  background: var(--mint-bg);
  border-radius: 999px;
  padding: 2px 8px;
  margin-top: 5px;
  width: fit-content;
}

.user-select-enter {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--mint-bg);
  color: var(--mint-deep);
  display: flex;
  align-items: center;
  justify-content: center;
}
.user-select-enter svg { width: 18px; height: 18px; }

.user-select-empty {
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-faint);
  padding: 20px;
}

/* ---------- App Shell ---------- */
.app {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ---------- Top App Bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bg);
  padding: 18px 16px 6px;
}

.topbar-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.profile-switch {
  flex: 1 1 auto;
  min-width: 0;
  transition: flex-basis 0.3s ease;
}

.ps-main {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border-radius: 999px;
  padding: 6px 16px 6px 6px;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  user-select: none;
}

.ps-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Baloo 2', sans-serif;
  font-weight: 700;
  font-size: 16px;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,0.08);
  background: linear-gradient(160deg, var(--mint) 0%, var(--mint-deep) 100%);
}

.ps-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.ps-name {
  font-family: 'Baloo 2', sans-serif;
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ps-username {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-faint);
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.25s ease, opacity 0.2s ease, margin-top 0.25s ease;
}
.profile-switch.expanded .ps-username {
  max-height: 18px;
  opacity: 1;
  margin-top: 1px;
}

.ps-chevron {
  flex-shrink: 0;
  color: var(--ink-faint);
  display: flex;
  transition: transform 0.3s ease;
}
.ps-chevron svg { width: 16px; height: 16px; }
.profile-switch.expanded .ps-chevron { transform: rotate(180deg); }

.add-btn {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--mint-deep);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: opacity 0.25s ease, width 0.3s ease, margin 0.3s ease, padding 0.3s ease;
}
.add-btn svg { width: 20px; height: 20px; }
.add-btn:active { transform: scale(0.94); }

.topbar-row.expanded .add-btn {
  opacity: 0;
  width: 0;
  height: 44px;
  overflow: hidden;
  pointer-events: none;
  margin-left: -10px;
}

.ps-dropdown {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  margin-top: 0;
  transition: max-height 0.3s ease, opacity 0.25s ease, margin-top 0.3s ease;
}
.ps-dropdown.open {
  max-height: 320px;
  opacity: 1;
  margin-top: 10px;
  overflow-y: auto;
}

.ps-dropdown-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border-radius: 999px;
  padding: 6px 6px;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}
.ps-dropdown-row:active { transform: scale(0.99); }

.ps-switch-icon {
  flex-shrink: 0;
  margin-left: auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--mint-bg);
  color: var(--mint-deep);
  display: flex;
  align-items: center;
  justify-content: center;
}
.ps-switch-icon svg { width: 16px; height: 16px; }

.ps-dropdown-empty {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-faint);
  text-align: center;
  padding: 6px;
}

/* ---------- Pages ---------- */
.pages {
  flex: 1;
  padding: 10px 16px 24px;
}

.page { display: none; }
.page.active { display: block; animation: fadeUp 0.35s ease; }

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

.page-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 56px 24px;
  min-height: 58vh;
  margin-top: 4px;
}

.page-placeholder-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
}
.page-placeholder-icon svg { width: 28px; height: 28px; }
.page-placeholder-icon.mint { background: var(--mint-bg); color: var(--mint-deep); }
.page-placeholder-icon.sky { background: var(--sky-bg); color: var(--sky-deep); }
.page-placeholder-icon.amber { background: var(--amber-bg); color: var(--amber-deep); }
.page-placeholder-icon.coral { background: var(--coral-bg); color: var(--coral-deep); }

.page-placeholder-title {
  font-family: 'Baloo 2', sans-serif;
  font-weight: 700;
  font-size: 19px;
  color: var(--ink);
  margin-bottom: 6px;
}

.page-placeholder-text {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-faint);
  max-width: 220px;
  line-height: 1.5;
}

/* ---------- Profile Page Component Styling ---------- */
.profile-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 8px 8px 20px;
}

.avatar-ring {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  padding: 5px;
  background: conic-gradient(var(--mint-deep) 0% var(--streak-pct, 0%), var(--line) var(--streak-pct, 0%) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: linear-gradient(160deg, var(--mint) 0%, var(--mint-deep) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Baloo 2', sans-serif;
  font-weight: 700;
  font-size: 34px;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,0.08);
}

.profile-header .name {
  font-family: 'Baloo 2', sans-serif;
  font-weight: 700;
  font-size: 22px;
  margin: 2px 0 2px;
  color: var(--ink);
}

.profile-header .username {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-faint);
  letter-spacing: 0.2px;
}

.streak-pill {
  margin-top: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--amber-bg);
  color: var(--amber-deep);
  font-weight: 800;
  font-size: 13px;
  padding: 7px 14px;
  border-radius: 999px;
}
.streak-pill svg { width: 14px; height: 14px; }

.profile-tabs {
  display: flex;
  background: #EAEFEC;
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 22px;
  gap: 4px;
}

.profile-tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 11px 0;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 14px;
  color: var(--ink-soft);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
}

.profile-tab-btn.active {
  background: var(--card);
  color: var(--mint-deep);
  box-shadow: 0 2px 0 var(--line), 0 4px 10px -6px rgba(51,66,59,0.3);
}

.profile-panel { display: none; }
.profile-panel.active { display: block; animation: fadeUp 0.35s ease; }

.section-label {
  font-family: 'Baloo 2', sans-serif;
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--ink-faint);
  margin: 0 4px 12px;
}

.overview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 6px;
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius-md);
  padding: 16px 14px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stat-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stat-icon svg { width: 18px; height: 18px; }

.stat-icon.mint { background: var(--mint-bg); color: var(--mint-deep); }
.stat-icon.sky { background: var(--sky-bg); color: var(--sky-deep); }
.stat-icon.amber { background: var(--amber-bg); color: var(--amber-deep); }
.stat-icon.coral { background: var(--coral-bg); color: var(--coral-deep); }

.stat-value {
  font-family: 'Baloo 2', sans-serif;
  font-weight: 700;
  font-size: 22px;
  color: var(--ink);
  line-height: 1;
}

.stat-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-soft);
}

.records-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.record-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  aspect-ratio: 3 / 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 16px 8px 12px;
  text-align: center;
}

.record-icon {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}
.record-icon svg { width: 22px; height: 22px; }

.record-icon.mint { background: var(--mint-bg); color: var(--mint-deep); }
.record-icon.sky { background: var(--sky-bg); color: var(--sky-deep); }
.record-icon.amber { background: var(--amber-bg); color: var(--amber-deep); }

.record-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.record-value {
  font-family: 'Baloo 2', sans-serif;
  font-weight: 700;
  font-size: 21px;
  color: var(--ink);
}

.record-title {
  font-size: 11.5px;
  font-weight: 800;
  color: var(--ink-soft);
  line-height: 1.25;
}

.record-date {
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-faint);
  opacity: 0.7;
  text-align: center;
  letter-spacing: 0.2px;
}

/* ---------- Bottom Navigation ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  background: var(--card);
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  box-shadow: 0 -2px 0 var(--line), 0 -10px 24px -18px rgba(51,66,59,0.35);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  z-index: 40;
}

.nav-btn {
  border: none;
  background: transparent;
  width: 52px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  color: var(--ink-faint);
  cursor: pointer;
  transition: background 0.25s ease, color 0.25s ease;
}
.nav-btn svg { width: 23px; height: 23px; }
.nav-btn.active {
  background: var(--mint-bg);
  color: var(--mint-deep);
}

.nav-spacer { height: 78px; }

@media (min-width: 420px) {
  .overview-grid { grid-template-columns: repeat(4, 1fr); }
  .stat-card { padding: 16px 12px; }
  .stat-value { font-size: 20px; }
}

@media (max-width: 340px) {
  .records-grid { grid-template-columns: 1fr 1fr; }
  .records-grid .record-card:last-child { grid-column: 1 / -1; max-width: calc(50% - 6px); margin: 0 auto; }
}
