:root {
  color-scheme: light;
  --navy: #062f63;
  --navy-2: #0b4fa5;
  --blue: #0a56c9;
  --blue-soft: #eaf3ff;
  --page: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #f8fbff;
  --text: #10233f;
  --muted: #56657a;
  --border: #cddcf0;
  --shadow: 0 8px 24px rgba(19, 52, 89, 0.09);
  --focus: #4f8ef7;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --page: #081522;
  --surface: #102235;
  --surface-2: #142a40;
  --text: #edf5ff;
  --muted: #b8c7d9;
  --border: #31506f;
  --shadow: none;
  --blue-soft: #132f50;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--page);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.45;
}
button, a { font: inherit; }

.app-header {
  background: linear-gradient(135deg, #052b5d 0%, #073c7d 100%);
  color: white;
  padding: max(18px, env(safe-area-inset-top)) clamp(18px, 4vw, 44px) 28px;
  text-align: center;
}
.brand-wrap {
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  width: 100%;
}

.brand-wrap .icon-button {
  margin-left: auto;
  flex: 0 0 auto;
}

.brand-logo {
  display: block;
  width: clamp(290px, 48vw, 560px);
  max-width: calc(100% - 60px);
  height: auto;
  object-fit: contain;
  flex: 0 1 auto;
}
.brand-mark {
  display: grid;
  grid-template-columns: repeat(4, 10px);
  grid-template-rows: repeat(3, 10px);
  gap: 3px;
  flex: 0 0 auto;
}
.brand-mark span { clip-path: polygon(0 0, 100% 0, 100% 100%); }
.brand-mark span:nth-child(4n+1) { background:#73c044; }
.brand-mark span:nth-child(4n+2) { background:#61c5d7; }
.brand-mark span:nth-child(4n+3) { background:#8c6bb1; }
.brand-mark span:nth-child(4n+4) { background:#f59b32; }
.brand-text { flex: 1; }
.brand-main { font-size: clamp(1.55rem, 4vw, 2.35rem); font-weight: 750; line-height: 1; }
.brand-sub { margin-top: 5px; font-size: clamp(1rem, 2.4vw, 1.45rem); line-height: 1.15; }
.icon-button {
  width: 46px;
  height: 46px;
  border: 1px solid rgba(255,255,255,.5);
  border-radius: 12px;
  background: rgba(255,255,255,.1);
  color: white;
  cursor: pointer;
}
.icon-button:hover { background: rgba(255,255,255,.18); }
.theme-icon { font-size: 1.5rem; }
.title-rule {
  max-width: 1120px;
  margin: 18px auto;
  height: 1px;
  background: rgba(255,255,255,.35);
}
.app-header h1 {
  margin: 0;
  font-size: clamp(1.65rem, 4vw, 2.7rem);
  line-height: 1.15;
  text-transform: uppercase;
  letter-spacing: .02em;
}
.patient-type {
  margin: 8px 0 0;
  color: #ffd84d;
  font-size: clamp(1rem, 2.6vw, 1.45rem);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.subtitle {
  margin: 5px 0 0;
  color: white;
  font-size: clamp(.95rem, 2.3vw, 1.18rem);
}

.app-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 24px auto 32px;
}
.intro {
  text-align: center;
  margin: 4px auto 22px;
}
.intro h2 {
  margin: 0;
  color: var(--navy-2);
  text-transform: uppercase;
  letter-spacing: .015em;
  font-size: 1.35rem;
}
html[data-theme="dark"] .intro h2 { color: #7fb4ff; }
.intro p { margin: 8px 0 0; color: var(--muted); }

.tools-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}
/* Featured general calculator: centered above the respiratory calculator grid. */
.featured-calculator {
  grid-column: 1 / -1;
  width: calc((100% - 20px) / 2);
  justify-self: center;
}

.tool-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 370px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: clamp(22px, 4vw, 34px);
  text-align: center;
}
.tool-card:hover { transform: translateY(-3px); border-color: var(--focus); box-shadow: 0 14px 32px rgba(19, 52, 89, 0.16); }
.tool-card:focus-visible { outline: 4px solid rgba(79,142,247,.4); outline-offset: 4px; }
.tool-icon {
  font-size: 1rem;
  line-height: 1.1;
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: linear-gradient(135deg, #0b58ca, #063b8d);
  color: white;
  font-size: 1.35rem;
  font-weight: 900;
  box-shadow: 0 8px 20px rgba(10,86,201,.2);
}

.tool-content { display: flex; flex: 1; flex-direction: column; }
.tool-card h2 {
  margin: 0;
  color: var(--navy-2);
  font-size: clamp(1.25rem, 2.7vw, 1.65rem);
  line-height: 1.25;
  text-transform: uppercase;
}
html[data-theme="dark"] .tool-card h2 { color: #8ebeff; }
.tool-subtitle {
  margin: 12px 0 0;
  color: #c28a00;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .025em;
}
.tool-description {
  margin: 16px auto 24px;
  max-width: 430px;
  color: var(--muted);
}
.launch-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: min(100%, 360px);
  min-height: 56px;
  margin: auto auto 0;
  border-radius: 12px;
  background: linear-gradient(135deg, #0b58ca, #063b8d);
  color: white;
  padding: 13px 22px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .02em;
  transition: filter .15s ease, transform .15s ease;
}
.launch-button:hover { filter: brightness(1.08); transform: translateY(-1px); }
.launch-button:focus-visible, .icon-button:focus-visible { outline: 4px solid rgba(79,142,247,.4); outline-offset: 3px; }

.disclaimer {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  margin-top: 20px;
  padding: 18px 22px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--blue-soft);
  color: var(--navy-2);
  box-shadow: var(--shadow);
}
html[data-theme="dark"] .disclaimer { color: #bcd9ff; }
.disclaimer p { margin: 0; }
.info-symbol {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--blue);
  font-weight: 900;
}
footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 4px 0;
  color: var(--muted);
  font-size: .86rem;
}
.noscript { margin: 20px; padding: 16px; background: #fde8e7; color: #c5221f; }

@media (max-width: 760px) {
  .tools-grid { grid-template-columns: 1fr; }
  .featured-calculator { grid-column: auto; width: 100%; }
  .tool-card { min-height: 330px; }
}
@media (max-width: 660px) {
  .app-shell { width: min(100% - 18px, 1180px); margin-top: 16px; }
  .brand-mark { grid-template-columns: repeat(4, 8px); grid-template-rows: repeat(3, 8px); }
  .icon-button { width: 42px; height: 42px; }
  footer { flex-direction: column; text-align: center; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}


/* Version 1.2: third calculator tile */
.tool-icon-placeholder {
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
}



/* Version 2.0: Clinical Reference Center */
.resource-feature {
  display: flex;
  justify-content: center;
  margin: 28px auto 0;
}
.resource-feature-card {
  width: min(760px, 100%);
  display: flex;
  align-items: center;
  gap: clamp(20px, 4vw, 36px);
  padding: clamp(24px, 4vw, 38px);
  border-radius: 20px;
  background: linear-gradient(135deg, #052b5d 0%, #0b58ca 100%);
  color: white;
  box-shadow: 0 12px 30px rgba(6,47,99,.2);
  text-align: left;
}
.resource-feature-card:hover { transform: translateY(-3px); filter: brightness(1.04); }
.resource-feature-card:focus-visible { outline: 4px solid rgba(79,142,247,.45); outline-offset: 4px; }
.resource-feature-icon { width: 96px; height: 96px; flex: 0 0 auto; display: grid; place-items: center; }
.resource-feature-icon svg { width: 100%; height: 100%; }
.resource-feature-content { flex: 1; }
.resource-feature-content h2 { margin: 0; font-size: clamp(1.5rem, 3vw, 2rem); text-transform: uppercase; }
.resource-feature-content p { margin: 10px 0 20px; color: rgba(255,255,255,.9); font-weight: 650; }
.resource-feature-card .launch-button { margin: 0; background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.45); }
.home-link { display: grid; place-items: center; text-decoration: none; }
.home-link svg { width: 24px; height: 24px; }
.resource-header .brand-wrap { gap: 10px; }
.resources-shell { max-width: 1120px; }
.library-summary {
  display: grid;
  grid-template-columns: 1fr minmax(260px, 360px);
  align-items: end;
  gap: 24px;
  margin-bottom: 26px;
  padding: 22px 24px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.library-summary h2 { margin: 0; color: var(--navy-2); text-transform: uppercase; }
html[data-theme="dark"] .library-summary h2 { color: #8ebeff; }
.library-summary p { margin: 8px 0 0; color: var(--muted); }
.search-control span { display: block; margin-bottom: 7px; font-weight: 800; color: var(--text); }
.search-control input { width: 100%; min-height: 48px; padding: 10px 13px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); color: var(--text); font: inherit; }
.search-control input:focus { outline: 4px solid rgba(79,142,247,.25); border-color: var(--focus); }
.resource-category { margin: 26px 0 0; }
.category-heading { display: flex; align-items: center; gap: 15px; margin-bottom: 14px; }
.category-heading h2 { margin: 0; color: var(--navy-2); font-size: 1.35rem; text-transform: uppercase; }
html[data-theme="dark"] .category-heading h2 { color: #8ebeff; }
.category-heading p { margin: 4px 0 0; color: var(--muted); }
.category-icon {
  min-width: 62px; height: 52px; padding: 0 9px; display: grid; place-items: center;
  border-radius: 13px; background: linear-gradient(135deg,#0b58ca,#063b8d); color: white;
  font-size: .8rem; font-weight: 900; letter-spacing: .02em;
}
.resource-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px; }
.resource-grid.single-resource { grid-template-columns: minmax(0, 1fr); }
.resource-grid.single-resource .resource-card { max-width: 760px; }
.resource-card {
  display: flex; flex-direction: column; padding: 24px; border: 1px solid var(--border); border-radius: 18px;
  background: var(--surface); box-shadow: var(--shadow);
}
.resource-card h3 { margin: 0; color: var(--navy-2); font-size: 1.2rem; line-height: 1.3; }
html[data-theme="dark"] .resource-card h3 { color: #8ebeff; }
.resource-card p { margin: 12px 0 22px; color: var(--muted); }
.resource-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: auto; }
.resource-button { min-height: 48px; display: inline-flex; align-items: center; justify-content: center; padding: 11px 16px; border-radius: 11px; font-weight: 850; text-align: center; }
.resource-button.guide { background: var(--blue-soft); color: var(--navy-2); border: 1px solid var(--border); }
html[data-theme="dark"] .resource-button.guide { color: #cde1ff; }
.resource-button.video { background: linear-gradient(135deg,#0b58ca,#063b8d); color: white; }
.resource-button:hover { filter: brightness(1.06); transform: translateY(-1px); }
.no-results { padding: 22px; text-align: center; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--muted); }
[hidden] { display: none !important; }
@media (max-width: 760px) {
  .resource-feature-card { flex-direction: column; text-align: center; }
  .resource-feature-card .launch-button { margin: 0 auto; }
  .resource-feature-icon { width: 78px; height: 78px; }
  .library-summary { grid-template-columns: 1fr; align-items: stretch; }
  .resource-grid { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .resource-actions { grid-template-columns: 1fr; }
  .category-heading { align-items: flex-start; }
}

/* Version 2.1: standardized category badges and resource equipment images */
.category-heading {
  padding-bottom: 10px;
  border-bottom: 3px solid var(--navy-2);
}
.category-icon {
  width: 132px;
  min-width: 132px;
  height: 64px;
  padding: 7px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.03;
  font-size: .72rem;
  text-transform: uppercase;
}
.category-icon span { display: block; }
.resource-card-body {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
}
.resource-copy { min-width: 0; }
.resource-copy p { margin-bottom: 0; }
.resource-image {
  width: 118px;
  height: 104px;
  object-fit: contain;
  object-position: center;
  display: block;
}
.invasive-category .category-icon {
  background: linear-gradient(135deg, #dc2626, #991b1b);
}
.invasive-category .category-heading {
  border-bottom-color: #c5221f;
}
.invasive-category .category-heading h2 {
  color: #c5221f;
}
html[data-theme="dark"] .invasive-category .category-heading h2 {
  color: #ff7a73;
}
@media (max-width: 620px) {
  .category-icon { width: 112px; min-width: 112px; height: 60px; font-size: .64rem; }
  .resource-card-body { grid-template-columns: 92px minmax(0, 1fr); gap: 14px; }
  .resource-image { width: 92px; height: 86px; }
}
@media (max-width: 430px) {
  .resource-card-body { grid-template-columns: 1fr; text-align: center; }
  .resource-image { width: 130px; height: 100px; margin: 0 auto; }
}

/* Version 2.3: category color identity and terminology updates */
.niv-category .category-icon {
  background: linear-gradient(135deg, #0f9b8e, #087f75);
}
.niv-category .category-heading {
  border-bottom-color: #0f8f83;
}
.niv-category .category-heading h2 {
  color: #0f8f83;
}
html[data-theme="dark"] .niv-category .category-heading h2 {
  color: #5eead4;
}
.hfnc-category .category-icon {
  background: linear-gradient(135deg, #7c3aed, #5b21b6);
}
.hfnc-category .category-heading {
  border-bottom-color: #6d28d9;
}
.hfnc-category .category-heading h2 {
  color: #6d28d9;
}
html[data-theme="dark"] .hfnc-category .category-heading h2 {
  color: #c4b5fd;
}

/* HFNC badge uses full terminology rather than an abbreviation. */
.hfnc-category .category-icon { font-size: .66rem; }
@media (max-width: 620px) { .hfnc-category .category-icon { font-size: .58rem; } }


/* Keep all resource-header action buttons grouped in the upper-right corner. */
.resource-header .brand-wrap .icon-button {
  margin-left: 0;
}
.resource-header .brand-wrap .home-link {
  margin-left: auto;
}


/* Version 3.0: interactive Medication Reference entry */
.medication-category .category-icon { background: linear-gradient(135deg,#e0aa00,#a87500); color:#fff; }
.medication-category .category-heading { border-bottom-color:#c28a00; }
.medication-category .category-heading h2 { color:#9a6b00; }
html[data-theme="dark"] .medication-category .category-heading h2 { color:#ffd84d; }
.medication-resource-card { }
html[data-theme="dark"] .medication-resource-card { }
.medication-symbol { width:118px; height:104px; display:grid; place-items:center; background:transparent; border-radius:0; box-shadow:none; overflow:visible; }
.medication-symbol img { width:100%; height:100%; object-fit:contain; display:block; }
.resource-actions.single-action { grid-template-columns:1fr; }
.resource-button.medication-open { background:linear-gradient(135deg,#e0aa00,#a87500); color:white; border:1px solid #a87500; text-transform:uppercase; letter-spacing:.02em; }
@media (max-width:620px) { .medication-symbol { width:92px; height:86px; } }
@media (max-width:430px) { .medication-symbol { width:130px; height:100px; margin:0 auto; } }

/* Two-section home portal */
.home-shell { max-width: 980px; }
.portal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}
.portal-card {
  min-width: 0;
  min-height: 390px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(26px, 4vw, 40px);
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
  color: var(--text);
  text-decoration: none;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.portal-card:hover { transform: translateY(-3px); border-color: var(--focus); box-shadow: 0 14px 32px rgba(19,52,89,.16); }
.portal-card:focus-visible { outline: 4px solid rgba(79,142,247,.4); outline-offset: 4px; }
.portal-icon {
  width: 100px;
  height: 100px;
  margin: 0 auto 24px;
  display: grid;
  place-items: center;
  border-radius: 24px;
  background: linear-gradient(135deg, #0b58ca, #063b8d);
  color: white;
  box-shadow: 0 8px 20px rgba(10,86,201,.2);
}
.portal-icon svg { width: 66px; height: 66px; }
.portal-content { display: flex; flex: 1; flex-direction: column; width: 100%; }
.portal-content h2 { margin: 0; color: var(--navy-2); font-size: clamp(1.45rem, 3vw, 1.9rem); text-transform: uppercase; line-height: 1.2; }
html[data-theme="dark"] .portal-content h2 { color: #8ebeff; }
.portal-content p { max-width: 380px; margin: 16px auto 26px; color: var(--muted); }
.portal-content .launch-button { margin-top: auto; }
@media (max-width: 760px) {
  .portal-grid { grid-template-columns: 1fr; gap: 16px; }
  .portal-card { min-height: 0; padding: 24px 20px; }
  .portal-icon { width: 82px; height: 82px; margin-bottom: 18px; border-radius: 20px; }
  .portal-icon svg { width: 54px; height: 54px; }
  .portal-content p { margin: 12px auto 20px; }
}
