:root {
  --sim-ink: #0d1834;
  --sim-muted: #55648a;
  --sim-faint: #64748b;
  --sim-blue: #2563eb;
  --sim-blue-deep: #1a49c9;
  --sim-sky: #0ea5e9;
  --sim-indigo: #6366f1;
  --sim-teal: #0f9f8a;
  --sim-green: #059669;
  --sim-red: #e0334b;

  /* Liquid glass: the fill must stay LIGHTER than the plate behind it, so the
     page base is deliberately tinted rather than white. */
  /* One light source, top-right. The rule for every gradient in this file:
     a fill LIGHTER than what's behind it puts its dense stop at 205-220deg;
     a fill DARKER than its backdrop inverts, and puts it at 35deg. Getting
     this backwards is what makes a surface read as a flat wash. */
  --glass-fill: linear-gradient(215deg, rgba(255, 255, 255, 0.58), rgba(255, 255, 255, 0.3));
  --glass-fill-strong: linear-gradient(220deg, rgba(255, 255, 255, 0.66), rgba(255, 255, 255, 0.34));
  /* No brightness() — it compounds across nested backdrop layers and flattens
     every card inside the frame back to white. */
  --glass-blur: blur(30px) saturate(180%);
  --glass-shadow:
    0 1px 2px rgba(19, 46, 110, 0.07),
    0 12px 24px -8px rgba(19, 46, 110, 0.16),
    0 40px 80px -24px rgba(19, 46, 110, 0.24);
  --glass-shadow-sm:
    0 1px 2px rgba(19, 46, 110, 0.06),
    0 8px 18px -6px rgba(19, 46, 110, 0.14),
    0 24px 48px -20px rgba(19, 46, 110, 0.18);

  /* Radius scale — four steps, no in-between values. */
  --r-frame: 36px;
  --r-card: 28px;
  --r-panel: 24px;
  --r-control: 18px;
}

.sim-cases-page {
  position: relative;
  min-height: 100vh;
  min-width: 320px;
  color: var(--sim-ink);
  background: #dfe9fb;
}

/* Saturated colour directly behind the card cluster — without this the
   backdrop-filter has nothing to refract and the glass reads as white card. */
/* One viewport-locked layer carrying every blob as a background gradient.
   Oversized positioned boxes were widening the page and their own edges were
   clipping the gradients into a visible arc; gradients inside `inset: 0`
   can do neither. */
.sim-cases-page::before {
  position: fixed;
  inset: 0;
  z-index: 0;
  content: "";
  pointer-events: none;
  /* Fine grain gives backdrop-filter something to actually frost — blurring a
     smooth gradient is a no-op. The noise is neutral grey and `overlay`-blended
     so it modulates texture without shifting the mean, and the base gradient
     lives here too so the noise always has an opaque layer to blend against. */
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch' /%3E%3CfeColorMatrix type='saturate' values='0' /%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' /%3E%3C/svg%3E") 0 0 / 180px 180px repeat,
    radial-gradient(58rem 48rem at 84% -8%, rgba(56, 132, 255, 0.58), transparent 62%),
    radial-gradient(44rem 40rem at 99% 24%, rgba(14, 165, 233, 0.44), transparent 60%),
    radial-gradient(40rem 38rem at 72% 2%, rgba(124, 58, 237, 0.16), transparent 58%),
    radial-gradient(52rem 48rem at -8% 98%, rgba(79, 110, 240, 0.46), transparent 62%),
    radial-gradient(44rem 40rem at 96% 88%, rgba(14, 165, 233, 0.3), transparent 60%),
    radial-gradient(38rem 36rem at 14% 76%, rgba(15, 159, 138, 0.22), transparent 58%),
    linear-gradient(180deg, #e7eefc 0%, #d3e0fe 45%, #cbd9fb 100%);
  background-blend-mode: overlay, normal, normal, normal, normal, normal, normal, normal;
}

.sim-cases-page .site-header {
  position: relative;
  z-index: 3;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0.34));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    inset 0 -1px 0 rgba(37, 99, 235, 0.14),
    0 8px 26px -14px rgba(19, 46, 110, 0.5);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.sim-shell {
  position: relative;
  z-index: 2;
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 30px 0 78px;
}

/* ---------- disclosure bar ---------- */

.demo-disclosure {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
  padding: 15px 24px;
  border: 0;
  border-radius: 999px;
  background: var(--glass-fill);
  box-shadow: var(--glass-shadow-sm);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  color: #2c3d63;
  font-size: 0.88rem;
}

.demo-disclosure::after {
  position: absolute;
  inset: 0;
  padding: 1px;
  content: "";
  border-radius: inherit;
  background: linear-gradient(220deg,
    rgba(255, 255, 255, 0.98) 0%,
    rgba(255, 255, 255, 0.38) 32%,
    rgba(37, 99, 235, 0.1) 64%,
    rgba(19, 46, 110, 0.22) 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  pointer-events: none;
}

/* Without this the two ends sit ~1000px apart and it reads as a cookie bar. */
.demo-disclosure {
  max-width: 1000px;
}

.demo-disclosure > div {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.demo-disclosure strong { color: #10254f; }

.demo-disclosure a {
  position: relative;
  z-index: 1;
  color: var(--sim-blue);
  font-weight: 800;
  text-decoration: none;
}

.demo-disclosure a:hover { text-decoration: underline; }

.demo-disclosure-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(205deg, #7cb4ff, var(--sim-blue));
  box-shadow: 0 0 0 5px rgba(37, 99, 235, 0.16), 0 2px 6px rgba(37, 99, 235, 0.5);
}

/* ---------- app frame ---------- */

/* Deliberately thin: the frame is a bezel, the cards inside are the glass.
   Filling both at high opacity stacks to ~0.9 white and kills the interior. */
.sim-app {
  position: relative;
  overflow: hidden;
  border: 0;
  border-radius: var(--r-frame);
  background: linear-gradient(220deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0.14));
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
}

.sim-app::after {
  position: absolute;
  inset: 0;
  z-index: 4;
  padding: 1.5px;
  content: "";
  border-radius: inherit;
  background: linear-gradient(220deg,
    rgba(255, 255, 255, 1) 0%,
    rgba(255, 255, 255, 0.44) 28%,
    rgba(37, 99, 235, 0.12) 62%,
    rgba(19, 46, 110, 0.26) 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  pointer-events: none;
}

.sim-app-header {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 28px 32px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.5);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0.06));
}

.sim-logo {
  position: relative;
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border-radius: 18px;
  color: #fff;
  background: linear-gradient(205deg, #5b9dff 0%, var(--sim-blue) 58%, #3f4ee0 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    inset 0 -1px 0 rgba(10, 30, 80, 0.3),
    0 2px 6px -2px rgba(37, 99, 235, 0.5),
    0 14px 30px -10px rgba(37, 99, 235, 0.62);
}

.sim-logo svg {
  position: relative;
  width: 28px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
}

.sim-app-heading h1 {
  margin: 0 0 5px;
  color: #12224a;
  font-size: clamp(1.45rem, 2.2vw, 1.68rem);
  letter-spacing: -0.03em;
}

.sim-app-heading p {
  margin: 0;
  color: var(--sim-muted);
  font-size: 0.9rem;
}

.demo-ready-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 15px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  color: #06674a;
  background: linear-gradient(215deg, rgba(209, 250, 233, 0.92), rgba(190, 242, 222, 0.6));
  box-shadow: 0 6px 18px -6px rgba(5, 150, 105, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  font-size: 0.79rem;
  font-weight: 800;
  white-space: nowrap;
}

.demo-ready-status i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.22);
}

.sim-body {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 318px minmax(0, 1fr);
  align-items: start;
}

/* ---------- case rail ---------- */

.sim-rail {
  position: sticky;
  top: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  max-height: 100vh;
  border-right: 1px solid rgba(255, 255, 255, 0.45);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.08));
}

.sim-rail-head {
  padding: 18px 18px 14px;
}

.sim-search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 999px;
  background: linear-gradient(215deg, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.52));
  box-shadow: 0 6px 18px -6px rgba(19, 46, 110, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  transition: box-shadow 180ms ease, border-color 180ms ease;
}

.sim-search:focus-within {
  border-color: rgba(37, 99, 235, 0.45);
  box-shadow: 0 8px 22px -6px rgba(37, 99, 235, 0.4), 0 0 0 4px rgba(37, 99, 235, 0.14);
}

.sim-search svg {
  width: 16px;
  flex: none;
  fill: none;
  stroke: var(--sim-faint);
  stroke-width: 2.1;
  stroke-linecap: round;
}

.sim-search input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.85rem;
}

.sim-search input::placeholder { color: var(--sim-faint); }

.sim-rail-list {
  padding: 4px 12px 16px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.sim-track-label {
  padding: 16px 10px 7px;
  color: #5c6b8c;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.sim-case-button {
  position: relative;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 12px;
  width: 100%;
  margin-bottom: 5px;
  padding: 11px 13px;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: var(--r-control);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 180ms ease, border-color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.sim-case-button:hover {
  border-color: rgba(255, 255, 255, 0.85);
  background: linear-gradient(215deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.34));
  box-shadow: 0 6px 18px -8px rgba(19, 46, 110, 0.28);
  transform: translateX(2px);
}

.sim-case-button[aria-selected="true"] {
  border-color: rgba(255, 255, 255, 0.9);
  background: linear-gradient(35deg, rgba(219, 234, 254, 0.94), rgba(226, 239, 255, 0.58));
  box-shadow:
    0 1px 2px rgba(19, 46, 110, 0.06),
    0 12px 26px -10px rgba(37, 99, 235, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
  transform: none;
}

.sim-case-button[aria-selected="true"]::before {
  position: absolute;
  top: 50%;
  left: 0;
  width: 3px;
  height: 26px;
  content: "";
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, #7cb4ff, var(--sim-blue));
  transform: translateY(-50%);
}

.sim-case-chapter {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 13px;
  background: linear-gradient(215deg, rgba(255, 255, 255, 0.95), rgba(226, 233, 248, 0.75));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 2px 6px -2px rgba(19, 46, 110, 0.24);
  color: var(--sim-muted);
  font-size: 0.79rem;
  font-weight: 900;
  transition: background 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

.sim-case-button[aria-selected="true"] .sim-case-chapter {
  background: linear-gradient(205deg, #5b9dff, var(--sim-blue) 62%, #3f4ee0);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    0 6px 16px -4px rgba(37, 99, 235, 0.6);
  color: #fff;
}

.sim-case-name {
  display: block;
  font-size: 0.91rem;
  font-weight: 800;
  line-height: 1.3;
}

.sim-case-button[aria-selected="true"] .sim-case-name { color: #12336e; }

.sim-case-sub {
  display: block;
  margin-top: 3px;
  color: var(--sim-muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.sim-rail-empty {
  padding: 22px 12px;
  color: var(--sim-muted);
  font-size: 0.85rem;
}

/* ---------- case detail ---------- */

.sim-detail {
  min-width: 0;
  padding: 28px 32px 36px;
}

.sim-case-head {
  max-width: 800px;
  margin-bottom: 24px;
}

.sim-case-head .project-label {
  margin: 0 0 9px;
  color: var(--sim-blue);
  font-size: 0.71rem;
  font-weight: 800;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

.sim-case-head h2 {
  margin: 0 0 12px;
  font-size: clamp(1.8rem, 3.1vw, 2.6rem);
  letter-spacing: -0.038em;
  line-height: 1.1;
}

.sim-scenario {
  margin: 0 0 16px;
  color: var(--sim-muted);
  font-size: 0.99rem;
  line-height: 1.62;
}

.sim-method-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.sim-method-tags li {
  padding: 6px 14px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 999px;
  background: linear-gradient(215deg, rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0.42));
  box-shadow: 0 4px 12px -4px rgba(19, 46, 110, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  color: #33477a;
  font-size: 0.76rem;
  font-weight: 700;
}

/* Row 1 pairs the controls with the headline numbers they change; charts run
   full width below, which removes ~900px of empty column and widens the plots. */
.sim-workbench {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.sim-wide {
  display: grid;
  gap: 20px;
  margin-top: 22px;
  min-width: 0;
}

/* ---------- shared glass surfaces ---------- */

.sim-controls,
.sim-metric,
.sim-chart,
.sim-preview {
  position: relative;
  overflow: hidden;
  border: 0;
  background: var(--glass-fill-strong);
  box-shadow: var(--glass-shadow-sm);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}

.sim-controls::after,
.sim-metric::after,
.sim-chart::after,
.sim-preview::after {
  position: absolute;
  inset: 0;
  z-index: 2;
  padding: 1px;
  content: "";
  border-radius: inherit;
  background: linear-gradient(220deg,
    rgba(255, 255, 255, 0.98) 0%,
    rgba(255, 255, 255, 0.38) 32%,
    rgba(37, 99, 235, 0.1) 64%,
    rgba(19, 46, 110, 0.22) 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  pointer-events: none;
}

/* ---------- controls ---------- */

.sim-controls {
  display: grid;
  gap: 17px;
  padding: 22px;
  border-radius: var(--r-panel);
}

.sim-controls > * { position: relative; z-index: 1; }

.sim-controls h3 {
  margin: 0;
  color: #5c6b8c;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.sim-control {
  display: grid;
  gap: 7px;
}

.sim-control-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.sim-control-top span {
  font-size: 0.85rem;
  font-weight: 700;
}

.sim-control-top output {
  padding: 2px 11px;
  border-radius: 999px;
  background: linear-gradient(35deg, rgba(219, 234, 254, 0.95), rgba(191, 219, 254, 0.62));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
  color: var(--sim-blue-deep);
  font-size: 0.82rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

/* Track fill follows the thumb — JS keeps --fill in sync. */
.sim-control input[type="range"] {
  width: 100%;
  height: 6px;
  margin: 7px 0;
  border-radius: 999px;
  background:
    linear-gradient(90deg, #3d86f7 0%, var(--sim-blue) var(--fill, 50%), rgba(120, 145, 190, 0.32) var(--fill, 50%));
  box-shadow: inset 0 1px 3px rgba(19, 46, 110, 0.18);
  appearance: none;
  cursor: pointer;
}

.sim-control input[type="range"]::-webkit-slider-thumb {
  width: 19px;
  height: 19px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: linear-gradient(205deg, #5b9dff, var(--sim-blue));
  box-shadow: 0 2px 8px -1px rgba(37, 99, 235, 0.7);
  appearance: none;
  cursor: pointer;
}

.sim-control input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: linear-gradient(205deg, #5b9dff, var(--sim-blue));
  box-shadow: 0 2px 8px -1px rgba(37, 99, 235, 0.7);
  cursor: pointer;
}

.sim-control input[type="range"]:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.38);
  outline-offset: 3px;
}

.sim-control-hint {
  margin: 0;
  color: var(--sim-faint);
  font-size: 0.75rem;
  line-height: 1.45;
}

.sim-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}

.sim-toggle input {
  width: 17px;
  height: 17px;
  accent-color: var(--sim-blue);
  cursor: pointer;
}

.sim-control-actions {
  display: grid;
  gap: 9px;
}

.sim-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 9px 16px;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: var(--r-control);
  background: linear-gradient(215deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.55));
  box-shadow: 0 6px 18px -8px rgba(19, 46, 110, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.92);
  color: #1c2c52;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}

.sim-button:hover {
  box-shadow: 0 12px 26px -10px rgba(19, 46, 110, 0.42);
  transform: translateY(-1px);
}

.sim-button:active { transform: translateY(1px); }

/* Rim-light top, shade bottom — no gloss dome. */
.sim-button.is-primary {
  border: 0;
  background: linear-gradient(180deg, #3d86f7 0%, var(--sim-blue) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.44),
    inset 0 -1px 0 rgba(10, 30, 80, 0.3),
    0 2px 6px -2px rgba(37, 99, 235, 0.5),
    0 12px 26px -8px rgba(37, 99, 235, 0.6);
  color: #fff;
}

.sim-button.is-primary:hover { filter: brightness(1.06); }

.sim-seed {
  margin: 0;
  color: var(--sim-faint);
  font-size: 0.74rem;
  text-align: center;
}

.sim-seed strong {
  color: var(--sim-muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- results ---------- */

.sim-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  min-width: 0;
}

/* Four metrics would otherwise leave an orphan on a 3-up row. */
.sim-metrics:has(> :nth-child(4):last-child) {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.sim-metric {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: 20px 22px;
  border-radius: var(--r-card);
  /* The corner is a specular first and a hue second: a near-white highlight on
     top of a wide, faint tint. Reversing that reads as a colour wash. */
  background:
    radial-gradient(62% 52% at 100% 0%, rgba(255, 255, 255, 0.6), transparent 62%),
    radial-gradient(96% 78% at 100% 0%, var(--metric-tint, rgba(59, 130, 246, 0.06)), transparent 68%),
    var(--glass-fill-strong);
}

/* Corner bloom: the core sits off-card and the edge is masked, so an arc
   enters the corner rather than a findable ball being clipped by it. */
.sim-metric::before {
  position: absolute;
  top: -92px;
  right: -70px;
  width: 200px;
  height: 200px;
  content: "";
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, var(--metric-glow, rgba(59, 130, 246, 0.55)), transparent 70%);
  opacity: 0.2;
  filter: blur(34px);
  -webkit-mask-image: radial-gradient(circle at 50% 50%, #000 25%, transparent 70%);
  mask-image: radial-gradient(circle at 50% 50%, #000 25%, transparent 70%);
  pointer-events: none;
}

.sim-metric > * { position: relative; z-index: 1; }

.sim-metric-label {
  display: block;
  color: var(--sim-muted);
  font-size: 0.77rem;
  font-weight: 700;
  line-height: 1.35;
}

.sim-metric-value {
  display: block;
  margin-top: 7px;
  font-size: 1.58rem;
  font-weight: 900;
  letter-spacing: -0.032em;
  font-variant-numeric: tabular-nums;
  line-height: 1.12;
}

/* Reserve the caption line rather than forcing a min-height on the card: grid
   already equalises row heights, so this keeps the caption attached to its
   number and still lines every card up. */
.sim-metric-hint {
  display: block;
  min-height: 1.4em;
  margin-top: 5px;
  color: var(--sim-faint);
  font-size: 0.73rem;
  line-height: 1.4;
}

.sim-metric.is-good {
  --metric-glow: rgba(16, 185, 129, 0.55);
  --metric-tint: rgba(16, 185, 129, 0.06);
}
.sim-metric.is-good .sim-metric-value { color: var(--sim-green); }

.sim-metric.is-bad {
  --metric-glow: rgba(244, 63, 94, 0.5);
  --metric-tint: rgba(244, 63, 94, 0.06);
}
.sim-metric.is-bad .sim-metric-value { color: var(--sim-red); }

.sim-metric.is-accent {
  --metric-glow: rgba(129, 140, 248, 0.6);
  --metric-tint: rgba(129, 140, 248, 0.06);
}
.sim-metric.is-accent .sim-metric-value { color: var(--sim-blue); }

/* Single column: two-up columns fall below the plot's minimum width and force
   the SVG to scroll inside its own card. */
.sim-charts {
  display: grid;
  gap: 16px;
}

/* <figure> carries a UA `margin: 1em 40px`, which inset every chart 40px from
   the column its siblings align to. */
.sim-chart {
  margin: 0;
  min-width: 0;
  padding: 20px 22px 16px;
  border-radius: var(--r-panel);
}

.sim-chart > * { position: relative; z-index: 1; }

.sim-chart h4 {
  margin: 0 0 5px;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: -0.012em;
}

.sim-chart-note {
  margin: 0 0 12px;
  color: var(--sim-muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

/* Inset plate so data marks never sit directly on background texture. */
.sim-chart-canvas {
  padding: 10px 10px 4px;
  overflow-x: auto;
  border-radius: var(--r-control);
  /* Holds the tail flat so the plate never dips below the card it sits in. */
  background: linear-gradient(220deg,
    rgba(255, 255, 255, 0.72) 0%,
    rgba(246, 250, 255, 0.56) 70%,
    rgba(246, 250, 255, 0.56) 100%);
  box-shadow:
    inset -1px 1px 3px rgba(19, 46, 110, 0.1),
    inset 0 0 0 1px rgba(255, 255, 255, 0.7);
}

.sim-chart svg {
  display: block;
  width: 100%;
  min-width: 430px;
  height: auto;
}

.sim-bar { filter: drop-shadow(0 4px 9px rgba(30, 64, 150, 0.26)); }
.sim-line { filter: drop-shadow(0 3px 7px rgba(30, 64, 150, 0.24)); }

.sim-axis-line { stroke: rgba(120, 145, 190, 0.55); stroke-width: 1; }
.sim-grid-line { stroke: rgba(120, 145, 190, 0.32); stroke-width: 1; }
.sim-axis-text { fill: #5c6c8c; font-size: 12px; font-weight: 600; }
.sim-axis-title { fill: #46557a; font-size: 12px; font-weight: 800; }
.sim-value-text { fill: #16244a; font-size: 12px; font-weight: 800; }

.sim-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 12px;
  color: var(--sim-muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.sim-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.sim-legend i {
  width: 12px;
  height: 12px;
  border-radius: 5px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 2px 5px -1px rgba(19, 46, 110, 0.3);
}

.sim-insight {
  position: relative;
  margin: 0;
  padding: 19px 24px 19px 26px;
  overflow: hidden;
  border: 0;
  border-radius: var(--r-panel);
  background: linear-gradient(35deg, rgba(219, 233, 255, 0.9), rgba(233, 241, 255, 0.55));
  box-shadow:
    0 1px 2px rgba(19, 46, 110, 0.06),
    0 14px 34px -12px rgba(37, 99, 235, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.92);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  color: #23345c;
  font-size: 0.91rem;
  line-height: 1.62;
}

.sim-insight::before {
  position: absolute;
  top: 16px;
  bottom: 16px;
  left: 0;
  width: 4px;
  content: "";
  border-radius: 0 4px 4px 0;
  background: linear-gradient(180deg, #7cb4ff, var(--sim-blue) 60%, var(--sim-indigo));
}

.sim-insight strong { color: #12336e; }

.sim-insight code {
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.16);
  font-size: 0.86em;
}

.sim-preview {
  border-radius: var(--r-panel);
}

.sim-preview > * { position: relative; z-index: 1; }

.sim-preview summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  font-size: 0.87rem;
  font-weight: 800;
  cursor: pointer;
  list-style: none;
}

.sim-preview summary::-webkit-details-marker { display: none; }

.sim-preview summary svg {
  width: 15px;
  flex: none;
  fill: none;
  stroke: var(--sim-blue);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 180ms ease;
}

.sim-preview[open] summary svg { transform: rotate(90deg); }

.sim-table-wrap {
  padding: 0 20px 18px;
  overflow-x: auto;
}

.sim-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.sim-table th,
.sim-table td {
  padding: 8px 14px 8px 0;
  border-bottom: 1px solid rgba(120, 145, 190, 0.24);
  text-align: right;
  white-space: nowrap;
}

.sim-table th:first-child,
.sim-table td:first-child { text-align: left; }

.sim-table th {
  color: var(--sim-faint);
  font-size: 0.71rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.sim-source {
  margin: 0;
  color: var(--sim-faint);
  font-size: 0.78rem;
}

.sim-source a { color: var(--sim-blue); font-weight: 800; }

/* ---------- responsive ---------- */

/* Raised from 1080: between there and ~1250 the 318px rail squeezed the plot
   column hard enough to shrink chart type. */
@media (max-width: 1180px) {
  .sim-body { grid-template-columns: 1fr; }

  .sim-rail {
    position: static;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.45);
  }

  .sim-rail-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(238px, 1fr));
    align-content: start;
    grid-auto-rows: max-content;
    max-height: 330px;
  }

  .sim-track-label { grid-column: 1 / -1; }

  .sim-workbench { grid-template-columns: 1fr; }

  .sim-controls { position: static; }
}

@media (max-width: 680px) {
  .sim-shell { width: min(100% - 20px, 1280px); padding-top: 20px; }

  .sim-app { border-radius: var(--r-card); }

  .sim-app-header {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    padding: 20px 18px 16px;
  }

  .demo-ready-status { grid-column: 1 / -1; justify-self: start; }

  .sim-detail { padding: 22px 18px 28px; }

  /* Stacked, 18 cases push the simulation four screens down. A horizontal
     snap strip keeps the controls and numbers near the top of the page. */
  .sim-rail-list {
    display: flex;
    gap: 10px;
    max-height: none;
    /* Left padding matches .sim-rail-head so the strip shares the column its
       search field and case heading sit on. */
    padding: 4px 18px 14px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding-left: 18px;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 36px), transparent);
    mask-image: linear-gradient(90deg, #000 calc(100% - 36px), transparent);
  }

  .sim-rail-list::-webkit-scrollbar { display: none; }

  .sim-case-button {
    flex: 0 0 214px;
    margin-bottom: 0;
    scroll-snap-align: start;
  }

  /* Sits inside the card's rounded corner instead of hanging off its edge. */
  .sim-case-button[aria-selected="true"]::before {
    left: 6px;
    border-radius: 3px;
  }

  .sim-track-label { display: none; }

  .sim-case-sub {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }

  .demo-disclosure {
    flex-direction: column;
    align-items: flex-start;
    gap: 9px;
    border-radius: var(--r-panel);
  }

  .sim-metrics,
  .sim-metrics:has(> :nth-child(4):last-child) {
    grid-template-columns: 1fr;
  }

  .sim-metric { min-height: 0; }

  .sim-chart { padding: 16px 14px 12px; }

  .sim-chart-canvas { padding: 8px 6px 2px; }
}

@media (prefers-reduced-motion: reduce) {
  .sim-case-button,
  .sim-button,
  .sim-search,
  .sim-preview summary svg { transition: none; }
}
