:root {
  color-scheme: dark;
  --nus-blue: #8bc7ff;
  --nus-blue-strong: #003d7c;
  --nus-orange: #ff9f1c;
  --page: #071421;
  --panel: #101e30;
  --panel-strong: #132842;
  --soft: #16283e;
  --ink: #eef6ff;
  --muted: #aebed2;
  --subtle: #8396ad;
  --line: #29415d;
  --good: #4ade80;
  --bad: #fb7185;
  --warn: #facc15;
  --cyan: #4fd1c5;
  --shadow: 0 18px 54px rgb(0 0 0 / 0.45);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html[data-theme="light"] {
  color-scheme: light;
  --nus-blue: #003d7c;
  --nus-blue-strong: #003d7c;
  --nus-orange: #ef7c00;
  --page: #edf3f8;
  --panel: #ffffff;
  --panel-strong: #f7fbff;
  --soft: #eef5fb;
  --ink: #071421;
  --muted: #5f6f82;
  --subtle: #718096;
  --line: #d8e2ee;
  --good: #12805c;
  --bad: #b42318;
  --warn: #9a5a00;
  --cyan: #047f78;
  --shadow: 0 18px 54px rgb(0 30 64 / 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  min-width: 320px;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgb(255 255 255 / 0.025) 1px, transparent 1px),
    linear-gradient(0deg, rgb(255 255 255 / 0.025) 1px, transparent 1px),
    radial-gradient(circle at 20% 8%, color-mix(in srgb, var(--nus-blue) 20%, var(--page)) 0, var(--page) 36%, #040b13 100%);
  background-size: 28px 28px, 28px 28px, auto;
  color: var(--ink);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
.dose-slider:focus-visible,
select:focus-visible {
  outline: 3px solid rgb(239 124 0 / 0.78);
  outline-offset: 2px;
}

.app-shell {
  display: grid;
  width: 100%;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  padding: max(4px, env(safe-area-inset-top, 0px)) max(4px, env(safe-area-inset-right, 0px))
    max(4px, env(safe-area-inset-bottom, 0px)) max(4px, env(safe-area-inset-left, 0px));
  place-items: center;
}

.phone-frame {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: 100%;
  max-width: 480px;
  height: 100%;
  max-height: calc(100dvh - 8px);
  min-height: 0;
  overflow: hidden;
  border: 2px solid var(--nus-blue);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgb(255 255 255 / 0.055), transparent 42%),
    var(--panel);
  box-shadow: var(--shadow);
}

@media (min-width: 700px) and (min-height: 760px) {
  .app-shell {
    padding: max(12px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px))
      max(12px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
  }

  .phone-frame {
    width: min(calc(100vw - 2rem), calc((100dvh - 2rem) * 0.68), 680px);
    max-width: none;
    height: min(calc(100dvh - 2rem), 940px);
    max-height: none;
  }
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  width: 100%;
  min-width: 0;
  min-height: 54px;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 92%, #000 8%);
}

.brand-title {
  display: flex;
  min-width: 0;
  flex: 1 1 auto;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  color: var(--nus-blue);
  text-align: left;
}

.brand-mark {
  position: relative;
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  overflow: hidden;
  border: 0;
  border-radius: 9px;
  background: transparent;
}

.brand-icon-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-copy {
  display: grid;
  min-width: 0;
  gap: 1px;
  --brand-title-size: 1.54rem;
  --brand-subtitle-size: calc(var(--brand-title-size) * 0.49);
}

.brand-copy strong {
  overflow: hidden;
  color: var(--nus-blue);
  font-size: var(--brand-title-size);
  font-weight: 800;
  line-height: 0.98;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-copy small {
  color: var(--nus-orange);
  font-size: var(--brand-subtitle-size);
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.brand-copy small span + span {
  color: var(--nus-blue);
}

.top-actions {
  display: flex;
  min-width: max-content;
  flex: 0 0 auto;
  gap: 4px;
}

.icon-button,
.mini-command,
.secondary-command,
.primary-command,
.close-button,
.segmented button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel-strong) 90%, #fff 10%);
  color: var(--ink);
  font-weight: 800;
}

.icon-button {
  display: grid;
  position: relative;
  width: 31px;
  height: 31px;
  place-items: center;
  padding: 0;
  color: var(--nus-blue);
  font-size: 0.82rem;
  line-height: 1;
  box-shadow: inset 0 -2px 0 rgb(0 0 0 / 0.16);
}

.topbar .icon-button {
  width: 36px;
  height: 36px;
}

.topbar .icon-button::before {
  position: absolute;
  inset: -4px;
  content: "";
}

.icon-button span {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  font-weight: 950;
}

.icon-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.3;
}

.icon-button svg.theme-moon {
  display: none;
  width: 18px;
  height: 18px;
  fill: currentColor;
  stroke: none;
}

html[data-theme="light"] .theme-sun {
  display: none;
}

html[data-theme="light"] .theme-moon {
  display: block;
}

.icon-button svg.support-cup {
  width: 19px;
  height: 19px;
  stroke-width: 2.05;
  transform: translateY(0.25px);
}

.screen-grid {
  display: grid;
  width: 100%;
  min-width: 0;
  grid-template-rows: auto auto auto minmax(128px, 1fr) auto auto auto;
  gap: clamp(5px, 0.95dvh, 8px);
  min-height: 0;
  padding: clamp(8px, 1.4dvh, 12px);
}

.screen-grid > * {
  min-width: 0;
}

.score-strip,
.fact-row,
.result-grid {
  display: grid;
  min-width: 0;
  gap: 6px;
}

.score-strip {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.fact-row,
.result-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.score-strip span,
.fact-row span,
.result-grid span {
  display: grid;
  min-width: 0;
  min-height: 41px;
  align-content: center;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--soft) 78%, transparent);
  padding: 4px 5px;
  text-align: center;
}

.score-strip small,
.fact-row small,
.result-grid small,
.learning-strip small,
.drug-select-label {
  overflow: hidden;
  color: var(--subtle);
  font-size: clamp(0.58rem, 1.05dvh, 0.72rem);
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.1;
  text-transform: uppercase;
  white-space: nowrap;
}

.score-strip strong,
.fact-row strong,
.result-grid strong {
  overflow: hidden;
  color: var(--ink);
  font-size: clamp(0.74rem, 1.35dvh, 0.95rem);
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drug-panel {
  display: grid;
  min-width: 0;
  grid-template-columns: 30px minmax(0, 1fr) 46px;
  align-items: center;
  gap: 5px;
  min-height: 34px;
}

.case-panel {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.setup-tabs {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(0, 3fr) 1px minmax(0, 2fr);
  align-items: stretch;
  gap: 5px;
}

.setup-divider {
  align-self: stretch;
  border-radius: 999px;
  background: color-mix(in srgb, var(--nus-orange) 52%, var(--line));
  opacity: 0.8;
}

.mode-tabs,
.objective-tabs,
.expert-actions {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.mode-tabs {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.objective-tabs {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.expert-actions {
  display: none;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mode-tabs button,
.objective-tabs button,
.expert-actions button,
.weight-control button {
  min-width: 0;
  min-height: 27px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel-strong) 88%, #fff 12%);
  color: var(--muted);
  font-size: clamp(0.56rem, 0.98dvh, 0.68rem);
  font-weight: 900;
}

.mode-tabs button.is-selected,
.objective-tabs button.is-selected,
.expert-actions button:active,
.weight-control button:active {
  border-color: color-mix(in srgb, var(--nus-orange) 74%, var(--line));
  background: color-mix(in srgb, var(--nus-orange) 18%, var(--panel-strong));
  color: var(--ink);
}

.dose-column .expert-actions button {
  min-height: 39px;
}

.patient-strip {
  display: grid;
  grid-template-columns: 0.8fr 1.15fr auto;
  min-width: 0;
  gap: 5px;
}

.patient-strip span {
  display: grid;
  min-width: 0;
  min-height: 38px;
  align-content: center;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--soft) 74%, transparent);
  padding: 4px 6px;
}

.patient-strip small {
  overflow: hidden;
  color: var(--subtle);
  font-size: 0.54rem;
  font-weight: 900;
  line-height: 1.05;
  text-transform: uppercase;
  white-space: nowrap;
}

.patient-strip strong {
  overflow: hidden;
  color: var(--ink);
  font-size: clamp(0.68rem, 1.18dvh, 0.78rem);
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.weight-control {
  grid-template-columns: 24px minmax(46px, auto) 24px;
  align-items: center;
  justify-items: center;
  padding-inline: 4px;
}

.weight-control button {
  width: 24px;
  min-height: 24px;
  padding: 0;
  color: var(--nus-blue);
}

.weight-control.is-disabled {
  opacity: 0.48;
}

.weight-control.is-disabled button {
  pointer-events: none;
}

.drug-select-label {
  color: var(--nus-orange);
}

select {
  width: 100%;
  min-width: 0;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--ink);
  padding: 0 6px;
  font-size: clamp(0.72rem, 1.18dvh, 0.84rem);
  font-weight: 800;
}

.mini-command {
  min-height: 34px;
  padding: 0 7px;
  color: var(--nus-blue);
  font-size: 0.78rem;
}

.arena {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--nus-blue) 42%, var(--line));
  border-radius: 10px;
  background:
    linear-gradient(90deg, rgb(255 255 255 / 0.035) 1px, transparent 1px),
    linear-gradient(0deg, rgb(255 255 255 / 0.035) 1px, transparent 1px),
    color-mix(in srgb, var(--panel-strong) 86%, #000 14%);
  background-size: 22px 22px, 22px 22px, auto;
}

#pkCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.event-banner {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 78px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 31px;
  border: 1px solid color-mix(in srgb, var(--nus-orange) 35%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 86%, transparent);
  padding: 5px 8px;
  pointer-events: none;
}

.graph-speed-button,
.graph-play-button {
  position: absolute;
  z-index: 3;
  display: grid;
  min-width: 0;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--nus-blue) 42%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 86%, transparent);
  color: var(--ink);
  box-shadow: 0 8px 18px rgb(0 0 0 / 0.22), inset 0 -2px 0 rgb(0 0 0 / 0.14);
}

.graph-speed-button {
  top: 8px;
  right: 43px;
  grid-template-columns: auto;
  width: 31px;
  height: 31px;
  padding: 0;
  color: var(--nus-blue);
}

.graph-speed-button span {
  width: 21px;
  height: 21px;
  line-height: 1;
}

.graph-speed-button svg {
  width: 21px;
  height: 21px;
  fill: currentColor;
  stroke: none;
}

.speed-slow-svg {
  display: none;
}

.graph-speed-button.is-slow .speed-fast-svg {
  display: none;
}

.graph-speed-button.is-slow .speed-slow-svg {
  display: block;
}

.graph-speed-button small {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.graph-speed-button.is-slow {
  border-color: color-mix(in srgb, var(--nus-orange) 68%, var(--line));
  background: color-mix(in srgb, var(--nus-orange) 18%, var(--panel));
}

.graph-play-button {
  top: 8px;
  right: 8px;
  width: 31px;
  height: 31px;
  padding: 0;
  color: var(--nus-blue);
  font-size: 0.92rem;
  font-weight: 950;
}

.playback-icon {
  position: relative;
  display: block;
  width: 16px;
  height: 16px;
}

.playback-icon::before,
.playback-icon::after {
  position: absolute;
  top: 2px;
  width: 4px;
  height: 12px;
  border-radius: 2px;
  background: currentColor;
  content: "";
}

.playback-icon::before {
  left: 3px;
}

.playback-icon::after {
  right: 3px;
}

.graph-play-button.is-paused .playback-icon::before {
  top: 1px;
  left: 5px;
  width: 0;
  height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 11px solid currentColor;
  border-radius: 0;
  background: transparent;
}

.graph-play-button.is-paused .playback-icon::after {
  display: none;
}

.event-banner span {
  overflow: hidden;
  color: var(--nus-orange);
  font-size: 0.66rem;
  font-weight: 900;
  line-height: 1;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.event-banner strong {
  overflow: hidden;
  color: var(--ink);
  font-size: clamp(0.72rem, 1.25dvh, 0.84rem);
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.learning-strip {
  display: grid;
  grid-template-columns: minmax(90px, 0.72fr) minmax(0, 1.2fr);
  gap: 9px;
  min-height: clamp(56px, 8.5dvh, 70px);
  align-items: center;
  border: 1px solid color-mix(in srgb, var(--cyan) 24%, var(--line));
  border-radius: 10px;
  background: color-mix(in srgb, var(--cyan) 8%, var(--panel-strong));
  padding: 8px 10px;
  cursor: pointer;
}

.learning-strip:focus-visible {
  outline: 2px solid var(--nus-orange);
  outline-offset: 2px;
}

.learning-strip div {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.learning-strip strong {
  overflow: hidden;
  color: var(--ink);
  font-size: clamp(0.84rem, 1.45dvh, 1rem);
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.learning-strip p {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: clamp(0.7rem, 1.22dvh, 0.82rem);
  font-weight: 700;
  line-height: 1.22;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.learning-modal {
  padding-top: 38px;
}

.learning-modal h2 {
  margin-right: 20px;
}

.learning-modal p:last-child {
  color: var(--muted);
  font-weight: 700;
  line-height: 1.42;
}

.control-panel {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(105px, 0.48fr) minmax(0, 1fr);
  gap: 8px;
  min-height: clamp(88px, 13dvh, 104px);
}

.dose-column {
  display: grid;
  min-width: 0;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 6px;
}

.dose-button {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 4px;
  min-width: 0;
  border: 0;
  border-radius: 10px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--nus-orange) 88%, #fff 12%), var(--nus-orange));
  color: #08111f;
  box-shadow: inset 0 -3px 0 rgb(0 0 0 / 0.18);
}

.dose-button span {
  font-size: clamp(1.1rem, 2.5dvh, 1.38rem);
  font-weight: 950;
  line-height: 1;
}

.dose-button small {
  font-size: 0.73rem;
  font-weight: 900;
}

.demo-highlight {
  z-index: 31;
  outline: 3px solid #ffbf47;
  outline-offset: 3px;
  box-shadow:
    0 0 0 7px rgb(255 159 28 / 0.24),
    0 0 22px rgb(255 159 28 / 0.34);
}

.demo-highlight:not(.graph-speed-button):not(.graph-play-button) {
  position: relative;
}

.graph-speed-button.demo-highlight,
.graph-play-button.demo-highlight {
  z-index: 31;
}

.dose-button.is-demo-pressing {
  animation: demoPress 0.78s ease-in-out 1;
}

.demo-coach {
  position: absolute;
  z-index: 32;
  left: 8px;
  top: 8px;
  width: min(238px, calc(100% - 18px));
  border: 2px solid #ff9f1c;
  border-radius: 8px;
  background:
    linear-gradient(180deg, #fffdf8 0%, #ffe9c7 100%);
  box-shadow:
    0 16px 36px rgb(0 0 0 / 0.42),
    0 0 0 4px rgb(255 159 28 / 0.18);
  color: #06172b;
  opacity: 0;
  padding: 9px 11px 10px;
  pointer-events: none;
  transform: translateY(6px) scale(0.98);
  transition: opacity 160ms ease, transform 180ms ease;
}

.demo-coach::after {
  position: absolute;
  left: var(--demo-tail-x, 28px);
  bottom: -8px;
  width: 14px;
  height: 14px;
  border-right: 2px solid #ff9f1c;
  border-bottom: 2px solid #ff9f1c;
  background: #ffe9c7;
  content: "";
  transform: rotate(45deg);
}

.demo-coach.is-below::after {
  top: -8px;
  bottom: auto;
  border: 0;
  border-top: 2px solid #ff9f1c;
  border-left: 2px solid #ff9f1c;
}

.demo-coach.is-visible:not(.is-positioning) {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.demo-coach small {
  display: block;
  margin-bottom: 4px;
  color: #003d7c;
  font-size: 0.62rem;
  font-weight: 950;
  letter-spacing: 0.02em;
  line-height: 1;
  text-transform: uppercase;
}

.demo-coach p {
  margin: 0;
  color: #06172b;
  font-size: clamp(0.72rem, 1.2dvh, 0.84rem);
  font-weight: 800;
  line-height: 1.25;
}

@keyframes demoPress {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }

  45% {
    filter: brightness(1.12);
    transform: translateY(2px) scale(0.97);
  }
}

.control-stack {
  display: grid;
  min-width: 0;
  gap: 6px;
}

.dose-slider-panel {
  display: grid;
  min-width: 0;
  min-height: 49px;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--soft) 72%, transparent);
  padding: 5px 8px 4px;
}

.dose-slider-head {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.dose-slider-head small {
  overflow: hidden;
  color: var(--subtle);
  font-size: 0.54rem;
  font-weight: 900;
  line-height: 1;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.dose-slider-head strong {
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 950;
  line-height: 1;
}

.dose-slider {
  --dose-slider-progress: 60%;
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
  height: 22px;
  margin: 0;
  cursor: pointer;
  touch-action: none;
}

.dose-slider-track {
  position: absolute;
  top: 50%;
  right: 0;
  left: 0;
  height: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--panel-strong) 92%, #fff 8%);
  transform: translateY(-50%);
}

.dose-slider-fill {
  display: block;
  width: var(--dose-slider-progress);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--nus-orange), var(--cyan));
}

.dose-slider-thumb {
  position: absolute;
  top: 50%;
  left: var(--dose-slider-progress);
  width: 18px;
  height: 18px;
  border: 2px solid #eef6ff;
  border-radius: 999px;
  background: var(--nus-orange);
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.3);
  transform: translate(-50%, -50%);
}

.dose-slider-ticks {
  position: relative;
  display: block;
  min-height: 8px;
  color: var(--subtle);
  font-size: 0.52rem;
  font-weight: 900;
  line-height: 1;
}

.dose-slider-ticks span {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  white-space: nowrap;
}

.dose-slider-ticks span:nth-child(1) {
  left: 0;
  transform: none;
}

.dose-slider-ticks span:nth-child(2) {
  left: 60%;
}

.dose-slider-ticks span:nth-child(3) {
  right: 0;
  transform: none;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(42px, 1fr));
  gap: 5px;
}

.segmented.interval {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.segmented button {
  min-width: 0;
  min-height: 39px;
  padding: 0 4px;
  color: var(--muted);
  font-size: clamp(0.62rem, 1.15dvh, 0.76rem);
  line-height: 1.05;
}

.segmented button.is-selected {
  border-color: color-mix(in srgb, var(--nus-orange) 74%, var(--line));
  background: color-mix(in srgb, var(--nus-orange) 22%, var(--panel-strong));
  color: var(--ink);
}

.segmented button.is-hidden {
  display: none;
}

.control-panel.has-expert-actions .expert-actions {
  display: grid;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 10px 0;
  background: rgb(7 20 33 / 0.52);
  backdrop-filter: blur(2px);
}

.overlay.is-visible {
  display: flex;
}

.modal-card {
  position: relative;
  display: grid;
  width: min(90%, 600px);
  max-height: calc(100dvh - 20px);
  gap: 10px;
  overflow: auto;
  border: 1px solid color-mix(in srgb, var(--nus-blue) 42%, var(--line));
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 12px;
}

.modal-card.help-modal {
  max-height: calc(100dvh - 20px);
  gap: 6px;
  overflow: auto;
  padding: 12px;
}

.modal-kicker {
  margin: 0;
  color: var(--nus-orange);
  font-size: 0.73rem;
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
}

.modal-card h1,
.modal-card h2 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(1.24rem, 2.7dvh, 1.58rem);
  line-height: 1.08;
}

#startOverlay .start-title {
  overflow: hidden;
  font-size: clamp(1.02rem, 5.1vw, 1.2rem);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-card .help-title {
  overflow: hidden;
  font-size: 1rem;
  line-height: 1.12;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-card.help-modal > p:not(.modal-kicker):not(.source-note) {
  font-size: 0.85rem;
  line-height: 1.32;
}

.modal-card.help-modal ul {
  gap: 3px;
  padding-left: 0.9rem;
  font-size: 0.85rem;
  line-height: 1.32;
}

.help-modal .source-note {
  font-size: 0.62rem;
  line-height: 1.18;
}

.modal-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
  line-height: 1.42;
}

.guided-demo-note {
  border-left: 3px solid var(--nus-orange);
  background: color-mix(in srgb, var(--nus-orange) 9%, transparent);
  padding: 7px 9px;
}

.start-warning {
  margin-top: 8px;
  font-size: 0.66rem;
  line-height: 1.3;
  text-align: center;
}

.modal-card a {
  color: var(--nus-blue);
  font-weight: 900;
  text-decoration-color: color-mix(in srgb, var(--nus-orange) 70%, transparent);
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
}

.modal-card ul {
  display: grid;
  gap: 7px;
  margin: 0;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 650;
  line-height: 1.32;
}

.source-note,
.share-status,
.progress-row {
  color: var(--subtle);
  font-size: 0.76rem;
  font-weight: 750;
}

.share-status {
  text-align: center;
}

.panel-insight {
  border: 1px solid color-mix(in srgb, var(--cyan) 28%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--cyan) 9%, var(--panel-strong));
  padding: 9px 10px;
}

.modal-info-row {
  display: grid;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--soft) 72%, transparent);
  padding: 8px 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  line-height: 1.3;
}

.modal-info-row strong {
  color: var(--nus-blue);
  font-size: 0.7rem;
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
}

.modal-note {
  border-left: 3px solid var(--nus-orange);
  background: color-mix(in srgb, var(--soft) 70%, transparent);
  padding: 8px 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.3;
}

.modal-note.local-data-warning {
  border-color: var(--warn);
  background: color-mix(in srgb, var(--warn) 11%, var(--panel-strong));
  color: var(--warn);
}

.modal-note.safety-disclaimer {
  border: 1px solid rgb(251 146 60 / 0.42);
  border-left: 4px solid #fb923c;
  border-radius: 8px;
  background: #431407;
  color: #fed7aa;
  font-size: 0.75rem;
  font-weight: 800;
  line-height: 1.4;
  padding: 0.55rem 0.7rem;
}

.modal-note.safety-disclaimer strong {
  color: #fdba74;
}

html[data-theme="light"] .modal-note.safety-disclaimer {
  border-color: rgb(239 124 0 / 0.34);
  border-left-color: #ef7c00;
  background: #fff7ed;
  color: #7c2d12;
}

html[data-theme="light"] .modal-note.safety-disclaimer strong {
  color: #9a4a00;
}

.support-modal {
  gap: 0;
  overflow: hidden;
  padding: 0;
}

.support-modal .support-header {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--soft) 72%, transparent);
  padding: 12px 48px 12px 12px;
}

.support-modal .support-heading-icon {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  background: color-mix(in srgb, var(--nus-orange) 12%, var(--panel));
  color: var(--nus-orange);
}

.support-modal .support-heading-icon svg {
  display: block;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.support-modal .support-header h2 {
  margin: 0;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.15;
}

.support-modal .support-header p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1.35;
  text-transform: uppercase;
}

.support-modal .support-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--nus-blue);
}

.support-modal .support-close:hover {
  border-color: var(--nus-orange);
  background: color-mix(in srgb, var(--nus-orange) 10%, var(--panel));
}

.support-modal .support-close svg {
  width: 18px;
  height: 18px;
}

.support-modal .support-body {
  display: grid;
  min-height: 0;
  gap: 12px;
  overflow-y: auto;
  padding: 12px;
}

.support-modal .support-body > * {
  margin: 0;
}

.support-modal .support-body p {
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 650;
  line-height: 1.55;
}

.support-modal .support-card {
  border-radius: 8px;
}

.support-modal .support-link {
  width: 100%;
  max-width: 380px;
  margin: 0 auto;
  border-radius: 8px;
}

.support-modal .support-link img {
  border-radius: 8px;
  box-shadow: 0 1px 2px rgb(15 23 42 / 0.12);
}

.support-modal .modal-note {
  border-radius: 8px;
  text-align: center;
}
.support-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--soft) 72%, transparent);
  padding: 10px;
}

.support-card h3 {
  margin: 0 0 8px;
  color: var(--nus-orange);
  font-size: 0.7rem;
  font-weight: 950;
  text-transform: uppercase;
}

.support-card ul {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.support-card li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.28;
}

.support-card li > span:first-child {
  color: var(--good);
  font-weight: 950;
}

.support-link {
  display: block;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  line-height: 0;
}

.support-link img {
  display: block;
  width: 100%;
  height: auto;
}

.stats-modal {
  gap: 8px;
}

.stats-modal > p {
  font-size: 0.78rem;
  line-height: 1.28;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.stats-grid span {
  display: grid;
  min-height: 50px;
  align-content: center;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--soft) 74%, transparent);
  padding: 7px 8px;
  text-align: center;
}

.stats-grid small,
.stats-recent small {
  overflow: hidden;
  color: var(--subtle);
  font-size: 0.62rem;
  font-weight: 900;
  line-height: 1.05;
  text-transform: uppercase;
  white-space: nowrap;
}

.stats-grid strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-recent {
  border: 1px solid color-mix(in srgb, var(--cyan) 24%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--cyan) 8%, var(--panel-strong));
  padding: 8px 9px;
}

.stats-recent p {
  margin-top: 3px;
  font-size: 0.78rem;
  line-height: 1.28;
}

.share-command {
  display: inline-grid;
  grid-template-columns: auto auto;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.share-command svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.3;
}

.progress-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--soft) 68%, transparent);
  padding: 8px 10px;
  text-align: center;
}

.mode-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 4px;
}

.mode-row.start-actions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.report-link-button {
  display: inline-grid;
  grid-template-columns: auto auto;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  border: 1px solid color-mix(in srgb, var(--warn) 38%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--warn) 8%, var(--panel-strong));
  color: var(--warn);
  font-size: 0.78rem;
  font-weight: 900;
}

.report-link-button svg,
.report-action-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.3;
}

.report-modal {
  gap: 8px;
}

.report-modal > p {
  font-size: 0.78rem;
  line-height: 1.28;
}

.report-details {
  width: 100%;
  min-height: 142px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--soft) 76%, #000 24%);
  color: var(--ink);
  padding: 8px;
  font: 700 0.68rem/1.32 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

.report-status {
  min-height: 1.1em;
}

.report-modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.report-action-button,
.report-submit-link {
  display: inline-grid;
  min-height: 38px;
  grid-template-columns: auto auto;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 8px;
  padding: 0 10px;
  font-size: 0.76rem;
  font-weight: 900;
  text-align: center;
  text-decoration: none;
}

.report-action-button {
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel-strong) 90%, #fff 10%);
  color: var(--nus-blue);
}

.report-submit-link {
  border: 0;
  background: var(--nus-orange);
  color: #08111f;
}

.primary-command,
.secondary-command {
  min-height: 42px;
  padding: 0 12px;
}

.primary-command {
  border: 0;
  background: var(--nus-orange);
  color: #08111f;
}

.secondary-command {
  color: var(--nus-blue);
}

.close-button {
  position: absolute;
  display: grid;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  place-content: center;
  place-items: center;
  padding: 0;
  color: var(--nus-blue);
  line-height: 1;
}

.close-button svg {
  display: block;
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  fill: none;
  pointer-events: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

@media (max-height: 690px) {
  .screen-grid {
    grid-template-rows: auto auto auto minmax(104px, 1fr) auto auto auto;
    gap: 5px;
    padding: 7px;
  }

  .topbar {
    min-height: 50px;
    padding: 5px 7px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .brand-copy {
    --brand-title-size: 1.42rem;
  }

  .score-strip span,
  .fact-row span {
    min-height: 39px;
    padding: 4px 5px;
  }

  .learning-strip {
    min-height: 52px;
    padding: 6px 8px;
  }

  .control-panel {
    min-height: 80px;
  }

  .case-panel {
    gap: 4px;
  }

  .mode-tabs button,
  .objective-tabs button,
  .expert-actions button {
    min-height: 25px;
  }

  .patient-strip span {
    min-height: 34px;
  }

  .segmented button {
    min-height: 34px;
  }

  .dose-column .expert-actions button {
    min-height: 34px;
  }

  .dose-slider-panel {
    min-height: 44px;
    padding-block: 4px 3px;
  }
}

@media (max-width: 430px) {
  .topbar {
    gap: 5px;
    padding: 5px 6px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .brand-copy {
    --brand-title-size: 1.42rem;
  }

  .top-actions {
    gap: 3px;
  }

  .icon-button {
    width: 32px;
    height: 32px;
  }

  .screen-grid {
    gap: 6px;
    padding: 7px;
  }

  .score-strip,
  .fact-row {
    gap: 4px;
  }

  .score-strip span,
  .fact-row span {
    min-height: 40px;
    padding: 4px 2px;
  }

  .score-strip small,
  .fact-row small {
    font-size: 0.52rem;
  }

  .score-strip strong,
  .fact-row strong {
    font-size: 0.72rem;
  }

  .drug-panel {
    grid-template-columns: 28px minmax(0, 1fr) 42px;
  }

  .control-panel {
    grid-template-columns: minmax(102px, 0.42fr) minmax(0, 1fr);
  }

  .segmented {
    gap: 4px;
  }

  .segmented button {
    min-height: 36px;
    font-size: 0.61rem;
  }

  .patient-strip {
    grid-template-columns: 0.72fr 1fr auto;
  }

  .patient-strip span {
    padding: 4px;
  }
}

@media (max-width: 520px) {
  .phone-frame {
    justify-self: start;
    max-width: none;
  }
}

@media (max-width: 360px) {
  .brand-copy {
    --brand-title-size: 1.32rem;
  }

  .control-panel {
    grid-template-columns: minmax(94px, 0.4fr) minmax(0, 1fr);
  }

  .segmented.interval button {
    font-size: 0.56rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
