/* ==========================================================================
   GlucoRead landing page — the paper logbook.

   The page is the glucose diary clinics hand to new insulin users, laid open
   on its own sage book-cloth cover: each section is one spread (or one
   fold-out page) of that diary. Tokens and faces come from main/css/warm.css;
   primitives (.btn, .badge, the theme switch, the drawer) from theme.css.

   Two rules hold the page together:

     1. Handwriting is what a person logs; print is what GlucoRead works out.
        Biro (Kalam, --biro) is only ever an entry. Totals, labels, copy and
        controls are printed.
     2. Colour is information. Biro navy is glucose, plum is insulin, ochre is
        meals, leaf green is in range — and red is reserved for "above range".
        Nothing decorative is red.
   ========================================================================== */

/* ------------------------------- utilities -------------------------------- */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.ink-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* Figures are data: lining, fixed-width digits stop a value from shuffling
   sideways when the unit switch rewrites it. */
.diary-table tfoot,
.unit-value,
.tir-value,
.stage-axis {
  font-variant-numeric: tabular-nums lining-nums;
}

.hand {
  font-family: var(--font-hand);
  font-weight: 400;
  color: var(--biro);
  letter-spacing: 0;
}

/* ---------------------------------- ink -----------------------------------
   Every hand-drawn mark (rings, ticks, underlines) is one path with
   pathLength="1". Drawn by default; the script marks the root ink-ready and
   each mark then waits for its section to arrive before it draws on — the
   page's one motion. */
.ink {
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.9s var(--ease);
}

.ink-ready .reveal:not(.show) .ink {
  stroke-dashoffset: 1;
}

/* the hero's marks draw once on load: they are above the fold, so there is
   nothing to wait for */
.hero .ink {
  animation: ink-draw 1s var(--ease) 0.5s both;
}

.hero .circled .ink {
  animation-delay: 1.1s;
}

@keyframes ink-draw {
  from {
    stroke-dashoffset: 1;
  }
}

.underlined {
  position: relative;
  white-space: nowrap;
}

.ink-under {
  position: absolute;
  left: -2%;
  bottom: -0.02em;
  max-width: none;
  width: 104%;
  height: 0.32em;
  color: var(--biro);
  stroke-width: 4;
}

.circled {
  position: relative;
  display: inline-block;
}

.ink-ring {
  position: absolute;
  max-width: none;
  left: 50%;
  top: 50%;
  width: 3.4em;
  height: 1.7em;
  margin: -0.85em 0 0 -1.7em;
  color: var(--warn);
  stroke-width: 2.6;
  pointer-events: none;
}

/* ------------------------------- the cover -------------------------------- */
/* The body is the sage cloth (warm.css .cloth). Everything readable sits on a
   page; only the topbar, the closer and the footer print straight onto the
   cover, in cloth ink. */

/* The topbar sits on the cover, so it borrows cover colours for the shared
   primitives inside it. Scoped custom properties, not copied selectors. */
.topbar {
  --paper: var(--cloth);
  --accent: var(--cloth-ink);
  --accent-ink: var(--cloth-2);
  --paper-2: rgba(0, 0, 0, 0.18);
  --line-soft: rgba(255, 255, 255, 0.16);
  --line: rgba(255, 255, 255, 0.26);
  --ink: var(--cloth-ink);
  --ink-2: var(--cloth-ink-2);
  --ink-3: var(--cloth-ink-2);
  color: var(--cloth-ink);
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.3rem;
  letter-spacing: 0;
}


.menu > a:not(.btn) {
  color: var(--cloth-ink-2);
}

.menu > a:not(.btn):hover {
  color: var(--cloth-ink);
}

.menu-login {
  font-weight: 600;
}

.menu-spacer {
  flex: 1;
}

/* ------------------------------- buttons ---------------------------------- */
.btn {
  font-weight: 700;
  letter-spacing: 0.005em;
}

.btn-lg {
  font-size: 1.02rem;
  padding: 0.85rem 1.35rem;
}

/* A rubber stamp: the fill, then a thin inner frame in the fill's own ink. */
.btn-stamp {
  box-shadow:
    inset 0 0 0 3px var(--stamp-gap, var(--accent-strong)),
    inset 0 0 0 4px color-mix(in srgb, currentColor 45%, transparent),
    var(--shadow-sm);
}

.btn-stamp:hover {
  box-shadow:
    inset 0 0 0 3px var(--stamp-gap, var(--accent-strong-hover)),
    inset 0 0 0 4px color-mix(in srgb, currentColor 55%, transparent),
    var(--shadow-lg);
}

.btn-quiet {
  border-color: var(--ink-3);
}

.btn-quiet:hover {
  border-color: var(--ink);
  background: color-mix(in srgb, var(--ink) 5%, transparent);
}

/* on the cover: a paper button and a cloth one */
.btn-paper {
  --stamp-gap: var(--cloth-ink);
  background: var(--cloth-ink);
  color: var(--cloth-2);
  box-shadow: var(--shadow-sm);
}

.btn-paper:hover {
  --stamp-gap: #fffaf0;
  background: #fffaf0;
  transform: translateY(-2px);
}

.btn-cloth {
  color: var(--cloth-ink);
  border-color: color-mix(in srgb, var(--cloth-ink) 55%, transparent);
  background: transparent;
}

.btn-cloth:hover {
  border-color: var(--cloth-ink);
  background: rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

/* ------------------------------ the spreads ------------------------------- */
.section {
  padding-top: clamp(1.75rem, 4vw, 3.25rem);
}

.hero {
  padding-top: clamp(0.5rem, 1.5vw, 1rem);
}

.spread {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  color: var(--ink);
  background: var(--paper);
  border-radius: 3px;
  box-shadow: var(--shadow-lg);
}

.page {
  position: relative;
  min-width: 0;
  padding: clamp(1.75rem, 4.2vw, 4rem) clamp(1.35rem, 4.2vw, 4rem) clamp(2.75rem, 5vw, 4.5rem);
}

.page-full {
  grid-column: 1 / -1;
}

/* The gutter: the paper darkens into the fold between the two pages. Drawn on
   the left page so a full-width page never has a fold through its text. */
.page-left::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  right: -36px;
  width: 72px;
  pointer-events: none;
  background: linear-gradient(
    to right,
    transparent,
    rgba(70, 50, 20, 0.07) 38%,
    rgba(70, 50, 20, 0.2) 50%,
    rgba(70, 50, 20, 0.07) 62%,
    transparent
  );
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .page-left::after {
    background: linear-gradient(
      to right,
      transparent,
      rgba(0, 0, 0, 0.18) 38%,
      rgba(0, 0, 0, 0.45) 50%,
      rgba(0, 0, 0, 0.18) 62%,
      transparent
    );
  }
}

:root[data-theme="dark"] .page-left::after {
  background: linear-gradient(
    to right,
    transparent,
    rgba(0, 0, 0, 0.18) 38%,
    rgba(0, 0, 0, 0.45) 50%,
    rgba(0, 0, 0, 0.18) 62%,
    transparent
  );
}

.page-right {
  margin: 0;
}

/* page numbers, the way a printed booklet has them */
.folio {
  position: absolute;
  bottom: clamp(1rem, 2vw, 1.5rem);
  left: clamp(1.35rem, 4.2vw, 4rem);
  font-family: var(--font-display);
  font-size: 0.82rem;
  color: var(--ink-3);
}

.page-right .folio {
  left: auto;
  right: clamp(1.35rem, 4.2vw, 4rem);
}

/* The diary's double red margin rule. It sits inside the page as printed
   ruling, not along an edge. */
.ruled-page {
  --margin-x: clamp(2.1rem, 4.4vw, 3.6rem);
  background:
    linear-gradient(
      to right,
      transparent var(--margin-x),
      var(--margin) var(--margin-x) calc(var(--margin-x) + 1px),
      transparent calc(var(--margin-x) + 1px) calc(var(--margin-x) + 4px),
      var(--margin) calc(var(--margin-x) + 4px) calc(var(--margin-x) + 5px),
      transparent calc(var(--margin-x) + 5px)
    );
}

/* -------------------------------- type ------------------------------------ */
h1,
h2,
.form-title,
.notices h3 {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: -0.01em;
}

h2 {
  font-size: clamp(1.9rem, 3.6vw, 2.9rem);
  line-height: 1.08;
}

.page p {
  text-wrap: pretty;
  color: var(--ink-2);
  font-size: 1.0625rem;
  line-height: 1.65;
}

.page-head {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: 1.25rem clamp(2rem, 5vw, 5rem);
  align-items: end;
  margin-bottom: clamp(1.75rem, 3.5vw, 2.75rem);
}

.page-head p {
  max-width: 46ch;
}

.split-copy {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.split-copy h2 {
  margin-bottom: 0.4rem;
}

.split-copy p {
  max-width: 44ch;
}

.lede-strong {
  font-family: var(--font-display);
  font-size: 1.3rem !important;
  line-height: 1.35 !important;
  color: var(--ink) !important;
}

/* ---------------------------------- hero ---------------------------------- */
.hero-spread {
  min-height: min(calc(100svh - 68px - 2.5rem), 760px);
}

.hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1.5rem;
}

.hero-title {
  font-size: clamp(2.6rem, 5.4vw, 4.6rem);
  line-height: 1.03;
  letter-spacing: -0.015em;
  max-width: 11ch;
}

.hero-lead {
  font-size: clamp(1.1rem, 1.5vw, 1.25rem) !important;
  max-width: 34ch;
}

.hero-copy .actions {
  margin-top: 0.4rem;
}

.hero-meta {
  font-size: 0.9rem !important;
  color: var(--ink-3) !important;
}

/* the right page: one example day, written in */
.diary {
  display: flex;
  flex-direction: column;
  padding-left: calc(var(--margin-x) + 0.9rem);
}

.diary-date {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--rule);
}

.field-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-3);
}

.diary-date .hand {
  font-size: 1.35rem;
  line-height: 1;
}

.diary-table {
  width: 100%;
  border-collapse: collapse;
}

.diary-table th {
  padding: 0 0.4rem 0.45rem;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  vertical-align: bottom;
  color: var(--ink-2);
}

.diary-table thead th:first-child {
  text-align: left;
  padding-left: 0;
}

.diary-table thead th {
  border-bottom: 1.5px solid var(--ink-3);
}

.diary-table .unit {
  display: block;
  font-weight: 400;
  color: var(--ink-3);
}

.diary-table tbody td {
  height: 2.05rem;
  padding: 0 0.4rem;
  font-size: 1.2rem;
  line-height: 1;
  text-align: center;
  border-bottom: 1px solid var(--rule);
}

.diary-table tbody td:first-child {
  padding-left: 0;
  text-align: left;
  font-size: 1.05rem;
  color: color-mix(in srgb, var(--biro) 72%, var(--paper));
}

.diary-table .col-note {
  text-align: left;
}

.diary-table tbody .col-note {
  font-size: 1rem;
  color: color-mix(in srgb, var(--biro) 72%, var(--paper));
}

.diary-table .g {
  color: var(--biro);
  font-weight: 700;
}

.diary-table .i {
  color: var(--insulin);
}

.diary-table .m {
  color: var(--meal);
}

.diary-table tr.is-high .g {
  color: var(--warn);
}

/* the printed totals line — the part the paper diary never did */
.diary-table tfoot th,
.diary-table tfoot td {
  padding: 0.7rem 0.4rem 0;
  font-family: var(--font-sans);
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--ink);
  text-align: center;
  vertical-align: top;
  border-top: 3px double var(--ink-2);
}

.diary-table tfoot th {
  text-align: left;
  padding-left: 0;
}

.diary-table tfoot .col-note {
  text-align: left;
  color: var(--range-deep);
}

.total-label,
.total-sub {
  font-weight: 400;
  color: var(--ink-3);
}

.total-label {
  font-size: 0.8rem;
}

.total-sub {
  display: block;
  font-size: 0.78rem;
}

.margin-note {
  align-self: flex-end;
  margin-top: 0.85rem;
  font-size: 1.2rem;
  transform: rotate(-3deg);
  color: var(--biro);
}

.diary-caption {
  margin-top: auto;
  padding-top: 1.25rem;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--ink-3);
  max-width: 52ch;
}

/* -------------------------------- the stage -------------------------------
   The diary's graph page. The SVG is held between 620px and 900px wide; its
   text is sized in viewBox units, so that window keeps every label legible.
   Below 620px the figure scrolls sideways inside its own box. */
.stage-wrap {
  margin: 0;
}

.tick-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.4rem;
}

.stage-steps {
  margin-bottom: 1.1rem;
}

.tick-option {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 44px;
  padding: 0 0.15rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink-2);
  background: none;
  border: 0;
  cursor: pointer;
  transition: color 0.2s var(--ease);
}

.tick-option:hover,
.tick-option[aria-pressed="true"] {
  color: var(--ink);
}

.tickbox {
  position: relative;
  display: inline-block;
  width: 1.3rem;
  height: 1.3rem;
  flex: none;
  border: 1.5px solid var(--ink-3);
  border-radius: 2px;
  background: var(--surface);
  transition: border-color 0.2s var(--ease);
}

.tick-option:hover .tickbox {
  border-color: var(--ink);
}

/* the tick overshoots its box, the way a quick biro tick does */
.tickbox .ink {
  position: absolute;
  inset: -30% -35% -10% -10%;
  width: 145%;
  height: 140%;
  color: var(--biro);
  stroke-width: 2.6;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset 0.4s var(--ease);
}

.tick-option[aria-pressed="true"] .tickbox .ink {
  stroke-dashoffset: 0;
}

/* The stage's steps are cumulative ("+ Target range"), so every step up to
   the current one stays ticked; aria-pressed still marks only the current. */
.stage-wrap[data-current="2"] [data-step="1"] .tickbox .ink,
.stage-wrap[data-current="3"] [data-step="1"] .tickbox .ink,
.stage-wrap[data-current="3"] [data-step="2"] .tickbox .ink {
  stroke-dashoffset: 0;
}

.tick-option:focus-visible {
  outline: 2px solid var(--biro);
  outline-offset: 2px;
  border-radius: 3px;
}

.graph-paper {
  background-color: var(--surface);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 18px 18px;
  border: 1px solid var(--rule);
  border-radius: 2px;
}

.stage-scroll {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding: 0.75rem 0.5rem 0.25rem;
}

.stage-scroll:focus-visible {
  outline: 2px solid var(--biro);
  outline-offset: 3px;
}

.stage {
  width: 100%;
  min-width: 620px;
  max-width: 900px;
  height: auto;
  margin-inline: auto;
}

.stage text {
  font-family: var(--font-sans);
}

.stage-axis,
.stage-lane-label {
  font-size: 13px;
  fill: var(--ink-3);
}

.stage-value {
  font-family: var(--font-hand) !important;
  font-size: 17px;
  fill: var(--biro);
}

.stage-value.is-high {
  fill: var(--warn);
  font-weight: 700;
}

.stage-layer {
  opacity: 0;
  transition: opacity 0.5s var(--ease);
}

.stage-wrap[data-current="2"] .stage-layer[data-from="2"],
.stage-wrap[data-current="3"] .stage-layer[data-from="2"],
.stage-wrap[data-current="3"] .stage-layer[data-from="3"] {
  opacity: 1;
}

.stage-focus rect {
  fill: var(--warn-wash);
  stroke: var(--warn-soft);
  stroke-dasharray: 5 4;
}

.stage-band rect {
  fill: var(--range-wash);
}

.stage-band line {
  stroke: var(--range);
  stroke-width: 1;
  stroke-dasharray: 4 4;
  opacity: 0.7;
}

.stage-trace polyline {
  fill: none;
  stroke: var(--biro);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset 0.9s var(--ease);
}

.stage-wrap[data-current="2"] .stage-trace polyline,
.stage-wrap[data-current="3"] .stage-trace polyline {
  stroke-dashoffset: 0;
}

.stage-points circle {
  fill: var(--biro);
  stroke: var(--surface);
  stroke-width: 2;
}

/* Out of range is never colour alone: the dot is larger, the value is bolder,
   and the caption and the hidden table both say "high". */
.stage-points circle.is-high {
  fill: var(--warn);
}

.stage-lane-rule {
  stroke: var(--rule);
  stroke-width: 1;
}

.lane-insulin {
  fill: var(--insulin);
}

/* Basal is the flat background dose; the app leaves it uncoloured, and
   --ink-2 is what .t-neutral resolves --tone to, so mark and swatch agree. */
.lane-basal {
  fill: var(--ink-2);
}

.lane-meal {
  fill: var(--meal);
}

.stage-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.4rem;
  margin: 0.9rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.88rem;
  color: var(--ink-2);
}

.stage-legend li {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.stage-legend svg {
  width: 12px;
  height: 12px;
  flex: none;
  fill: var(--tone);
}

.stage-hint {
  display: none;
  margin-top: 0.5rem;
  font-size: 0.82rem !important;
  color: var(--ink-3) !important;
}

.stage-caption {
  margin-top: 1rem;
  max-width: 56ch;
  min-height: 3.3em;
  color: var(--ink);
  font-size: 1.02rem;
  line-height: 1.6;
}

.beat {
  margin-top: clamp(1.75rem, 3.5vw, 2.5rem);
  font-size: clamp(1.4rem, 2.6vw, 1.9rem) !important;
  line-height: 1.3 !important;
  color: var(--biro) !important;
  transform: rotate(-1deg);
  transform-origin: left center;
}

/* -------------------------------- entries ---------------------------------
   The diary's printed column guide: one ruled row per column, what it is for
   on the left, its fields filled in once in that column's own ink. */
.guide {
  border-bottom: 1px solid var(--line);
}

.guide-row {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: 1.25rem clamp(2rem, 5vw, 4.5rem);
  padding-block: clamp(1.5rem, 3vw, 2.1rem);
  border-top: 1px solid var(--line);
}

.guide-what {
  display: grid;
  align-content: start;
  gap: 0.6rem;
}

/* The column's name heads its row of sample fields, the way a diary prints
   a ruled column header, underlined in that column's own ink. */
.guide-entry {
  display: grid;
  align-content: end;
  gap: 0.85rem;
}

.guide-col {
  padding-bottom: 0.35rem;
  font-size: 0.82rem !important;
  font-weight: 700;
  color: var(--tone-ink) !important;
  border-bottom: 2px solid var(--tone);
}

.guide-row h3 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.35rem;
  line-height: 1.25;
}

.guide-what > p:last-child {
  font-size: 1rem !important;
  max-width: 42ch;
}

.guide-fields {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-content: end;
  gap: 1.25rem;
}

.guide-fields > div {
  align-content: end;
}

.guide-fields dd {
  border-bottom-color: color-mix(in srgb, var(--tone) 35%, transparent);
}

.form-lines {
  margin: 0;
  display: grid;
  gap: 0.85rem;
}

.form-lines > div {
  display: grid;
  gap: 0.1rem;
}

.form-lines dt {
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--ink-3);
}

.form-lines dd {
  margin: 0;
  padding: 0.1rem 0 0.2rem;
  font-size: 1.25rem;
  line-height: 1.2;
  color: var(--tone-ink, var(--biro));
  border-bottom: 1px solid var(--rule);
}

.hand-aside {
  font-size: 0.95rem;
  color: var(--ink-3);
}

/* -------------------------------- history --------------------------------- */
.week {
  display: flex;
  flex-direction: column;
  padding-left: calc(var(--margin-x) + 0.9rem);
}

.week-table {
  width: 100%;
  border-collapse: collapse;
}

.week-table th {
  padding: 0 0.5rem 0.5rem;
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
  color: var(--ink-2);
  border-bottom: 1.5px solid var(--ink-3);
}

.week-table thead th:first-child,
.week-table tbody th {
  text-align: left;
  padding-left: 0;
}

.week-table tbody th {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--ink-2);
  border-bottom: 1px solid var(--rule);
}

.week-table td {
  height: 4.25rem;
  padding: 0 0.5rem;
  font-size: 1.45rem;
  line-height: 1;
  text-align: center;
  border-bottom: 1px solid var(--rule);
}

.week-table td small {
  display: block;
  margin-top: 0.35rem;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  color: var(--ink-3);
}

/* the column the pattern runs down */
.week-table .col-evening {
  background: var(--warn-wash);
}

.week-table td.is-high {
  color: var(--warn);
  font-weight: 700;
}

.week-table td.is-empty::after {
  content: "";
  display: block;
  width: 1.1rem;
  height: 1px;
  margin-inline: auto;
  background: var(--ink-3);
  opacity: 0.6;
}

.week-note {
  margin-right: 0.5rem;
}

.week .diary-caption {
  margin-top: 1.5rem;
}

/* -------------------------------- targets --------------------------------- */
.targets {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.form-title {
  font-size: 1.45rem;
  line-height: 1.2;
}

.range-demo {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.25rem;
  margin: 0;
}

.range-demo dd {
  font-size: 1.6rem;
  color: var(--biro);
}

.unit-value.is-swapping {
  animation: rewrite 0.45s var(--ease);
}

@keyframes rewrite {
  from {
    opacity: 0;
    filter: blur(3px);
  }
}

/* a printed 2–14 mmol/L scale; the band and the dot are placed on it */
.range-bar {
  position: relative;
  height: 22px;
  margin-top: 0.5rem;
}

.range-bar::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1.5px;
  background: var(--ink-3);
}

.range-band {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 15.83%; /* 3.9 on a 2–14 scale */
  width: 50.84%; /* to 10.0 */
  background: var(--range-soft);
  border: 1px solid var(--range);
  border-radius: 2px;
}

.range-dot {
  position: absolute;
  top: 50%;
  left: 35%; /* 6.2 */
  width: 13px;
  height: 13px;
  margin: -6.5px 0 0 -6.5px;
  border-radius: 50%;
  background: var(--biro);
  box-shadow: 0 0 0 2px var(--paper);
}

.range-caption {
  font-size: 0.95rem !important;
}

.tir-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin: 0.75rem 0 0;
  padding-top: 1.1rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink-2);
  border-top: 1px solid var(--line);
}

.tir-value {
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 400;
  color: var(--ink);
}

.tir {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tir li {
  display: grid;
  place-items: center;
  height: 3.1rem;
  font-size: 1.3rem;
  border: 1px solid var(--rule);
  border-radius: 2px;
}

.tir .is-in {
  background: var(--range-wash);
  border-color: var(--range-soft);
}

.tir .is-high .unit-value {
  color: var(--warn);
  font-weight: 700;
}

.tir .ink-ring {
  width: 3.6em;
  margin-left: -1.8em;
}

.range-meter-foot {
  font-size: 0.9rem !important;
  color: var(--ink-3) !important;
}

/* -------------------------------- everyday -------------------------------- */
.moments {
  margin: 0.2rem 0 0.3rem;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.6rem;
}

.moments li {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--ink);
}

.moments .ink {
  width: 1.5rem;
  height: 1.5rem;
  margin-top: 0.05rem;
  flex: none;
  color: var(--range);
}

.moments li:nth-child(2) .ink {
  transition-delay: 0.15s;
}

.moments li:nth-child(3) .ink {
  transition-delay: 0.3s;
}

.slip-page {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* a slip of the app, tucked into the diary */
.slip {
  position: relative;
  padding: clamp(1.25rem, 3vw, 2rem);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 2px;
  box-shadow: var(--shadow-sm), 0 14px 28px -18px rgba(47, 36, 26, 0.45);
  transform: rotate(-1.2deg);
}

.slip-desc {
  margin-top: 0.3rem;
  font-size: 0.92rem !important;
}

.slip-form {
  display: grid;
  gap: 1rem;
  margin-top: 1.35rem;
}

.slip-field {
  display: grid;
  gap: 0.35rem;
}

.slip-label {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink);
}

.slip-label em {
  font-style: normal;
  font-weight: 400;
  color: var(--ink-3);
}

.slip-input {
  display: block;
  padding: 0.45rem 0.8rem;
  font-size: 1.25rem;
  line-height: 1.4;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 3px;
}

.slip-input.is-select {
  background-image: var(--select-chevron);
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  background-size: 16px 16px;
}

.slip-input.is-empty {
  font-size: 0.95rem;
  line-height: 1.85;
  color: var(--ink-3);
}

.slip-hint {
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--ink-2);
}

.slip-submit {
  justify-self: start;
  margin-top: 0.25rem;
  padding: 0.6rem 1.1rem;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--accent-strong);
  border-radius: 4px;
}

.slip-page .diary-caption {
  margin-top: 1.5rem;
}

/* --------------------------------- privacy -------------------------------- */
.notices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 clamp(2rem, 5vw, 5rem);
  margin: 0;
  padding: 0;
  list-style: none;
}

.notices li {
  display: grid;
  align-content: start;
  gap: 0.55rem;
  padding-block: 1.4rem 1.6rem;
  border-top: 1px solid var(--line);
}

.notices h3 {
  font-size: 1.3rem;
  line-height: 1.25;
}

.notices p {
  max-width: 48ch;
}

.text-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  width: fit-content;
  font-weight: 700;
  color: var(--accent-strong);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.text-link:hover {
  text-decoration-thickness: 2px;
}

/* --------------------------------- closer ---------------------------------
   The back cover: the cloth, with the booklet's printed label pasted on it,
   framed by a double printed rule the way clinic booklets label their covers. */
.closer {
  padding-block: clamp(3.5rem, 8vw, 6rem);
}

.cover-label {
  display: grid;
  justify-items: center;
  gap: 1.2rem;
  max-width: 640px;
  margin-inline: auto;
  padding: clamp(2rem, 5vw, 3.25rem) clamp(1.5rem, 5vw, 3.5rem);
  text-align: center;
  color: var(--ink);
  background: var(--paper);
  border-radius: 3px;
  box-shadow:
    inset 0 0 0 10px var(--paper),
    inset 0 0 0 11px var(--ink-3),
    inset 0 0 0 14px var(--paper),
    inset 0 0 0 15px var(--ink-3),
    var(--shadow-lg);
}

.cover-label h2 {
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  line-height: 1.04;
  max-width: 12ch;
}

.cover-label p {
  max-width: 40ch;
  font-size: 1.08rem;
  line-height: 1.6;
  color: var(--ink-2);
  text-wrap: pretty;
}

.cover-label .actions {
  justify-content: center;
  margin-top: 0.3rem;
}

/* --------------------------------- footer --------------------------------- */
.site-footer {
  padding-block: 2.25rem 2.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--cloth-ink-2);
  font-size: 0.9rem;
}

.footer-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1.25rem 2rem;
  align-items: center;
}

.footer-brand {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.footer-brand .brand-name {
  color: var(--cloth-ink);
}

.footer-tagline {
  margin-left: 0.35rem;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.4rem;
}

.footer-nav a {
  color: var(--cloth-ink);
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 4px;
  transition: text-decoration-color 0.2s var(--ease);
}

.footer-nav a:hover {
  text-decoration-color: currentColor;
}

.footer-disclaimer {
  grid-column: 1 / -1;
  max-width: 70ch;
  font-size: 0.84rem;
  line-height: 1.55;
}

/* focus on the cover reads in cloth ink */
.topbar :focus-visible,
.closer :focus-visible,
.site-footer :focus-visible {
  outline-color: var(--cloth-ink);
}

:focus-visible {
  outline-color: var(--biro);
}

/* ------------------------------- responsive ------------------------------- */
@media (max-width: 960px) {
  .spread {
    grid-template-columns: minmax(0, 1fr);
  }

  .page-left::after {
    display: none;
  }

  /* stacked, the right page follows on below a fold line */
  .page-right {
    border-top: 1px dashed var(--line);
  }

  .hero-spread {
    min-height: 0;
  }

  .hero-title {
    max-width: 13ch;
  }

  .page-head {
    grid-template-columns: minmax(0, 1fr);
  }

  .guide-row {
    grid-template-columns: minmax(0, 1fr);
  }

  /* stacked, the pages run on, so only the right page keeps its number */
  .page-left .folio {
    display: none;
  }

  .page-left {
    padding-bottom: clamp(1.75rem, 4.2vw, 4rem);
  }

  .notices {
    grid-template-columns: minmax(0, 1fr);
  }

  .slip {
    transform: none;
  }
}

@media (max-width: 860px) {
  /* the drawer opens over the cover */
  .topbar .menu {
    background: var(--cloth);
  }

  .topbar .menu .btn {
    margin-top: 0.75rem;
  }
}

@media (max-width: 700px) {
  .stage-hint {
    display: block;
  }
}

@media (max-width: 560px) {
  .container {
    padding-inline: 1rem;
  }

  .page {
    padding-inline: 1.25rem;
  }

  .diary,
  .week {
    padding-left: calc(var(--margin-x) + 0.6rem);
  }

  .diary-table .col-note {
    display: none;
  }

  .diary-table tbody td {
    font-size: 1.1rem;
  }

  .diary-table th {
    font-size: 0.72rem;
    padding-inline: 0.2rem;
  }

  .week-table td {
    font-size: 1.25rem;
  }

  .range-demo {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .range-demo > div:last-child {
    grid-column: 1 / -1;
  }

  .guide-fields {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.85rem;
  }

  .tir li {
    font-size: 1.1rem;
  }

  .actions .btn {
    flex: 1 1 100%;
  }

  .footer-inner {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero .ink {
    animation: none;
  }

  .ink-ready .reveal:not(.show) .ink {
    stroke-dashoffset: 0;
  }
}

/* Diaries open on a filled-in example page; this one says so, so no figure
   in the first viewport can be mistaken for a real reading. */
.sample-mark {
  margin-left: auto;
  padding: 0.15rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink-2);
  border: 1px solid var(--ink-3);
  border-radius: 2px;
  transform: rotate(2deg);
}
