:root {
  --bg0: #070a0f;
  --bg1: #0b0f17;
  --surface: #10151f;
  --surface-2: #161c28;
  --line: rgba(255, 255, 255, 0.07);
  --line-2: rgba(255, 255, 255, 0.12);
  --text: #eef2f8;
  --muted: #93a0b4;
  --faint: #5d6a82;
  --acc: #4fd1ff;
  --low: #ff5c6c;
  --urgent: #ff3b47;
  --inrange: #34d399;
  --high: #fbbf24;
  --vhigh: #fb7185;
  --radius: 20px;
  --radius-sm: 13px;
  font-size: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body {
  margin: 0;
  background:
    radial-gradient(130% 70% at 50% -15%, rgba(79, 209, 255, 0.12) 0%, transparent 58%),
    linear-gradient(180deg, var(--bg1) 0%, var(--bg0) 40%);
  background-attachment: fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
.num { font-family: "SF Mono", ui-monospace, "JetBrains Mono", "Roboto Mono", monospace; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.app { max-width: 460px; margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) 16px 0; }
.tabspacer { height: 86px; }

.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.brand { display: flex; align-items: center; gap: 9px; }
.brand .mark { width: 22px; height: 22px; }
.brand .word { font-weight: 700; letter-spacing: 0.32em; font-size: 13px; padding-left: 2px; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); padding: 5px 10px; border-radius: 999px; }
#freshChip { cursor: pointer; -webkit-tap-highlight-color: transparent; }
#freshChip:active { transform: scale(0.96); }
#freshChip.spinning .dot { animation: chipspin .7s linear infinite; transform-origin: center; }
@keyframes chipspin { to { transform: rotate(360deg); } }
.ptr { position: fixed; top: calc(env(safe-area-inset-top, 0px) + 4px); left: 50%; transform: translate(-50%, 0); z-index: 300; width: 32px; height: 32px; border-radius: 50%; background: var(--surface-2, #1b2130); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 16px; opacity: 0; pointer-events: none; }
.ptr.ready { color: var(--acc); border-color: var(--acc); }
.ptr.spinning { opacity: 1 !important; }
.ptr.spinning .ptr-spin { display: inline-block; animation: chipspin .7s linear infinite; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--inrange); box-shadow: 0 0 8px currentColor; }
.dot.stale { background: var(--high); }
.topright { display: flex; align-items: center; gap: 9px; }
.gearbtn { background: var(--surface); border: 1px solid var(--line); color: var(--muted); width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.gearbtn svg { width: 17px; height: 17px; }
.gearbtn:active { transform: scale(0.94); }
.setcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; margin-bottom: 10px; }
.setlbl { font-size: 14px; font-weight: 500; margin-bottom: 9px; }
.setrow { display: flex; align-items: center; gap: 10px; }
.setrow input { flex: 1; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 11px 13px; color: var(--text); font: inherit; font-size: 17px; font-variant-numeric: tabular-nums; }
.setrow input:focus { outline: none; border-color: var(--acc); }
.setunit { font-size: 12.5px; color: var(--faint); white-space: nowrap; }
.setrec { font-size: 12.5px; color: var(--muted); margin-top: 10px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.setrec b { color: var(--acc); }
.setrec.dim { color: var(--faint); }
.usebtn { background: rgba(79, 209, 255, .14); border: 1px solid rgba(79, 209, 255, .35); color: var(--acc); border-radius: 8px; padding: 3px 10px; font: inherit; font-size: 12px; cursor: pointer; margin-left: auto; }
.setunit2 { font-size: 11px; color: var(--faint); font-weight: 400; }
.segrow { display: flex; align-items: center; gap: 9px; margin-top: 8px; }
.seglbl { font-size: 12.5px; color: var(--muted); width: 74px; flex: none; }
.segrow input { flex: 1; min-width: 0; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 9px; padding: 8px 11px; color: var(--text); font: inherit; font-size: 15px; font-variant-numeric: tabular-nums; }
.segrow input:focus { outline: none; border-color: var(--acc); }
.segchip { background: rgba(79, 209, 255, .12); border: 1px solid rgba(79, 209, 255, .3); color: var(--acc); border-radius: 8px; padding: 5px 9px; font: inherit; font-size: 12px; cursor: pointer; white-space: nowrap; flex: none; }
.segchip.dim { background: none; border: 1px dashed var(--line); color: var(--faint); cursor: default; }
.segchip .cn { color: var(--faint); font-size: 10.5px; }

.hero { position: relative; background: linear-gradient(180deg, var(--surface) 0%, #0d121b 100%); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 16px 6px; overflow: hidden; }
.hero-head { display: flex; align-items: flex-start; justify-content: space-between; position: relative; z-index: 2; }
.reading { display: flex; align-items: baseline; gap: 10px; }
.bgval { font-size: 72px; font-weight: 700; line-height: 0.9; }
.arrow { font-size: 34px; font-weight: 600; line-height: 1; }
.sub { font-size: 13px; color: var(--muted); margin-top: 6px; }
.sub .rate { color: var(--text); }
.headingto { font-size: 13px; color: var(--muted); margin-top: 4px; }
.headingto b { color: var(--text); font-weight: 600; }
.drivers-sum { font-size: 13.5px; color: var(--muted); margin: -2px 0 11px; line-height: 1.45; }
.drivers-sum b { color: var(--text); font-weight: 600; }
.tier-pill { font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; padding: 4px 9px; border-radius: 999px; }
.t-in-range .bgval, .t-in-range .arrow { color: var(--inrange); text-shadow: 0 0 26px rgba(52, 211, 153, 0.35); }
.t-low .bgval, .t-low .arrow { color: var(--low); text-shadow: 0 0 26px rgba(255, 92, 108, 0.4); }
.t-urgent-low .bgval, .t-urgent-low .arrow { color: var(--urgent); text-shadow: 0 0 30px rgba(255, 59, 71, 0.55); }
.t-high .bgval, .t-high .arrow { color: var(--high); text-shadow: 0 0 26px rgba(251, 191, 36, 0.35); }
.t-very-high .bgval, .t-very-high .arrow { color: var(--vhigh); text-shadow: 0 0 26px rgba(251, 113, 133, 0.4); }
.t-unknown .bgval { color: var(--muted); }
.t-in-range .tier-pill { color: var(--inrange); background: rgba(52, 211, 153, 0.12); }
.t-low .tier-pill, .t-urgent-low .tier-pill { color: var(--low); background: rgba(255, 92, 108, 0.14); }
.t-high .tier-pill, .t-very-high .tier-pill { color: var(--high); background: rgba(251, 191, 36, 0.14); }
.t-unknown .tier-pill { color: var(--muted); background: var(--surface-2); }
.trace { display: block; width: 100%; height: auto; margin-top: 6px; touch-action: none; cursor: crosshair; }
.axislbl { fill: var(--faint); font-size: 13px; font-family: "SF Mono", ui-monospace, monospace; }
.thlbl { font-size: 12px; font-family: "SF Mono", ui-monospace, monospace; paint-order: stroke; stroke: var(--bg1); stroke-width: 3.5px; stroke-linejoin: round; font-weight: 600; }
.evlbl { font-size: 12px; font-family: "SF Mono", ui-monospace, monospace; }
.rangebar { display: flex; gap: 6px; justify-content: flex-end; margin-top: 4px; }
.rangebar button { background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); font: inherit; font-size: 12px; padding: 4px 11px; border-radius: 999px; cursor: pointer; }
.rangebar button.active { color: var(--bg0); background: var(--acc); border-color: var(--acc); font-weight: 600; }
.scrub { position: absolute; z-index: 6; transform: translateX(-50%); background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 9px; padding: 6px 10px; font-size: 12.5px; pointer-events: none; white-space: nowrap; color: var(--text); box-shadow: 0 4px 16px rgba(0,0,0,0.4); }
.scrub b { font-weight: 600; } .scrub .tm { color: var(--muted); }

.action { margin-top: 12px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); padding: 15px 16px; }
.action .status { font-size: 19px; font-weight: 600; letter-spacing: -0.01em; }
.action .cta { margin-top: 11px; display: flex; align-items: center; gap: 11px; font-size: 15.5px; font-weight: 600; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line-2); }
.action .cta svg { width: 20px; height: 20px; flex: none; }
.k-urgent .status { color: var(--urgent); } .k-urgent .cta { background: rgba(255, 59, 71, 0.12); border-color: rgba(255, 59, 71, 0.35); color: #ffd9dc; }
.k-warn .status { color: var(--high); } .k-warn .cta { background: rgba(251, 191, 36, 0.1); border-color: rgba(251, 191, 36, 0.3); color: #ffe8b3; }
.k-ok .status { color: var(--inrange); } .k-ok .cta { background: rgba(52, 211, 153, 0.09); border-color: rgba(52, 211, 153, 0.26); color: #bff3df; }
.k-info .cta { background: var(--surface-2); color: var(--text); }

.predlow { margin-top: 12px; display: none; align-items: center; gap: 12px; background: var(--surface); border: 1px solid rgba(255, 92, 108, 0.4); border-radius: var(--radius); padding: 13px 15px; }
.predlow.show { display: flex; }
.predlow .ico { width: 26px; height: 26px; color: var(--low); flex: none; }
.predlow .t { font-size: 15px; font-weight: 600; color: var(--low); }
.predlow .d { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* prominent log-a-meal */
.logmeal { width: 100%; margin-top: 12px; display: flex; align-items: center; gap: 12px; background: linear-gradient(180deg, var(--surface-2), var(--surface)); border: 1px solid var(--line-2); border-radius: var(--radius); padding: 14px 16px; color: var(--text); font: inherit; cursor: pointer; }
.logmeal:active { transform: scale(0.99); }
.logmeal svg { width: 24px; height: 24px; color: var(--acc); flex: none; }
.logmeal span { font-size: 16px; font-weight: 600; }
.logmeal em { margin-left: auto; font-style: normal; font-size: 12px; color: var(--faint); }

.block { margin-top: 14px; }
.block-h { font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); margin-bottom: 9px; display: flex; align-items: center; gap: 8px; }
.block-h .src { font-size: 10px; color: var(--muted); background: var(--surface-2); padding: 2px 7px; border-radius: 999px; letter-spacing: 0.04em; }

.drivers { display: flex; flex-direction: column; gap: 8px; }
.driver { display: flex; align-items: center; gap: 11px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 11px 13px; }
.driver .ar { font-size: 17px; font-weight: 700; width: 16px; text-align: center; flex: none; }
.driver.up .ar { color: var(--high); } .driver.down .ar { color: var(--acc); }
.driver .dtxt { display: flex; flex-direction: column; gap: 2px; }
.driver .nm { font-size: 14.5px; font-weight: 500; }
.driver .det { font-size: 12px; color: var(--muted); line-height: 1.35; }

.gauges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.gauge { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; }
.gauge .lbl { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); }
.gauge .val { font-size: 24px; font-weight: 700; margin-top: 5px; }
.gauge .val small { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.minisel { background-color: var(--surface-2); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='9' height='12' viewBox='0 0 9 12' fill='none' stroke='%239aa4b2' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 4.3 4.5 2 7 4.3'/%3E%3Cpath d='M2 7.7 4.5 10 7 7.7'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 5px center; color: var(--text); border: 1px solid var(--line-2); border-radius: 8px; font: inherit; font-size: 11px; padding: 2px 18px 2px 6px; cursor: pointer; -webkit-appearance: none; appearance: none; }
.catn { font-size: 11px; color: var(--faint); margin-top: 4px; }
.bar { height: 4px; border-radius: 2px; background: var(--surface-2); margin-top: 9px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 2px; background: var(--acc); }
.bar.green > i { background: var(--inrange); }

.bodyrow { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.metric { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 8px; text-align: center; }
.metric .v { font-size: 19px; font-weight: 700; }
.metric .k { font-size: 10.5px; color: var(--faint); margin-top: 3px; letter-spacing: 0.03em; }
.metric.good .v { color: var(--inrange); } .metric.mid .v { color: var(--high); } .metric.bad .v { color: var(--low); }
.actline { margin-top: 10px; font-size: 13.5px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.actline b { color: var(--text); font-weight: 600; }
.ring { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 4px 9px; text-align: center; }
.ringwrap { position: relative; width: 62px; height: 62px; margin: 0 auto; }
.ringwrap svg { width: 62px; height: 62px; display: block; }
.ringval { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 17px; font-weight: 700; line-height: 1; pointer-events: none; }
.ringval small { font-size: 9.5px; font-weight: 600; margin-left: 1px; opacity: 0.8; }
.ringk { font-size: 10.5px; color: var(--faint); margin-top: 7px; letter-spacing: 0.02em; }
.statcard { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; }
.statcard .statbig { font-size: 26px; font-weight: 700; color: var(--text); }
.gtir { display: flex; flex-direction: column; justify-content: center; }
.tircap { font-size: 11px; text-align: center; margin-top: 6px; min-height: 14px; font-weight: 500; }

.meals { display: flex; flex-direction: column; gap: 8px; }
.meal { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 13px; }
.meal .nm { font-size: 14px; font-weight: 500; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meal .cb { font-size: 13px; color: var(--acc); font-weight: 600; flex: none; }
.meal .ag { font-size: 12px; color: var(--faint); flex: none; }
.emptybox { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 15px; font-size: 13.5px; color: var(--muted); line-height: 1.55; }
.emptybox b { color: var(--text); font-weight: 600; }
.srctag { font-size: 10px; color: var(--muted); background: var(--surface-2); padding: 1px 6px; border-radius: 999px; font-weight: 500; letter-spacing: 0.02em; }
.tagcue { font-size: 11px; color: var(--acc); font-weight: 600; opacity: 0.8; margin-left: 2px; }
.photochip { font-size: 11px; opacity: 0.85; margin-left: 1px; cursor: pointer; }
.photochip:hover { opacity: 1; }
.lightbox { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.9); display: none; align-items: center; justify-content: center; padding: 22px; cursor: zoom-out; }
.lightbox.open { display: flex; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 12px; box-shadow: 0 8px 40px rgba(0,0,0,.6); }
.meal.tapmeal { cursor: pointer; transition: border-color .12s ease, background .12s ease; }
.meal.tapmeal:hover { border-color: var(--line-2); background: var(--surface-2); }
.meal.tapmeal:active { border-color: var(--acc); }
.sheet-sub { font-size: 13px; color: var(--muted); margin: -2px 0 12px; line-height: 1.4; }
.trends-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.coach-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.clearbtn { background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); font: inherit; font-size: 12.5px; padding: 7px 14px; border-radius: 999px; cursor: pointer; margin-top: 14px; }
.clearbtn:hover { color: var(--text); border-color: var(--line-2); }

/* ---------- today's training ---------- */
.train-rec { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; }
.train-pick { font-size: 16px; font-weight: 600; color: var(--acc); margin-bottom: 8px; }
.train-why { font-size: 13.5px; color: var(--muted); line-height: 1.5; margin-top: 5px; }
.train-why b { color: var(--text); font-weight: 600; }
.train-why.warn { color: var(--high); }

/* ---------- calendar ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; font-size: 15px; font-weight: 600; }
.cal-head button { background: var(--surface-2); border: 1px solid var(--line); color: var(--text); width: 32px; height: 32px; border-radius: 8px; font-size: 18px; cursor: pointer; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-wd { text-align: center; font-size: 11px; color: var(--faint); padding-bottom: 2px; }
.cal-cell { position: relative; aspect-ratio: 1; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 4px 4px 3px; display: flex; flex-direction: column; min-height: 0; cursor: pointer; transition: border-color .1s ease; }
.cal-cell.empty { background: none; border: none; cursor: default; }
.cal-cell:not(.empty):hover { border-color: var(--line-2); }
.cal-cell.today { border-color: var(--acc); }
.cal-cell.sel { background: rgba(79, 209, 255, 0.14); border-color: var(--acc); }
.cal-cell .cd { font-size: 12px; color: var(--muted); }
.cal-cell.today .cd { color: var(--acc); font-weight: 700; }
.recdot { position: absolute; top: 5px; right: 5px; width: 6px; height: 6px; border-radius: 50%; }
.cm-row { display: flex; flex-wrap: wrap; gap: 2px; margin-top: auto; align-items: center; line-height: 1; }
.cm { font-size: 11px; line-height: 1; }
.cdot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.cdot.rel { width: 7px; height: 7px; box-shadow: 0 0 0 1.5px rgba(255,255,255,0.12); }
.dd-head { font-size: 15px; font-weight: 600; margin: 14px 0 10px; }
.dd-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.dd-stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 4px; text-align: center; }
.dd-stat .v { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
.dd-stat .v small { font-size: 10px; font-weight: 600; opacity: 0.8; }
.dd-stat .k { font-size: 10.5px; color: var(--muted); margin-top: 4px; }
/* prep / next-up */
.prep-strip { display: flex; gap: 9px; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.prep-strip::-webkit-scrollbar { display: none; }
.prep-card { position: relative; flex: 0 0 auto; min-width: 124px; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 11px 26px 11px 12px; cursor: pointer; font: inherit; color: var(--text); transition: border-color .12s ease; }
.prep-card.on { background: var(--surface-2); }
.pc-chev { position: absolute; right: 9px; bottom: 8px; color: var(--faint); font-size: 15px; line-height: 1; transition: transform .16s ease; }
.prep-card.on .pc-chev { transform: rotate(90deg); color: var(--muted); }
.pc-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 6px; }
.pc-emoji { font-size: 17px; }
.pc-when { font-size: 11px; color: var(--muted); white-space: nowrap; }
.pc-title { font-size: 13.5px; font-weight: 600; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.pc-bg { font-size: 11.5px; font-weight: 600; margin-top: 5px; font-variant-numeric: tabular-nums; }
.prep-detail { margin-top: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 15px; }
.pd-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 16px; font-weight: 700; }
.pd-when { font-size: 12px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.pd-bg { margin-top: 12px; font-size: 13px; }
.pd-bgline { color: var(--muted); margin-top: 4px; line-height: 1.5; }
.pd-sec { margin-top: 14px; }
.pd-sec-h { font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--faint); margin-bottom: 7px; }
.pd-bullet { font-size: 13.5px; line-height: 1.5; color: var(--text); padding: 5px 0 5px 14px; position: relative; }
.pd-bullet::before { content: "·"; position: absolute; left: 3px; color: var(--muted); }
.prep-sessions { margin-top: 14px; }
.prep-sessions summary { font-size: 12.5px; color: var(--muted); cursor: pointer; }
.ps-row { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; padding: 6px 0; border-top: 1px solid var(--line); }
.ps-row:first-of-type { margin-top: 6px; }
.pd-main { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 10px; margin-top: 11px; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--radius-sm); font-size: 14.5px; }
.pdm-lbl { font-size: 11px; letter-spacing: 0.03em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.pdm-when { margin-left: auto; font-size: 12.5px; color: var(--acc); font-weight: 600; white-space: nowrap; }
.ps-day { font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--faint); margin-top: 10px; }
.ps-row.main span:first-child { color: var(--acc); font-weight: 600; }
/* recent recap */
.recap-list { display: flex; flex-direction: column; gap: 8px; }
.recap-row { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 11px 13px; }
.rc-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.rc-title { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.rc-ago { font-size: 12px; color: var(--faint); white-space: nowrap; flex: none; }
.rc-how { font-size: 12.5px; font-weight: 500; margin-top: 5px; font-variant-numeric: tabular-nums; }
.recap-row.unconf { opacity: 0.72; border-style: dashed; }
.rc-conf { color: var(--inrange); font-size: 12px; font-weight: 700; }
.rc-unconf { font-size: 10px; color: var(--high); background: rgba(251, 191, 36, 0.12); border: 1px solid rgba(251, 191, 36, 0.3); padding: 1px 6px; border-radius: 999px; font-weight: 600; letter-spacing: 0.02em; }
.rc-how.rc-warn { color: var(--high); font-weight: 500; }
/* insights */
.ins-facts { display: flex; flex-direction: column; gap: 8px; }
.ins-fact { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 13.5px; line-height: 1.5; }
.ins-fact b { color: var(--text); font-weight: 700; }
.ins-dose { display: flex; flex-direction: column; gap: 6px; }
.idz { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 11px 14px; }
.idz-l { font-size: 13.5px; color: var(--muted); }
.idz-v { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.idz-v b { color: var(--acc); }
.idz-p { font-size: 11.5px; color: var(--faint); font-weight: 500; margin-left: 4px; }
.ins-hours { display: flex; align-items: flex-end; gap: 2px; height: 84px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 8px 4px; }
.ihr { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 2px; height: 100%; }
.ihr-val { font-size: 8.5px; color: var(--muted); line-height: 1; }
.ihr-bar { width: 100%; max-width: 9px; border-radius: 2px; }
.ihr-h { font-size: 8.5px; color: var(--faint); height: 10px; }
.ihow { font-size: 12px; color: var(--muted); flex: 1; text-align: right; margin: 0 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ins-range { display: flex; gap: 7px; margin-bottom: 4px; }
.rgc, .mtc { background: var(--surface); border: 1px solid var(--line); color: var(--muted); font: inherit; font-size: 12.5px; font-weight: 600; padding: 6px 13px; border-radius: 999px; cursor: pointer; }
.rgc.on, .mtc.on { background: rgba(79, 209, 255, 0.14); border-color: var(--acc); color: var(--acc); }
.ins-metric { display: flex; gap: 7px; margin-bottom: 8px; }
.insact { cursor: pointer; }
.insact.open { border-color: var(--line-2); background: var(--surface-2); }
.insact .chev { color: var(--faint); margin-left: 8px; display: inline-block; transition: transform .16s ease; flex: 0 0 auto; }
.insact.open .chev { transform: rotate(90deg); color: var(--muted); }
.insact-detail { background: var(--surface-2); border: 1px solid var(--line); border-top: none; border-radius: 0 0 var(--radius-sm) var(--radius-sm); margin-top: -8px; padding: 8px 12px 12px; }
.sparkline { width: 100%; height: 130px; display: block; }
.axl { font-size: 9px; fill: var(--muted); }
.axy { font-size: 8.5px; fill: var(--faint); }
.mbs-list { display: flex; flex-direction: column; gap: 8px; }
.mbs-row .meal { margin: 0; }
.mbs-dp { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 4px 2px 12px; }
.mbs-cell { font-size: 11.5px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 3px 8px; }
.mbs-cell small { color: var(--faint); margin-left: 3px; }
.mbs-stats { display: flex; flex-wrap: wrap; gap: 12px; padding: 4px 4px 2px 12px; }
.mbs-stat { font-size: 12px; color: var(--muted); }
.mbs-act { margin-top: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; display: flex; flex-direction: column; gap: 7px; }
.mbs-act-h { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.spark-cap { font-size: 11px; color: var(--faint); text-align: center; margin-top: 2px; }
.scen-list { display: flex; flex-direction: column; gap: 10px; }
.scen { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 11px 13px; }
.scen-l { font-size: 12.5px; font-weight: 600; margin-bottom: 8px; }
.scen-g { display: flex; align-items: center; gap: 9px; padding: 3px 0; }
.sg-n { font-size: 12.5px; color: var(--muted); width: 92px; flex: none; }
.sg-bar { flex: 1; height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.sg-bar i { display: block; height: 100%; border-radius: 999px; }
.sg-v { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; width: 62px; text-align: right; flex: none; }
.sg-v small { color: var(--faint); font-weight: 500; font-size: 10.5px; }
.plan-into { display: flex; flex-direction: column; gap: 7px; }
.plan-row { display: grid; grid-template-columns: 64px auto 1fr; align-items: baseline; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 13px; }
.plan-row.ev { border-color: var(--line-2); background: var(--surface-2); }
.pl-when { font-size: 12px; color: var(--muted); font-weight: 600; }
.pl-pick { font-size: 13.5px; font-weight: 600; }
.plan-row.ev .pl-pick { color: var(--acc); }
.pl-why { font-size: 12px; color: var(--muted); line-height: 1.4; }

/* ---------- program ---------- */
.prog-day { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 8px; }
.prog-day summary { padding: 13px 14px; cursor: pointer; font-weight: 600; font-size: 15px; list-style: none; display: flex; align-items: center; gap: 8px; }
.prog-day summary::-webkit-details-marker { display: none; }
.prog-n { font-size: 12px; color: var(--faint); font-weight: 500; }
.prog-chev { margin-left: auto; color: var(--faint); font-size: 18px; line-height: 1; transition: transform .16s ease; }
.prog-day[open] summary .prog-chev { transform: rotate(90deg); color: var(--muted); }
.prog-day summary:hover .prog-chev { color: var(--muted); }
.prog-exs { padding: 0 14px 10px; }
.prog-ex { padding: 9px 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.prog-ex > div:first-child { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.pe-name { font-size: 14px; font-weight: 500; }
.pe-scheme { font-size: 12.5px; color: var(--acc); font-family: "SF Mono", ui-monospace, monospace; text-align: right; flex: none; }
.pe-notes { font-size: 12px; color: var(--muted); }
/* program edit mode */
.editbtn { margin-left: auto; background: var(--surface-2); border: 1px solid var(--line-2); color: var(--acc); font: inherit; font-size: 12px; font-weight: 600; text-transform: none; letter-spacing: 0; padding: 4px 12px; border-radius: 999px; cursor: pointer; }
.prog-day-ed { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 11px 12px; margin-bottom: 8px; }
.pde-day { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.pe-edit { display: flex; align-items: center; gap: 7px; padding: 5px 0; }
.pe-i { background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; color: var(--text); font: inherit; font-size: 14px; min-width: 0; }
.pe-name-i { flex: 1; }
.pe-scheme-i { width: 72px; flex: none; text-align: center; font-family: "SF Mono", ui-monospace, monospace; font-size: 13px; }
.pe-opt { flex: none; background: var(--surface-2); border: 1px solid var(--line-2); color: var(--faint); font: inherit; font-size: 11px; font-weight: 600; padding: 7px 8px; border-radius: 8px; cursor: pointer; }
.pe-opt.on { color: var(--acc); border-color: var(--acc); background: rgba(79, 209, 255, 0.12); }
.pe-del { flex: none; background: none; border: none; color: var(--low); font-size: 15px; cursor: pointer; padding: 4px 6px; }
.pe-add { margin-top: 6px; background: none; border: 1px dashed var(--line-2); color: var(--muted); font: inherit; font-size: 13px; padding: 9px; width: 100%; border-radius: 8px; cursor: pointer; }
.pe-add:hover { color: var(--text); border-color: var(--acc); }

.foot { margin-top: 16px; font-size: 11.5px; color: var(--faint); display: flex; align-items: center; gap: 7px; line-height: 1.4; }
.foot svg { width: 13px; height: 13px; flex: none; }
.foot .badge { color: var(--muted); } .foot .badge.warn { color: var(--high); }

/* bottom tab bar */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around; background: rgba(10, 13, 19, 0.92); backdrop-filter: blur(14px); border-top: 1px solid var(--line); padding: 8px 6px calc(8px + env(safe-area-inset-bottom)); z-index: 40; }
.tab { background: none; border: 0; color: var(--faint); display: flex; flex-direction: column; align-items: center; gap: 3px; font: inherit; font-size: 10.5px; cursor: pointer; padding: 4px 10px; }
.tab svg { width: 22px; height: 22px; }
.tab.active { color: var(--acc); }

/* meal sheet */
.sheet-wrap { position: fixed; inset: 0; z-index: 60; display: none; }
.sheet-wrap.open { display: block; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; max-width: 460px; margin: 0 auto; background: var(--bg1); border-top-left-radius: 22px; border-top-right-radius: 22px; border: 1px solid var(--line); padding: 10px 16px calc(20px + env(safe-area-inset-bottom)); max-height: 88vh; overflow-y: auto; }
.sheet-grab { width: 38px; height: 4px; border-radius: 2px; background: var(--line-2); margin: 4px auto 12px; }
.sheet-h { display: flex; align-items: center; justify-content: space-between; font-size: 18px; font-weight: 600; margin-bottom: 14px; }
.sheet-h .x { background: var(--surface-2); border: 0; color: var(--muted); width: 30px; height: 30px; border-radius: 50%; font-size: 14px; cursor: pointer; }
.photo-row { display: flex; gap: 9px; }
.photo-btn { flex: 1; display: flex; align-items: center; justify-content: center; gap: 9px; background: var(--acc); color: #04222e; font-weight: 700; border-radius: var(--radius-sm); padding: 14px; cursor: pointer; font-size: 14.5px; }
.photo-btn.alt { background: var(--surface-2); color: var(--text); border: 1px solid var(--line-2); }
.photo-btn svg { width: 21px; height: 21px; }
.photo-prev { width: 100%; border-radius: var(--radius-sm); margin-top: 10px; max-height: 300px; object-fit: contain; background: rgba(0,0,0,.28); cursor: zoom-in; }
.field { margin-top: 11px; }
.field label { display: block; font-size: 11px; color: var(--faint); margin-bottom: 5px; letter-spacing: 0.04em; }
.field input { width: 100%; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 12px 13px; color: var(--text); font: inherit; font-size: 15px; }
.field input:focus { outline: none; border-color: var(--acc); }
.two { display: flex; gap: 9px; }
.two .half { flex: 2; } .two .qtr { flex: 1; }
.results { max-height: 200px; overflow-y: auto; margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.results .r { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; cursor: pointer; }
.results .r:active { border-color: var(--acc); }
.results .r .rn { font-size: 13.5px; }
.results .r .rm { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.gihint { font-size: 12.5px; color: var(--muted); margin-top: 8px; min-height: 16px; }
.addfood { width: 100%; margin-top: 8px; background: transparent; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius-sm); padding: 10px; font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.addfood:active { transform: scale(0.99); }
.mealitems { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.mealitems:empty { margin-top: 0; }
.fitem { display: inline-flex; align-items: center; gap: 7px; background: var(--card2, #1b2130); border: 1px solid var(--line); border-radius: 999px; padding: 6px 11px; font-size: 13px; }
.fitem .fx { cursor: pointer; color: var(--muted); font-weight: 700; padding: 0 2px; }
.fitem .fx:hover { color: var(--low, #ff5c6c); }
.fitem-total { flex-basis: 100%; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.mealbolus { margin-top: 12px; font-size: 15px; color: var(--text); }
.mealbolus:empty { margin-top: 0; }
.mealbolus b { color: var(--acc); }
.mealbolus small { display: block; color: var(--faint); font-size: 11.5px; margin-top: 2px; }
.primary { width: 100%; margin-top: 14px; background: var(--inrange); color: #04261a; border: 0; border-radius: var(--radius-sm); padding: 15px; font: inherit; font-size: 16px; font-weight: 700; cursor: pointer; }
.primary:active { transform: scale(0.99); }
.dangerbtn { width: 100%; margin-top: 8px; background: transparent; color: var(--muted); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 11px; font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.dangerbtn:active { transform: scale(0.99); }
.dangerbtn.armed { color: #fff; background: var(--low, #ff5c6c); border-color: var(--low, #ff5c6c); }
.sheet-note { font-size: 12.5px; color: var(--muted); margin-top: 10px; text-align: center; min-height: 16px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 100px; background: var(--surface-2); border: 1px solid var(--line-2); color: var(--text); padding: 11px 18px; border-radius: 999px; font-size: 14px; z-index: 80; opacity: 0; transition: opacity 0.25s, transform 0.25s; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }

.loading .hero, .loading .action { opacity: 0.6; }

.block-sub { font-size: 12.5px; color: var(--muted); margin: -4px 0 10px; line-height: 1.45; }

/* ---------- coach chat ---------- */
.chat { display: flex; flex-direction: column; gap: 12px; }
.chat-log { display: flex; flex-direction: column; gap: 10px; min-height: 180px; }
.msg { max-width: 88%; padding: 11px 14px; border-radius: 16px; font-size: 14.5px; line-height: 1.5; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--acc); color: #04222e; font-weight: 500; border-bottom-right-radius: 5px; }
.msg.bot { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.msg.think { color: var(--muted); }
.cquick { display: flex; flex-wrap: wrap; gap: 7px; }
.cquick button { background: var(--surface); border: 1px solid var(--line); color: var(--muted); font: inherit; font-size: 12.5px; padding: 7px 11px; border-radius: 999px; cursor: pointer; }
.cquick button:hover { border-color: var(--acc); color: var(--text); }
.chat-input { display: flex; gap: 8px; }
.chat-input input { flex: 1; background: var(--surface); border: 1px solid var(--line-2); border-radius: 999px; padding: 12px 16px; color: var(--text); font: inherit; font-size: 15px; }
.chat-input input:focus { outline: none; border-color: var(--acc); }
.chat-input button { background: var(--acc); color: #04222e; border: 0; border-radius: 999px; padding: 0 18px; font: inherit; font-weight: 700; cursor: pointer; }

/* ---------- trends ---------- */
.tirstack { display: flex; height: 26px; border-radius: 7px; overflow: hidden; border: 1px solid var(--line); }
.tirstack > span { display: block; }
.tirlegend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 9px; font-size: 12px; color: var(--muted); }
.tirlegend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.agp { width: 100%; height: auto; display: block; touch-action: none; cursor: crosshair; }
.agp-wrap { position: relative; }
.scorecard { display: flex; flex-direction: column; gap: 8px; }
.scrow { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.scrow .h { width: 56px; color: var(--muted); flex: none; }
.scrow .track { flex: 1; height: 8px; background: var(--surface-2); border-radius: 4px; position: relative; overflow: hidden; }
.scrow .track i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; }
.scrow .v { width: 118px; text-align: right; flex: none; color: var(--muted); font-size: 12px; }
.recent-side { display: none; }

/* ---------- desktop layout (Mac) ---------- */
.sidebar { display: none; }
@media (min-width: 880px) {
  .tabbar { display: none; }
  .tabspacer { display: none; }
  .sidebar {
    display: flex; flex-direction: column; gap: 3px;
    position: fixed; left: 0; top: 0; bottom: 0; width: 212px;
    background: rgba(9, 12, 18, 0.7); border-right: 1px solid var(--line); padding: 22px 14px; z-index: 30;
  }
  .sb-brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 20px; }
  .sb-brand img { width: 24px; height: 24px; }
  .sb-brand span { font-weight: 700; letter-spacing: 0.3em; font-size: 14px; }
  .snav { display: flex; align-items: center; gap: 12px; background: none; border: 0; color: var(--muted);
    font: inherit; font-size: 15px; padding: 11px 13px; border-radius: var(--radius-sm); cursor: pointer; text-align: left; }
  .snav svg { width: 21px; height: 21px; }
  .snav:hover { background: var(--surface); color: var(--text); }
  .snav.active { background: rgba(79, 209, 255, 0.14); color: var(--acc); }
  .app { margin-left: 212px; max-width: 1020px; padding: 26px 30px 40px; }
  /* main column (stat cards then Whoop stacked below) + a recent-activity sidebar */
  #homeView { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 18px; align-items: start; }
  #homeMain { grid-column: 1; min-width: 0; }
  #recentSide { grid-column: 2; }
  .recent-side { display: flex; flex-direction: column; gap: 14px; }
  #mealsBlock { display: none !important; }
  #coachView, #trendsView, #activityView { max-width: 780px; }
  .bgval { font-size: 84px; }
  .topbar .brand { display: none; }
}
