/* Baby Log — mobile-first, sage green with warm beige accents */

:root {
  /* Sage palette, lightest to darkest. Text sits dark on the three light greens
     and white on moss and evergreen, which keeps every label readable. */
  --sage-hint: #D8E2D5;
  --mint:      #BFCFBB;
  --sage:      #8EA58C;
  --moss:      #738A6E;
  --evergreen: #344C3D;

  /* Warm tones, for what is not breastfeeding: bottles, solids, nappies.
     Clay and sage are nearly equal in lightness, so they never share a chart. */
  --sand:      #EFE6D8;
  --clay:      #C9A992;

  --bg:        #F5F2EA;
  --card:      #FFFFFF;
  --ink:       #24312A;
  --ink-soft:  #5C6B5F;
  --line:      #E4E2D6;
  --radius:    16px;
  --shadow:    0 1px 2px rgba(52, 76, 61, .08), 0 6px 18px rgba(52, 76, 61, .07);
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  padding: 0 0 var(--safe-bottom);
}
body.has-nav { padding-bottom: calc(76px + var(--safe-bottom)); }

img { max-width: 100%; }
[hidden] { display: none !important; }
a { color: var(--evergreen); }

/* ------------------------------------------------------------------ chrome */

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--evergreen); color: #F2F6F0;
  padding: calc(14px + var(--safe-top)) 18px 16px;
  border-radius: 0 0 22px 22px;
}
.topbar h1 { margin: 0; font-size: 20px; font-weight: 650; letter-spacing: .2px; }
.topbar .sub { margin: 3px 0 0; font-size: 13px; color: var(--mint); }
.icon-link {
  color: #E7E8DF; text-decoration: none; font-size: 22px; line-height: 1;
  width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 50%; background: rgba(255,255,255,.1);
}

.wrap { padding: 16px; max-width: 760px; margin: 0 auto; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: #FDFCF8EE; backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bottom);
}
.tabbar a {
  flex: 1; text-align: center; padding: 10px 4px 12px; text-decoration: none;
  color: var(--ink-soft); font-size: 11px; letter-spacing: .3px; text-transform: uppercase;
  display: flex; flex-direction: column; gap: 3px; align-items: center;
}
.tabbar a .ico { font-size: 17px; line-height: 1; }
.tabbar a.on { color: var(--evergreen); font-weight: 700; }

.flash {
  position: fixed; top: calc(10px + var(--safe-top)); left: 12px; right: 12px; z-index: 50;
  background: var(--evergreen); color: #fff; padding: 12px 16px; border-radius: 12px;
  box-shadow: var(--shadow); font-size: 14px; animation: fade 4s forwards;
}
@keyframes fade { 0%,80% { opacity: 1 } 100% { opacity: 0; visibility: hidden } }

/* ------------------------------------------------------------------- cards */

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin: 0 0 14px;
}
.card h2 {
  margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--ink-soft); font-weight: 700;
}
.card.timer { background: linear-gradient(145deg, var(--moss), var(--evergreen)); color: #fff; text-align: center; }
.card.timer h2 { color: rgba(255,255,255,.75); }
.clock { font-size: 46px; font-weight: 300; font-variant-numeric: tabular-nums; letter-spacing: 1px; margin: 4px 0 2px; }
.card.timer .meta { color: rgba(255,255,255,.8); font-size: 13px; margin-bottom: 14px; }

/* ------------------------------------------------------------------ inputs */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 12px; padding: 14px 16px; font-size: 15px; font-weight: 600;
  background: var(--sage); color: var(--ink); text-decoration: none; cursor: pointer;
  font-family: inherit; min-height: 48px; width: 100%;
}
.btn:active { transform: scale(.985); }
.btn.dark    { background: var(--evergreen); color: #F2F6F0; }
.btn.moss    { background: var(--moss); color: #F2F6F0; }
.btn.mint    { background: var(--mint); color: var(--ink); }
.btn.hint    { background: var(--sage-hint); color: var(--ink); }
.btn.sand    { background: var(--sand); color: var(--ink); }
.btn.clay    { background: var(--clay); color: var(--ink); }
.btn.light   { background: var(--mint); color: var(--evergreen); }
.btn.ghost   { background: transparent; color: var(--ink-soft); border: 1px solid var(--line); }
.btn.white   { background: #fff; color: var(--evergreen); }
.btn.danger  { background: #fff; color: #8F4636; border: 1px solid #E3CCC5; }
.btn.sm      { padding: 9px 12px; font-size: 13px; min-height: 38px; width: auto; border-radius: 10px; }

.grid   { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; gap: 10px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid form, .grid-3 form { display: flex; }
.grid .btn, .grid-3 .btn {
  flex-direction: column; gap: 2px; padding: 13px 6px; height: 100%;
  overflow-wrap: anywhere;   /* long labels wrap instead of stretching their column */
}
.grid .btn small, .grid-3 .btn small { font-weight: 500; opacity: .85; font-size: 11px; }

label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin: 0 0 5px; }
.field { margin-bottom: 12px; }
input[type=text], input[type=password], input[type=number],
input[type=datetime-local], input[type=date], select, textarea {
  width: 100%; padding: 12px; font-size: 16px; font-family: inherit; color: var(--ink);
  border: 1px solid var(--line); border-radius: 11px; background: #FCFCF8; min-height: 48px;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--moss); outline-offset: 1px; border-color: transparent; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

details.adder { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 14px; }
details.adder > summary {
  list-style: none; cursor: pointer; padding: 15px 16px; font-weight: 650; font-size: 14px; color: var(--evergreen);
}
details.adder > summary::-webkit-details-marker { display: none; }
details.adder > summary::after { content: '+'; float: right; font-size: 20px; line-height: 1; color: var(--moss); }
details.adder[open] > summary::after { content: '–'; }
details.adder .body { padding: 0 16px 16px; }

/* ------------------------------------------------------------------- lists */

.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 0; border-top: 1px solid var(--line);
}
.list li:first-child { border-top: 0; }
.dot {
  width: 38px; height: 38px; border-radius: 12px; flex: 0 0 38px;
  display: grid; place-items: center; font-size: 15px; background: var(--mint); color: var(--evergreen);
}
.dot.feed   { background: var(--mint); }
.dot.bottle { background: var(--sand); }
.dot.pee    { background: var(--mint); }
.dot.poo    { background: var(--clay); }
.li-main   { flex: 1; min-width: 0; }
.li-title  { font-weight: 600; font-size: 15px; }
.li-sub    { font-size: 12.5px; color: var(--ink-soft); }
.li-side   { text-align: right; font-size: 12.5px; color: var(--ink-soft); white-space: nowrap; }
.li-side b { display: block; font-size: 15px; color: var(--ink); font-weight: 600; }

.day-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin: 18px 2px 8px; font-size: 13px; font-weight: 700; color: var(--evergreen);
  text-transform: uppercase; letter-spacing: .06em;
}
.day-head span { font-weight: 500; color: var(--ink-soft); text-transform: none; letter-spacing: 0; }
.empty { text-align: center; color: var(--ink-soft); padding: 26px 10px; font-size: 14px; }

/* ------------------------------------------------------------------- stats */

.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.tile {
  background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow);
  border-left: 4px solid var(--sage);
}
.tile.b { border-left-color: var(--clay); }
.tile.c { border-left-color: var(--mint); }
.tile.d { border-left-color: var(--evergreen); }
.tile .k { font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-soft); font-weight: 600; }
.tile .v { font-size: 25px; font-weight: 650; line-height: 1.15; margin-top: 3px; font-variant-numeric: tabular-nums; }
.tile .u { font-size: 12px; color: var(--ink-soft); }

.segmented { display: flex; gap: 6px; background: #E7E5DA; padding: 4px; border-radius: 12px; margin-bottom: 14px; }
.segmented a {
  flex: 1; text-align: center; padding: 9px 4px; border-radius: 9px; text-decoration: none;
  font-size: 13px; font-weight: 600; color: var(--ink-soft);
}
.segmented a.on { background: #fff; color: var(--evergreen); box-shadow: var(--shadow); }

/* Bar charts: a y axis with gridlines, so bar heights can be read as numbers. */
.chart { display: flex; align-items: flex-start; gap: 7px; margin: 10px 0 2px; }
.chart .y {
  position: relative; flex: 0 0 auto; min-width: 20px; height: 140px;
  font-size: 9.5px; color: var(--ink-soft); font-variant-numeric: tabular-nums;
}
.chart .y span { position: absolute; right: 0; transform: translateY(50%); line-height: 1; white-space: nowrap; }
.chart .plot { flex: 1; min-width: 0; }
.chart .area { position: relative; height: 140px; }
.chart .area > i { position: absolute; left: 0; right: 0; height: 1px; background: var(--line); }
.chart .area > i:first-child { background: #C9D5C4; }
.chart .cols,
.chart .xlabels { display: flex; gap: var(--gap, 4px); }
.chart .cols { position: absolute; inset: 0; align-items: flex-end; }
.chart .col { flex: 1; min-width: 0; height: 100%; display: flex; align-items: flex-end; gap: 2px; }
.chart .stack { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; }
.chart .stack.stacked { gap: 1px; }
.chart .stack.stacked .bar { border-radius: 0; }
.chart .stack.stacked .bar:first-of-type { border-radius: 4px 4px 0 0; }
.chart .bar { background: var(--sage); border-radius: 4px 4px 0 0; }
.chart .bar.alt  { background: var(--moss); }
.chart .bar.dark { background: var(--evergreen); }
.chart .bar.clay { background: var(--clay); }
.chart .bar.mint { background: var(--mint); }
.chart .val { font-size: 9.5px; text-align: center; color: var(--ink-soft); font-variant-numeric: tabular-nums; line-height: 1; margin-bottom: 2px; }
.chart .lab { flex: 1; min-width: 0; font-size: 9.5px; text-align: center; color: var(--ink-soft); padding-top: 5px; }

.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-soft); margin-top: 10px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 5px; background: var(--sage); }
.legend i.alt  { background: var(--moss); }
.legend i.dark { background: var(--evergreen); }
.legend i.clay { background: var(--clay); }
.legend i.mint { background: var(--mint); }

/* Medicine banner: loud enough to catch the eye, quiet enough to live above
   the timer card without shouting. */
.banner {
  display: flex; align-items: center; gap: 12px;
  background: var(--clay); color: #34210F;
  border-radius: var(--radius); padding: 13px 15px; margin: 0 0 12px;
  box-shadow: var(--shadow);
}
.banner.now { background: var(--evergreen); color: #F2F6F0; }
.banner-main  { flex: 1; min-width: 0; }
.banner-title { font-weight: 650; font-size: 15px; }
.banner-sub   { font-size: 12.5px; opacity: .85; margin-top: 2px; }
.banner .btn  { width: auto; white-space: nowrap; }

.card.countdown { background: linear-gradient(145deg, var(--sage), var(--moss)); color: #fff; text-align: center; }
.card.countdown h2 { color: rgba(255,255,255,.75); }
.card.countdown .clock.done { font-size: 30px; font-weight: 600; }

.balance { display: flex; height: 10px; border-radius: 5px; overflow: hidden; margin-top: 16px; background: var(--line); }
.balance .seg.l { background: var(--moss); }
.balance .seg.r { background: var(--mint); }

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { padding: 9px 6px; text-align: right; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.table th { color: var(--ink-soft); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; border-top: 0; }
.table td:first-child, .table th:first-child { text-align: left; }
.scroll-x { overflow-x: auto; }

.hint { font-size: 12.5px; color: var(--ink-soft); margin: 8px 2px 0; }

/* -------------------------------------------------------------- auth pages */

.auth { min-height: 100svh; display: flex; align-items: center; justify-content: center; padding: 24px 18px; }
.auth .box { width: 100%; max-width: 380px; }
.auth .logo { text-align: center; margin-bottom: 22px; }
.auth .logo .mark { font-size: 40px; }
.auth .logo h1 { margin: 6px 0 2px; font-size: 24px; color: var(--evergreen); }
.auth .logo p { margin: 0; color: var(--ink-soft); font-size: 14px; }
.err { background: #F2E4DF; color: #8F4636; padding: 11px 14px; border-radius: 11px; font-size: 14px; margin-bottom: 14px; }

@media (min-width: 620px) {
  .tiles { grid-template-columns: repeat(4, 1fr); }
  .grid  { grid-template-columns: repeat(4, 1fr); }
}
