/* Baby log — built for 4am: dim, warm, huge targets, nothing to read twice. */
:root {
  --bg: #0b0c0e;
  --tile: #17191d;
  --tile-press: #23262c;
  --line: #2a2d33;
  --text: #e6dccd;          /* warm off-white, easier on night eyes than pure white */
  --dim: #8d857a;
  --accent: #d99a4e;        /* amber */
  --accent-bg: #2b2117;
  --rec: #c4453b;
  --gap: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none; -webkit-user-select: none; user-select: none; }
button { font: inherit; color: inherit; }

#app {
  height: 100dvh;
  display: flex; flex-direction: column; gap: var(--gap);
  padding: calc(var(--gap) + var(--safe-top)) var(--gap) calc(var(--gap) + var(--safe-bot));
}

/* ── wide bars (Audio on top, Home at the bottom of history) ── */
.bar {
  flex: 0 0 auto; min-height: 16dvh; width: 100%;
  border: 2px solid var(--line); border-radius: 22px; background: var(--tile);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; padding: 10px 14px; cursor: pointer;
}
.bar:active { background: var(--tile-press); }
.bar-label { font-size: 34px; font-weight: 650; letter-spacing: .5px; }
.bar-sub { font-size: 15px; color: var(--dim); text-align: center; line-height: 1.3;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.audio.busy .bar-sub { color: var(--accent); }
.bar.back { min-height: 11dvh; }
.bar.back .bar-label { font-size: 26px; color: var(--dim); }

/* ── screens ── */
.screen { display: none; flex: 1 1 auto; min-height: 0; }
#app[data-screen="home"]      .screen[data-screen="home"],
#app[data-screen="diaper"]    .screen[data-screen="diaper"],
#app[data-screen="feed"]      .screen[data-screen="feed"],
#app[data-screen="feeding"]   .screen[data-screen="feeding"],
#app[data-screen="bottle"]    .screen[data-screen="bottle"],
#app[data-screen="sleep"]     .screen[data-screen="sleep"],
#app[data-screen="history"]   .screen[data-screen="history"],
#app[data-screen="recording"] .screen[data-screen="recording"] { display: grid; }
#app[data-screen="history"] .screen[data-screen="history"] { display: flex; }
#app[data-screen="recording"] #audioBar { display: none; }

.grid { grid-template-columns: 1fr 1fr; grid-auto-rows: 1fr; gap: var(--gap); }

/* ── square tiles ── */
.tile {
  border: 2px solid var(--line); border-radius: 22px; background: var(--tile);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 10px; min-height: 0; cursor: pointer; position: relative;
  transition: background .08s, transform .08s;
}
.tile:active { background: var(--tile-press); transform: scale(.97); }
.tile b { font-size: clamp(34px, 11vw, 64px); font-weight: 650; line-height: 1; }
.grid:not(.six) .tile b:only-child { font-size: clamp(30px, 9vw, 52px); }
.screen[data-screen="home"] .tile b { font-size: clamp(56px, 20vw, 110px); font-weight: 600; }
.tile .name { font-size: 17px; color: var(--dim); }
.tile .sub { font-size: 15px; color: var(--dim); text-align: center; line-height: 1.25;
  min-height: 1.25em; }
.tile.wide { grid-column: 1 / -1; }
.tile.back b { color: var(--dim); font-size: 40px; }
.tile.back { border-style: dashed; }

/* highlighted = "this is probably what you want" (next side, running feed...) */
.tile.accent, .tile.suggest { border-color: var(--accent); background: var(--accent-bg); }
.tile.accent .sub, .tile.suggest .sub, .tile.live .sub { color: var(--accent); }
.tile.live { border-color: var(--accent); }

/* ── recording ── */
.rec { grid-template-columns: 1fr; grid-template-rows: 1fr auto; gap: var(--gap); }
.rec-tile { background: #2a1210; border-color: var(--rec); animation: pulse 1.6s ease-in-out infinite; }
.rec-tile b { font-size: 72px; font-variant-numeric: tabular-nums; }
.rec-tile .name { color: #e8b2aa; font-size: 20px; }
.rec-cancel { min-height: 13dvh; }
.rec-cancel b { font-size: 28px; color: var(--dim); }
@keyframes pulse { 50% { background: #3a1714; } }

/* ── history ── */
.history { flex-direction: column; gap: var(--gap); min-height: 0; }
#historyList { flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch;
  border-radius: 18px; user-select: text; -webkit-user-select: text; }
.day { margin-bottom: 18px; }
.day-head { position: sticky; top: 0; background: var(--bg); padding: 4px 4px 8px; z-index: 1; }
.day-title { font-size: 20px; font-weight: 650; }
.day-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 8px; }
.stat { background: var(--tile); border: 1px solid var(--line); border-radius: 12px;
  padding: 8px 4px; text-align: center; }
.stat b { display: block; font-size: 22px; }
.stat span { font-size: 12px; color: var(--dim); }
.entry { display: grid; grid-template-columns: 70px 34px 1fr; align-items: center; gap: 8px;
  width: 100%; text-align: left; background: var(--tile); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px 10px; margin-top: 6px; cursor: pointer; }
.entry:active { background: var(--tile-press); }
.entry .t { font-variant-numeric: tabular-nums; color: var(--dim); font-size: 15px; }
.entry .k { font-weight: 700; font-size: 20px; text-align: center; color: var(--accent); }
.entry .w { font-size: 17px; }
.entry .m { display: block; font-size: 13px; color: var(--dim); margin-top: 2px; }
.entry.running { border-color: var(--accent); }
.memo { background: transparent; border-style: dashed; cursor: default; }
.memo .w { font-size: 15px; }
.memo .q { display: block; color: var(--dim); font-style: italic; margin-top: 4px; }
.memo-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.memo-actions button, .memo-actions audio { font-size: 14px; }
.history-foot { display: flex; gap: var(--gap); }
.small-btn { flex: 1; text-align: center; padding: 14px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--tile); color: var(--text);
  text-decoration: none; font-size: 16px; cursor: pointer; }
.empty { color: var(--dim); text-align: center; padding: 40px 10px; }

/* ── edit sheet ── */
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.65); display: flex;
  align-items: flex-end; z-index: 10; }
.sheet[hidden] { display: none; }
.sheet-card { width: 100%; background: var(--bg); border-top: 2px solid var(--line);
  border-radius: 24px 24px 0 0; padding: 18px var(--gap) calc(var(--gap) + var(--safe-bot));
  max-height: 92dvh; overflow-y: auto; }
.sheet-card h2 { margin: 0 0 12px; font-size: 22px; }
.field { margin-bottom: 14px; }
.field label { display: block; color: var(--dim); font-size: 14px; margin-bottom: 6px; }
.field input[type="datetime-local"], .field input[type="number"], .field textarea {
  width: 100%; font: inherit; font-size: 18px; color: var(--text); background: var(--tile);
  border: 2px solid var(--line); border-radius: 14px; padding: 12px; }
.field textarea { min-height: 90px; resize: vertical; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); gap: 8px; }
.choice { padding: 14px 6px; border-radius: 14px; border: 2px solid var(--line);
  background: var(--tile); font-size: 17px; cursor: pointer; }
.choice.on { border-color: var(--accent); background: var(--accent-bg); color: var(--accent); }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); margin-top: 8px; }
.sheet-actions .tile { min-height: 70px; }
.sheet-actions .tile b { font-size: 22px; }
#sheetDelete b { color: #d9776d; }
.clear-end { margin-top: 6px; background: none; border: none; color: var(--dim);
  text-decoration: underline; font-size: 14px; padding: 4px 0; cursor: pointer; }

/* ── toast ── */
.toast { position: fixed; left: var(--gap); right: var(--gap);
  bottom: calc(var(--gap) + var(--safe-bot)); z-index: 20;
  background: #24272d; border: 1px solid var(--line); border-radius: 18px;
  padding: 16px 18px; display: flex; align-items: center; gap: 12px;
  font-size: 18px; box-shadow: 0 10px 30px rgba(0,0,0,.6); }
.toast[hidden] { display: none; }
.toast span { flex: 1; }
.toast button { background: var(--accent-bg); color: var(--accent); border: 1px solid var(--accent);
  border-radius: 12px; padding: 10px 18px; font-size: 18px; font-weight: 650; cursor: pointer; }
