/* GLP-1 Dosebook. One stylesheet, self-hosted font, no third-party requests.
   Type: Atkinson Hyperlegible Next (SIL OFL, /fonts/OFL.txt), chosen so dose numbers can't be misread.
   Colour: evergreen ink on sage paper. Amber and red are reserved for safety notes only. */
@font-face { font-family: "Atkinson Next"; src: url("/fonts/ahn-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Atkinson Next"; src: url("/fonts/ahn-600.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Atkinson Next"; src: url("/fonts/ahn-800.woff2") format("woff2"); font-weight: 800; font-style: normal; font-display: swap; }

:root {
  color-scheme: light dark;
  --paper: #eef3ee;      /* sage paper */
  --surface: #ffffff;
  --ink: #18302a;        /* evergreen ink */
  --ink-2: #4f645d;
  --accent: #1d6b52;     /* evergreen */
  --accent-ink: #15553f;
  --accent-soft: #dcefe5;
  --marker: #7fd4b0;     /* the dose-marker line in the logo */
  --line: #cfdcd4;
  --line-strong: #9db3a8;
  --check-bg: #fff6dd; --check-line: #e0b54a; --check-ink: #6f4a00;
  --stop-bg: #fdeaea; --stop-line: #df9a9a; --stop-ink: #8c1c1c;
  --radius: 12px;
  --max: 1040px;
  --read: 68ch;
  /* legacy names used by tool scripts */
  --bg: var(--paper);
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f1a17; --surface: #15231f; --ink: #e4efe9; --ink-2: #a6bab2;
    --accent: #4cc497; --accent-ink: #8ee0bf; --accent-soft: #173229; --marker: #8ee0bf;
    --line: #29423a; --line-strong: #46655a;
    --check-bg: #2b2310; --check-line: #6d5521; --check-ink: #f3d68f;
    --stop-bg: #2e1515; --stop-line: #6d2c2c; --stop-ink: #f6b4b4;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 16px; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: "Atkinson Next", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 18px; line-height: 1.6; font-variant-numeric: lining-nums;
}
a { color: var(--accent-ink); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
a:hover { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
img, svg { max-width: 100%; }
.wrap { max-width: var(--max); margin: 0 auto; padding: 0 20px; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 12px; top: 12px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 10; }

/* Header: logo, nav, and the graduation ruler */
.site-header { background: var(--surface); position: relative; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand svg { width: 36px; height: 36px; flex: none; }
.wordmark { font-size: 20px; font-weight: 800; letter-spacing: -.01em; line-height: 1; }
.wordmark .glp { font-weight: 400; color: var(--ink-2); }
.nav-wide { display: flex; gap: 22px; font-size: 16px; }
.nav-wide a { color: var(--ink-2); text-decoration: none; padding: 10px 0; }
.nav-wide a:hover, .nav-wide a[aria-current="page"] { color: var(--accent-ink); text-decoration: underline; text-decoration-thickness: 2px; }
.ruler {
  height: 10px; border-bottom: 1px solid var(--line-strong);
  background:
    repeating-linear-gradient(90deg, var(--line-strong) 0 1.5px, transparent 1.5px 60px) bottom left / 100% 10px no-repeat,
    repeating-linear-gradient(90deg, var(--line) 0 1px, transparent 1px 12px) bottom left / 100% 5px no-repeat;
}
.menu { display: none; position: relative; }
.menu summary {
  list-style: none; cursor: pointer; font-weight: 600; font-size: 16px; padding: 10px 14px; min-height: 44px;
  border: 1.5px solid var(--line); border-radius: 10px; display: inline-flex; align-items: center; gap: 8px;
}
.menu summary::-webkit-details-marker { display: none; }
.menu summary svg { width: 18px; height: 18px; }
.menu[open] summary { background: var(--accent-soft); border-color: var(--accent); }
.menu-sheet {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; width: min(320px, calc(100vw - 40px));
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 14px; padding: 8px;
  box-shadow: 0 12px 32px rgba(24, 48, 42, .18);
}
.menu-sheet a { display: block; padding: 12px 12px; border-radius: 10px; text-decoration: none; color: var(--ink); font-weight: 600; }
.menu-sheet a small { display: block; font-weight: 400; color: var(--ink-2); font-size: 14px; }
.menu-sheet a:hover, .menu-sheet a[aria-current="page"] { background: var(--accent-soft); }
.menu-sheet hr { border: 0; border-top: 1px solid var(--line); margin: 6px 4px; }
@media (max-width: 860px) {
  .nav-wide { display: none; }
  .menu { display: block; }
}

/* Footer */
.site-footer { margin-top: 72px; background: var(--surface); border-top: 1px solid var(--line-strong); font-size: 15px; color: var(--ink-2); }
.site-footer .wrap { padding-top: 32px; padding-bottom: 40px; }
.footer-grid { display: grid; grid-template-columns: 1.6fr 1fr 1fr; gap: 28px; }
.footer-grid h2 { font-size: 15px; margin: 0 0 8px; color: var(--ink); }
.footer-grid ul { list-style: none; padding: 0; margin: 0; }
.footer-grid li { margin: 6px 0; }
.footer-grid a { color: var(--ink-2); }
.fineprint { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 14px; }
@media (max-width: 720px) { .footer-grid { grid-template-columns: 1fr 1fr; } .footer-grid > div:first-child { grid-column: 1 / -1; } }

/* Type scale (minor third from 18px) */
h1 { font-size: clamp(31px, 6vw, 44px); line-height: 1.12; letter-spacing: -.02em; font-weight: 800; margin: 32px 0 12px; max-width: 22ch; }
h2 { font-size: 26px; line-height: 1.2; letter-spacing: -.01em; font-weight: 800; margin: 44px 0 12px; }
h3 { font-size: 21px; line-height: 1.3; font-weight: 600; margin: 26px 0 8px; }
p { margin: 0 0 14px; }
.lede { font-size: 20px; line-height: 1.5; color: var(--ink-2); margin: 0 0 20px; max-width: 60ch; }
.meta { font-size: 15px; color: var(--ink-2); margin: 0 0 22px; }
.meta a { color: inherit; }

/* Panels */
.card { background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 22px; }
.tool { margin-top: 8px; border-color: var(--line-strong); }
@media (max-width: 520px) {
  .wrap { padding: 0 16px; }
  .card { padding: 18px 16px; }
  .tool { margin-left: -6px; margin-right: -6px; }
}

/* Home: hero and task list */
.hero { padding: 12px 0 4px; }
.hero h1 { font-size: clamp(34px, 7vw, 54px); max-width: 16ch; }
.tasks h2 { margin-top: 28px; }
.task-list { list-style: none; padding: 0; margin: 0; background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: 16px; overflow: hidden; }
.task-list li + li { border-top: 1px solid var(--line); }
.task { display: grid; grid-template-columns: 48px 1fr 20px; gap: 14px; align-items: center; padding: 16px 18px; text-decoration: none; color: var(--ink); min-height: 76px; }
a.task:hover { background: var(--accent-soft); color: var(--ink); }
.task .ico { width: 48px; height: 48px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-ink); display: grid; place-items: center; }
.task .ico svg { width: 28px; height: 28px; }
.task strong { display: block; font-size: 19px; line-height: 1.3; }
.task small { display: block; color: var(--ink-2); font-size: 15px; line-height: 1.4; margin-top: 2px; }
.task .go { width: 10px; height: 10px; border-right: 2.5px solid var(--ink-2); border-top: 2.5px solid var(--ink-2); transform: rotate(45deg); justify-self: center; }
.task .sublinks { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.task .sublinks a { font-size: 15px; font-weight: 600; padding: 6px 12px; border-radius: 99px; border: 1.5px solid var(--line-strong); text-decoration: none; color: var(--accent-ink); background: var(--surface); min-height: 36px; display: inline-flex; align-items: center; }
.task .sublinks a:hover { border-color: var(--accent); background: var(--accent-soft); }
div.task { grid-template-columns: 48px 1fr; }
.promises { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 32px; margin: 8px 0 0; padding: 0; list-style: none; }
.promises li { padding-left: 30px; position: relative; }
.promises li::before { content: ""; position: absolute; left: 0; top: 7px; width: 16px; height: 9px; border-left: 2.5px solid var(--accent); border-bottom: 2.5px solid var(--accent); transform: rotate(-45deg); }
.promises strong { display: block; }
.promises span { color: var(--ink-2); font-size: 16px; }
@media (max-width: 640px) { .promises { grid-template-columns: 1fr; } .task { padding: 14px; gap: 12px; } }
.next-list { padding-left: 20px; color: var(--ink-2); }
.next-list li { margin: 4px 0; }

/* Tags (kept for old markup) */
.tag { display: inline-block; font-size: 13px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--accent-soft); color: var(--accent-ink); }

/* Notices: amber and red only ever mean "check" and "stop" */
.notice { border-radius: 12px; padding: 14px 16px; margin: 12px 0; border: 1.5px solid var(--line); background: var(--surface); font-size: 16px; }
.notice.check { background: var(--check-bg); border-color: var(--check-line); color: var(--check-ink); }
.notice.stop { background: var(--stop-bg); border-color: var(--stop-line); color: var(--stop-ink); font-weight: 600; }
.notice.info { background: var(--accent-soft); border-color: transparent; }

/* Tool controls */
.step { margin: 0 0 24px; }
.step-title { font-weight: 800; margin: 0 0 10px; font-size: 18px; }
.choices { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; pointer-events: none; }
.choice label { display: block; border: 1.5px solid var(--line-strong); border-radius: 12px; padding: 12px 14px 12px 44px; cursor: pointer; background: var(--surface); min-height: 56px; position: relative; font-weight: 600; }
.choice label::before { content: ""; position: absolute; left: 14px; top: 15px; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-strong); background: var(--surface); }
.choice label small { display: block; color: var(--ink-2); font-size: 14px; font-weight: 400; }
.choice input:checked + label { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.choice input:checked + label::before { border-color: var(--accent); background: radial-gradient(circle, var(--accent) 0 5px, var(--surface) 5.5px); }
.choice input:focus-visible + label { outline: 3px solid var(--accent); outline-offset: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; pointer-events: none; }
.chip label { display: inline-block; border: 1.5px solid var(--line-strong); border-radius: 99px; padding: 10px 16px; cursor: pointer; background: var(--surface); font-weight: 600; min-width: 72px; min-height: 46px; text-align: center; font-variant-numeric: tabular-nums; }
.chip input:checked + label { border-color: var(--accent); background: var(--accent); color: #fff; }
.chip input:focus-visible + label { outline: 3px solid var(--accent); outline-offset: 2px; }
.fields { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); align-items: end; }
.field label { display: block; font-size: 15px; font-weight: 600; margin-bottom: 5px; }
.field input, .field select {
  width: 100%; font: inherit; font-size: 19px; padding: 11px 12px; border-radius: 10px; font-variant-numeric: tabular-nums;
  border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--ink); min-height: 52px;
}
.field select { appearance: none; -webkit-appearance: none; padding-right: 40px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; }
.field input:focus, .field select:focus { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
.field .hint { font-size: 14px; color: var(--ink-2); margin-top: 5px; }
.hint { color: var(--ink-2); font-size: 16px; }
.confirm { display: flex; gap: 12px; align-items: flex-start; margin-top: 14px; font-size: 16px; }
.confirm input { width: 24px; height: 24px; margin-top: 2px; accent-color: var(--accent); flex: none; }

/* Results */
.result { border: 2px solid var(--accent); border-radius: 14px; padding: 20px; background: var(--surface); margin-top: 8px; }
.result[hidden] { display: none; }
.result-main { display: flex; flex-wrap: wrap; gap: 6px 24px; align-items: baseline; }
.result-units { font-size: clamp(44px, 11vw, 64px); font-weight: 800; letter-spacing: -.02em; color: var(--accent-ink); line-height: 1; font-variant-numeric: tabular-nums; }
.result-units span { font-size: 22px; font-weight: 600; }
.result-ml { font-size: 22px; font-weight: 600; }
.result-sub { color: var(--ink-2); margin: 8px 0 0; font-size: 16px; }
.syringe-wrap { margin: 16px 0 6px; }
.reverse { font-size: 16px; background: var(--paper); border-radius: 10px; padding: 10px 12px; margin-top: 12px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.btn { font: inherit; font-weight: 600; font-size: 17px; border-radius: 12px; padding: 12px 18px; border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer; min-height: 50px; }
.btn:hover { border-color: var(--accent); }
.btn.primary, a.btn.primary:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.primary, a.btn.primary:hover, .chip input:checked + label { color: #08140f; } }
a.btn { display: inline-block; text-decoration: none; }
@media (max-width: 520px) { .actions .btn { flex: 1 1 100%; } }
.result.is-stop { border-color: var(--stop-line); }
.result.is-stop .result-units { color: var(--stop-ink); }
.result.is-stop #result-h { color: var(--stop-ink) !important; }
.placeholder { color: var(--ink-2); border: 1.5px dashed var(--line-strong); border-radius: 12px; padding: 20px; text-align: center; }

/* Articles */
.prose p, .prose li { max-width: var(--read); }
.prose table { border-collapse: collapse; width: 100%; max-width: 760px; font-size: 16px; background: var(--surface); }
.prose th, .prose td { border: 1px solid var(--line); padding: 9px 11px; text-align: left; vertical-align: top; }
.prose th { background: var(--accent-soft); }
.formula { font-variant-numeric: tabular-nums; font-weight: 600; background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: 10px; padding: 12px 14px; display: inline-block; }
.source-card { margin-top: 36px; font-size: 16px; }
.source-card h2 { font-size: 19px; margin-top: 0; }
.source-card ul { padding-left: 20px; }
details { background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px; padding: 0; margin: 10px 0; max-width: 760px; }
summary { cursor: pointer; font-weight: 600; padding: 14px 16px; min-height: 52px; }
details > p { padding: 0 16px 14px; margin: 0; }
details[open] summary { color: var(--accent-ink); }

/* Ad slots (fixed height so nothing shifts), kept away from tools */
.ad-slot { min-height: 280px; margin: 36px 0; display: grid; place-items: center; }
.ad-slot::before { content: "Advertisement"; font-size: 12px; color: var(--ink-2); }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; animation: none !important; } }
@media print {
  .site-header, .site-footer, .actions, .ad-slot, .no-print { display: none !important; }
  body { background: #fff; color: #000; font-size: 13pt; }
  .result { border-color: #000; }
}

/* Planners (week 2) */
.steps { display: grid; gap: 10px; margin: 10px 0 4px; }
.step-row { display: grid; grid-template-columns: 30px 1fr 1fr 44px; gap: 10px; align-items: end; background: var(--bg); border-radius: 12px; padding: 10px 12px; }
.step-no { width: 28px; height: 28px; border-radius: 99px; background: var(--accent); color: #fff; font-weight: 700; display: grid; place-items: center; margin-bottom: 11px; font-size: 14px; }
.with-unit { display: flex; align-items: center; gap: 8px; }
.with-unit input { flex: 1; min-width: 0; }
.with-unit span { color: var(--ink-2); font-size: 15px; }
.icon-btn { font: inherit; font-size: 22px; line-height: 1; width: 44px; height: 46px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink-2); cursor: pointer; margin-bottom: 2px; }
.icon-btn:hover { color: var(--stop-ink); border-color: var(--stop-line); }
@media (max-width: 520px) {
  .step-row { grid-template-columns: 30px 1fr 44px; }
  .step-row .field:nth-of-type(2) { grid-column: 2 / 3; }
  .step-row .icon-btn { grid-row: 1; grid-column: 3; }
}
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.plan, table.compare { border-collapse: collapse; width: 100%; font-size: 15px; background: var(--surface); }
table.plan th, table.plan td, table.compare th, table.compare td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
table.plan th, table.compare th { background: var(--bg); }
table.compare { min-width: 640px; max-width: none !important; }
.result h3 { margin-top: 4px; }
.dose-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; max-width: 420px; }
.dose-list li { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--line); padding: 4px 0; }
.routine { padding-left: 0; list-style: none; display: grid; gap: 8px; margin: 0; }
.routine li { background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.routine strong { display: block; color: var(--accent-ink); }
.missed { margin-top: 28px; }
.missed-box { border-radius: 12px; padding: 14px 16px; margin-top: 14px; border: 2px solid var(--line); }
.missed-box p { margin: 6px 0; }
.missed-box.take { border-color: var(--accent); background: var(--accent-soft); }
.missed-box.skip { border-color: var(--check-line); background: var(--check-bg); color: var(--check-ink); }
.missed-head { font-size: 20px; font-weight: 800; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
#pen-tool { margin: 28px 0; }
@media print { .tool .step, #missed, .prose, .source-card, #pl-warnings .notice.info { display: none !important; } .tool { border: 0; box-shadow: none; } }
.swipe { display: none; font-size: 14px; color: var(--ink-2); }
@media (max-width: 700px) { .swipe { display: block; } table.plan { font-size: 14px; } table.plan th, table.plan td { padding: 6px 7px; } }
@media (max-width: 640px) { .prose table:not(.compare) { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; font-size: 15px; } .prose th, .prose td { padding: 8px 9px; } }
.task { align-items: start; }
.task .go { align-self: center; }
@media (max-width: 640px) { .task { grid-template-columns: 40px 1fr 16px; } div.task { grid-template-columns: 40px 1fr; } .task .ico { width: 40px; height: 40px; border-radius: 10px; } .task .ico svg { width: 24px; height: 24px; } .task strong { font-size: 18px; } }
