/* sophiewell.com styles. Dark theme ported from encryptalotta.com.
   Tokens, topbar, home-grid, tool-card, breadcrumb, footer-badges, and
   form treatments mirror encryptalotta/index.html. */

:root {
  --bg-primary: #0a0a0a;
  --bg-secondary: #1a1a1a;
  --bg-tertiary: #2a2a2a;
  --text-primary: #ffffff;
  --text-secondary: #c8c8c8;
  --text-muted: #9a9a9a;
  --border: #333333;
  --border-light: #404040;
  --accent: #ffffff;
  --accent-hover: #e0e0e0;
  --focus-ring: #4d90fe;

  --content-max: 1200px;
  --radius: 8px;
  --radius-card: 14px;
  --radius-pill: 999px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --logo-glow: rgba(255, 255, 255, 0.18);
  --logo-glow-hover: rgba(255, 255, 255, 0.32);
  --shadow-strong: rgba(0, 0, 0, 0.5);
  --shadow-soft: rgba(0, 0, 0, 0.3);
  --tint-soft: rgba(255, 255, 255, 0.06);
  --tint-faint: rgba(255, 255, 255, 0.02);
  --tint-border: rgba(255, 255, 255, 0.22);
  --tint-inset: rgba(255, 255, 255, 0.04);

  /* A single cheerful accent for interactive flourishes (category pills,
     hovers, friendly highlights). Kept separate from --accent (which stays
     monochrome for sober body chrome and focus) so the utility reads
     calm-and-clinical at rest and pops a clean medical teal on touch. */
  --accent-pop: #2dd4bf;
  --accent-pop-strong: #14b8a6;
  --accent-pop-tint: rgba(45, 212, 191, 0.14);
  --accent-pop-glow: rgba(45, 212, 191, 0.28);
}

[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-secondary: #f4f4f5;
  --bg-tertiary: #e6e6e8;
  --text-primary: #0a0a0a;
  --text-secondary: #2a2a2a;
  --text-muted: #5a5a5a;
  --border: #d6d6d9;
  --border-light: #b8b8bc;
  --accent: #0a0a0a;
  --accent-hover: #2a2a2a;

  --logo-glow: rgba(0, 0, 0, 0.18);
  --logo-glow-hover: rgba(0, 0, 0, 0.32);
  --shadow-strong: rgba(0, 0, 0, 0.18);
  --shadow-soft: rgba(0, 0, 0, 0.10);
  --tint-soft: rgba(0, 0, 0, 0.04);
  --tint-faint: rgba(0, 0, 0, 0.02);
  --tint-border: rgba(0, 0, 0, 0.18);
  --tint-inset: rgba(0, 0, 0, 0.04);

  /* Light theme leans on the darker teal so the pill text/border keeps
     AA contrast on the near-white background. */
  --accent-pop: #0d9488;
  --accent-pop-strong: #0f766e;
  --accent-pop-tint: rgba(13, 148, 136, 0.10);
  --accent-pop-glow: rgba(13, 148, 136, 0.22);
}

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

html {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
}

/* Skip link */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--text-primary);
  color: var(--bg-primary);
  padding: var(--space-2) var(--space-3);
  z-index: 100;
  border-radius: var(--radius);
}
.skip-link:focus {
  left: var(--space-2);
  top: var(--space-2);
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

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

/* ==========================================================
   TOPBAR  -  sticky brand bar, ported from encryptalotta.
   ========================================================== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.topbar .topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 800;
  font-size: 1.08rem;
  letter-spacing: -0.01em;
  border-radius: 8px;
  padding: 4px 6px;
  transition: opacity 0.2s ease;
}
.topbar .topbar-brand:hover { opacity: 0.85; }
.topbar .topbar-brand:focus { outline: 2px solid var(--focus-ring); outline-offset: 3px; }
.topbar .topbar-brand img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  filter: drop-shadow(0 0 8px var(--logo-glow));
}
.topbar .topbar-brand:hover img {
  filter: drop-shadow(0 0 14px var(--logo-glow-hover));
}
.topbar-brand { flex: 0 0 auto; }
.topbar-spacer { flex: 0 0 auto; width: 56px; }

/* Theme toggle */
.topbar-theme-toggle {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.topbar-theme-toggle:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-light);
}
.topbar-theme-toggle:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}
.topbar-theme-toggle .theme-icon { display: none; }
[data-theme="dark"] .topbar-theme-toggle .theme-icon-sun { display: block; }
[data-theme="light"] .topbar-theme-toggle .theme-icon-moon { display: block; }

/* Header search */
.topbar-search {
  position: relative;
  flex: 1 1 auto;
  max-width: 560px;
  margin: 0 auto;
}
.topbar-search input[type="search"] {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.topbar-search input[type="search"]::placeholder { color: var(--text-muted); }
.topbar-search input[type="search"]:hover { border-color: var(--border-light); }
.topbar-search input[type="search"]:focus {
  border-color: var(--focus-ring);
  box-shadow: 0 0 0 3px rgba(77, 144, 254, 0.25);
  background: var(--bg-tertiary);
}
.topbar-search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  list-style: none;
  margin: 0;
  padding: 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: 0 10px 30px var(--shadow-strong);
  max-height: min(60vh, 480px);
  overflow-y: auto;
  z-index: 60;
}
.topbar-search-results[hidden] { display: none; }
.topbar-search-result {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-primary);
  user-select: none;
}
.topbar-search-result .tsr-name { font-weight: 600; font-size: 0.95rem; }
.topbar-search-result .tsr-group { font-size: 0.78rem; color: var(--text-muted); }
.topbar-search-result:hover,
.topbar-search-result.is-active {
  background: var(--bg-tertiary);
}
.topbar-search-empty {
  padding: 14px 12px;
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
}

/* ==========================================================
   CONTAINER
   ========================================================== */
.container {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 20px;
}

/* spec-seo §9.1: visible h1 + lede above the task hero. */
.home-h1 {
  font-size: clamp(1.6rem, 3.4vw, 2.2rem);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: var(--space-4) auto var(--space-2);
  max-width: 1100px;
  padding: 0 var(--space-3);
  text-align: center;
}
.home-lede {
  max-width: 720px;
  margin: 0 auto var(--space-4);
  padding: 0 var(--space-3);
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 1.5;
  text-align: center;
}

/* spec-seo §5: pre-rendered per-tool landing pages at /tools/<id>/.
   The page reuses the topbar + container chrome and adds a handful
   of layout classes for the indexable prose body. */
.tool-page {
  max-width: 820px;
  margin: 0 auto;
  padding: var(--space-4) var(--space-3) var(--space-6);
}
.tool-page .tp-breadcrumb {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}
.tool-page .tp-breadcrumb a { color: var(--text-secondary); }
.tool-page .tp-h1 {
  font-size: clamp(1.5rem, 3vw, 2rem);
  margin: 0 0 var(--space-2);
  letter-spacing: -0.01em;
}
.tool-page .tp-lede {
  color: var(--text-secondary);
  font-size: 1.05rem;
  line-height: 1.5;
  margin: 0 0 var(--space-4);
}
.tool-page .tp-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin: 0 0 var(--space-5);
}
.tool-page .tp-open {
  display: inline-block;
  padding: 10px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: 8px;
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 600;
}
.tool-page .tp-open:hover,
.tool-page .tp-open:focus-visible {
  border-color: var(--text-secondary);
}
.tool-page section { margin-bottom: var(--space-5); }
.tool-page section h2 {
  font-size: 1.1rem;
  margin: 0 0 var(--space-2);
}
.tool-page section p {
  color: var(--text-secondary);
  line-height: 1.55;
  margin: 0 0 var(--space-2);
}
.tool-page .src-stamp {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
}
.tool-page .tp-citation-link {
  color: var(--accent-pop-strong);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  word-break: break-word;
}
.tool-page .tp-citation-link:hover,
.tool-page .tp-citation-link:focus-visible {
  color: var(--accent-pop);
  text-decoration: underline;
}
.tool-page .tp-related ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
}
.tool-page .tp-related li a {
  display: block;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 6px;
  color: var(--text-primary);
  text-decoration: none;
}
.tool-page .tp-related li a:hover,
.tool-page .tp-related li a:focus-visible {
  border-color: var(--text-secondary);
}
.tool-page .tp-author { margin-top: var(--space-5); }
@media (max-width: 600px) {
  .tool-page .tp-related ul { grid-template-columns: 1fr; }
}

/* spec-seo §10: audience hub pages at /for/<slug>/. Reuses .tool-page
   chrome from above; adds list-of-tools and "other hubs" affordances. */
.hub-page {
  max-width: 900px;
  margin: 0 auto;
  padding: var(--space-4) var(--space-3) var(--space-6);
}
.hub-page .hub-count {
  margin: 0 0 var(--space-5);
  font-size: 0.95rem;
}
.hub-page .hub-group { margin-bottom: var(--space-6); }
.hub-page .hub-group h2 {
  font-size: 1.1rem;
  margin: 0 0 var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-primary);
}
.hub-page .hub-tile-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
}
.hub-page .hub-tile-list li a {
  display: block;
  padding: var(--space-3);
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 8px;
  color: var(--text-primary);
  text-decoration: none;
}
.hub-page .hub-tile-list li a:hover,
.hub-page .hub-tile-list li a:focus-visible {
  border-color: var(--text-secondary);
}
.hub-page .hub-tile-name {
  display: block;
  font-weight: 600;
  margin-bottom: 2px;
}
.hub-page .hub-tile-desc {
  display: block;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.4;
}
.hub-page .hub-other {
  margin-top: var(--space-6);
  padding: var(--space-4);
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 8px;
}
.hub-page .hub-other h2 { font-size: 1rem; margin: 0 0 var(--space-2); }
.hub-page .hub-other ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}
.hub-page .hub-other li a { color: var(--text-secondary); }
@media (max-width: 600px) {
  .hub-page .hub-tile-list { grid-template-columns: 1fr; }
}

/* ==========================================================
   HOME GRID
   ========================================================== */
.home-view {
  padding: 24px 0 32px;
  max-width: 1100px;
  margin: 0 auto;
  animation: fadeInUp 0.6s ease-out;
}
.home-section { margin-bottom: 56px; }
.home-section:last-child { margin-bottom: 16px; }
.home-section h3 {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--text-muted);
  margin: 0 0 20px;
  padding-left: 4px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.home-section h3::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, var(--border) 0%, transparent 100%);
}
.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.tool-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 24px 22px;
  cursor: pointer;
  text-align: left;
  color: var(--text-primary);
  transition:
    transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1),
    border-color 0.22s ease,
    background 0.22s ease,
    box-shadow 0.22s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 110px;
  font-family: inherit;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}
.tool-card::before {
  /* Subtle radial-gradient sheen that lights up on hover. Pure CSS, no
     new images, no extra DOM. Sits behind the text via z-index 0. */
  content: "";
  position: absolute;
  inset: -1px;
  background: radial-gradient(
    600px circle at var(--mx, 50%) var(--my, -10%),
    var(--tint-soft),
    transparent 40%
  );
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
  z-index: 0;
}
.tool-card:hover::before { opacity: 1; }
.tool-card > * { position: relative; z-index: 1; }
.tool-card::after {
  content: "→";
  position: absolute;
  top: 22px;
  right: 22px;
  color: var(--text-muted);
  font-size: 1.1rem;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.18s ease, transform 0.18s ease, color 0.18s ease;
}
.tool-card:hover {
  border-color: var(--tint-border);
  background: var(--bg-tertiary);
  transform: translateY(-3px);
  box-shadow:
    0 10px 28px var(--shadow-strong),
    0 0 0 1px var(--tint-inset) inset;
}
.tool-card:hover::after {
  opacity: 1;
  transform: translateX(0);
  color: var(--text-primary);
}
.tool-card:active { transform: translateY(0); }
.tool-card:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
}
.tool-card[hidden] { display: none; }
.tool-card .tc-title {
  font-weight: 700;
  font-size: 1.02rem;
  color: var(--text-primary);
  letter-spacing: -0.005em;
  display: block;
}
.tool-card .tc-desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
  display: block;
}
.tool-card .tc-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.tool-card .tc-tag {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: var(--tint-faint);
  letter-spacing: 0.02em;
}

/* ==========================================================
   FILTERS  -  kept from sophiewell, restyled to encryptalotta look.
   ========================================================== */
.filters {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 12px auto 28px;
  max-width: 1100px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--bg-secondary);
}
.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}
.filter-label {
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  min-width: 5.5rem;
  color: var(--text-muted);
}
.search-row input[type="search"] {
  flex: 1 1 240px;
  min-width: 0;
}
.toggle-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* spec-v53: task hero. One big search combobox, centered, as the single
   entry point to the catalog. Focusing the input opens the results listbox
   (full catalog A-Z); typing filters it; the dropdown routes to the tile on
   click or Enter. The results list anchors to this positioned wrapper. */
.task-hero {
  position: relative;
  width: 100%;
  max-width: 720px;
  margin: 8px auto 24px;
}
.task-hero .hero-label {
  display: block;
  margin-bottom: 12px;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  text-align: center;
}
.task-hero input[type="search"] {
  display: block;
  width: 100%;
  font: inherit;
  font-size: 1.2rem;
  padding: 18px 24px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  box-shadow: 0 1px 2px var(--shadow-soft);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.task-hero input[type="search"]::placeholder { color: var(--text-muted); }
.task-hero input[type="search"]:hover { border-color: var(--border-light); }
.task-hero input[type="search"]:focus {
  outline: none;
  border-color: var(--focus-ring);
  box-shadow: 0 0 0 3px rgba(77, 144, 254, 0.25);
  background: var(--bg-tertiary);
}

.hero-search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  list-style: none;
  margin: 0;
  padding: 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: 0 12px 36px var(--shadow-strong);
  max-height: min(60vh, 460px);
  overflow-y: auto;
  z-index: 60;
  text-align: left;
}
.hero-search-results[hidden] { display: none; }
.hero-search-result {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-primary);
  user-select: none;
}
.hero-search-result .hsr-name { font-weight: 600; font-size: 0.98rem; }
.hero-search-result .hsr-group { font-size: 0.78rem; color: var(--text-muted); }
.hero-search-result:hover,
.hero-search-result.is-active { background: var(--bg-tertiary); }
.hero-search-empty {
  padding: 16px 14px;
  color: var(--text-muted);
  font-size: 0.92rem;
  text-align: center;
}

/* Small screens: keep the bar prominent but trim padding, and hold the
   input font at >=16px so iOS Safari does not zoom on focus. */
@media (max-width: 600px) {
  .task-hero { margin: 4px auto 18px; }
  .task-hero .hero-label { font-size: 1.05rem; }
  .task-hero input[type="search"] { font-size: 1.05rem; padding: 14px 18px; }
  .hero-search-results { max-height: min(70vh, 420px); }
}

/* spec-seo §10: "browse by category" nav under the hero. Two grouped
   pill clusters (specialty topics + audience hubs) that link out to the
   prerendered /topics/<slug>/ and /for/<slug>/ landing pages. Calm at
   rest, cheery on touch -- the pills lift and bloom the teal accent on
   hover/focus so the home page feels alive without shouting. */
.home-browse {
  width: 100%;
  max-width: 760px;
  margin: var(--space-4) auto 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}
.home-browse-group { text-align: center; }
.home-browse-h2 {
  margin: 0 0 var(--space-3);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
}
.home-browse-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
}
.home-browse-list a {
  display: inline-block;
  padding: 9px 16px;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.2;
  color: var(--text-secondary);
  text-decoration: none;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  transition: color 0.16s ease, border-color 0.16s ease,
    background 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
}
.home-browse-list a:hover,
.home-browse-list a:focus-visible {
  color: var(--accent-pop-strong);
  background: var(--accent-pop-tint);
  border-color: var(--accent-pop);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px var(--accent-pop-glow);
  outline: none;
}
.home-browse-list a:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}
.home-browse-list a:active { transform: translateY(0); }

@media (prefers-reduced-motion: reduce) {
  .home-browse-list a { transition: color 0.16s ease, border-color 0.16s ease, background 0.16s ease; }
  .home-browse-list a:hover,
  .home-browse-list a:focus-visible { transform: none; }
}

@media (max-width: 600px) {
  .home-browse { gap: var(--space-4); margin-top: var(--space-3); }
  .home-browse-list a { padding: 8px 14px; font-size: 0.9rem; }
}
/* spec-v52 §4.2: prior-auth packet linter dropzone. Lives on the
   pa-lint tile only; reuses the existing tool-meta + tool-result
   surrounds. The wave 52-1b stub computes per-file SHA-256 + size +
   MIME; subsequent waves slot the rule engine, the parsers, and the
   DOCX report under the same dropzone without UI churn. */
.pa-trust-strip {
  list-style: none;
  padding: 0;
  margin: 12px 0 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.pa-trust-strip li {
  margin: 4px 0;
}
.pa-dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  justify-content: center;
  padding: 28px 18px;
  background: var(--bg-secondary);
  border: 2px dashed var(--border);
  border-radius: var(--radius-card);
  color: var(--text-primary);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.pa-dropzone:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}
.pa-dropzone-hot {
  background: var(--bg-tertiary);
  border-color: var(--focus-ring);
}
.pa-dropzone-headline {
  margin: 0;
  font-weight: 600;
}
.pa-dropzone-sub {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.pa-status {
  margin: 12px 0 6px;
  font-size: 0.88rem;
  color: var(--text-muted);
}
.pa-results {
  list-style: none;
  padding: 0;
  margin: 6px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pa-finding {
  padding: 10px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: var(--radius-card);
}
.pa-finding[data-severity="flag"] {
  border-left-color: #c9a227;
}
.pa-finding[data-severity="info"] {
  border-left-color: #4d8fcc;
}
.pa-finding-name {
  margin: 0;
  font-weight: 600;
}
.pa-finding-meta,
.pa-finding-hash,
.pa-finding-err {
  margin: 4px 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  word-break: break-all;
}
.pa-finding-hash {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
}
.pa-findings-panel {
  margin-top: 18px;
}
.pa-findings-headline {
  margin: 0 0 8px;
  font-size: 1rem;
}
.pa-payer-line {
  margin: 0 0 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.pa-role-list {
  list-style: disc;
  padding-left: 18px;
  margin: 0 0 12px;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.pa-role-list li { margin: 2px 0; }
.pa-findings-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pa-rule {
  padding: 10px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: var(--radius-card);
}
.pa-rule[data-status="block"] { border-left-color: #d44d4d; }
.pa-rule[data-status="flag"]  { border-left-color: #c9a227; }
.pa-rule[data-status="pass"]  { border-left-color: #3fa56b; }
.pa-rule[data-status="error"] { border-left-color: #7a4fa0; }
.pa-rule-head { margin: 0; font-weight: 600; }
.pa-rule-id {
  display: inline-block;
  padding: 1px 6px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
}
.pa-rule-status {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.pa-rule-note,
.pa-rule-evidence,
.pa-rule-citation {
  margin: 4px 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  /* Citations embed long policy URLs (e.g. uhcprovider.com /
     aetna.com paths). Break them anywhere so a narrow viewport
     never scrolls horizontally (spec-v52 §4.6 report parity). */
  overflow-wrap: anywhere;
}
.pa-rule-citation {
  font-size: 0.78rem;
  opacity: 0.85;
}

/* Patient-artifact dropzone CSS removed when the dropzone UI shipped
   in spec-v7 sec 3.1 was retired during the clinical-staff-first
   pivot; the lib/artifact-*.js helpers were deleted in spec-v29 wave
   29-2 (Group C/L). */

.empty-state {
  margin: 16px 4px 24px;
  font-size: 0.95rem;
}

/* spec-v6 §3.3: lab result interpreter. */
.lab-ctx, .lab-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px 6px;
  margin: 14px 0;
}
.lab-ctx legend, .lab-panel legend {
  font-weight: 700;
  padding: 0 6px;
  color: var(--text-secondary);
}
.lab-result {
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 10px 0;
  background: var(--bg-secondary);
}
.lab-result[data-flag="within-range"]        { border-left-color: #4caf50; }
.lab-result[data-flag="borderline"]          { border-left-color: #ffb74d; }
.lab-result[data-flag="flagged-mild"]        { border-left-color: #ff9800; }
.lab-result[data-flag="flagged-significant"] { border-left-color: #e53935; }
.lab-result-head { font-size: 1.0rem; margin-bottom: 4px; }
.lab-result-band {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  margin-left: 6px;
}
.lab-result-range { font-size: 0.85rem; margin: 4px 0; }
.lab-result-narrative { margin: 6px 0; }
.lab-result-ask { margin: 6px 0; font-style: italic; color: var(--text-secondary); }
.lab-result-source { font-size: 0.78rem; margin-top: 4px; }
.lab-result-footer { margin-top: 14px; font-size: 0.88rem; }
.toggle {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 7px 12px;
  cursor: pointer;
  line-height: 1.2;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}
.toggle:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}
.toggle:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.toggle.is-active {
  background: var(--text-primary);
  color: var(--bg-primary);
  border-color: var(--text-primary);
}

/* ==========================================================
   BREADCRUMB
   ========================================================== */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0 18px;
  font-size: 0.9rem;
  flex-wrap: wrap;
}
.breadcrumb-back {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  transition: all 0.18s ease;
}
.breadcrumb-back:hover {
  color: var(--text-primary);
  border-color: var(--border-light);
  background: var(--bg-secondary);
}
.breadcrumb-back:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.breadcrumb-trail { color: var(--text-muted); font-size: 0.86rem; }
.breadcrumb-trail .bc-current { color: var(--text-primary); font-weight: 600; }

/* ==========================================================
   CONTENT (tool view)
   ========================================================== */
.content {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 32px 28px;
  border: 1px solid var(--border);
  margin: 0 auto 32px;
  max-width: 1100px;
  animation: fadeInUp 0.5s ease-out;
}
.content.is-empty { display: none; }

main h1 {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 4px 0 16px;
  outline: none;
}

.intro {
  max-width: 1100px;
  margin: 8px auto 0;
}
.intro p {
  font-size: 1rem;
  color: var(--text-secondary);
  margin: 0 0 var(--space-5);
  max-width: 70ch;
}

#tools h2 { font-size: 1rem; margin: 0 0 var(--space-3); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.14em; font-weight: 700; }

.empty-state {
  margin: var(--space-5) auto;
  padding: var(--space-4);
  border: 1px dashed var(--border);
  border-radius: var(--radius-card);
  color: var(--text-muted);
  text-align: center;
  max-width: 1100px;
}

/* ==========================================================
   FOOTER  -  credit-badge + gh-badge pills, disclaimer above.
   ========================================================== */
.site-footer {
  margin: 48px auto 28px;
  padding: 0 24px;
  max-width: 1100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.footer-badges {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}
.credit-badge,
.gh-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s ease;
  font-family: inherit;
}
.credit-badge:hover,
.gh-badge:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-light);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px var(--shadow-soft);
}
.credit-badge:focus-visible,
.gh-badge:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 3px; }
.credit-heart { color: #ff5d6c; transition: transform 0.2s ease; }
.credit-badge:hover .credit-heart { transform: scale(1.15); }
.gh-badge-mark { display: block; color: var(--text-primary); }

/* ==========================================================
   TOOL VIEW CHROME
   ========================================================== */
.back-link a {
  color: var(--text-secondary);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.back-link a:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

.clinical-notice {
  margin: 0 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 0.92rem;
  border-radius: var(--radius);
}
.deprecation-notice {
  margin: 0 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-left: 4px solid var(--text-secondary);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 0.92rem;
  border-radius: var(--radius);
}
.tool-description {
  margin: 0 0 var(--space-4);
  color: var(--text-secondary);
  max-width: 70ch;
}
.tool-input,
.tool-output { margin-bottom: var(--space-4); }
.tool-sources {
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}
.tool-sources h2 { font-size: 0.95rem; margin: 0 0 var(--space-2); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.12em; }
.muted { color: var(--text-muted); }

.tool-meta {
  margin: 0 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-tertiary);
}
.tool-meta p {
  margin: 0 0 var(--space-2);
  font-size: 0.9rem;
  color: var(--text-secondary);
}
.tool-meta p:last-child { margin-bottom: 0; }
.tool-meta .citation { color: var(--text-secondary); }
.tool-meta .source-stamp {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.8rem;
}
/* Citation + source links: the teal accent marks them as the primary
   source without shouting, underline keeps them recognizable as links. */
.tool-meta .citation-inline-link,
.tool-meta .source-link {
  color: var(--accent-pop-strong);
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-word;
}
.tool-meta .citation-link {
  display: inline-block;
  margin-left: 2px;
  color: var(--accent-pop-strong);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.tool-meta .citation-link:hover,
.tool-meta .citation-link:focus-visible,
.tool-meta .citation-inline-link:hover,
.tool-meta .source-link:hover,
.tool-meta .source-link:focus-visible {
  color: var(--accent-pop);
  text-decoration: underline;
}
.tool-meta a:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 3px;
}
.tool-meta .example-row { margin-bottom: 0; }
.tool-meta .example-expected { margin-left: var(--space-2); font-size: 0.85rem; }
.tool-meta .example-btn { font-size: 0.85rem; }
.tool-meta .example-reset { font-size: 0.85rem; }
/* spec-v9 §3.3: muted "(example: <value>)" annotation next to input labels. */
.example-hint { font-size: 0.8rem; margin-left: var(--space-1); font-weight: normal; }

/* Copy buttons */
.copy-row { margin-bottom: 0; }
.copy-btn { font-size: 0.85rem; padding: 4px 10px; }
/* Copy confirms with a cheerful teal flash so the user sees the action
   land, not just hears the screen-reader announcement. */
.copy-btn[data-copied='1'] {
  background: var(--accent-pop-tint);
  border-color: var(--accent-pop);
  color: var(--accent-pop-strong);
}

/* Keyboard shortcut overlay (spec-v2 3.3) */
#shortcut-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.65);
  display: flex; align-items: center; justify-content: center; z-index: 200;
  outline: none;
}
#shortcut-overlay .shortcut-panel {
  background: var(--bg-secondary); color: var(--text-primary);
  max-width: 36rem; width: calc(100% - 2rem); padding: var(--space-5);
  border-radius: var(--radius-card); border: 1px solid var(--border);
  max-height: 80vh; overflow: auto;
}
#shortcut-overlay h2 { margin-top: 0; }
#shortcut-overlay ul { list-style: none; padding: 0; columns: 2; column-gap: var(--space-5); }
#shortcut-overlay li { margin: 0 0 var(--space-2); break-inside: avoid; color: var(--text-secondary); }
#shortcut-overlay kbd {
  display: inline-block; min-width: 2.5rem; padding: 1px 6px;
  border: 1px solid var(--border); border-radius: 3px;
  font-family: var(--font-mono); font-size: 0.8125rem;
  background: var(--bg-tertiary); color: var(--text-primary);
}
:root[data-leader-armed='1']::after {
  content: 'G_'; position: fixed; right: 12px; bottom: 12px;
  font-family: var(--font-mono); font-size: 12px; padding: 2px 6px;
  background: var(--text-primary); color: var(--bg-primary); border-radius: 3px;
  z-index: 150;
}

/* Doc view (changelog, stability) */
.doc-body h2 { font-size: 1.25rem; margin: var(--space-4) 0 var(--space-2); }
.doc-body h3 { font-size: 1.05rem; margin: var(--space-3) 0 var(--space-2); }
.doc-body h4 { font-size: 1rem; margin: var(--space-3) 0 var(--space-1); }
.doc-body p  { margin: 0 0 var(--space-3); max-width: 70ch; color: var(--text-secondary); }
.doc-body ul { margin: 0 0 var(--space-3); padding-left: var(--space-5); color: var(--text-secondary); }
.doc-body li { margin-bottom: var(--space-1); }

/* Tool widgets */
.notice {
  margin: 0 0 var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  font-size: 0.9rem;
  color: var(--text-secondary);
}
/* The answer card. #q-results is the shared aria-live region every tool
   writes its computed result into; it was unstyled, so the payoff line
   read as flat body text. One rule lifts every tool at once: once there's
   a result, it sits on a teal-tinted surface anchored by a left accent
   bar, and the headline line (the value) is set large and bold. Empty
   between inputs, so the card only appears when there's an answer. No
   entrance animation -- this region updates live as the user types, and
   motion on every keystroke would be noise, not delight. */
#q-results:empty { display: none; }
#q-results:not(:empty) {
  margin: var(--space-3) 0 var(--space-4);
  padding: var(--space-4);
  padding-left: calc(var(--space-4) + 4px);
  background: var(--accent-pop-tint);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent-pop);
  border-radius: var(--radius);
}
#q-results > p { margin: 0 0 var(--space-2); color: var(--text-secondary); }
#q-results > p:last-child { margin-bottom: 0; }
#q-results > p:first-child {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}
@media (max-width: 600px) {
  #q-results > p:first-child { font-size: 1.1rem; }
}

.result-list {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--space-3);
}
.result-list li {
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
}
.result-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
  background: var(--bg-tertiary);
}
.lookup-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-3);
}
.lookup-table th,
.lookup-table td {
  text-align: left;
  padding: var(--space-3);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  font-size: 0.92rem;
}
.lookup-table th {
  font-weight: 700;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.78rem;
}

/* Form controls */
input[type="number"],
input[type="text"],
input[type="search"],
input[type="email"],
input[type="tel"],
select,
textarea {
  font: inherit;
  padding: 12px 14px;
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-radius: var(--radius);
  min-width: 12rem;
  max-width: 100%;
  transition: border-color 0.18s ease;
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-color: var(--border-light);
}

label {
  display: inline-block;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.92rem;
  margin-bottom: 6px;
}

button {
  font: inherit;
  padding: 10px 16px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 600;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
button:hover {
  background: var(--bg-secondary);
  border-color: var(--border-light);
}
/* Tactile press: buttons dip slightly when pressed so taps feel physical. */
button:active { transform: translateY(1px) scale(0.985); }
@media (prefers-reduced-motion: reduce) {
  button { transition: background 0.18s ease, border-color 0.18s ease; }
  button:active { transform: none; }
}

/* Animations */
@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-30px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50%      { transform: translateY(-10px); }
}

/* Responsive */
@media (max-width: 700px) {
  .topbar { padding: 12px 16px; flex-wrap: wrap; gap: 10px; }
  .topbar .topbar-brand { font-size: 1rem; gap: 10px; }
  .topbar .topbar-brand img { width: 28px; height: 28px; }
  .topbar-spacer { display: none; }
  .topbar-search { order: 3; flex: 1 1 100%; max-width: none; margin: 0; }
  .container { padding: 12px; }
  .home-view { padding: 4px 4px 16px; }
  .home-section { margin-bottom: 40px; }
  .home-grid { grid-template-columns: 1fr; gap: 12px; }
  .tool-card { padding: 20px 18px; min-height: 96px; }
  .tool-card::after { top: 18px; right: 18px; }
  .site-footer { margin: 32px auto 24px; }
  .content { padding: 22px 18px; }
  main h1 { font-size: 1.5rem; }
}

/* Print stylesheet for utility 62 (Printable Bill Decoder Summary) and the
   v4 shared printable-template renderer (lib/print.js). */
@media print {
  .topbar,
  .filters,
  .back-link,
  .breadcrumb,
  #print-btn,
  #decode-btn,
  textarea,
  .footer-badges,
  .site-footer {
    display: none !important;
  }
  @page { margin: 0.5in; }
  html, body { background: #fff; color: #000; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  body { font-size: 11pt; }
  .container, .content { max-width: 100%; padding: 0; background: #fff; color: #000; border: 0; }
  .decode-summary, section, .printable-section { page-break-inside: avoid; }
  .printable h1 { font-size: 14pt; margin: 0 0 12pt; }
  .printable h2 { font-size: 12pt; margin: 12pt 0 6pt; }
  .printable p, .printable li { font-size: 11pt; line-height: 1.35; }
  .printable-warning { border: 1pt solid #000; padding: 6pt; margin: 6pt 0; }
  .printable-footer { margin-top: 16pt; border-top: 0.5pt solid #000; padding-top: 6pt; font-size: 9pt; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after { animation: none !important; transition: none !important; }
}

/* spec-v48: derivation block ("where does this come from?") */
.tile-derivation {
  margin-top: 1rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border, #ccc);
  border-radius: 4px;
  background: var(--surface-alt, transparent);
}
.tile-derivation > summary {
  cursor: pointer;
  font-weight: 600;
}
.tile-derivation h4 {
  margin: 0.75rem 0 0.25rem;
  font-size: 0.95rem;
}
.tile-derivation pre.tile-derivation-formula {
  white-space: pre-wrap;
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 0.85rem;
  margin: 0;
}
.tile-derivation blockquote {
  margin: 0;
  padding-left: 0.75rem;
  border-left: 3px solid var(--border, #ccc);
  font-style: italic;
}
.tile-derivation-steps ol {
  margin: 0.25rem 0 0 1.25rem;
  padding: 0;
}
.tile-derivation-steps li {
  margin: 0.15rem 0;
}
