/* Why Am I Tired but Can't Sleep? — one stylesheet, no dependencies. */

:root {
  --ink: #14171a;
  --muted: #5b646d;
  --line: #d9dee3;
  --bg: #ffffff;
  --soft: #f5f7f9;
  --accent: #10331f;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Georgia, "Times New Roman", Times, serif;
  font-size: 18px;
  line-height: 1.62;
  overflow-wrap: break-word;
}

img, table, pre { max-width: 100%; }

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 20px 72px;
}

h1 {
  font-size: 1.85em;
  line-height: 1.2;
  margin: 0 0 20px;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 1.28em;
  line-height: 1.28;
  margin: 44px 0 12px;
  padding-top: 6px;
}

p { margin: 0 0 18px; }

.answer {
  font-size: 1.08em;
  border-left: 4px solid var(--accent);
  padding-left: 16px;
  margin-bottom: 28px;
}

.start {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px 20px 6px;
  margin: 0 0 30px;
}

.start p { font-weight: bold; margin-bottom: 10px; }

.start ol { margin: 0 0 14px; padding-left: 22px; }

.start li { margin-bottom: 10px; }

/* ---- download entry ---- */

.entry {
  border: 2px solid var(--accent);
  border-radius: 10px;
  padding: 20px 20px 16px;
  margin: 0 0 40px;
  background: #fbfdfb;
}

.entry-title {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 1.06em;
  font-weight: 700;
  margin: 0 0 8px;
}

.entry-lead { font-size: 0.95em; margin-bottom: 16px; }

.entry-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.btn {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 0.94em;
  font-weight: 600;
  line-height: 1.25;
  min-height: 46px;
  padding: 12px 18px;
  border-radius: 8px;
  border: 2px solid var(--accent);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-align: center;
}

.btn-primary { background: var(--accent); color: #fff; }

.btn-secondary { background: #fff; color: var(--accent); }

.btn:focus-visible { outline: 3px solid #0b6b3a; outline-offset: 2px; }

.entry-note { font-size: 0.85em; color: var(--muted); margin: 0; }

/* ---- code-ish blocks ---- */

pre.calc, pre.fields {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.82em;
  line-height: 1.5;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px 16px;
  margin: 0 0 18px;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

ul { padding-left: 22px; }

li { margin-bottom: 10px; }

/* ---- print-only sheet: hidden on screen ---- */

.sheet { display: none; }

@media print {
  @page { size: A4 portrait; margin: 10mm; }

  html, body {
    background: #fff;
    color: #000;
    font-size: 10pt;
  }

  .wrap { display: none !important; }

  .sheet { display: block !important; }

  .sheet-title {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 15pt;
    font-weight: bold;
    margin: 0 0 2mm;
    letter-spacing: 0;
  }

  .sheet-sub {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 8pt;
    margin: 0 0 3mm;
  }

  table.diary {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 7pt;
  }

  table.diary th, table.diary td {
    border: 0.6pt solid #000;
    padding: 1mm 1.2mm;
    height: 8.5mm;
    vertical-align: middle;
    text-align: center;
    overflow: hidden;
  }

  table.diary thead th {
    height: 6mm;
    font-size: 7.5pt;
    font-weight: bold;
    background: #fff;
  }

  table.diary th.rowlab {
    width: 18%;
    text-align: left;
    font-weight: normal;
    font-size: 6.8pt;
    line-height: 1.15;
  }

  table.diary tr.calcrow th.rowlab { font-weight: bold; }

  .sheet-foot { margin-top: 4mm; }

  .sheet-foot .formula {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 7pt;
    margin: 0 0 1mm;
  }

  .sheet-foot .range {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 7.5pt;
    margin: 3mm 0 1mm;
  }

  .sheet-foot .avg {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 9pt;
    font-weight: bold;
    margin: 3mm 0 0;
  }

  .sheet-foot .blank {
    display: inline-block;
    width: 22mm;
    border-bottom: 0.6pt solid #000;
  }
}

/* ---- phone width ---- */

@media (max-width: 560px) {
  body { font-size: 16.5px; line-height: 1.58; }

  .wrap { padding: 22px 15px 56px; }

  h1 { font-size: 1.5em; }

  h2 { font-size: 1.18em; margin-top: 34px; }

  .answer { padding-left: 12px; font-size: 1.03em; }

  .start, .entry { padding: 16px 14px; }

  .entry-actions { flex-direction: column; }

  .btn { width: 100%; }

  pre.calc, pre.fields { font-size: 0.76em; padding: 12px 12px; }
}
