Heart Rate Zone Calculator
:root {
–bg: #FAF9F6;
–panel: #12161F;
–text: #14171F;
–text-soft: #4A4F5C;
–accent: #B8912F;
–rule: #D8D5CC;
–font: ‘Helvetica Neue’, Arial, Helvetica, sans-serif;
}
* { box-sizing: border-box; }
body {
margin: 0;
font-family: var(–font);
background: var(–bg);
color: var(–text);
}
.hrz-widget {
max-width: 640px;
margin: 0 auto;
padding: 32px 28px;
background: var(–bg);
}
.hrz-title {
font-weight: 700;
font-size: 20px;
letter-spacing: -0.01em;
margin: 0 0 6px;
color: var(–text);
}
.hrz-sub {
font-size: 14px;
color: var(–text-soft);
margin: 0 0 24px;
line-height: 1.5;
}
.hrz-form {
display: flex;
gap: 16px;
flex-wrap: wrap;
align-items: flex-end;
margin-bottom: 28px;
padding-bottom: 24px;
border-bottom: 1px solid var(–rule);
}
.hrz-field {
display: flex;
flex-direction: column;
gap: 6px;
}
.hrz-field label {
font-size: 12px;
font-weight: 600;
letter-spacing: 0.04em;
text-transform: uppercase;
color: var(–text-soft);
}
.hrz-field input {
font-family: var(–font);
font-size: 16px;
padding: 10px 12px;
border: 1px solid var(–rule);
border-radius: 2px;
width: 130px;
background: #fff;
color: var(–text);
}
.hrz-field input:focus {
outline: none;
border-color: var(–accent);
}
.hrz-btn {
font-family: var(–font);
font-size: 15px;
font-weight: 600;
letter-spacing: 0.01em;
background: var(–panel);
color: #F3F1EB;
border: none;
border-radius: 2px;
padding: 11px 24px;
cursor: pointer;
transition: opacity 0.15s ease;
}
.hrz-btn:hover { opacity: 0.88; }
.hrz-error {
font-size: 13px;
color: #A33;
margin: -18px 0 20px;
display: none;
}
table.hrz-table {
width: 100%;
border-collapse: collapse;
font-size: 14px;
display: none;
}
.hrz-table th, .hrz-table td {
text-align: left;
padding: 12px 10px 12px 0;
border-bottom: 1px solid var(–rule);
}
.hrz-table th {
font-size: 10.5px;
letter-spacing: 0.07em;
text-transform: uppercase;
color: var(–text-soft);
font-weight: 700;
}
.hrz-table td.zone-name { font-weight: 600; }
.hrz-table td.bpm {
font-weight: 700;
color: var(–accent);
white-space: nowrap;
}
.hrz-table td.purpose {
color: var(–text-soft);
font-size: 13px;
}
.hrz-footnote {
font-size: 11.5px;
color: var(–text-soft);
margin-top: 18px;
line-height: 1.5;
}
function hrzCalculate() {
var age = parseFloat(document.getElementById(‘hrz-age’).value);
var rhr = parseFloat(document.getElementById(‘hrz-rhr’).value);
var errorEl = document.getElementById(‘hrz-error’);
var tableEl = document.getElementById(‘hrz-table’);
var footEl = document.getElementById(‘hrz-footnote’);
if (!age || !rhr || age 100 || rhr 120) {
errorEl.style.display = ‘block’;
tableEl.style.display = ‘none’;
footEl.style.display = ‘none’;
return;
}
errorEl.style.display = ‘none’;
// Tanaka formula for max heart rate (more accurate than 220-age, especially over 40)
var maxHR = 208 – (0.7 * age);
var hrr = maxHR – rhr; // Heart Rate Reserve (Karvonen method)
var zones = [
{ id: ‘hrz-z1’, low: 0.50, high: 0.60 },
{ id: ‘hrz-z2’, low: 0.60, high: 0.70 },
{ id: ‘hrz-z3’, low: 0.70, high: 0.80 },
{ id: ‘hrz-z4’, low: 0.80, high: 0.90 },
{ id: ‘hrz-z5’, low: 0.90, high: 1.00 }
];
zones.forEach(function(z) {
var lowBpm = Math.round((hrr * z.low) + rhr);
var highBpm = Math.round((hrr * z.high) + rhr);
document.getElementById(z.id).textContent = lowBpm + ‘–’ + highBpm + ‘ bpm’;
});
tableEl.style.display = ‘table’;
footEl.textContent = ‘Estimated max heart rate: ‘ + Math.round(maxHR) + ‘ bpm (Tanaka formula: 208 − 0.7 × age). Calculated using the Karvonen method (Heart Rate Reserve). These are general estimates — consult your physician before starting a new exercise program, especially if you have a cardiovascular condition.’;
footEl.style.display = ‘block’;
}
