/* Sleep guide by age. Loaded after ../mental-health-meditation/meditation.css (same pattern as /disclaimer/ and /five-steps/).
   Colors: site navy/ice family for the page; one indigo family (#3F43A0 on #E8EAF6) for the bars, no good/bad coding. */
:root {
  --sg-ink: #1B1F3B;
  --sg-sec: #4A4F66;
  --sg-band: #3F43A0;
  --sg-track: #E8EAF6;
  --sg-outline: #595E78;
  --sg-line: #b9c7cf;
}
a:focus-visible, button:focus-visible, .table-wrap:focus-visible, summary:focus-visible,
.sg-chip:has(input:focus-visible) {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
[hidden] { display: none !important; }
button { font-family: inherit; }
main { width: min(980px, calc(100% - 48px)); }
main p, main li { line-height: 1.6; }
main h1 { margin-bottom: 8px; }
.sg-subtitle { margin: 0 0 20px; font-size: 22px; font-weight: 400; color: var(--sg-sec); }
.sg-intro p { margin: 0 0 14px; max-width: 820px; }
.sg-intro p:first-child { font-size: 20px; }

/* Tool shell */
.sg-tool { margin: 28px 0 8px; }
.sg-selector {
  margin: 0 0 20px; padding: 18px 20px 20px; border: 0; background: var(--ice); border-left: 8px solid var(--navy);
}
.sg-selector legend { padding: 0; font-size: 26px; font-weight: 400; color: var(--navy); float: left; width: 100%; margin: 0 0 4px; }
.sg-selector legend + * { clear: both; }
.sg-helper { margin: 0 0 14px; font-size: 17px; color: var(--sg-ink); }
.sg-chips { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.sg-chip {
  display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 14px;
  background: #fff; border: 2px solid var(--sg-line); color: var(--sg-ink); cursor: pointer;
  font-size: 18px; font-weight: 400; line-height: 1.25; border-radius: 4px;
}
.sg-chip:hover { border-color: var(--navy); }
.sg-chip input {
  appearance: none; -webkit-appearance: none; flex: 0 0 auto; width: 24px; height: 24px; margin: 0;
  border: 2px solid var(--sg-outline); border-radius: 50%; background: #fff; display: grid; place-content: center;
}
.sg-chip input:checked { background: var(--navy); border-color: var(--navy); }
.sg-chip input:checked::after {
  content: ""; width: 6px; height: 12px; margin-top: -2px; border: solid #fff; border-width: 0 3px 3px 0; transform: rotate(45deg);
}
.sg-chip:has(input:checked) { border-color: var(--sg-ink); background: #fff; box-shadow: inset 0 0 0 1px var(--sg-ink); font-weight: 700; }
.sg-clear {
  margin-top: 14px; min-height: 44px; padding: 8px 20px; background: #fff; color: var(--sg-ink);
  border: 2px solid var(--sg-ink); font-size: 17px; cursor: pointer; border-radius: 4px;
}
.sg-clear:hover { background: var(--sg-ink); color: #fff; }

.sg-empty {
  margin: 0 0 20px; padding: 28px 22px; text-align: center; font-size: 19px; color: var(--sg-ink);
  background: #fff; border: 2px dashed var(--sg-outline);
}

/* Result card */
.sg-card { margin: 0 0 20px; border: 1px solid var(--sg-line); background: #fff; }
.sg-card-head { display: flex; align-items: center; gap: 14px; padding: 16px 22px; background: var(--sg-ink); color: #fff; }
.sg-head-moon { flex: 0 0 auto; }
.sg-card-head h2 { margin: 0; color: #fff; font-size: 30px; font-weight: 400; line-height: 1.2; }
.sg-card-body { padding: 20px 22px 22px; }
.sg-status {
  margin: 0 0 18px; padding: 12px 16px; background: var(--sg-track); border-left: 6px solid var(--sg-band);
  color: var(--sg-ink); font-size: 18px; font-weight: 400;
}
.sg-print-title { display: none; }
.sg-legend { list-style: none; margin: 0 0 18px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 22px; }
.sg-legend-item { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 16px; font-weight: 400; color: var(--sg-ink); line-height: 1.35; }
.sg-marker { display: inline-block; flex: 0 0 auto; width: 12px; height: 12px; background: var(--sg-band); }
.sg-marker-circle { border-radius: 50%; }
.sg-marker-square { border-radius: 0; }
.sg-marker-diamond { clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); width: 14px; height: 14px; }
.sg-swatch-hatch {
  flex: 0 0 auto; width: 34px; height: 14px; border: 1.5px solid var(--sg-band); border-radius: 7px;
  background: repeating-linear-gradient(45deg, var(--sg-band) 0 2px, #fff 2px 6px);
}

.sg-row { margin: 0 0 18px; }
.sg-rowhead { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin: 0 0 2px; }
.sg-rowhead .sg-marker { align-self: center; }
.sg-source { font-size: 20px; font-weight: 700; color: var(--sg-ink); }
.sg-hours { font-size: 20px; font-weight: 400; color: var(--sg-ink); }
.sg-open {
  font-size: 14px; font-weight: 700; color: var(--sg-ink); padding: 1px 10px; border: 1.5px solid var(--sg-band); border-radius: 12px; background: #fff;
  align-self: center; line-height: 1.5;
}
.sg-sub { margin: 0 0 6px; font-size: 15px; font-weight: 400; color: var(--sg-sec); line-height: 1.45; }
.sg-svg { display: block; width: 100%; height: auto; overflow: visible; }
.sg-nsf { margin: 6px 0 0; font-size: 14px; font-weight: 400; color: var(--sg-sec); line-height: 1.45; }

.sg-axis-wrap { margin: 4px 0 18px; }
.sg-axis { position: relative; height: 24px; margin: 0 0 4px; border-top: 0; }
.sg-tick { position: absolute; top: 0; transform: translateX(-50%); font-size: 14px; font-weight: 400; color: var(--sg-sec); white-space: nowrap; }
.sg-tick-0 { left: 5.556%; } .sg-tick-6 { left: 27.778%; } .sg-tick-12 { left: 50%; } .sg-tick-18 { left: 72.222%; } .sg-tick-24 { left: 94.444%; }
.sg-axis-cap { margin: 0 0 4px; font-size: 14px; font-weight: 400; color: var(--sg-sec); line-height: 1.45; }
.sg-notes { margin: 8px 0 14px; padding: 14px 18px; background: #f2f2f2; border-left: 6px solid var(--sg-outline); }
.sg-notes p { margin: 0 0 10px; font-size: 16px; font-weight: 300; color: var(--sg-ink); }
.sg-notes p:last-child { margin-bottom: 0; }
.sg-resultfoot { margin: 0; font-size: 16px; font-weight: 400; color: var(--sg-ink); }

/* Not-medical-advice block */
.sg-disclaimer { margin: 0 0 8px; padding: 22px 24px 14px; background: var(--ice); border-left: 8px solid var(--navy); }
.sg-disclaimer p { margin: 0 0 14px; }
.sg-disclaimer p:first-child { font-weight: 400; }
.sg-disclaimer .disc-link { font-weight: 400; }
.sg-disclaimer .disc-link a { color: var(--ink); }

/* Table (also the no-JavaScript view) */
.sg-table-sec { margin: 28px 0 8px; }
.sg-toggle {
  min-height: 48px; padding: 10px 22px; background: var(--navy); color: #fff; border: 0; font-size: 18px; cursor: pointer; border-radius: 4px;
}
.sg-toggle:hover { background: var(--ink); }
#sg-table-wrap { margin-top: 14px; }
.sg-edu { margin: 0 0 8px; font-size: 18px; font-weight: 700; color: var(--sg-ink); }
.table-wrap { max-width: 100%; overflow-x: auto; border: 1px solid var(--sg-line); background: #fff; }
.table-wrap table { width: 100%; min-width: 760px; border-collapse: collapse; font-size: 16px; }
.table-wrap caption { text-align: left; padding: 12px 14px; font-size: 18px; font-weight: 400; color: var(--sg-ink); background: #f2f2f2; border-bottom: 1px solid var(--sg-line); }
.table-wrap th, .table-wrap td { padding: 10px 14px; border-bottom: 1px solid #d5dde2; text-align: left; vertical-align: top; font-weight: 300; line-height: 1.4; color: var(--sg-ink); }
.table-wrap thead th { background: var(--sg-ink); color: #fff; font-weight: 700; border-bottom: 0; }
.table-wrap tbody th { font-weight: 700; background: var(--ice); }
.table-wrap tbody tr:last-child th, .table-wrap tbody tr:last-child td { border-bottom: 0; }
.table-wrap tbody th { min-width: 200px; }
.t-hours { display: block; font-weight: 400; }
.t-band { display: block; margin-top: 4px; font-size: 14px; color: var(--sg-sec); line-height: 1.4; }
.t-none { color: var(--sg-sec); font-style: italic; }
.sg-small { margin: 10px 0 0; font-size: 14px; color: var(--sg-sec); }

.sg-meta { margin: 20px 0 8px; padding: 16px 20px; background: #f2f2f2; border-left: 6px solid var(--sg-outline); }
.sg-meta p { margin: 0 0 10px; font-size: 16px; font-weight: 300; color: var(--sg-ink); }
.sg-meta p:last-child { margin-bottom: 0; }
.sg-meta a, .sg-sources a { overflow-wrap: anywhere; color: var(--sg-ink); }

.sg-text { margin: 0 0 8px; }
.sg-text h2 { margin-top: 44px; padding: 14px 20px; background: var(--ice); border-left: 8px solid var(--navy); font-size: 28px; }
.sg-text p, .sg-text li { max-width: 820px; }
.sg-text ul { padding-left: 1.3em; }

/* Forced colors / high contrast */
@media (forced-colors: active) {
  .sg-band, .sg-cap, .sg-chev-plate { fill: CanvasText; }
  .sg-band-open { fill: Canvas; stroke: CanvasText; }
  .sg-track { fill: Canvas; stroke: CanvasText; }
  .sg-grid { stroke: CanvasText; }
  .sg-hatch-line { fill: CanvasText; }
  .sg-hatch-bg { fill: Canvas; }
  .sg-chev { stroke: CanvasText; }
  .sg-moon { fill: CanvasText; }
  .sg-moon-cut { fill: Canvas; }
  .sg-mk { fill: Canvas; stroke: CanvasText; }
  .sg-marker { background: CanvasText; }
}

/* Responsive */
@media (max-width: 999px) {
  main { width: min(980px, calc(100% - 40px)); }
  .sg-chips { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  main { width: calc(100% - 32px); }
  .sg-subtitle { font-size: 19px; }
  main h1 { font-size: 36px; }
  .sg-selector { padding: 14px 14px 16px; }
  .sg-selector legend { font-size: 22px; }
  .sg-chips { grid-template-columns: 1fr 1fr; gap: 8px; }
  .sg-chip { padding: 8px 10px; gap: 8px; font-size: 16px; }
  .sg-card-head { padding: 12px 14px; }
  .sg-card-head h2 { font-size: 24px; }
  .sg-card-body { padding: 16px 14px 18px; }
  .sg-row { margin-bottom: 22px; }
  .sg-text h2 { font-size: 24px; padding: 12px 14px; }
  .sg-disclaimer { padding: 18px 16px 10px; }
}
@media (max-width: 480px) {
  .sg-tick-mid { display: none; }
}
@media (max-width: 480px) {
  .sg-chips { grid-template-columns: 1fr; }
  .sg-chip { min-height: 48px; padding: 6px 12px; }
}

/* Print: keep the result, notes, disclaimer, privacy and source lines; hide the selector chrome and toggle. */
@media print {
  .accent-bar, .menu-toggle, .nav, .sg-selector, .sg-toggle, .sg-clear { display: none !important; }
  .sg-tool-js { display: block; }
  .sg-card-head { display: none; }
  .sg-print-title { display: block; margin: 0 0 12px; font-size: 22px; font-weight: 700; color: #000; }
  .sg-card { border: 0; }
  .sg-card-body { padding: 0; }
  .sg-empty { display: none; }
  .sg-card, .sg-row, .sg-notes, .sg-disclaimer, .sg-meta, .table-wrap tr { break-inside: avoid; }
  .sg-svg, .sg-marker, .sg-swatch-hatch, .sg-status, .sg-chip { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .sg-status { background: #fff; border: 1px solid #000; border-left-width: 6px; }
  .sg-text h2 { background: #fff; border-left: 6px solid #000; color: #000; }
  .sg-disclaimer { background: #fff; border: 1px solid #000; }
  .table-wrap { overflow: visible; }
  .table-wrap table { min-width: 0; }
  .table-wrap thead th { background: #fff; color: #000; border-bottom: 2px solid #000; }
  .table-wrap tbody th { background: #fff; }
  a { text-decoration: underline; }
  main { width: 100%; }
}

/* v38-r5 tool-first (spec section 2 item 1 and Privacy P7): compact top block; picker privacy sentence (screen only; the .sg-meta copy prints). */
.top-block { margin: 0 0 8px; }
.top-block p { margin: 0 0 4px; font-size: 18px; font-weight: 400; line-height: 27px; color: var(--sg-ink); }
.top-block .disc-link a { display: block; width: max-content; padding: 10px 0; line-height: 24px; color: var(--ink); }
.sg-picker-privacy { margin: 0 0 20px; font-size: 18px; font-weight: 300; color: var(--sg-ink); }
@media print { .sg-picker-privacy { display: none !important; } }
