:root{
  --bg:#f7f4ef;
  --card:#ffffff;
  --primary:#2f9e8f;
  --primary-d:#237a6e;
  --primary-l:#e3f3f0;
  --ink:#20302e;
  --muted:#75837f;
  --line:#e8e2d8;
  --tabbar-h:60px;
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{height:100%}
@supports (height:100dvh){html,body{height:100dvh}}
body{
  margin:0;display:flex;flex-direction:column;overflow:hidden;
  background:var(--bg);color:var(--ink);
  font:16px/1.55 -apple-system,BlinkMacSystemFont,"PingFang SC","Hiragino Sans GB","Microsoft YaHei",sans-serif;
}
.hidden{display:none !important}

.app-header{
  flex:none;width:100%;max-width:560px;margin:0 auto;
  display:flex;align-items:center;gap:10px;
  padding:calc(env(safe-area-inset-top,0px) + 12px) 16px 10px;
}
.hd-title{display:flex;flex-direction:column;justify-content:center;min-width:0}
#hd-title{font-size:17px;font-weight:600;letter-spacing:.5px}
.hd-sub{font-size:12px;color:var(--muted)}
.upd-btn{
  margin-left:auto;flex:none;border:0;border-radius:999px;
  padding:6px 12px;font-size:12px;color:#fff;background:var(--primary);
}
main{
  flex:1 1 auto;min-height:0;overflow-y:auto;-webkit-overflow-scrolling:touch;
  width:100%;max-width:560px;margin:0 auto;
  padding:0 14px calc(var(--tabbar-h) + 42px + env(safe-area-inset-bottom,0px));
}
.view{padding-top:2px}
.tabbar{
  flex:none;width:100%;max-width:560px;margin:0 auto;
  display:flex;background:rgba(255,255,255,.96);
  border-top:1px solid var(--line);
  padding-bottom:env(safe-area-inset-bottom,0px);
  backdrop-filter:saturate(1.2) blur(8px);
}
.tab{
  flex:1;height:var(--tabbar-h);border:0;background:none;
  display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1px;
  font-size:11px;color:var(--muted);font-family:inherit;
}
.tab i{font-style:normal;font-size:17px;line-height:1}
.tab.on{color:var(--primary-d);font-weight:600}

/* ---------- hero ---------- */
.hero{
  display:flex;align-items:center;justify-content:space-between;gap:12px;
  background:linear-gradient(160deg,#ffffff 0%,#eef7f4 100%);
  border:1px solid var(--line);border-radius:18px;padding:16px 16px 14px;margin-top:6px;
  box-shadow:0 2px 10px rgba(47,158,143,.06);
}
.hero-date{font-size:13px;color:var(--muted)}
.hero-streak{margin-top:6px;font-size:14px;color:var(--muted);display:flex;align-items:baseline;gap:4px}
.hero-streak b{font-size:30px;color:var(--primary-d);font-weight:700;line-height:1}
.hero-note{margin-top:8px;font-size:13px;color:var(--primary-d);min-height:20px}
.hero-right{position:relative;flex:none;width:104px;height:104px}
.ring{width:104px;height:104px;transform:rotate(-90deg)}
.ring-bg{fill:none;stroke:#e4ece9;stroke-width:10}
.ring-fg{fill:none;stroke:var(--primary);stroke-width:10;stroke-linecap:round;
  stroke-dasharray:326.7;stroke-dashoffset:326.7;transition:stroke-dashoffset .35s ease}
.ring-txt{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center}
.ring-txt b{font-size:26px;line-height:1;color:var(--ink)}
.ring-txt span{font-size:11px;color:var(--muted);margin-top:3px}

.sec-title{
  margin:22px 2px 10px;font-size:13px;color:var(--muted);letter-spacing:.4px;
}
.sec-title.sm{margin:14px 2px 8px}
.hint{margin:8px 2px 0;font-size:12.5px;color:var(--muted);line-height:1.6}

/* ---------- item list ---------- */
.list{display:flex;flex-direction:column;gap:8px}
.row{
  display:flex;align-items:flex-start;gap:10px;background:var(--card);
  border:1px solid var(--line);border-radius:14px;padding:11px 12px;
}
.row-main{flex:1;min-width:0}
.row-top{display:flex;align-items:baseline;gap:8px;flex-wrap:wrap}
.row-name{font-size:15.5px;font-weight:600}
.row-dose{font-size:12.5px;color:var(--primary-d);background:var(--primary-l);
  border-radius:999px;padding:1px 8px}
.row-cue{margin-top:3px;font-size:12.5px;color:var(--muted);line-height:1.5}
.tick{
  flex:none;width:28px;height:28px;border-radius:50%;border:1.5px solid #cfdad7;
  background:#fff;color:transparent;font-size:15px;line-height:1;padding:0;margin-top:2px;
  display:flex;align-items:center;justify-content:center;
}
.row.on{border-color:#bfe3dc;background:#f4fbf9}
.row.on .tick{background:var(--primary);border-color:var(--primary);color:#fff}
.row.on .row-name{color:var(--primary-d)}
.tmr{
  flex:none;margin-top:1px;min-height:36px;border:1px solid var(--line);background:#fff;border-radius:10px;
  padding:7px 10px;font-size:13px;color:var(--muted);font-family:inherit;
}
.tmr:active{background:var(--primary-l)}
.list.mini .row{padding:9px 10px;border-radius:12px}
.list.mini .row-cue{display:none}

/* ---------- chips ---------- */
.chips{display:flex;flex-wrap:wrap;gap:8px}
.chip{
  border:1px solid var(--line);background:#fff;border-radius:999px;
  padding:8px 12px;font-size:13.5px;color:var(--ink);font-family:inherit;line-height:1.35;
  text-align:left;
}
.chip.on{background:var(--primary-l);border-color:#bfe3dc;color:var(--primary-d)}

/* ---------- log ---------- */
.stat-row{display:flex;gap:8px;margin-top:8px}
.stat{
  flex:1;background:var(--card);border:1px solid var(--line);border-radius:14px;
  padding:12px 6px;text-align:center;
}
.stat b{display:block;font-size:22px;color:var(--primary-d)}
.stat span{font-size:11.5px;color:var(--muted)}
.grid-wrap{background:var(--card);border:1px solid var(--line);border-radius:14px;padding:12px}
.grid-head{display:grid;grid-template-columns:repeat(7,1fr);gap:6px;margin-bottom:6px}
.grid-head i{font-style:normal;font-size:11px;color:var(--muted);text-align:center}
.grid{display:grid;grid-template-columns:repeat(7,1fr);gap:6px}
.cell{
  width:100%;aspect-ratio:1/1;border-radius:7px;background:#f1efea;border:1px solid #eee9e1;
  display:block;padding:0;
}
button.cell{font-family:inherit}
.cell.l1{background:#c9e7e0;border-color:#bde0d8}
.cell.l2{background:#79c8ba;border-color:#6ec0b1}
.cell.l3{background:var(--primary);border-color:var(--primary)}
.cell.today{outline:2px solid var(--primary-d);outline-offset:1px}
.cell.future{background:transparent;border-style:dashed;border-color:#efebe4}
.legend{display:flex;gap:12px;margin-top:10px;flex-wrap:wrap}
.lg{display:flex;align-items:center;gap:5px;font-size:11.5px;color:var(--muted)}
.lg .cell{width:13px;height:13px;aspect-ratio:auto;border-radius:4px}
.totals{display:flex;flex-direction:column;gap:6px}
.tot{display:flex;align-items:center;gap:8px;font-size:13.5px}
.tot span.n{margin-left:auto;color:var(--muted);font-size:12.5px}
.tot .bar{flex:1;height:6px;border-radius:99px;background:#f0ede7;overflow:hidden;max-width:120px}
.tot .bar i{display:block;height:100%;background:var(--primary);border-radius:99px}

/* ---------- buttons / cards ---------- */
.btn-row{display:flex;gap:10px;margin-top:10px}
.btn{
  flex:1;border:0;border-radius:12px;padding:12px 14px;font-size:15px;
  background:var(--primary);color:#fff;font-family:inherit;font-weight:600;
}
.btn:active{background:var(--primary-d)}
.btn.ghost{background:#fff;color:var(--primary-d);border:1px solid #cfe3df;font-weight:500}
.card{background:var(--card);border:1px solid var(--line);border-radius:16px;padding:14px;margin-top:10px}
.card-t{font-size:15px;font-weight:600;margin-bottom:6px}
.card p{margin:0 0 8px;font-size:14px;line-height:1.65;color:#3c4a47}
.card p:last-child{margin-bottom:0}
.about-line{font-size:12.5px;color:var(--muted)}

/* ---------- timer ---------- */
.timer{
  position:fixed;inset:0;z-index:60;background:rgba(23,34,32,.94);color:#fff;
  display:flex;align-items:center;justify-content:center;padding:20px;
}
.tm-inner{width:100%;max-width:340px;text-align:center;position:relative}
.tm-name{font-size:16px;color:#cfe6e2}
.tm-set{font-size:12.5px;color:#8fb0ab;margin-top:3px;min-height:18px}
.tm-digits{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;
  font-size:56px;font-weight:700;font-variant-numeric:tabular-nums}
.tm-ring{margin:26px auto 0;width:220px;height:220px;position:relative}
.tm-ring svg{width:220px;height:220px;transform:rotate(-90deg)}
.tm-bg{fill:none;stroke:rgba(255,255,255,.16);stroke-width:8}
.tm-fg{fill:none;stroke:#5fd0bf;stroke-width:8;stroke-linecap:round;
  stroke-dasharray:339.3;stroke-dashoffset:0;transition:stroke-dashoffset .2s linear}
.tm-btns{display:flex;gap:10px;margin-top:26px}
.tm-btns .btn{background:#5fd0bf;color:#12302c}
.tm-btns .btn.ghost{background:transparent;color:#cfe6e2;border:1px solid rgba(255,255,255,.3)}
.timer.done .tm-fg{stroke:#ffd479}
.timer.done .tm-digits{color:#ffd479}

/* ---------- modal ---------- */
.modal{
  position:fixed;inset:0;z-index:50;background:rgba(20,30,28,.42);
  display:flex;align-items:flex-end;justify-content:center;
}
.modal-box{
  width:100%;max-width:560px;background:var(--bg);border-radius:18px 18px 0 0;
  max-height:86vh;display:flex;flex-direction:column;
  padding-bottom:env(safe-area-inset-bottom,0px);
}
.modal-hd{display:flex;align-items:center;padding:14px 16px 8px;font-size:15px;font-weight:600}
.modal-hd .x{margin-left:auto;border:0;background:none;font-size:18px;color:var(--muted);padding:2px 6px}
.modal-bd{padding:0 16px 6px;overflow-y:auto}
.modal-ft{padding:10px 16px 18px}
.toast{
  position:fixed;left:50%;bottom:calc(var(--tabbar-h) + 26px + env(safe-area-inset-bottom,0px));
  transform:translateX(-50%);z-index:70;background:rgba(32,48,46,.94);color:#fff;
  font-size:13.5px;padding:9px 16px;border-radius:999px;max-width:86vw;text-align:center;
}
