:root {
  --bg: #f8f7fc;
  --surface: #ffffff;
  --text: #1b1d3a;
  --muted: #62667f;
  --line: #e6e4f0;
  --accent: #5b5bd6;
  --accent-ink: #ffffff;
  --accent-soft: #efeefd;
  --nap: #f3f4ff;
  --nap-line: #d6d9fb;
  --sun: #c7771a;
  --sun-soft: #fff4e6;
  --night: #2d2f6b;
  --night-ink: #f4f4fd;
  --now: #1a8a5a;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(27, 29, 58, .05), 0 8px 28px rgba(27, 29, 58, .07);
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.6 var(--font); -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; letter-spacing: -.02em; font-weight: 800; }
h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); margin: 1.2rem 0 .4rem; }
h2 { font-size: 1.3rem; margin: 2.2rem 0 .6rem; }
h3 { font-size: 1.05rem; margin: 1.2rem 0 .3rem; }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }
.lede { color: var(--muted); font-size: 1.05rem; margin-top: 0; }
.fine { color: var(--muted); font-size: .85rem; }

.site-header { border-bottom: 1px solid var(--line); background: var(--surface); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); text-decoration: none; }
.brand svg { color: var(--accent); }
.site-header nav { display: flex; gap: 16px; font-size: .95rem; }
.site-header nav a { color: var(--muted); text-decoration: none; }
.site-header nav a:hover { color: var(--text); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.calc { margin: 1rem 0 1.5rem; }
.calc-form { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .calc-form { grid-template-columns: 1fr 1fr; } .calc-form .more { grid-column: 1 / -1; } }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label, .log label { font-size: .85rem; font-weight: 600; color: var(--muted); }
select, input {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; min-height: 44px; width: 100%;
}
select:focus, input:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.more summary { cursor: pointer; color: var(--accent); font-size: .95rem; }
.more[open] { display: grid; gap: 12px; }
@media (min-width: 560px) { .more[open] { grid-template-columns: 1fr 1fr; } .more summary, .more .fine { grid-column: 1 / -1; } }
.age-note { font-size: .9rem; color: var(--muted); min-height: 1.2em; margin: 6px 0 0; }
.link-btn { font: inherit; background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; }
#use-mine { margin-top: 8px; }

.results { margin-top: 18px; }
.next-up { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap;
  background: var(--accent-soft); border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; }
.next-up span { color: var(--muted); font-size: .9rem; }
.chips { list-style: none; padding: 0; margin: 0 0 16px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 560px) { .chips { grid-template-columns: repeat(4, 1fr); } }
.chips li { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; display: flex; flex-direction: column; }
.chips span { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.chips b { font-size: 1.1rem; font-variant-numeric: tabular-nums; }

.timeline { list-style: none; margin: 0; padding: 0; }
.tl { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 12px; border-radius: 12px; padding: 10px 14px; }
.tl-time { font-weight: 700; font-variant-numeric: tabular-nums; }
.tl-label { grid-column: 1; color: var(--muted); font-size: .92rem; }
.tl-label em { font-style: normal; font-size: .75rem; background: var(--accent); color: var(--accent-ink); border-radius: 99px; padding: 1px 8px; margin-left: 4px; }
.tl--wake { background: var(--sun-soft); }
.tl--wake .tl-time { color: var(--sun); }
.tl--nap { background: var(--nap); border: 1px solid var(--nap-line); }
.tl--nap .log-btn { grid-column: 2; grid-row: 1 / span 2; }
.tl--nap.is-past { opacity: .7; }
.tl--nap.is-now { border-color: var(--now); box-shadow: inset 4px 0 0 var(--now); }
.tl--bed { background: var(--night); color: var(--night-ink); }
.tl--bed .tl-label { color: var(--night-ink); opacity: .8; }
.tl--gap { display: block; font-size: .82rem; color: var(--muted); padding: 4px 14px 4px 28px; position: relative; }
.tl--gap::before { content: ""; position: absolute; left: 16px; top: 0; bottom: 0; border-left: 2px dotted var(--line); }
.log-btn { font: inherit; font-size: .85rem; border: 1px solid var(--nap-line); background: var(--surface); color: var(--accent);
  border-radius: 99px; padding: 6px 12px; cursor: pointer; min-height: 36px; }
.log { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.log[hidden] { display: none; }
.log label { display: flex; flex-direction: column; gap: 4px; }
.notes { margin: 14px 0 0; padding: 12px 14px 12px 32px; background: var(--sun-soft); border-radius: 12px; font-size: .92rem; }

table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
td { font-variant-numeric: tabular-nums; }
.table-card { padding: 4px 8px; overflow-x: auto; }

.age-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 560px) { .age-grid { grid-template-columns: repeat(4, 1fr); } }
.age-grid a { display: block; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); text-decoration: none; color: var(--text); font-size: .95rem; }
.age-grid a:hover { border-color: var(--accent); }
.age-grid a[aria-current] { border-color: var(--accent); background: var(--accent-soft); }

.faq details { border-bottom: 1px solid var(--line); padding: 10px 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq p { margin: .5rem 0 0; }

.safe { border-left: 4px solid var(--accent); }
.safe h2 { margin-top: 0; font-size: 1.1rem; }
.pager { display: flex; justify-content: space-between; gap: 12px; margin: 2rem 0; flex-wrap: wrap; }

.ad-slot { margin: 1.5rem 0; min-height: 100px; }
.ad-slot--placeholder { display: grid; place-items: center; border: 1px dashed var(--line); border-radius: 12px; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; }

.site-footer { border-top: 1px solid var(--line); margin-top: 3rem; padding: 1.5rem 0 2.5rem; color: var(--muted); font-size: .88rem; }
.site-footer nav { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: .6rem; }
.site-footer a { color: var(--muted); }
.next-up[hidden], .age-note:empty { display: none; }
@media (max-width: 559px) { .chips b { font-size: 1rem; } }
