/* ==========================================================================
   JFK Clinical Reference Dashboard — Shared Stylesheet
   Dark-first clinical theme with light mode toggle
   Fonts: General Sans (body) + Satoshi (headings) from Fontshare
   ========================================================================== */


/* ==========================================================================
   1. RESET & BASE
   ========================================================================== */

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

html {
  -moz-text-size-adjust: none;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  hanging-punctuation: first last;
  scroll-padding-top: 5rem;
}

body {
  min-height: 100dvh;
  line-height: 1.6;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--text);
  background-color: var(--bg);
}

img, picture, video, canvas, svg { display: block; max-width: 100%; height: auto; }
ul[role="list"], ol[role="list"] { list-style: none; }
input, button, textarea, select { font: inherit; color: inherit; }

h1, h2, h3, h4, h5, h6 { text-wrap: balance; line-height: 1.2; }
p, li, figcaption { text-wrap: pretty; max-width: 72ch; }

button { cursor: pointer; background: none; border: none; }
table { border-collapse: collapse; width: 100%; }

a { color: var(--teal); text-decoration: none; }
a:hover { color: var(--teal-dim); }

::selection {
  background: var(--teal-bg);
  color: var(--text);
}

:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

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

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


/* ==========================================================================
   2. DESIGN TOKENS
   ========================================================================== */

:root {
  /* --- Fonts --- */
  --font-body:    'General Sans', 'Inter', sans-serif;
  --font-display: 'Satoshi', 'Inter', sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

  /* --- Fluid Type Scale --- */
  --text-xs:   clamp(0.75rem,  0.7rem  + 0.25vw, 0.875rem);   /* 12→14px */
  --text-sm:   clamp(0.875rem, 0.8rem  + 0.35vw, 1rem);       /* 14→16px */
  --text-base: clamp(1rem,     0.95rem + 0.25vw, 1.125rem);    /* 16→18px */
  --text-lg:   clamp(1.125rem, 1rem    + 0.75vw, 1.5rem);      /* 18→24px */
  --text-xl:   clamp(1.5rem,   1.2rem  + 1.25vw, 2.25rem);     /* 24→36px */

  /* --- Spacing (4px base) --- */
  --space-1:  0.25rem;   /*  4px */
  --space-2:  0.5rem;    /*  8px */
  --space-3:  0.75rem;   /* 12px */
  --space-4:  1rem;      /* 16px */
  --space-5:  1.25rem;   /* 20px */
  --space-6:  1.5rem;    /* 24px */
  --space-8:  2rem;      /* 32px */
  --space-10: 2.5rem;    /* 40px */
  --space-12: 3rem;      /* 48px */
  --space-16: 4rem;      /* 64px */
  --space-20: 5rem;      /* 80px */

  /* --- Radius --- */
  --radius-sm:  0.25rem;  /* 4px */
  --radius-md:  0.5rem;   /* 8px */
  --radius-lg:  0.75rem;  /* 12px */
  --radius-xl:  1rem;     /* 16px */
  --radius-full: 9999px;

  /* --- Transitions (specific properties only — never "all") --- */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --duration: 180ms;

  /* --- Content Width --- */
  --content-max: 900px;
}


/* --------------------------------------------------------------------------
   2a. DARK THEME (default)
   -------------------------------------------------------------------------- */
:root {
  /* Surfaces */
  --bg:         #0d1117;
  --surface:    #161b22;
  --surface-2:  #1c2129;
  --surface-3:  #21262d;

  /* Borders */
  --border:     #30363d;

  /* Text */
  --text:           #e6edf3;
  --text-secondary: #8b949e;
  --text-muted:     #656d76;

  /* Accents */
  --teal:     #2dd4bf;
  --teal-dim: #14b8a6;
  --amber:    #fbbf24;
  --red:      #f87171;

  /* Alpha / background variants */
  --teal-bg:  rgba(45, 212, 191, 0.12);
  --teal-bg2: rgba(45, 212, 191, 0.08);
  --amber-bg: rgba(251, 191, 36, 0.12);
  --amber-bg2: rgba(251, 191, 36, 0.08);
  --red-bg:   rgba(248, 113, 113, 0.12);
  --red-bg2:  rgba(248, 113, 113, 0.08);

  /* Semantic borders */
  --teal-border:  rgba(45, 212, 191, 0.25);
  --amber-border: rgba(251, 191, 36, 0.25);
  --red-border:   rgba(248, 113, 113, 0.25);

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
}


/* --------------------------------------------------------------------------
   2b. LIGHT THEME
   -------------------------------------------------------------------------- */
[data-theme="light"] {
  /* Surfaces */
  --bg:         #f8fafc;
  --surface:    #ffffff;
  --surface-2:  #f8fafc;
  --surface-3:  #f1f5f9;

  /* Borders */
  --border:     #d1d5db;

  /* Text */
  --text:           #0f172a;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;

  /* Accents */
  --teal:     #0d9488;
  --teal-dim: #0f766e;
  --amber:    #d97706;
  --red:      #dc2626;

  /* Alpha / background variants */
  --teal-bg:  rgba(13, 148, 136, 0.1);
  --teal-bg2: rgba(13, 148, 136, 0.06);
  --amber-bg: rgba(217, 119, 6, 0.1);
  --amber-bg2: rgba(217, 119, 6, 0.06);
  --red-bg:   rgba(220, 38, 38, 0.1);
  --red-bg2:  rgba(220, 38, 38, 0.06);

  /* Semantic borders */
  --teal-border:  rgba(13, 148, 136, 0.3);
  --amber-border: rgba(217, 119, 6, 0.3);
  --red-border:   rgba(220, 38, 38, 0.3);

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.12);
}

/* System-preference fallback for light mode (if no toggle yet) */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg:         #f8fafc;
    --surface:    #ffffff;
    --surface-2:  #f8fafc;
    --surface-3:  #f1f5f9;
    --border:     #d1d5db;
    --text:           #0f172a;
    --text-secondary: #475569;
    --text-muted:     #94a3b8;
    --teal:     #0d9488;
    --teal-dim: #0f766e;
    --amber:    #d97706;
    --red:      #dc2626;
    --teal-bg:  rgba(13, 148, 136, 0.1);
    --teal-bg2: rgba(13, 148, 136, 0.06);
    --amber-bg: rgba(217, 119, 6, 0.1);
    --amber-bg2: rgba(217, 119, 6, 0.06);
    --red-bg:   rgba(220, 38, 38, 0.1);
    --red-bg2:  rgba(220, 38, 38, 0.06);
    --teal-border:  rgba(13, 148, 136, 0.3);
    --amber-border: rgba(217, 119, 6, 0.3);
    --red-border:   rgba(220, 38, 38, 0.3);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.12);
  }
}


/* ==========================================================================
   3. TYPOGRAPHY
   ========================================================================== */

/* Section title — e.g. "Alcohol Withdrawal Protocol" */
.section-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  margin-bottom: var(--space-6);
}

/* Subsection title — e.g. "CIWA Assessment" */
.subsection-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
  margin-bottom: var(--space-4);
}

/* Detail title — e.g. individual drug name or step label */
.detail-title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--space-2);
}

/* Body text */
.body-text {
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Small / meta text */
.meta-text {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Tabular numbers for clinical data */
.tabular-nums {
  font-variant-numeric: tabular-nums lining-nums;
}


/* ==========================================================================
   4. LAYOUT
   ========================================================================== */

/* Single-column centered layout */
.page-layout {
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--space-4);
  padding-block: var(--space-6);
}


/* --------------------------------------------------------------------------
   4a. TOP BAR — sticky header with solid background (no blur)
   -------------------------------------------------------------------------- */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.top-bar-inner {
  max-width: var(--content-max);
  margin-inline: auto;
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* Back button */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-md);
  white-space: nowrap;
  flex-shrink: 0;
  transition: color var(--duration) var(--ease-out),
              background-color var(--duration) var(--ease-out);
}

.back-btn:hover {
  color: var(--teal);
  background-color: var(--teal-bg2);
}

.back-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Search bar */
.search-bar {
  flex: 1;
  min-width: 0;
  position: relative;
}

.search-bar input {
  width: 100%;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  padding-left: var(--space-8);
  font-size: var(--text-sm);
  color: var(--text);
  transition: border-color var(--duration) var(--ease-out),
              box-shadow var(--duration) var(--ease-out);
}

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

.search-bar input:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-bg);
}

.search-bar .search-icon {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}


/* --------------------------------------------------------------------------
   4b. BREADCRUMB
   -------------------------------------------------------------------------- */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--text-muted);
  padding: var(--space-3) 0;
  margin-bottom: var(--space-4);
}

.breadcrumb a {
  color: var(--text-secondary);
  transition: color var(--duration) var(--ease-out);
}

.breadcrumb a:hover {
  color: var(--teal);
}

.breadcrumb .separator {
  color: var(--text-muted);
  user-select: none;
}

.breadcrumb .current {
  color: var(--text);
  font-weight: 500;
}


/* ==========================================================================
   5. COMPONENTS
   ========================================================================== */


/* --------------------------------------------------------------------------
   5a. SMARTPHRASE CHIPS (.sp)
   -------------------------------------------------------------------------- */
.sp {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--teal);
  background-color: var(--teal-bg);
  border: 1px solid var(--teal-border);
  border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-2);
  cursor: pointer;
  user-select: all;
  white-space: nowrap;
  transition: background-color var(--duration) var(--ease-out),
              border-color var(--duration) var(--ease-out);
}

.sp:hover {
  background-color: var(--teal-bg2);
  border-color: var(--teal);
}

/* Period prefix removed — dot phrases already include the leading period in their text content */


/* --------------------------------------------------------------------------
   5b. BANNERS — Hold / Warning / Info
   -------------------------------------------------------------------------- */

/* Shared banner base */
.hold-banner,
.warning-banner,
.info-banner {
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  font-size: var(--text-sm);
  line-height: 1.5;
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}

.hold-banner .banner-icon,
.warning-banner .banner-icon,
.info-banner .banner-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 1px;
}

.hold-banner .banner-content,
.warning-banner .banner-content,
.info-banner .banner-content {
  flex: 1;
  min-width: 0;
}

/* Hold banner — red */
.hold-banner {
  background-color: var(--red-bg);
  border: 1px solid var(--red-border);
  color: var(--red);
}

.hold-banner strong {
  font-weight: 700;
}

/* Warning banner — amber */
.warning-banner {
  background-color: var(--amber-bg);
  border: 1px solid var(--amber-border);
  color: var(--amber);
}

.warning-banner strong {
  font-weight: 700;
}

/* Info banner — teal */
.info-banner {
  background-color: var(--teal-bg);
  border: 1px solid var(--teal-border);
  color: var(--teal);
}

.info-banner strong {
  font-weight: 700;
}


/* --------------------------------------------------------------------------
   5c. PROTOCOL CARD — Expandable section
   -------------------------------------------------------------------------- */
.protocol-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-3);
  overflow: hidden;
}

.protocol-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  user-select: none;
  gap: var(--space-3);
  transition: background-color var(--duration) var(--ease-out);
}

.protocol-header:hover {
  background-color: var(--surface-2);
}

.protocol-header-text {
  flex: 1;
  min-width: 0;
}

.protocol-header-title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text);
}

.protocol-header-subtitle {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-top: var(--space-1);
}

/* Chevron — rotates on expand */
.protocol-chevron {
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform var(--duration) var(--ease-out),
              color var(--duration) var(--ease-out);
}

.protocol-card.expanded .protocol-chevron {
  transform: rotate(180deg);
  color: var(--teal);
}

/* Body — hidden by default, shown when expanded */
.protocol-body {
  display: none;
  padding: 0 var(--space-4) var(--space-4);
  border-top: 1px solid var(--border);
}

.protocol-card.expanded .protocol-body {
  display: block;
}

.protocol-body-inner {
  padding-top: var(--space-4);
}


/* --------------------------------------------------------------------------
   5d. TAPER TABLE — Protocol taper schedule
   -------------------------------------------------------------------------- */
.taper-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
}

.taper-table thead {
  background-color: var(--surface-2);
}

.taper-table th {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  padding: var(--space-2) var(--space-3);
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.taper-table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-variant-numeric: tabular-nums lining-nums;
}

.taper-table tbody tr {
  transition: background-color var(--duration) var(--ease-out);
}

.taper-table tbody tr:hover {
  background-color: var(--surface-2);
}

.taper-table tbody tr:last-child td {
  border-bottom: none;
}

/* Highlight rows for active day / current step */
.taper-table .active-row {
  background-color: var(--teal-bg2);
}

.taper-table .active-row td {
  color: var(--teal);
  font-weight: 500;
}


/* --------------------------------------------------------------------------
   5e. PRN BOX — Highlighted PRN medication
   -------------------------------------------------------------------------- */
.prn-box {
  background-color: var(--amber-bg);
  border: 1px solid var(--amber-border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
}

.prn-box .prn-label {
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--amber);
  margin-bottom: var(--space-1);
}

.prn-box .prn-drug {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--space-1);
}

.prn-box .prn-details {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.5;
}


/* --------------------------------------------------------------------------
   5f. WORKFLOW PHASE — Expandable workflow section
   -------------------------------------------------------------------------- */
.workflow-phase {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-3);
  overflow: hidden;
}

.workflow-phase-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  user-select: none;
  gap: var(--space-3);
  transition: background-color var(--duration) var(--ease-out);
}

.workflow-phase-header:hover {
  background-color: var(--surface-2);
}

.workflow-phase-header-text {
  flex: 1;
  min-width: 0;
}

.workflow-phase-title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text);
}

.workflow-phase-subtitle {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-top: var(--space-1);
}

.workflow-phase-chevron {
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform var(--duration) var(--ease-out),
              color var(--duration) var(--ease-out);
}

.workflow-phase.expanded .workflow-phase-chevron {
  transform: rotate(180deg);
  color: var(--teal);
}

/* Body — hidden by default */
.workflow-phase-body {
  display: none;
  padding: 0 var(--space-4) var(--space-4);
  border-top: 1px solid var(--border);
}

.workflow-phase.expanded .workflow-phase-body {
  display: block;
}

.workflow-phase-body-inner {
  padding-top: var(--space-4);
}


/* --------------------------------------------------------------------------
   5g. VIEW TOGGLE — Detailed / Checklist switch
   -------------------------------------------------------------------------- */
.view-toggle {
  display: inline-flex;
  background-color: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: var(--space-4);
}

.view-toggle button {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 500;
  padding: var(--space-2) var(--space-3);
  color: var(--text-secondary);
  border-right: 1px solid var(--border);
  transition: color var(--duration) var(--ease-out),
              background-color var(--duration) var(--ease-out);
}

.view-toggle button:last-child {
  border-right: none;
}

.view-toggle button:hover {
  color: var(--text);
  background-color: var(--surface-3);
}

.view-toggle button.active {
  color: var(--teal);
  background-color: var(--surface);
  font-weight: 600;
}


/* --------------------------------------------------------------------------
   5h. CHECKLIST TABLE
   -------------------------------------------------------------------------- */
.checklist-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.checklist-table th {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  padding: var(--space-2) var(--space-3);
  text-align: left;
  border-bottom: 2px solid var(--border);
  background-color: var(--surface-2);
}

.checklist-table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

.checklist-table tbody tr {
  transition: background-color var(--duration) var(--ease-out);
}

.checklist-table tbody tr:hover {
  background-color: var(--surface-2);
}

/* Styled teal checkboxes */
.checklist-table input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background-color: var(--surface);
  cursor: pointer;
  position: relative;
  vertical-align: middle;
  flex-shrink: 0;
  transition: border-color var(--duration) var(--ease-out),
              background-color var(--duration) var(--ease-out);
}

.checklist-table input[type="checkbox"]:hover {
  border-color: var(--teal);
}

.checklist-table input[type="checkbox"]:checked {
  background-color: var(--teal);
  border-color: var(--teal);
}

.checklist-table input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 5px;
  width: 5px;
  height: 9px;
  border: solid var(--bg);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.checklist-table input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}


/* --------------------------------------------------------------------------
   5i. CARD GRID — Landing page navigation cards
   -------------------------------------------------------------------------- */
.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

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

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

/* Landing card — clickable navigation tile */
.landing-card {
  display: flex;
  flex-direction: column;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: border-color var(--duration) var(--ease-out),
              box-shadow var(--duration) var(--ease-out),
              transform var(--duration) var(--ease-out);
}

.landing-card:hover {
  border-color: var(--teal-border);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  color: inherit;
}

.landing-card-icon {
  width: 40px;
  height: 40px;
  color: var(--teal);
  margin-bottom: var(--space-3);
}

.landing-card-title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--space-1);
}

.landing-card-desc {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  line-height: 1.5;
}

.landing-card-arrow {
  margin-top: auto;
  padding-top: var(--space-3);
  color: var(--teal);
  font-size: var(--text-sm);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: var(--space-1);
}


/* --------------------------------------------------------------------------
   5j. BACK TO TOP — Floating button, bottom-right
   -------------------------------------------------------------------------- */
.back-to-top {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 90;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration) var(--ease-out),
              background-color var(--duration) var(--ease-out),
              color var(--duration) var(--ease-out);
}

.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
}

.back-to-top:hover {
  background-color: var(--teal-bg);
  color: var(--teal);
  border-color: var(--teal-border);
}

.back-to-top svg {
  width: 18px;
  height: 18px;
}


/* --------------------------------------------------------------------------
   5k. THEME TOGGLE — Light/dark switch in header
   -------------------------------------------------------------------------- */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: color var(--duration) var(--ease-out),
              background-color var(--duration) var(--ease-out);
}

.theme-toggle:hover {
  color: var(--teal);
  background-color: var(--teal-bg2);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
}


/* --------------------------------------------------------------------------
   5l. FOOTER
   -------------------------------------------------------------------------- */
.footer {
  border-top: 1px solid var(--border);
  padding: var(--space-6) var(--space-4);
  margin-top: var(--space-10);
  text-align: center;
}

.footer-inner {
  max-width: var(--content-max);
  margin-inline: auto;
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: 1.6;
}

.footer a {
  color: var(--text-secondary);
  transition: color var(--duration) var(--ease-out);
}

.footer a:hover {
  color: var(--teal);
}


/* ==========================================================================
   6. UTILITY CLASSES
   ========================================================================== */

/* Search — dim non-matching elements */
.search-no-match {
  opacity: 0.15;
}

/* Search-targetable marker (no style needed; used by JS) */
[data-searchable] {}

/* Inline code / key values */
.code-inline {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background-color: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 0.1em 0.4em;
}

/* Teal highlight text */
.text-teal { color: var(--teal); }
.text-amber { color: var(--amber); }
.text-red { color: var(--red); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }

/* Background accents */
.bg-teal { background-color: var(--teal-bg); }
.bg-amber { background-color: var(--amber-bg); }
.bg-red { background-color: var(--red-bg); }

/* Font weight helpers */
.fw-400 { font-weight: 400; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

/* Spacing helpers */
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }

/* Flex helpers */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }


/* ==========================================================================
   7. RESPONSIVE ADJUSTMENTS
   ========================================================================== */

/* Mobile (default — mobile-first) */
@media (max-width: 479px) {
  .page-layout {
    padding-inline: var(--space-3);
    padding-block: var(--space-4);
  }

  .top-bar {
    padding: var(--space-2) var(--space-3);
  }

  .protocol-header,
  .workflow-phase-header {
    padding: var(--space-3);
  }

  .protocol-body,
  .workflow-phase-body {
    padding-left: var(--space-3);
    padding-right: var(--space-3);
  }

  .landing-card {
    padding: var(--space-4);
  }

  .taper-table {
    font-size: var(--text-xs);
  }

  .taper-table th,
  .taper-table td {
    padding: var(--space-1) var(--space-2);
  }

  /* Horizontal scroll for wide tables on small screens */
  .table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-inline: calc(-1 * var(--space-3));
    padding-inline: var(--space-3);
  }

  .back-to-top {
    bottom: var(--space-4);
    right: var(--space-4);
  }
}

/* Tablet and up */
@media (min-width: 480px) {
  .page-layout {
    padding-inline: var(--space-6);
    padding-block: var(--space-8);
  }
}

/* Desktop — comfortable reading */
@media (min-width: 768px) {
  .page-layout {
    padding-block: var(--space-10);
  }

  .section-title {
    margin-bottom: var(--space-8);
  }
}


/* ==========================================================================
   8. PRINT STYLES
   ========================================================================== */

@media print {
  /* Force light background for print */
  :root,
  :root[data-theme="dark"] {
    --bg:         #ffffff;
    --surface:    #ffffff;
    --surface-2:  #f8f9fa;
    --surface-3:  #f1f3f5;
    --border:     #dee2e6;
    --text:           #000000;
    --text-secondary: #495057;
    --text-muted:     #868e96;
    --teal:     #0d9488;
    --teal-dim: #0f766e;
    --amber:    #d97706;
    --red:      #dc2626;
    --teal-bg:  rgba(13, 148, 136, 0.08);
    --amber-bg: rgba(217, 119, 6, 0.08);
    --red-bg:   rgba(220, 38, 38, 0.08);
    --teal-border:  rgba(13, 148, 136, 0.2);
    --amber-border: rgba(217, 119, 6, 0.2);
    --red-border:   rgba(220, 38, 38, 0.2);
    --shadow-sm: none;
    --shadow-md: none;
    --shadow-lg: none;
  }

  body {
    font-size: 11pt;
    line-height: 1.5;
  }

  /* Hide interactive-only elements */
  .back-to-top,
  .theme-toggle,
  .view-toggle,
  .search-bar {
    display: none !important;
  }

  /* Make header non-sticky */
  .top-bar {
    position: static;
    border-bottom: 2px solid #000;
  }

  /* Show ALL collapsed content for print */
  .protocol-body,
  .workflow-phase-body {
    display: block !important;
  }

  .protocol-chevron,
  .workflow-phase-chevron {
    display: none;
  }

  /* Page breaks */
  .protocol-card,
  .workflow-phase {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .section-title {
    break-after: avoid;
    page-break-after: avoid;
  }

  /* Remove decorative shadows and transforms */
  .landing-card {
    box-shadow: none;
    transform: none;
    border: 1px solid #dee2e6;
  }

  /* Links show URL */
  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #868e96;
    word-break: break-all;
  }

  /* SmartPhrase chips print cleanly */
  .sp {
    border: 1px solid #dee2e6;
    background: #f8f9fa;
    color: #0d9488;
  }
}
