/* Bedtime Math: dusk, dark-first. Deep lavender twilight, warm moon-gold accent. */
:root {
  color-scheme: dark;
  --night: #1b1730;
  --night-2: #221d3b;
  --night-3: #2c2549;
  --dusk: #47325e;
  --line: #3e3564;
  --line-2: #312a52;
  --ink: #eee9f8;
  --muted: #b6acd0;
  --lav: #b9a6e8;
  --lav-2: #8f7bd0;
  --gold: #f2c46d;
  --gold-2: #f8dca0;
  --gold-ink: #241a06;
  --warn: #f3b37a;
  --display: 'Quicksand', 'Nunito', system-ui, sans-serif;
  --text: 'Nunito', system-ui, sans-serif;
  --w: 1140px;
  --r: 14px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--night); color: var(--ink); font: 400 1.0625rem/1.65 var(--text); overflow-x: hidden; }
a { color: var(--gold-2); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; color: var(--gold); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--gold); color: var(--gold-ink); padding: 8px 12px; z-index: 10; border-radius: 8px; }
.skip:focus { left: 8px; }
.wrap { max-width: var(--w); margin: 0 auto; padding: 0 24px; }
h1, h2, h3 { font-family: var(--display); line-height: 1.12; margin: 0 0 .5em; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); }
h2 { font-size: clamp(1.45rem, 2.6vw, 1.85rem); }
h3 { font-size: 1.25rem; }
.lede { font-size: 1.18rem; line-height: 1.55; color: var(--muted); max-width: 38em; margin: 0 0 1.4rem; }
small { font-size: .85em; }

/* Header */
.top { border-bottom: 1px solid var(--line-2); background: var(--night); }
.top-in { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 66px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font: 600 1.45rem/1 var(--display); }
.brand b, .foot-brand b { color: var(--gold); font-weight: 700; }
.brand:hover { color: var(--ink); }
.nav { display: flex; gap: 4px; }
.nav a { color: var(--ink); text-decoration: none; padding: 8px 14px; border-radius: 999px; font-weight: 600; }
.nav a:hover { background: var(--night-3); color: var(--ink); }
.nav a[aria-current] { background: var(--gold); color: var(--gold-ink); }

/* Hero: the sky darkens upward from a warm horizon line */
.hero { position: relative; padding: 46px 0 40px; background: linear-gradient(180deg, var(--night) 0%, #241d3e 55%, #33264d 100%); border-bottom: 2px solid var(--gold); }
.hero::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 60px; background: radial-gradient(60% 100% at 50% 100%, rgba(242, 196, 109, .16), transparent 70%); pointer-events: none; }
.hero-head { max-width: 760px; }
.help { position: relative; z-index: 1; font-size: .92rem; color: var(--muted); margin: 18px 0 0; }

/* Tool layout */
.tool-grid { display: grid; grid-template-columns: minmax(280px, 340px) 1fr; gap: 28px; align-items: start; position: relative; z-index: 1; }
.result-col { min-width: 0; }
.panel { display: grid; gap: 16px; background: var(--night-2); padding: 20px; border: 1px solid var(--line); border-radius: var(--r); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label { display: grid; gap: 6px; align-content: start; font-weight: 700; font-size: .98rem; }
label small { font-weight: 400; color: var(--muted); display: block; font-size: .86rem; line-height: 1.4; }
input, select { font: 600 1.1rem var(--text); color: var(--ink); background: var(--night); border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; min-height: 50px; font-variant-numeric: tabular-nums; }
input[type=time] { font-size: 1.35rem; font-family: var(--display); font-weight: 700; }
input::-webkit-calendar-picker-indicator { filter: invert(.85); }
input:focus, select:focus { border-color: var(--gold); outline: none; box-shadow: 0 0 0 3px rgba(242, 196, 109, .25); }
input[type=range] { padding: 0; min-height: 32px; border: 0; background: transparent; accent-color: var(--gold); }
output { font-weight: 800; color: var(--gold-2); }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { font-weight: 700; padding: 0; margin-bottom: 8px; font-size: .98rem; }
.seg-track { display: grid; grid-template-columns: 1fr 1fr; background: var(--night); border: 1.5px solid var(--line); border-radius: 999px; padding: 4px; }
.seg label { display: block; position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; min-height: 0; }
.seg span { display: block; text-align: center; padding: 9px 6px; border-radius: 999px; font-weight: 700; font-size: .95rem; color: var(--muted); }
.seg input:checked + span { background: var(--lav); color: var(--night); }
.seg input:focus-visible + span { outline: 3px solid var(--gold); outline-offset: 1px; }
.adjust { border-top: 1px solid var(--line); padding-top: 12px; }
.adjust summary { cursor: pointer; font-weight: 700; color: var(--lav); }
.adjust[open] summary { margin-bottom: 14px; }
.adjust label + label { margin-top: 14px; }
[hidden] { display: none !important; }

/* Result */
.night { min-width: 0; }
.night-lead { margin: 0 0 12px; font-size: 1.08rem; }
.night-lead b, .night-sub b { color: var(--gold-2); }
.night-sub { margin: 12px 0 0; }
.night-note { color: var(--muted); font-size: .92rem; margin: 12px 0 0; max-width: 46em; }
.picks { list-style: none; margin: 0 0 16px; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.picks.two { grid-template-columns: repeat(2, 1fr); }
.pick { display: grid; gap: 2px; align-content: start; width: 100%; height: 100%; text-align: left; font: inherit; color: var(--ink); background: transparent; border: 1.5px solid var(--line); border-radius: var(--r); padding: 12px 14px; cursor: pointer; }
.pick.static { cursor: default; }
.pick:hover { border-color: var(--lav-2); }
.pick[aria-pressed=true] { border-color: var(--gold); background: rgba(242, 196, 109, .08); }
.pick-t { font: 700 clamp(1.6rem, 3.4vw, 2.2rem)/1.1 var(--display); font-variant-numeric: tabular-nums; }
.pick[aria-pressed=true] .pick-t, .pick.static .pick-t { color: var(--gold); }
.pick-t small { display: block; font: 600 .85rem var(--text); color: var(--muted); margin-top: 2px; }
.pick-d { font-size: .9rem; color: var(--ink); }
.pick em { font-style: normal; font-size: .8rem; color: var(--warn); line-height: 1.3; margin-top: 4px; }
.flag { margin: 14px 0 0; padding: 10px 14px; border-left: 3px solid var(--warn); background: rgba(243, 179, 122, .08); border-radius: 0 10px 10px 0; font-size: .95rem; }
.err { color: var(--warn); font-weight: 700; margin: 0; }
.big-range { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin: 0; }
.big-range strong { font: 700 clamp(3.4rem, 9vw, 5.4rem)/1 var(--display); color: var(--gold); font-variant-numeric: tabular-nums; }
.big-range span { font-size: 1.1rem; color: var(--muted); }
.cmp { margin: 10px 0 0; font-size: 1.05rem; }
.cmp-below b { color: var(--warn); }
.cmp-within b { color: var(--lav); }

/* Horizon timeline */
.horizon { margin: 0; }
.hz-svg, .nap-svg { display: block; width: 100%; height: auto; border-radius: var(--r); background: #191429; border: 1px solid var(--line-2); }
.hz-sky0 { stop-color: #1b1730; }
.hz-sky1 { stop-color: #4a345f; }
.hz-deep0 { stop-color: #3a3070; stop-opacity: .55; }
.hz-deep1 { stop-color: #8f7bd0; stop-opacity: .95; }
.hz-dip { stroke: var(--lav); stroke-width: 1.5; }
.hz-part { fill: none; stroke: var(--lav); stroke-width: 1.5; stroke-dasharray: 4 5; opacity: .8; }
.hz-n { fill: var(--night); font: 700 17px var(--display); }
.hz-line { stroke: var(--gold); stroke-width: 2; }
.hz-fall { stroke: var(--night); stroke-width: 3; stroke-dasharray: 2 5; stroke-linecap: round; }
.hz-tick { stroke: var(--gold-2); stroke-width: 2; stroke-linecap: round; }
.hz-star { fill: #e7defa; opacity: .7; }
.hz-moon { fill: var(--gold); }
.hz-sun path { fill: var(--gold); }
.hz-sun line { stroke: var(--gold); stroke-width: 2.4; stroke-linecap: round; }
.hz-marks { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 8px; font-size: .88rem; color: var(--muted); }
.hz-marks li { padding: 3px 10px; border: 1px solid var(--line-2); border-radius: 999px; white-space: nowrap; }
.hz-marks b { color: var(--ink); font-variant-numeric: tabular-nums; }
.hz-marks span { font-size: .8rem; opacity: .8; }
.hz-marks .hz-m-bed, .hz-marks .hz-m-wake { border-color: var(--gold); }
.hz-marks .hz-m-bed b, .hz-marks .hz-m-wake b { color: var(--gold); }
.nap-svg { background: #1f1936; }
.nap-avoid { fill: rgba(243, 179, 122, .16); stroke: rgba(243, 179, 122, .5); stroke-dasharray: 3 4; }
.nap-dot { fill: var(--lav); }
.nap-alarm { fill: var(--gold); }
.nap-lbl { fill: var(--ink); font: 700 18px var(--display); }
.nap-lbl.dim { fill: var(--warn); font-weight: 600; font-size: 16px; }

/* Tables */
.table-scroll { overflow-x: auto; margin: 18px 0 0; border: 1px solid var(--line-2); border-radius: var(--r); }
table { border-collapse: collapse; width: 100%; font-size: .95rem; font-variant-numeric: tabular-nums; }
caption { text-align: left; padding: 10px 14px; color: var(--muted); font-size: .88rem; }
th, td { text-align: left; padding: 9px 14px; border-top: 1px solid var(--line-2); vertical-align: top; }
thead th { border-top: 0; color: var(--lav); font-weight: 700; white-space: nowrap; }
tbody th { font-weight: 700; }
tr.hl { background: rgba(242, 196, 109, .1); }
tr.hl th, tr.hl td { color: var(--gold-2); }

/* Home blocks */
.block { padding-top: 44px; padding-bottom: 44px; }
.block + .block { border-top: 1px solid var(--line-2); }
.tool-row { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 0; border-top: 1px solid var(--line); }
.tool-row li { border-bottom: 1px solid var(--line); }
.tool-row li:first-child { border-right: 1px solid var(--line); }
.tool-row a { display: grid; gap: 4px; padding: 18px 20px 20px 0; text-decoration: none; color: var(--ink); }
.tool-row li + li a { padding-left: 20px; }
.tool-row a:hover .tr-name { color: var(--gold); }
.tr-name { font: 700 1.3rem/1.2 var(--display); }
.tr-name::after { content: ' →'; color: var(--gold); }
.tr-desc { color: var(--muted); }
.split { display: grid; grid-template-columns: 1fr 1.2fr; gap: 48px; }
.age-strip { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.age-strip div { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.age-strip dt { color: var(--muted); }
.age-strip dd { margin: 0; font: 700 1.05rem var(--display); color: var(--gold-2); white-space: nowrap; }
.note { font-size: .92rem; color: var(--muted); margin: 14px 0 0; }

/* Lists of posts */
.post-list { list-style: none; margin: 0; padding: 0; }
.post-list li { border-bottom: 1px solid var(--line-2); }
.post-list a { display: grid; gap: 3px; padding: 14px 0; text-decoration: none; color: var(--ink); }
.pl-title { font: 700 1.14rem/1.3 var(--display); }
.post-list a:hover .pl-title { color: var(--gold); }
.pl-desc { color: var(--muted); font-size: .95rem; }
.post-list time { font-size: .82rem; color: var(--lav); }
.list-page { padding-top: 40px; padding-bottom: 56px; max-width: 820px; }

/* Tool pages & articles */
.crumbs { font-size: .9rem; color: var(--muted); padding: 22px 0 6px; }
.crumbs a { color: var(--muted); }
.tool-page { padding-bottom: 56px; }
.tool-head { margin-bottom: 8px; }
.how { margin-top: 48px; max-width: 760px; }
.doctor { max-width: 760px; margin: 32px 0 0; padding: 18px 20px; border: 1.5px solid var(--gold); border-radius: var(--r); }
.doctor h2 { font-size: 1.3rem; color: var(--gold); }
.doctor p { margin: 0 0 8px; }
.doctor q { font-style: italic; }
.doctor .src { font-size: .88rem; margin: 0; }
.more { margin-top: 36px; max-width: 760px; }
.more h2 { font-size: 1.3rem; }
.more ul { margin: 0; padding-left: 1.2em; }
.more li { margin: 6px 0; }
.article { max-width: 780px; padding-bottom: 56px; }
.article-head { margin-bottom: 18px; }
.byline { font-size: .92rem; color: var(--muted); }
.tool-callout { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; justify-content: space-between; padding: 16px 18px; border-radius: var(--r); background: var(--night-3); border-left: 4px solid var(--gold); margin: 0 0 28px; }
.tool-callout p { margin: 0; flex: 1 1 280px; }
.btn { display: inline-block; background: var(--gold); color: var(--gold-ink); font-weight: 800; text-decoration: none; padding: 10px 18px; border-radius: 999px; }
.btn:hover { background: var(--gold-2); color: var(--gold-ink); }
.prose { font-size: 1.08rem; }
.prose h2 { margin-top: 1.8em; }
.prose h3 { margin-top: 1.4em; }
.prose p, .prose li { max-width: 40em; }
.prose li { margin: 4px 0; }
.prose table { display: block; overflow-x: auto; margin: 1.2em 0; border: 1px solid var(--line-2); border-radius: var(--r); }
.prose blockquote { margin: 1.2em 0; padding: 4px 18px; border-left: 3px solid var(--lav); color: var(--muted); }
.prose .horizon { margin: 1.4em 0; }
.prose strong { color: #fff; }
.sources { margin-top: 36px; padding-top: 18px; border-top: 1px solid var(--line); }
.sources h2 { font-size: 1.3rem; }
.sources ul { padding-left: 1.2em; font-size: .95rem; }
.disclaimer { font-size: .9rem; color: var(--muted); border-top: 1px solid var(--line-2); padding-top: 14px; margin-top: 28px; }
.contact-pending { padding: 12px 16px; border: 1px dashed var(--line); border-radius: 10px; }

/* Footer */
.foot { border-top: 1px solid var(--line); margin-top: 24px; padding: 32px 0 20px; background: #17142a; font-size: .95rem; }
.foot-in { display: grid; grid-template-columns: 1.4fr 1fr; gap: 32px; }
.foot-brand { display: flex; align-items: center; gap: 8px; font: 600 1.2rem var(--display); margin: 0 0 8px; }
.foot-in p { color: var(--muted); margin: 0 0 8px; max-width: 34em; }
.foot nav { display: flex; flex-wrap: wrap; gap: 6px 18px; align-content: start; }
.foot nav a { color: var(--ink); }
.foot-copy { color: var(--muted); font-size: .85rem; margin-top: 18px; }

@media (max-width: 900px) {
  .tool-grid, .split, .foot-in { grid-template-columns: 1fr; }
  .split { gap: 32px; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; animation: none !important; } }

/* Phone */
@media (max-width: 640px) {
  .wrap { padding-left: 16px; padding-right: 16px; }
  .top-in { flex-wrap: wrap; gap: 0; min-height: 0; padding-top: 12px; }
  .brand { padding-bottom: 6px; }
  .nav { width: calc(100% + 32px); margin: 0 -16px; padding: 4px 12px 10px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { white-space: nowrap; padding: 7px 13px; }
  h1 { font-size: 2.15rem; }
  .hero { padding: 26px 0 28px; }
  .lede { font-size: 1.06rem; margin-bottom: 1rem; }
  .panel { padding: 16px; }
  .picks { grid-template-columns: 1fr; gap: 8px; }
  .picks.two { grid-template-columns: 1fr; }
  .pick { grid-template-columns: auto 1fr; align-items: baseline; column-gap: 14px; padding: 10px 14px; }
  .pick-t small { display: inline; margin-left: 6px; }
  .pick em { grid-column: 1 / -1; margin-top: 0; }
  .tool-row { grid-template-columns: 1fr; }
  .tool-row li:first-child { border-right: 0; }
  .tool-row li + li a { padding-left: 0; }
  .age-strip { grid-template-columns: 1fr; }
  .hz-marks { font-size: .82rem; }
  .row { grid-template-columns: 1fr 1fr; }
}
