/* =============================================================
   Psychofarm - Library: Side effects and Tools
   -------------------------------------------------------------
   The by-side-effect pages (side-effects/) and the Tools shelf
   (tools/: fillable sheets, the prior authorization letter and the
   monitoring planner). Pages are written by library-tools/build.mjs;
   library.css supplies the colour tokens (--h turns into --c-deep,
   --c-lift, --c-tint and the rest) and the dark band.
   ============================================================= */

/* ---------- the dark band at the top of each page ---------- */
.lib-band.lt-band { position: relative; top: auto; margin-bottom: 0; }
.lt-intro { position: relative; z-index: 2; padding: var(--s-2) 0; }
.lt-intro .eyebrow { margin: 0 0 var(--s-2); }
.lt-intro h1 { color: #fff; margin: 0 0 var(--s-2); font-size: clamp(2rem, 5vw, 3rem); line-height: 1.08; letter-spacing: -0.02em; }
.lt-lede { color: var(--on-dark); font-size: var(--fs-400); line-height: 1.5; max-width: 46rem; margin: 0; }
.lt-crumb { margin: 0 0 var(--s-2); font-family: var(--font-mono); font-size: var(--fs-50); letter-spacing: .06em; text-transform: uppercase; }
.lt-crumb a { color: var(--cyan); text-decoration: none; }

.lt-page { padding-block: var(--s-6) var(--s-8); }

/* ---------- cards on the shelf pages (the Library's dark panels) ---------- */
.lt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--s-3); }
.lt-card {
  position: relative; overflow: hidden; display: flex; flex-direction: column; gap: var(--s-2); padding: var(--s-4); border-radius: var(--r);
  color: #fff; text-decoration: none;
  background: radial-gradient(120% 100% at 100% 0%, var(--c-glow) 0%, transparent 58%), linear-gradient(140deg, var(--c-deep) 0%, var(--c-lift) 100%);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / .07);
  transition: box-shadow .18s var(--ease), transform .18s var(--ease);
}
a.lt-card:hover { transform: translateY(-3px); box-shadow: inset 0 0 0 1px rgb(255 255 255 / .16), 0 20px 34px -18px var(--c-lift); }
a.lt-card:focus-visible { outline: 3px solid var(--violet); outline-offset: 3px; }
.lt-card-kind { align-self: flex-start; padding: 4px 10px; border-radius: var(--r-pill); font-family: var(--font-mono); font-size: var(--fs-50); letter-spacing: .06em; text-transform: uppercase; background: rgb(255 255 255 / .14); box-shadow: inset 0 0 0 1px rgb(255 255 255 / .22); }
.lt-card-title { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-500); line-height: 1.15; letter-spacing: -0.01em; }
.lt-card-desc { color: var(--c-soft); font-size: var(--fs-100); line-height: 1.45; }
.lt-shelf-note { color: var(--slate); font-size: var(--fs-200); line-height: 1.55; max-width: 46rem; margin: var(--s-6) 0 0; }

/* ---------- members gate (calc-gate.js sets body[data-lib]) ---------- */
body[data-lib="pending"] .lt-gated, body[data-lib="locked"] .lt-gated { display: none; }
.lt-locked { display: none; }
body[data-lib="locked"] .lt-locked {
  display: block; max-width: 40rem; padding: var(--s-5); border-radius: var(--r);
  background: var(--c-tint); color: var(--c-ink);
}
.lt-locked h2 { margin: 0 0 var(--s-2); font-size: var(--fs-500); color: var(--c-ink); }
.lt-locked p { margin: 0 0 var(--s-4); color: var(--c-ink); font-size: var(--fs-200); line-height: 1.55; }
.lt-locked .lt-signin { margin-left: var(--s-3); color: var(--c-ink); font-weight: 600; }
body[data-lib="pending"] .lt-wait { display: block; }
.lt-wait { display: none; color: var(--slate); padding: var(--s-6) 0; }

/* ---------- side-effect page ---------- */
.lt-jump { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 var(--s-5); }
.lt-jump a { display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border-radius: var(--r-pill); background: var(--c-tint); color: var(--c-ink); font-weight: 600; font-size: var(--fs-100); text-decoration: none; }
.lt-jump a:focus-visible { outline: 3px solid var(--violet); outline-offset: 2px; }
.lt-sec { margin: 0 0 var(--s-7, 40px); scroll-margin-top: calc(var(--header-h, 72px) + 16px); }
.lt-sec > h2 { display: flex; align-items: center; gap: var(--s-3); margin: 0 0 var(--s-3); font-family: var(--font-display); font-weight: 700; font-size: var(--fs-600); line-height: 1.15; letter-spacing: -0.02em; color: var(--heading-ink); }
.lt-sec > h2::before { content: ''; flex: none; width: 7px; height: 1.7rem; border-radius: 4px; background: linear-gradient(180deg, var(--c-dot), var(--c-lift)); }
.lt-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; max-width: 48rem; }
.lt-list > li { position: relative; padding: 12px 14px 12px 40px; border-radius: 12px; background: #fff; box-shadow: 0 0 0 1px var(--c-line); color: var(--ink-2, #1E293B); font-size: var(--fs-200); line-height: 1.5; }
.lt-list > li::before { content: ''; position: absolute; left: 16px; top: 1.15em; width: 9px; height: 9px; border-radius: 50%; background: var(--c-dot); }
ol.lt-list { counter-reset: step; }
ol.lt-list > li { counter-increment: step; }
ol.lt-list > li::before { content: counter(step); width: 22px; height: 22px; left: 10px; top: 12px; display: grid; place-items: center; font: 700 .78rem/1 var(--font-body); color: #fff; background: var(--c-lift); }
.lt-from { display: block; margin-top: 4px; font-size: var(--fs-50); font-family: var(--font-mono); letter-spacing: .04em; text-transform: uppercase; color: var(--slate); }
.lt-from a { color: var(--c-ink); text-decoration: none; border-bottom: 1px solid var(--c-line); }
.lt-from a:hover { border-bottom-color: currentColor; }

.lt-tier { margin: var(--s-5) 0 var(--s-2); display: flex; align-items: center; gap: var(--s-2); font-family: var(--font-display); font-weight: 700; font-size: var(--fs-400); color: var(--heading-ink); }
.lt-tier:first-of-type { margin-top: 0; }
.lt-n { font-family: var(--font-body); font-weight: 600; font-size: var(--fs-100); line-height: 1; padding: 5px 10px; border-radius: var(--r-pill); color: var(--c-ink); background: var(--c-tint); }
.lt-drugs { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.lt-drugs a { display: flex; flex-direction: column; gap: 3px; height: 100%; box-sizing: border-box; padding: 11px 14px; border-radius: 12px; text-decoration: none; color: var(--c-ink); background: var(--c-tint); box-shadow: inset 0 0 0 1px var(--c-line); }
.lt-drugs a:hover { box-shadow: inset 0 0 0 1px var(--c-dot); }
.lt-drugs a:focus-visible { outline: 3px solid var(--violet); outline-offset: 2px; }
.lt-drugs b { font-family: var(--font-display); font-size: var(--fs-300); }
.lt-drugs span { font-size: var(--fs-100); line-height: 1.4; color: var(--ink-2, #334155); }
.lt-tier[data-level="1"] + .lt-drugs a { background: var(--c-deep); color: #fff; box-shadow: none; }
.lt-tier[data-level="1"] + .lt-drugs span { color: var(--c-soft); }

.lt-hand { display: flex; flex-wrap: wrap; gap: 10px; }
.lt-hand a { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 12px; background: var(--c-deep); color: #fff; text-decoration: none; font-weight: 600; font-size: var(--fs-200); }
.lt-hand a:focus-visible { outline: 3px solid var(--violet); outline-offset: 2px; }
.lt-fine { max-width: 48rem; color: var(--slate); font-size: var(--fs-100); line-height: 1.55; margin: var(--s-6) 0 0; }
.lt-scale { display: inline-block; margin-top: 6px; font-weight: 600; color: var(--c-ink); }

/* ---------- fillable sheets ---------- */
.fs-actions { position: sticky; top: var(--header-h, 72px); z-index: 15; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 var(--s-5); padding: 10px 0; background: var(--paper, #F8FAFC); }
.fs-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 16px; border-radius: var(--r-pill); border: 0; cursor: pointer; font: 600 var(--fs-200)/1 var(--font-body); }
.fs-btn--go { background: var(--cyan); color: var(--ink); }
.fs-btn--quiet { background: #fff; color: var(--ink-2, #334155); box-shadow: inset 0 0 0 1px var(--c-line); }
.fs-btn:focus-visible { outline: 3px solid var(--violet); outline-offset: 2px; }
.fs-keep { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-100); color: var(--slate); }
.fs-keep input { width: 18px; height: 18px; }
.fs-saved { font-size: var(--fs-100); color: var(--teal-deep, #0F766E); }
.fs-danger { max-width: 48rem; margin: 0 0 var(--s-5); padding: 14px 16px; border-radius: 12px; background: #FFF1EB; color: #7C2D12; box-shadow: inset 0 0 0 1px #FDBA9A; font-size: var(--fs-200); line-height: 1.5; }
.fs-danger b { color: #9A3412; }
.fs-meta { display: flex; flex-wrap: wrap; gap: 12px 20px; margin: 0 0 var(--s-5); }
.fs-meta label { display: flex; flex-direction: column; gap: 4px; font-size: var(--fs-100); font-weight: 600; color: var(--ink-2, #334155); }
.fs-meta input { min-width: 12rem; }
.fs-form { display: grid; gap: var(--s-4); max-width: 52rem; }
.fs-group { padding: var(--s-4); border-radius: var(--r); background: #fff; box-shadow: 0 0 0 1px var(--c-line), 0 14px 26px -24px rgb(15 23 42 / .5); }
.fs-group h2 { margin: 0 0 6px; font-family: var(--font-display); font-weight: 700; font-size: var(--fs-500); line-height: 1.2; color: var(--c-ink); }
.fs-note { margin: 0 0 var(--s-3); color: var(--slate); font-size: var(--fs-100); line-height: 1.5; }
.fs-field { display: block; margin: 0 0 10px; }
.fs-field > span { display: block; margin: 0 0 4px; font-size: var(--fs-100); font-weight: 600; color: var(--ink-2, #334155); }
.fs-form input[type="text"], .fs-form input[type="date"], .fs-form textarea, .fs-meta input {
  width: 100%; box-sizing: border-box; padding: 10px 12px; border-radius: 10px; border: 1px solid #CBD5E1; background: #fff;
  font: 400 1rem/1.4 var(--font-body); color: var(--ink, #0B1220);
}
.fs-form textarea { min-height: 2.9em; resize: vertical; overflow: hidden; }
.fs-form input:focus, .fs-form textarea:focus, .fs-meta input:focus { outline: 3px solid var(--violet-soft, #C4B5FD); outline-offset: 1px; border-color: transparent; }
.fs-inline { font-size: var(--fs-200); line-height: 2.2; color: var(--ink-2, #334155); }
.fs-inline input[type="text"] { display: inline-block; width: 4.5em; padding: 4px 8px; margin: 0 4px; text-align: center; }
.fs-add { margin-top: 2px; padding: 6px 10px; border: 0; border-radius: 8px; background: var(--c-tint); color: var(--c-ink); font: 600 var(--fs-100)/1 var(--font-body); cursor: pointer; }
.fs-fixed { margin: 0 0 10px; padding: 10px 12px; border-radius: 10px; background: var(--c-tint); color: var(--c-ink); font-size: var(--fs-100); line-height: 1.5; }
.fs-table-wrap { overflow-x: auto; }
.fs-table { width: 100%; border-collapse: collapse; min-width: 34rem; }
.fs-table th { text-align: left; font-size: var(--fs-50); font-family: var(--font-mono); letter-spacing: .04em; text-transform: uppercase; color: var(--slate); padding: 0 6px 6px; }
.fs-table td { padding: 3px; }
.fs-table input[type="text"] { padding: 7px 8px; }
.fs-credit { max-width: 48rem; margin: var(--s-6) 0 0; color: var(--slate); font-size: var(--fs-100); line-height: 1.55; }
.fs-credit a { color: var(--c-ink); }

/* the print view: the plan alone, as a clean page to hand over */
.fs-print-title { display: none; }
@media print {
  @page { margin: 14mm; }
  body { background: #fff !important; }
  .site-header, .lib-tabs, .lib-band, .site-footer, .disclaimer-band, .fs-actions, .fs-add, .fs-credit, .skip-link, .pf-lt-overlay, .lib-modal, .gj-bar, .pf-fav-toast, .lt-locked, .lt-wait { display: none !important; }
  .lt-page { padding: 0 !important; }
  .fs-print-title { display: block; margin: 0 0 8px; font: 700 20pt/1.1 var(--font-display); color: #000; }
  .fs-group { box-shadow: none; border: 1px solid #999; padding: 8px 10px; break-inside: avoid; }
  .fs-form { gap: 8px; max-width: none; }
  .fs-group h2 { font-size: 12pt; color: #000; }
  .fs-note { font-size: 9pt; margin-bottom: 4px; }
  .fs-field { margin-bottom: 4px; }
  .fs-field > span { font-size: 9pt; color: #000; }
  .fs-form input[type="text"], .fs-form input[type="date"], .fs-form textarea, .fs-meta input {
    border: 0; border-bottom: 1px solid #777; border-radius: 0; padding: 2px 0; font-size: 10.5pt; min-height: 0; resize: none; background: transparent;
  }
  .fs-danger { background: #fff; color: #000; box-shadow: none; border: 2px solid #000; font-size: 10pt; padding: 6px 8px; }
  .fs-danger b { color: #000; }
  .fs-fixed { background: #fff; padding: 0; font-size: 9pt; color: #000; }
  .fs-table { min-width: 0; }
  .fs-table input[type="text"] { border-bottom: 1px solid #777; }
}

/* ---------- prior authorization letter ---------- */
.pa-wrap { display: grid; gap: var(--s-5); align-items: start; }
@media (min-width: 1040px) { .pa-wrap { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .pa-out { position: sticky; top: calc(var(--header-h, 72px) + 12px); } }
.pa-privacy { margin: 0; }
.pa-types { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 var(--s-3); }
.pa-types label { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: var(--r-pill); background: var(--c-tint); color: var(--c-ink); font-weight: 600; font-size: var(--fs-100); cursor: pointer; }
.pa-types input { accent-color: var(--c-lift); }
.pa-check { display: flex; align-items: flex-start; gap: 8px; margin: 0 0 6px; font-size: var(--fs-200); color: var(--ink-2, #334155); cursor: pointer; }
.pa-check input { margin-top: 4px; width: 18px; height: 18px; flex: none; accent-color: var(--c-lift); }
.pa-reason { margin: 0 0 10px; }
.pa-reason input[type="text"] { margin-left: 26px; width: calc(100% - 26px); }
.pa-trials { display: grid; gap: 10px; margin-bottom: 8px; }
.pa-trial { display: grid; gap: 6px; padding: 10px; border-radius: 10px; background: var(--c-tint); grid-template-columns: 1fr 1fr; }
.pa-trial input[name$="drug"], .pa-trial input[name$="note"] { grid-column: 1 / -1; }
.pa-trial select { width: 100%; box-sizing: border-box; padding: 10px 12px; border-radius: 10px; border: 1px solid #CBD5E1; background: #fff; font: 400 1rem/1.4 var(--font-body); }
.pa-out .fs-actions { margin-bottom: var(--s-3); }
.pa-letter { padding: 22px 24px; border-radius: 6px; background: #fff; color: #111827; box-shadow: 0 0 0 1px #E2E8F0, 0 18px 34px -26px rgb(15 23 42 / .55); font: 400 .98rem/1.55 Georgia, 'Times New Roman', serif; }
.pa-letter p { margin: 0 0 .9em; color: inherit; }
@media print {
  .pa-form, .pa-actions, .lt-fine { display: none !important; }
  .pa-wrap { display: block; }
  .pa-letter { box-shadow: none; padding: 0; font-size: 11.5pt; }
}

/* ---------- monitoring planner ---------- */
.mp { max-width: 56rem; }
.mp-pick { position: relative; margin-bottom: var(--s-4); }
.mp-search { margin: 0; }
.mp-search input { width: 100%; box-sizing: border-box; padding: 12px 14px; border-radius: 12px; border: 1px solid #CBD5E1; background: #fff; font: 400 1.05rem/1.3 var(--font-body); }
.mp-search input:focus { outline: 3px solid var(--violet-soft, #C4B5FD); outline-offset: 1px; border-color: transparent; }
.mp-list { position: absolute; z-index: 30; left: 0; right: 0; margin: 4px 0 0; padding: 6px; list-style: none; border-radius: 12px; background: #fff; box-shadow: 0 0 0 1px #E2E8F0, 0 18px 34px -18px rgb(15 23 42 / .45); max-height: 50vh; overflow-y: auto; }
.mp-opt { display: block; width: 100%; text-align: left; padding: 11px 12px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; font: 400 1rem/1.3 var(--font-body); color: var(--ink, #0B1220); }
.mp-opt:hover, .mp-opt:focus-visible { background: var(--c-tint); outline: none; }
.mp-opt span { color: var(--slate); }
.mp-none { color: var(--slate); font-size: var(--fs-100); padding: 8px 12px; margin: 0; }
.mp-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.mp-chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 4px 4px 12px; border-radius: var(--r-pill); background: var(--c-deep); color: #fff; font-weight: 600; font-size: var(--fs-100); }
.mp-x { width: 30px; height: 30px; border: 0; border-radius: 50%; background: rgb(255 255 255 / .12); color: #fff; font-size: 1.1rem; line-height: 1; cursor: pointer; }
.mp-x:focus-visible { outline: 2px solid var(--cyan); outline-offset: 1px; }
.mp-empty { color: var(--slate); font-size: var(--fs-200); line-height: 1.55; max-width: 44rem; }
.mp-title { font-family: var(--font-display); font-size: var(--fs-500); color: var(--heading-ink); margin: 0 0 var(--s-4); }
.mp-part { margin-bottom: var(--s-6); }
.mp-part-h { display: flex; align-items: center; gap: 10px; margin: 0 0 var(--s-3); font-family: var(--font-display); font-size: var(--fs-500); color: var(--heading-ink); }
.mp-part-h::before { content: ''; width: 7px; height: 1.6rem; border-radius: 4px; background: linear-gradient(180deg, var(--c-dot), var(--c-lift)); }
.mp-groups { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.mp-group { padding: 12px 14px; border-radius: 12px; background: #fff; box-shadow: 0 0 0 1px var(--c-line); }
.mp-group h4 { margin: 0 0 6px; font-family: var(--font-display); font-size: var(--fs-300); color: var(--c-ink); }
.mp-row { margin: 0 0 6px; font-size: var(--fs-200); line-height: 1.5; color: var(--ink-2, #334155); }
.mp-row:last-child { margin-bottom: 0; }
.mp-src { font-family: var(--font-mono); font-size: var(--fs-50); letter-spacing: .04em; text-transform: uppercase; color: var(--c-ink); text-decoration: none; border-bottom: 1px solid var(--c-line); }
@media print {
  .mp-pick .mp-search, .mp-list, .mp-x, .mp-actions, .mp-src { display: none !important; }
  .mp-chip { background: #fff; color: #000; border: 1px solid #000; }
  .mp-group { box-shadow: none; border: 1px solid #999; break-inside: avoid; }
  .mp-group h4, .mp-part-h, .mp-title { color: #000; }
  .mp-row { font-size: 10pt; color: #000; }
}
