/* Bluestem Baby — mobile-first UI */

:root {
  --ink: #3b4a66;
  --muted: #8b95a7;
  --faint: #e6e9ef;
  --bg: #ffffff;
  --surface: #f5f6f8;
  --orange: #f4793b;
  --orange-soft: #fdece2;
  --teal: #29b2c5;
  --green: #93c94e;
  --green-dark: #7fb43c;
  --navy: #3b4a66;
  --red: #d94f4f;
  --radius: 16px;
  --nav-h: 64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 17px;
  line-height: 1.35;
}

.app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100%;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 12px);
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--ink); }
a { color: var(--teal); text-decoration: none; }
[hidden] { display: none !important; }

h1 { font-size: 22px; font-weight: 700; }
.muted { color: var(--muted); }

/* ---------- top bars ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px;
  padding-top: calc(14px + env(safe-area-inset-top));
}
.topbar .title { font-size: 20px; font-weight: 700; flex: 1; text-align: center; }
.topbar .side { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; }
.iconbtn {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink); font-size: 24px; line-height: 1;
}
.iconbtn:active { background: var(--surface); }

.who { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--teal); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px;
}
.who .name { font-weight: 700; font-size: 19px; }

/* ---------- cards / home ---------- */
.pad { padding: 0 16px; }

.hero {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  margin: 6px 16px 14px;
  display: flex; align-items: center; gap: 12px;
}
.hero .big { font-size: 19px; font-weight: 700; }

.cardgrid { display: grid; grid-template-columns: 3fr 2fr; gap: 12px; margin: 0 16px 12px; }

.card {
  border-radius: var(--radius);
  padding: 16px;
  color: #fff;
  position: relative;
  overflow: hidden;
  text-align: left;
  min-height: 108px;
  display: block;
  width: 100%;
}
.card .cardtitle { font-size: 21px; font-weight: 700; }
.card .cardsub { margin-top: 6px; font-size: 15px; opacity: .95; }
.card.orange { background: var(--orange); }
.card.teal { background: var(--teal); }
.card.navy { background: var(--navy); }
.card.wide { grid-column: 1 / -1; min-height: 84px; }

.livechip {
  position: absolute; top: 12px; right: 12px;
  background: #fff; color: var(--orange);
  font-weight: 700; font-size: 14px;
  border-radius: 999px; padding: 4px 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
}
.livechip .dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--orange); margin-right: 5px;
  animation: pulse 1.2s infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

.card .glyph { position: absolute; right: -6px; bottom: -10px; opacity: .18; width: 84px; height: 84px; }

.sectionhead { margin: 18px 16px 8px; font-size: 15px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* ---------- list rows ---------- */
.rows { margin: 0 16px; border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 14px;
  width: 100%; text-align: left;
  border-bottom: 1px solid var(--faint);
  background: transparent;
}
.row:last-child { border-bottom: 0; }
.row .rowicon {
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex: none; color: #fff;
}
.row .rowicon.nurse { background: var(--orange); }
.row .rowicon.bottle { background: var(--teal); }
.row .rowmain { flex: 1; min-width: 0; }
.row .rowtitle { font-weight: 600; }
.row .rowsub { font-size: 14px; color: var(--muted); margin-top: 1px; }
.row .rowtime { font-size: 14px; color: var(--muted); flex: none; }
.empty { text-align: center; color: var(--muted); padding: 28px 16px; }

/* ---------- segmented control ---------- */
.seg {
  display: flex; margin: 8px 16px 4px;
  border: 1px solid var(--faint); border-radius: 12px; overflow: hidden;
  background: #fff;
}
.seg button {
  flex: 1; padding: 12px 8px; font-weight: 600; color: var(--ink);
  border-right: 1px solid var(--faint);
}
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--green); color: #fff; }
.seg.mini { margin: 0; }
.seg.mini button { padding: 9px 14px; }
.seg.mini button.on { background: var(--teal); }

/* ---------- form rows ---------- */
.formrow {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px; margin: 0 0;
  border-bottom: 1px solid var(--faint);
}
.formrow .label { font-size: 18px; color: var(--ink); }
.formrow .value { color: var(--ink); font-size: 18px; }
.formrow .value.link { color: var(--ink); border-bottom: 2px solid var(--teal); padding-bottom: 1px; font-weight: 500; }
.formrow input[type="number"] {
  width: 64px; padding: 8px; text-align: center;
  border: 1px solid var(--faint); border-radius: 10px; background: #fff;
  font-size: 17px;
}
.formrow input[type="text"] {
  flex: 1; padding: 10px; border: 1px solid var(--faint); border-radius: 10px;
}
.notewrap { padding: 8px 16px 16px; border-bottom: 1px solid var(--faint); }
.notewrap textarea {
  width: 100%; min-height: 64px; border: 0; background: transparent; resize: vertical;
  outline: none; text-align: right; color: var(--ink);
}
.notewrap textarea::placeholder { color: #b9c0cc; font-size: 17px; }

/* Tappable start-time field: a native datetime-local input sits transparently
   over the label so a tap opens the OS picker directly (reliable on iOS). */
.timefield { position: relative; display: inline-block; }
.timefield .tf-input {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; border: 0; margin: 0; padding: 0;
  -webkit-appearance: none; appearance: none; background: transparent;
  font-size: 16px; /* keep iOS from zooming on focus */
}
.addmanual {
  display: block; width: calc(100% - 32px); margin: 4px 16px 6px;
  text-align: center; color: var(--teal); font-weight: 700; font-size: 17px;
  padding: 14px; border: 1.5px dashed var(--faint); border-radius: var(--radius);
}
.addmanual:active { background: var(--surface); }

/* ---------- timer ---------- */
.timerwrap { padding: 8px 16px; text-align: center; }
.digits {
  display: flex; justify-content: center; gap: 6px;
  font-variant-numeric: tabular-nums;
  margin: 34px 0 40px;
}
.digits .unit { display: flex; flex-direction: column; align-items: center; }
.digits .num { font-size: 64px; font-weight: 600; letter-spacing: 1px; }
.digits .colon { font-size: 56px; font-weight: 500; color: var(--ink); padding-top: 2px; }
.digits .cap { font-size: 13px; letter-spacing: .12em; color: var(--muted); font-weight: 600; margin-top: 2px; }

.sides { display: flex; justify-content: space-around; align-items: flex-start; margin: 8px 0 26px; }
.sidebtn { position: relative; width: 148px; }
.sidecircle {
  width: 140px; height: 140px; margin: 0 auto;
  border-radius: 50%;
  background: var(--orange);
  color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  box-shadow: 0 0 0 5px #fff, 0 0 0 7px #f8c9ac;
  transition: transform .1s;
}
.sidebtn:active .sidecircle { transform: scale(.96); }
.sidebtn.running .sidecircle { box-shadow: 0 0 0 5px #fff, 0 0 0 7px var(--orange); }
.sidecircle svg { width: 34px; height: 34px; }
.sidecircle .stime { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.sidelabel { margin-top: 10px; font-weight: 700; color: var(--muted); letter-spacing: .06em; font-size: 14px; }
.lastbadge {
  position: absolute; top: -8px; right: -2px;
  background: var(--navy); color: #fff;
  border-radius: 50%;
  width: 56px; height: 56px;
  font-size: 13px; font-weight: 600; line-height: 1.15;
  display: flex; align-items: center; justify-content: center; text-align: center;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
  z-index: 2;
}

.timerlinks { display: flex; justify-content: space-around; margin: 26px 0 10px; }
.timerlinks button { color: var(--teal); font-weight: 700; font-size: 19px; display: flex; align-items: center; gap: 8px; }

/* ---------- buttons ---------- */
.savebar {
  position: sticky; bottom: calc(env(safe-area-inset-bottom) + 10px);
  padding: 10px 16px 0;
  background: linear-gradient(transparent, var(--bg) 40%);
}
.btn-primary {
  display: block; width: 100%;
  background: var(--green); color: #fff;
  font-size: 21px; font-weight: 700;
  border-radius: 999px; padding: 17px;
}
.btn-primary:active { background: var(--green-dark); }
.btn-primary:disabled { opacity: .5; }
.btn-danger {
  display: block; width: 100%; text-align: center;
  color: var(--red); font-weight: 600; font-size: 17px;
  padding: 14px; margin-top: 4px;
}

/* ---------- login ---------- */
.login {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; padding: 24px;
}
.login img { width: 88px; height: 88px; border-radius: 22px; margin-bottom: 6px; }
.login h1 { font-size: 26px; }
.login .sub { color: var(--muted); margin-bottom: 18px; }
.login form { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 12px; }
.login input {
  padding: 14px 16px; border: 1.5px solid var(--faint); border-radius: 14px;
  background: var(--surface); font-size: 17px; outline: none;
}
.login input:focus { border-color: var(--teal); background: #fff; }
.login .err { color: var(--red); font-size: 15px; min-height: 20px; text-align: center; }

/* ---------- reports ---------- */
.tabs { display: flex; gap: 0; margin: 4px 16px 10px; border: 1px solid var(--faint); border-radius: 12px; overflow: hidden; }
.tabs button { flex: 1; padding: 11px 4px; font-weight: 600; color: var(--ink); border-right: 1px solid var(--faint); }
.tabs button:last-child { border-right: 0; }
.tabs button.on { background: var(--green); color: #fff; }

.weekstrip { display: flex; align-items: center; padding: 4px 10px 10px; gap: 2px; }
.weekstrip .month { width: 52px; font-weight: 700; font-size: 15px; line-height: 1.2; flex: none; }
.weekstrip .days { flex: 1; display: flex; justify-content: space-between; }
.weekstrip .day { width: 40px; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 0; border-radius: 12px; }
.weekstrip .dow { font-size: 12px; color: var(--muted); font-weight: 600; }
.weekstrip .dnum {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 600; color: var(--ink);
}
.weekstrip .day.sel .dnum { background: #c9ecf3; color: var(--teal); }
.weekstrip .day.future { opacity: .35; }
.weekstrip .arrow { width: 34px; height: 44px; color: var(--muted); font-size: 22px; flex: none; }

.statcard { margin: 0 16px 12px; border-left: 5px solid var(--orange); background: #fff; border-radius: 6px; box-shadow: 0 1px 6px rgba(59,74,102,.10); }
.statline { display: flex; justify-content: space-between; align-items: center; padding: 13px 16px; border-bottom: 1px solid var(--faint); }
.statline:last-child { border-bottom: 0; }
.statline .k { display: flex; align-items: center; gap: 10px; font-size: 18px; }
.statline .v { font-size: 19px; font-weight: 600; }

.daylabel { padding: 12px 16px; font-weight: 700; font-size: 18px; background: var(--surface); }

.timeline { position: relative; margin: 0 0 20px; }
.tl-hour { position: absolute; left: 0; right: 0; border-top: 1px solid var(--faint); }
.tl-hour .hlabel { position: absolute; top: -9px; left: 14px; font-size: 14px; color: var(--muted); background: var(--bg); padding-right: 6px; }
.tl-block {
  position: absolute; left: 72px; right: 10px;
  background: var(--orange); color: #fff;
  border-radius: 5px;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 3px 10px;
  font-size: 15px; font-weight: 600;
  min-height: 22px;
  overflow: hidden;
  border: 1px solid #fff;
}
.tl-block.bottle { background: var(--teal); }
.tl-now { position: absolute; left: 64px; right: 0; border-top: 2px solid var(--green); }
.tl-now::before { content: ''; position: absolute; left: -8px; top: -6px; width: 10px; height: 10px; border-radius: 50%; background: var(--green); }

/* week chart */
.chart { margin: 6px 16px 4px; padding: 12px 8px 0; }
.chart .bars { display: flex; align-items: flex-end; gap: 8px; height: 160px; }
.chart .barcol { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.chart .barval { font-size: 12px; color: var(--muted); font-weight: 600; min-height: 15px; }
.chart .bar { width: 100%; max-width: 34px; background: var(--orange); border-radius: 4px 4px 0 0; min-height: 2px; }
.chart .bar.zero { background: var(--faint); }
.chart .xlabels { display: flex; gap: 8px; margin-top: 6px; border-top: 1px solid var(--faint); padding-top: 6px; }
.chart .xlabels span { flex: 1; text-align: center; font-size: 12px; color: var(--muted); font-weight: 600; }
.chart .xlabels span.today { color: var(--teal); }

/* ---------- settings ---------- */
.settingsgroup { margin: 0 16px 20px; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.settingsgroup .formrow { border-bottom-color: #e9ecf1; }
.settingsgroup .formrow:last-child { border-bottom: 0; }

/* ---------- bottom nav ---------- */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: #fff;
  border-top: 1px solid var(--faint);
  display: flex;
  max-width: 520px; margin: 0 auto;
  z-index: 10;
}
.bottomnav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--muted); font-size: 12px; font-weight: 600;
}
.bottomnav a svg { width: 26px; height: 26px; }
.bottomnav a.on { color: var(--green-dark); }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 18px);
  left: 50%; transform: translateX(-50%);
  background: var(--navy); color: #fff;
  border-radius: 999px; padding: 10px 20px;
  font-size: 15px; font-weight: 600;
  box-shadow: 0 4px 14px rgba(0,0,0,.25);
  z-index: 50;
  max-width: 90vw; text-align: center;
}

@media (min-width: 521px) {
  .bottomnav { border-left: 1px solid var(--faint); border-right: 1px solid var(--faint); }
}
