:root {
  color-scheme: dark;
  --ink: #171914;
  --paper: #f3efe5;
  --quiet: #aeb3a8;
  --line-dark: rgba(243, 239, 229, 0.2);
  --line-light: rgba(23, 25, 20, 0.18);
  --coral: #ff7468;
  --green: #a7bb8e;
  --blue: #91b4c5;
  --yellow: #e4bd66;
}

* { box-sizing: border-box; }

html { background: var(--ink); }

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  background: var(--ink);
  color: var(--paper);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

a { color: inherit; }

.hero {
  position: relative;
  height: 58svh;
  min-height: 460px;
  max-height: 580px;
  overflow: hidden;
  background: #171914;
  isolation: isolate;
}

.hero::before {
  content: "";
  position: absolute;
  inset: -35% -20%;
  z-index: 0;
  background: linear-gradient(180deg, transparent 48%, rgba(255, 116, 104, 0.1) 50%, transparent 52%);
  opacity: 0.42;
  pointer-events: none;
  transform: translateY(-38%);
  animation: hero-scan 11s linear infinite;
}

.life-field {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.95;
  filter: contrast(1.04) saturate(0.9);
  pointer-events: none;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: rgba(11, 13, 10, 0.18);
  pointer-events: none;
}

.hero-inner {
  position: relative;
  z-index: 1;
  width: min(1240px, calc(100% - 64px));
  height: 100%;
  margin: 0 auto;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 72px;
  border-bottom: 1px solid var(--line-dark);
}

.identity {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--paper);
  font-size: 14px;
  font-weight: 650;
  text-decoration: none;
}

.identity-mark {
  position: relative;
  overflow: hidden;
  display: grid;
  flex: 0 0 29px;
  width: 29px;
  height: 29px;
  place-items: center;
  border: 1px solid rgba(243, 239, 229, 0.58);
  border-radius: 50%;
  clip-path: circle(50% at 50% 50%);
  contain: layout paint;
  font-family: Georgia, serif;
  font-size: 14px;
}

.identity-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.identity-mark img {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
  object-position: center;
  border-radius: 50%;
}

.identity-mark img[hidden] { display: none; }

.signal {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: #c9cdc4;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.signal-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #777d72;
}

.signal-dot.live {
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(167, 187, 142, 0.13);
  animation: signal-beat var(--beat-ms, 820ms) cubic-bezier(.2,.8,.25,1) infinite;
}

.signal-dot.stale { background: var(--yellow); }

.hero-copy {
  position: absolute;
  top: 48%;
  left: 0;
  width: min(800px, 76%);
  transform: translateY(-50%);
}

.last-seen {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 0 0 23px;
  color: #c7cbc2;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.last-seen::before {
  content: "";
  width: 38px;
  height: 1px;
  background: var(--coral);
}

h1 {
  margin: 0;
  color: #c1c5bc;
  font-size: 20px;
  font-weight: 580;
  line-height: 1.35;
}

.answer {
  max-width: 100%;
  margin: 9px 0 22px;
  color: var(--paper);
  font-family: "Songti SC", "STSong", Georgia, serif;
  font-size: 82px;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: 0;
  text-wrap: balance;
}

.answer.live::after {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-left: 18px;
  border-radius: 50%;
  background: var(--coral);
  vertical-align: 0.18em;
  animation: answer-beat var(--beat-ms, 820ms) cubic-bezier(.2,.8,.25,1) infinite;
}

.heartbeat-copy {
  margin: 0;
  color: #d5d8d0;
  font-size: 17px;
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
}

.hero-foot {
  position: absolute;
  right: 0;
  bottom: 20px;
  left: 0;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  color: #9da399;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.hero-foot p { margin: 0; }
.hero-rule { height: 1px; background: var(--line-dark); }

.day-strip {
  background: var(--paper);
  color: var(--ink);
  padding: 0 max(32px, calc((100% - 1240px) / 2));
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  min-height: 54px;
  padding: 11px 0 9px;
  border-bottom: 1px solid var(--line-light);
}

.section-heading p {
  margin: 0;
  font-family: "Songti SC", "STSong", Georgia, serif;
  font-size: 28px;
  font-weight: 700;
}

.section-heading span { color: #6f756d; font-size: 12px; }

.day-grid {
  display: grid;
  grid-template-columns: 1.35fr repeat(4, 1fr);
}

.reading {
  position: relative;
  min-width: 0;
  min-height: 130px;
  padding: 16px 18px 17px;
  border-left: 1px solid var(--line-light);
  overflow: hidden;
}

.reading:first-child { border-left: 0; padding-left: 0; }
.reading:last-child { padding-right: 0; }

.reading > p:first-child {
  min-height: 18px;
  margin: 0 0 13px;
  color: #697067;
  font-size: 13px;
  font-weight: 650;
}

.reading > div:not(.battery-track) {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.reading strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 35px;
  font-weight: 500;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.reading span { color: #646b62; font-size: 12px; font-weight: 650; }

.reading-note {
  margin: 8px 0 0;
  color: #777e75;
  font-size: 11px;
  line-height: 1.5;
}

.reading-heart strong { color: #ce514b; }
.reading-oxygen strong { color: #3e7b92; }
.reading-stress strong { color: #95691f; }

.mini-line {
  position: absolute;
  right: 20px;
  bottom: 14px;
  left: 0;
  width: calc(100% - 20px);
  height: 26px;
  opacity: 0.75;
}

.battery-track {
  width: 100%;
  height: 5px;
  margin-top: 14px;
  background: #d5d9d1;
  overflow: hidden;
}

.battery-track span {
  display: block;
  width: 0;
  height: 100%;
  background: #657f4f;
  transition: width 500ms ease;
}

.sleep-section {
  display: grid;
  grid-template-columns: minmax(280px, 0.82fr) minmax(360px, 1.18fr);
  gap: 48px;
  min-height: 220px;
  padding: 30px max(32px, calc((100% - 1240px) / 2));
  background: #b8c9b0;
  color: #172018;
}

.section-kicker {
  margin: 0 0 11px;
  color: #516050;
  font-size: 12px;
  font-weight: 700;
}

.sleep-copy h2 {
  max-width: 560px;
  margin: 0;
  font-family: "Songti SC", "STSong", Georgia, serif;
  font-size: 35px;
  line-height: 1.25;
  letter-spacing: 0;
  text-wrap: balance;
}

.sleep-copy > p:last-child {
  max-width: 520px;
  margin: 10px 0 0;
  color: #435143;
  font-size: 14px;
  line-height: 1.6;
}

.sleep-figure {
  align-self: center;
  padding-top: 3px;
}

.sleep-track {
  display: flex;
  width: 100%;
  height: 50px;
  gap: 3px;
  border-top: 1px solid rgba(23, 32, 24, 0.28);
  border-bottom: 1px solid rgba(23, 32, 24, 0.28);
  padding: 8px 0;
}

.sleep-segment {
  min-width: 3px;
  height: 100%;
  background: #697b8a;
}

.sleep-segment.deep { background: #303f5b; }
.sleep-segment.light { background: #6d879a; }
.sleep-segment.rem { background: #d0aa65; }
.sleep-segment.awake { background: #d36a5b; }

.sleep-legend {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.legend-item { min-width: 0; }
.legend-item::before { content: ""; display: block; width: 18px; height: 3px; margin-bottom: 9px; background: currentColor; }
.legend-item.deep { color: #303f5b; }
.legend-item.light { color: #556f82; }
.legend-item.rem { color: #8b631d; }
.legend-item.awake { color: #a4483c; }
.legend-item strong { display: block; color: #172018; font-size: 13px; }
.legend-item span { display: block; margin-top: 3px; color: #516050; font-size: 11px; font-variant-numeric: tabular-nums; }

.traces-section {
  padding: 28px max(32px, calc((100% - 1240px) / 2)) 26px;
  background: #e5e2d9;
  color: var(--ink);
}

.traces-heading {
  display: grid;
  grid-template-columns: minmax(260px, .82fr) minmax(320px, 1.18fr);
  gap: 48px;
  align-items: end;
  padding-bottom: 18px;
}

.traces-heading h2 {
  margin: 0;
  font-family: "Songti SC", "STSong", Georgia, serif;
  font-size: 31px;
  line-height: 1.2;
}

.traces-heading > p {
  max-width: 600px;
  margin: 0;
  color: #60665e;
  font-size: 13px;
  line-height: 1.65;
}

.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.chart-figure {
  position: relative;
  min-width: 0;
  margin: 0;
  padding: 15px 0 0;
  border-top: 1px solid var(--line-light);
}

.chart-heart { grid-column: 1 / -1; }
.chart-steps { padding-right: 28px; }
.chart-sleep { padding-left: 28px; border-left: 1px solid var(--line-light); }

.chart-figure figcaption {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  min-height: 36px;
}

.chart-figure figcaption div { display: flex; align-items: baseline; gap: 9px; }
.chart-figure figcaption span { color: #747a72; font-size: 11px; font-weight: 700; }
.chart-figure figcaption strong { font-size: 14px; }
.chart-figure figcaption p { margin: 0; color: #60665e; font-size: 11px; font-variant-numeric: tabular-nums; }

.chart-stage { position: relative; width: 100%; }
.chart-stage svg { display: block; width: 100%; height: 118px; overflow: visible; }
.chart-heart .chart-stage svg { height: 130px; }
.chart-axis { fill: #6b7169; font-size: 10px; font-variant-numeric: tabular-nums; }
.chart-grid-line { stroke: rgba(23, 25, 20, 0.12); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-heart-line { fill: none; stroke: #c9534d; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.chart-heart-line { stroke-dasharray: 1; stroke-dashoffset: 1; animation: chart-draw 850ms cubic-bezier(.2,.8,.25,1) forwards; }
.chart-heart-area { fill: url(#heartArea); opacity: 0; animation: chart-area-in 850ms ease-out 100ms forwards; }
.chart-heart-points circle { fill: #c9534d; opacity: 0.2; vector-effect: non-scaling-stroke; }
.chart-heart-dot { fill: #c9534d; stroke: #e5e2d9; stroke-width: 2; vector-effect: non-scaling-stroke; }
.chart-bar-steps { fill: #70855d; }
.chart-bar-sleep { fill: #637e91; }
.chart-bar-steps, .chart-bar-sleep {
  transform-box: fill-box;
  transform-origin: center bottom;
  animation: chart-bar-rise 620ms cubic-bezier(.2,.8,.25,1) both;
}
.chart-bar-delay-1 { animation-delay: 45ms; }
.chart-bar-delay-2 { animation-delay: 90ms; }
.chart-bar-delay-3 { animation-delay: 135ms; }
.chart-bar-delay-4 { animation-delay: 180ms; }
.chart-bar-delay-5 { animation-delay: 225ms; }
.chart-bar-delay-6 { animation-delay: 270ms; }
.chart-bar-missing { fill: rgba(23, 25, 20, 0.07); }
.chart-hover-line { stroke: rgba(23, 25, 20, 0.36); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-hit { fill: transparent; cursor: crosshair; touch-action: pan-y; }
.chart-empty { fill: #737971; font-size: 11px; }

.chart-tooltip {
  position: absolute;
  z-index: 2;
  max-width: 190px;
  padding: 7px 9px;
  border: 1px solid rgba(243, 239, 229, 0.18);
  border-radius: 3px;
  background: #1f221d;
  color: #f3efe5;
  box-shadow: 0 10px 28px rgba(23, 25, 20, 0.16);
  font-size: 11px;
  line-height: 1.45;
  pointer-events: none;
  transform: translate(-50%, -100%);
  font-variant-numeric: tabular-nums;
}

.page-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 64px;
  padding: 16px max(32px, calc((100% - 1240px) / 2));
  background: #171914;
  color: #aeb3a8;
  font-size: 12px;
}

.page-footer p { margin: 0; }
.page-footer a { color: var(--paper); text-underline-offset: 4px; }

@keyframes signal-beat {
  0%, 18%, 100% { transform: scale(1); }
  7% { transform: scale(1.7); }
  12% { transform: scale(1.16); }
}

@keyframes hero-scan {
  from { transform: translateY(-38%); }
  to { transform: translateY(38%); }
}

@keyframes chart-draw {
  to { stroke-dashoffset: 0; }
}

@keyframes chart-area-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes chart-bar-rise {
  from { transform: scaleY(0.08); opacity: 0.2; }
  to { transform: scaleY(1); opacity: 1; }
}

@keyframes answer-beat {
  0%, 18%, 100% { transform: scale(1); opacity: 0.72; }
  7% { transform: scale(1.48); opacity: 1; }
  12% { transform: scale(1.12); opacity: 0.9; }
}

@media (max-width: 960px) {
  .hero-inner { width: min(100% - 40px, 760px); }
  .answer { font-size: 68px; }
  .day-strip { padding: 0 20px; }
  .day-grid { grid-template-columns: repeat(3, 1fr); }
  .reading { min-height: 122px; border-bottom: 1px solid var(--line-light); }
  .reading:first-child { grid-column: span 2; }
  .reading:nth-last-child(-n+2) { border-bottom: 0; }
  .reading:nth-child(4) { border-left: 0; padding-left: 0; }
  .reading:last-child { padding-right: 24px; }
  .sleep-section { gap: 30px; padding: 30px 20px; }
  .traces-section { padding: 28px 20px 24px; }
  .traces-heading { gap: 30px; }
}

@media (max-width: 640px) {
  .hero { height: 40svh; min-height: 340px; max-height: 380px; }
  .hero-inner { width: calc(100% - 36px); }
  .site-header { min-height: 60px; }
  .identity { font-size: 13px; }
  .signal { max-width: 48%; justify-content: flex-end; text-align: right; font-size: 11px; }
  .hero-copy { top: 47%; width: 100%; }
  .last-seen { margin-bottom: 12px; font-size: 11px; }
  h1 { font-size: 17px; }
  .answer { margin: 7px 0 10px; font-size: 46px; line-height: 1.06; }
  .answer.live::after { width: 10px; height: 10px; margin-left: 10px; }
  .heartbeat-copy { max-width: 90%; font-size: 13px; }
  .hero-foot { bottom: 11px; grid-template-columns: 1fr auto; font-size: 10px; }
  .hero-rule { display: none; }
  .section-heading { min-height: 46px; padding: 9px 0 7px; }
  .section-heading p { font-size: 23px; }
  .day-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .reading { min-height: 92px; padding: 12px 12px; }
  .reading:first-child { grid-column: 1 / -1; min-height: 104px; padding-left: 0; padding-right: 0; border-left: 0; }
  .reading:nth-child(2), .reading:nth-child(4) { border-left: 0; padding-left: 0; }
  .reading:nth-child(3), .reading:nth-child(5) { padding-right: 0; }
  .reading:nth-child(4) { border-bottom: 0; }
  .reading > p:first-child { min-height: 14px; margin-bottom: 8px; font-size: 11px; }
  .reading strong { font-size: 29px; }
  .reading-note { margin-top: 5px; line-height: 1.35; }
  .mini-line { right: 0; width: 100%; }
  .sleep-section { display: grid; grid-template-columns: 1fr 1.2fr; gap: 14px; min-height: 0; padding: 20px 16px 22px; }
  .sleep-copy h2 { font-size: 24px; }
  .sleep-copy > p:last-child { margin-top: 8px; font-size: 10px; line-height: 1.4; }
  .sleep-figure { margin-top: 0; }
  .sleep-track { height: 40px; }
  .sleep-legend { grid-template-columns: repeat(2, 1fr); gap: 8px 6px; margin-top: 8px; }
  .legend-item::before { width: 12px; margin-bottom: 4px; }
  .legend-item strong { font-size: 10px; }
  .legend-item span { font-size: 9px; }
  .traces-section { padding: 20px 16px 18px; }
  .traces-heading { display: block; padding-bottom: 12px; }
  .traces-heading h2 { font-size: 24px; }
  .traces-heading > p { margin-top: 7px; font-size: 10px; }
  .chart-figure { padding-top: 10px; }
  .chart-heart .chart-stage svg { height: 92px; }
  .chart-stage svg { height: 84px; }
  .chart-steps { padding-right: 12px; }
  .chart-sleep { padding-left: 12px; }
  .chart-figure figcaption { display: block; min-height: 38px; }
  .chart-figure figcaption div { display: block; }
  .chart-figure figcaption span { display: block; margin-bottom: 2px; }
  .chart-figure figcaption p { margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .page-footer { min-height: 54px; padding: 12px 16px; line-height: 1.4; }
  .page-footer a { flex: 0 0 auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .chart-heart-line { stroke-dasharray: none; stroke-dashoffset: 0; }
  .chart-heart-area { opacity: 1; }
}
