/* mltox — minimalist biotech UI
   Palette: warm-neutral paper, ink slate, one confident teal accent,
   graduated hazard scale. Mono for instrument-style data readouts. */

:root {
  --paper:      #F4F7F7;
  --card:       #FFFFFF;
  --ink:        #0B1A1C;
  --ink-soft:   #33474A;
  --muted:      #6B7E81;
  --faint:      #93A3A5;
  --line:       #E2E9EA;
  --line-soft:  #EDF2F2;

  --accent:     #0FA896;
  --accent-dk:  #0A8375;
  --accent-wash:#E4F5F2;

  --risk-minimal: #10A697;
  --risk-low:     #3BA776;
  --risk-moderate:#DFA023;
  --risk-high:    #DC5B3E;

  --ok:         #3BA776;
  --hazard:     #DC5B3E;

  --radius:     14px;
  --radius-sm:  9px;
  --shadow:     0 1px 2px rgba(11,26,28,.04), 0 8px 24px rgba(11,26,28,.05);
  --shadow-lg:  0 2px 6px rgba(11,26,28,.06), 0 18px 48px rgba(11,26,28,.10);

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", "Roboto Mono", ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(circle at 1px 1px, rgba(11,26,28,.045) 1px, transparent 0);
  background-size: 22px 22px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.label {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 500;
}

/* ---------- header ---------- */
header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(244,247,247,.82);
  backdrop-filter: saturate(1.2) blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  max-width: 1080px; margin: 0 auto;
  padding: 14px 24px;
  display: flex; align-items: center; gap: 14px;
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand svg { display: block; }
.brand .name {
  font-weight: 640; font-size: 17px; letter-spacing: -.01em;
}
.brand .name b { color: var(--accent-dk); font-weight: 640; }
.brand .tag {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--faint);
  border-left: 1px solid var(--line); padding-left: 11px; margin-left: 2px;
}
.header-spacer { flex: 1; }
.model-chip {
  display: flex; align-items: center; gap: 9px;
  font-family: var(--mono); font-size: 11.5px; color: var(--muted);
}
.model-chip .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--faint); box-shadow: 0 0 0 3px rgba(0,0,0,.03);
}
.model-chip.live .dot { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.model-chip .ver { color: var(--ink-soft); }

/* ---------- layout ---------- */
main { max-width: 1080px; margin: 0 auto; padding: 40px 24px 80px; }

.hero { margin-bottom: 30px; }
.hero h1 {
  font-size: 30px; line-height: 1.15; letter-spacing: -.02em;
  font-weight: 660; margin: 14px 0 8px;
}
.hero p { color: var(--muted); font-size: 15px; max-width: 60ch; margin: 0; }

/* ---------- input card ---------- */
.panel {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.input-card { padding: 20px; margin-bottom: 26px; }
.input-row { display: flex; gap: 10px; align-items: flex-start; }
.smiles-wrap { position: relative; flex: 1; }
.smiles-wrap .glyph {
  position: absolute; left: 15px; top: 18px;
  color: var(--faint); pointer-events: none;
}
textarea.smiles {
  width: 100%; min-height: 52px; height: 52px; max-height: 260px;
  padding: 15px 16px 15px 44px;
  font-family: var(--mono); font-size: 15px; line-height: 1.4; color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: #FCFDFD; outline: none; resize: none; overflow-y: auto;
  transition: border-color .15s, box-shadow .15s;
}
textarea.smiles::placeholder { color: var(--faint); }
textarea.smiles:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}

/* physicochemistry stat chips (biologic reports) */
.stats { display: flex; flex-wrap: wrap; gap: 7px; }
.stat {
  font-family: var(--mono); font-size: 11.5px; padding: 4px 10px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--card);
  color: var(--ink-soft);
}
.stat b { color: var(--faint); font-weight: 500; margin-right: 4px; }
.ov-meta .canon.seq { font-size: 12px; letter-spacing: .02em; }
button.primary {
  height: 52px; padding: 0 26px; border: none;
  border-radius: var(--radius-sm);
  background: var(--accent); color: #fff;
  font-family: var(--sans); font-size: 14.5px; font-weight: 600;
  letter-spacing: .01em; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  transition: background .15s, transform .06s;
  white-space: nowrap;
}
button.primary:hover { background: var(--accent-dk); }
button.primary:active { transform: translateY(1px); }
button.primary:disabled { opacity: .55; cursor: default; }

.examples { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; align-items: center; }
.examples .label { margin-right: 4px; }
.chip {
  font-size: 12.5px; padding: 5px 11px; border-radius: 100px;
  background: var(--paper); border: 1px solid var(--line);
  color: var(--ink-soft); cursor: pointer;
  transition: all .13s; font-family: var(--sans);
}
.chip:hover { border-color: var(--accent); color: var(--accent-dk); background: var(--accent-wash); }

/* ---------- recent-analysis history ---------- */
.history { margin: 0 0 26px; }
.history-head { display: flex; align-items: baseline; justify-content: space-between; margin: 0 4px 10px; }
.hist-clear {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--faint); background: none; border: none; cursor: pointer; padding: 0;
}
.hist-clear:hover { color: var(--hazard); }
.history-list { display: flex; flex-direction: column; gap: 6px; }
.hist-item {
  display: grid; grid-template-columns: 68px 1fr auto 20px; align-items: center; gap: 12px;
  text-align: left; width: 100%; padding: 9px 14px; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-family: var(--sans); transition: border-color .13s, box-shadow .13s;
}
.hist-item:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.hist-kind {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent-dk); background: var(--accent-wash); border-radius: 100px;
  padding: 3px 0; text-align: center;
}
.hist-name { font-family: var(--mono); font-size: 12.5px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-sum { font-size: 11.5px; white-space: nowrap; }
.hist-del { color: var(--faint); font-size: 16px; line-height: 1; text-align: center; border-radius: 4px; }
.hist-del:hover { color: var(--hazard); background: var(--line-soft); }

.error-msg {
  margin-top: 12px; font-size: 13.5px; color: var(--hazard);
  display: none;
}
.error-msg.show { display: block; }

/* ---------- results ---------- */
#results { display: none; }
#results.show { display: block; animation: rise .35s ease both; }

/* results toolbar (report lead + export) */
.results-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; margin: 0 4px 14px;
}
.export-btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 36px; padding: 0 15px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--card); color: var(--ink-soft);
  font-family: var(--sans); font-size: 13px; font-weight: 560; cursor: pointer;
  transition: border-color .13s, color .13s, background .13s, transform .06s;
}
.export-btn:hover { border-color: var(--accent); color: var(--accent-dk); background: var(--accent-wash); }
.export-btn:active { transform: translateY(1px); }
.export-btn svg { display: block; }

/* print-only report header (screen: hidden) */
.print-head { display: none; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.overview {
  display: grid; grid-template-columns: 168px 208px 1fr; gap: 24px;
  padding: 24px; margin-bottom: 20px; align-items: center;
}
.overview.bio { grid-template-columns: 168px 1fr; }  /* no 2D structure column */
.structure {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  align-self: stretch; justify-content: center;
  border-left: 1px solid var(--line-soft); border-right: 1px solid var(--line-soft);
  padding: 4px 16px;
}
.structure .mol-holder {
  width: 100%; min-height: 150px; display: flex; align-items: center; justify-content: center;
}
.structure svg, .structure img { max-width: 100%; height: auto; display: block; }
.structure .mol-missing { color: var(--faint); font-size: 12px; text-align: center; }
.gauge { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.gauge svg { transform: rotate(-90deg); }
.gauge .g-band { font-family: var(--mono); font-weight: 600; letter-spacing: .06em; font-size: 15px; }
.gauge .g-score { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.gauge .g-driver { font-size: 11px; color: var(--muted); text-align: center; margin-top: 2px; max-width: 150px; line-height: 1.3; }

.ov-meta { min-width: 0; }
.ov-meta .canon {
  font-family: var(--mono); font-size: 14px; color: var(--ink);
  word-break: break-all; margin: 2px 0 14px;
}
.badges { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.badge {
  font-family: var(--mono); font-size: 11px; letter-spacing: .04em;
  padding: 4px 10px; border-radius: 6px; display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); color: var(--ink-soft); background: var(--card);
}
.badge.domain-in { color: var(--accent-dk); border-color: #BFE7E1; background: var(--accent-wash); }
.badge.domain-out { color: #A8551C; border-color: #F0D9B8; background: #FBF1E2; }

.alerts { display: flex; flex-wrap: wrap; gap: 7px; }
.alert-tag {
  font-size: 12px; padding: 4px 11px; border-radius: 100px;
  background: #FBEDE8; color: #B4482C; border: 1px solid #F1D3C8;
  cursor: default;
}
.alerts .none { color: var(--faint); font-size: 12.5px; }

/* B1.5c plain-language explanation line */
.explain-line {
  display: none; margin: -6px 4px 20px; padding: 12px 16px;
  background: var(--accent-wash); border: 1px solid #CDEBE6; border-radius: var(--radius-sm);
  color: var(--ink-soft); font-size: 13.5px; line-height: 1.5;
}

/* section heading */
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 26px 4px 12px;
  flex-wrap: wrap; gap: 8px;            /* controls wrap instead of overflowing on mobile */
}
.section-head h2 { font-size: 14px; font-weight: 600; letter-spacing: -.01em; margin: 0; }
.section-head .head-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.panel-select {
  font-family: var(--mono); font-size: 11.5px; color: var(--ink-soft);
  padding: 4px 26px 4px 10px; border: 1px solid var(--line); border-radius: 7px;
  background: var(--card); cursor: pointer; outline: none;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%236B7E81' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
}
.panel-select:hover { border-color: var(--accent); }
.panel-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
/* ---------- B1.6 structure-aware refinement module (ESMFold) ---------- */
.struct-module { padding: 20px; }
.sm-peek { padding: 16px 2px; font-size: 13px; }
.sm-intro .sm-lead { font-size: 14px; color: var(--ink-soft); margin: 0 0 6px; }
.sm-intro .sm-sub { font-size: 12.5px; line-height: 1.5; margin: 0; }
.sm-actions { display: flex; align-items: center; gap: 14px; margin-top: 16px; flex-wrap: wrap; }
.sm-actions button.primary { height: 40px; padding: 0 20px; font-size: 14px; }
.sm-ico { font-size: 13px; }
.sm-ready { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.sm-ready.warn { color: #9A7412; }

/* progress */
.sm-progress { display: flex; align-items: center; gap: 16px; padding: 8px 2px; }
.sm-spinner {
  width: 26px; height: 26px; flex: none; border-radius: 50%;
  border: 2.5px solid var(--line); border-top-color: var(--accent);
  animation: sm-spin .8s linear infinite;
}
@keyframes sm-spin { to { transform: rotate(360deg); } }
.sm-status { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.sm-status b { font-size: 14px; font-weight: 560; }
.sm-status .muted { font-size: 11.5px; font-family: var(--mono); }
.sm-bar { height: 5px; border-radius: 100px; background: var(--line); overflow: hidden; position: relative; }
.sm-bar i {
  position: absolute; left: -40%; width: 40%; height: 100%; border-radius: 100px;
  background: var(--accent); animation: sm-indeterminate 1.15s ease-in-out infinite;
}
@keyframes sm-indeterminate {
  0% { left: -40%; } 60% { left: 100%; } 100% { left: 100%; }
}

/* result header */
.sm-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.sm-verdict { font-family: var(--mono); font-size: 12px; font-weight: 600; letter-spacing: .04em; }
.sm-verdict.ok { color: #2F8259; }
.sm-verdict.warn { color: #B4482C; }
.sm-conf { font-family: var(--mono); font-size: 11px; padding: 4px 10px; border-radius: 100px; }
.sm-conf.ok { background: #E9F4EE; color: #2F8259; }
.sm-conf.mod { background: #FCF3DD; color: #9A7412; }
.sm-conf.hz { background: #FBEDE8; color: #B4482C; }
.sm-cached { font-family: var(--mono); font-size: 10px; color: var(--accent-dk); background: var(--accent-wash); border: 1px solid #BFE7E1; padding: 2px 7px; border-radius: 100px; margin-right: 8px; }
.sm-did { font-size: 13.5px; color: var(--ink-soft); line-height: 1.5; margin: 0 0 16px; }

/* metric tiles */
.sm-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.sm-tile {
  background: #FCFDFD; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 14px 14px 12px; display: flex; flex-direction: column; gap: 2px;
}
.sm-tval { font-family: var(--mono); font-size: 24px; font-weight: 600; letter-spacing: -.02em; line-height: 1; }
.sm-tval small { font-size: 14px; color: var(--faint); font-weight: 500; }
.sm-tval.ok { color: #2F8259; } .sm-tval.warn { color: #B4482C; } .sm-tval.mod { color: #9A7412; } .sm-tval.hz { color: #B4482C; }
.sm-tlbl { font-size: 12px; color: var(--ink-soft); margin-top: 6px; font-weight: 560; }
.sm-tnote { font-size: 11px; color: var(--muted); }

/* exposure sparkline */
.sm-spark { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.sm-spark .label { flex: none; }
/* min-width:0 lets the SVG actually shrink inside the flex row — without it the
   box collapses to 0 while its contents keep painting, overflowing on mobile. */
.sm-sparksvg { flex: 1 1 140px; min-width: 0; height: 22px; }
.sm-spark-base { stroke: var(--line); stroke-width: 1; }
.sm-spark-line { fill: none; stroke: var(--accent); stroke-width: 1.3; vector-effect: non-scaling-stroke; }
.sm-spark-key { font-family: var(--mono); font-size: 10px; flex: none; }

/* exposed-epitope list */
.sm-list { margin-bottom: 16px; }
.sm-list .label { display: block; margin-bottom: 8px; }
.sm-list ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.sm-list li { display: flex; align-items: center; gap: 10px; font-size: 13px; flex-wrap: wrap; }
.sm-list code { font-family: var(--mono); font-size: 12px; background: var(--paper); border: 1px solid var(--line); padding: 2px 7px; border-radius: 5px; }
.sm-exp { font-family: var(--mono); font-size: 11px; color: #B4482C; background: #FBEDE8; padding: 2px 8px; border-radius: 100px; margin-left: auto; }

/* interpretation callout */
.sm-interp { border-radius: var(--radius-sm); padding: 16px 18px; border: 1px solid var(--line); }
.sm-interp.ok { background: #F2F9F5; border-color: #CDE9D8; }
.sm-interp.warn { background: #FDF6EE; border-color: #F0DCC2; }
.sm-interp .label { display: block; margin-bottom: 8px; }
.sm-interp p { font-size: 13px; line-height: 1.55; color: var(--ink-soft); margin: 0 0 8px; }
.sm-interp p:last-child { margin-bottom: 0; }
.sm-caveat { font-size: 11.5px; line-height: 1.5; margin: 14px 0 0; }

/* unavailable / error */
.sm-unavail { font-size: 13px; color: var(--ink-soft); padding: 4px 0; }
.sm-unavail.err { color: #B4482C; }

/* multidomain (large protein) */
.sm-mdnote { font-size: 13px; color: var(--ink-soft); line-height: 1.5; margin: 0 0 14px;
  background: #FCF3DD; border: 1px solid #F0D9B8; border-radius: var(--radius-sm); padding: 12px 14px; }
.sm-segtabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.sm-seg { font-family: var(--mono); font-size: 11px; color: var(--ink-soft); background: var(--card);
  border: 1px solid var(--line); border-radius: 100px; padding: 4px 11px; cursor: pointer; transition: .15s; }
.sm-seg:hover { border-color: var(--accent); color: var(--accent-dk); }
.sm-seg.active { background: var(--accent-wash); border-color: #BFE7E1; color: var(--accent-dk); }

/* live 3D viewer */
.sm-viewer-wrap { margin: 0 0 18px; }
.sm-viewer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.sm-modes { display: inline-flex; border: 1px solid var(--line); border-radius: 100px; padding: 2px; background: var(--card); }
.sm-mode { border: none; background: transparent; font-family: var(--mono); font-size: 11px; letter-spacing: .02em; color: var(--muted); padding: 5px 12px; border-radius: 100px; cursor: pointer; transition: .15s; }
.sm-mode:hover { color: var(--accent-dk); }
.sm-mode.active { background: var(--accent-wash); color: var(--accent-dk); }
.sm-viewer {
  position: relative; width: 100%; height: 340px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); overflow: hidden; background:
    linear-gradient(#FCFDFD, #F4F7F7);
}
.sm-viewer canvas { display: block; }
.sm-viewer-load, .sm-viewer-fail {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 20px; font-size: 13px; color: var(--muted);
}
.sm-viewer-fail { color: var(--ink-soft); }
.sm-legend { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 9px; font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
.sm-legend .lg-t { letter-spacing: .06em; text-transform: uppercase; }
.sm-legend .lg-chip { color: #fff; padding: 2px 8px; border-radius: 100px; font-size: 10px; }
.sm-legend .lg-grad { width: 90px; height: 8px; border-radius: 100px; }
.sm-legend .lg-grad.exp { background: linear-gradient(90deg, rgb(15,168,150), rgb(220,91,62)); }
.sm-legend .lg-note { margin-left: 6px; }

@media (max-width: 720px) {
  .sm-tiles { grid-template-columns: repeat(2, 1fr); }
  .sm-viewer { height: 280px; }
}

/* findings */
.findings { display: flex; flex-direction: column; gap: 10px; }
.finding {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--card);
  overflow: hidden; transition: box-shadow .16s, border-color .16s;
}
.finding.hazard { border-color: #F1D3C8; }
.finding:hover { box-shadow: var(--shadow); }
.finding-head {
  display: grid; grid-template-columns: 1fr 260px auto;
  gap: 18px; align-items: center; padding: 15px 18px; cursor: pointer;
}
.f-title { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.f-title .nm { font-weight: 560; font-size: 14.5px; }
.f-title .sub { display: flex; gap: 10px; align-items: center; }
.pill {
  font-family: var(--mono); font-size: 10px; letter-spacing: .05em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 5px; font-weight: 500;
}
.pill.hz { background: #FBEDE8; color: #B4482C; }
.pill.ok { background: #E9F4EE; color: #2F8259; }
.pill.conf-high { background: var(--accent-wash); color: var(--accent-dk); }
.pill.conf-moderate { background: #FCF3DD; color: #9A7412; }
.pill.conf-low { background: #F0F1F2; color: var(--muted); }
.pill.conf-set { border: 1px solid var(--line); background: var(--card); }
.pill.conf-set.hz { color: #B4482C; border-color: #F1D3C8; background: #FBEDE8; }
.pill.conf-set.ok { color: #2F8259; border-color: #CDE9D8; background: #E9F4EE; }
.pill.conf-set.amb { color: #9A7412; border-color: #F0D9B8; background: #FCF3DD; }
.calib-line { font-size: 12.5px; color: var(--ink-soft); margin: 14px 0 8px;
  padding: 8px 11px; background: #FAFBFB; border: 1px solid var(--line-soft); border-radius: 8px; }
.calib-line b { font-family: var(--mono); color: var(--ink); }
.f-auc { font-family: var(--mono); font-size: 11px; color: var(--faint); }

.prob { display: flex; align-items: center; gap: 11px; }
.prob .track {
  flex: 1; height: 8px; border-radius: 100px; background: var(--line-soft); overflow: hidden;
}
.prob .fill {
  height: 100%; width: 0; border-radius: 100px;
  transition: width .6s cubic-bezier(.22,.61,.36,1), background .3s;
}
.prob .val { font-family: var(--mono); font-size: 13px; font-weight: 600; width: 40px; text-align: right; }
.prob .delta { font-family: var(--mono); font-size: 11px; font-weight: 600; margin-left: 2px; }
.prob .delta.up { color: var(--hazard); }
.prob .delta.down { color: var(--ok); }

.f-toggle {
  color: var(--faint); transition: transform .2s; display: flex;
}
.finding.open .f-toggle { transform: rotate(90deg); }

.finding-body {
  display: none; padding: 0 18px 16px 18px;
  border-top: 1px solid var(--line-soft);
}
.finding.open .finding-body { display: block; }
.rationale { font-size: 13.5px; color: var(--ink-soft); margin: 14px 0 14px; }
.drivers { display: flex; flex-direction: column; gap: 5px; margin-bottom: 16px; }
.driver { display: grid; grid-template-columns: 150px 1fr 54px; gap: 10px; align-items: center; font-size: 12px; }
.driver .dn { font-family: var(--mono); color: var(--muted); font-size: 11.5px; }
.driver .dbar { height: 5px; background: var(--line-soft); border-radius: 3px; position: relative; }
.driver .dbar i { position: absolute; top: 0; bottom: 0; border-radius: 3px; }
.driver .dbar i.pos { left: 50%; background: var(--hazard); }
.driver .dbar i.neg { right: 50%; background: var(--accent); }
.driver .dv { font-family: var(--mono); font-size: 11px; color: var(--faint); text-align: right; }

/* feedback affordance */
.fb {
  border-top: 1px dashed var(--line); padding-top: 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.fb .fb-lead { display: flex; align-items: center; gap: 8px; }
.fb .fb-lead .label { color: var(--muted); }
.fb-form { display: none; flex-wrap: wrap; gap: 8px; align-items: center; }
.fb-form.show { display: flex; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button {
  border: none; background: var(--card); padding: 7px 13px; font-size: 12.5px;
  cursor: pointer; color: var(--ink-soft); font-family: var(--sans);
  border-right: 1px solid var(--line); transition: background .12s, color .12s;
}
.seg button:last-child { border-right: none; }
.seg button.sel.hz { background: var(--hazard); color: #fff; }
.seg button.sel.ok { background: var(--ok); color: #fff; }
select.src, input.note {
  height: 34px; border: 1px solid var(--line); border-radius: 8px;
  padding: 0 10px; font-size: 12.5px; font-family: var(--sans); color: var(--ink);
  background: var(--card); outline: none;
}
input.note { flex: 1; min-width: 140px; font-family: var(--mono); font-size: 12px; }
select.src:focus, input.note:focus { border-color: var(--accent); }
button.ghost {
  height: 34px; padding: 0 15px; border: 1px solid var(--accent);
  background: var(--accent-wash); color: var(--accent-dk); border-radius: 8px;
  font-size: 12.5px; font-weight: 600; cursor: pointer; font-family: var(--sans);
  transition: background .12s;
}
button.ghost:hover { background: #D6F0EB; }
button.link {
  background: none; border: none; color: var(--accent-dk); font-size: 12.5px;
  cursor: pointer; padding: 0; font-family: var(--sans); font-weight: 560;
}

/* protein sequence map (visualizer) */
#seqMapPanel { padding: 18px 20px; }
#seqMapPanel svg { display: block; width: 100%; height: auto; }
.seqmap-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
.seqmap-legend .item { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); }
.seqmap-legend .sw { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.seqmap-lane-label { font-family: var(--mono); font-size: 10px; fill: var(--faint); }
.solubility-plot { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.solubility-plot svg { display: block; width: 100%; height: auto; }
.sol-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 4px; }
.sol-head .sol-score { font-family: var(--mono); font-size: 11.5px; font-weight: 600; }

/* immunogenicity panel */
#immunoPanel { padding: 20px; }
.immuno-explain { font-size: 13px; color: var(--ink-soft); margin: 2px 0 14px;
  padding-left: 12px; border-left: 2px solid var(--line); }
.immuno-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.immuno-band {
  font-family: var(--mono); font-weight: 600; letter-spacing: .05em;
  font-size: 13px; padding: 4px 12px; border-radius: 7px;
}
.immuno-load { font-size: 13.5px; color: var(--ink-soft); }
.immuno-load b { font-family: var(--mono); }
.epitope-track {
  position: relative; height: 26px; border-radius: 6px; margin: 4px 0 6px;
  background: repeating-linear-gradient(90deg, var(--line-soft) 0 1px, var(--card) 1px 100%);
  background-color: var(--line-soft); border: 1px solid var(--line); overflow: hidden;
}
.epitope-seg {
  position: absolute; top: 0; bottom: 0; background: var(--hazard); opacity: .82;
  border-radius: 2px; cursor: default;
}
.epitope-seg.human { background: var(--ok); opacity: .5; }  /* self / tolerated */
.epitope-track-labels { display: flex; justify-content: space-between;
  font-family: var(--mono); font-size: 10px; color: var(--faint); }
.hotspot-list { display: flex; flex-direction: column; gap: 7px; margin-top: 14px; }
.hotspot {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--card);
}
.hotspot .pep { font-family: var(--mono); font-size: 13px; color: var(--ink); flex: 1 1 auto; min-width: 0; }
.hotspot .region {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .03em;
  padding: 3px 8px; border-radius: 6px; white-space: nowrap;
  border: 1px solid var(--line); color: var(--muted); background: var(--paper);
}
.hotspot .region.cdr { color: var(--accent-dk); border-color: #BFE7E1; background: var(--accent-wash); }
.hotspot .region.fr { color: #9A7412; border-color: #F0D9B8; background: #FBF1E2; }
.hotspot .loc { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.hotspot .promis { font-family: var(--mono); font-size: 11px; padding: 3px 9px;
  border-radius: 100px; background: #FBEDE8; color: #B4482C; }
.hotspot .promis.self { background: #E9F4EE; color: #2F8259; }
.hotspot.hazard { border-color: #F1D3C8; background: #FEFAF8; }

/* B1.1 junctional-neoepitope sub-panel */
.junction-panel { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line); }
.junction-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.junction-head .jbadge {
  font-family: var(--mono); font-size: 11.5px; font-weight: 600; letter-spacing: .03em;
  padding: 3px 10px; border-radius: 6px; background: #FBEDE8; color: #B4482C;
}
.junction-head .jnote { font-size: 12px; color: var(--muted); }
.junction-head .jnote b { color: #A8551C; font-weight: 600; }

/* B1.2 de-immunization suggestions */
.deimm-panel { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--line); }
.deimm-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.deimm-head .dbadge {
  font-family: var(--mono); font-size: 11.5px; font-weight: 600; letter-spacing: .03em;
  padding: 3px 10px; border-radius: 6px; background: var(--accent-wash); color: var(--accent-dk);
}
.deimm-head .dnote { font-size: 12px; color: var(--muted); max-width: 52ch; }
.deimm-head .dnote b { color: #A8551C; font-weight: 600; }
.deimm-epi { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px;
  margin-bottom: 10px; background: #FCFDFD; }
.deimm-epi-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.deimm-epi-head .pep { font-family: var(--mono); font-size: 13px; color: var(--ink); }
.deimm-epi-head .loc { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.deimm-best { display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--ink-soft); margin-bottom: 10px; }
.deimm-best .lbl, .deimm-pair .lbl { font-family: var(--mono); font-size: 10px;
  letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }
.deimm-best .mut, .deimm-pair .mut {
  font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--accent-dk);
  background: var(--accent-wash); padding: 2px 8px; border-radius: 6px; }
.deimm-best .arrow, .deimm-pair .arrow { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.deimm-best .removes { font-family: var(--mono); font-size: 10.5px; padding: 2px 8px;
  border-radius: 100px; background: #E9F4EE; color: #2F8259; }
.deimm-best .partial { font-family: var(--mono); font-size: 10.5px; padding: 2px 8px;
  border-radius: 100px; background: #FCF3DD; color: #9A7412; }
.deimm-row { display: grid; grid-template-columns: 86px 1fr; gap: 10px; align-items: center;
  padding: 5px 0; border-top: 1px solid var(--line-soft); }
.deimm-row .pos { font-family: var(--mono); font-size: 12px; color: var(--ink-soft); }
.deimm-row .pos em { font-style: normal; color: var(--accent-dk); font-size: 10px; }
.deimm-row .alts { display: flex; flex-wrap: wrap; gap: 6px; }
.deimm-row .alt { font-family: var(--mono); font-size: 11.5px; padding: 3px 8px;
  border: 1px solid var(--line); border-radius: 6px; color: var(--ink-soft); background: var(--card); }
.deimm-row .alt.removes { border-color: #BFE7E1; background: var(--accent-wash); color: var(--accent-dk); }
.deimm-row .alt i { font-style: normal; color: var(--ok); font-weight: 600; }
.deimm-pair { display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 9px; padding-top: 9px; border-top: 1px solid var(--line-soft); font-size: 12.5px; color: var(--ink-soft); }

/* caveats */
.caveats { padding: 18px 20px; background: #FAFBFB; }
.caveats ul { margin: 10px 0 0; padding-left: 18px; }
.caveats li { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }

/* retrain banner */
.retrain-bar {
  position: sticky; bottom: 18px; z-index: 15;
  margin: 22px auto 0; max-width: 640px;
  display: none; align-items: center; gap: 14px;
  padding: 13px 16px 13px 18px;
  background: var(--ink); color: #EAF2F1; border-radius: 12px;
  box-shadow: var(--shadow-lg);
}
.retrain-bar.show { display: flex; animation: rise .3s ease both; }
.retrain-bar .rb-text { flex: 1; font-size: 13px; }
.retrain-bar .rb-text b { color: #fff; }
.retrain-bar button.primary { height: 38px; padding: 0 18px; font-size: 13px; }
.retrain-bar button.primary.busy { pointer-events: none; }

/* toast */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 10px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 40;
  box-shadow: var(--shadow-lg);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* empty / loading */
.loading { display: none; text-align: center; padding: 50px 0; color: var(--muted); }
.loading.show { display: block; }
.spinner {
  width: 26px; height: 26px; border: 2.5px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; margin: 0 auto 14px; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

footer {
  max-width: 1080px; margin: 0 auto; padding: 26px 24px 40px;
  border-top: 1px solid var(--line); color: var(--faint); font-size: 12px;
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
footer .mono { font-family: var(--mono); }

@media (max-width: 720px) {
  /* `.overview.bio` (2 classes) outranks a bare `.overview` here — media queries
     add no specificity — so it must be named explicitly or the biologic report
     keeps its 168px gauge column and squeezes the meta column to ~46px. */
  .overview, .overview.bio { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .ov-meta { text-align: left; width: 100%; }
  .structure { border: none; border-top: 1px solid var(--line-soft);
    border-bottom: 1px solid var(--line-soft); padding: 16px 4px; width: 100%; }
  .finding-head { grid-template-columns: 1fr auto; gap: 10px; }
  .prob { grid-column: 1 / -1; order: 3; }
  .hero h1 { font-size: 25px; }
}

/* ---------- phones ---------- */
@media (max-width: 600px) {
  main { padding: 24px 16px 60px; }
  /* iOS Safari zooms the whole page when a focused field is under 16px —
     keep every text control at 16px on phones. (The old rule here targeted
     `input.smiles`, but the control is a <textarea>, so it never applied.) */
  textarea.smiles { font-size: 16px; padding: 14px 14px 14px 42px; }
  .panel-select { font-size: 16px; }
  /* a side-by-side field + button squeezes the input to ~160px — stack them.
     align-items:stretch is required: the base rule uses flex-start, which in
     column direction shrinks children to content width instead of full width. */
  .input-row { flex-direction: column; align-items: stretch; }
  .smiles-wrap { width: 100%; }
  button.primary { width: 100%; }
  .input-card { padding: 16px; }
  .struct-module, #immunoPanel { padding: 16px; }
  .sm-tiles { grid-template-columns: repeat(2, 1fr); }
  .sm-viewer { height: 240px; }
  /* the nowrap summary column can't fit beside kind + name + delete on a phone */
  .hist-item { grid-template-columns: 60px 1fr 20px; gap: 10px; padding: 9px 12px; }
  .hist-sum { display: none; }
  /* `flex:none` pins this caption to its 326px intrinsic width — give it a full
     row so it wraps, with the sparkline + key below it */
  .sm-spark .label { flex: 1 1 100%; }
}

/* ---------- print / export-to-PDF ---------- */
@media print {
  @page { margin: 14mm; }
  html, body { background: #fff !important; }
  body { background-image: none !important; color: #000; }

  /* strip interactive chrome — keep only the report itself */
  header, footer, .hero, .input-card, .loading, .retrain-bar,
  #toast, .results-bar, .fb, .f-toggle { display: none !important; }

  main { max-width: none; margin: 0; padding: 0; }
  #results { display: block !important; animation: none !important; }

  /* print-only masthead */
  .print-head { display: block !important; margin: 0 0 16px; padding-bottom: 10px;
    border-bottom: 1.5px solid var(--ink); }
  .print-head .ph-row { display: flex; justify-content: space-between;
    align-items: baseline; gap: 16px; }
  .print-head .ph-brand { font-size: 15px; font-weight: 640; letter-spacing: -.01em; }
  .print-head .ph-brand b { color: var(--accent-dk); font-weight: 640; }
  .print-head .ph-when { font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
  .print-head .ph-ident { font-family: var(--mono); font-size: 11px; color: var(--ink-soft);
    margin-top: 5px; word-break: break-all; }

  /* preserve gauge ring / bars / chips / badges when printing */
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }

  /* expand every finding so the rationale + drivers are in the record */
  .finding-body { display: block !important; }

  /* keep visual units intact across page breaks */
  .panel, .overview, .finding, .section-head, .hotspot,
  .immuno-head, .seqmap-legend, .print-head { break-inside: avoid; }
  .section-head { break-after: avoid; }

  .panel, .finding { box-shadow: none !important; }
  .finding { border-color: var(--line) !important; }
}
