/* Layout: one phone-width column, sticky day header. */
:root {
  --bg: #eef2f0;
  --surface: #ffffff;
  --fg: #16201c;
  --muted: #5d6b65;
  --line: #d5ddd9;
  --accent: #1f6f5c;
  --accent-fg: #ffffff;
  --s1: #d1453a; --s2: #e5803a; --s3: #dcb233; --s4: #86b648; --s5: #379659;
  --on-s3: #2a2205;
  --font-ui: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-num: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1412; --surface: #17201c; --fg: #e4ebe8; --muted: #8fa19a; --line: #2a3632;
    --accent: #5cc2a6; --accent-fg: #062219;
    --s1: #e0584c; --s2: #ec8f4b; --s3: #e3bf45; --s4: #93c257; --s5: #47aa6a;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font-ui); font-size: 15px; -webkit-tap-highlight-color: transparent; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg); }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#app { max-width: 480px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 0 32px; }

/* day header */
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--bg); display: grid; grid-template-columns: 44px 1fr 44px 20px; align-items: center; gap: 4px; padding-block: 10px; }
.top h1 { margin: 0; font-size: 1.25rem; text-align: center; }
.top h1 small { display: block; font-size: .72rem; font-weight: 400; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.nav { height: 44px; border-radius: 50%; font-size: 1.5rem; }
.nav:disabled { opacity: .25; cursor: default; }
.sync { width: 10px; height: 10px; border-radius: 50%; background: var(--s5); justify-self: center; }
.sync.pending { background: var(--s2); }
.sync.local { background: var(--line); }

/* widgets */
.wk { font-family: var(--font-num); font-size: .75rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.wk.ok { color: var(--s5); }
.wk.bad { color: var(--s1); font-weight: 700; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.seg button { min-height: 40px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); font-size: .85rem; }
.seg button.on { color: #fff; border-color: transparent; font-weight: 700; }
.seg .m1.on { background: var(--s5); }
.seg .m2.on { background: var(--s3); color: var(--on-s3); }
.seg .m3.on { background: var(--s1); }
.dots { display: flex; gap: 8px; justify-content: space-between; }
.dot { width: 38px; height: 38px; border-radius: 50%; font-family: var(--font-num); font-size: .8rem; color: transparent; transition: transform .12s; }
.dot.s1 { background: color-mix(in srgb, var(--s1) 22%, transparent); }
.dot.s2 { background: color-mix(in srgb, var(--s2) 22%, transparent); }
.dot.s3 { background: color-mix(in srgb, var(--s3) 22%, transparent); }
.dot.s4 { background: color-mix(in srgb, var(--s4) 22%, transparent); }
.dot.s5 { background: color-mix(in srgb, var(--s5) 22%, transparent); }
.dot.on { color: #fff; transform: scale(1.12); box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--fg); }
.dot.on.s1 { background: var(--s1); }
.dot.on.s2 { background: var(--s2); }
.dot.on.s3 { background: var(--s3); color: var(--on-s3); }
.dot.on.s4 { background: var(--s4); }
.dot.on.s5 { background: var(--s5); }
.ctr { display: inline-grid; grid-template-columns: 40px 2.2rem 40px; align-items: center; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.ctr button { height: 38px; font-size: 1.2rem; }
.ctr .n { text-align: center; font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 8px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: .88rem; }
.chip.on { background: var(--accent); color: var(--accent-fg); border-color: transparent; font-weight: 700; }
.chk { display: flex; align-items: center; gap: 8px; padding: 8px 0; }
.box { width: 24px; height: 24px; border-radius: 6px; border: 2px solid var(--line); display: grid; place-items: center; font-size: .9rem; }
.chk.on .box { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.cbtn { width: 36px; height: 40px; display: grid; place-items: center; color: var(--muted); position: relative; }
.cbtn svg { width: 20px; height: 20px; }
.has::after { content: ""; position: absolute; top: 7px; right: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.meas { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding-top: 8px; }
.meas label { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; color: var(--muted); }
.meas .unit { font-family: var(--font-num); font-size: .7rem; margin-left: 4px; }
.meas input, .login input { font: 500 1.05rem var(--font-num); color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; width: 100%; }
.note { display: flex; align-items: center; gap: 8px; width: 100%; padding: 12px; border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); position: relative; text-align: left; }
.note svg { width: 18px; height: 18px; flex: none; }
.note .txt { color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* sections */
.sec { padding-block: 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.sec h2 { margin: 0 0 2px; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); display: flex; justify-content: space-between; }
.row { display: grid; grid-template-columns: 4.6rem minmax(0, 1fr) auto; align-items: center; gap: 8px; min-height: 42px; }
.row .lbl { font-weight: 700; font-size: .92rem; }
.row .ctr { justify-self: start; }
.pair { display: flex; gap: 24px; flex-wrap: wrap; }
.disc { display: flex; justify-content: space-between; align-items: center; width: 100%; padding-block: 6px; font-weight: 700; }
.disc span { display: flex; gap: 6px; align-items: center; color: var(--muted); font-weight: 400; font-size: .85rem; }

/* login */
.login { display: flex; flex-direction: column; gap: 12px; padding-top: 25vh; }
.login h1 { margin: 0; font-size: 1.5rem; }
.login p { margin: 0; color: var(--muted); }

/* dialog */
dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--fg); padding: 16px; width: min(440px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog h3 { margin: 0 0 10px; font-size: 1.05rem; }
dialog .acts { display: flex; justify-content: flex-end; gap: 6px; margin-top: 10px; }
#ctext { width: 100%; font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px; resize: vertical; }
.pri { background: var(--accent); color: var(--accent-fg); padding: 12px 18px; border-radius: 10px; font-weight: 700; }
.pri:disabled { opacity: .5; }
.ghost { color: var(--muted); padding: 12px 8px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
