:root {
  color-scheme: light;
  --bg: #f4f6f3;
  --surface: #ffffff;
  --surface-subtle: #f7f9f6;
  --text: #14211b;
  --muted: #51625a;
  --accent: #185a44;
  --accent-deep: #114534;
  --accent-soft: #e6f0eb;
  --teal: #0c6b82;
  --teal-soft: #edf6f9;
  --amber: #b45309;
  --amber-soft: #fff9eb;
  --red: #b91c1c;
  --red-soft: #fdf0ef;
  --slate: #3b5f8a;
  --border: rgba(20, 33, 27, 0.085);
  --shadow-sm: 0 1px 2px rgba(17, 32, 24, 0.04), 0 4px 14px rgba(17, 32, 24, 0.045);
  --radius-lg: 20px;
  --radius-md: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); }
h1, h2, h3, h4, h5, p, figure, ul, ol { margin: 0; }
a { color: var(--accent); }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; }

/* Sticky frosted-glass header (exact Uppa signature) */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  padding-top: env(safe-area-inset-top);
  background: rgba(244, 246, 243, 0.9);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.header-inner,
.page {
  width: min(600px, calc(100% - 1.75rem));
  margin-inline: auto;
}

.header-inner {
  min-height: 60px;
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  gap: 0.75rem;
}

.brand-mark { width: 40px; height: 36px; display: grid; place-items: center; }
.brand-mark svg { display: block; width: 40px; height: 24px; }

.segmented {
  justify-self: center;
  width: min(228px, 100%);
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  gap: 3px;
  border-radius: 13px;
  background: rgba(20, 33, 27, 0.075);
}

.segmented button {
  min-height: 38px;
  border: 0;
  background: transparent;
  display: grid;
  place-items: center;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 660;
  letter-spacing: -0.01em;
  color: var(--muted);
  transition: background-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
  -webkit-tap-highlight-color: transparent;
}

.segmented button[aria-current="page"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(17, 32, 24, 0.12), 0 1px 1px rgba(17, 32, 24, 0.06);
}

.page {
  padding-top: 0.95rem;
  padding-bottom: max(2.75rem, calc(env(safe-area-inset-bottom) + 1.5rem));
}

/* Uniform collapsible section cards */
.area-list { display: grid; gap: 0.85rem; }

.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.section-card > summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.95rem 1.05rem;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.section-card > summary::-webkit-details-marker { display: none; }

.summary-text { display: grid; gap: 0.14rem; min-width: 0; }
.summary-title { font-size: 1.04rem; font-weight: 740; letter-spacing: -0.015em; color: var(--text); line-height: 1.2; }
.summary-sub { font-size: 0.82rem; color: var(--muted); line-height: 1.3; }
.summary-right { display: flex; align-items: center; gap: 0.5rem; flex: none; }

.count-pill {
  padding: 0.22rem 0.62rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 720;
  background: rgba(20, 33, 27, 0.07);
  color: var(--muted);
  white-space: nowrap;
}
.pill-good { background: var(--accent-soft); color: var(--accent-deep); }
.pill-limit { background: var(--red-soft); color: var(--red); }
.pill-info { background: var(--teal-soft); color: var(--teal); }
.pill-warm-soft { background: var(--amber-soft); color: var(--amber); }

.chev {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: rgba(20, 33, 27, 0.06);
  color: var(--muted);
  display: grid;
  place-items: center;
  flex: none;
}
.chev svg { transition: transform 0.2s ease; }
details[open] > summary .chev svg { transform: rotate(180deg); }

.card-body {
  padding: 0.85rem 1rem 1.05rem;
  border-top: 1px solid var(--border);
}

/* Uniform dark-green Guidelines bar (identical height across Exercise & Diet) */
.guide-card {
  margin-bottom: 0.85rem;
  border-color: #164f3c;
}
.guide-card > summary {
  min-height: 70px;
  background: linear-gradient(135deg, #1a614a 0%, #124736 100%);
  color: #ffffff;
}
.guide-card > summary .summary-title { color: #ffffff; }
.guide-card > summary .summary-sub {
  color: rgba(255, 255, 255, 0.82);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.guide-card > summary .count-pill { background: rgba(255, 255, 255, 0.16); color: #ffffff; }
.guide-card > summary .chev { background: rgba(255, 255, 255, 0.16); color: #ffffff; }

.guide-list {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 0.55rem;
  margin-top: 0.7rem;
}
.guide-list li {
  padding: 0.68rem 0.82rem;
  border-radius: 12px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
}
.guide-list strong { display: block; font-size: 0.9rem; font-weight: 720; color: var(--text); }
.guide-list span { display: block; margin-top: 0.18rem; font-size: 0.83rem; color: var(--muted); line-height: 1.45; }

/* Dual why cards */
.dual-why-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.55rem; }
.why-pill-card {
  padding: 0.72rem 0.75rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  display: grid;
  gap: 0.28rem;
  align-content: start;
}
.why-pill-card.tone-green { background: #edf7f2; border-color: rgba(24, 90, 68, 0.22); }
.why-pill-card.tone-amber { background: #fff9eb; border-color: rgba(180, 115, 10, 0.24); }
.why-badge {
  display: inline-block; width: fit-content;
  padding: 0.16rem 0.48rem; border-radius: 999px;
  font-size: 0.7rem; font-weight: 740; color: #fff;
}
.tone-green .why-badge { background: var(--accent); }
.tone-amber .why-badge { background: var(--amber); }
.why-pill-card strong { font-size: 0.86rem; font-weight: 740; color: var(--text); line-height: 1.25; }
.why-pill-card span:last-child { font-size: 0.78rem; color: var(--muted); line-height: 1.4; }

.refresh-btn {
  width: 100%;
  margin-top: 0.75rem;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border-radius: 13px;
  border: 1.5px solid var(--border);
  background: rgba(255, 255, 255, 0.82);
  color: var(--accent-deep);
  font-size: 0.86rem;
  font-weight: 700;
  -webkit-tap-highlight-color: transparent;
}
.refresh-ico { flex: none; }
.loading-note { padding: 1.5rem; text-align: center; color: var(--muted); }
