/* Shared presentation for interactive study tools.
   Loaded after each tool's own CSS. Maps tool tokens onto the 2026
   design system and restyles chrome, panels, buttons, and inputs.
   Clinical status colors (alarms, acid/base, oxygen) stay distinct. */

body.ds.tool-page {
  --maxw: 1120px;
}

body.ds.tool-page .tool-root {
  --bg: #07080d;
  --surface: #101218;
  --surface-2: rgba(255, 255, 255, 0.06);
  --sunk: rgba(255, 255, 255, 0.06);
  --panel: #101218;
  --panel2: #181b24;
  --panel3: #222633;
  --ink: #f4f4f5;
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --text-muted: #a1a1aa;
  --text-subtle: #b4b4be;
  --dim: #b4b4be;
  --line: rgba(255, 255, 255, 0.12);
  --border: rgba(255, 255, 255, 0.12);
  --accent: #a5b4fc;
  --accent-ink: #1e1b4b;
  --accent-soft: rgba(165, 180, 252, 0.16);
  --accent-dim: rgba(165, 180, 252, 0.16);
  --accent-text: #c7d2fe;
  --teal: #a5b4fc;
  --teal-dim: rgba(165, 180, 252, 0.12);
  --teal-dim2: rgba(165, 180, 252, 0.22);
  --tutor: #141824;
  --me: #1c2438;
  --soft: rgba(165, 180, 252, 0.14);
  --navy: #12141c;
  --navy-ink: #e0e7ff;
  --gold: #fbbf24;
  --gold-soft: rgba(251, 191, 36, 0.14);
  --label: #fde68a;
  --label-ink: #1c1917;
  --ok: #4ade80;
  --ok-soft: rgba(74, 222, 128, 0.14);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.14);
  --bad: #fb7185;
  --bad-soft: rgba(251, 113, 133, 0.14);
  --alert: #fb7185;
  --alert-soft: rgba(251, 113, 133, 0.14);
  --critical: #fca5a5;
  --critical-dim: rgba(252, 165, 165, 0.14);
  --warning: #fdba74;
  --warning-dim: rgba(253, 186, 116, 0.14);
  --good: #86efac;
  --good-dim: rgba(134, 239, 172, 0.14);
  --info: #93c5fd;
  --info-dim: rgba(147, 197, 253, 0.14);
  --type1: #93c5fd;
  --type1-dim: rgba(147, 197, 253, 0.14);
  --type2: #d8b4fe;
  --type2-dim: rgba(216, 180, 254, 0.14);
  --red: #fca5a5;
  --yellow: #fde68a;
  --blue: #93c5fd;
  --purple: #d8b4fe;
  --orange: #fdba74;
  --green: #86efac;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
  --f-body: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --f-display: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --f-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text);
  font-family: var(--f-body);
  font-size: 16px;
  line-height: 1.55;
}

html.theme-light body.ds.tool-page .tool-root {
  --bg: #f5f6fb;
  --surface: #ffffff;
  --surface-2: rgba(15, 23, 42, 0.04);
  --sunk: rgba(15, 23, 42, 0.04);
  --panel: #ffffff;
  --panel2: #f3f4f8;
  --panel3: #e7e9f2;
  --ink: #0b1020;
  --text: #0b1020;
  --muted: #52607a;
  --text-muted: #52607a;
  --text-subtle: #52607a;
  --dim: #3f4d66;
  --line: rgba(15, 23, 42, 0.12);
  --border: rgba(15, 23, 42, 0.12);
  --accent: #4338ca;
  --accent-ink: #ffffff;
  --accent-soft: rgba(67, 56, 202, 0.1);
  --accent-dim: rgba(67, 56, 202, 0.1);
  --accent-text: #312e81;
  --teal: #4338ca;
  --teal-dim: rgba(67, 56, 202, 0.08);
  --teal-dim2: rgba(67, 56, 202, 0.14);
  --tutor: #ffffff;
  --me: #eef2ff;
  --soft: rgba(67, 56, 202, 0.08);
  --navy: #eef2ff;
  --navy-ink: #312e81;
  --gold: #92400e;
  --gold-soft: #fef3c7;
  --label: #fde68a;
  --label-ink: #1c1917;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #ffedd5;
  --bad: #be123c;
  --bad-soft: #ffe4e6;
  --alert: #be123c;
  --alert-soft: #ffe4e6;
  --critical: #b91c1c;
  --critical-dim: #fee2e2;
  --warning: #c2410c;
  --warning-dim: #ffedd5;
  --good: #15803d;
  --good-dim: #dcfce7;
  --info: #1d4ed8;
  --info-dim: #dbeafe;
  --type1: #1d4ed8;
  --type1-dim: #dbeafe;
  --type2: #6d28d9;
  --type2-dim: #ede9fe;
  --red: #be123c;
  --yellow: #a16207;
  --blue: #1d4ed8;
  --purple: #6d28d9;
  --orange: #c2410c;
  --green: #15803d;
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
}

body.ds.tool-page .tool-root,
body.ds.tool-page .tool-root button,
body.ds.tool-page .tool-root input,
body.ds.tool-page .tool-root textarea,
body.ds.tool-page .tool-root select,
body.ds.tool-page .tool-root h1,
body.ds.tool-page .tool-root h2,
body.ds.tool-page .tool-root h3,
body.ds.tool-page .tool-root .brand h1,
body.ds.tool-page .tool-root .page-title,
body.ds.tool-page .tool-root .sec-title {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body.ds.tool-page .tool-root h1 {
  font-size: clamp(1.7rem, 3vw, 2.25rem);
  letter-spacing: -0.035em;
  line-height: 1.12;
  color: var(--text);
  margin: 0 0 6px;
}

body.ds.tool-page .tool-root h2,
body.ds.tool-page .tool-root h3 {
  color: var(--text);
  letter-spacing: -0.03em;
}

body.ds.tool-page .tool-root.wrap,
body.ds.tool-page .tool-root .wrap {
  max-width: 1360px;
}

body.ds.tool-page .site-header > .wrap {
  max-width: var(--maxw);
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
}

body.ds.tool-page .tool-root .top,
body.ds.tool-page .tool-root .page-header,
body.ds.tool-page .tool-root header.top {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: none;
}

body.ds.tool-page .tool-root .top .brand p,
body.ds.tool-page .tool-root .top .unit,
body.ds.tool-page .tool-root .top .score,
body.ds.tool-page .tool-root .top .score b,
body.ds.tool-page .tool-root .brand p,
body.ds.tool-page .tool-root .page-sub,
body.ds.tool-page .tool-root .lede {
  color: var(--muted);
}

body.ds.tool-page .tool-root .panel,
body.ds.tool-page .tool-root .card,
body.ds.tool-page .tool-root .q-card,
body.ds.tool-page .tool-root .insulin-card,
body.ds.tool-page .tool-root .comp-card,
body.ds.tool-page .tool-root .board,
body.ds.tool-page .tool-root .study,
body.ds.tool-page .tool-root details.pocket,
body.ds.tool-page .tool-root .compare-wrap,
body.ds.tool-page .tool-root .exam-q {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--text);
  box-shadow: none;
}

body.ds.tool-page .tool-root .card:hover,
body.ds.tool-page .tool-root .q-card:hover,
body.ds.tool-page .tool-root .comp-card:hover {
  transform: none;
  box-shadow: none;
}

body.ds.tool-page .tool-root .btn,
body.ds.tool-page .tool-root a.btn,
body.ds.tool-page .tool-root button.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 999px;
  background: #f4f4f5;
  color: #111827;
  border: 1px solid transparent;
  font-weight: 700;
  text-decoration: none;
  padding: 9px 16px;
  cursor: pointer;
  line-height: 1.2;
}

body.ds.tool-page .tool-root .btn:hover,
body.ds.tool-page .tool-root a.btn:hover {
  background: #fff;
  color: #111827;
  text-decoration: none;
}

html.theme-light body.ds.tool-page .tool-root .btn,
html.theme-light body.ds.tool-page .tool-root a.btn,
html.theme-light body.ds.tool-page .tool-root button.btn {
  background: #111827;
  color: #fff;
}

html.theme-light body.ds.tool-page .tool-root .btn:hover,
html.theme-light body.ds.tool-page .tool-root a.btn:hover {
  background: #000;
  color: #fff;
}

body.ds.tool-page .tool-root .btn.ghost,
body.ds.tool-page .tool-root .btn-outline,
body.ds.tool-page .tool-root button.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  font-weight: 600;
}

body.ds.tool-page .tool-root .btn.ghost:hover,
body.ds.tool-page .tool-root .btn-outline:hover,
html.theme-light body.ds.tool-page .tool-root .btn.ghost,
html.theme-light body.ds.tool-page .tool-root .btn.ghost:hover,
html.theme-light body.ds.tool-page .tool-root button.btn.ghost {
  background: var(--chip);
  color: var(--text);
  border-color: rgba(129, 140, 248, 0.6);
}

body.ds.tool-page .tool-root .btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

body.ds.tool-page .tool-root input,
body.ds.tool-page .tool-root textarea,
body.ds.tool-page .tool-root select,
body.ds.tool-page .tool-root .search {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
}

body.ds.tool-page .tool-root :focus-visible {
  outline: 2px solid #22d3ee;
  outline-offset: 3px;
}

body.ds.tool-page .tool-root .chip,
body.ds.tool-page .tool-root .mode,
body.ds.tool-page .tool-root .tab,
body.ds.tool-page .tool-root .pt,
body.ds.tool-page .tool-root .opt,
body.ds.tool-page .tool-root .option,
body.ds.tool-page .tool-root .room,
body.ds.tool-page .tool-root .nav-btn,
body.ds.tool-page .tool-root .nav-a {
  border-radius: 12px;
}

body.ds.tool-page .tool-root .tab:disabled,
body.ds.tool-page .tool-root .pt.locked,
body.ds.tool-page .tool-root .pt:disabled,
body.ds.tool-page .tool-root .nav-btn:disabled,
body.ds.tool-page .tool-root .mode:disabled,
body.ds.tool-page .tool-root .nav-a.is-locked {
  opacity: 0.55;
  cursor: not-allowed;
}

body.ds.tool-page .tool-root .nav {
  margin-left: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

body.ds.tool-page .sample-end {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 16px;
  padding: 20px 20px 8px;
  margin: 18px 0 8px;
}

body.ds.tool-page .sample-end p {
  margin: 0 0 12px;
  color: var(--text);
  font-size: 1.05rem;
  line-height: 1.45;
}

body.ds.tool-page .sample-end .hint,
body.ds.tool-page .tool-note {
  color: var(--muted);
  font-size: 0.875rem;
}

body.ds.tool-page .tool-root .sticky-nav,
body.ds.tool-page .tool-root .mh-nav,
body.ds.tool-page .tool-root nav.tabs {
  position: sticky;
  top: 64px;
  z-index: 5;
  background: rgba(7, 8, 13, 0.92);
  border: 1px solid var(--line);
  border-radius: 16px;
  backdrop-filter: blur(16px);
}

html.theme-light body.ds.tool-page .tool-root .sticky-nav,
html.theme-light body.ds.tool-page .tool-root .mh-nav,
html.theme-light body.ds.tool-page .tool-root nav.tabs {
  background: rgba(245, 246, 251, 0.92);
}

body.ds.tool-page .site-footer .tool-note {
  max-width: 78ch;
}

body.ds.page-tools .tool-gallery {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 760px) {
  body.ds.page-tools .tool-gallery { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 1100px) {
  body.ds.page-tools .tool-gallery { grid-template-columns: 1fr 1fr 1fr; }
}

body.ds .free-badge {
  display: inline-flex;
  align-self: flex-start;
  margin: 0;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(129, 140, 248, 0.45);
  background: rgba(99, 102, 241, 0.16);
  color: #c7d2fe;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

html.theme-light body.ds .free-badge {
  color: #3730a3;
  background: #e0e7ff;
  border-color: #c7d2fe;
}

body.ds.page-tools .tool-gallery h3 a {
  color: var(--text);
  text-decoration: none;
}

body.ds.page-tools .tool-gallery h3 a:hover {
  color: var(--accent);
}

@media (max-width: 700px) {
  body.ds.tool-page .tool-root .sticky-nav,
  body.ds.tool-page .tool-root .mh-nav,
  body.ds.tool-page .tool-root nav.tabs {
    top: 56px;
  }
}
