/* ===========================================================================
   lipsite webserver: frontend styles
   Self-contained: system fonts only, no external resources (CSP / offline safe).

   Design: a calm scientific instrument. One teal accent, used sparingly and
   reserved for the file drop zones and primary actions so the eye lands on
   "put your data here". Quiet borders, generous whitespace, clear hierarchy.
   Desktop-first: a wide form column beside a secondary reference/console rail.

   Theming: light by default; a real dark theme via prefers-color-scheme; an
   explicit [data-theme] on <html> overrides the media query in both directions
   (attribute selectors out-specify the bare :root inside @media).
   =========================================================================== */

/* ------------------------------- tokens -------------------------------- */
:root {
  /* Match the ReadTheDocs docs (sphinx_rtd_theme): body in Lato, headings in Roboto Slab.
     Fonts are inlined via system stacks only, no external/CDN fonts (a CSP blocks them).
     Lato/Roboto Slab are used when present, otherwise a close system fallback renders. */
  --font-sans: "Lato", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --font-head: "Roboto Slab", "Rockwell", "Rockwell Nova", ui-serif, Georgia,
    "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", "Courier New", monospace;

  /* light palette: cool neutral canvas, one teal accent */
  --bg: #f2f5f8;
  --surface: #ffffff;
  --surface-2: #eef2f6;
  --surface-3: #e1e7ee;
  --border: #e3e8ee;
  --border-2: #ccd4de;
  --text: #111820;
  --text-2: #3d4753;
  --muted: #64707d;
  --faint: #8a94a0;

  --accent: #0d746a;
  --accent-2: #0a5c54;
  --accent-ink: #ffffff;
  --accent-weak: #e2efec;
  --accent-line: #a7d2cc;

  --danger: #b42318;
  --danger-weak: #fcecea;
  --danger-line: #f0c8c4;
  --warn: #8a4f06;
  --warn-weak: #fbf1e1;
  --warn-line: #ecd7ac;
  --ok: #167a3b;

  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 26%, transparent);
  --ring-danger: 0 0 0 3px color-mix(in srgb, var(--danger) 24%, transparent);
  --shadow-1: 0 1px 2px rgba(17, 30, 44, .05), 0 1px 3px rgba(17, 30, 44, .04);
  --shadow-2: 0 10px 30px -10px rgba(17, 30, 44, .18), 0 2px 8px -4px rgba(17, 30, 44, .08);

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --shell: 1200px;
}

/* dark tokens, shared by media-query auto-dark and explicit override */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0e13;
    --surface: #141b24;
    --surface-2: #1c2530;
    --surface-3: #26313d;
    --border: #253039;
    --border-2: #39434f;
    --text: #e9eef4;
    --text-2: #c2ccd7;
    --muted: #93a0ad;
    --faint: #6b7681;

    --accent: #34c9ba;
    --accent-2: #57dccd;
    --accent-ink: #042220;
    --accent-weak: rgba(52, 201, 186, .13);
    --accent-line: rgba(52, 201, 186, .34);

    --danger: #ff958e;
    --danger-weak: rgba(255, 149, 142, .13);
    --danger-line: rgba(255, 149, 142, .34);
    --warn: #f0c064;
    --warn-weak: rgba(240, 192, 100, .12);
    --warn-line: rgba(240, 192, 100, .30);
    --ok: #5bd583;

    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-2: 0 14px 36px -12px rgba(0, 0, 0, .6);
  }
}

/* explicit override wins over the media query above */
:root[data-theme="dark"] {
  --bg: #0a0e13;
  --surface: #141b24;
  --surface-2: #1c2530;
  --surface-3: #26313d;
  --border: #253039;
  --border-2: #39434f;
  --text: #e9eef4;
  --text-2: #c2ccd7;
  --muted: #93a0ad;
  --faint: #6b7681;

  --accent: #34c9ba;
  --accent-2: #57dccd;
  --accent-ink: #042220;
  --accent-weak: rgba(52, 201, 186, .13);
  --accent-line: rgba(52, 201, 186, .34);

  --danger: #ff958e;
  --danger-weak: rgba(255, 149, 142, .13);
  --danger-line: rgba(255, 149, 142, .34);
  --warn: #f0c064;
  --warn-weak: rgba(240, 192, 100, .12);
  --warn-line: rgba(240, 192, 100, .30);
  --ok: #5bd583;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-2: 0 14px 36px -12px rgba(0, 0, 0, .6);
}

/* -------------------------------- base --------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
/* 17px root: a comfortable reading base for a desktop tool. */
html { font-size: 106.25%; -webkit-text-size-adjust: 100%; }

/* The `hidden` attribute must always win: several toggled elements carry a
   class/id that sets `display` (e.g. .btn, #job-result, .steppers), which would
   otherwise out-specify the UA [hidden] rule and leak through while hidden. */
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-sans);
  font-size: 1rem;              /* 17px */
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { margin: 0; line-height: 1.18; letter-spacing: -0.01em; font-family: var(--font-head); }
/* Roboto-Slab-style headings on the major titles, echoing the docs. Small uppercase
   eyebrows/labels stay in the body sans. */
.intro__title, .panel__title, .how__t, .sub__title { font-family: var(--font-head); }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible { outline: none; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

.mono { font-family: var(--font-mono); font-size: 0.92em; letter-spacing: -0.01em; }

.shell { width: 100%; max-width: var(--shell); margin-inline: auto; padding-inline: 32px; }

.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--surface); color: var(--text);
  padding: 10px 16px; border-radius: 0 0 var(--r-sm) 0; box-shadow: var(--shadow-2);
}
.skip-link:focus { left: 0; }

/* ------------------------------- header -------------------------------- */
.masthead {
  position: sticky; top: 0; z-index: 30;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(150%) blur(10px);
}
.masthead__inner {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 64px;
}
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand__mark { color: var(--accent); display: inline-flex; }
.brand__lockup { display: flex; flex-direction: column; line-height: 1.1; }
/* LipidSite wordmark lockup: bold "Lip"+"Site" (spells the package), muted "id". */
.brand__name { font-family: var(--font-sans); font-size: 1.28rem; font-weight: 800; letter-spacing: -0.01em; color: var(--text); }
.brand__name .wm-b { font-weight: 800; color: var(--text); }
.brand__name .wm-m { font-weight: 400; color: var(--muted); }
.brand__tag { font-size: 0.75rem; color: var(--muted); margin-top: 1px; }
@media (max-width: 640px) { .brand__tag { display: none; } }

.masthead__end { display: flex; align-items: center; gap: 14px; }
.masthead__link { font-size: 0.92rem; font-weight: 550; color: var(--muted); }
.masthead__link:hover { color: var(--text); }
@media (max-width: 520px) { .masthead__link { display: none; } }

.theme-toggle {
  flex: none; width: 38px; height: 38px; display: grid; place-items: center; cursor: pointer;
  color: var(--muted); background: var(--surface);
  border: 1px solid var(--border-2); border-radius: var(--r-sm); transition: color .15s, border-color .15s;
}
.theme-toggle:hover { color: var(--text); border-color: var(--muted); }
.theme-toggle:focus-visible { box-shadow: var(--ring); border-color: var(--accent); }
.theme-toggle .t-sun { display: none; }
.theme-toggle .t-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .t-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .t-moon { display: none; }
}
:root[data-theme="dark"] .theme-toggle .t-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .t-moon { display: none; }
:root[data-theme="light"] .theme-toggle .t-sun { display: none; }
:root[data-theme="light"] .theme-toggle .t-moon { display: block; }

/* -------------------------------- intro -------------------------------- */
.intro {
  padding: 46px 0 30px;
  background: radial-gradient(1100px 380px at 8% -40%, var(--accent-weak), transparent 62%);
}
.intro__grid {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  gap: 44px; align-items: center;
}
.intro__lead { min-width: 0; }
.intro__kicker { font-size: 0.8rem; font-weight: 650; color: var(--accent); margin-bottom: 12px; }
.intro__title {
  font-size: clamp(1.9rem, 2.8vw, 2.5rem); font-weight: 720;
  max-width: 18ch; margin-bottom: 14px;
}
.intro__lede { max-width: 60ch; color: var(--text-2); font-size: 1.1rem; line-height: 1.55; }

/* the input requirement, surfaced prominently, top of page */
.reqcard {
  background: var(--accent-weak); border: 1px solid var(--accent-line);
  border-radius: var(--r-lg); padding: 22px 24px;
}
.reqcard__title {
  font-size: 0.74rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent-2); margin-bottom: 14px;
}
.reqcard__formats {
  list-style: none; margin: 0 0 14px; padding: 0 0 14px;
  border-bottom: 1px solid var(--accent-line); display: grid; gap: 9px;
}
.reqcard__formats li { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.reqcard__k { font-size: 0.96rem; font-weight: 600; color: var(--text); }
.reqcard__v { font-size: 1rem; font-weight: 700; color: var(--accent-2); }
.reqcard__note { font-size: 0.92rem; line-height: 1.55; color: var(--text-2); }
.reqcard__note strong { color: var(--text); font-weight: 660; }
@media (max-width: 900px) { .intro__grid { grid-template-columns: 1fr; gap: 26px; } }

/* ----------------------------- how it works ---------------------------- */
.how { padding: 6px 0 40px; }
.how__list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 22px; }
.how__item { display: flex; align-items: flex-start; gap: 13px; }
.how__n {
  flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  font-size: 0.92rem; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--accent); background: var(--accent-weak); border: 1px solid var(--accent-line);
}
.how__body { min-width: 0; }
.how__t { font-size: 1rem; font-weight: 650; margin-bottom: 4px; }
.how__d { font-size: 0.9rem; color: var(--muted); line-height: 1.5; }
@media (max-width: 760px) { .how__list { grid-template-columns: 1fr 1fr; gap: 20px 26px; } }
@media (max-width: 520px) { .how__list { grid-template-columns: 1fr; } }

/* ------------------------------ workbench ------------------------------ */
.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 40px; align-items: start;
  padding-top: 8px; padding-bottom: 72px;
}
.stack { display: flex; flex-direction: column; gap: 22px; min-width: 0; }
.side { min-width: 0; }
@media (max-width: 1080px) {
  .workbench { grid-template-columns: 1fr; gap: 24px; }
  .side { order: 2; }
}

/* ------------------------------- panels -------------------------------- */
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 28px 30px; box-shadow: var(--shadow-1);
}
/* the data step reads as the primary input via a faint accent frame */
.panel--primary { border-color: var(--accent-line); }
.panel--flush { padding: 0; overflow: hidden; }

.panel__head { display: flex; align-items: flex-start; gap: 15px; margin-bottom: 22px; }
.panel__heads { min-width: 0; }
.panel__title { display: block; font-size: 1.24rem; font-weight: 660; }
.panel__sub { margin-top: 5px; font-size: 0.95rem; color: var(--muted); line-height: 1.5; max-width: 64ch; }

.step {
  flex: none; width: 34px; height: 34px; border-radius: 10px; margin-top: 1px;
  display: grid; place-items: center; font-size: 1rem; font-weight: 700;
  font-variant-numeric: tabular-nums; color: var(--accent-ink); background: var(--accent);
}
.step--ghost {
  color: var(--accent); background: var(--accent-weak); border: 1px solid var(--accent-line);
}

/* ------------------------------- fields -------------------------------- */
.field { padding-block: 22px; border-top: 1px solid var(--border); }
.field--top { border-top: 0; padding-top: 4px; }
.field--bare { padding: 0; border-top: 0; }

.lbl { display: block; font-weight: 630; font-size: 1rem; margin-bottom: 12px; }
.lbl--sm { font-size: 0.9rem; font-weight: 600; margin-bottom: 8px; }
.lbl-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.lbl-row .lbl { margin-bottom: 0; }

.hint { color: var(--muted); font-size: 0.88rem; margin-top: 10px; line-height: 1.5; }
.hint--tight { margin-top: 0; margin-bottom: 14px; }
.field--bare .hint { margin-top: 8px; }

/* required / optional pills next to a label */
.req, .opt {
  display: inline-block; vertical-align: 0.08em; margin-left: 8px;
  font-size: 0.64rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  padding: 2px 8px; border-radius: 999px; font-family: var(--font-sans);
}
.req { color: var(--danger); background: var(--danger-weak); border: 1px solid var(--danger-line); }
.opt { color: var(--muted); background: var(--surface-2); border: 1px solid var(--border-2); }

/* two-column settings row (force field | cutoff) */
.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 40px; align-items: start; }
@media (max-width: 760px) { .cols2 { grid-template-columns: 1fr; gap: 0; } }

/* three-up number grid (detection) */
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
@media (max-width: 680px) { .grid3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 440px) { .grid3 { grid-template-columns: 1fr; } }

/* inline "i" tooltip */
.tip {
  display: inline-grid; place-items: center; width: 17px; height: 17px; margin-left: 5px;
  border-radius: 50%; font-size: 0.68rem; font-weight: 700; font-style: normal; cursor: help;
  color: var(--muted); background: var(--surface-2); border: 1px solid var(--border-2);
  position: relative; vertical-align: 0.05em; font-family: var(--font-mono);
}
.tip:hover, .tip:focus-visible {
  color: var(--accent); border-color: var(--accent-line); background: var(--accent-weak);
}
.tip::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 9px); left: 50%; transform: translateX(-50%);
  width: max-content; max-width: 240px; z-index: 40;
  background: var(--text); color: var(--surface);
  font-size: 0.8rem; font-weight: 400; line-height: 1.45; font-family: var(--font-sans);
  text-align: left; letter-spacing: normal;
  padding: 8px 11px; border-radius: 8px; box-shadow: var(--shadow-2);
  opacity: 0; visibility: hidden; transition: opacity .14s; pointer-events: none;
}
.tip:hover::after, .tip:focus-visible::after { opacity: 1; visibility: visible; }

/* --------------------------- comparison mode --------------------------- */
.mode { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; }
.mode__label { flex: none; font-weight: 620; font-size: 0.98rem; color: var(--text-2); }
.mode .segmented { flex: 1; }
@media (max-width: 520px) { .mode { flex-direction: column; align-items: stretch; gap: 8px; } }

.note {
  font-size: 0.92rem; color: var(--text-2); line-height: 1.55;
  padding: 12px 15px; margin-bottom: 18px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-left: 3px solid var(--accent-line); border-radius: var(--r-sm);
}
.note strong { color: var(--text); font-weight: 650; }

/* ------------------------------ segmented ------------------------------ */
.segmented {
  display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px;
}
.segmented--fill { display: flex; width: 100%; }
.segmented--fill .segmented__opt { flex: 1 1 0; }
.segmented__opt { position: relative; cursor: pointer; }
.segmented__opt input { position: absolute; opacity: 0; inset: 0; cursor: pointer; margin: 0; }
.segmented__opt span {
  display: block; text-align: center; padding: 9px 16px; border-radius: 8px;
  font-size: 0.94rem; font-weight: 550; color: var(--text-2);
  transition: background .12s, color .12s; white-space: nowrap;
}
.segmented__opt:hover span { color: var(--text); }
.segmented__opt input:checked + span {
  background: var(--surface); color: var(--accent); box-shadow: var(--shadow-1); font-weight: 650;
}
.segmented__opt input:focus-visible + span { box-shadow: var(--ring); }

/* ==================== proteins (multi-receptor cards) =================== */
.receptors { display: flex; flex-direction: column; gap: 16px; margin-top: 2px; }

.receptor {
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: var(--r); overflow: hidden;
}
.receptor.is-error { border-color: var(--danger); }

.receptor__head {
  display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap;
  padding: 15px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.receptor__idx {
  flex: none; align-self: center; display: grid; place-items: center; min-width: 32px; height: 32px; padding: 0 8px;
  font-size: 0.8rem; font-weight: 700; color: var(--accent-ink); background: var(--accent); border-radius: 8px;
}
.receptor__field { display: flex; flex-direction: column; gap: 6px; }
.receptor__field--name { flex: 1 1 200px; min-width: 0; }
.receptor__field--off { flex: 0 0 150px; }
.receptor__flabel { font-size: 0.8rem; font-weight: 600; color: var(--muted); }
/* clarifies that the receptor name is a label (output folder / config key), not a selection */
.receptor__namehint { flex: 0 0 100%; margin: 8px 0 0; font-size: 0.8rem; line-height: 1.45; color: var(--muted); }
.receptor__del {
  flex: none; align-self: center; width: 34px; height: 34px; border-radius: 8px; cursor: pointer;
  display: grid; place-items: center; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border-2); transition: all .13s;
}
.receptor__del:hover { color: var(--danger); border-color: var(--danger-line); background: var(--danger-weak); }
.receptor__del:focus-visible { box-shadow: var(--ring); border-color: var(--accent); }
.receptor--solo .receptor__del { display: none; }

.receptor__fasta { padding: 15px 16px 0; }
.receptor__fastalabel { display: block; margin-bottom: 8px; }
.receptor__fasta .select { max-width: 420px; }
.receptor__states { padding: 16px; display: flex; flex-direction: column; gap: 16px; }

/* per-protein advanced disclosure (chain + per-file offsets) */
.receptor__adv { border-top: 1px solid var(--border); }
.receptor__advsum {
  list-style: none; cursor: pointer; padding: 12px 16px; font-size: 0.88rem; font-weight: 600; color: var(--accent);
  display: inline-flex; align-items: center; gap: 7px; user-select: none;
}
.receptor__advsum::-webkit-details-marker { display: none; }
.receptor__advsum::before {
  content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg); transition: transform .18s;
}
.receptor__adv[open] .receptor__advsum::before { transform: rotate(45deg); }
.receptor__advsum:focus-visible { box-shadow: var(--ring); border-radius: var(--r-sm); }
.receptor__advbody { padding: 2px 16px 18px; display: flex; flex-direction: column; gap: 16px; }

/* add-protein button */
.addbtn {
  margin-top: 16px; display: inline-flex; align-items: center; gap: 8px;
  font: inherit; font-size: 0.95rem; font-weight: 620; cursor: pointer; color: var(--accent);
  background: var(--accent-weak); border: 1px solid var(--accent-line); border-radius: var(--r-sm);
  padding: 11px 18px; transition: background .13s, border-color .13s;
}
.addbtn:hover { background: color-mix(in srgb, var(--accent) 15%, transparent); border-color: var(--accent); }
.addbtn:focus-visible { box-shadow: var(--ring); border-color: var(--accent); }
.addbtn svg { flex: none; }

.upload-limit { margin-top: 14px; font-size: 0.88rem; color: var(--muted); }

/* optional shared FASTA, clearly secondary */
.optional { margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--border); }
.optional__head { display: flex; align-items: center; gap: 4px; margin-bottom: 4px; }
.optional__title { font-weight: 640; font-size: 1.02rem; }

/* ==================== states (single vs active/inactive) =============== */
/* general (single condition) is the sole group, minimal chrome.
   active / inactive read as two distinct, colour-tagged groups to compare. */
.stategroup__head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.stategroup__name { font-weight: 640; font-size: 1rem; letter-spacing: -0.01em; }
.stategroup__count {
  font-family: var(--font-mono); font-size: 0.72rem; font-weight: 700;
  color: var(--muted); background: var(--surface-2);
  border: 1px solid var(--border-2); border-radius: 999px; padding: 2px 9px;
}
.stategroup--filled .stategroup__count { color: var(--accent); background: var(--accent-weak); border-color: var(--accent-line); }
.stategroup__body { min-width: 0; }
.repeats { display: flex; flex-direction: column; gap: 12px; }
.repeats:empty { display: none; }
.stategroup__empty { font-size: 0.88rem; color: var(--faint); padding: 2px 0 10px; }

.stategroup[data-state="general"] .stategroup__name {
  font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; color: var(--muted);
}
.stategroup[data-state="active"],
.stategroup[data-state="inactive"] {
  border: 1px solid var(--border); border-left-width: 3px; border-radius: var(--r-sm); padding: 14px;
}
.stategroup[data-state="active"] { border-left-color: var(--ok); }
.stategroup[data-state="inactive"] { border-left-color: var(--faint); }

/* add-repeat button (built by app.js) */
.addrepeat {
  margin-top: 12px; display: inline-flex; align-items: center; gap: 7px;
  font: inherit; font-size: 0.88rem; font-weight: 600; cursor: pointer; color: var(--accent);
  background: transparent; border: 1.5px dashed var(--accent-line); border-radius: var(--r-sm);
  padding: 9px 15px; transition: background .13s, border-color .13s;
}
.addrepeat:hover { background: var(--accent-weak); border-color: var(--accent); }
.addrepeat:focus-visible { box-shadow: var(--ring); border-color: var(--accent); }
.addrepeat svg { flex: none; }

/* a repeat row: [tag] [ topology | trajectory ] [offset?] [delete] */
.repeat {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center;
}
.repeat__tag {
  flex: none; align-self: stretch; display: grid; place-items: center; min-width: 30px; padding: 0 5px;
  font-size: 0.72rem; font-weight: 700; color: var(--accent);
  background: var(--accent-weak); border: 1px solid var(--accent-line); border-radius: 7px;
}
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; min-width: 0; }
.repeat__off { display: none; width: 100%; }
.repeat__del {
  flex: none; width: 34px; height: 34px; border-radius: 8px; cursor: pointer;
  display: grid; place-items: center; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--border-2); transition: all .13s;
}
.repeat__del:hover { color: var(--danger); border-color: var(--danger-line); background: var(--danger-weak); }
.repeat__del:focus-visible { box-shadow: var(--ring); border-color: var(--accent); }

/* per-file offset column, revealed by the per-protein toggle */
.receptor.show-offsets .repeat { grid-template-columns: auto minmax(0, 1fr) 88px auto; }
.receptor.show-offsets .repeat__off { display: block; }

/* ------------------------------- file cell ----------------------------- */
/* the primary action: prominent drop targets, the only strongly-styled control */
.filecell {
  position: relative; display: flex; align-items: center; gap: 12px; min-width: 0;
  padding: 13px 14px; min-height: 66px; cursor: pointer;
  background: var(--surface-2); border: 1.5px dashed var(--border-2); border-radius: var(--r-sm);
  transition: border-color .14s, background .14s, box-shadow .14s;
}
.filecell:hover { border-color: var(--accent); background: var(--accent-weak); }
.filecell:focus-visible { box-shadow: var(--ring); border-color: var(--accent); }
.filecell.is-drag { border-color: var(--accent); background: var(--accent-weak); border-style: solid; }
.filecell.has-file { border-style: solid; border-color: var(--accent-line); background: var(--surface); cursor: default; }
.filecell.is-error { border-color: var(--danger); border-style: solid; background: var(--danger-weak); }
.filecell__icon { flex: none; color: var(--accent); }
.filecell__body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.filecell__title { font-size: 0.95rem; font-weight: 620; color: var(--text); }
.filecell__hint { font-size: 0.78rem; color: var(--faint); }
.filecell.has-file .filecell__icon, .filecell.has-file .filecell__body { display: none; }

.filecell__file { display: flex; align-items: center; gap: 11px; width: 100%; min-width: 0; }
.filecell__badge {
  flex: none; width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center;
  background: var(--accent-weak); color: var(--accent); font-size: 0.58rem; font-weight: 700;
}
.filecell__meta { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 1px; }
.filecell__name {
  font-weight: 600; font-size: 0.9rem; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.filecell__size { font-size: 0.78rem; color: var(--muted); }
.filecell__x {
  flex: none; width: 28px; height: 28px; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--border-2); background: var(--surface-2); color: var(--muted);
  font-size: 1.15rem; line-height: 1; display: grid; place-items: center; transition: all .13s;
}
.filecell__x:hover { color: var(--danger); border-color: var(--danger-line); background: var(--danger-weak); }
.filecell__x:focus-visible { box-shadow: var(--ring); border-color: var(--accent); }

.filecell--wide { min-height: 60px; }

@media (max-width: 620px) {
  .pair { grid-template-columns: 1fr; }
  .receptor.show-offsets .repeat { grid-template-columns: auto minmax(0, 1fr) auto; }
  .receptor.show-offsets .repeat__off { grid-column: 1 / -1; width: 100%; }
}

/* ----------------------- disclosure + code block ----------------------- */
.disclose { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.disclose__sum {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer; list-style: none;
  font-size: 0.9rem; font-weight: 600; color: var(--accent); width: max-content;
}
.disclose__sum::-webkit-details-marker { display: none; }
.disclose__sum::before {
  content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg); transition: transform .18s;
}
.disclose[open] .disclose__sum::before { transform: rotate(45deg); }
.disclose__sum:focus-visible { box-shadow: var(--ring); border-radius: var(--r-sm); }
.disclose__body { margin-top: 12px; }

.code {
  position: relative; margin-top: 12px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); overflow: hidden;
}
:root[data-theme="dark"] .code { background: #0a0f16; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .code { background: #0a0f16; } }
.code pre {
  margin: 0; padding: 14px 16px; padding-right: 70px;
  white-space: pre-wrap; overflow-wrap: break-word;
  font-family: var(--font-mono); font-size: 0.82rem; line-height: 1.7; color: var(--text-2);
}
.code__line { display: block; }
.code__copy {
  position: absolute; top: 8px; right: 8px;
  font: inherit; font-size: 0.76rem; font-weight: 600;
  color: var(--muted); background: var(--surface); border: 1px solid var(--border-2);
  border-radius: 6px; padding: 4px 10px; cursor: pointer;
}
.code__copy:hover { color: var(--text); border-color: var(--muted); }
.code__copy.is-copied { color: var(--ok); border-color: var(--accent-line); }
.code__copy:focus-visible { box-shadow: var(--ring); border-color: var(--accent); }

/* ------------------------------- chips --------------------------------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chips button {
  font: inherit; font-size: 0.84rem; font-weight: 550; cursor: pointer;
  color: var(--text-2); background: var(--surface-2);
  border: 1px solid var(--border-2); border-radius: 999px; padding: 5px 14px; transition: all .12s;
  font-family: var(--font-mono);
}
.chips button:hover { border-color: var(--accent-line); color: var(--text); }
.chips button:focus-visible { box-shadow: var(--ring); border-color: var(--accent); }
.chips button.is-on { color: var(--accent); background: var(--accent-weak); border-color: var(--accent-line); }

/* ------------------------------- tag box ------------------------------- */
.tagbox {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 9px; min-height: 50px;
  background: var(--surface); border: 1px solid var(--border-2); border-radius: 11px;
  transition: border-color .15s, box-shadow .15s;
}
.tagbox:focus-within { border-color: var(--accent); box-shadow: var(--ring); }
.tag {
  display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono);
  font-size: 0.84rem; font-weight: 600; color: var(--accent);
  background: var(--accent-weak); border: 1px solid var(--accent-line);
  border-radius: 7px; padding: 4px 6px 4px 11px;
}
.tag button { border: 0; background: transparent; color: inherit; cursor: pointer; font-size: 1.05rem; line-height: 1; padding: 0 3px; opacity: .7; }
.tag button:hover { opacity: 1; }
.tagbox__input {
  flex: 1; min-width: 150px; border: 0; background: transparent; outline: none;
  font: inherit; font-size: 0.96rem; color: var(--text); padding: 4px 6px;
}
.tagbox__input::placeholder { color: var(--faint); }

/* -------------------------------- range -------------------------------- */
.valbadge {
  font-weight: 700; color: var(--accent); background: var(--accent-weak);
  border: 1px solid var(--accent-line); border-radius: 7px; padding: 3px 12px; font-size: 0.92rem;
}
.range {
  -webkit-appearance: none; appearance: none; width: 100%; height: 6px; margin: 8px 0 2px;
  border-radius: 999px; cursor: pointer;
  background: linear-gradient(var(--accent), var(--accent)) no-repeat, var(--surface-3);
  background-size: 40% 100%;
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 20px; height: 20px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--accent); box-shadow: var(--shadow-1); cursor: pointer;
}
.range::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--accent); box-shadow: var(--shadow-1); cursor: pointer;
}
.range:focus-visible::-webkit-slider-thumb { box-shadow: var(--ring); }
.range:focus-visible::-moz-range-thumb { box-shadow: var(--ring); }
.range__scale { display: flex; justify-content: space-between; margin-top: 9px; font-size: 0.76rem; color: var(--faint); }

/* -------------------------- inputs / selects --------------------------- */
.input {
  width: 100%; font: inherit; font-size: 0.98rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: 9px; padding: 11px 13px; transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--faint); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.input.is-error { border-color: var(--danger); box-shadow: var(--ring-danger); }
.input--num { max-width: 100%; }

.input-unit { position: relative; display: flex; align-items: center; }
.input-unit .input { padding-right: 62px; }
.input-unit__u {
  position: absolute; right: 13px; font-size: 0.82rem; color: var(--faint); pointer-events: none;
}

/* injected per-protein FASTA record picker */
.select { position: relative; }
.select::after {
  content: ""; position: absolute; right: 14px; top: 50%; width: 8px; height: 8px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: translateY(-70%) rotate(45deg); pointer-events: none;
}
.select select {
  width: 100%; font: inherit; font-size: 0.96rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: 9px; padding: 10px 38px 10px 13px; cursor: pointer;
  -webkit-appearance: none; appearance: none;
}
.select select:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }

/* custom selection reveal + live preview */
.reveal { margin-top: 14px; }
.preview {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 14px; padding: 11px 14px; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--border);
}
.preview__tag {
  flex: none; font-size: 0.66rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted);
}
.preview code { font-family: var(--font-mono); font-size: 0.86rem; color: var(--accent); overflow-wrap: anywhere; }

/* ------------------------------- switch -------------------------------- */
.switch { display: flex; align-items: flex-start; gap: 14px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track {
  flex: none; margin-top: 2px; width: 46px; height: 26px; border-radius: 999px;
  background: var(--surface-3); border: 1px solid var(--border-2);
  position: relative; transition: background .16s, border-color .16s;
}
.switch__thumb {
  position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--surface); box-shadow: var(--shadow-1); transition: transform .16s;
}
.switch input:checked + .switch__track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch__track .switch__thumb { transform: translateX(20px); }
.switch input:focus-visible + .switch__track { box-shadow: var(--ring); }
.switch__text strong { display: block; font-size: 0.98rem; font-weight: 640; }
.switch__text span { font-size: 0.86rem; color: var(--muted); line-height: 1.5; }
.switch__text > span { display: block; margin-top: 4px; }
.switch--sm .switch__track { width: 40px; height: 23px; }
.switch--sm .switch__thumb { width: 17px; height: 17px; }
.switch--sm input:checked + .switch__track .switch__thumb { transform: translateX(17px); }
.switch--sm .switch__text strong { font-size: 0.92rem; }

/* ------------------------------ advanced ------------------------------- */
.adv__summary { list-style: none; cursor: pointer; padding: 26px 30px; user-select: none; display: flex; align-items: center; gap: 15px; }
.adv__summary::-webkit-details-marker { display: none; }
.adv__summary-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.adv__summary-text .panel__title { font-size: 1.2rem; }
.adv__summary-text .panel__sub { margin-top: 0; }
.adv__chev { color: var(--muted); transition: transform .18s; flex: none; }
.adv[open] .adv__chev { transform: rotate(180deg); }
.adv__summary:hover .panel__title { color: var(--accent); }
.adv__summary:focus-visible { box-shadow: var(--ring); border-radius: var(--r-lg); }
.adv__body { padding: 0 30px 28px; border-top: 1px solid var(--border); }

/* labelled subgroup */
.sub { min-width: 0; margin: 0; padding: 24px 0; border: 0; border-top: 1px solid var(--border); }
.sub:first-of-type { border-top: 0; padding-top: 4px; }
.sub--last { padding-bottom: 4px; }
.sub__title {
  display: block; width: 100%; padding: 0; font-weight: 650; font-size: 1.02rem; color: var(--text);
  margin-bottom: 4px;
}

.steppers { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 18px; max-width: 360px; }
@media (max-width: 440px) { .steppers { grid-template-columns: 1fr; } }

/* ------------------------------- callouts ------------------------------ */
.callout {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: var(--r-sm); font-size: 0.9rem; line-height: 1.5;
}
.callout svg { flex: none; margin-top: 2px; }
.callout--warn { margin-top: 14px; color: var(--warn); background: var(--warn-weak); border: 1px solid var(--warn-line); }
.callout--error { display: block; color: var(--danger); background: var(--danger-weak); border: 1px solid var(--danger-line); }

/* ------------------------------- buttons ------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  font: inherit; font-weight: 630; cursor: pointer; border-radius: 10px; padding: 12px 22px;
  border: 1px solid transparent; transition: background .15s, border-color .15s, color .15s, opacity .15s;
}
.btn--full { width: 100%; }
.btn--primary { background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow-1); }
.btn--primary:hover { background: var(--accent-2); text-decoration: none; }
.btn--primary:focus-visible { box-shadow: var(--ring); }
.btn--primary:disabled { opacity: .6; cursor: default; }
.btn--ghost { background: var(--surface); color: var(--text-2); border-color: var(--border-2); }
.btn--ghost:hover { color: var(--text); border-color: var(--muted); text-decoration: none; }
.btn--ghost:focus-visible { box-shadow: var(--ring); border-color: var(--accent); }
.btn--sm { padding: 8px 14px; font-size: 0.88rem; border-radius: 8px; gap: 6px; }
.btn--run { width: 100%; padding: 16px 26px; font-size: 1.06rem; }
.btn__spinner { display: none; animation: spin .8s linear infinite; }
.btn.is-loading .btn__spinner { display: inline; }
.btn.is-loading .btn__arrow { display: none; }
.btn.is-loading { pointer-events: none; }
.btn.is-copied { color: var(--ok); border-color: var(--accent-line); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ----------------------------- form error ------------------------------ */
.form-error {
  background: var(--danger-weak); border: 1px solid var(--danger-line);
  color: var(--danger); font-size: 0.94rem; font-weight: 500;
  border-radius: var(--r); padding: 14px 17px;
}

/* ---------------------------- side / rail ------------------------------ */
.panel--side { padding: 26px; }
@media (min-width: 1081px) { .panel--side { position: sticky; top: 84px; } }

.eyebrow {
  font-size: 0.74rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint);
}
.eyebrow--spaced { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }

.ticks { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.ticks li { position: relative; padding-left: 26px; font-size: 0.93rem; color: var(--text-2); line-height: 1.45; }
.ticks li::before {
  content: ""; position: absolute; left: 3px; top: 5px; width: 11px; height: 6px;
  border-left: 2px solid var(--accent); border-bottom: 2px solid var(--accent); transform: rotate(-45deg);
}
.ticks strong { color: var(--text); font-weight: 630; }

.spec { margin: 22px 0 0; padding-top: 20px; border-top: 1px solid var(--border); display: grid; gap: 11px; }
.spec > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.spec dt { font-size: 0.9rem; color: var(--muted); }
.spec dd { margin: 0; font-size: 0.9rem; color: var(--text-2); }

.notes { list-style: none; margin: 13px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.notes li { position: relative; padding-left: 16px; font-size: 0.86rem; color: var(--muted); line-height: 1.5; }
.notes li::before { content: ""; position: absolute; left: 0; top: 9px; width: 5px; height: 5px; border-radius: 50%; background: var(--accent-line); }

/* ----------------------------- job console ----------------------------- */
.job__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.state-tag {
  font-size: 0.74rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 4px 12px; border-radius: 999px; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--border-2);
}
.state-tag.is-running { color: var(--accent); background: var(--accent-weak); border-color: var(--accent-line); }
.state-tag.is-done { color: var(--ok); background: var(--accent-weak); border-color: var(--accent-line); }
.state-tag.is-failed { color: var(--danger); background: var(--danger-weak); border-color: var(--danger-line); }

/* copyable results link, prominent */
.joblink {
  margin: 0 0 18px; padding: 15px; border-radius: var(--r);
  background: var(--accent-weak); border: 1px solid var(--accent-line);
}
.joblink__label { display: block; font-size: 0.86rem; font-weight: 650; color: var(--text); margin-bottom: 9px; }
.joblink__row { display: flex; gap: 8px; align-items: stretch; }
.joblink__input {
  flex: 1 1 auto; min-width: 0; font-size: 0.84rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-2); border-radius: 8px; padding: 9px 11px;
}
.joblink__input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.joblink__note { margin: 10px 0 0; font-size: 0.82rem; color: var(--muted); line-height: 1.45; }

.readout { display: grid; gap: 10px; margin: 0 0 18px; }
.readout > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.readout dt { font-size: 0.9rem; color: var(--muted); }
.readout dd { margin: 0; font-size: 0.9rem; color: var(--text); overflow-wrap: anywhere; }

.progress { margin-bottom: 18px; }
.progress__track { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; position: relative; }
.progress__fill { display: block; height: 100%; width: 0%; border-radius: 999px; background: var(--accent); transition: width .3s ease; }
.progress.is-indeterminate .progress__fill { width: 35%; animation: indeterminate 1.3s ease-in-out infinite; }
@keyframes indeterminate { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }
.progress.is-done .progress__fill { width: 100% !important; margin-left: 0 !important; animation: none; }
.progress__label { display: block; margin-top: 8px; font-size: 0.82rem; color: var(--muted); }

.track { list-style: none; margin: 0 0 18px; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.track li { display: flex; align-items: center; gap: 12px; padding: 7px 0; font-size: 0.93rem; color: var(--faint); position: relative; }
.track li::before { content: ""; position: absolute; left: 6px; top: 24px; bottom: -2px; width: 2px; background: var(--border-2); }
.track li:last-child::before { display: none; }
.track__dot { flex: none; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border-2); z-index: 1; }
.track li.is-active { color: var(--text); font-weight: 600; }
.track li.is-active .track__dot { border-color: var(--accent); background: var(--accent); box-shadow: 0 0 0 4px var(--accent-weak); }
.track li.is-complete { color: var(--text-2); }
.track li.is-complete .track__dot { border-color: var(--accent); background: var(--accent); }
.track li.is-complete::before { background: var(--accent); }
.track li.is-failed { color: var(--danger); font-weight: 600; }
.track li.is-failed .track__dot { border-color: var(--danger); background: var(--danger); }

.job-msg { font-size: 0.92rem; color: var(--muted); margin-bottom: 14px; }
.job-msg:empty { display: none; }

#job-result { display: flex; flex-direction: column; gap: 10px; }
.job-failed__title { display: block; color: var(--danger); margin-bottom: 8px; font-size: 0.98rem; }
.log {
  margin: 0; padding: 12px; max-height: 240px; overflow: auto;
  font-family: var(--font-mono); font-size: 0.8rem; line-height: 1.5; color: var(--text-2);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm);
  white-space: pre-wrap; word-break: break-word;
}
#reset { margin-top: 12px; }

/* -------------------------------- footer ------------------------------- */
.colophon { border-top: 1px solid var(--border); padding: 22px 0; margin-top: auto; }
.colophon__inner { display: flex; align-items: center; justify-content: space-between; gap: 12px 28px; flex-wrap: wrap; }
.colophon__cite { font-size: 0.9rem; color: var(--text-2); }
.colophon__meta { font-size: 0.86rem; color: var(--faint); }

/* -------------------------- responsive polish -------------------------- */
@media (max-width: 640px) {
  .shell { padding-inline: 20px; }
  .panel { padding: 22px; border-radius: var(--r); }
  .adv__summary { padding: 22px; }
  .adv__body { padding: 0 22px 22px; }
  .intro { padding-top: 36px; }
}

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