:root {
  --bg: #f4f3ef;
  --card: #ffffff;
  --ink: #15171c;
  --muted: #80838f;
  --line: #e7e6e1;
  --grid: #eeede8;
  --accent: #0e9f8a;
  --alert: #f0442e;
  --state: var(--accent);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Mona Sans Variable", "Mona Sans", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.stage {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: clamp(12px, 3vw, 28px);
}

/* ---- the card ---- */
.card {
  position: relative;
  width: min(780px, 100%);
  padding: clamp(14px, 3.4vh, 24px) clamp(14px, 3.4vw, 26px) clamp(12px, 2.8vh, 20px);
  border-radius: clamp(20px, 3vw, 28px);
  background: var(--card);
  box-shadow:
    0 0 0 1px var(--line),
    0 1px 1px rgba(21, 23, 28, 0.04),
    0 14px 30px -14px rgba(21, 23, 28, 0.16),
    0 46px 80px -40px color-mix(in srgb, var(--state) 34%, rgba(21, 23, 28, 0.2));
  transition: box-shadow 0.6s ease;
}
.card.is-bad { --state: var(--alert); }

.head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.service {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: clamp(14px, 1.3vw, 16px);
  font-weight: 560;
  letter-spacing: -0.005em;
  white-space: nowrap;
}
.service__mark {
  width: 26px;
  height: 26px;
  padding: 4px;
  border-radius: 9px;
  background: var(--ink);
  fill: none;
  stroke: #ffffff;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---- the status pill ---- */
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 11px 0 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--state) 11%, #ffffff);
  color: color-mix(in srgb, var(--state) 78%, #15171c);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color 0.4s ease, color 0.4s ease;
}
.status__icon {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.status__bad { opacity: 0; }
.card.is-bad .status__ok { opacity: 0; }
.card.is-bad .status__bad { opacity: 1; }
.status__ok, .status__bad { transition: opacity 0.2s ease; }
.status__roll {
  display: inline-block;
  overflow: hidden;
  height: 28px;
  line-height: 28px;
}
.status__word { display: inline-block; }

/* ---- the reading ---- */
.read {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-top: clamp(8px, 2.4vh, 18px);
}
.read__n {
  font-size: clamp(34px, min(8vw, 9.5vh), 68px);
  line-height: 1;
  font-weight: 640;
  font-stretch: 92%;
  letter-spacing: -0.03em;
  color: color-mix(in srgb, var(--state) 0%, var(--ink));
  transition: color 0.4s ease;
}
.card.is-bad .read__n { color: color-mix(in srgb, var(--alert) 82%, var(--ink)); }
.read__n small {
  margin-left: 4px;
  font-size: 0.36em;
  font-weight: 560;
  letter-spacing: 0;
  color: var(--muted);
}
.read__label {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

/* ---- the chart ---- */
.chart {
  position: relative;
  margin-top: clamp(8px, 2vh, 16px);
  height: clamp(104px, 34vh, 300px);
  touch-action: pan-y;
  cursor: crosshair;
}
.chart__svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.chart__grid line { stroke: var(--grid); stroke-width: 1; }
.chart__line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.chart__line--hot { stroke: var(--alert); }
.chart__limit {
  stroke: color-mix(in srgb, var(--alert) 55%, #b9b8b2);
  stroke-width: 1.2;
  stroke-dasharray: 3 5;
  stroke-linecap: round;
}
.chart__head { fill: var(--state); transition: fill 0.3s ease; }
.chart__hair { stroke: var(--ink); stroke-width: 1; opacity: 0; }
.chart__mark { fill: var(--ink); opacity: 0; }
.chart .flag line { stroke: var(--alert); stroke-width: 1.2; opacity: 0.55; }
.chart .flag path { fill: var(--alert); }

.limit {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
}
.limit span {
  display: inline-block;
  transform: translateY(-50%);
  height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--alert) 34%, #ffffff);
  color: color-mix(in srgb, var(--alert) 80%, #15171c);
  font-size: 11px;
  font-weight: 600;
  line-height: 20px;
  white-space: nowrap;
  transition: background-color 0.3s ease, color 0.3s ease;
}
.card.is-bad .limit span { background: var(--alert); color: #ffffff; }

.tip {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 6px 10px 7px;
  border-radius: 11px;
  background: rgba(21, 23, 28, 0.9);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: #ffffff;
  font-size: 12px;
  line-height: 1.25;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  box-shadow: 0 8px 18px -8px rgba(21, 23, 28, 0.5);
}
.tip b { font-weight: 620; font-variant-numeric: tabular-nums; }
.tip span { color: rgba(255, 255, 255, 0.62); font-size: 11px; }

/* ---- the foot ---- */
.foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: clamp(8px, 2vh, 14px);
  padding-top: clamp(8px, 2vh, 13px);
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
}
.foot b { font-weight: 600; color: var(--ink); }
.foot__n {
  display: inline-block;
  overflow: hidden;
  vertical-align: bottom;
  height: 1.3em;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}
.foot__n span { display: inline-block; }

.ghost {
  position: fixed;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  pointer-events: none;
  fill: #15171c;
  stroke: #ffffff;
  stroke-width: 1.4;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 4px rgba(21, 23, 28, 0.3));
  opacity: 0;
  z-index: 5;
}

@media (max-width: 420px) {
  .read__label { font-size: 12px; }
  .service { font-size: 13.5px; }
}
