/* ============================================================
   tools.doctor — Clinical Tools Platform
   Design: Clinical Precision — Navy × Teal × Monospace
   Mobile-first, instant-load, zero-bloat
   ============================================================ */

/* === RESET === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Core palette */
  --navy:          #0B1D35;
  --navy-mid:      #162B4A;
  --navy-border:   rgba(255,255,255,0.08);
  --teal:          #00C4B4;
  --teal-dark:     #009E91;
  --teal-glow:     rgba(0,196,180,0.12);
  --white:         #FFFFFF;
  --off-white:     #F5F7FA;
  --surface:       #FFFFFF;
  --border:        #E4E9F0;
  --border-dark:   #C9D3DF;
  --text:          #0D1B2E;
  --text-mid:      #4A5568;
  --text-light:    #8C9DB5;

  /* Type badge palette */
  --calc-fg:       #0080CC;
  --calc-bg:       #E0F0FF;
  --check-fg:      #B45309;
  --check-bg:      #FEF3C7;
  --mnem-fg:       #6D28D9;
  --mnem-bg:       #EDE9FE;
  --image-fg:      #047857;
  --image-bg:      #D1FAE5;

  /* Layout */
  --max-w:         1100px;
  --pad:           16px;
  --radius:        10px;
  --radius-sm:     6px;
  --radius-xs:     4px;

  /* Motion */
  --ease:          cubic-bezier(0.4, 0, 0.2, 1);
  --dur:           0.16s;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--off-white);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* ============================================================
   HEADER
   ============================================================ */

.site-header {
  background: var(--navy);
  position: sticky;
  top: 0;
  z-index: 500;
  border-bottom: 1px solid var(--navy-border);
}

.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--pad);
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  flex-shrink: 0;
}

.logo-cross {
  width: 28px;
  height: 28px;
  background: var(--teal);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--navy);
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
}

.logo-wordmark {
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--white);
}

.logo-dot { color: var(--teal); }

/* Header nav */
.header-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.14);
  color: rgba(255,255,255,0.7);
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 13px;
  font-weight: 400;
  padding: 5px 11px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
  white-space: nowrap;
  line-height: 1.4;
}

.nav-btn:hover {
  background: rgba(255,255,255,0.08);
  color: var(--white);
}

/* Category dropdown */
.cat-dropdown { position: relative; }

.cat-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.06);
  min-width: 200px;
  z-index: 400;
  overflow: hidden;
  animation: menuIn 0.14s var(--ease);
}

.cat-menu.open { display: block; }

@keyframes menuIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.cat-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text);
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  transition: background var(--dur) var(--ease);
  font-family: 'IBM Plex Sans', sans-serif;
}

.cat-menu-item:hover { background: var(--off-white); color: var(--teal-dark); }

.cat-count {
  margin-left: auto;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--text-light);
}

/* ============================================================
   SEARCH HERO
   ============================================================ */

.search-hero {
  background: var(--navy);
  padding: 10px var(--pad) 0;
}

.search-wrap {
  max-width: 660px;
  margin: 0 auto;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  color: rgba(255,255,255,0.35);
  pointer-events: none;
  flex-shrink: 0;
}

.search-input {
  width: 100%;
  height: 50px;
  padding: 0 52px 0 44px;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 16px;
  font-weight: 400;
  color: var(--text);
  background: var(--white);
  border: 2px solid rgba(255,255,255,0.12);
  border-radius: var(--radius);
  outline: none;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  -webkit-appearance: none;
  appearance: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.search-input::placeholder { color: var(--text-mid); }

.search-input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px var(--teal-glow);
}

/* Clear button inside search */
.search-clear {
  position: absolute;
  right: 12px;
  background: var(--border);
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-mid);
  transition: background var(--dur) var(--ease);
  line-height: 1;
}

.search-clear:hover { background: var(--border-dark); }
.search-clear.visible { display: flex; }

/* kbd hint — desktop only */
.search-kbd {
  position: absolute;
  right: 12px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--text-light);
  background: var(--off-white);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  pointer-events: none;
  display: none;
}

@media (min-width: 640px) {
  .search-kbd { display: block; }
  .search-input { height: 54px; font-size: 17px; }
}

/* Filter chips row */
.filter-chips {
  display: flex;
  gap: 5px;
  padding-top: 10px;
  padding-bottom: 12px;
  padding-right: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  flex-wrap: nowrap;
}

.filter-chips::-webkit-scrollbar { display: none; }
.chip-external { display: none !important; }
.chip {
  flex-shrink: 0;
  padding: 5px 10px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.28);
  background: transparent;
  color: rgba(255,255,255,0.72);
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 12px;
  font-weight: 400;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  white-space: nowrap;
  line-height: 1.4;
}

.chip:hover {
  background: rgba(255,255,255,0.10);
  color: rgba(255,255,255,0.92);
}

.chip.active {
  background: var(--teal);
  border-color: var(--teal);
  color: var(--navy);
  font-weight: 600;
  opacity: 1;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */

.main {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 14px var(--pad) 48px;
}

/* Sections */
.section { margin-bottom: 20px; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 10px;
}

.section-title {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-light);
}

.result-count {
  color: var(--teal-dark);
  margin-left: 6px;
  letter-spacing: 0;
}

.clear-btn {
  font-size: 12px;
  color: var(--text-light);
  background: none;
  border: none;
  cursor: pointer;
  font-family: 'IBM Plex Sans', sans-serif;
  transition: color var(--dur) var(--ease);
  padding: 2px 0;
  flex-shrink: 0;
}

.clear-btn:hover { color: var(--teal-dark); }

/* ============================================================
   CARD GRID
   ============================================================ */

.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
}

@media (min-width: 460px) {
  .card-grid { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 720px) {
  .card-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 960px) {
  .card-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ============================================================
   TOOL CARD
   ============================================================ */

.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 13px 11px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  cursor: pointer;
  transition: border-color var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease),
              transform var(--dur) var(--ease);
  text-decoration: none;
  color: inherit;
  position: relative;
  min-height: 108px;
  animation: fadeUp 0.2s var(--ease) both;
}

.card:hover {
  border-color: var(--teal);
  box-shadow: 0 4px 20px rgba(0,196,180,0.10), 0 1px 4px rgba(0,0,0,0.06);
  transform: translateY(-1px);
}

.card:active { transform: translateY(0); }

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
}

.card-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  flex: 1;
}

.card-fav {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-light);
  padding: 0 0 0 4px;
  line-height: 1;
  transition: color var(--dur) var(--ease), transform var(--dur) var(--ease);
  flex-shrink: 0;
  margin-top: -1px;
}

.card-fav:hover { color: #F59E0B; transform: scale(1.15); }
.card-fav.active { color: #F59E0B; }

.card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* Type badges */
.badge {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  white-space: nowrap;
}

.badge-calculator { color: var(--calc-fg); background: var(--calc-bg); }
.badge-checklist  { color: var(--check-fg); background: var(--check-bg); }
.badge-mnemonic   { color: var(--mnem-fg);  background: var(--mnem-bg); }
.badge-image      { color: var(--image-fg); background: var(--image-bg); }

.card-category {
  font-size: 11px;
  color: var(--text-light);
  white-space: nowrap;
}

.card-launch {
  margin-top: auto;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--teal-dark);
  transition: color var(--dur) var(--ease), letter-spacing var(--dur) var(--ease);
}

.card:hover .card-launch {
  color: var(--teal);
  letter-spacing: 0.02em;
}

/* Stagger animation for grid items */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card:nth-child(1) { animation-delay: 0.00s; }
.card:nth-child(2) { animation-delay: 0.03s; }
.card:nth-child(3) { animation-delay: 0.05s; }
.card:nth-child(4) { animation-delay: 0.07s; }
.card:nth-child(5) { animation-delay: 0.09s; }
.card:nth-child(6) { animation-delay: 0.11s; }
.card:nth-child(7) { animation-delay: 0.13s; }
.card:nth-child(8) { animation-delay: 0.15s; }

/* Keyboard nav */
.card:focus {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

/* ============================================================
   CATEGORY BROWSER
   ============================================================ */

.cat-section { margin-bottom: 28px; scroll-margin-top: 80px; }

.cat-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px 0 8px;
  border-bottom: 1px solid var(--border);
}

.cat-section-icon {
  font-size: 18px;
  line-height: 1;
}

.cat-section-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.cat-section-count {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--text-light);
  margin-left: auto;
}

/* ============================================================
   EMPTY / NO RESULTS
   ============================================================ */

.no-results {
  text-align: center;
  padding: 52px var(--pad);
  color: var(--text-mid);
}

.no-results-icon {
  display: block;
  font-size: 32px;
  color: var(--border-dark);
  margin-bottom: 14px;
  line-height: 1;
}

.no-results p { font-size: 15px; }

.no-results-hint {
  font-size: 13px !important;
  color: var(--text-light);
  margin-top: 6px;
}

/* ============================================================
   FOOTER
   ============================================================ */

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--white);
  padding: 14px var(--pad);
  text-align: center;
  font-size: 11.5px;
  color: var(--text-light);
}

/* ============================================================
   UTILITY
   ============================================================ */

.hidden { display: none !important; }

/* Scrollbar styling for browsers that support it */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-dark); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-light); }

/* PWA safe areas */
@supports (padding: env(safe-area-inset-bottom)) {
  .site-footer {
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
  }
}

/* ============================================================
   RESPONSIVE TYPOGRAPHY
   ============================================================ */

@media (min-width: 640px) {
  .card-name { font-size: 14px; }
  .logo-wordmark { font-size: 15px; }
}

/* ============================================================
   CORE TOOLS GATEWAY
   ============================================================ */

.core-tools {
  background: var(--navy);
  padding: 16px var(--pad) 0;
  border-bottom: 1px solid var(--navy-border);
}

.core-tools-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding-bottom: 16px;
}

@media (min-width: 480px) {
  .core-tools-inner { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 860px) {
  .core-tools-inner { grid-template-columns: repeat(5, 1fr); }
}

.core-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: var(--radius);
  padding: 14px;
  text-decoration: none;
  color: var(--white);
  transition: background var(--dur) var(--ease),
              border-color var(--dur) var(--ease),
              transform var(--dur) var(--ease);
  min-height: 64px;
}

.core-card:hover {
  background: rgba(0,196,180,0.12);
  border-color: var(--teal);
  transform: translateY(-1px);
}

.core-card:active { transform: translateY(0); }

.core-card-body {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.core-card-icon {
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
}

.core-card-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--white);
  line-height: 1.2;
}

.core-card-desc {
  font-size: 11px;
  color: rgba(255,255,255,0.45);
  margin-top: 2px;
  line-height: 1.3;
}

.core-card-arrow {
  font-size: 16px;
  color: var(--teal);
  flex-shrink: 0;
  transition: transform var(--dur) var(--ease);
}

.core-card:hover .core-card-arrow { transform: translateX(3px); }

/* Operation Notes badge */

/* core-card as button — reset browser defaults */
button.core-card {
  width: 100%;
  cursor: pointer;
  text-align: left;
  font-family: 'IBM Plex Sans', sans-serif;
}

.footer-links { margin-top: 6px; }
.footer-links a { color: var(--text-light); text-decoration: none; font-size: 11.5px; }
.footer-links a:hover { color: var(--teal-dark); }

/* ============================================================
   COOKIE BANNER
   ============================================================ */
#cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 999;
  background: rgba(11,29,53,0.97);
  border-top: 1px solid rgba(255,255,255,0.08);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: nowrap;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.2);
}
#cookie-banner p {
  font-size: 12px;
  color: rgba(255,255,255,0.6);
  margin: 0;
  flex: 1;
  min-width: 0;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#cookie-banner p a {
  color: var(--teal);
  text-decoration: none;
  font-weight: 500;
  margin-left: 4px;
}
#cookie-banner p a:hover { text-decoration: underline; }
.cookie-btns {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  align-items: center;
}
#accept-cookies, #reject-cookies {
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--dur) var(--ease);
  border: none;
}
#accept-cookies {
  background: var(--teal);
  color: var(--navy);
}
#accept-cookies:hover { background: var(--teal-dark); }
#reject-cookies {
  background: transparent;
  color: rgba(255,255,255,0.5);
  border: 1px solid rgba(255,255,255,0.15) !important;
}
#reject-cookies:hover {
  background: rgba(255,255,255,0.06);
  color: white;
}
@media (max-width: 480px) {
  #cookie-banner { flex-wrap: wrap; }
  #cookie-banner p { white-space: normal; min-width: 100%; }
  .cookie-btns { width: 100%; }
  #accept-cookies, #reject-cookies { flex: 1; text-align: center; }
}

/* ============================================================
   CATEGORY NAV CARDS
   ============================================================ */

.cat-card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-bottom: 28px;
}

@media (min-width: 640px) {
  .cat-card-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 960px) {
  .cat-card-grid { grid-template-columns: repeat(4, 1fr); }
}

.cat-nav-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  text-align: left;
  font-family: 'IBM Plex Sans', sans-serif;
  transition: border-color var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease),
              transform var(--dur) var(--ease);
  min-height: 60px;
  width: 100%;
}

.cat-nav-card:hover {
  border-color: var(--teal);
  box-shadow: 0 2px 12px rgba(0,196,180,0.10);
  transform: translateY(-1px);
}

.cat-nav-card:active { transform: translateY(0); }

.cat-nav-icon {
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
}

.cat-nav-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
  min-width: 0;
}

.cat-nav-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.cat-nav-count {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--text-light);
}

.cat-nav-arrow {
  font-size: 18px;
  color: var(--teal);
  flex-shrink: 0;
  transition: transform var(--dur) var(--ease);
  line-height: 1;
}

.cat-nav-card:hover .cat-nav-arrow { transform: translateX(3px); }

/* Remove Open → arrow from cards (card itself is the tap target) */
.card-launch { display: none; }

/* Section subtext */
.section-sub {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 2px;
  font-family: 'IBM Plex Sans', sans-serif;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}

/* ============================================================
   COLLAPSIBLE SPECIALTY SECTIONS
   ============================================================ */

.cat-section-toggle {
  font-size: 12px;
  color: var(--text-light);
  margin-left: 4px;
  flex-shrink: 0;
  transition: transform var(--dur) var(--ease);
}

.cat-section-header {
  cursor: pointer;
  user-select: none;
}

.cat-section-header:hover .cat-section-name {
  color: var(--teal-dark);
}

.cat-section-grid {
  transition: opacity 0.15s var(--ease);
}

.cat-section.collapsed .cat-section-grid {
  display: none;
}

/* Active state on specialty nav cards */
.cat-nav-card.active {
  border-color: var(--teal);
  background: var(--teal-glow);
  box-shadow: 0 0 0 2px var(--teal-glow);
}

/* Soften active filter chip slightly */
.chip.active {
  background: var(--teal);
  border-color: var(--teal);
  color: var(--navy);
  font-weight: 500;
  opacity: 0.9;
}

/* ============================================================
   COMPACT STICKY SEARCH HEADER (scroll state)
   ============================================================ */

.search-hero.sticky-search {
  position: sticky;
  top: 50px; /* below site-header */
  z-index: 200;
  padding: 6px var(--pad);
  background: var(--navy);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.search-hero.sticky-search .search-input {
  height: 40px;
  font-size: 15px;
}

.search-hero.sticky-search .filter-chips {
  display: none;
}

/* Improve specialty card grid spacing on desktop */
@media (min-width: 860px) {
  .cat-card-grid {
    gap: 12px;
  }
}

/* Recent section stronger visual weight */
#recentSection .section-title {
  color: var(--text-mid);
  font-size: 11.5px;
  letter-spacing: 0.06em;
}

#recentSection .section-sub {
  color: var(--text-light);
  font-size: 11.5px;
  margin-top: 1px;
}

/* Collapsible active chip override */
.chip.active {
  background: var(--teal) !important;
  border-color: var(--teal) !important;
  color: var(--navy) !important;
  font-weight: 600 !important;
  opacity: 1 !important;
}

/* ============================================================
   BACK TO TOP BUTTON
   ============================================================ */

#back-to-top {
  position: fixed;
  bottom: 80px;
  right: 16px;
  z-index: 500;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--navy);
  color: var(--teal);
  border: 1px solid rgba(0,196,180,0.3);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px rgba(0,0,0,0.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  transform: translateY(8px);
  font-family: 'IBM Plex Sans', sans-serif;
}

#back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

#back-to-top:hover {
  background: var(--navy-mid);
  border-color: var(--teal);
}

/* Mobile: tighter sticky search */
@media (max-width: 639px) {
  .search-hero.sticky-search {
    padding: 5px var(--pad);
  }

  .search-hero.sticky-search .search-input {
    height: 36px;
    font-size: 14px;
  }

  .search-hero.sticky-search .search-icon {
    width: 16px;
    height: 16px;
  }
}

/* Safe area for back-to-top on iPhone */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  #back-to-top {
    bottom: calc(80px + env(safe-area-inset-bottom));
  }
}

/* Scroll margin safety net for specialty sections */
.cat-section {
  scroll-margin-top: 110px;
}

/* Tighter mobile sticky search */
@media (max-width: 639px) {
  .search-hero.sticky-search .search-wrap {
    padding-bottom: 6px;
  }
  .search-hero.sticky-search .filter-chips {
    display: none;
  }
}

/* Fix back-to-top position — below sticky search, above browser toolbar */
#back-to-top {
  bottom: 24px !important;
  right: 16px !important;
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
  #back-to-top {
    bottom: calc(24px + env(safe-area-inset-bottom)) !important;
  }
}

/* Increase scroll-margin to fully clear both sticky bars */
.cat-section {
  scroll-margin-top: 140px !important;
}

/* ============================================================
   OP NOTE badge + PRO STRIP + NEW CATEGORY ICONS
   ============================================================ */

/* Override old teal op badge with slate surgical colour */
.badge-operation {
  color: #475569 !important;
  background: #F1F5F9 !important;
  border: 1px solid #CBD5E1 !important;
}

/* Professional Resources Strip */
.pro-strip {
  background: var(--white);
  border-bottom: 1px solid var(--border);
}

.pro-strip-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 7px var(--pad);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.pro-strip-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-light);
  flex-shrink: 0;
}

.pro-strip-divider { color: var(--border-dark); flex-shrink: 0; }

.pro-strip-text {
  color: var(--text-mid);
  font-size: 12px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pro-strip-link {
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  flex-shrink: 0;
  white-space: nowrap;
}

.pro-strip-link:hover { color: var(--teal); text-decoration: underline; }

@media (max-width: 480px) {
  .pro-strip-text { display: none; }
}

/* ============================================================
   ECOSYSTEM TILE — CVtoWebsite
   ============================================================ */

.eco-tile {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--navy-mid);
  border: 1px solid rgba(0,196,180,0.22);
  border-radius: 6px;
  text-decoration: none;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  transition: border-color var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease),
              transform var(--dur) var(--ease);
  padding: 4px 3px;
  gap: 0;
  line-height: 1;
}

.eco-tile:hover {
  border-color: rgba(0,196,180,0.55);
  box-shadow: 0 0 0 2px var(--teal-glow), 0 2px 6px rgba(0,0,0,0.25);
  transform: translateY(-1px);
}

.eco-tile:active { transform: translateY(0); }

.eco-tile .eco-line1,
.eco-tile .eco-line2 {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 7.5px;
  font-weight: 600;
  color: rgba(255,255,255,0.88);
  letter-spacing: 0.02em;
  text-align: center;
  display: block;
  line-height: 1.35;
}

@media (max-width: 639px) {
  .eco-tile .eco-line1,
  .eco-tile .eco-line2 { font-size: 7px; }
}

/* ============================================================
   USER STATS POPOVER
   ============================================================ */

/* Trigger button — matches footer link style */
.footer-link-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-light);
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 11.5px;
  padding: 0;
  outline: none;
  transition: color var(--dur) var(--ease);
}
.footer-link-btn:hover { color: var(--teal-dark); }
.footer-link-btn:focus-visible { outline: 2px solid var(--teal); border-radius: 2px; }

/* Wrapper — positions popover relative to trigger */
.ustat-trigger-wrap {
  position: relative;
  display: inline-block;
}

/* Popover */
.ustat-popover {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  width: 280px;
  background: var(--navy);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4), 0 2px 8px rgba(0,0,0,0.2);
  z-index: 600;
  opacity: 0;
  transform: translateX(-50%) translateY(6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}

.ustat-popover[hidden] { display: none; }

.ustat-popover.ustat-popover-open {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

/* Mobile — align to right edge */
@media (max-width: 500px) {
  .ustat-popover {
    left: auto;
    right: -8px;
    transform: translateY(6px);
  }
  .ustat-popover.ustat-popover-open {
    transform: translateY(0);
  }
}

/* Header */
.ustat-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

.ustat-popover-title {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.85);
}

.ustat-close {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,0.3);
  font-size: 12px;
  padding: 0;
  line-height: 1;
  outline: none;
  transition: color var(--dur) var(--ease);
}
.ustat-close:hover { color: rgba(255,255,255,0.7); }

/* Body */
.ustat-popover-body { padding: 10px 14px 8px; }

.ustat-total {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--teal);
  margin-bottom: 10px;
  letter-spacing: 0.03em;
}

.ustat-rows { display: flex; flex-direction: column; gap: 6px; }

.ustat-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ustat-country {
  font-size: 12px;
  color: rgba(255,255,255,0.68);
  width: 130px;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ustat-bar-track {
  flex: 1;
  height: 3px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
}

.ustat-bar-fill {
  height: 100%;
  background: var(--teal);
  opacity: 0.7;
  border-radius: 2px;
  min-width: 5px;
}

.ustat-count {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  width: 28px;
  text-align: right;
  flex-shrink: 0;
}

/* Footer */
.ustat-popover-footer {
  padding: 7px 14px 10px;
  font-size: 10px;
  color: rgba(255,255,255,0.2);
  font-family: 'IBM Plex Mono', monospace;
  letter-spacing: 0.05em;
  border-top: 1px solid rgba(255,255,255,0.06);
}

/* Skeleton loading */
.ustat-skeleton { display: flex; flex-direction: column; gap: 8px; padding: 4px 0; }
.ustat-skel-row {
  height: 10px;
  background: rgba(255,255,255,0.06);
  border-radius: 4px;
  animation: ustat-shimmer 1.4s ease-in-out infinite;
}
.ustat-skel-row:nth-child(2) { width: 75%; animation-delay: 0.1s; }
.ustat-skel-row:nth-child(3) { width: 55%; animation-delay: 0.2s; }

@keyframes ustat-shimmer {
  0%, 100% { opacity: 0.4; }
  50%       { opacity: 0.8; }
}

.ustat-empty {
  font-size: 12px;
  color: rgba(255,255,255,0.3);
  margin: 4px 0;
  text-align: center;
  padding: 8px 0;
}

/* ============================================================
   ONBOARDING MODAL
   ============================================================ */

.onboard-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5,15,30,0.75);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 1000;
  display: none; /* shown via JS: style.display = 'flex' */
  align-items: center;
  justify-content: center;
  padding: 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  opacity: 0;
  transition: opacity 0.25s ease;
  -webkit-overflow-scrolling: touch;
  overflow-y: auto;
}

.onboard-overlay.onboard-visible { opacity: 1; }

.onboard-modal {
  background: var(--navy);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 14px;
  padding: 28px 22px 22px;
  width: 92vw;
  max-width: 380px;
  max-height: 85vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5), 0 4px 16px rgba(0,0,0,0.3);
  transform: scale(0.96) translateY(8px);
  transition: transform 0.25s ease;
  /* Prevent modal from being taller than viewport */
  flex-shrink: 0;
}

.onboard-overlay.onboard-visible .onboard-modal {
  transform: scale(1) translateY(0);
}

/* Mobile refinements */
@media (max-width: 480px) {
  .onboard-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .onboard-modal {
    width: 100%;
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    max-height: 88vh;
    transform: translateY(24px);
    padding-bottom: max(22px, env(safe-area-inset-bottom));
  }

  .onboard-overlay.onboard-visible .onboard-modal {
    transform: translateY(0);
  }

  .onboard-close {
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.07);
    border-radius: 50%;
  }

  .onboard-btn-primary,
  .onboard-btn-secondary {
    min-height: 48px; /* larger tap targets on mobile */
  }
}

.onboard-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,0.3);
  font-size: 16px;
  padding: 4px;
  line-height: 1;
  transition: color var(--dur) var(--ease);
}
.onboard-close:hover { color: rgba(255,255,255,0.7); }

/* Steps */
.onboard-step { text-align: center; }
.onboard-step.hidden { display: none; }

.onboard-icon { font-size: 36px; margin-bottom: 14px; line-height: 1; }

.onboard-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--white);
  margin-bottom: 10px;
  line-height: 1.3;
}

.onboard-body {
  font-size: 13.5px;
  color: rgba(255,255,255,0.6);
  line-height: 1.6;
  margin-bottom: 24px;
}

.onboard-sub {
  font-size: 12.5px;
  color: rgba(255,255,255,0.45);
  line-height: 1.5;
  margin: 12px 0 20px;
}

/* Feature grid */
.onboard-features {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 4px;
}

.onboard-feature {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: rgba(255,255,255,0.7);
  font-weight: 500;
}

.onboard-feature span:first-child { font-size: 22px; line-height: 1; }

/* Buttons */
.onboard-btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--teal);
  color: var(--navy);
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--dur) var(--ease);
  margin-bottom: 10px;
}
.onboard-btn-primary:hover { background: var(--teal-dark); }

.onboard-btn-secondary {
  padding: 10px 20px;
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.6);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-sm);
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--dur) var(--ease);
}
.onboard-btn-secondary:hover { background: rgba(255,255,255,0.12); }

.onboard-btn-skip {
  background: none;
  border: none;
  cursor: pointer;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 12.5px;
  color: rgba(255,255,255,0.3);
  padding: 4px;
  transition: color var(--dur) var(--ease);
}
.onboard-btn-skip:hover { color: rgba(255,255,255,0.6); }

.onboard-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
}
.onboard-actions .onboard-btn-primary { width: auto; flex: 1; margin-bottom: 0; }

.onboard-ext-link {
  display: block;
  font-size: 12.5px;
  color: rgba(255,255,255,0.4);
  text-decoration: none;
  margin-top: 4px;
  transition: color var(--dur) var(--ease);
}
.onboard-ext-link:hover { color: var(--teal); }

/* Quick links */
.onboard-quicklinks {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.07);
}

.onboard-ql-label {
  font-size: 11px;
  color: rgba(255,255,255,0.3);
  font-family: 'IBM Plex Mono', monospace;
}

.onboard-ql {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 11.5px;
  color: rgba(255,255,255,0.55);
  cursor: pointer;
  font-family: 'IBM Plex Sans', sans-serif;
  transition: all var(--dur) var(--ease);
}
.onboard-ql:hover { border-color: var(--teal); color: var(--teal); }

/* Step dots */
.onboard-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 20px;
}

.onboard-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.onboard-dot.active {
  background: var(--teal);
  transform: scale(1.2);
}

/* Clerking badge — warm slate */
.badge-clerking { color: #0369A1; background: #E0F2FE; }

/* Test badge — cool purple */
.badge-test { color: #6D28D9; background: #EDE9FE; }

/* ============================================================
   RESOURCES POPOVER
   ============================================================ */

.res-wrap {
  position: relative;
  flex-shrink: 0;
}

.res-btn {
  cursor: pointer;
  width: auto !important;
  height: auto !important;
  padding: 0 10px;
  border-radius: 6px;
  white-space: nowrap;
}

.res-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 260px;
  background: var(--navy-mid);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  z-index: 500;
  overflow: hidden;
  animation: resIn 0.14s var(--ease);
}

.res-popover[hidden] { display: none; }

@keyframes resIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.res-popover-title {
  padding: 10px 14px 8px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.3);
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

.res-list {
  padding: 4px 0;
}

.res-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 10px 14px;
  text-decoration: none;
  background: none;
  border: none;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-family: 'IBM Plex Sans', sans-serif;
  transition: background var(--dur) var(--ease);
  -webkit-tap-highlight-color: rgba(255,255,255,0.06);
  min-height: 48px;
  box-sizing: border-box;
}

.res-item:last-child { border-bottom: none; }

.res-item:hover,
.res-item:active { background: rgba(255,255,255,0.08); }

.res-item-name {
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,0.82);
  line-height: 1.3;
}

.res-item-desc {
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  line-height: 1.4;
}

/* Mobile: align popover left if it would overflow */
@media (max-width: 400px) {
  .res-popover {
    right: auto;
    left: 0;
    width: 240px;
  }
}

/* Resources nav button — overrides eco-tile, matches nav-btn */
.res-nav-btn {
  font-size: 13px !important;
  font-weight: 500 !important;
  padding: 5px 12px !important;
  white-space: nowrap !important;
  cursor: pointer !important;
  pointer-events: auto !important;
  position: relative;
  z-index: 1;
}

.res-nav-btn[aria-expanded="true"] {
  background: rgba(255,255,255,0.10);
  color: var(--white);
}

/* ============================================================
   MOBILE FIXES — Resources button + filter chips layout
   ============================================================ */

@media (max-width: 639px) {

  /* Resources button — prevent cutoff */
  .res-nav-btn {
    font-size: 12px !important;
    padding: 5px 10px !important;
    min-width: 80px !important;
  }

  /* Filter chips — 2 fixed rows */
  .filter-chips {
    display: grid !important;
    grid-template-columns: repeat(4, auto) !important;
    grid-template-rows: auto auto !important;
    gap: 5px !important;
    overflow-x: visible !important;
    flex-wrap: unset !important;
    padding-right: 0 !important;
    justify-content: start;
  }

  /* Row 1: All, Clerking, Tests, Checklists */
  .chip[data-type="all"]        { order: 1; }
  .chip[data-type="clerking"]   { order: 2; }
  .chip[data-type="test"]       { order: 3; }
  .chip[data-type="checklist"]  { order: 4; }

  /* Row 2: Calculators, Mnemonics, Op Notes */
  .chip[data-type="calculator"] { order: 5; }
  .chip[data-type="mnemonic"]   { order: 6; }
  .chip[data-type="operation"]  { order: 7; }

  .chip {
    font-size: 11.5px !important;
    padding: 5px 9px !important;
  }
}

/* Mobile: Resources popover — prevent overflow */
@media (max-width: 639px) {
  .res-popover {
    width: calc(100vw - 32px) !important;
    right: 0 !important;
    left: auto !important;
    max-height: 70vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Guideline badge — clinical green */
.badge-guideline { color: #065F46; background: #D1FAE5; }


  .chip[data-type="calculator"] { order: 2; }
  .chip[data-type="checklist"]  { order: 3; }
  .chip[data-type="clerking"]   { order: 4; }
  .chip[data-type="guideline"]  { order: 5; }
  .chip[data-type="mnemonic"]   { order: 6; }
  .chip[data-type="operation"]  { order: 7; }
  .chip[data-type="test"]       { order: 8; }
}

/* Calculator checkbox fields */

/* ============================================================
   NATIVE TOOL PAGE — unified clean UI for all portal types
   ============================================================ */

.tool-view {
  min-height: 100vh;
  background: #F8FAFC;
  position: relative;
  z-index: 1;
}

.tool-view-inner {
  max-width: 680px;
  margin: 0 auto;
  padding: 20px var(--pad) 80px;
}

.tool-view-back {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  padding: 4px 0 16px;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 13px;
  color: var(--text-light);
  cursor: pointer;
  transition: color var(--dur) var(--ease);
}
.tool-view-back:hover { color: var(--teal-dark); }

/* Header */
.tpage { display: flex; flex-direction: column; gap: 12px; }

.tpage-header { margin-bottom: 8px; }

.tpage-title {
  font-size: clamp(24px, 5vw, 32px);
  font-weight: 700;
  color: #0F172A;
  margin: 8px 0 4px;
  line-height: 1.15;
}

.tpage-cat {
  font-size: 12px;
  color: var(--text-light);
  font-family: 'IBM Plex Mono', monospace;
  letter-spacing: 0.04em;
  margin: 0;
}

/* Description card */
.tpage-desc {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  font-size: 14px;
  color: #475569;
  line-height: 1.65;
  margin: 0;
}

/* Content sections — guidelines, clerking, on-call, op notes */
.tpage-section {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.tpage-section h2 {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin: 0 0 14px;
  font-family: 'IBM Plex Mono', monospace;
}

.tpage-section h3 {
  font-size: 13px;
  font-weight: 600;
  color: #0F172A;
  margin: 14px 0 6px;
}

.tpage-section h4 {
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  margin: 12px 0 4px;
}

.tpage-section p {
  font-size: 14px;
  color: #475569;
  line-height: 1.7;
  margin: 0 0 10px;
}

.tpage-section p:last-child { margin-bottom: 0; }

.tpage-section ul {
  padding-left: 20px;
  margin: 6px 0;
}

.tpage-section li {
  font-size: 14px;
  color: #475569;
  margin-bottom: 6px;
  line-height: 1.55;
}

.tpage-section strong { color: #0F172A; }

/* Mnemonic */
.tpage-mnemonic {
  background: var(--navy);
  color: var(--teal);
  font-family: 'IBM Plex Mono', monospace;
  font-size: clamp(28px, 8vw, 44px);
  font-weight: 700;
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  letter-spacing: 0.08em;
  word-break: break-word;
  line-height: 1.5;
}

/* Test — normal range highlight */
.tpage-highlight {
  background: var(--navy);
  border-radius: var(--radius);
  padding: 20px 22px;
  display: flex;
  align-items: flex-start;
  gap: 20px;
}

.tpage-hl-label {
  font-size: 10px;
  color: rgba(255,255,255,0.4);
  font-family: 'IBM Plex Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  flex-shrink: 0;
  padding-top: 3px;
  line-height: 1.4;
}

.tpage-hl-val {
  font-family: 'IBM Plex Mono', monospace;
  font-size: clamp(15px, 3vw, 18px);
  font-weight: 600;
  color: var(--teal);
  line-height: 1.5;
}

/* Calculator fields */
.tpage-calc {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tpage-field {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tpage-label {
  font-size: 13px;
  font-weight: 500;
  color: #334155;
  display: block;
}

.tpage-input {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #CBD5E1;
  border-radius: 8px;
  font-size: 14px;
  font-family: 'IBM Plex Sans', sans-serif;
  color: #0F172A;
  background: #F8FAFC;
  box-sizing: border-box;
  transition: border-color 0.15s ease;
  -webkit-appearance: auto;
}
.tpage-input:focus { outline: none; border-color: var(--teal); background: var(--white); }

.tpage-calc-btn {
  background: var(--navy);
  color: var(--white);
  border: none;
  border-radius: 10px;
  padding: 14px 28px;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  align-self: flex-start;
  transition: background 0.15s ease;
  margin-top: 4px;
}
.tpage-calc-btn:hover { background: #1e3a5f; }

.tpage-result {
  background: var(--navy);
  border-radius: var(--radius);
  padding: 24px 22px;
  margin-top: 4px;
}

.tpage-result-score {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 52px;
  font-weight: 700;
  color: var(--teal);
  text-align: center;
  line-height: 1;
  margin-bottom: 16px;
}

.tpage-result-interp {
  font-size: 13px;
  color: rgba(255,255,255,0.6);
  line-height: 1.6;
}
.tpage-result-interp p { margin: 0 0 6px; color: rgba(255,255,255,0.6); }
.tpage-result-err { font-size: 13px; color: #FCA5A5; margin: 0; text-align: center; }

/* Checkbox fields */
.tpage-checkbox-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}
.tpage-checkbox {
  width: 18px !important;
  height: 18px !important;
  cursor: pointer;
  accent-color: var(--teal);
  flex-shrink: 0;
}
.tpage-checkbox-label {
  font-size: 13px;
  color: #475569;
  cursor: pointer;
}

/* Tags */
.tpage-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 4px;
}

.tpage-tag {
  font-size: 11px;
  color: var(--text-light);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px;
  display: inline-block;
}

/* States */
.tpage-loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
  font-size: 14px;
}

.tpage-unavailable {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  color: var(--text-light);
  font-size: 14px;
}

@media (max-width: 480px) {
  .tool-view-inner { padding: 14px 14px 60px; }
  .tpage-title { font-size: 22px; }
  .tpage-section { padding: 14px 16px; }
  .tpage-field { padding: 12px 14px; }
  .tpage-highlight { padding: 16px 18px; gap: 14px; }
  .tpage-result { padding: 18px 16px; }
  .tpage-result-score { font-size: 40px; }
}

/* Mobile chip order + hide Medical Dictionary */
@media (max-width: 639px) {
  .chip-external { display: none !important; }

  .chip[data-type="all"]        { order: 1; }
  .chip[data-type="oncall"]     { order: 2; }
  .chip[data-type="calculator"] { order: 3; }
  .chip[data-type="checklist"]  { order: 4; }
  .chip[data-type="clerking"]   { order: 5; }
  .chip[data-type="guideline"]  { order: 6; }
  .chip[data-type="mnemonic"]   { order: 7; }
  .chip[data-type="operation"]  { order: 8; }
  .chip[data-type="test"]       { order: 9; }
}
/* ============================================================
   TOOL PAGE — improved content typography
   ============================================================ */

/* Numbered steps */
.tpage-section ol.tpage-ol {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: tpage-step;
}

.tpage-section ol.tpage-ol > li {
  counter-increment: tpage-step;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid #F1F5F9;
  font-size: 14px;
  color: #334155;
  line-height: 1.65;
  margin: 0;
}

.tpage-section ol.tpage-ol > li:last-child { border-bottom: none; padding-bottom: 0; }

.tpage-section ol.tpage-ol > li::before {
  content: counter(tpage-step);
  min-width: 22px;
  height: 22px;
  background: var(--navy);
  color: var(--teal);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

/* Bullet lists */
.tpage-section ul.tpage-ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.tpage-section ul.tpage-ul > li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 8px 0;
  border-bottom: 1px solid #F1F5F9;
  font-size: 14px;
  color: #334155;
  line-height: 1.65;
  margin: 0;
}

.tpage-section ul.tpage-ul > li:last-child { border-bottom: none; padding-bottom: 0; }

.tpage-section ul.tpage-ul > li::before {
  content: '›';
  color: var(--teal);
  font-size: 18px;
  font-weight: 700;
  flex-shrink: 0;
  line-height: 1.3;
}

/* Pipe-delimited bullet lists (on-call / guideline content) */
.tpage-section ul.tpage-pipe-list {
  list-style: none;
  padding: 0;
  margin: 4px 0 0;
}

.tpage-section ul.tpage-pipe-list > li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 7px 0;
  border-bottom: 1px solid #F1F5F9;
  font-size: 14px;
  color: #334155;
  line-height: 1.6;
  margin: 0;
}

.tpage-section ul.tpage-pipe-list > li:last-child { border-bottom: none; padding-bottom: 0; }

.tpage-section ul.tpage-pipe-list > li::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--teal);
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 7px;
}

/* Section divider (between || blocks) */
.tpage-rule {
  height: 1px;
  background: var(--border);
  margin: 18px 0;
}

/* Section label (heading within pipe content, e.g. "Management:") */
p.tpage-section-label {
  font-size: 10px !important;
  font-weight: 700 !important;
  color: var(--text-light) !important;
  text-transform: uppercase !important;
  letter-spacing: 0.1em !important;
  margin: 0 0 6px !important;
  font-family: 'IBM Plex Mono', monospace !important;
}
