:root{
  --bg:#f7fbff;
  --card:#ffffff;
  --ink:#0f172a;
  --muted:#64748b;
  --blue:#3b82f6;
  --green:#22c55e;
  --shadow: 0 14px 35px rgba(15, 23, 42, .10);
  --radius: 18px;
}

*{box-sizing:border-box}
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
  color:var(--ink);
  background:
    radial-gradient(circle at 12% 10%, rgba(59,130,246,.12), transparent 40%),
    radial-gradient(circle at 88% 25%, rgba(34,197,94,.12), transparent 45%),
    var(--bg);
  min-height:100vh;
}

/* Header */
.topbar{
  display:flex;
  align-items:center;
  gap:12px;
  padding: 18px 16px;
  max-width: 1200px;
  margin: 0 auto;
}
.back{
  text-decoration:none;
  background: rgba(15,23,42,.06);
  padding: 10px 12px;
  border-radius: 14px;
  color: var(--ink);
  font-weight: 900;
}
.title h1{
  margin:0;
  font-size: clamp(22px, 3vw, 34px);
}
.title p{
  margin:4px 0 0;
  color:var(--muted);
  font-size: 14px;
}

.wrap{
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px 28px;
}

.card{
  background:var(--card);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding: 16px;
  border: 1px solid rgba(15,23,42,.06);
}

.muted{color:var(--muted)}

.grid{
  display:grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 14px;
}
@media(min-width: 980px){
  .grid{grid-template-columns: 1.1fr .9fr}
}

/* quick notes */
.miniNotes{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  margin-top: 10px;
}
.miniNote{
  display:flex;
  gap:10px;
  align-items:center;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(15,23,42,.04);
  border: 1px solid rgba(15,23,42,.08);
  font-weight: 700;
}
.badgeNote{
  display:inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(34,197,94,.20);
  border: 1px solid rgba(34,197,94,.35);
  font-weight: 900;
  font-size: 12px;
}
.badgeNote.ghost{
  background: rgba(59,130,246,.12);
  border: 1px solid rgba(59,130,246,.22);
}

/* sim header */
.simHeader{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.chips{display:flex; gap:8px; flex-wrap:wrap}
.chip{
  display:inline-flex;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(59,130,246,.10);
  color:#1d4ed8;
  font-weight: 900;
  font-size: 12px;
}

.simArea{
  margin-top: 10px;
  display:grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media(min-width: 720px){
  .simArea{grid-template-columns: 1.05fr .95fr}
}

/* SYRINGE */
.syringe{
  position:relative;
  background: linear-gradient(180deg, rgba(59,130,246,.08), rgba(34,197,94,.06));
  border: 1px solid rgba(59,130,246,.18);
  border-radius: 20px;
  padding: 14px;
  overflow:hidden;
  min-height: 360px;
}

.plungerTop{
  position:relative;
  height: 70px;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:flex-end;
  gap: 10px;
}

.plungerHandleTop{
  width: 120px;
  height: 26px;
  border-radius: 999px;
  background: rgba(59,130,246,.24);
  border: 2px solid rgba(59,130,246,.35);
  box-shadow: 0 10px 22px rgba(15,23,42,.08);
}

.plungerRodTop{
  width: 10px;
  height: 32px;
  border-radius: 999px;
  background: rgba(15,23,42,.18);
}

/* Tube container */
.tube{
  position:relative;
  height: 250px;
  border-radius: 18px;
  background: rgba(255,255,255,.88);
  border: 2px solid rgba(15,23,42,.10);
  overflow:hidden;
  box-shadow: inset 0 0 0 6px rgba(59,130,246,.05);
}

/* Gas layer */
.gas{
  position:absolute;
  inset:0;
  z-index: 1;
}

/* Plunger head INSIDE the tube (from TOP) */
.plungerHead{
  position:absolute;
  left: 10px;
  right: 10px;
  top: var(--plungerY, 0px);
  height: 16px;
  border-radius: 999px;
  background: rgba(59,130,246,.30);
  border: 2px solid rgba(59,130,246,.40);
  box-shadow: 0 10px 22px rgba(15,23,42,.10);
  z-index: 4;
}

/* Rod INSIDE tube from top down to head */
.tube::before{
  content:"";
  position:absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 0;
  width: 10px;
  height: var(--plungerY, 0px);
  border-radius: 999px;
  background: rgba(15,23,42,.16);
  z-index: 3;
}

/* Compressed top zone */
.tube::after{
  content:"";
  position:absolute;
  left:0; right:0;
  top:0;
  height: var(--plungerY, 0px);
  background: rgba(15,23,42,.06);
  border-bottom: 1px dashed rgba(15,23,42,.14);
  z-index: 2;
}

.volumeLabel{
  position:absolute;
  left: 12px;
  bottom: 10px;
  background: rgba(15,23,42,.06);
  padding: 8px 10px;
  border-radius: 14px;
  font-size: 13px;
  z-index: 6;
}

.compressedLabel{
  position:absolute;
  right: 12px;
  top: 10px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(15,23,42,.05);
  border: 1px solid rgba(15,23,42,.08);
  font-size: 12px;
  z-index: 6;
}

.readings{
  display:grid;
  gap: 10px;
}
.meter{
  border-radius: 18px;
  padding: 12px;
  border: 1px solid rgba(15,23,42,.08);
  background: rgba(255,255,255,.88);
}
.meter.tip{
  background: rgba(34,197,94,.10);
  border: 1px solid rgba(34,197,94,.20);
}
.meterTop{
  font-weight: 900;
  font-size: 12px;
  color: var(--muted);
  text-transform:uppercase;
  letter-spacing: .08em;
}
.meterVal{
  margin-top: 6px;
  font-size: 22px;
  font-weight: 900;
}
.meterHint{margin-top: 6px; font-size: 12px; line-height: 1.35}

.controls{
  margin-top: 12px;
  border-top: 1px dashed rgba(15,23,42,.14);
  padding-top: 12px;
}
.controlRow{
  display:grid;
  gap: 8px;
}
.label{font-weight:900}
input[type="range"]{
  width:100%;
  accent-color: var(--blue);
}
.minmax{
  display:flex;
  justify-content:space-between;
  font-size: 12px;
  color: var(--muted);
}

.btnRow{
  display:flex;
  gap: 10px;
  flex-wrap:wrap;
  margin-top: 10px;
}
.btn{
  border:0;
  cursor:pointer;
  font-weight: 900;
  border-radius: 16px;
  padding: 10px 14px;
  background: rgba(34,197,94,.20);
  border: 1px solid rgba(34,197,94,.35);
}
.btn.ghost{
  background: rgba(15,23,42,.06);
  border: 1px solid rgba(15,23,42,.10);
}
.btn:active{transform: scale(.99)}

.note{
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.graph canvas{
  width:100%;
  height:auto;
  border-radius: 16px;
  border: 1px solid rgba(15,23,42,.08);
  background: rgba(255,255,255,.92);
}
.legend{
  margin-top: 8px;
  font-size: 12px;
}
