:root {
  --ink: #1b1b1f;
  --muted: #6b6b75;
  --bg: #fbfaf8;
  --card: #ffffff;
  --line: #ece8e3;
  --red: #b3263a;
  --red-soft: #fbe9ec;
  --z1: #8fb8de; --z2: #6cc18a; --z3: #f2c14e; --z4: #f08a4b; --z5: #d64550;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 17px/1.65 Charter, "Iowan Old Style", Georgia, serif;
  color: var(--ink);
  background: var(--bg);
}
h1, h2, h3, nav, .eyebrow, .button, label, .bpm, .this-week, .zone-list, time, .foot, .muted.small, .head-row span {
  font-family: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
}
a { color: var(--red); }
.wrap { width: min(1080px, calc(100vw - 32px)); margin: 0 auto; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

.bar { border-bottom: 1px solid var(--line); background: rgba(251, 250, 248, .92); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 5; }
.bar-row { display: flex; justify-content: space-between; align-items: center; height: 62px; gap: 16px; }
.brand { color: var(--ink); text-decoration: none; font: 700 19px "Avenir Next", system-ui, sans-serif; letter-spacing: -.01em; }
.beat { color: var(--red); display: inline-block; animation: beat 1.1s ease-in-out infinite; }
@keyframes beat { 0%, 100% { transform: scale(1); } 14% { transform: scale(1.25); } 28% { transform: scale(1); } 42% { transform: scale(1.18); } }
nav { display: flex; gap: 20px; align-items: center; font-size: 15px; }
nav a { color: var(--ink); text-decoration: none; }
nav a:hover { color: var(--red); }
.pill { border: 1.5px solid var(--red); color: var(--red) !important; border-radius: 999px; padding: 5px 13px; }
.pill:hover { background: var(--red); color: #fff !important; }

.hero { display: grid; grid-template-columns: 1.2fr .8fr; gap: 40px; align-items: center; padding: 60px 0 30px; }
.eyebrow { color: var(--red); font-weight: 700; font-size: 13px; letter-spacing: .12em; text-transform: uppercase; margin: 0 0 12px; }
h1 { font-size: clamp(34px, 5vw, 56px); line-height: 1.05; letter-spacing: -.03em; margin: 0 0 20px; }
.lead { font-size: 20px; color: #3d3d45; margin: 0; max-width: 600px; }
.ecg { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 18px; box-shadow: 0 20px 50px rgba(179, 38, 58, .08); }
.ecg svg { width: 100%; height: 120px; display: block; }
#ecg-line { stroke-dasharray: 1400; stroke-dashoffset: 1400; animation: trace 3.2s linear infinite; }
@keyframes trace { to { stroke-dashoffset: 0; } }
.bpm { display: flex; align-items: baseline; gap: 10px; padding-top: 6px; }
.bpm b { font-size: 40px; color: var(--red); font-variant-numeric: tabular-nums; }
.bpm span { color: var(--muted); font-size: 14px; }

.block { padding: 46px 0 6px; }
.head-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
h2 { font-size: 30px; letter-spacing: -.02em; margin: 0; }
.head-row span { font-size: 14px; }

.log-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 22px; align-items: start; }
.chart, .this-week, .zone-list, .post, .signin-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; }
.chart { padding: 16px; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .bar-rect { fill: var(--red); opacity: .82; transform-origin: bottom; transform-box: fill-box; animation: grow .9s cubic-bezier(.2, .8, .2, 1) both; }
.chart .bar-rect.is-now { fill: #e0606f; }
.chart text { font: 12px "Avenir Next", system-ui, sans-serif; fill: var(--muted); }
@keyframes grow { from { transform: scaleY(0); } }
.this-week { list-style: none; margin: 0; padding: 8px 18px; font-size: 15px; }
.this-week li { display: grid; grid-template-columns: 44px 1fr; column-gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.this-week li:last-child { border-bottom: 0; }
.this-week span { color: var(--muted); grid-row: span 2; padding-top: 1px; }
.this-week em { font-style: normal; color: var(--muted); font-size: 13px; }

.zones { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; align-items: start; }
.zones p { margin: 12px 0 18px; }
.zone-form { display: flex; gap: 14px; flex-wrap: wrap; }
label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
input { font: inherit; font-size: 17px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; width: 150px; color: var(--ink); }
input:focus { outline: 2px solid var(--red-soft); border-color: var(--red); }
.zone-list { list-style: none; margin: 0; padding: 10px; }
.zone-list li { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 10px 12px; border-radius: 10px; }
.zone-list li + li { margin-top: 4px; }
.zone-list .zname { font-weight: 700; }
.zone-list .zrange { font-variant-numeric: tabular-nums; font-weight: 700; }
.zone-list .zbar { grid-column: 1 / -1; height: 6px; border-radius: 6px; background: currentColor; opacity: .85; transition: width .4s; }
.zone-list .zdesc { grid-column: 1 / -1; font-size: 13px; color: var(--muted); }

.posts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.post { padding: 20px; text-decoration: none; color: var(--ink); transition: transform .18s, box-shadow .18s; }
.post:hover { transform: translateY(-3px); box-shadow: 0 16px 30px rgba(0, 0, 0, .06); }
.post time { color: var(--red); font-size: 13px; font-weight: 600; }
.post h3 { font-size: 20px; margin: 6px 0 8px; line-height: 1.25; }
.post p { margin: 0; color: var(--muted); font-size: 16px; }

.coach { display: flex; justify-content: space-between; align-items: center; gap: 24px; background: var(--red-soft); border-radius: 18px; padding: 30px; margin-top: 46px; }
.coach p { margin: 10px 0 0; max-width: 640px; }
.button { display: inline-block; border: 0; background: var(--red); color: #fff; text-decoration: none; font-size: 16px; font-weight: 600; padding: 12px 20px; border-radius: 999px; cursor: pointer; white-space: nowrap; }
.button:hover { background: #941d2f; }
.button:disabled { opacity: .6; cursor: progress; }

.article { max-width: 720px; padding: 48px 0 10px; }
.article h1 { font-size: clamp(32px, 4.4vw, 46px); }
.article .meta { color: var(--muted); font: 14px "Avenir Next", system-ui, sans-serif; margin-bottom: 26px; }
.article h2 { font-size: 24px; margin-top: 34px; }
.article table { border-collapse: collapse; width: 100%; font: 15px "Avenir Next", system-ui, sans-serif; margin: 10px 0; }
.article th, .article td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.article .back { font: 15px "Avenir Next", system-ui, sans-serif; }

.signin { display: grid; place-items: center; min-height: calc(100vh - 170px); padding: 40px 0; }
.signin-card { width: min(440px, 100%); padding: 32px; }
.signin-card h1 { font-size: 32px; margin-bottom: 8px; }
.signin-card form { display: grid; gap: 14px; margin: 22px 0 14px; }
.signin-card input { width: 100%; }
.form-status { margin: 0; min-height: 1.4em; font: 14px "Avenir Next", system-ui, sans-serif; color: var(--muted); }
.form-status.is-bad { color: var(--red); }

.foot { border-top: 1px solid var(--line); margin-top: 60px; padding: 24px 0; font-size: 13px; color: var(--muted); }
.foot-row { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

@media (max-width: 900px) {
  .hero, .log-grid, .zones { grid-template-columns: 1fr; }
  .posts { grid-template-columns: 1fr; }
  .coach { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 560px) {
  nav a:not(.pill) { display: none; }
  .signin-page nav a { display: inline; }
}
@media (prefers-reduced-motion: reduce) {
  .beat, #ecg-line, .chart .bar-rect { animation: none; }
  #ecg-line { stroke-dashoffset: 0; }
}
