/* ============================================================
   PepRecon shared stylesheet
   Used by root domain + all 5 calculator subdomains
   ============================================================ */

/* ---------- Theme tokens ---------- */
:root {
  /* Light theme (Clinical) — default */
  color-scheme: light;
  --bg:            #f7f8fa;
  --bg-elevated:   #ffffff;
  --bg-subtle:     #eef0f4;
  --border:        #e3e6ec;
  --border-strong: #c9cfd9;
  --text:          #1a1f2b;
  --text-muted:    #5a6478;
  --text-faint:    #66707e;
  --accent:        #0891a8;
  --accent-hover:  #0a7d92;
  --accent-soft:   #e6f4f7;
  --accent-ink:    #067084;
  --accent-text:   #ffffff;
  --shadow-sm:     0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md:     0 4px 6px rgba(15, 23, 42, 0.05), 0 10px 20px rgba(15, 23, 42, 0.06);
  --focus-ring:    0 0 0 3px rgba(8, 145, 168, 0.25);
  --danger:        #b91c1c;
  --danger-soft:   #fef2f2;
  --success:       #047857;
  --success-soft:  #ecfdf5;
}

[data-theme="dark"] {
  /* Dark theme (Tech) */
  color-scheme: dark;
  --bg:            #0d1117;
  --bg-elevated:   #161b22;
  --bg-subtle:     #1c232c;
  --border:        #2a323d;
  --border-strong: #3a4554;
  --text:          #e6edf3;
  --text-muted:    #9ba7b6;
  --text-faint:    #7a8595;
  --accent:        #2dd4bf;
  --accent-hover:  #5eead4;
  --accent-soft:   #042f2e;
  --accent-ink:    #2dd4bf;
  --accent-text:   #0d1117;
  --shadow-sm:     0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md:     0 4px 6px rgba(0, 0, 0, 0.35), 0 10px 20px rgba(0, 0, 0, 0.5);
  --focus-ring:    0 0 0 3px rgba(45, 212, 191, 0.3);
  --danger:        #f87171;
  --danger-soft:   #2a1414;
  --success:       #34d399;
  --success-soft:  #0c2620;
}

/* Auto mode follows system preference */
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] {
    color-scheme: dark;
    --bg:            #0d1117;
    --bg-elevated:   #161b22;
    --bg-subtle:     #1c232c;
    --border:        #2a323d;
    --border-strong: #3a4554;
    --text:          #e6edf3;
    --text-muted:    #9ba7b6;
    --text-faint:    #7a8595;
    --accent:        #2dd4bf;
    --accent-hover:  #5eead4;
    --accent-soft:   #042f2e;
    --accent-ink:    #2dd4bf;
    --accent-text:   #0d1117;
    --shadow-sm:     0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md:     0 4px 6px rgba(0, 0, 0, 0.35), 0 10px 20px rgba(0, 0, 0, 0.5);
    --focus-ring:    0 0 0 3px rgba(45, 212, 191, 0.3);
    --danger:        #f87171;
    --danger-soft:   #2a1414;
    --success:       #34d399;
    --success-soft:  #0c2620;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: 'Inter Tight', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  background-color: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.2s ease, color 0.2s ease;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

a {
  color: var(--accent-ink);
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover { color: var(--accent-hover); }

/* ---------- Layout ---------- */
.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

.site-header {
  padding: 56px 0 16px;
  text-align: center;
}

.wordmark {
  font-family: 'JetBrains Mono', ui-monospace, 'SF Mono', Consolas, monospace;
  font-weight: 600;
  font-size: clamp(2rem, 5vw, 2.75rem);
  letter-spacing: -0.04em;
  margin: 0;
  color: var(--text);
}

.wordmark .accent { color: var(--accent); }

/* Generic accent text — usable in any heading */
.accent { color: var(--accent); }

.tagline {
  margin: 8px 0 0;
  font-size: 1rem;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

/* ---------- Theme switcher ---------- */
.theme-switcher {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 50;
  display: inline-flex;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  box-shadow: var(--shadow-sm);
}

.theme-switcher button {
  background: transparent;
  border: none;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 999px;
  transition: color 0.15s ease, background-color 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  line-height: 1;
}

.theme-switcher button:hover {
  color: var(--text);
}

.theme-switcher button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-text);
}

.theme-switcher button:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.theme-switcher svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- App grid (root page) ---------- */
.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin: 40px 0 48px;
}

.app-card {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 14px;
  row-gap: 4px;
  align-items: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 22px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
  position: relative;
  overflow: hidden;
}

.app-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s ease;
}

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

.app-card:hover::before { transform: scaleX(1); }

.app-card:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-color: var(--accent);
}

.app-card:focus-visible::before { transform: scaleX(1); }

.app-card .app-icon {
  grid-column: 1;
  grid-row: 1;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 9px;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.app-card:hover .app-icon {
  transform: scale(1.05);
}

.app-card .app-icon svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-card .app-title {
  grid-column: 2;
  grid-row: 1;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  letter-spacing: -0.01em;
}

.app-card .app-desc {
  grid-column: 1 / -1;
  grid-row: 2;
  margin: 6px 0 0;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.45;
}

/* ---------- Calculator pages — form layout ---------- */
.calc-shell {
  max-width: 640px;
  margin: 32px auto 48px;
  padding: 0 24px;
}

.calc-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  box-shadow: var(--shadow-sm);
}

.calc-card h1 {
  margin: 0 0 4px;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.calc-card .calc-sub {
  margin: 0 0 24px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.field input[type="number"],
.field input[type="text"],
.field select {
  width: 100%;
  padding: 10px 12px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  -moz-appearance: textfield;
}

.field input[type="number"]::-webkit-outer-spin-button,
.field input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.field .field-hint {
  display: block;
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--text-faint);
}

/* Inline unit selector (e.g. mcg / mg toggle) */
.field-row {
  display: flex;
  gap: 8px;
}
.field-row > *:first-child { flex: 1; }
.field-row select {
  width: auto;
  min-width: 90px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
  line-height: 1;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover {
  background: var(--bg-subtle);
}

.btn-block { width: 100%; }

.btn-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

/* Result display */
.result {
  margin-top: 24px;
  padding: 20px;
  background: var(--accent-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  border-left: 3px solid var(--accent);
}

.result.hidden { display: none; }

.result-label {
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0 0 6px;
}

.result-value {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  letter-spacing: -0.01em;
}

.result-detail {
  margin: 4px 0 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.result + .result { margin-top: 12px; }

.result.error {
  background: var(--danger-soft);
  border-left-color: var(--danger);
}
.result.error .result-value,
.result.error .result-label { color: var(--danger); }

/* ---------- Hamburger nav (used by calculator pages, not root) ---------- */
.nav-toggle {
  position: fixed;
  top: 16px;
  left: 16px;
  /* Above the drawer (100) and overlay (99), not below them. At z-index 50 the
     open overlay covered this button, so elementFromPoint at its center
     returned .nav-overlay and the button itself was never hit: the menu still
     closed, because the overlay closes it too, but the hamburger read as dead
     while showing aria-expanded="true". */
  z-index: 101;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: background-color 0.15s ease;
}

.nav-toggle:hover { background: var(--bg-subtle); }

.nav-toggle:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.nav-toggle svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
}

.nav-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 99;
}

.nav-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.nav-drawer {
  position: fixed;
  top: 0;
  left: 0;
  width: 260px;
  height: 100%;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  /* Slide with transform, not `left`.
     Animating `left` is a layout property: every frame re-runs layout for a
     full-height scroll container holding 15 links and 3 section headings, on
     the main thread. Any main-thread work during the slide (this drawer also
     lazy-loads a 35 kB search index on first focus) stutters or stalls it,
     which reads as the menu lagging or not opening. `transform` is composited
     and runs off the main thread. */
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  will-change: transform;
  z-index: 100;
  padding: 64px 20px 20px;
  /* The drawer holds 15 links plus group headings, which overflows a short
     phone viewport. Without this the last items are simply unreachable. */
  overflow-y: auto;
  overscroll-behavior: contain;
}

.nav-drawer.active { transform: translateX(0); }

/* Respect a reduced-motion preference: snap rather than slide. */
@media (prefers-reduced-motion: reduce) {
  .nav-drawer { transition: none; }
  .nav-overlay { transition: none; }
}

.nav-drawer .nav-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 22px;
  border-radius: 6px;
}
.nav-drawer .nav-close:hover { background: var(--bg-subtle); color: var(--text); }

.nav-drawer ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.nav-drawer li { margin: 0; }

.nav-drawer a {
  display: block;
  padding: 10px 12px;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: 6px;
  transition: background-color 0.12s ease;
}

.nav-drawer a:hover {
  background: var(--bg-subtle);
  color: var(--accent-ink);
}

.nav-drawer a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.nav-drawer .nav-section {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 4px 6px;
  list-style: none;
}

.nav-drawer .nav-section span {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  white-space: nowrap;
}

.nav-drawer .nav-section::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ---------- Footer ---------- */
.site-footer {
  margin-top: auto;
  padding: 24px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-faint);
  border-top: 1px solid var(--border);
}

.site-footer a {
  color: var(--text-muted);
}

.site-footer a:hover { color: var(--accent-ink); }

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

.hidden { display: none !important; }

/* The browser's own [hidden] rule is `display: none` at UA priority, which ANY
   author `display` declaration outranks. That silently broke the sanity ribbon:
   `.pep-sanity { display: flex }` kept an empty red box on screen even with
   el.hidden set. Enforce it once, globally, so it cannot recur on the next
   component that toggles `hidden` and happens to set a display. */
[hidden] { display: none !important; }

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
  .container { padding: 0 16px; }
  .site-header { padding: 80px 0 12px; }
  .calc-shell { padding: 0 16px; margin-top: 80px; }
  .calc-card { padding: 20px; }
  .result-value { font-size: 1.25rem; }

  /* Force 2-column tile grid on mobile so cards stay card-shaped */
  .app-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin: 28px 0 36px;
  }
  .app-card {
    padding: 16px;
    column-gap: 10px;
  }
  .app-card .app-icon {
    width: 32px;
    height: 32px;
  }
  .app-card .app-icon svg { width: 18px; height: 18px; }
  .app-card .app-title { font-size: 1rem; }
  .app-card .app-desc {
    font-size: 0.8rem;
    line-height: 1.4;
    margin-top: 4px;
  }
}

/* Very small screens — even tighter */
@media (max-width: 360px) {
  .app-card .app-desc { display: none; }
  .app-card { padding: 14px; }
}

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

/* ---------- Cross-document view transitions ---------- */
@view-transition { navigation: auto; }

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) { animation: none !important; }
}

/* ============================================================
   Shared primitives
   ------------------------------------------------------------
   Components every app can use, so tools stop inventing their own.
   Before these existed shared.css had no disclosure, table, badge,
   chip or search input, and each app hand-rolled what it needed.
   ============================================================ */

/* ---------- Disclosure (progressive detail) ---------- */
.disclosure {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elevated);
  margin: 16px 0;
}
.disclosure > summary {
  cursor: pointer;
  padding: 12px 16px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  list-style: none;
}
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary::before {
  content: '';
  flex: none;
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.18s ease;
}
.disclosure[open] > summary::before { transform: rotate(45deg); }
.disclosure > summary:hover { color: var(--text); }
.disclosure > summary:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.disclosure__body {
  padding: 0 16px 16px;
  font-size: 0.9rem;
  line-height: 1.65;
  color: var(--text-muted);
}
.disclosure__body > :first-child { margin-top: 0; }
.disclosure__body > :last-child { margin-bottom: 0; }

/* ---------- Tables ---------- */
.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elevated);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.data-table th {
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  background: var(--bg-subtle);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table .num,
.data-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---------- Badges and chips ---------- */
.badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.5;
  padding: 2px 8px;
  border-radius: 999px;
  color: var(--accent-ink);
  background: var(--accent-soft);
  border: 1px solid var(--accent);
}
.badge--muted {
  color: var(--text-muted);
  background: var(--bg-subtle);
  border-color: var(--border-strong);
}
.badge--danger {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: var(--danger);
}
.badge--success {
  color: var(--success);
  background: var(--success-soft);
  border-color: var(--success);
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  line-height: 1.4;
  padding: 5px 11px;
  border-radius: 999px;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
}
a.chip:hover,
button.chip:hover {
  color: var(--text);
  border-color: var(--border-strong);
}
.chip[aria-pressed="true"],
.chip--on {
  color: var(--accent-ink);
  background: var(--accent-soft);
  border-color: var(--accent);
}

/* ---------- Search input (nav drawer) ---------- */
.nav-search { margin-bottom: 14px; }
.nav-search__input {
  width: 100%;
  padding: 9px 12px;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 8px;
  -webkit-appearance: none;
  appearance: none;
}
.nav-search__input::-webkit-search-cancel-button { cursor: pointer; }
.nav-search__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}
.nav-search__results {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  max-height: 46vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-top: 1px solid var(--border);
}
.nav-search__results li { margin: 0; }
/* Stacked, not side by side: the drawer is 260px, so a long title plus a
   right-aligned kind label collide as soon as the title wraps. */
.nav-search__hit {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
}
.nav-search__hit:hover,
.nav-search__hit:focus-visible {
  background: var(--accent-soft);
  color: var(--accent-ink);
  outline: none;
}
.nav-search__hit-name {
  font-size: 0.88rem;
  line-height: 1.35;
  min-width: 0;
}
.nav-search__hit-kind {
  flex: none;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.6rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.nav-search__none {
  padding: 10px 4px;
  font-size: 0.85rem;
  color: var(--text-faint);
}

/* Homepage placement: wider, centered under the hero lede, and the results
   float over the grid rather than pushing it down. */
.hero-search {
  position: relative;
  max-width: 30rem;
  margin: 22px auto 0;
  text-align: left;
}
.hero-search .nav-search__input {
  padding: 11px 14px;
  font-size: 0.95rem;
  background: var(--bg-elevated);
}
.hero-search .nav-search__results {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 20;
  margin-top: 4px;
  padding: 4px 10px;
  max-height: 60vh;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
}

/* ---------- Result add-ons (PepResult) ---------- */
.pep-addons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 16px 0 0;
}
.pep-addons .disclosure { margin: 0; }

/* Magnitude sanity ribbon. Advisory, not an error: the math still ran. */
.pep-sanity {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid var(--danger);
  border-left-width: 3px;
  border-radius: 8px;
  background: var(--danger-soft);
}
.pep-sanity__label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--danger);
}
.pep-sanity__list {
  margin: 0;
  padding-left: 18px;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text);
}
.pep-sanity__list li + li { margin-top: 5px; }

/* Show the math: the worked equation, one line per step. */
.pep-math__work {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 14px;
  padding: 12px 14px;
  overflow-x: auto;
  background: var(--bg-subtle);
  border-radius: 8px;
}
.pep-math__line {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  line-height: 1.7;
  color: var(--text-muted);
  white-space: pre;          /* keeps the "=" columns aligned */
}
.pep-math__line--sub { color: var(--text); }
.pep-math__line--out {
  color: var(--accent-ink);
  font-weight: 600;
  margin-top: 2px;
}
.pep-math__table th {
  text-align: left;
  font-size: 0.85rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-muted);
  background: transparent;
  white-space: normal;
}
.pep-math__table td { font-family: 'JetBrains Mono', ui-monospace, monospace; }
.pep-math__note { margin: 10px 0 0; font-size: 0.83rem; color: var(--text-faint); }

/* ---------- Homepage "Your tools" (PepHome) ---------- */
.app-card--yours { position: relative; }
.app-pin {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  cursor: pointer;
  color: var(--text-faint);
  background: transparent;
  border: 1px solid transparent;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease;
}
.app-card--yours:hover .app-pin,
.app-pin:focus-visible,
.app-pin--on { opacity: 1; }
.app-pin:hover { color: var(--accent-ink); border-color: var(--border); }
.app-pin--on { color: var(--accent-ink); }
.app-pin:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.app-pin svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.app-pin--on svg { fill: currentColor; stroke: currentColor; }
/* Touch devices get no hover, so always show the control there. */
@media (hover: none) {
  .app-pin { opacity: 1; }
}

/* ============================================================
   Print
   ------------------------------------------------------------
   Every page should print as a clean reference card: no chrome,
   no controls, ink-cheap. Token overrides carry a [data-theme]
   selector so an explicit dark choice cannot out-specify them.
   ============================================================ */
.print-only { display: none; }

@media print {
  :root,
  :root[data-theme="dark"],
  :root[data-theme="light"],
  :root[data-theme="auto"] {
    color-scheme: light;
    --bg: #ffffff;
    --bg-elevated: #ffffff;
    --bg-subtle: #ffffff;
    --border: #bbbbbb;
    --border-strong: #888888;
    --text: #000000;
    --text-muted: #333333;
    --text-faint: #555555;
    --accent: #000000;
    --accent-hover: #000000;
    --accent-soft: #ffffff;
    --accent-ink: #000000;
    --accent-text: #ffffff;
    --shadow-sm: none;
    --shadow-md: none;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
  }

  /* Chrome and controls never print. */
  .nav-toggle,
  .nav-overlay,
  .nav-drawer,
  .theme-switcher,
  .site-footer,
  .btn,
  .btn-row,
  .share-actions,
  .app-pin,
  .nav-search,
  .share-url-wrapper,
  .no-print {
    display: none !important;
  }

  /* Printed cards end up on a fridge or a bench with no context, so stamp
     the source page and date on them. Injected by shared.js. */
  .print-source {
    display: block !important;
    margin-top: 14mm;
    padding-top: 3mm;
    border-top: 1px solid #bbbbbb;
    font-size: 9pt;
    color: #555555;
  }
  .print-source__url { font-family: 'JetBrains Mono', ui-monospace, monospace; }

  /* The sanity ribbon is the one thing worth carrying onto paper. */
  .pep-sanity {
    border: 1px solid #888888;
    border-left-width: 3px;
    background: #ffffff;
    break-inside: avoid;
  }

  .print-only { display: block !important; }

  .calc-shell,
  .container { max-width: none; padding: 0; }

  .calc-card,
  .table-scroll,
  .disclosure {
    box-shadow: none !important;
    border: 1px solid #bbbbbb;
    break-inside: avoid;
  }

  /* A collapsed disclosure still holds the working, so print it open. */
  .disclosure__body { display: block !important; }

  a { text-decoration: none; color: #000000; }

  h1, h2, h3 { break-after: avoid; }
  table, figure, .result { break-inside: avoid; }

  @page { margin: 14mm; }
}
