/* Converter quick-reference ("How to add a drug") stylesheet.
   Served from /api/static so it satisfies the strict CSP (style-src 'self');
   the page previously inlined this in a <style> block, which the browser
   blocked under style-src 'self' (no 'unsafe-inline'), rendering it unstyled.
   Kept local to this server-rendered doc page — intentionally separate from the
   SPA's drug-guide.css token system. */
:root {
  --ink: #07111f; --ink-soft: #24344d; --muted: #60748e;
  --rule: rgba(190, 203, 220, 0.68); --rule-soft: #f1f6fc; --bg: #f4f8fd;
  --surface: #ffffff;
  --accent: #2563eb; --code-bg: #f8fafc; --code-ink: #0f172a;
  --shadow-soft: 0 1px 2px rgba(15, 23, 42, 0.028), 0 14px 34px rgba(15, 23, 42, 0.055);
  --shadow-chrome: 0 14px 38px rgba(15, 23, 42, 0.12), inset 0 1px 0 rgba(255,255,255,0.9);
  --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; color: var(--ink);
  background:
    radial-gradient(circle at 16% -10%, rgba(255,255,255,0.98) 0, rgba(255,255,255,0) 31rem),
    radial-gradient(circle at 88% 0%, rgba(219,234,254,0.7) 0, rgba(219,234,254,0) 28rem),
    linear-gradient(180deg, #fbfdff 0%, var(--bg) 58%, #eaf2fb 100%);
}
body {
  font-family: var(--font-sans);
  font-size: 0.92rem; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
.qr-topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: calc(0.62rem + env(safe-area-inset-top)) max(1.25rem, env(safe-area-inset-right)) 0.62rem max(1.25rem, env(safe-area-inset-left));
  background-color: #fbfdff;
  background-image: linear-gradient(180deg, rgba(255,255,255,0.98) 0%, rgba(248,251,255,0.94) 100%);
  color: var(--ink); box-shadow: 0 1px 0 rgba(255,255,255,0.92), 0 12px 30px rgba(15,23,42,0.07);
  border-bottom: 1px solid rgba(203,213,225,0.72);
  backdrop-filter: blur(18px) saturate(1.15); -webkit-backdrop-filter: blur(18px) saturate(1.15);
  position: sticky; top: 0; z-index: 10;
}
.qr-actions { display: flex; gap: 0.5rem; align-items: center; }
.qr-topbar a {
  color: var(--ink-soft); text-decoration: none; font-size: 0.82rem; font-weight: 650;
  padding: 0.38rem 0.78rem; border: 1px solid var(--rule);
  border-radius: 999px; background: rgba(255,255,255,0.72);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.9);
}
.qr-topbar a:hover { background: #fff; border-color: rgba(37,99,235,0.28); color: var(--accent); text-decoration: none; }
.qr-topbar .qr-wordmark {
  font-family: var(--font-display); font-weight: 820; font-size: 0.95rem;
  letter-spacing: -0.035em;
}
.qr-topbar .qr-print {
  background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%); color: #fff; border-color: #2563eb;
  cursor: pointer; font: inherit;
  border-radius: 999px; padding: 0.38rem 0.78rem;
  box-shadow: 0 1px 2px rgba(15,23,42,0.05), 0 9px 20px rgba(37,99,235,0.18);
}
.qr-topbar .qr-print:hover { background: linear-gradient(180deg, #1d4ed8 0%, #1e40af 100%); border-color: #1d4ed8; }
main.qr {
  max-width: 900px; margin: 1.25rem auto 3rem; padding: 1.45rem 1.55rem 2.2rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 16px;
  box-shadow: var(--shadow-soft);
}
.qr-toc {
  position: sticky; top: calc(52px + env(safe-area-inset-top)); z-index: 5;
  max-width: 900px; margin: 0.8rem auto 0; padding: 0.55rem 1rem;
  background: rgba(255,255,255,0.86); backdrop-filter: blur(16px) saturate(1.12); -webkit-backdrop-filter: blur(16px) saturate(1.12);
  border: 1px solid var(--rule);
  border-radius: 999px;
  box-shadow: var(--shadow-chrome);
}
.qr-toc-title {
  font-family: var(--font-mono); font-size: 0.62rem; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-bottom: 0.35rem;
}
.qr-toc-list { display: flex; gap: 0.35rem; overflow-x: auto; scrollbar-width: none; }
.qr-toc-list::-webkit-scrollbar { display: none; }
.qr-toc-list a {
  flex: 0 0 auto; color: var(--ink-soft); text-decoration: none; font-size: 0.78rem; font-weight: 600;
  border: 1px solid var(--rule); border-radius: 999px; padding: 0.28rem 0.68rem; background: rgba(255,255,255,0.76);
}
.qr-toc-list a:hover { color: var(--accent); border-color: rgba(37,99,235,0.28); text-decoration: none; }
main.qr h1 {
  font-family: var(--font-display); font-size: 1.55rem; font-weight: 800;
  letter-spacing: -0.04em; margin: 0.25rem 0 1rem; color: var(--ink);
}
main.qr h2 {
  font-family: var(--font-display); font-size: 1.05rem; font-weight: 700;
  letter-spacing: -0.01em; margin: 1.4rem 0 0.5rem; color: var(--ink);
  padding-bottom: 0.25rem; border-bottom: 1px solid var(--rule);
}
main.qr h3 {
  font-family: var(--font-display); font-size: 0.95rem; font-weight: 700;
  margin: 0.9rem 0 0.35rem; color: var(--ink-soft);
}
main.qr p { margin: 0.4rem 0; }
main.qr ul, main.qr ol { margin: 0.35rem 0 0.6rem; padding-left: 1.4rem; }
main.qr li { margin: 0.15rem 0; }
main.qr blockquote {
  margin: 0.6rem 0; padding: 0.55rem 0.85rem; border-left: 3px solid var(--accent);
  background: var(--rule-soft); color: var(--ink-soft); border-radius: 0 10px 10px 0;
  font-size: 0.88rem;
}
main.qr blockquote p { margin: 0.15rem 0; }
main.qr code {
  font-family: var(--font-mono); font-size: 0.82em;
  background: var(--code-bg); color: var(--code-ink);
  padding: 0.08em 0.35em; border-radius: 4px; border: 1px solid var(--rule);
}
main.qr pre {
  position: relative;
  background: var(--code-bg); color: var(--code-ink);
  padding: 0.65rem 0.85rem; border-radius: 10px; border: 1px solid var(--rule);
  overflow-x: auto; font-size: 0.78rem; line-height: 1.45;
  margin: 0.5rem 0 0.8rem;
}
.qr-copy {
  position: absolute; top: 0.4rem; right: 0.45rem;
  border: 1px solid var(--rule); border-radius: 999px; background: #fff; color: var(--ink-soft);
  font-family: var(--font-sans); font-size: 0.72rem; font-weight: 700;
  padding: 0.18rem 0.5rem; cursor: pointer;
}
.qr-copy:hover { border-color: rgba(37,99,235,0.35); color: var(--accent); }
main.qr pre code { background: transparent; border: none; padding: 0; font-size: 1em; }
main.qr hr { border: 0; border-top: 1px solid var(--rule); margin: 1.2rem 0; }
main.qr a { color: var(--accent); text-decoration: none; }
main.qr a:hover { text-decoration: underline; }
main.qr table { border-collapse: collapse; margin: 0.5rem 0 0.8rem; font-size: 0.85rem; width: 100%; }
main.qr th, main.qr td { border: 1px solid var(--rule); padding: 0.35rem 0.55rem; text-align: left; vertical-align: top; }
main.qr th { background: var(--rule-soft); font-weight: 700; }

@media (max-width: 600px) {
  main.qr {
    margin: 0.9rem 0.72rem 2rem;
    padding: 1rem 1rem 2rem;
    border-radius: 14px;
  }
  main.qr h1 { font-size: 1.3rem; }
  main.qr pre { font-size: 0.72rem; }
  .qr-toc {
    top: calc(47px + env(safe-area-inset-top));
    margin: 0.65rem 0.72rem 0;
    padding: 0.48rem 0.7rem;
    border-radius: 14px;
  }
  .qr-topbar {
    padding: calc(0.55rem + env(safe-area-inset-top)) max(0.85rem, env(safe-area-inset-right)) 0.55rem max(0.85rem, env(safe-area-inset-left));
    gap: 0.6rem;
  }
  .qr-topbar .qr-wordmark { font-size: 0.85rem; }
  .qr-actions { gap: 0.35rem; }
  .qr-topbar a,
  .qr-topbar .qr-print { padding-inline: 0.62rem; }
}

/* Phase 3 premium documentation layer: aligns the quick reference with the
   Clinical Drug Guide product system while preserving the markdown output. */
:root {
  color-scheme: light dark;
  --ink: #081426; --ink-soft: #34445c; --muted: #5b6981;
  --rule: rgba(15, 23, 42, 0.08); --rule-soft: #f3f7fb; --bg: #f6f8fb;
  --surface: #ffffff; --accent: #2563eb; --code-bg: #f3f7fb; --code-ink: #0f172a;
  --shadow-soft: 0 1px 2px rgba(15, 23, 42, 0.045);
  --shadow-chrome: 0 1px 2px rgba(15, 23, 42, 0.05), 0 14px 34px rgba(15, 23, 42, 0.07);
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #f6f8fb; --ink-soft: #c8d3e2; --muted: #8fa2ba;
    --rule: rgba(226, 232, 240, 0.1); --rule-soft: #0a101a; --bg: #070b12;
    --surface: #0d1420; --accent: #7db0ff; --code-bg: #0a101a; --code-ink: #e8eef8;
    --shadow-soft: 0 1px 0 rgba(255, 255, 255, 0.04);
    --shadow-chrome: 0 1px 0 rgba(255, 255, 255, 0.04), 0 16px 42px rgba(0, 0, 0, 0.38);
  }
}
html, body {
  background:
    radial-gradient(circle at 16% -10%, color-mix(in srgb, var(--accent) 12%, transparent) 0, transparent 31rem),
    linear-gradient(180deg, var(--surface) 0%, var(--bg) 58%, var(--rule-soft) 100%) !important;
}
body { font-size: 16px; }
.qr-topbar {
  background: color-mix(in srgb, var(--surface) 90%, transparent) !important;
  border-bottom-color: var(--rule) !important;
  box-shadow: var(--shadow-soft) !important;
}
.qr-topbar a,
.qr-topbar .qr-print,
.qr-toc-list a,
.qr-copy {
  min-height: 38px;
  border-radius: 999px !important;
  font-weight: 760 !important;
}
.qr-topbar a,
.qr-toc-list a,
.qr-copy {
  background: color-mix(in srgb, var(--surface) 86%, transparent) !important;
  border-color: var(--rule) !important;
  color: var(--ink-soft) !important;
}
.qr-topbar .qr-print {
  background: linear-gradient(180deg, #2563eb 0%, #174ea6 100%) !important;
  border-color: #2563eb !important;
  color: #fff !important;
}
main.qr {
  background: color-mix(in srgb, var(--surface) 96%, transparent) !important;
  border-color: var(--rule) !important;
  border-radius: 16px !important;
  box-shadow: var(--shadow-soft) !important;
}
main.qr h1 {
  font-size: clamp(1.7rem, 4vw, 2.6rem) !important;
  font-weight: 820 !important;
  line-height: 1.02 !important;
}
main.qr h2 {
  font-size: 1.2rem !important;
  font-weight: 780 !important;
  border-bottom-color: var(--rule) !important;
}
main.qr code,
main.qr pre {
  background: var(--code-bg) !important;
  color: var(--code-ink) !important;
  border-color: var(--rule) !important;
}
main.qr pre {
  border-radius: 12px !important;
  padding: 0.8rem 0.9rem !important;
}
.qr-toc {
  border-radius: 16px !important;
  background: color-mix(in srgb, var(--surface) 86%, transparent) !important;
  border-color: var(--rule) !important;
  box-shadow: var(--shadow-chrome) !important;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 24%, transparent);
}

/* Print: fit on one page where possible, hide topbar, tighten spacing */
@media print {
  @page { size: A4; margin: 12mm; }
  .qr-topbar { display: none !important; }
  .qr-toc, .qr-copy { display: none !important; }
  html, body { background: #fff !important; color: #000 !important; }
  main.qr { max-width: none; margin: 0; padding: 0; font-size: 9pt; line-height: 1.35; }
  main.qr h1 { font-size: 14pt; margin: 0 0 0.4rem; }
  main.qr h2 { font-size: 11pt; margin: 0.55rem 0 0.25rem; padding-bottom: 0.15rem; }
  main.qr h3 { font-size: 9.5pt; margin: 0.45rem 0 0.2rem; }
  main.qr p, main.qr li { margin: 0.12rem 0; }
  main.qr ul, main.qr ol { margin: 0.2rem 0 0.35rem; padding-left: 1.05rem; }
  main.qr pre { font-size: 7.5pt; line-height: 1.25; padding: 0.35rem 0.5rem; margin: 0.25rem 0 0.4rem;
                break-inside: avoid; page-break-inside: avoid; }
  main.qr code { font-size: 0.85em; }
  main.qr blockquote { margin: 0.25rem 0; padding: 0.25rem 0.5rem; font-size: 8.5pt;
                       break-inside: avoid; page-break-inside: avoid; }
  main.qr hr { margin: 0.45rem 0; }
  main.qr h2, main.qr h3 { break-after: avoid; page-break-after: avoid; }
  a { color: #000 !important; text-decoration: none !important; }
}
