/* Farrell Fitness. Macro colors follow competition bumper plates:
   calories orange, protein red, carbs yellow, fat green. */

@font-face { font-family: 'Barlow'; font-weight: 400; font-style: normal; font-display: swap; src: url(../fonts/barlow-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 500; font-style: normal; font-display: swap; src: url(../fonts/barlow-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 600; font-style: normal; font-display: swap; src: url(../fonts/barlow-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 500; font-style: normal; font-display: swap; src: url(../fonts/barlow-condensed-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 600; font-style: normal; font-display: swap; src: url(../fonts/barlow-condensed-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 700; font-style: normal; font-display: swap; src: url(../fonts/barlow-condensed-latin-700-normal.woff2) format('woff2'); }

:root {
  --ground: #E9EDF1; --surface: #FFFFFF; --ink: #16202B; --muted: #4E5B69;
  --line: #D3DAE2; --field: #C9D2DC; --rule: #E1E6EC;
  /* Brand: navy for actions, orange for calories and energy. */
  --primary: #00275B; --primary-hover: #001A40; --on-primary: #FFFFFF; --soft-primary: #B5C3DA; --tint-primary: #E6ECF5;
  --kcal: #E06A1F; --soft-kcal: #F6C4A2; --on-kcal: #FFFFFF; --brand-orange: #FF914D;
  --red: #C9302C; --yellow: #E2A90F; --green: #23874F; --dot: #9AA6B3;
  --deep: #00275B; --deep-2: #12396E; --on-deep: #EEF2F8; --on-deep-muted: #B8C6DC; --deep-green: #4FCB86;
  --sleep-light: #A9BCDB; --sleep-deep: #00275B; --sleep-rem: #E06A1F;
  --danger-bg: #FBE9E8; --danger-ink: #7E1B18;
  --radius-card: 18px; --radius-ctl: 12px;
  --display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --body: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --tabbar: 72px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0F1823; --surface: #182330; --ink: #E8EDF2; --muted: #9AA8B7;
    --line: #2A3746; --field: #2F3C4C; --rule: #253242;
    --primary: #FF914D; --primary-hover: #FFAA72; --on-primary: #0F1823; --soft-primary: #6B4329; --tint-primary: #33241C;
    --kcal: #FF914D; --soft-kcal: #6B4329; --on-kcal: #0F1823; --brand-orange: #FF914D;
    --red: #E5554F; --yellow: #F0BE2E; --green: #3DB874; --dot: #5F6E7E;
    --deep: #0A1A33; --deep-2: #1C3358; --sleep-light: #33507F; --sleep-deep: #8FAAD6; --sleep-rem: #FF914D;
    --danger-bg: #3A1A1A; --danger-ink: #F7B4B1;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #0F1823; --surface: #182330; --ink: #E8EDF2; --muted: #9AA8B7;
  --line: #2A3746; --field: #2F3C4C; --rule: #253242;
  --primary: #FF914D; --primary-hover: #FFAA72; --on-primary: #0F1823; --soft-primary: #6B4329; --tint-primary: #33241C;
    --kcal: #FF914D; --soft-kcal: #6B4329; --on-kcal: #0F1823; --brand-orange: #FF914D;
  --red: #E5554F; --yellow: #F0BE2E; --green: #3DB874; --dot: #5F6E7E;
  --deep: #0A1A33; --deep-2: #1C3358; --sleep-light: #33507F; --sleep-deep: #8FAAD6; --sleep-rem: #FF914D;
  --danger-bg: #3A1A1A; --danger-ink: #F7B4B1;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--ground); color: var(--ink); font: 400 15px/1.4 var(--body); -webkit-text-size-adjust: 100%; }
/* The page itself never scrolls: the content area scrolls inside a full-height shell, and the
   tab bar sits below it. On iPhone a position: fixed bar on a scrolling page drifts whenever the
   toolbar, keyboard or a sheet changes the viewport height. */
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body { display: flex; flex-direction: column; height: 100vh; height: 100dvh; -webkit-tap-highlight-color: transparent; }
a { color: var(--primary); }
a:hover { color: var(--primary-hover); }
h1, h2, h3 { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- app shell ---------- */
.shell { display: flex; flex: 1; min-height: 0; }
.sidebar { display: none; }
.content { flex: 1; min-width: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior-y: contain; padding-bottom: 28px; }
.view { max-width: 1240px; margin: 0 auto; padding: 0 16px; }
.tabbar {
  position: relative; flex: none; z-index: 20;
  height: calc(var(--tabbar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 12px; font-weight: 500; text-decoration: none; }
.tabbar a[aria-current="page"] { color: var(--primary); font-weight: 600; }
.tab-add { display: flex; align-items: center; justify-content: center; }
.tab-add button {
  width: 58px; height: 58px; margin-top: -20px; border-radius: 29px; border: 4px solid var(--surface); cursor: pointer;
  background: var(--kcal); color: var(--on-kcal); display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(0, 39, 91, 0.25);
}
.tab-add button svg { width: 26px; height: 26px; }
.add-btn {
  height: 44px; margin: 0 0 14px; border-radius: 10px; border: 0; cursor: pointer; font: 600 15px var(--body);
  background: var(--kcal); color: var(--on-kcal); display: flex; align-items: center; justify-content: center; gap: 8px;
}
.quick-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.quick-grid button { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 2px 10px; border: 0; border-radius: 14px; background: var(--ground); color: var(--ink); font: 600 13px var(--body); cursor: pointer; }
.quick-grid .qi { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; color: #fff; }
.quick-grid .qi svg { width: 22px; height: 22px; }
.tabbar svg, .sidebar svg { width: 24px; height: 24px; }

@media (min-width: 1024px) {
  .tabbar { display: none; }
  .content { padding-bottom: 40px; }
  .sidebar {
    display: flex; flex-direction: column; gap: 4px; width: 248px; flex: none;
    height: 100%; overflow-y: auto; padding: 28px 16px; background: var(--deep); color: var(--on-deep);
  }
  .sidebar .brand { font: 700 26px/1 var(--display); padding: 0 12px 24px; display: flex; align-items: center; gap: 10px; }
  .sidebar .brand img { width: 34px; height: 28px; flex: none; }
  .sidebar a { height: 44px; border-radius: 10px; padding: 0 12px; display: flex; align-items: center; gap: 12px; color: var(--on-deep-muted); font-weight: 500; text-decoration: none; }
  .sidebar a:hover { color: #fff; background: rgba(255,255,255,0.05); }
  .sidebar a[aria-current="page"] { background: var(--deep-2); color: #fff; font-weight: 600; }
  .sidebar svg { width: 20px; height: 20px; }
  .sidebar .spacer { flex: 1; }
  .view { padding: 0 32px; }
}

/* ---------- page header ---------- */
.page-head { padding: 28px 4px 12px; display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.page-head .eyebrow { font-size: 14px; color: var(--muted); font-weight: 500; }
.page-head h1 { font: 700 38px/1 var(--display); letter-spacing: -0.01em; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
@media (min-width: 1024px) { .page-head h1 { font-size: 44px; } }

/* ---------- cards & layout ---------- */
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; }
.row > * { min-width: 0; }
.card { background: var(--surface); border-radius: var(--radius-card); padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card.pad-lg { padding: 20px; }
.card.dark { background: var(--deep); color: var(--on-deep); }
.card.dark .muted { color: var(--on-deep-muted); }
.card h2 { font: 600 22px/1.1 var(--display); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.grow-3 { flex: 3 1 520px; }
.grow-2 { flex: 2 1 320px; }
.half { flex: 1 1 160px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 1024px) { .row, .stack { gap: 16px; } .card { padding: 22px 24px; } }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.num { font-family: var(--display); font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.num .unit { font-weight: 500; color: var(--muted); font-size: 0.55em; }
.card.dark .num .unit { color: var(--on-deep-muted); }
.stat { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.stat .num { font-size: 28px; }
.stat .label { font-size: 12px; color: var(--muted); }
.card.dark .stat .label { color: var(--on-deep-muted); }
.hero-num { font: 700 76px/0.9 var(--display); color: var(--kcal); font-variant-numeric: tabular-nums; }
@media (min-width: 1024px) { .hero-num { font-size: 96px; line-height: 0.88; } }
.hero-num.over { color: var(--red); }
p { margin: 0; }
.note { font-size: 14px; line-height: 1.45; color: var(--muted); }

/* ---------- controls ---------- */
.btn {
  height: 48px; padding: 0 18px; border-radius: var(--radius-ctl); border: 1px solid var(--field); background: var(--surface);
  font-weight: 600; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  cursor: pointer; text-decoration: none; color: var(--ink); white-space: nowrap;
}
.btn:hover { border-color: var(--muted); color: var(--ink); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--on-primary); }
.btn.danger { color: var(--red); }
.btn.sm { height: 40px; padding: 0 14px; border-radius: 10px; font-size: 14px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: 0.55; cursor: default; }
.icon-btn { width: 44px; height: 44px; border: 0; background: transparent; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: inherit; }
.icon-btn:hover { background: var(--ground); }
.icon-btn svg { width: 22px; height: 22px; }

.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); font-weight: 500; min-width: 0; }
.input, .field input, .field select, .field textarea, select.input {
  height: 46px; border-radius: 10px; border: 1px solid var(--field); padding: 0 12px; background: var(--surface);
  font-size: 16px; font-weight: 500; color: var(--ink); width: 100%; min-width: 0;
}
.field textarea { height: 96px; padding: 10px 12px; resize: vertical; }
.input.big { height: 52px; font: 700 26px var(--display); }
.search { height: 48px; border-radius: var(--radius-ctl); background: var(--ground); display: flex; align-items: center; gap: 10px; padding: 0 14px; flex: 1; }
.search input { flex: 1; border: 0; background: transparent; outline: none; font-size: 16px; font-weight: 500; min-width: 0; }
.search svg { width: 20px; height: 20px; color: var(--muted); flex: none; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 15px; color: var(--ink); min-height: 44px; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); }

.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--field); background: var(--surface); font-weight: 500; font-size: 14px; cursor: pointer; }
.pill[aria-selected="true"], .pill[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); font-weight: 600; }
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--ground); border-radius: 10px; padding: 3px; gap: 3px; }
.segmented button { height: 34px; border: 0; border-radius: 8px; background: transparent; font-weight: 500; font-size: 14px; cursor: pointer; }
.segmented button[aria-selected="true"] { background: var(--surface); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,0.08); }

/* ---------- macros ---------- */
.plate-bar { display: flex; height: 22px; border-radius: 6px; overflow: hidden; gap: 3px; background: var(--ground); }
.plate-bar > div { border-radius: 2px; min-width: 0; }
.plate-bar > div:first-child { border-radius: 6px 2px 2px 6px; }
.plate-bar.over { outline: 2px solid var(--red); outline-offset: 2px; }
.swatch { width: 8px; height: 14px; border-radius: 2px; display: inline-block; flex: none; }
.c-protein { background: var(--red); } .c-carbs { background: var(--yellow); } .c-fat { background: var(--green); } .c-kcal { background: var(--kcal); }
.macro { display: flex; flex-direction: column; gap: 6px; }
.macro .name { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.macro .num { font-size: 24px; font-weight: 600; }
.meter { height: 6px; border-radius: 3px; background: var(--ground); overflow: hidden; }
.meter > div { height: 100%; border-radius: 3px; }
@media (min-width: 1024px) { .macro .num { font-size: 30px; } .meter { height: 8px; } .plate-bar { height: 26px; } }

/* ---------- lists ---------- */
.list { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--rule); min-height: 52px; }
.list-row:first-child { border-top: 0; }
.list-row .main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.list-row .title { font-weight: 600; overflow-wrap: anywhere; }
button.list-row { background: none; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; cursor: pointer; width: 100%; color: inherit; }
button.list-row:first-child { border-top: 0; }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { font-size: 12px; color: var(--muted); font-weight: 500; text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--rule); }
.table td { padding: 10px 6px; border-bottom: 1px solid var(--rule); }
.table .r { text-align: right; }
.scroll-x { overflow-x: auto; }

/* ---------- sheet / dialog ---------- */
.scrim { position: fixed; inset: 0; background: rgba(22, 32, 43, 0.45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--surface); width: 100%; max-width: 640px; max-height: 92vh; max-height: 92dvh; border-radius: 22px 22px 0 0;
  display: flex; flex-direction: column; overflow: hidden; padding-bottom: env(safe-area-inset-bottom);
  animation: sheet-in 0.22s ease-out;
}
.sheet.tall { height: 92vh; height: 92dvh; }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--field); margin: 10px auto 2px; flex: none; }
.sheet-head { padding: 6px 12px 10px 16px; display: flex; justify-content: space-between; align-items: center; gap: 8px; flex: none; }
.sheet-head h2 { font: 700 26px/1.1 var(--display); }
.sheet-body { padding: 0 16px 20px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 12px; overscroll-behavior: contain; }
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (min-width: 720px) {
  .scrim { align-items: center; }
  .sheet { border-radius: 22px; max-height: 86vh; }
  .sheet.tall { height: 86vh; }
}

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 16px); transform: translateX(-50%);
  background: var(--ink); color: var(--surface); padding: 12px 18px; border-radius: 12px; font-weight: 600; z-index: 60; max-width: calc(100% - 32px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}
.toast.error { background: var(--red); color: #fff; }
@media (min-width: 1024px) { .toast { bottom: 32px; } }
.banner { border-radius: 12px; padding: 12px 16px; background: var(--danger-bg); color: var(--danger-ink); font-size: 14px; }
.banner.info { background: var(--tint-primary); color: var(--ink); }
.empty { padding: 24px 8px; text-align: center; color: var(--muted); display: flex; flex-direction: column; gap: 10px; align-items: center; }

/* ---------- specific pieces ---------- */
.chip-btn { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px; border-radius: 20px; border: 1px solid var(--field); background: var(--surface); font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; color: var(--ink); }
.dot { width: 10px; height: 10px; border-radius: 5px; display: inline-block; }
.linkcard { background: var(--deep); color: #fff; border-radius: var(--radius-card); padding: 16px; display: flex; align-items: center; justify-content: space-between; text-decoration: none; gap: 12px; }
.linkcard:hover { color: #fff; }
.linkcard .muted { color: var(--on-deep-muted); }
:root[data-theme="dark"] .linkcard, :root:not([data-theme="light"]) .linkcard { }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .linkcard { background: var(--deep-2); } }
:root[data-theme="dark"] .linkcard { background: var(--deep-2); }

.sleepbar { display: flex; height: 10px; gap: 2px; }
.sleepbar > div { border-radius: 3px; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { font: 12px var(--body); fill: var(--muted); }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; }

.date-nav { display: flex; align-items: center; justify-content: space-between; padding: 24px 0 8px; }
.date-nav .center { display: flex; flex-direction: column; align-items: center; }
.date-nav h1 { font: 700 30px/1 var(--display); }

.set-grid { display: grid; grid-template-columns: 34px minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr) 44px; gap: 8px; align-items: center; }
.set-grid.head { font-size: 12px; color: var(--muted); padding: 4px 0 0; }
.set-row { border-radius: 10px; padding: 4px 0; }
.set-row.done { background: var(--tint-primary); }
.set-row input { height: 40px; width: 100%; border-radius: 8px; border: 1px solid var(--field); text-align: center; font-weight: 600; font-size: 16px; background: var(--surface); color: var(--ink); padding: 0 4px; }
.set-n { font: 600 18px var(--display); text-align: center; background: none; border: 0; cursor: pointer; color: inherit; height: 40px; }
.done-btn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--field); background: var(--surface); color: var(--dot); display: flex; align-items: center; justify-content: center; justify-self: center; cursor: pointer; }
.done-btn[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.done-btn svg { width: 18px; height: 18px; }
.rest { position: sticky; top: 8px; z-index: 5; background: var(--deep); color: #fff; border-radius: 14px; padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rest .btn { background: transparent; color: #fff; border-color: #3A4757; }
.rest .btn.light { background: #fff; color: var(--deep); border-color: #fff; }
.dashed { border-style: dashed; }

.login { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login .card { width: 100%; max-width: 400px; padding: 28px; gap: 14px; }
.login h1 { font: 700 40px/1 var(--display); text-align: center; }
.login h1 + .note { text-align: center; }
.login .logo { width: 92px; height: auto; align-self: center; margin-bottom: 4px; }

body.logged-out .tabbar, body.logged-out .sidebar { display: none !important; }
body.logged-out .content { padding-bottom: 0; }
#view:focus { outline: none; }
.diary-grid { display: grid; gap: 12px; }
@media (min-width: 1024px) { .diary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; } }
.desk-only { display: none !important; }
@media (min-width: 1024px) {
  .desk-only { display: flex !important; }
  .phone-only { display: none !important; }
  .whoop-card { background: var(--deep); color: var(--on-deep); }
  .whoop-card .muted, .whoop-card .stat .label { color: var(--on-deep-muted); }
  .whoop-card .num .unit { color: var(--on-deep-muted); }
  .whoop-card .big-recovery { display: flex !important; }
  .whoop-card .sleepbar > div:nth-child(1) { background: #4C6A9C !important; }
  .whoop-card .sleepbar > div:nth-child(2) { background: #A9BCDB !important; }
  .whoop-card .sleepbar > div:nth-child(3) { background: #FF914D !important; }
}
.scanner video { width: 100%; border-radius: 14px; background: #000; aspect-ratio: 4 / 3; object-fit: cover; }
.offline-pill { position: fixed; top: calc(env(safe-area-inset-top) + 8px); left: 50%; transform: translateX(-50%); z-index: 50; background: var(--ink); color: var(--surface); font-size: 13px; font-weight: 600; padding: 6px 14px; border-radius: 16px; }

/* ---------- more ---------- */
.more-group { padding: 4px 16px; gap: 0; }
.more-row { display: flex; align-items: center; gap: 14px; min-height: 60px; border-top: 1px solid var(--rule); color: var(--ink); text-decoration: none; }
.more-row:first-child { border-top: 0; }
.more-row:hover { color: var(--ink); }
.more-row .main { flex: 1; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.more-row .title { font-weight: 600; }
.more-row > svg { color: var(--muted); flex: none; }
.more-ic { width: 38px; height: 38px; border-radius: 10px; background: var(--ground); display: flex; align-items: center; justify-content: center; flex: none; }
.more-ic.dark { background: var(--primary); color: var(--on-primary); }
.more-ic svg { width: 20px; height: 20px; }
@media (min-width: 1024px) { .more-group { padding: 4px 24px; } }

/* ---------- segmented links (Diary | Plan, Strength | Cardio | Progress) ---------- */
.segmented.big { padding: 4px; gap: 4px; border-radius: 12px; background: var(--line); }
.segmented.big a, .segmented.big button { height: 40px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 15px; color: var(--ink); text-decoration: none; }
.segmented.big a[aria-current="page"], .segmented.big button[aria-selected="true"] { background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,0.08); }
@media (min-width: 1024px) { .segmented.big { max-width: 420px; } }

/* ---------- full-screen barcode scanner ---------- */
.scanner-full { position: fixed; inset: 0; z-index: 70; background: #0B1118; color: #fff; display: flex; flex-direction: column; align-items: center; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
.scan-top { width: 100%; max-width: 640px; display: flex; justify-content: space-between; align-items: center; padding: 16px; }
.scan-title { font-weight: 600; }
.scan-round { width: 44px; height: 44px; border-radius: 22px; border: 0; background: rgba(255,255,255,0.14); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.scan-round[hidden] { display: flex !important; visibility: hidden; }
.scan-round[aria-pressed="true"] { background: #fff; color: #0B1118; }
.scan-round svg { width: 20px; height: 20px; }
.scan-stage { position: relative; width: 100%; max-width: 640px; flex: 1; max-height: 62vh; overflow: hidden; }
.scan-stage video { width: 100%; height: 100%; object-fit: cover; display: block; background: #000; }
.scan-stage.off video { opacity: 0.2; }
.scan-frame { position: absolute; left: 7%; right: 7%; top: 29%; bottom: 29%; pointer-events: none; }
.scan-frame i { position: absolute; width: 34px; height: 34px; border: 4px solid #fff; }
.scan-frame i:nth-child(1) { left: 0; top: 0; border-right: 0; border-bottom: 0; border-radius: 12px 0 0 0; }
.scan-frame i:nth-child(2) { right: 0; top: 0; border-left: 0; border-bottom: 0; border-radius: 0 12px 0 0; }
.scan-frame i:nth-child(3) { left: 0; bottom: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 12px; }
.scan-frame i:nth-child(4) { right: 0; bottom: 0; border-left: 0; border-top: 0; border-radius: 0 0 12px 0; }
.scan-frame b { position: absolute; left: 8%; right: 8%; top: 50%; height: 3px; border-radius: 2px; background: #3DB874; animation: scanline 1.6s ease-in-out infinite alternate; }
@keyframes scanline { from { transform: translateY(-34px); } to { transform: translateY(34px); } }
.scan-status { padding: 16px 20px 8px; text-align: center; font-weight: 600; max-width: 420px; }
.scan-manual { display: flex; gap: 8px; padding: 8px 16px 20px; width: 100%; max-width: 420px; }
.scan-manual input { flex: 1; height: 44px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.3); background: rgba(255,255,255,0.08); color: #fff; padding: 0 12px; font-size: 16px; min-width: 0; }
.scan-manual input::placeholder { color: #B9C4D0; }
.scan-manual .btn { background: #fff; color: #0B1118; border-color: #fff; height: 44px; }

/* ---------- meal plans ---------- */
.plan-chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 4px; scrollbar-width: none; }
.plan-chips::-webkit-scrollbar { display: none; }
.plan-chips .pill { display: inline-flex; align-items: center; white-space: nowrap; text-decoration: none; color: var(--ink); flex: none; }
.pill[aria-current="page"] { background: var(--ink); color: var(--surface); border-color: var(--ink); font-weight: 600; }
.plan-macro { display: flex; flex-direction: column; gap: 6px; }
.plan-macro-head { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; flex-wrap: wrap; }
.plan-macro .name { font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.plan-macro .meter { height: 8px; }

/* ---------- cardio and progress ---------- */
.cardio-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-top: 1px solid var(--rule); color: var(--ink); text-decoration: none; }
.cardio-row:first-child { border-top: 0; }
.cardio-row:hover { color: var(--ink); }
.cardio-row .main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.cardio-row .title, .callout .title { font-weight: 600; }
.act-ic { width: 40px; height: 40px; border-radius: 12px; background: var(--ground); display: flex; align-items: center; justify-content: center; flex: none; color: var(--ink); }
.act-ic svg { width: 22px; height: 22px; }
.act-ic.sm { width: 34px; height: 34px; border-radius: 10px; }
.act-ic.sm svg { width: 18px; height: 18px; }
.badge { font-size: 12px; font-weight: 600; padding: 4px 8px; border-radius: 6px; background: var(--ground); color: var(--ink); white-space: nowrap; flex: none; }
.badge.dark { background: var(--deep); color: #fff; }
.zones { display: flex; height: 8px; gap: 2px; margin-top: 4px; max-width: 320px; }
.zones > div { border-radius: 2px; min-width: 2px; }
.callout { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--tint-primary); border: 1px solid var(--soft-kcal); color: var(--ink); text-decoration: none; }
.callout .main { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.callout:hover { color: var(--ink); }
.act-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.act-grid button { height: 44px; border-radius: 12px; border: 1px solid var(--field); background: var(--surface); color: var(--ink); font: 600 14px var(--body); cursor: pointer; }
.act-grid button[aria-checked="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.pace-box { display: flex; justify-content: space-between; align-items: center; background: var(--ground); border-radius: 12px; padding: 10px 14px; }
.totals-grid { gap: 16px 12px; }
.card.dark .note { color: var(--on-deep-muted); }
.card.dark h2 { color: var(--on-deep); }

/* ---------- health ---------- */
.vo2-tile { display: flex; align-items: center; gap: 14px; background: var(--deep); color: var(--on-deep); border-radius: 14px; padding: 14px 16px; }
.vo2-tile .num .unit { color: var(--on-deep-muted); }
.btn.light { background: #fff; color: var(--deep); border-color: #fff; }
.btn.light:hover { color: var(--deep); background: #fff; }
.vitals-grid { gap: 16px 8px; }
.stat-btn { background: none; border: 0; padding: 0; text-align: left; cursor: pointer; color: inherit; font: inherit; }
.check-row { display: flex; align-items: center; gap: 12px; min-height: 54px; padding: 6px 0; border-top: 1px solid var(--rule); cursor: pointer; }
.check-row input { width: 24px; height: 24px; margin: 0; accent-color: var(--green); flex: none; }
.check-row .main { flex: 1; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.check-row .title { font-weight: 600; }
.list-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; padding: 12px 0 4px; }
.list > .list-label:first-child { padding-top: 0; }
.list-label + .check-row { border-top: 0; }
.linkish { text-decoration: none; color: inherit; }
.linkish:hover { color: inherit; }
.linkish svg { color: var(--muted); }
.back-link { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; text-decoration: none; font-size: 15px; }
.lab-row { display: flex; flex-direction: column; gap: 6px; padding: 12px 0; border: 0; border-top: 1px solid var(--rule); background: none; text-align: left; width: 100%; cursor: pointer; color: inherit; font: inherit; }
.lab-row:first-child { border-top: 0; }
.lab-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.lab-head .title { font-weight: 600; }
.lab-foot { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.range-bar { position: relative; height: 8px; border-radius: 4px; background: var(--ground); }
.range-bar .ok { position: absolute; top: 0; bottom: 0; border-radius: 4px; background: #9ED4B3; }
.range-bar .mark { position: absolute; top: -3px; width: 4px; height: 14px; margin-left: -2px; border-radius: 2px; background: var(--ink); }
.range-bar .mark.out { background: var(--red); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .range-bar .ok { background: #23664A; } }
:root[data-theme="dark"] .range-bar .ok { background: #23664A; }
.lab-edit { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 12px; background: var(--ground); }
.lab-edit .field input { background: var(--surface); }

/* ---------- habits ---------- */
.heatmap { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; text-align: center; }
.heat { display: block; height: 22px; border-radius: 4px; background: var(--rule); }
.heat.l-1 { background: transparent; border: 1px dashed var(--rule); }
.heat.l0 { background: var(--rule); }
.heat.l1 { background: #BFE3CD; }
.heat.l2 { background: #6FC193; }
.heat.l3 { background: var(--green); }
.heat.today { outline: 2px solid var(--ink); outline-offset: 1px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .heat.l1 { background: #1F4A35; } :root:not([data-theme="light"]) .heat.l2 { background: #2D7A52; } }
:root[data-theme="dark"] .heat.l1 { background: #1F4A35; }
:root[data-theme="dark"] .heat.l2 { background: #2D7A52; }
.legend .heat { display: inline-block; }
.habit-group { gap: 4px; }
.habit-row .main { cursor: pointer; }
.habit-row .btn.sm { min-width: 52px; height: 36px; padding: 0 10px; }
.habit-row.done .title { color: var(--muted); }
.streak { font-size: 13px; font-weight: 600; min-width: 32px; text-align: right; }
.check-row input:disabled { opacity: 1; }

/* ---------- journal ---------- */
.scale-set { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.scale-set legend { padding: 0; margin-bottom: 6px; font-size: 13px; font-weight: 600; }
.scale { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.scale button { height: 44px; border-radius: 10px; border: 1px solid var(--field); background: var(--surface); color: var(--ink); font: 600 16px var(--body); cursor: pointer; }
.scale button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.scale-ends { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.context-box { display: flex; flex-direction: column; gap: 4px; background: var(--ground); border-radius: 12px; padding: 12px; }
.journal-row { display: flex; flex-direction: column; gap: 4px; padding: 12px 0; border-top: 1px solid var(--rule); color: var(--ink); text-decoration: none; }
.journal-row:first-child { border-top: 0; }
.journal-row:hover { color: var(--ink); }
.journal-row[aria-current="true"] .title { color: var(--primary); }
.jr-head { display: flex; justify-content: space-between; gap: 8px; }
.jr-head .title { font-weight: 600; }
.jr-text { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.habit-segs { display: flex; gap: 3px; }
.habit-segs > div { flex: 1; height: 6px; border-radius: 3px; background: var(--rule); }
.habit-segs > div.on { background: var(--green); }
.med-pill { display: inline-flex; align-items: center; gap: 6px; height: 40px; }
.med-pill[aria-pressed="true"] { background: #E6F3EC; color: #1B6B3F; border-color: var(--green); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .med-pill[aria-pressed="true"] { background: #173A2A; color: #9BE3B9; } }
:root[data-theme="dark"] .med-pill[aria-pressed="true"] { background: #173A2A; color: #9BE3B9; }
.med-pill svg { width: 16px; height: 16px; }
.journal-ic { width: 44px; height: 44px; border-radius: 12px; background: rgba(255,255,255,0.12); display: flex; align-items: center; justify-content: center; flex: none; }
.journal-ic svg { width: 22px; height: 22px; }
.card h2.list-label { font: 600 12px/1.2 var(--body); letter-spacing: 0.06em; }
.list > .check-row:first-child { border-top: 0; }
.intro-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.intro-step { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.intro-tick { width: 22px; height: 22px; border-radius: 11px; border: 2px solid var(--field); display: flex; align-items: center; justify-content: center; flex: none; }
.intro-step.done .intro-tick { background: var(--green); border-color: var(--green); color: #fff; }
.intro-step.done { color: var(--muted); }
