/* Personal Health App. Values copied from docs/design (Components.dc.html and the screens).
   Light mode only until Stage 6. */

:root {
  --ground: #FFFFFF;
  --surface: #F4F4F4;
  --hairline: #E2E2E2;
  --divider: #DDDDDD;
  --track: #D9D9D9;
  --outline: #8A8A8A;
  --secondary: #5C5C5C;
  --ink: #111111;
  --accent: #F26A1B;
  --accent-text: #B4460A;
  --disabled-bg: #E2E2E2;
  --disabled-text: #6E6E6E;
  --font: 'Helvetica Neue', Helvetica, -apple-system, system-ui, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 20px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; text-align: left; cursor: pointer; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; }
input, textarea { font-family: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* Icons */
.i { fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.i.bold { stroke-width: 2; }
.i.thick { stroke-width: 2.25; }
.i.muted { color: var(--secondary); }

/* ---- Page shells ---------------------------------------------------------- */

.page {
  max-width: 430px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 12px) 20px calc(var(--safe-bottom) + 32px);
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 100vh;
}
/* Pages with an orange action bar fixed at the bottom. */
.page:has(.bottom-bar) { padding-bottom: calc(var(--safe-bottom) + 112px); }
.page--setup { padding-top: calc(var(--safe-top) + 24px); }
.page--main { padding-bottom: calc(var(--safe-bottom) + 104px); }
.stack { display: flex; flex-direction: column; gap: 20px; }

/* ---- Type ----------------------------------------------------------------- */

.h1 { font-size: 28px; line-height: 34px; font-weight: 700; letter-spacing: -0.02em; }
.h2 { font-size: 17px; line-height: 22px; font-weight: 700; }
.h3 { font-size: 15px; line-height: 20px; font-weight: 700; }
.title { font-size: 20px; line-height: 26px; font-weight: 700; letter-spacing: -0.01em; }
.sub { font-size: 13px; line-height: 16px; color: var(--secondary); }
.lead { font-size: 15px; line-height: 20px; color: var(--secondary); text-wrap: pretty; }
.caption { font-size: 12px; line-height: 16px; color: var(--secondary); text-wrap: pretty; }
.eyebrow { font-size: 13px; line-height: 16px; font-weight: 600; color: var(--secondary); }
.head { display: flex; flex-direction: column; gap: 6px; }
.head--tight { gap: 4px; }

/* ---- Back link ------------------------------------------------------------ */

.backbar { display: flex; align-items: center; height: 44px; margin: 0 -8px -8px; }
.back { display: flex; align-items: center; gap: 2px; height: 44px; padding: 0 8px; font-size: 15px; line-height: 20px; font-weight: 600; }

/* ---- Buttons -------------------------------------------------------------- */

.btn { display: flex; align-items: center; justify-content: center; gap: 8px; height: 52px; padding: 0 28px; border-radius: 14px; font-size: 16px; line-height: 20px; font-weight: 700; text-align: center; }
.btn-primary { background: var(--accent); color: var(--ink); }
.btn-secondary { border: 1.5px solid var(--ink); }
.btn-text { height: 48px; padding: 0 12px; margin: 0 -12px; align-self: flex-start; font-size: 16px; font-weight: 700; }
.btn-block { width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { background: var(--disabled-bg); color: var(--disabled-text); border-color: transparent; cursor: default; }

.bottom-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  padding: 12px max(20px, calc(50% - 195px)) calc(var(--safe-bottom) + 24px);
  background: var(--ground);
  border-top: 1px solid var(--hairline);
  display: flex; gap: 12px;
}
.bottom-bar .btn-back { order: -1; flex: none; width: 104px; padding: 0; }
.bottom-bar .btn-grow { flex: 1 1 0; }

.icon-btn { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; border-radius: 50%; }
.text-link { display: flex; align-items: center; height: 44px; padding: 0 8px; margin: -12px -8px; font-size: 15px; line-height: 20px; font-weight: 600; }
.dashed-btn { display: flex; align-items: center; gap: 12px; width: 100%; height: 56px; margin-top: 4px; padding: 0 14px; border: 1px dashed var(--outline); border-radius: 16px; font-size: 15px; line-height: 20px; font-weight: 700; }
.danger-link { align-self: flex-start; display: flex; align-items: center; min-height: 44px; font-size: 15px; font-weight: 700; color: var(--accent-text); text-decoration: underline; text-underline-offset: 3px; }

/* ---- Form fields ---------------------------------------------------------- */

.fields { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 13px; line-height: 16px; font-weight: 600; }
.optional { font-weight: 400; color: var(--secondary); }
.hint { font-size: 12px; line-height: 16px; color: var(--secondary); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid-2--tight { gap: 14px 12px; }

.input, .input-unit input, .input-wrap input {
  width: 100%; height: 48px; padding: 0 14px;
  border: 1px solid var(--outline); border-radius: 12px;
  background: var(--ground); color: var(--ink); font-size: 16px;
  -webkit-appearance: none; appearance: none;
}
.input:focus, .input-wrap:focus-within, .input-unit:focus-within { outline: none; border: 2px solid var(--ink); }
.input:focus { padding: 0 13px; }

.input-unit, .input-wrap {
  display: flex; align-items: center; gap: 8px; height: 48px; padding: 0 14px;
  border: 1px solid var(--outline); border-radius: 12px; background: var(--ground);
}
.input-unit:focus-within, .input-wrap:focus-within { padding: 0 13px; }
.input-unit input, .input-wrap input { flex: 1 1 0; min-width: 0; height: 40px; padding: 0; border: 0; border-radius: 0; }
.input-unit input { font-weight: 700; }
.input-unit input:focus, .input-wrap input:focus { outline: none; border: 0; }
.input-unit span { font-size: 13px; line-height: 16px; color: var(--secondary); }
.input-wrap { padding-right: 2px; }
.input-wrap:focus-within { padding-right: 1px; }
.reveal { flex: none; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; color: var(--secondary); }
.reveal[aria-pressed="true"] { color: var(--ink); }

[aria-invalid="true"].input, .input-unit:has([aria-invalid="true"]), .input-wrap:has([aria-invalid="true"]) { border: 2px solid var(--accent); }

.field-error, .form-error, .form-ok { display: flex; align-items: flex-start; gap: 4px; font-size: 12px; line-height: 16px; font-weight: 700; color: var(--accent-text); }
.field-error .i { margin-top: 1px; }
.form-error, .form-ok { gap: 8px; font-size: 15px; line-height: 20px; }
.form-ok { color: var(--ink); font-weight: 600; }

/* Segmented choice: radios (forms) or buttons with aria-pressed (settings). */
.seg { display: grid; gap: 4px; height: 48px; padding: 2px; border-radius: 12px; background: var(--surface); }
.seg-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.seg-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.seg--fixed { width: 176px; flex: none; }
.seg label { position: relative; display: flex; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span, .seg button {
  flex: 1 1 0; display: flex; align-items: center; justify-content: center;
  height: 44px; border-radius: 10px; font-size: 15px; line-height: 20px; font-weight: 600; text-align: center; cursor: pointer;
}
.seg input:checked + span, .seg button[aria-pressed="true"] { background: var(--ink); color: #FFFFFF; }
.seg input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ---- Setup steps ---------------------------------------------------------- */

.steps { display: flex; flex-direction: column; gap: 8px; }
.step-bar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.step-bar span { height: 4px; border-radius: 2px; background: var(--track); }
.step-bar span.on { background: var(--accent); }

/* ---- Lists and rows ------------------------------------------------------- */

.group { display: flex; flex-direction: column; gap: 8px; }
.group-head { display: flex; align-items: center; justify-content: space-between; }
.list { display: flex; flex-direction: column; border: 1px solid var(--hairline); border-radius: 16px; overflow: hidden; }
.list > *:not(:last-child) .list-row, .list > .list-row:not(:last-child) { border-bottom: 1px solid var(--hairline); }
.list > form { display: contents; }
.list-row { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 48px; padding: 0 12px 0 14px; }
.list-row--setting { height: 48px; }
.list-row--boxed { height: 58px; border: 1px solid var(--hairline); border-radius: 16px; }
.list-row--unit { justify-content: space-between; gap: 12px; height: 60px; padding: 0 8px 0 14px; }
.list-row--data { gap: 12px; height: 56px; }
.list-row--profile { gap: 12px; height: 72px; }
.row-label { flex: 1 1 0; font-size: 15px; line-height: 20px; }
.row-value { font-size: 15px; line-height: 20px; font-weight: 700; }
.row-text { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-text .row-label { flex: none; }
.row-title { font-size: 15px; line-height: 20px; font-weight: 700; }
.row-sub { font-size: 12px; line-height: 14px; color: var(--secondary); }

.profile-card { display: flex; align-items: center; gap: 12px; width: 100%; height: 72px; padding: 0 14px; border: 1px solid var(--hairline); border-radius: 16px; }
.profile-card.is-current { border: 2px solid var(--ink); padding: 0 13px; }
.current { display: flex; align-items: center; gap: 4px; font-size: 13px; line-height: 16px; font-weight: 700; }

.avatar { flex: none; width: 44px; height: 44px; border-radius: 50%; background: var(--ink); color: #FFFFFF; display: flex; align-items: center; justify-content: center; font-size: 17px; font-weight: 700; }
.avatar--outline { background: none; color: var(--ink); border: 1.5px solid var(--ink); }

.note { background: var(--surface); border-radius: 16px; padding: 14px 16px; display: flex; align-items: flex-start; gap: 10px; }
.note p { font-size: 13px; line-height: 18px; text-wrap: pretty; }
.note--muted p { color: var(--secondary); }

/* ---- Main page ------------------------------------------------------------ */

.main-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 48px; }
.who { display: flex; align-items: center; gap: 12px; height: 48px; min-width: 0; }
.who-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.who-name { display: flex; align-items: center; gap: 4px; }
.who-name .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.card { background: var(--surface); border-radius: 20px; padding: 16px 16px 4px; display: flex; flex-direction: column; }
.card-head { display: flex; justify-content: space-between; font-size: 13px; line-height: 16px; font-weight: 500; color: var(--secondary); }
.card-head--plain { font-weight: 400; }
.card-head--plain span:first-child { font-weight: 500; }

.quota { gap: 16px; }
.quota-main { display: flex; flex-direction: column; gap: 6px; }
.quota-big { display: flex; align-items: baseline; gap: 8px; }
.quota-big .num { font-size: 56px; line-height: 56px; font-weight: 700; letter-spacing: -0.03em; }
.quota-big .word { font-size: 17px; line-height: 22px; color: var(--secondary); }
.quota .body { font-size: 15px; line-height: 20px; }
.grid-2--quota { gap: 16px; }
.quota-small { display: flex; flex-direction: column; gap: 4px; }
.label-sm { font-size: 13px; line-height: 16px; color: var(--secondary); }
.quota-mid { display: flex; align-items: baseline; gap: 6px; }
.quota-mid .num { font-size: 22px; line-height: 26px; font-weight: 700; letter-spacing: -0.01em; }
.quota-mid .word { font-size: 13px; line-height: 16px; color: var(--secondary); }
/* Over target: attention colour together with the word "over", never a minus sign alone. */
.over .num, .over .word, .val.over { color: var(--accent-text); font-weight: 700; }

.bar { display: flex; background: var(--track); overflow: hidden; }
.bar--thick { height: 8px; border-radius: 4px; }
.bar--thin { height: 4px; border-radius: 2px; }
.bar .fill { height: 100%; border-radius: inherit; background: var(--ink); }
.bar--thick .fill { background: var(--accent); }

.quota-foot { display: flex; flex-direction: column; }
.expander { display: flex; align-items: center; justify-content: space-between; width: 100%; height: 44px; border-top: 1px solid var(--divider); font-size: 15px; line-height: 20px; }
.expander .chev { color: var(--secondary); display: flex; transition: transform .15s; }
.expander[aria-expanded="true"] .chev { transform: rotate(180deg); }
.quota-more { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding: 4px 0 16px; }
.quota-extra { display: flex; flex-direction: column; gap: 4px; }
.quota-extra .cap { font-size: 12px; line-height: 14px; color: var(--secondary); }
.quota-extra .val { font-size: 15px; line-height: 20px; font-weight: 700; }

.quota-cells { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--divider); }
.cell { display: flex; align-items: center; gap: 10px; height: 52px; }
.cell--right { padding-left: 16px; border-left: 1px solid var(--divider); }
.cell-text { display: flex; flex-direction: column; min-width: 0; }
.cell-text .cap { font-size: 12px; line-height: 14px; color: var(--secondary); }
.cell-val { font-size: 15px; line-height: 20px; font-weight: 700; }
.cell-val.with-icon { display: flex; align-items: center; gap: 4px; }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tile { height: 96px; padding: 12px 14px; border: 1px solid var(--hairline); border-radius: 16px; display: flex; flex-direction: column; justify-content: space-between; }
.tile-top { display: flex; align-items: center; justify-content: space-between; }
.tile-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tile-name { font-size: 17px; line-height: 22px; font-weight: 700; }
.tile-status { font-size: 13px; line-height: 16px; color: var(--secondary); }
.tile--wide { grid-column: 1 / -1; flex-direction: row; align-items: center; justify-content: flex-start; gap: 12px; height: 64px; padding: 0 14px; }
.tile--wide .tile-text { flex: 1 1 0; }

.stats { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }
.empty-box { height: 96px; padding: 0 16px; border: 1px dashed var(--outline); border-radius: 16px; display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.empty-title { font-size: 15px; line-height: 20px; font-weight: 700; }
.empty-text { font-size: 13px; line-height: 16px; color: var(--secondary); text-wrap: pretty; }

.summary { gap: 8px; margin-top: 4px; }
.summary-text { font-size: 15px; line-height: 22px; text-wrap: pretty; }
.card-link { display: flex; align-items: center; justify-content: space-between; height: 44px; border-top: 1px solid var(--divider); font-size: 15px; line-height: 20px; font-weight: 600; }

/* Quick add: stays in reach while scrolling. */
.fab {
  position: fixed; z-index: 20;
  right: max(20px, calc(50% - 195px)); bottom: calc(var(--safe-bottom) + 24px);
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent); color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
}
.fab span { display: flex; }
.qa-menu {
  position: fixed; z-index: 20;
  right: max(20px, calc(50% - 195px)); bottom: calc(var(--safe-bottom) + 92px);
  width: 224px; padding: 4px 0; display: flex; flex-direction: column;
  background: var(--ground); border: 1px solid var(--hairline); border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
}
.qa-item { display: flex; align-items: center; gap: 12px; width: 100%; height: 48px; padding: 0 16px; font-size: 15px; line-height: 20px; font-weight: 600; }
.fab-pill {
  position: fixed; z-index: 20;
  right: max(20px, calc(50% - 195px)); bottom: calc(var(--safe-bottom) + 24px);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 56px; padding: 0 22px; border-radius: 28px;
  background: var(--accent); color: var(--ink); font-size: 16px; line-height: 20px; font-weight: 700;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
}

/* Screens from later stages: shown as designed, not tappable yet. */
[data-later] { cursor: default; }

/* ---- Offline -------------------------------------------------------------- */

.offline-bar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: calc(var(--safe-top) + 8px) 20px 8px;
  background: var(--ink); color: #FFFFFF;
  font-size: 13px; line-height: 16px; font-weight: 600;
}
body.is-offline .page { padding-top: 12px; }

/* Progress widths in whole percent. Classes, because the security policy allows no inline styles. */
.p0{width:0}.p1{width:1%}.p2{width:2%}.p3{width:3%}.p4{width:4%}.p5{width:5%}.p6{width:6%}.p7{width:7%}.p8{width:8%}.p9{width:9%}
.p10{width:10%}.p11{width:11%}.p12{width:12%}.p13{width:13%}.p14{width:14%}.p15{width:15%}.p16{width:16%}.p17{width:17%}.p18{width:18%}.p19{width:19%}
.p20{width:20%}.p21{width:21%}.p22{width:22%}.p23{width:23%}.p24{width:24%}.p25{width:25%}.p26{width:26%}.p27{width:27%}.p28{width:28%}.p29{width:29%}
.p30{width:30%}.p31{width:31%}.p32{width:32%}.p33{width:33%}.p34{width:34%}.p35{width:35%}.p36{width:36%}.p37{width:37%}.p38{width:38%}.p39{width:39%}
.p40{width:40%}.p41{width:41%}.p42{width:42%}.p43{width:43%}.p44{width:44%}.p45{width:45%}.p46{width:46%}.p47{width:47%}.p48{width:48%}.p49{width:49%}
.p50{width:50%}.p51{width:51%}.p52{width:52%}.p53{width:53%}.p54{width:54%}.p55{width:55%}.p56{width:56%}.p57{width:57%}.p58{width:58%}.p59{width:59%}
.p60{width:60%}.p61{width:61%}.p62{width:62%}.p63{width:63%}.p64{width:64%}.p65{width:65%}.p66{width:66%}.p67{width:67%}.p68{width:68%}.p69{width:69%}
.p70{width:70%}.p71{width:71%}.p72{width:72%}.p73{width:73%}.p74{width:74%}.p75{width:75%}.p76{width:76%}.p77{width:77%}.p78{width:78%}.p79{width:79%}
.p80{width:80%}.p81{width:81%}.p82{width:82%}.p83{width:83%}.p84{width:84%}.p85{width:85%}.p86{width:86%}.p87{width:87%}.p88{width:88%}.p89{width:89%}
.p90{width:90%}.p91{width:91%}.p92{width:92%}.p93{width:93%}.p94{width:94%}.p95{width:95%}.p96{width:96%}.p97{width:97%}.p98{width:98%}.p99{width:99%}
.p100{width:100%}

/* Chips: one choice from several short options (Components.dc.html, "Chips"). */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; display: flex; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip span { display: flex; align-items: center; height: 44px; padding: 0 18px; border-radius: 22px; border: 1px solid var(--outline); font-size: 15px; line-height: 20px; font-weight: 600; cursor: pointer; }
.chip input:checked + span { background: var(--ink); border-color: var(--ink); color: #FFFFFF; }
.chip input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 2px; }
