/* ---------- Top nav ---------- */
#tabbar{
  position:sticky; top:0; z-index:50;
  display:flex; width:100%;
  background:var(--nav-bg); backdrop-filter:blur(12px);
  border-bottom:1px solid var(--border);
  padding-top:env(safe-area-inset-top);
}
.tab{
  position:relative; flex:1 1 0; min-width:0;
  display:flex; flex-direction:column; align-items:center; gap:2px;
  background:none; border:none; color:var(--muted);
  padding:10px 4px 8px; font-weight:500;
  border-bottom:2px solid transparent;
  transition:color .15s ease, border-color .15s ease;
}
.tab .ico{font-size:17px; line-height:1}
.tab .lbl{font-size:11px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:100%}
/* The active tab paints itself with the current --accent (set per tab on activate),
   so any registered tab styles correctly with no per-tab CSS. */
.tab.active{color:var(--accent); border-color:var(--accent)}
.tab[data-tab="summary"].active{color:var(--text); border-color:var(--text)}
.tab:focus-visible{outline:2px solid var(--accent); outline-offset:-2px; border-radius:4px}

.count{
  position:absolute; top:5px; right:calc(50% - 22px);
  min-width:16px; height:16px; padding:0 4px;
  display:none; align-items:center; justify-content:center;
  font-size:10px; font-weight:600; line-height:1;
  background:var(--card); color:var(--muted);
  border:1px solid var(--border); border-radius:9px;
}
.count.show{display:flex}
.pulse-dot{
  position:absolute; top:6px; right:calc(50% - 24px);
  width:8px; height:8px; border-radius:50%; background:var(--red);
  display:none;
}
.pulse-dot.show{display:block; animation:pulse 1.6s ease-in-out infinite}

/* ---------- Hamburger (in tab bar) ---------- */
.tab-menu .ham{display:inline-flex; flex-direction:column; justify-content:center; gap:3px; width:18px; height:14px}
.tab-menu .ham i{display:block; height:2px; width:100%; background:currentColor; border-radius:2px; transition:transform .2s ease, opacity .2s ease}
.tab-menu.on{color:var(--text)}
.tab-menu.on .ham i:nth-child(1){transform:translateY(5px) rotate(45deg)}
.tab-menu.on .ham i:nth-child(2){opacity:0}
.tab-menu.on .ham i:nth-child(3){transform:translateY(-5px) rotate(-45deg)}

/* ---------- Slide-out drawer (all features in one place) ---------- */
.drawer{
  position:fixed; top:0; left:0; height:100%; width:264px; z-index:70;
  background:var(--surface); border-right:1px solid var(--border);
  transform:translateX(-100%); transition:transform .24s cubic-bezier(.2,.8,.2,1);
  display:flex; flex-direction:column; gap:1px; overflow-y:auto;
  padding:calc(env(safe-area-inset-top) + 10px) 10px 16px;
  box-shadow:4px 0 24px rgba(0,0,0,.35);
}
body.drawer-open .drawer{transform:none}
.drawer-scrim{position:fixed; inset:0; z-index:65; background:rgba(0,0,0,.5); opacity:0; visibility:hidden; transition:opacity .2s ease}
body.drawer-open .drawer-scrim{opacity:1; visibility:visible}
.drawer-head{display:flex; align-items:center; justify-content:space-between; padding:6px 10px 8px}
.drawer-title{font-weight:700; font-size:15px}
.drawer-ver{font-size:10px; font-weight:700; color:var(--muted); border:1px solid var(--border); border-radius:5px; padding:1px 5px}
.drawer-group{font-size:10.5px; text-transform:uppercase; letter-spacing:.05em; color:var(--muted); padding:12px 10px 4px}
.drawer-item{display:flex; align-items:center; gap:12px; width:100%; text-align:left; background:none; border:none; color:var(--text); padding:10px; border-radius:8px}
.drawer-item:hover{background:var(--card)}
.drawer-item.active{background:var(--card); color:var(--accent)}
.di-ico{font-size:18px; width:22px; text-align:center; flex-shrink:0}
.di-text{flex:1; min-width:0; display:flex; flex-direction:column}
.di-label{font-weight:600; font-size:14px}
.di-sub{font-size:11px; color:var(--muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.di-count{min-width:18px; height:18px; padding:0 5px; display:none; align-items:center; justify-content:center; font-size:10.5px; font-weight:700; background:var(--card); color:var(--muted); border:1px solid var(--border); border-radius:9px; flex-shrink:0}
.di-count.show{display:inline-flex}
.drawer-item.active .di-count{border-color:var(--accent); color:var(--accent)}

/* On wide screens the open drawer docks and pushes the app right (no scrim). */
@media (min-width:760px){
  body.drawer-open{padding-left:264px}
  body.drawer-open .drawer-scrim{display:none}
}

/* ---------- Layout ---------- */
#content{max-width:560px; margin:0 auto; padding:16px 14px 40px}
.panel{display:none}
.panel.active{display:block}
.panel-title{
  display:flex; align-items:center; justify-content:space-between;
  margin:0 0 12px; font-size:13px; font-weight:600; letter-spacing:.02em;
  color:var(--muted); text-transform:uppercase;
}

/* ---------- "More" overflow slide-over ---------- */
.more-sheet{
  position:fixed; inset:0; z-index:60; display:none;
}
.more-sheet.show{display:block}
.more-sheet .scrim{position:absolute; inset:0; background:rgba(0,0,0,.5); opacity:0; transition:opacity .2s ease}
.more-sheet.show .scrim{opacity:1}
.more-sheet .sheet{
  position:absolute; top:0; right:0; height:100%; width:min(300px,82vw);
  background:var(--surface); border-left:1px solid var(--border);
  padding:calc(env(safe-area-inset-top) + 16px) 14px 16px;
  transform:translateX(100%); transition:transform .24s cubic-bezier(.2,.8,.2,1);
  display:flex; flex-direction:column; gap:6px; overflow-y:auto;
}
.more-sheet.show .sheet{transform:none}
.more-sheet .sheet h3{margin:0 0 8px; font-size:13px; text-transform:uppercase; letter-spacing:.02em; color:var(--muted)}
.more-item{
  display:flex; align-items:center; gap:12px; text-align:left;
  background:var(--card); border:1px solid var(--border); color:var(--text);
  border-radius:var(--radius-card); padding:13px 14px; font-weight:600;
}
.more-item:hover{border-color:var(--muted)}
.more-item .ico{font-size:18px}
.more-item .sub{display:block; font-size:11.5px; font-weight:500; color:var(--muted); margin-top:1px}

/* ---------- App-wide reminder banner ---------- */
#bannerHost{position:sticky; top:0; z-index:40; display:flex; flex-direction:column; gap:6px}
#bannerHost:empty{display:none}
.alert-banner{
  display:flex; align-items:center; gap:10px;
  background:linear-gradient(180deg, rgba(245,158,11,.16), rgba(245,158,11,.06));
  border:1px solid rgba(245,158,11,.4); color:var(--text);
  border-radius:var(--radius-card); padding:10px 12px; margin:0 14px;
  font-size:13px; font-weight:500;
}
.alert-banner .ab-ico{font-size:16px}
.alert-banner .ab-msg{flex:1; min-width:0}
.alert-banner button{
  background:none; border:1px solid var(--border); color:var(--muted);
  border-radius:5px; padding:4px 8px; font-size:12px; font-weight:600;
}
.alert-banner button:hover{color:var(--text); border-color:var(--muted)}

/* ---------- Chart ---------- */
.chart-wrap{
  background:var(--surface); border:1px solid var(--border);
  border-radius:var(--radius-card); padding:12px; margin-bottom:16px;
}
.chart-box{height:180px; position:relative}
.chart-empty{height:180px; display:flex; align-items:center; justify-content:center; color:var(--muted); font-size:13px}

/* ---------- Sleep live timer ---------- */
.live{
  background:linear-gradient(180deg, rgba(129,140,248,.10), rgba(129,140,248,.03));
  border:1px solid rgba(129,140,248,.3); border-radius:var(--radius-card);
  padding:18px 16px; margin-bottom:16px; text-align:center; display:none;
}
.live.show{display:block}
.live .lt{font-size:13px; color:var(--indigo); font-weight:600}
.live .lv{font-size:30px; font-weight:700; margin:4px 0 12px; font-variant-numeric:tabular-nums}
.live .end{background:var(--indigo); color:#0a0a0a; border:none; border-radius:var(--radius-input); padding:9px 18px; font-weight:600}
.live .end:active{transform:translateY(1px)}

/* sleep timeline */
.timeline-wrap{
  background:var(--surface); border:1px solid var(--border);
  border-radius:var(--radius-card); padding:12px; margin-bottom:16px;
}
.timeline-wrap .tl-head{display:flex; justify-content:space-between; align-items:center; margin-bottom:8px}
.timeline-wrap .tl-head span{font-size:11px; color:var(--muted)}
#sleepCanvas{width:100%; height:64px; display:block}

/* ---------- Summary ---------- */
.grid-card{
  background:var(--surface); border:1px solid var(--border);
  border-radius:var(--radius-card); padding:14px; margin-bottom:16px;
}
.grid-card h3{margin:0 0 12px; font-size:13px; font-weight:600}
.hourgrid{display:grid; grid-template-columns:repeat(24,1fr); gap:3px}
.hg-legend{display:grid; grid-template-columns:repeat(24,1fr); gap:3px; margin-top:6px}
.hg-legend span{font-size:8.5px; color:var(--muted); text-align:center; white-space:nowrap}
.cell{
  aspect-ratio:1; background:var(--card); border:1px solid var(--border);
  border-radius:3px; position:relative; display:flex; align-items:center; justify-content:center;
  gap:2px; flex-wrap:wrap; padding:2px;
}
.cell.asleep{background:rgba(129,140,248,.32); border-color:rgba(129,140,248,.45)}
.cell .dot{width:5px; height:5px; border-radius:50%}
.cell .dot.feed{background:var(--teal)}
.cell .dot.diap{background:var(--amber)}
.legend-keys{display:flex; gap:14px; flex-wrap:wrap; margin-top:12px; font-size:11px; color:var(--muted)}
.legend-keys i{display:inline-block; width:9px; height:9px; border-radius:50%; margin-right:5px; vertical-align:-1px}

.scards{display:grid; grid-template-columns:1fr 1fr; gap:8px; margin-bottom:16px}
.scard{background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-card); padding:12px 13px}
.scard .k{font-size:11px; color:var(--muted)}
.scard .v{font-size:20px; font-weight:700; margin-top:3px; font-variant-numeric:tabular-nums}

/* ---------- Lactation (pump) stash ---------- */
.stash{
  background:linear-gradient(180deg, rgba(167,139,250,.12), rgba(167,139,250,.03));
  border:1px solid rgba(167,139,250,.3); border-radius:var(--radius-card);
  padding:16px; margin-bottom:16px; text-align:center;
}
.stash .st-k{font-size:12px; color:var(--purple); font-weight:600; letter-spacing:.02em}
.stash .st-v{font-size:30px; font-weight:700; margin:3px 0 8px; font-variant-numeric:tabular-nums}
.stash .st-v.low{color:var(--red)}
.stash .st-sub{font-size:12px; color:var(--muted)}
.stash .st-sub b{color:var(--text); font-weight:600}

/* ---------- Meds ---------- */
.weekdays{display:flex; gap:6px}
.weekdays .wd{
  flex:1; background:var(--card); border:1px solid var(--border); color:var(--muted);
  border-radius:6px; padding:8px 0; font-weight:600; font-size:13px;
}
.weekdays .wd.on{background:rgba(74,222,128,.16); border-color:rgba(74,222,128,.45); color:var(--green)}

.med-today{display:flex; flex-direction:column; gap:8px; margin-bottom:16px}
.dose-row{
  width:100%; text-align:left; background:var(--card); border:1px solid var(--border);
  border-radius:var(--radius-card); padding:13px 14px; display:flex; align-items:center; gap:12px;
  color:var(--text); transition:border-color .12s ease, background .12s ease;
}
.dose-row:hover{border-color:var(--muted)}
.dose-row.done{background:rgba(74,222,128,.08); border-color:rgba(74,222,128,.35)}
.dose-row .cbox{
  width:24px; height:24px; flex-shrink:0; border-radius:7px; border:2px solid var(--border);
  display:flex; align-items:center; justify-content:center; color:transparent;
}
.dose-row.done .cbox{background:var(--green); border-color:var(--green); color:#0a0a0a}
.dose-row .cbox svg{width:14px; height:14px; stroke:currentColor; fill:none; stroke-width:3; stroke-linecap:round; stroke-linejoin:round}
.dose-row .dn{flex:1; min-width:0}
.dose-row .dn .nm{font-weight:600}
.dose-row .dn .mt{font-size:12px; color:var(--muted); margin-top:2px}
.dose-row .st{font-size:11.5px; color:var(--muted); flex-shrink:0; text-align:right; max-width:42%}
.dose-row.done .st{color:var(--green)}

.cal-head{display:flex; align-items:center; justify-content:space-between; margin-bottom:10px}
.cal-head .cal-range{font-size:13px; font-weight:600}
.cal-nav{background:var(--card); border:1px solid var(--border); color:var(--text); width:30px; height:30px; border-radius:6px; font-size:16px; line-height:1}
.cal-nav:hover{border-color:var(--muted)}
.med-cal{display:flex; flex-direction:column; gap:4px}
.cal-row{display:grid; grid-template-columns:60px repeat(7,1fr); gap:4px; align-items:center}
.cal-row.head .cal-lbl{visibility:hidden}
.cal-lbl{font-size:11.5px; color:var(--muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; padding-right:2px}
.cal-dh{text-align:center; font-size:10px; color:var(--muted); line-height:1.25}
.cal-dh .dnum{display:block; font-size:12px; color:var(--text); font-weight:600}
.cal-dh.today .dnum{color:var(--green)}
.cal-cell{
  aspect-ratio:1; border-radius:5px; border:1px solid var(--border); background:var(--card);
  display:flex; align-items:center; justify-content:center; color:transparent; padding:0;
}
.cal-cell svg{width:13px; height:13px; stroke:currentColor; fill:none; stroke-width:3; stroke-linecap:round; stroke-linejoin:round}
.cal-cell.na{background:transparent; border-color:transparent}
.cal-cell.na::after{content:''; width:4px; height:4px; border-radius:50%; background:var(--border)}
.cal-cell.done{background:var(--green); border-color:var(--green); color:#0a0a0a}
.cal-cell.missed{background:rgba(248,113,113,.12); border-color:rgba(248,113,113,.4)}
.cal-cell.pending{border-color:var(--green); border-style:dashed}
.cal-cell.future{opacity:.45}
.cal-foot{display:flex; align-items:center; justify-content:space-between; margin-top:12px; gap:10px}
.muted-stat{font-size:12px; color:var(--muted); text-align:right}
.entry.paused{opacity:.6}

/* ---------- responsive ---------- */
@media (max-width:480px){
  .tab .lbl{font-size:0}
  .tab .lbl::first-letter{font-size:0}
  .tab .ico{font-size:19px}
  .count{right:calc(50% - 16px)}
  .pulse-dot{right:calc(50% - 18px)}
  .stat .v{font-size:15px}
}
