/* Juno: feeds and sleep. Built for one-handed use at night. */

:root {
  --bg: #1c2132;
  --panel: #262c41;
  --panel-2: #303752;
  --line: #3c4463;
  --text: #eef0f6;
  --muted: #9ba3bd;
  --sleep: #9fb9e3;
  --sleep-ink: #172238;
  --feed: #f0a23c;
  --feed-ink: #37230a;
  --today: #4a6da3;
  --danger: #f09a90;
  --night: rgba(255, 255, 255, 0.05);
  --hour: 24px;
  --serif: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 var(--sans);
  font-variant-numeric: tabular-nums;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

h1, h2, p, ul, dl, dd, fieldset, legend { margin: 0; padding: 0; }
ul { list-style: none; }
fieldset { border: 0; min-width: 0; }

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; text-align: inherit; }
button:disabled { opacity: 0.45; cursor: default; }

:focus-visible { outline: 2px solid var(--sleep); outline-offset: 2px; }

.boot { padding: 30vh 24px 0; text-align: center; color: var(--muted); }

/* ---------- Shell ---------- */

.shell {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 16px calc(env(safe-area-inset-bottom, 0px) + 84px);
}

.top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 4px 2px 16px; }
.top h1 { font: 400 34px/1.05 var(--serif); letter-spacing: 0.01em; }
.top p { color: var(--muted); font-size: 14px; text-align: right; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; justify-content: center;
  background: rgba(28, 33, 50, 0.94);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tabs button {
  flex: 1; max-width: 173px; min-height: 58px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: 12px;
}
.tabs svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tabs button[aria-current="page"] { color: var(--sleep); }

.notice { background: var(--panel); border-left: 3px solid var(--danger); border-radius: 6px; padding: 10px 12px; margin-bottom: 14px; font-size: 14px; }
.notice button { color: var(--sleep); text-decoration: underline; margin-left: 6px; }

/* ---------- Activity ---------- */

.log-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.log {
  min-height: 104px; border-radius: 18px; padding: 16px;
  display: flex; flex-direction: column; justify-content: space-between;
  background: var(--panel); border: 1px solid var(--line);
}
.log-title { font-size: 20px; font-weight: 600; }
.log-sub { font-size: 13px; color: var(--muted); }
.log.feed { border-color: rgba(240, 162, 60, 0.55); }
.log.feed .log-title { color: var(--feed); }
.log.sleep { border-color: rgba(159, 185, 227, 0.55); }
.log.sleep .log-title { color: var(--sleep); }
.log.sleep.on { background: var(--sleep); border-color: var(--sleep); }
.log.sleep.on .log-title, .log.sleep.on .log-sub { color: var(--sleep-ink); }
.log:active { transform: scale(0.985); }

.block { margin-top: 26px; }
.block > h2 { font: 400 20px/1.2 var(--serif); margin-bottom: 10px; }

.figures { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.figures > div { background: var(--panel); padding: 12px 14px; }
.figures dt { font-size: 13px; color: var(--muted); }
.figures dd { font-size: 17px; margin-top: 2px; }
.figures .big dd { font-size: 26px; font-weight: 600; line-height: 1.15; }
.figures .milk dd { color: var(--feed); }
.figures .nap dd { color: var(--sleep); }
.figures small { display: block; font-size: 13px; color: var(--muted); font-weight: 400; margin-top: 2px; }

.entries li + li { margin-top: 6px; }
.entry {
  width: 100%; min-height: 54px; padding: 9px 12px 9px 14px;
  display: grid; grid-template-columns: 1fr auto; column-gap: 12px; align-items: center;
  background: var(--panel); border-radius: 10px; border-left: 4px solid var(--sleep);
}
.entry.feed { border-left-color: var(--feed); }
.entry .when, .entry .what { grid-column: 1; }
.entry .when { font-size: 13px; color: var(--muted); }
.entry .what { font-size: 16px; }
.entry .who { font-size: 13px; color: var(--muted); grid-row: 1 / span 2; grid-column: 2; text-align: right; }
.entry .note { grid-column: 1 / -1; font-size: 13px; color: var(--muted); margin-top: 3px; white-space: pre-wrap; overflow-wrap: anywhere; }
.empty { color: var(--muted); font-size: 15px; padding: 6px 2px; }

.link { color: var(--sleep); text-decoration: underline; text-underline-offset: 3px; min-height: 44px; padding: 0 2px; }

/* ---------- History ---------- */

.hist-bar { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.hist-bar .range { flex: 1; text-align: center; font-size: 15px; }
.round { width: 44px; height: 44px; border-radius: 50%; background: var(--panel); font-size: 22px; line-height: 1; text-align: center; }

.seg { display: flex; background: var(--panel); border-radius: 10px; padding: 3px; gap: 2px; }
.seg label, .seg button { flex: 1; text-align: center; min-height: 38px; display: flex; align-items: center; justify-content: center; border-radius: 8px; font-size: 14px; color: var(--muted); padding: 0 10px; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked), .seg button[aria-pressed="true"] { background: var(--panel-2); color: var(--text); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--sleep); outline-offset: 2px; }
.filter { margin-bottom: 12px; }

.grid { display: grid; grid-template-columns: 34px 1fr; }
.axis { position: relative; margin-top: 52px; height: calc(var(--hour) * 24); }
.axis span { position: absolute; right: 6px; transform: translateY(-50%); font-size: 11px; color: var(--muted); white-space: nowrap; }
.cols { display: grid; grid-template-columns: repeat(7, 1fr); }
.col-head { width: 100%; height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 12px; color: var(--muted); border-radius: 8px 8px 0 0; }
.col-head b { font-size: 17px; font-weight: 500; color: var(--text); }
.col.today .col-head { background: var(--today); color: #dfe8f7; }
.col-body {
  position: relative; height: calc(var(--hour) * 24);
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--hour) * 3 - 1px), var(--line) calc(var(--hour) * 3 - 1px), var(--line) calc(var(--hour) * 3));
}
.band { position: absolute; left: 0; right: 0; background: var(--night); pointer-events: none; }
.blk { position: absolute; left: 12%; right: 12%; display: block; }
.blk.sleep { background: var(--sleep); min-height: 3px; border-radius: 2px; }
.blk.feed { background: var(--feed); height: 8px; border-radius: 2px; z-index: 2; box-shadow: 0 0 0 1px var(--bg); }
.now { position: absolute; left: 0; right: 0; height: 2px; background: #fff; z-index: 3; pointer-events: none; }
.now i { position: absolute; right: -3px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: #fff; }
.key { display: flex; gap: 16px; justify-content: center; margin-top: 12px; font-size: 13px; color: var(--muted); }
.key i { display: inline-block; width: 12px; height: 12px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

/* ---------- Account ---------- */

.card { background: var(--panel); border-radius: 14px; padding: 16px; }
.card + .card { margin-top: 14px; }
.card h2 { font: 400 20px/1.2 var(--serif); margin-bottom: 12px; }
.card p { font-size: 14px; color: var(--muted); }
.card p + p { margin-top: 8px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.plain { margin: 6px 0 12px; font-size: 14px; }
.plain li { padding: 3px 0; }
.plain b { font-weight: 600; }

.field { display: block; margin-bottom: 14px; }
.field > span, .field > legend { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="time"], input[type="datetime-local"], textarea {
  width: 100%; min-height: 46px; padding: 10px 12px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  font-size: 16px; -webkit-appearance: none; appearance: none;
}
textarea { resize: vertical; min-height: 64px; }

.btn { min-height: 46px; padding: 0 18px; border-radius: 10px; background: var(--panel-2); font-size: 16px; text-align: center; }
.btn.primary { background: var(--sleep); color: var(--sleep-ink); font-weight: 600; }
.btn.danger { color: var(--danger); background: none; padding: 0 8px; }
.btn.wide { width: 100%; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.error { color: var(--danger); font-size: 14px; margin: 0 0 12px; }

/* ---------- Sheets ---------- */

.scrim { position: fixed; inset: 0; background: rgba(8, 10, 18, 0.6); z-index: 10; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 11;
  max-width: 520px; margin: 0 auto; max-height: 92vh; max-height: 92dvh; overflow-y: auto;
  background: var(--panel); border-radius: 20px 20px 0 0;
  padding: 20px 18px calc(env(safe-area-inset-bottom, 0px) + 18px);
  animation: rise 0.18s ease-out;
}
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet h2 { font: 400 24px/1.2 var(--serif); margin-bottom: 4px; }
.sheet .origin { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.sheet .fields { margin-top: 16px; }
.amount { display: grid; grid-template-columns: 52px 1fr 52px; gap: 8px; align-items: center; }
.amount .round { width: 52px; height: 52px; background: var(--panel-2); }
.amount .box { position: relative; }
.amount input { font-size: 28px; font-weight: 600; text-align: center; padding-right: 44px; min-height: 58px; color: var(--feed); }
.amount .unit { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 15px; pointer-events: none; }
.picks { display: flex; gap: 8px; margin-top: 10px; }
.picks button { flex: 1; min-height: 44px; border-radius: 10px; background: var(--panel-2); text-align: center; font-size: 16px; }
.with-clear { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.hint { font-size: 13px; color: var(--muted); margin: -6px 0 14px; }
.sheet-actions { display: flex; gap: 10px; align-items: center; margin-top: 6px; }
.sheet-actions .spacer { flex: 1; }

/* ---------- Toast ---------- */

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 20;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 74px);
  max-width: min(92vw, 480px); display: flex; align-items: center; gap: 14px;
  background: var(--text); color: var(--bg); border-radius: 12px; padding: 12px 16px; font-size: 15px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.toast.bad { background: var(--danger); }
.toast button { font-weight: 600; text-decoration: underline; min-height: 28px; }

/* ---------- Sign in and messages ---------- */

.center { max-width: 400px; margin: 0 auto; padding: calc(env(safe-area-inset-top, 0px) + 18vh) 24px 40px; }
.center h1 { font: 400 40px/1.1 var(--serif); margin-bottom: 10px; }
.center > p { color: var(--muted); margin-bottom: 22px; }

@media (prefers-reduced-motion: reduce) {
  .sheet { animation: none; }
  .log:active { transform: none; }
}

/* The option switch sits on a darker well inside sheets and cards. */
.sheet .seg, .card .seg { background: var(--bg); }
