/* Dew Not Resuscitate — soda-can green world, one black patient monitor. */
:root {
  --can: #0B4A24;        /* deep can green, the page */
  --can-2: #0F5E2E;      /* lighter can green, panels */
  --can-3: #14753A;      /* highlight on the can */
  --can-ink: #062A14;    /* darkest green, text on lime */
  --lime: #C8F531;       /* neon citrus, actions + scores */
  --phosphor: #5CFF8F;   /* monitor trace */
  --cyan: #53E6F5;       /* SpDEW readout */
  --alarm: #FF3B4A;      /* code red */
  --monitor: #040806;    /* the monitor glass */
  --cream: #F4F8E6;      /* body text */
  --muted: #A9C7A6;      /* secondary text */

  --display: "Shrikhand", "Georgia", serif;
  --mono: "Share Tech Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --body: "Barlow Semi Condensed", "Avenir Next Condensed", system-ui, sans-serif;

  --gutter: 16px;
  --radius: 18px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--can-ink);
  color: var(--cream);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* The app column reads as one aluminum can: dark edges, bright middle. */
.app {
  position: relative;
  max-width: 480px;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 14px) calc(env(safe-area-inset-right) + var(--gutter)) calc(env(safe-area-inset-bottom) + 20px) calc(env(safe-area-inset-left) + var(--gutter));
  background:
    linear-gradient(90deg, rgba(0,0,0,.28) 0%, rgba(255,255,255,0) 18%, rgba(255,255,255,.07) 38%, rgba(255,255,255,0) 58%, rgba(0,0,0,.30) 100%),
    linear-gradient(180deg, var(--can-2) 0%, var(--can) 55%, #083A1C 100%);
  overflow-x: hidden;
}

.screen { animation: screen-in .35s cubic-bezier(.2,.8,.2,1); }
@keyframes screen-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

:focus-visible { outline: 3px solid var(--lime); outline-offset: 3px; border-radius: 6px; }

/* ---------- Buttons ---------- */
.btn {
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: 60px; padding: 0 20px;
  border: 0; border-radius: 16px;
  font-family: var(--body); font-weight: 700; font-size: 19px; letter-spacing: .04em; text-transform: uppercase;
  cursor: pointer; touch-action: manipulation;
  transition: transform .12s ease, box-shadow .12s ease, background-color .2s;
}
.btn:active { transform: translateY(2px); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-primary {
  background: var(--lime); color: var(--can-ink);
  box-shadow: 0 4px 0 #7EA316, 0 10px 24px rgba(200,245,49,.18);
}
.btn-primary:active { box-shadow: 0 2px 0 #7EA316, 0 6px 14px rgba(200,245,49,.14); }
.btn-ghost { background: transparent; color: var(--lime); box-shadow: inset 0 0 0 2px rgba(200,245,49,.55); }
.btn-quiet { background: transparent; color: var(--muted); min-height: 48px; font-size: 16px; }

.iconbtn {
  display: grid; place-items: center;
  width: 44px; height: 44px; border: 0; border-radius: 12px;
  background: rgba(0,0,0,.22); color: var(--cream); cursor: pointer;
}
.iconbtn svg { width: 22px; height: 22px; }
.linkbtn { background: none; border: 0; padding: 8px 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; font-size: 14px; cursor: pointer; }

/* ---------- Wristband ---------- */
.band {
  display: flex; align-items: center; gap: 10px;
  height: 34px; padding: 0 6px 0 14px;
  border-radius: 17px;
  background: var(--cream); color: var(--can-ink);
  font-family: var(--mono); font-size: 13px; letter-spacing: .06em;
  box-shadow: 0 2px 0 rgba(0,0,0,.25);
}
.band-name { font-family: var(--body); font-weight: 700; font-size: 15px; letter-spacing: .08em; }
.band-mrn { opacity: .7; white-space: nowrap; }
.band-code {
  flex: 1; height: 18px; min-width: 30px;
  background: repeating-linear-gradient(90deg, var(--can-ink) 0 2px, transparent 2px 4px, var(--can-ink) 4px 5px, transparent 5px 8px, var(--can-ink) 8px 11px, transparent 11px 12px);
  opacity: .85;
}
.band-dnr {
  padding: 3px 9px; border-radius: 12px;
  background: var(--alarm); color: #fff;
  font-family: var(--body); font-weight: 700; font-size: 14px; letter-spacing: .1em;
}

/* ---------- Home ---------- */
.wordmark {
  margin: 22px 0 4px;
  font-family: var(--display); font-weight: 400;
  font-size: clamp(38px, 11.5vw, 54px); line-height: .95;
  color: var(--lime);
  text-shadow: 0 3px 0 var(--can-ink), 0 0 28px rgba(200,245,49,.25);
  transform: rotate(-2deg); transform-origin: left center;
}
.wordmark span { display: block; color: var(--cream); font-size: .82em; }
.greet { margin: 14px 0 16px; color: var(--muted); font-size: 18px; }
.greet #greet-line { color: var(--cream); font-weight: 600; }
.greet-date { display: block; font-family: var(--mono); font-size: 14px; letter-spacing: .04em; }

/* ---------- Monitor (the signature) ---------- */
.monitor {
  position: relative;
  padding: 12px 14px 14px;
  border-radius: var(--radius);
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(92,255,143,.06), transparent 60%),
    var(--monitor);
  box-shadow:
    0 0 0 3px #1B2B20,
    0 0 0 6px #0A140D,
    0 18px 40px rgba(0,0,0,.45),
    inset 0 0 40px rgba(0,0,0,.8);
  font-family: var(--mono);
}
.mon-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 26px; }
.mon-label { color: var(--phosphor); font-size: 14px; letter-spacing: .05em; text-transform: uppercase; }
.mon-hr { color: var(--phosphor); display: flex; align-items: baseline; gap: 6px; }
.mon-hr small, .vital small, .mon-stats dt { font-size: 11px; letter-spacing: .12em; opacity: .75; }
.mon-hr b { font-size: 26px; font-weight: 400; text-shadow: 0 0 10px rgba(92,255,143,.6); }

.ekg { display: block; width: 100%; height: 96px; margin: 6px 0 4px; }
.ekg-big { height: 128px; }

.mon-score { display: flex; align-items: baseline; gap: 12px; margin: 2px 0 12px; }
.mon-score b { font-weight: 400; font-size: 52px; line-height: 1; color: var(--lime); text-shadow: 0 0 16px rgba(200,245,49,.45); }
.mon-score span { color: var(--cream); font-family: var(--body); font-weight: 600; font-size: 18px; }

.mon-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 0; padding-top: 10px; border-top: 1px solid rgba(92,255,143,.16); }
.mon-stats div { min-width: 0; }
.mon-stats dt { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mon-stats dd { margin: 2px 0 0; color: var(--cyan); font-size: 24px; line-height: 1.1; }

.home-actions { margin: 26px 0 0; }
.today-actions { display: grid; gap: 12px; }

/* ---------- 30-day chart ---------- */
.chart-card {
  margin-top: 28px; padding: 16px 14px 12px;
  border-radius: var(--radius);
  background: rgba(0,0,0,.2);
  box-shadow: inset 0 0 0 1px rgba(244,248,230,.08);
}
.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.chart-head h2 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.chart-readout { font-family: var(--mono); font-size: 13px; color: var(--muted); text-align: right; }
.chart { display: block; width: 100%; height: auto; touch-action: pan-y; }
.chart .bar { fill: var(--phosphor); opacity: .75; transition: opacity .15s; }
.chart .bar.record { fill: var(--lime); opacity: 1; }
.chart .bar.sel { opacity: 1; }
.chart .gap { fill: rgba(244,248,230,.18); }
.chart .guide { stroke: rgba(244,248,230,.14); stroke-dasharray: 3 4; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart-axis { display: flex; justify-content: space-between; margin-top: 6px; font-family: var(--mono); font-size: 12px; color: var(--muted); }

.foot { margin-top: 30px; text-align: center; color: var(--muted); font-size: 14px; }
.foot p { margin: 0 0 6px; }
.foot a { color: var(--cream); }

/* ---------- Rounds ---------- */
.screen-rounds { display: flex; flex-direction: column; min-height: calc(100svh - 34px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
.rounds-head { display: flex; align-items: center; gap: 12px; }
.progress { display: flex; gap: 6px; flex: 1; justify-content: center; margin: 0; padding: 0; list-style: none; }
.progress li { width: 22px; height: 34px; color: rgba(244,248,230,.25); transition: color .25s, transform .25s; }
.progress li svg { width: 100%; height: 100%; display: block; }
.progress li.done { color: var(--lime); }
.progress li.now { color: var(--cream); transform: translateY(-3px); }
.step-count { min-width: 44px; white-space: nowrap; text-align: right; font-family: var(--mono); font-size: 14px; color: var(--muted); }

.step { flex: 1; display: flex; flex-direction: column; }
.step-inner { flex: 1; display: flex; flex-direction: column; padding-top: 18px; }
.step-inner.fwd { animation: step-fwd .32s cubic-bezier(.2,.8,.2,1); }
.step-inner.back { animation: step-back .32s cubic-bezier(.2,.8,.2,1); }
@keyframes step-fwd { from { opacity: 0; transform: translateX(36px); } to { opacity: 1; transform: none; } }
@keyframes step-back { from { opacity: 0; transform: translateX(-36px); } to { opacity: 1; transform: none; } }

.eyebrow { margin: 0; font-family: var(--mono); font-size: 14px; letter-spacing: .14em; text-transform: uppercase; color: var(--lime); }
.q { margin: 6px 0 0; font-size: clamp(28px, 8vw, 34px); line-height: 1.08; font-weight: 700; }

.gauge { flex: 1; display: flex; align-items: center; justify-content: center; gap: 18px; margin: 18px 0 8px; }
.can { height: clamp(200px, 34svh, 290px); width: auto; flex: none; overflow: visible; filter: drop-shadow(0 12px 18px rgba(0,0,0,.35)); }
.can .liquid { transition: transform .45s cubic-bezier(.3,1.4,.5,1); }
.can .wave { animation: wave 2.4s linear infinite; }
.can .bubble { animation: bubble 2.8s ease-in infinite; opacity: 0; }
.can .bubble:nth-child(2) { animation-delay: .7s; animation-duration: 3.4s; }
.can .bubble:nth-child(3) { animation-delay: 1.5s; animation-duration: 2.6s; }
.can .bubble:nth-child(4) { animation-delay: 2.1s; animation-duration: 3.1s; }
@keyframes wave { from { transform: translateX(-60px); } to { transform: translateX(0); } }
@keyframes bubble { 0% { transform: translateY(0); opacity: 0; } 15% { opacity: .9; } 100% { transform: translateY(-150px); opacity: 0; } }

.readout { display: flex; flex-direction: column; align-items: flex-start; font-family: var(--mono); line-height: 1; }
.readout b { font-weight: 400; font-size: 96px; color: var(--meter, var(--lime)); text-shadow: 0 0 22px color-mix(in srgb, var(--meter, var(--lime)) 45%, transparent); transition: color .3s; }
.readout span { font-size: 20px; color: var(--muted); margin-top: 4px; letter-spacing: .06em; }

.quip { min-height: 52px; margin: 6px 0 14px; text-align: center; font-size: 20px; font-weight: 600; line-height: 1.25; color: var(--cream); }
.quip.bump { animation: bump .28s ease; }
@keyframes bump { 0% { transform: scale(.94); opacity: .4; } 100% { transform: none; opacity: 1; } }

/* Range input as a thick fill track */
.slider {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 44px; margin: 0; background: transparent; cursor: pointer;
  --pct: 50%;
}
.slider::-webkit-slider-runnable-track {
  height: 18px; border-radius: 9px;
  background: linear-gradient(90deg, var(--meter, var(--lime)) var(--pct), rgba(0,0,0,.35) var(--pct));
  box-shadow: inset 0 0 0 1px rgba(244,248,230,.12);
}
.slider::-moz-range-track { height: 18px; border-radius: 9px; background: rgba(0,0,0,.35); }
.slider::-moz-range-progress { height: 18px; border-radius: 9px; background: var(--meter, var(--lime)); }
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 40px; height: 40px; margin-top: -11px; border-radius: 50%;
  background: var(--cream); border: 4px solid var(--can-ink);
  box-shadow: 0 3px 10px rgba(0,0,0,.4);
}
.slider::-moz-range-thumb { width: 32px; height: 32px; border-radius: 50%; background: var(--cream); border: 4px solid var(--can-ink); }
.slider:focus-visible { outline: none; }
.slider:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px var(--lime); }
.ends { display: flex; justify-content: space-between; margin-top: 4px; font-family: var(--mono); font-size: 13px; color: var(--muted); }

/* Dew rack */
.rack { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin: 24px 0 6px; }
.rack-can {
  padding: 0; border: 0; background: none; cursor: pointer; touch-action: manipulation;
  color: rgba(244,248,230,.18);
  transition: color .2s, transform .15s;
}
.rack-can svg { display: block; width: 100%; height: auto; }
.rack-can.full { color: var(--lime); }
.rack-can.full .can-glint { opacity: 1; }
.rack-can.pop { animation: pop .35s cubic-bezier(.3,1.6,.5,1); }
.rack-can:active { transform: scale(.94); }
@keyframes pop { 0% { transform: translateY(14px) scale(.7); } 100% { transform: none; } }

.counter { display: flex; align-items: center; justify-content: center; gap: 22px; margin: 14px 0 4px; }
.counter .readout { align-items: center; min-width: 120px; }
.round-btn {
  display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%;
  border: 0; background: rgba(0,0,0,.28); color: var(--lime);
  font-family: var(--mono); font-size: 34px; line-height: 1; cursor: pointer; touch-action: manipulation;
  box-shadow: inset 0 0 0 2px rgba(200,245,49,.45);
}
.round-btn:active { transform: scale(.94); }
.round-btn:disabled { opacity: .35; }
.overflow { margin: 0; text-align: center; font-family: var(--mono); color: var(--lime); font-size: 15px; letter-spacing: .06em; }

.rounds-foot { padding-top: 14px; }

/* ---------- Result ---------- */
.screen-result { padding-top: 6px; }
.sound-btn {
  border: 0; background: none; padding: 4px 0 4px 8px;
  font-family: var(--mono); font-size: 12px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); cursor: pointer;
}
.sound-btn[aria-pressed="false"] { text-decoration: line-through; }
.vitals { display: flex; justify-content: space-between; align-items: flex-end; padding-top: 6px; border-top: 1px solid rgba(92,255,143,.16); }
.vital { display: flex; align-items: baseline; gap: 8px; }
.vital b { font-weight: 400; font-size: 40px; line-height: 1; }
.vital em { font-style: normal; font-size: 18px; }
.vital-hr { color: var(--phosphor); }
.vital-hr b { text-shadow: 0 0 12px rgba(92,255,143,.6); }
.vital-sp { color: var(--cyan); }
.vital-sp b { text-shadow: 0 0 12px rgba(83,230,245,.5); }
.monitor.flat .vital-hr { color: var(--alarm); }
.monitor.flat .vital-hr b { text-shadow: 0 0 12px rgba(255,59,74,.7); animation: blink 1s steps(2) infinite; }
.monitor.flat .mon-label { color: var(--alarm); }
@keyframes blink { 50% { opacity: .25; } }

.verdict { text-align: center; margin: 26px 0 10px; }
.big-score { display: flex; align-items: baseline; justify-content: center; gap: 6px; margin-top: 2px; font-family: var(--mono); line-height: .9; }
.big-score b { font-weight: 400; font-size: clamp(120px, 40vw, 168px); color: var(--lime); text-shadow: 0 0 34px rgba(200,245,49,.4); font-variant-numeric: tabular-nums; }
.big-score span { font-size: 26px; color: var(--muted); }
.tier {
  margin: 4px 0 0;
  font-family: var(--display); font-weight: 400; font-size: clamp(40px, 13vw, 58px); line-height: 1;
  color: var(--cream); text-shadow: 0 3px 0 var(--can-ink);
  transform: rotate(-2deg);
}
.tier.code-red { color: var(--alarm); }
.tagline { margin: 12px auto 0; max-width: 30ch; font-size: 19px; color: var(--muted); }
.badges { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 16px; }
.badge {
  padding: 6px 12px; border-radius: 999px;
  font-family: var(--mono); font-size: 13px; letter-spacing: .08em; text-transform: uppercase;
  box-shadow: inset 0 0 0 1.5px rgba(244,248,230,.35);
}
.badge.hot { background: var(--lime); color: var(--can-ink); box-shadow: none; }

.breakdown { list-style: none; margin: 22px 0 0; padding: 14px; border-radius: var(--radius); background: rgba(0,0,0,.2); }
.breakdown li { display: grid; grid-template-columns: 112px 1fr 52px; align-items: center; gap: 10px; padding: 7px 0; }
.bd-label { font-weight: 600; font-size: 16px; }
.bd-bar { height: 10px; border-radius: 5px; background: rgba(0,0,0,.35); overflow: hidden; }
.bd-bar i { display: block; height: 100%; width: var(--w); border-radius: 5px; background: var(--lime); transform-origin: left; animation: grow .8s cubic-bezier(.2,.8,.2,1) both; }
.breakdown li:nth-child(2) .bd-bar i { animation-delay: .06s; }
.breakdown li:nth-child(3) .bd-bar i { animation-delay: .12s; }
.breakdown li:nth-child(4) .bd-bar i { animation-delay: .18s; }
.breakdown li:nth-child(5) .bd-bar i { animation-delay: .24s; }
@keyframes grow { from { transform: scaleX(0); } }
.breakdown b { font-family: var(--mono); font-weight: 400; font-size: 18px; text-align: right; color: var(--cream); }

.result-actions { display: grid; gap: 12px; margin-top: 22px; }
.done-btn { margin-top: 14px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 24px);
  z-index: 10; max-width: calc(100% - 32px); margin: 0; padding: 12px 18px;
  border-radius: 14px; background: var(--cream); color: var(--can-ink);
  font-weight: 600; text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
  transform: translate(-50%, 140%); opacity: 0;
  transition: transform .3s cubic-bezier(.2,.8,.2,1), opacity .3s;
  pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 360px) {
  .band-mrn { display: none; }
  .breakdown li { grid-template-columns: 96px 1fr 46px; }
  .can { height: 180px; }
  .readout b { font-size: 80px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .can .bubble { display: none; }
}

/* Late additions */
.mon-label { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rack-can .can-mark { opacity: 0; transition: opacity .2s; }
.rack-can.full .can-mark { opacity: 1; }
.progress li:not(.done) .can-mark { opacity: 0; }
