/* Light, calm, spacious. Whites + pastels + grays/blacks, sage green accent.
   Typography and pill shapes inspired by immortals.com (DM Sans, soft radii). */
@import url('/vendor/fonts.css');

:root {
  --bg: #f7f7f4;          /* warm white */
  --card: #ffffff;
  --card2: #f1f2ec;       /* pale sage-gray */
  --line: #e5e6df;
  --text: #191c19;
  --dim: #70776e;
  --accent: #5f7f68;      /* sage green */
  --accent-soft: #e3ece2; /* pastel sage */
  --green: #4f8f6b;
  --green-soft: #ddefe3;
  --yellow: #b98a2f;
  --yellow-soft: #f6ecd4;
  --plum: #8d7f9e;        /* pastel plum for assumption/corrected */
  --plum-soft: #ece7f2;
  --optimal: #5b87ad;     /* blue = optimal tier */
  --optimal-soft: #dde9f2;
  --red: #bf5f52;
  --red-soft: #f6e0da;
  --rose-soft: #f3e2e4;   /* cycle shading */
}
* { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.5 'DM Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  padding-bottom: 48px;
}
.hidden { display: none !important; }
a { color: var(--accent); text-decoration: none; font-weight: 600; }
button {
  background: var(--accent); color: #fff; border: 0; border-radius: 999px;
  padding: 11px 20px; font-size: 15px; font-weight: 600; cursor: pointer;
  font-family: inherit;
}
button.ghost { background: var(--card); color: var(--text); border: 1.5px solid var(--line); }
button.danger { background: var(--red); }
input, select, textarea {
  background: var(--card); color: var(--text); border: 1.5px solid var(--line);
  border-radius: 12px; padding: 10px 14px; font-size: 15px; max-width: 100%;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[type="date"] { min-height: 42px; }

/* login */
#login { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 32px; width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 8px 30px rgba(25,28,25,.06); }
.login-card h1 { font-size: 21px; font-weight: 700; letter-spacing: -.01em; }
.err { color: var(--red); font-size: 13px; min-height: 1em; }

/* nav */
#topbar { position: sticky; top: 0; z-index: 10; background: rgba(247,247,244,.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
#nav { display: flex; overflow-x: auto; gap: 4px; padding: 8px 10px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
#nav::-webkit-scrollbar { display: none; }
#nav a { flex: 0 0 auto; padding: 8px 15px; border-radius: 999px; color: var(--dim); font-weight: 600; font-size: 14px; white-space: nowrap; }
#nav a.active { background: var(--text); color: #fff; }

main { padding: 16px; max-width: 760px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 18px; margin-bottom: 14px; }
.card h2 { font-size: 12.5px; color: var(--dim); text-transform: uppercase; letter-spacing: .09em; margin-bottom: 12px; font-weight: 700; }
h3.section { font-size: 17px; margin: 18px 0 10px; letter-spacing: -.01em; }
.muted { color: var(--dim); font-size: 13px; }
.empty { color: var(--dim); text-align: center; padding: 28px 12px; font-size: 14px; }

/* day picker */
.daypick { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; }
.daypick input { flex: 1; text-align: center; }
.daypick button { padding: 10px 16px; }

/* progress bars */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 74px 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.bar-label { color: var(--dim); font-weight: 600; }
.bar-track { background: var(--card2); border-radius: 999px; height: 14px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--accent); min-width: 3px; opacity: .85; }
.bar-fill.over { background: var(--yellow); }
.bar-fill.way-over { background: var(--red); }
.bar-fill.hit { background: var(--green); }
.bar-val { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* badges */
.badge { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 2.5px 8px; border-radius: 999px; letter-spacing: .03em; vertical-align: 1px; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.yellow { background: var(--yellow-soft); color: var(--yellow); }
.badge.blue { background: var(--plum-soft); color: var(--plum); }
.badge.status { background: var(--card2); color: var(--dim); }

/* food rows */
.meal-block { margin-bottom: 14px; }
.meal-head { display: flex; justify-content: space-between; align-items: baseline; padding: 4px 2px; font-weight: 700; }
.meal-head .muted { font-weight: 500; }
.food-row { background: var(--card2); border-radius: 14px; padding: 11px 14px; margin-bottom: 7px; }
.food-top { display: flex; justify-content: space-between; gap: 8px; }
.food-name { font-weight: 600; }
.food-cal { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--dim); }
.food-sub { font-size: 12.5px; color: var(--dim); margin-top: 3px; display: flex; flex-wrap: wrap; gap: 6px 12px; }
.food-notes { font-size: 12.5px; margin-top: 5px; color: var(--dim); }
.photo-link { font-size: 12.5px; }

/* timeline */
.tl { border-left: 2px solid var(--line); margin-left: 6px; padding-left: 15px; display: flex; flex-direction: column; gap: 9px; }
.tl-item { position: relative; font-size: 14px; }
.tl-item::before { content: ""; position: absolute; left: -20.5px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.tl-item.water::before { background: #9db8ac; }
.tl-item .muted { display: block; }

/* tables */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--dim); font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* photos */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.gallery .ph { position: relative; border-radius: 14px; overflow: hidden; aspect-ratio: 1; background: var(--card2); cursor: pointer; }
.gallery .ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery .ph .cap { position: absolute; bottom: 0; left: 0; right: 0; font-size: 10px; padding: 3px 7px; background: rgba(25,28,25,.55); color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day-photos { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.day-photos .ph { flex: 0 0 96px; height: 96px; border-radius: 14px; overflow: hidden; cursor: pointer; }
.day-photos .ph img { width: 100%; height: 100%; object-fit: cover; }

/* modal */
#modal { position: fixed; inset: 0; background: rgba(25,28,25,.45); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
#modal-body { background: var(--card); border-radius: 20px; max-width: 640px; width: 100%; max-height: 90vh; overflow-y: auto; padding: 18px; }
#modal-body img { width: 100%; border-radius: 14px; margin-bottom: 10px; }

/* trends */
.controls { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.controls select, .controls input { flex: 1 1 130px; }
.chart-box { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 12px; }
.legend-note { font-size: 12px; color: var(--dim); margin-top: 10px; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; }

/* expandable */
details { background: var(--card2); border-radius: 14px; padding: 11px 14px; margin-bottom: 7px; }
summary { cursor: pointer; font-weight: 600; }
details .body { margin-top: 8px; font-size: 13.5px; color: var(--dim); white-space: pre-wrap; }

/* settings + misc */
.setfield { background: var(--card2); border-radius: 14px; padding: 14px; margin-bottom: 10px; }
.setfield label { display: block; font-weight: 700; margin-bottom: 6px; }
.setfield input { width: 100%; margin-bottom: 8px; }
.linkbox { background: var(--card2); border-radius: 12px; padding: 10px 14px; font-size: 12.5px; word-break: break-all; margin: 8px 0; font-family: ui-monospace, SFMono-Regular, monospace; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 10px; }
.stat { background: var(--card2); border-radius: 14px; padding: 12px; text-align: center; }
.stat b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat span { font-size: 11.5px; color: var(--dim); }

/* comments */
.comment { background: var(--card2); border-radius: 14px; padding: 11px 14px; margin-bottom: 8px; }
.comment.trainer { background: var(--accent-soft); }
.comment .who { font-weight: 700; font-size: 13px; }
.comment .when { color: var(--dim); font-size: 11.5px; margin-left: 6px; }
.comment .body { margin-top: 4px; font-size: 14px; white-space: pre-wrap; }
.comment .anchor { font-size: 11.5px; color: var(--dim); margin-top: 4px; }
.comment-form { display: flex; gap: 8px; margin-top: 10px; }
.comment-form textarea { flex: 1; min-height: 44px; resize: vertical; }

/* sleep cards */
.sleep-card { background: var(--card2); border-radius: 14px; padding: 12px 14px; margin-bottom: 8px; display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: baseline; }
.sleep-card b { font-size: 17px; }
.sleep-card .src { font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }

/* trend panels */
.chart-box.mini { margin-bottom: 14px; }
.chart-box h2 { font-size: 12.5px; color: var(--dim); text-transform: uppercase; letter-spacing: .09em; margin: 4px 6px 10px; font-weight: 700; }

/* collapsible meals */
details.meal { background: transparent; border: 1px solid var(--line); border-radius: 14px; padding: 0; margin-bottom: 8px; overflow: hidden; }
details.meal summary { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--card2); font-weight: 700; list-style: none; }
details.meal summary::-webkit-details-marker { display: none; }
details.meal summary::after { content: "▾"; margin-left: auto; color: var(--dim); transition: transform .15s; }
details.meal[open] summary::after { transform: rotate(180deg); }
details.meal .meal-emoji { font-size: 15px; letter-spacing: 2px; }
details.meal .meal-meta { color: var(--dim); font-weight: 500; font-size: 12.5px; margin-left: auto; padding-right: 8px; }
details.meal[open] .meal-meta { display: none; }
details.meal .food-row { margin: 8px; }

/* food thumbnails */
.food-row.with-thumb { display: flex; gap: 11px; align-items: flex-start; }
.food-thumb { flex: 0 0 46px; width: 46px; height: 46px; border-radius: 12px; overflow: hidden; background: var(--card); border: 1px solid var(--line); cursor: pointer; }
.food-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.food-thumb.emoji { display: flex; align-items: center; justify-content: center; font-size: 22px; cursor: default; }
.food-main { flex: 1; min-width: 0; }
.cwrap { position: relative; height: 220px; }
.cwrap.tall { height: 280px; }
.food-total { display: flex; justify-content: space-between; padding: 12px 14px 2px; font-weight: 700; border-top: 2px solid var(--line); margin-top: 10px; }

/* cycle page */
.phase-bar { display: flex; gap: 3px; height: 34px; }
.ph-seg { border-radius: 8px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.ph-seg span { font-size: 10px; font-weight: 700; letter-spacing: .03em; color: rgba(25,28,25,.65); white-space: nowrap; }
.ph-seg.menses { background: #e9b6c0; }
.ph-seg.foll { background: #d9e4d5; }
.ph-seg.ovu { background: #9db8ac; }
.ph-seg.lut { background: #ece3d3; }
.cal-wrap { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.cal-month { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px; }
.cal-month h2 { font-size: 12px; color: var(--dim); text-transform: uppercase; letter-spacing: .07em; margin-bottom: 8px; font-weight: 700; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-dow { text-align: center; font-size: 9.5px; color: var(--dim); font-weight: 700; }
.cal-day { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; font-size: 11.5px; border-radius: 8px; font-variant-numeric: tabular-nums; }
.cal-day.menses { background: #d98a99; color: #fff; font-weight: 700; }
.cal-day.pred { background: #f0ccd3; }
.cal-day.ovu { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); }
.cal-day.today { box-shadow: inset 0 0 0 2px var(--text); font-weight: 700; }
.cal-day.pad { visibility: hidden; }
.ph-seg { cursor: pointer; }
.cal-day { transition: none; }

/* sleep calendar */
.sc-day { aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; border-radius: 9px; background: var(--card2); }
.sc-day b { font-size: 11px; line-height: 1; }
.sc-day i { font-style: normal; font-size: 8.5px; line-height: 1; opacity: .95; }
.sc-day.good { background: var(--green); color: #fff; }
.sc-day.ok { background: var(--yellow); color: #fff; }
.sc-day.bad { background: var(--red); color: #fff; }
.sc-day.today { box-shadow: inset 0 0 0 2px var(--text); }
.sc-day.pad { visibility: hidden; }
.sc-day.info { background: var(--accent-soft); }

/* dashboard rings */
.rings { display: flex; justify-content: space-around; gap: 8px; flex-wrap: wrap; }
.ring { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.ring span { font-size: 11.5px; font-weight: 700; color: var(--dim); }

/* program tracker */
.wk-future { color: var(--dim); font-size: 13px; padding: 10px 14px; border: 1px dashed var(--line); border-radius: 14px; margin-bottom: 8px; }
.wk-pills { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; margin-bottom: 8px; }
.pill { border-radius: 10px; padding: 7px 9px; background: var(--card2); }
.pill span { display: block; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--dim); }
.pill b { font-size: 12.5px; white-space: nowrap; }
.pill.good { background: var(--green-soft); } .pill.good span { color: var(--green); }
.pill.ok { background: var(--yellow-soft); } .pill.ok span { color: var(--yellow); }
.pill.bad { background: var(--red-soft); } .pill.bad span { color: var(--red); }
.wk-table td.num, .wk-table th.num { font-size: 12px; padding: 6px 6px; }
.wk-table td.st-good { background: var(--green-soft); }
.wk-table td.st-ok { background: var(--yellow-soft); }
.wk-table td.st-bad { background: var(--red-soft); }

/* blood rows */
.blood-row { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-bottom: 1px solid var(--line); cursor: pointer; }
.blood-row:last-child { border-bottom: 0; }
.blood-row .b-name { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 600; }
.blood-row .b-name .muted { font-weight: 400; font-size: 11.5px; }
.blood-row b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.spark { flex: 0 0 64px; }
.flag-row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.flag-row:last-child { border-bottom: 0; }
:root { --blue: #6a8caf; }
.blood-flag-card .bf-head { display: flex; align-items: baseline; gap: 8px; padding: 2px 6px; }
.blood-flag-card .bf-head b { font-size: 15px; }
.blood-flag-card .bf-val { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.zone-legend { display: flex; flex-direction: column; gap: 3px; margin-bottom: 8px; }
.zone-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* login role tabs */
.role-tabs { display: flex; gap: 4px; }
.role-tabs button { flex: 1; background: var(--card2); color: var(--dim); border: 1.5px solid var(--line); border-radius: 10px; padding: 8px 4px; font-size: 13px; }
.role-tabs button.active { background: var(--text); color: #fff; border-color: var(--text); }
.pw-wrap { display: flex; gap: 6px; }
.pw-wrap input { flex: 1; }
.pw-wrap button { background: var(--card2); border: 1.5px solid var(--line); border-radius: 10px; padding: 0 12px; }
#nav .switch-user { margin-left: auto; background: var(--accent-soft); color: var(--accent); font-size: 13px; }

/* trainer date strip + small rings */
.datestrip { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 10px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.datestrip::-webkit-scrollbar { display: none; }
.ds-day { flex: 0 0 52px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 0; border-radius: 16px; background: var(--card); border: 1px solid var(--line); color: var(--dim); font-family: inherit; }
.ds-day span { font-size: 10px; font-weight: 700; letter-spacing: .04em; }
.ds-day b { font-size: 16px; color: var(--text); }
.ds-day.sel { background: var(--text); border-color: var(--text); }
.ds-day.sel span, .ds-day.sel b { color: #fff; }
.rings-sm .ring svg { width: 56px; height: 56px; }
.rings-sm { gap: 4px; }

/* per-food nutrient mini rings */
.food-rings { display: flex; gap: 8px; margin-top: 7px; flex-wrap: wrap; }
.mring { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.mring i { font-style: normal; font-size: 8.5px; font-weight: 700; color: var(--dim); letter-spacing: .02em; }

/* workout muscle map */
.muscle-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; padding: 10px; background: var(--card); border-radius: 12px; }
.muscle-fig { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.muscle-fig i { font-style: normal; font-size: 10px; font-weight: 700; color: var(--dim); }


/* 4-tier semantics: green optimal / blue good / yellow warning / red bad */
.sc-day.best { background: var(--green); color: #fff; }
.sc-day.good { background: var(--optimal); color: #fff; }
.pill.best { background: var(--green-soft); } .pill.best span { color: var(--green); }
.pill.good { background: var(--optimal-soft) !important; } .pill.good span { color: var(--optimal) !important; }
.wk-table td.st-best { background: var(--green-soft); }
.wk-table td.st-good { background: var(--optimal-soft); }
.badge.optimal { background: var(--green-soft); color: var(--green); }
.bar-fill.best { background: var(--green); }
