/* ==========================================================================
   Health tools (/health-tools/). Loaded by those pages only.
   ========================================================================== */
.health-page { max-width: 820px; }
.health-crumbs { margin: 0 0 .4rem; font-size: .95rem; }
.health-crumbs a { color: var(--link); }
.health-lede { font-size: 1.05rem; line-height: 1.55; margin: 0 0 1.5rem; }
.health-note {
  margin-top: 2rem; padding: 1rem 1.2rem; border-left: 4px solid var(--gold);
  background: var(--wash); border-radius: 0 var(--radius) var(--radius) 0; line-height: 1.55;
}
.health-note p { margin: 0 0 .6rem; }
.health-note p:last-child { margin-bottom: 0; }

.health-tools { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }
.health-tool {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper);
  padding: 1.1rem 1.25rem 1.25rem; box-shadow: var(--shadow);
}
.health-tool h2 { margin: 0 0 .4rem; font-size: 1.3rem; }
.health-tool h2 a { color: var(--heading); text-decoration: none; }
.health-tool h2 a:hover { text-decoration: underline; }
.health-tool p { margin: 0 0 .9rem; line-height: 1.5; }

/* --- The timer's display ------------------------------------------------ */
.tabata-panel {
  --phase-bg: var(--wash); --phase-ink: var(--ink); --phase-bar: var(--slate);
  background: var(--phase-bg); color: var(--phase-ink);
  border: 1px solid var(--line); border-radius: 14px;
  padding: 1.25rem clamp(1rem, 4vw, 2rem) 1.4rem; text-align: center;
  margin-bottom: 2rem; transition: background-color .3s;
}
/* Each step has its own colour, the same in light and dark mode, so it can
   be told at a glance across a room: orange to warm up and cool down, green
   to work, blue to rest. Navy text reads at well over 7:1 on all three. */
.tabata-panel[data-phase="warmup"],
.tabata-panel[data-phase="cooldown"] { --phase-bg: #f5a54a; --phase-ink: var(--navy); --phase-bar: var(--navy); border-color: #c97a1f; }
.tabata-panel[data-phase="work"] { --phase-bg: #6cc785; --phase-ink: var(--navy); --phase-bar: var(--navy); border-color: #3e9a58; }
.tabata-panel[data-phase="rest"],
.tabata-panel[data-phase="cyclerest"] { --phase-bg: #8ec1ee; --phase-ink: var(--navy); --phase-bar: var(--navy); border-color: #4f8fc9; }
.tabata-panel[data-phase="done"] { --phase-bar: var(--good-text); }
.tabata-phase {
  margin: 0; font-size: clamp(1.6rem, 6vw, 2.4rem); font-weight: 700;
  letter-spacing: .02em; text-transform: uppercase;
}
.tabata-time {
  margin: .1rem 0; font-size: clamp(4.5rem, 22vw, 9rem); font-weight: 700; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.tabata-where { margin: .4rem 0 0; font-size: 1.2rem; font-weight: 600; min-height: 1.5em; }
.tabata-next { margin: .2rem 0 0; font-size: 1.05rem; min-height: 1.4em; }
.tabata-left { margin: .4rem 0 0; font-size: .95rem; min-height: 1.3em; }
.tabata-progress {
  height: .6rem; margin: 1rem auto 0; max-width: 32rem; border-radius: 999px;
  background: rgba(13, 27, 42, .12); overflow: hidden;
}
.tabata-progress span { display: block; height: 100%; width: 0; background: var(--phase-bar); }
.tabata-controls {
  display: flex; flex-wrap: wrap; justify-content: center; gap: .6rem; margin-top: 1.2rem;
}
.tabata-controls .btn { min-width: 8.5rem; }
.tabata-controls .btn[disabled] { opacity: .45; cursor: default; }
.tabata-controls .tabata-start { min-width: 11rem; }
.tabata-panel:is([data-phase="warmup"], [data-phase="work"], [data-phase="rest"],
                [data-phase="cyclerest"], [data-phase="cooldown"]) .tabata-start { background: var(--navy); color: #fff; }
@media (prefers-reduced-motion: reduce) { .tabata-panel { transition: none; } }

/* --- Settings ----------------------------------------------------------- */
.tabata-form h2 { margin: 0 0 .2rem; }
.tabata-form.is-locked .tabata-field { opacity: .6; }
.tabata-presets { margin: 1rem 0 1.25rem; }
.tabata-presets-label { display: block; font-weight: 600; margin-bottom: .45rem; }
.tabata-presets [role="group"] { display: flex; flex-wrap: wrap; gap: .5rem; }
.tabata-presets .btn { white-space: normal; text-align: left; }
.tabata-field {
  border: 0; border-top: 1px solid var(--line-soft); margin: 0; padding: .9rem 0;
  min-width: 0;
}
.tabata-field[hidden] { display: none; }
.tabata-field legend { font-weight: 700; font-size: 1.1rem; padding: 0; float: left; width: 100%; margin-bottom: .45rem; }
.tabata-field legend + * { clear: both; }
.tabata-field .field-note { margin-top: .4rem; }
.tabata-duration, .tabata-count { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; }
.tabata-duration label { display: inline-flex; align-items: center; gap: .4rem; font-size: 1rem; }
.tabata-form input[type="number"] {
  font: inherit; font-size: 1.15rem; width: 5ch; box-sizing: content-box;
  padding: .5rem .6rem; border: 1px solid var(--field-border); border-radius: var(--radius);
  background: var(--paper); color: var(--ink); text-align: center;
}
.tabata-count { gap: .5rem; }
.tabata-stepper { font-size: 1.4rem; line-height: 1; width: 3rem; height: 3rem; padding: 0; }
.tabata-check { display: flex; gap: .6rem; align-items: flex-start; margin: .2rem 0 .6rem; line-height: 1.4; }
.tabata-check input { width: 1.3rem; height: 1.3rem; margin-top: .1rem; flex: none; }

.tabata-log { margin: 1rem 0 0; font-size: 1.05rem; font-weight: 600; }
.tabata-log a { color: inherit; }

/* --- The daily health log ------------------------------------------------ */
.log-private {
  padding: .8rem 1rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--wash); line-height: 1.5; margin: 0 0 1.75rem;
}
.log-form, .log-summary, .log-history-section { margin-bottom: 2.25rem; }
.log-form h2, .log-summary h2, .log-history-section h2 { margin: 0 0 .6rem; }
.log-field { border: 0; border-top: 1px solid var(--line-soft); margin: 0; padding: 1rem 0; min-width: 0; }
.log-field > label, .log-field legend { display: block; font-weight: 700; font-size: 1.1rem; padding: 0; margin-bottom: .5rem; }
/* A legend sits on its fieldset's top border unless it floats; floated, the
   divider runs above it, as it does above the plain labels. */
.log-field legend { float: left; width: 100%; }
.log-field legend + * { clear: both; }
.log-legend-note { margin: -.2rem 0 .6rem; }
.log-form input[type="date"], .log-form input[type="number"], .log-form input[type="text"], .log-form textarea {
  font: inherit; font-size: 1.05rem; padding: .5rem .6rem; color: var(--ink); background: var(--paper);
  border: 1px solid var(--field-border); border-radius: var(--radius); max-width: 100%; box-sizing: border-box;
}
.log-form input[type="number"] { width: 7ch; text-align: center; }
.log-form textarea { width: 100%; line-height: 1.45; }
.log-choices { display: flex; flex-wrap: wrap; gap: .5rem; }
.log-choice {
  display: inline-flex; align-items: center; gap: .45rem; cursor: pointer;
  padding: .5rem .85rem; border: 1px solid var(--line); border-radius: 999px; background: var(--paper);
}
.log-choice:has(input:checked) { border-color: var(--selected-border); background: var(--slate-light); font-weight: 600; }
.log-choice input { width: 1.15rem; height: 1.15rem; margin: 0; }
.log-numbers { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr)); gap: .9rem 1.5rem; }
.log-number { display: flex; flex-direction: column; gap: .3rem; }
.log-number > span:first-child { font-weight: 600; }
.log-unit { display: inline-flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.log-activities { list-style: none; margin: 0 0 .7rem; padding: 0; display: grid; gap: .7rem; }
.log-activity { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .5rem .8rem; }
.log-activity label { display: flex; flex-direction: column; gap: .25rem; font-weight: 600; }
.log-activity-what { flex: 1 1 13rem; }
.log-activity-what input { width: 100%; }
.log-save { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1.2rem; padding-top: 1rem; border-top: 1px solid var(--line-soft); }
.log-status { margin: 0; font-weight: 600; color: var(--good-text); }
.log-status.is-error { color: var(--danger-text); }
.log-status:empty { display: none; }

.log-summary { padding: 1.1rem 1.25rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow); }
.log-summary-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr)); gap: .9rem 1.5rem; margin: 0 0 .8rem; }
.log-summary-facts dt { font-size: .95rem; color: var(--ink-muted); }
.log-summary-facts dd { margin: .15rem 0 0; font-size: 1.2rem; font-weight: 700; }
.log-summary-activity { grid-column: 1 / -1; }
.log-goal { display: block; height: .6rem; margin-top: .4rem; border-radius: 999px; background: var(--line-soft); overflow: hidden; max-width: 32rem; }
.log-goal span { display: block; height: 100%; width: 0; background: var(--good-text); }

.log-history { list-style: none; margin: 0 0 1.5rem; padding: 0; display: grid; gap: .8rem; }
.log-entry { border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1.1rem; background: var(--paper); }
.log-entry h3 { margin: 0 0 .5rem; font-size: 1.1rem; }
.log-facts { margin: 0; display: grid; gap: .25rem; }
.log-facts div { display: grid; grid-template-columns: minmax(7.5rem, 11rem) 1fr; gap: .8rem; }
.log-facts dt { color: var(--ink-muted); }
.log-facts dd { margin: 0; overflow-wrap: anywhere; white-space: pre-line; }
.log-entry-actions { display: flex; gap: .5rem; margin: .7rem 0 0; }
.log-delete { color: var(--danger-text); }
.log-tools { border-top: 1px solid var(--line-soft); padding-top: 1rem; margin-top: 1rem; }
.log-tools h3 { margin: 0 0 .5rem; font-size: 1.1rem; }
.log-tool-buttons { display: flex; flex-wrap: wrap; gap: .5rem; }
.log-restore { cursor: pointer; }
.log-restore:focus-within { outline: 3px solid var(--gold); outline-offset: 2px; }
@media (max-width: 479.98px) {
  .log-facts div { grid-template-columns: 1fr; gap: 0; }
  .log-facts div + div { margin-top: .35rem; }
}

/* --- Videos (health_app/_videos.html, video.js) ---------------------------- */
.health-videos { list-style: none; margin: 1rem 0 .6rem; padding: 0; display: grid; gap: 1.25rem;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr)); }
.health-video { margin: 0; }
.health-video-frame { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden;
  background: var(--navy); }
.health-video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.health-video-play { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: .35rem; color: #fff; text-decoration: none;
  background: linear-gradient(135deg, var(--navy), var(--navy-soft)); }
.health-video-play:hover .health-video-icon, .health-video-play:focus-visible .health-video-icon { background: var(--gold-dark); }
.health-video-play:focus-visible { outline: 3px solid var(--gold); outline-offset: -3px; }
.health-video-icon { display: grid; place-items: center; width: 3.6rem; height: 3.6rem; border-radius: 50%;
  background: var(--gold); color: var(--navy); font-size: 1.5rem; padding-left: .2rem; box-sizing: border-box; }
.health-video-label { font-weight: 700; font-size: 1.05rem; }
.health-video-length { font-size: .9rem; opacity: .85; }
.health-video-title { margin: .6rem 0 .15rem; font-size: 1.05rem; }
.health-video-source { margin: 0 0 .3rem; font-size: .92rem; color: var(--ink-muted); }
.health-video-about { margin: 0; line-height: 1.45; }

/* --- Fall risk check ----------------------------------------------------- */
.falls-section { margin: 0 0 2.5rem; }
.falls-section > h2 { margin: 0 0 .6rem; }
.falls-questions { margin: 1rem 0; padding-left: 1.6rem; display: grid; gap: .2rem; }
.falls-question { padding: .7rem 0; border-top: 1px solid var(--line-soft); }
.falls-question fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.falls-question legend { float: left; width: 100%; padding: 0; margin-bottom: .55rem; font-size: 1.08rem; font-weight: 600; line-height: 1.4; }
.falls-question legend + * { clear: both; }
.falls-points { font-weight: 400; font-size: .92rem; color: var(--ink-muted); }
.falls-advice { margin-top: .7rem; padding: .7rem .9rem; border-left: 4px solid var(--slate); background: var(--wash);
  border-radius: 0 var(--radius) var(--radius) 0; line-height: 1.5; }
.falls-advice p { margin: 0 0 .35rem; }
.falls-advice p:last-child { margin: 0; }
.falls-result { padding: 1rem 1.2rem; border: 2px solid var(--line); border-radius: var(--radius); background: var(--paper);
  box-shadow: var(--shadow); margin-bottom: .8rem; }
.falls-result.is-risk { border-color: #c97a1f; }
.falls-result.is-low { border-color: var(--good-text); }
.falls-result p { margin: 0 0 .5rem; }
.falls-progress { font-weight: 600; }
.falls-score { font-size: 1.35rem; }
.falls-verdict { font-size: 1.08rem; line-height: 1.5; }
.falls-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .8rem !important; }
.falls-home-count { font-weight: 700; color: var(--good-text); }
.falls-home { display: grid; gap: .4rem; }
.falls-room { border: 0; border-top: 1px solid var(--line-soft); margin: 0; padding: .8rem 0 .2rem; min-width: 0; }
.falls-room legend { float: left; width: 100%; padding: 0; margin-bottom: .5rem; font-weight: 700; font-size: 1.1rem; }
.falls-room legend + * { clear: both; }
.falls-list { margin: .6rem 0 0; padding-left: 1.3rem; display: grid; gap: .55rem; line-height: 1.5; }

/* --- Walking plan --------------------------------------------------------- */
.walk-why, .walk-builder, .walk-tips, .walk-videos { margin: 0 0 2.5rem; }
.walk-why h2, .walk-builder h2, .walk-tips h2, .walk-videos h2 { margin: 0 0 .6rem; }
.walk-benefits { margin: 0 0 .8rem; padding-left: 1.3rem; display: grid; gap: .6rem; line-height: 1.5; }
.walk-builder { padding: 1.1rem 1.25rem 1.25rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--paper); box-shadow: var(--shadow); }
.walk-fields { display: grid; gap: .9rem 1.5rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); }
.walk-field { display: flex; flex-direction: column; gap: .35rem; font-weight: 600; }
.walk-field select { font: inherit; font-weight: 400; font-size: 1.05rem; padding: .5rem .6rem; color: var(--ink);
  background: var(--paper); border: 1px solid var(--field-border); border-radius: var(--radius); max-width: 100%; }
.walk-summary { font-size: 1.12rem; font-weight: 600; line-height: 1.5; margin: 1.1rem 0 .8rem; }
.walk-weeks { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.walk-week { border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem 1rem; background: var(--paper); }
.walk-week.is-current { border: 2px solid var(--selected-border); background: var(--wash); }
.walk-week.is-done { border-color: var(--good-text); }
.walk-week.is-done .walk-week-title::after { content: " \2713  done"; color: var(--good-text); }
.walk-week-title { margin: 0 0 .2rem; font-size: 1.08rem; }
.walk-week-what { margin: 0 0 .5rem; }
.walk-ticks { display: flex; flex-wrap: wrap; gap: .4rem; }
.walk-tick { display: inline-flex; align-items: center; gap: .4rem; padding: .4rem .75rem; border: 1px solid var(--line);
  border-radius: 999px; background: var(--paper); cursor: pointer; }
.walk-tick:has(input:checked) { border-color: var(--good-text); font-weight: 600; }
.walk-tick input { width: 1.15rem; height: 1.15rem; margin: 0; }
.walk-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1rem 0 0; }

@media print {
  .walk-actions, .walk-videos, .walk-form .field-note, .falls-actions, .falls-section:has(.health-videos) { display: none !important; }
  .walk-builder, .falls-result { box-shadow: none; }
  .walk-week { break-inside: avoid; }
}

/* Printing the log: the summary and the days, nothing to click. */
@media print {
  .navbar, .site-footer, .skip-link, .log-form, .log-tools, .log-entry-actions,
  .log-private, .health-crumbs, .health-lede, .health-note, .community-thread { display: none !important; }
  .log-entry, .log-summary { box-shadow: none; break-inside: avoid; }
}
