/* ============ Healthier Tool — Design System ============ */
:root {
  --green: #0f9d76;
  --green-600: #0f8a68;
  --teal: #14b8a6;
  --blue: #3b82f6;
  --blue-600: #2563eb;
  --violet: #8b5cf6;
  --violet-600: #7c3aed;
  --amber: #f59e0b;
  --rose: #f43f5e;

  --bg: #f6f8fb;
  --bg-2: #eef2f7;
  --surface: #ffffff;
  --surface-2: #f9fbfd;
  --card-border: rgba(15, 23, 42, 0.08);
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #7b8794;
  --ring: rgba(59, 130, 246, 0.35);

  --grad-brand: linear-gradient(135deg, #0f9d76 0%, #14b8a6 40%, #3b82f6 100%);
  --grad-violet: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  --grad-warm: linear-gradient(135deg, #14b8a6 0%, #f59e0b 120%);

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 18px 48px rgba(15, 23, 42, 0.14);

  --r-sm: 10px;
  --r: 16px;
  --r-lg: 22px;
  --r-xl: 28px;

  --header-h: 66px;
  --maxw: 1200px;

  --font-head: "Sora", system-ui, sans-serif;
  --font-body: "Manrope", system-ui, sans-serif;
}

html[data-theme="dark"] {
  --bg: #0b1120;
  --bg-2: #0f172a;
  --surface: #131c2e;
  --surface-2: #182238;
  --card-border: rgba(148, 163, 184, 0.14);
  --text: #e8edf5;
  --text-2: #a8b3c4;
  --text-3: #7b8794;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  padding-bottom: env(safe-area-inset-bottom);
}
h1, h2, h3, h4, .display { font-family: var(--font-head); font-weight: 700; line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 .4em; }
h1 { font-size: clamp(2rem, 5vw, 3.6rem); }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); }
h3 { font-size: clamp(1.1rem, 2vw, 1.35rem); }
p { margin: 0 0 1rem; color: var(--text-2); }
a { color: var(--blue-600); text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }
::selection { background: rgba(20, 184, 166, 0.3); }

:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; border-radius: 6px; }

.skip-link { position: fixed; left: 12px; top: -60px; z-index: 200; background: var(--surface); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); transition: top .2s; }
.skip-link:focus { top: 12px; }

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 clamp(16px, 4vw, 28px); }

/* ============ Header / Nav ============ */
.app-header {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--card-border);
}
.header-inner { max-width: var(--maxw); margin: 0 auto; height: var(--header-h); padding: 0 clamp(14px, 4vw, 28px); display: flex; align-items: center; gap: 14px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-family: var(--font-head); font-weight: 800; font-size: 1.18rem; letter-spacing: -0.02em; }
.brand-mark { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--grad-brand); color: #fff; box-shadow: 0 6px 16px rgba(15, 157, 118, 0.4); }
.desktop-nav { display: flex; align-items: center; gap: 2px; margin-left: 8px; flex: 1; overflow: hidden; }
.desktop-nav a { color: var(--text-2); font-weight: 600; font-size: .86rem; padding: 8px 10px; border-radius: 10px; white-space: nowrap; transition: background-color .15s, color .15s; }
.desktop-nav a:hover { background: var(--bg-2); color: var(--text); }
.desktop-nav a.active { color: var(--green); background: color-mix(in srgb, var(--green) 12%, transparent); }
.header-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.icon-btn { width: 42px; height: 42px; border: 1px solid var(--card-border); background: var(--surface); color: var(--text); border-radius: 12px; display: grid; place-items: center; transition: background-color .15s, transform .15s; }
.icon-btn:hover { background: var(--bg-2); }
.icon-btn:active { transform: scale(.94); }
.menu-toggle { display: none; }

/* Mobile bottom nav */
.mobile-nav { display: none; }

/* Side drawer (More menu) */
.drawer-overlay { position: fixed; inset: 0; background: rgba(2, 6, 23, .5); z-index: 150; opacity: 0; transition: opacity .2s; }
.drawer-overlay.show { opacity: 1; }
.side-drawer {
  position: fixed; top: 0; right: 0; height: 100dvh; width: min(360px, 88vw); z-index: 160;
  background: var(--surface); box-shadow: var(--shadow-lg); padding: 20px; overflow-y: auto;
  transform: translateX(100%); transition: transform .28s cubic-bezier(.22,1,.36,1);
}
.side-drawer.show { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.drawer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.drawer-grid a { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 12px; background: var(--surface-2); color: var(--text); font-weight: 600; font-size: .9rem; border: 1px solid var(--card-border); }
.drawer-grid a.active { color: var(--green); border-color: color-mix(in srgb, var(--green) 40%, transparent); }
.drawer-grid a svg { color: var(--teal); flex: none; }

/* ============ Buttons ============ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 999px; padding: 12px 22px; font-weight: 700; font-size: .95rem; transition: transform .15s, box-shadow .15s, background-color .15s, border-color .15s; white-space: nowrap; color: var(--text); background: var(--surface); }
.btn svg { width: 18px; height: 18px; }
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary { background: var(--grad-brand); color: #fff; box-shadow: 0 10px 24px rgba(15, 157, 118, .35); border: none; }
.btn-primary:hover { box-shadow: 0 14px 30px rgba(15, 157, 118, .45); transform: translateY(-2px); }
.btn-violet { background: var(--grad-violet); color: #fff; border: none; box-shadow: 0 10px 24px rgba(124, 58, 237, .3); }
.btn-violet:hover { transform: translateY(-2px); }
.btn-outline { background: var(--surface); border-color: var(--card-border); }
.btn-outline:hover { background: var(--bg-2); border-color: var(--text-3); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-2); color: var(--text); }
.btn-sm { padding: 8px 14px; font-size: .84rem; }
.btn-danger { background: var(--rose); color: #fff; border: none; }
.btn-block { width: 100%; }
.btn-pill { border-radius: 999px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 999px; border: 1px solid var(--card-border); background: var(--surface); color: var(--text-2); font-weight: 600; font-size: .82rem; transition: all .15s; cursor: pointer; }
.chip:hover { border-color: var(--teal); color: var(--text); }
.chip.active { background: color-mix(in srgb, var(--green) 14%, transparent); border-color: var(--green); color: var(--green-600); }

/* ============ Cards & surfaces ============ */
.card { background: var(--surface); border: 1px solid var(--card-border); border-radius: var(--r); box-shadow: var(--shadow-sm); padding: clamp(16px, 3vw, 24px); }
.card-lg { border-radius: var(--r-lg); box-shadow: var(--shadow); }
.glass { background: color-mix(in srgb, var(--surface) 70%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--card-border); }
.section { padding: clamp(28px, 6vw, 56px) 0; }
.section-head { margin-bottom: clamp(16px, 3vw, 28px); }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-head); font-weight: 700; font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; color: var(--teal); margin-bottom: 10px; }
.muted { color: var(--text-3); }
.small { font-size: .84rem; }
.grid { display: grid; gap: clamp(12px, 2vw, 18px); }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.divider { height: 1px; background: var(--card-border); margin: 16px 0; border: none; }

/* Info / disclaimer callouts */
.callout { border-radius: var(--r); padding: 14px 16px; font-size: .88rem; border: 1px solid var(--card-border); background: var(--surface-2); color: var(--text-2); }
.callout.info { border-color: rgba(59, 130, 246, .3); background: color-mix(in srgb, var(--blue) 8%, var(--surface)); }
.callout.warn { border-color: rgba(245, 158, 11, .4); background: color-mix(in srgb, var(--amber) 10%, var(--surface)); }
.callout.danger { border-color: rgba(244, 63, 94, .4); background: color-mix(in srgb, var(--rose) 8%, var(--surface)); }
.callout strong { color: var(--text); }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: .72rem; font-weight: 700; background: var(--bg-2); color: var(--text-2); }
.badge.green { background: color-mix(in srgb, var(--green) 16%, transparent); color: var(--green-600); }
.badge.blue { background: color-mix(in srgb, var(--blue) 16%, transparent); color: var(--blue-600); }
.badge.violet { background: color-mix(in srgb, var(--violet) 16%, transparent); color: var(--violet-600); }
.badge.amber { background: color-mix(in srgb, var(--amber) 20%, transparent); color: #b45309; }

/* ============ Forms ============ */
label.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-weight: 700; font-size: .82rem; margin-bottom: 6px; color: var(--text); }
.field .hint { font-weight: 500; color: var(--text-3); font-size: .78rem; margin-top: 4px; }
input, select, textarea {
  width: 100%; font-family: inherit; font-size: .95rem; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--card-border); border-radius: 12px; padding: 12px 14px; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 4px rgba(20, 184, 166, .15); }
textarea { min-height: 90px; resize: vertical; }
.input-group { display: flex; gap: 8px; }
.input-group input { flex: 1; }
.field.error input, .field.error select { border-color: var(--rose); }
.err-msg { color: var(--rose); font-size: .8rem; margin-top: 4px; font-weight: 600; }
.seg { display: inline-flex; background: var(--bg-2); border-radius: 12px; padding: 4px; gap: 4px; flex-wrap: wrap; }
.seg button { border: none; background: transparent; padding: 8px 14px; border-radius: 9px; font-weight: 700; font-size: .85rem; color: var(--text-2); }
.seg button.active { background: var(--surface); color: var(--green); box-shadow: var(--shadow-sm); }

/* ============ Progress ============ */
.progress { height: 10px; border-radius: 999px; background: var(--bg-2); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: var(--grad-brand); width: 0; transition: width .6s cubic-bezier(.22,1,.36,1); }
.progress.violet > span { background: var(--grad-violet); }
.progress.amber > span { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.progress.blue > span { background: linear-gradient(90deg, #3b82f6, #60a5fa); }

.ring { position: relative; width: 120px; height: 120px; }
.ring svg { transform: rotate(-90deg); }
.ring .ring-label { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.ring .ring-val { font-family: var(--font-head); font-weight: 800; font-size: 1.4rem; }

/* ============ Stat cards ============ */
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat .num { font-family: var(--font-head); font-weight: 800; font-size: clamp(1.5rem, 4vw, 2.1rem); line-height: 1; }
.stat .lbl { font-size: .78rem; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.tile { border-radius: var(--r); padding: 18px; color: #fff; position: relative; overflow: hidden; }
.tile.g1 { background: var(--grad-brand); }
.tile.g2 { background: var(--grad-violet); }
.tile.g3 { background: var(--grad-warm); }
.tile .lbl { color: rgba(255,255,255,.85); }

/* ============ Tables / lists ============ */
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th, table.data td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--card-border); }
table.data th { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--card-border); border-radius: 14px; background: var(--surface); margin-bottom: 8px; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .grow strong { display: block; }
.list-row .meta { font-size: .8rem; color: var(--text-3); }
.tag-list { display: flex; gap: 6px; flex-wrap: wrap; }

/* ============ Tabs ============ */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 18px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { border: 1px solid var(--card-border); background: var(--surface); color: var(--text-2); padding: 9px 16px; border-radius: 999px; font-weight: 700; font-size: .85rem; white-space: nowrap; transition: all .15s; }
.tabs button.active { background: var(--text); color: var(--surface); border-color: var(--text); }

/* ============ Hero ============ */
.hero { position: relative; padding: clamp(36px, 7vw, 84px) 0 clamp(28px,5vw,56px); overflow: hidden; }
.hero::before { content: ""; position: absolute; inset: -20% -10% auto; height: 620px; background: radial-gradient(60% 60% at 20% 20%, rgba(20,184,166,.22), transparent 60%), radial-gradient(50% 50% at 85% 10%, rgba(139,92,246,.2), transparent 60%); pointer-events: none; }
.hero-grid { position: relative; display: grid; grid-template-columns: 1.15fr .85fr; gap: clamp(24px, 4vw, 48px); align-items: center; }
.hero h1 span.grad { background: var(--grad-brand); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero .lede { font-size: clamp(1.05rem, 2.2vw, 1.28rem); color: var(--text); font-weight: 600; margin-bottom: 6px; }
.hero .sub { max-width: 46ch; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 10px; margin: 22px 0; }
.hero-art { position: relative; }
.hero-card { border-radius: var(--r-xl); padding: 22px; }
.feature-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: clamp(24px,4vw,40px); }
.feature-card { border: 1px solid var(--card-border); border-radius: var(--r-lg); padding: 20px; background: var(--surface); transition: transform .2s, box-shadow .2s, border-color .2s; }
.feature-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: transparent; }
.feature-ic { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; color: #fff; margin-bottom: 12px; }
.feature-card h3 { margin-bottom: 4px; }
.feature-card p { margin: 0; font-size: .88rem; }

/* animated entrance */
.reveal { opacity: 0; transform: translateY(14px); animation: rise .6s forwards; }
@keyframes rise { to { opacity: 1; transform: none; } }

/* ============ Modal ============ */
.modal-overlay { position: fixed; inset: 0; z-index: 180; background: rgba(2,6,23,.55); display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.modal-overlay[hidden] { display: none !important; }
.modal { background: var(--surface); border-radius: var(--r-lg); width: min(620px, 96vw); max-height: 90dvh; overflow-y: auto; box-shadow: var(--shadow-lg); animation: pop .22s cubic-bezier(.22,1,.36,1); border: 1px solid var(--card-border); }
.modal.wide { width: min(880px, 96vw); }
@keyframes pop { from { opacity: 0; transform: scale(.95) translateY(10px); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--card-border); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.modal-body { padding: 20px; }
.modal-foot { padding: 16px 20px; border-top: 1px solid var(--card-border); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; position: sticky; bottom: 0; background: var(--surface); }

/* ============ Search ============ */
.search-overlay { position: fixed; inset: 0; z-index: 190; background: rgba(2,6,23,.5); backdrop-filter: blur(4px); padding: clamp(12px, 8vh, 90px) 16px 16px; }
.search-panel { max-width: 640px; margin: 0 auto; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); overflow: hidden; border: 1px solid var(--card-border); }
.search-box { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--card-border); color: var(--text-3); }
.search-box input { border: none; background: transparent; padding: 6px 0; }
.search-box input:focus { box-shadow: none; }
.search-results { max-height: 60vh; overflow-y: auto; padding: 8px; }
.search-item { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; cursor: pointer; }
.search-item:hover { background: var(--bg-2); }
.search-cat { font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--teal); padding: 12px 12px 4px; }

/* ============ Toast ============ */
.toast-wrap { position: fixed; z-index: 220; bottom: calc(16px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; width: min(420px, 92vw); }
.toast { background: var(--text); color: var(--surface); padding: 13px 16px; border-radius: 14px; font-weight: 600; font-size: .9rem; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 10px; animation: toastIn .25s; }
.toast.success { background: var(--green-600); color: #fff; }
.toast.error { background: var(--rose); color: #fff; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } }

/* Empty state */
.empty { text-align: center; padding: 40px 20px; color: var(--text-3); }
.empty svg { width: 46px; height: 46px; margin: 0 auto 12px; color: var(--text-3); opacity: .6; }

/* Macro/weight chart helpers */
.macro-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 12px; }
.macro-legend .li { display: flex; align-items: center; gap: 7px; font-size: .85rem; font-weight: 600; }
.dot { width: 12px; height: 12px; border-radius: 4px; }

/* exercise/muscle icon tile */
.ex-ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--bg-2); color: var(--teal); flex: none; }

.page-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; justify-content: space-between; margin-bottom: 20px; }

/* ============ Footer ============ */
.app-footer { border-top: 1px solid var(--card-border); background: var(--surface); margin-top: 40px; padding: 40px 0 calc(30px + env(safe-area-inset-bottom)); }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 30px; align-items: start; }
.footer-nav { display: flex; gap: 18px; flex-wrap: wrap; }
.footer-nav a { color: var(--text-2); font-weight: 600; font-size: .9rem; }
.footer-nav a:hover { color: var(--text); }

/* ============ Responsive ============ */
@media (max-width: 1080px) {
  .desktop-nav { display: none; }
  .menu-toggle { display: grid; }
}
@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-art { order: -1; }
  .g4 { grid-template-columns: repeat(2, 1fr); }
  .feature-cards { grid-template-columns: repeat(2, 1fr); }
  .footer-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .feature-cards { grid-template-columns: 1fr; }
  .mobile-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; z-index: 120;
    background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--card-border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .mobile-nav a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 2px; color: var(--text-3); font-size: .66rem; font-weight: 700; border-radius: 10px; }
  .mobile-nav a.active { color: var(--green); }
  .mobile-nav a svg { width: 22px; height: 22px; }
  .app-main { padding-bottom: 76px; }
  .drawer-grid { grid-template-columns: 1fr; }
  .modal-foot { flex-direction: column-reverse; }
  .modal-foot .btn { width: 100%; }
  .hero-cta .btn { flex: 1 1 100%; }
}
@media (max-width: 380px) {
  .brand-text { display: none; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* Print */
@media print {
  .app-header, .mobile-nav, .app-footer, .icon-btn, .btn, .tabs, .no-print, .side-drawer, .drawer-overlay { display: none !important; }
  body { background: #fff; color: #000; padding: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  .app-main { padding: 0 !important; }
  .print-only { display: block !important; }
}
.print-only { display: none; }
