@font-face {
  font-family: "Albert Sans";
  src: url("/app/albert-sans.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root,
:root[data-theme="night"] {
  --bg: #1b2422;
  --panel: #242f2c;
  --panel-2: #2f3b37;
  --line: #37443f;
  --ink: #e9e7df;
  --mute: #a3ada7;
  --milk: #d8b77f;
  --sleep: #a2b9cf;
  --nappy: #a9c4ae;
  --danger: #e8a79c;
  color-scheme: dark;
}

:root[data-theme="day"] {
  --bg: #f4f5f2;
  --panel: #fbfbf9;
  --panel-2: #e9ebe5;
  --line: #d9dcd4;
  --ink: #27322e;
  --mute: #646f69;
  --milk: #8c6a2f;
  --sleep: #4f6f8c;
  --nappy: #56795f;
  --danger: #a8432f;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Albert Sans", system-ui, sans-serif;
  font-size: 18px;
  font-weight: 400;
  line-height: 1.35;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

/* Barre d'état iOS : son texte reste blanc, il lui faut un fond sombre le jour. */
:root[data-theme="day"] body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: env(safe-area-inset-top);
  background: var(--ink);
  z-index: 5;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; text-align: left; touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

#root {
  min-height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 22px) 22px calc(env(safe-area-inset-bottom) + 8px);
}

/* En-tête */
.head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.head h1 { margin: 0; font-size: 30px; font-weight: 400; letter-spacing: -0.015em; }
.head .age { color: var(--mute); font-size: 16px; }

.notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 14px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--mute);
  font-size: 15px;
}
.notice button { color: var(--ink); white-space: nowrap; min-height: 32px; }

.feed { --accent: var(--milk); }
.sleep { --accent: var(--sleep); }
.nappy { --accent: var(--nappy); }

/* Les 24 dernières heures, piste par piste */
.sheet-chart { margin-top: 26px; }
.ruler, .track { position: relative; margin-left: 58px; }
.ruler { height: 20px; font-size: 13px; color: var(--mute); }
.ruler span { position: absolute; bottom: 3px; transform: translateX(-50%); }
.tracks { position: relative; }
.row { position: relative; display: block; width: 100%; height: 40px; }
.row .label {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 54px;
  display: flex;
  align-items: center;
  font-size: 14px;
  color: var(--mute);
}
.track { height: 100%; }
.grid { position: absolute; top: 0; bottom: 0; right: 0; left: 58px; pointer-events: none; }
.grid i { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line); opacity: 0; }
.grid i.major { opacity: 1; }
.grid .now { background: var(--ink); opacity: 1; width: 1px; right: 0; }

.key {
  position: absolute;
  top: 50%;
  width: 10px; height: 10px;
  margin: -5px 0 0 -5px;
  background: var(--accent);
  border-radius: 50%;
}
.key.bottle { background: var(--bg); border: 1.5px solid var(--accent); }
.hold {
  position: absolute;
  top: 16px; bottom: 16px;
  min-width: 3px;
  background: var(--accent);
  border-radius: 4px;
}
.hold.live { opacity: .5; }
.tick {
  position: absolute;
  top: 16px; bottom: 16px;
  width: 2px;
  margin-left: -1px;
  background: var(--accent);
  border-radius: 1px;
}
.tick.solid { top: 10px; bottom: 10px; }

.tally { margin: 14px 0 0; color: var(--mute); font-size: 15px; }

/* Les gestes de la nuit, à portée de pouce */
.actions { margin-top: auto; padding-top: 20px; }
.actions > div { border-top: 1px solid var(--line); }
.actions > div:last-child { border-bottom: 1px solid var(--line); }
.act {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 74px;
  padding: 8px 2px;
}
.act .name { display: flex; align-items: center; gap: 12px; font-size: 22px; }
.act .name::before {
  content: "";
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--accent);
}
.act .last { text-align: right; font-size: 17px; }
.act .last small { display: block; color: var(--mute); font-size: 14px; }
.act:active { opacity: .55; }

.running { display: flex; align-items: stretch; background: color-mix(in srgb, var(--accent) 16%, transparent); }
.running .act { flex: 1; padding: 8px 12px; }
.running .act .clock { font-size: 30px; font-weight: 300; font-variant-numeric: tabular-nums; line-height: 1.1; }
.running .cancel {
  flex: none;
  padding: 0 12px;
  color: var(--mute);
  font-size: 14px;
}

.tabs { display: flex; gap: 28px; justify-content: center; margin-top: 6px; }
.tabs button {
  min-height: 46px;
  color: var(--mute);
  font-size: 16px;
}
.tabs button[aria-current="page"] { color: var(--ink); text-decoration: underline; text-underline-offset: 6px; text-decoration-thickness: 1px; }

/* Journal */
.journal { flex: 1; }
.addbar { display: flex; gap: 22px; margin: 18px 0 4px; }
.addbar button { min-height: 44px; color: var(--accent); font-size: 16px; }
.day h2 { font-size: 18px; font-weight: 500; margin: 24px 0 2px; }
.day .sum { margin: 0 0 8px; color: var(--mute); font-size: 14px; }
.entry {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 8px;
  width: 100%;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  font-size: 17px;
}
.entry time { color: var(--mute); font-variant-numeric: tabular-nums; }
.entry b { color: var(--accent); font-weight: 500; }
.entry span small { color: var(--mute); font-size: 16px; }
.empty { color: var(--mute); margin-top: 24px; }
.foot { display: flex; justify-content: space-between; gap: 12px; margin: 28px 0 10px; font-size: 14px; }
.foot a, .foot button { color: var(--mute); text-decoration: underline; text-underline-offset: 3px; min-height: 32px; }

/* Panneau de saisie */
dialog {
  border: 0;
  padding: 24px 22px calc(env(safe-area-inset-bottom) + 16px);
  margin: auto auto 0;
  width: 100%;
  max-width: 520px;
  max-height: 90dvh;
  background: var(--panel);
  color: var(--ink);
  border-radius: 14px 14px 0 0;
}
dialog::backdrop { background: rgb(20 28 26 / .45); }
dialog h2 { margin: 0 0 18px; font-size: 24px; font-weight: 400; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice {
  min-height: 80px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 19px;
  text-align: center;
}
.choice small { display: block; font-size: 14px; color: var(--accent); }
.choice.wide { grid-column: 1 / -1; min-height: 60px; }
.choice[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips .choice { min-height: 46px; flex: 1 1 40%; font-size: 16px; padding: 8px 10px; }
.field { display: block; margin-top: 16px; }
.field > span { display: block; color: var(--mute); font-size: 14px; margin-bottom: 4px; }
.field input {
  width: 100%;
  min-height: 48px;
  padding: 8px 12px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 17px;
}
.stepper { display: grid; grid-template-columns: 60px 1fr 60px; gap: 8px; align-items: center; }
.stepper button { min-height: 50px; text-align: center; border: 1px solid var(--line); border-radius: 6px; font-size: 22px; font-weight: 300; }
.stepper output { text-align: center; font-size: 28px; font-weight: 300; }
.btn {
  display: block;
  width: 100%;
  min-height: 54px;
  margin-top: 20px;
  background: var(--ink);
  color: var(--bg);
  border-radius: 6px;
  font-size: 18px;
  text-align: center;
}
.btn:disabled { opacity: .55; }
.link {
  display: block;
  width: 100%;
  min-height: 44px;
  margin-top: 6px;
  text-align: center;
  color: var(--mute);
  font-size: 16px;
}
.link.danger { color: var(--danger); }

/* Connexion */
.login { margin: auto 0; }
.login h1 { font-size: 38px; margin: 0 0 6px; font-weight: 400; letter-spacing: -0.015em; }
.login p { color: var(--mute); margin: 0 0 14px; font-size: 16px; }
.login .error { color: var(--danger); margin: 12px 0 0; }

#toast {
  position: fixed;
  left: 22px; right: 22px;
  bottom: calc(env(safe-area-inset-bottom) + 18px);
  max-width: 476px;
  margin: 0 auto;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  background: var(--ink);
  color: var(--bg);
  border-radius: 6px;
  font-size: 16px;
  z-index: 10;
}
#toast.on { display: flex; }
#toast button { color: var(--bg); text-decoration: underline; text-underline-offset: 3px; min-height: 28px; }

@media (prefers-reduced-motion: no-preference) {
  dialog[open] { animation: rise .2s ease-out; }
  @keyframes rise { from { transform: translateY(16px); } }
}
