/* Design system for the zhoulab prediction apps.
 *
 * One stylesheet, five apps; each sets --accent in its own page. Light and
 * dark follow the system. The 2019 pages were Bootstrap 4 with a drop-shadow
 * card -- that look is gone on purpose, but everything that identified the
 * apps stays: their logos, names, headings, help text and attribution. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #8a96a8;
  --border: #e5e8ee;
  --border-strong: #cfd6e0;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --info: #1d4ed8;
  --info-soft: #dbeafe;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 12px 32px -16px rgba(15, 23, 42, .14);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0f17; --surface: #121826; --surface-2: #182033;
    --text: #e8ebf1; --text-2: #a5afc0; --text-3: #6f7a8d;
    --border: #222b3c; --border-strong: #34405a;
    --danger: #f87171; --danger-soft: #3b1515;
    --ok: #4ade80; --ok-soft: #0f2d1a;
    --warn: #fbbf24; --warn-soft: #3a2a08;
    --info: #93c5fd; --info-soft: #11213f;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 16px 40px -20px rgba(0,0,0,.6);
  }
}
:root[data-theme="dark"] {
  --bg: #0b0f17; --surface: #121826; --surface-2: #182033;
  --text: #e8ebf1; --text-2: #a5afc0; --text-3: #6f7a8d;
  --border: #222b3c; --border-strong: #34405a;
  --danger: #f87171; --danger-soft: #3b1515;
  --ok: #4ade80; --ok-soft: #0f2d1a;
  --warn: #fbbf24; --warn-soft: #3a2a08;
  --info: #93c5fd; --info-soft: #11213f;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 16px 40px -20px rgba(0,0,0,.6);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 var(--font); font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
code { font-family: var(--mono); font-size: .9em; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.skip {
  position: absolute; left: -999px; top: 8px; background: var(--surface);
  padding: 8px 12px; border-radius: 8px; z-index: 100;
}
.skip:focus { left: 12px; }

/* ---- top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(160%) blur(12px); -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 58px; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 600; font-size: 15px; }
.brand:hover { text-decoration: none; }
.brand img { height: 28px; width: auto; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 8px; background: var(--accent);
  color: #fff; display: inline-grid; place-items: center; font-weight: 700; font-size: 13px;
}
.nav { display: flex; align-items: center; gap: 4px; }
.nav a {
  color: var(--text-2); padding: 7px 11px; border-radius: 8px; font-weight: 500; font-size: 14px;
  display: inline-flex; align-items: center; gap: 4px;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }
.ext { font-size: 12px; color: var(--text-3); }

/* ---- hero ---- */
.hero { text-align: center; padding: 44px 0 26px; }
.hero img { height: 112px; width: auto; max-width: 260px; margin-bottom: 14px; }
.hero h1 {
  margin: 0 0 8px; font-size: clamp(22px, 3vw, 30px); line-height: 1.2; font-weight: 700;
  letter-spacing: -.015em; text-wrap: balance;
}
.tagline { margin: 0 auto; max-width: 640px; color: var(--text-2); font-size: 16px; text-wrap: pretty; }

/* ---- cards ---- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 28px; margin: 0 auto 20px; max-width: 920px;
}
.card[hidden] { display: none; }
/* Results want the room: a multi-panel 32 Mb PDF is unreadable in a narrow card. */
#jobcard { max-width: none; }

/* ---- form ---- */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 20px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.span { grid-column: 1 / -1; }
.field-label { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
label { font-weight: 600; font-size: 13.5px; color: var(--text); }
.hint { font-size: 12.5px; color: var(--text-3); }
.hint a, .link-btn {
  background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer;
  font-size: 12.5px; font-weight: 500;
}
.link-btn:hover { text-decoration: underline; }
.control {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 10px 12px; transition: border-color .15s, box-shadow .15s; min-height: 42px;
}
.control::placeholder { color: var(--text-3); }
.control:hover { border-color: color-mix(in srgb, var(--border-strong) 60%, var(--text-3)); }
.control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.control:disabled { opacity: .55; cursor: not-allowed; background: var(--surface-2); }
textarea.control { font-family: var(--mono); font-size: 13px; line-height: 1.5; resize: vertical; min-height: 160px; }
input.mono { font-family: var(--mono); font-size: 13.5px; }
select.control {
  appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a96a8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center;
}
.field-help { margin: 14px 0 0; padding: 12px 14px; background: var(--surface-2); border-radius: var(--radius-sm); font-size: 13px; color: var(--text-2); line-height: 1.6; }
.field-help strong { color: var(--text); }

/* combobox (multiplexer target) */
.combo { position: relative; }
.combo-list {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 6px);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); max-height: 280px; overflow: auto; padding: 6px; margin: 0; list-style: none;
}
.combo-list[hidden] { display: none; }
.combo-list li { padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 13.5px; display: flex; justify-content: space-between; gap: 10px; }
.combo-list li small { color: var(--text-3); font-family: var(--mono); font-size: 11.5px; }
.combo-list li:hover, .combo-list li[aria-selected="true"] { background: var(--surface-2); }
.combo-list .empty { color: var(--text-3); cursor: default; }
.combo-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: 0; color: var(--text-3); cursor: pointer; padding: 4px; border-radius: 6px; font-size: 16px; line-height: 1;
}
.combo-clear:hover { background: var(--surface-2); color: var(--text); }

.actions { display: flex; align-items: center; gap: 16px; margin-top: 22px; flex-wrap: wrap; }
.btn {
  font: inherit; font-weight: 600; font-size: 14px; padding: 10px 18px; border-radius: 10px;
  border: 1px solid transparent; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  transition: background .15s, transform .05s, box-shadow .15s; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: default; transform: none; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.08), inset 0 1px 0 rgba(255,255,255,.12); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.06); }
.btn-primary:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.btn-ghost { background: transparent; color: var(--text-2); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.error { color: var(--danger); font-size: 13.5px; font-weight: 500; margin: 0; }
.error:empty { display: none; }

/* ---- job ---- */
.job-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.status-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px 5px 9px; border-radius: 999px;
  font-size: 13px; font-weight: 600; background: var(--info-soft); color: var(--info);
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.busy .dot { animation: pulse 1.4s ease-in-out infinite; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.bad { background: var(--danger-soft); color: var(--danger); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .45; transform: scale(.8); } }
@media (prefers-reduced-motion: reduce) { .pill .dot { animation: none; } }
.job-id { font-size: 13px; color: var(--text-3); display: inline-flex; align-items: center; gap: 6px; }
.job-id code { color: var(--text-2); font-size: 12.5px; }
.icon-btn {
  background: none; border: 1px solid transparent; border-radius: 6px; padding: 3px; cursor: pointer;
  color: var(--text-3); display: inline-grid; place-items: center;
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.job-copy { margin: 10px 0 0; color: var(--text-2); font-size: 14px; max-width: 60ch; text-wrap: pretty; }
.progress { height: 3px; background: var(--surface-2); border-radius: 2px; overflow: hidden; margin-top: 18px; }
.progress-bar {
  height: 100%; width: 40%; background: var(--accent); border-radius: 2px;
  animation: slide 1.6s ease-in-out infinite;
}
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }
@media (prefers-reduced-motion: reduce) { .progress-bar { animation: none; width: 100%; opacity: .4; } }

/* ---- results ---- */
.viewer { margin-top: 22px; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.viewer-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: 13px;
}
.viewer-head .name { font-family: var(--mono); font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-head .tools { display: flex; gap: 6px; }
.viewer object, .viewer iframe { display: block; width: 100%; height: min(88vh, 1200px); border: 0; background: #fff; }
.files { margin-top: 18px; }
.files h3 { margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-size: 13px; font-family: var(--mono);
}
.chip:hover { border-color: var(--accent); text-decoration: none; background: var(--surface-2); }
.chip .size { color: var(--text-3); font-family: var(--font); font-size: 12px; }
.chip svg { color: var(--text-3); }

/* puffind viewer */
.pd-controls {
  display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: center; margin-top: 20px;
  padding: 12px 14px; background: var(--surface-2); border-radius: var(--radius-sm); font-size: 13.5px;
}
.pd-controls label { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; margin: 0; }
.pd-controls input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }
.pd-controls .scale { display: inline-flex; align-items: center; gap: 8px; }
.pd-controls .scale input { width: 92px; min-height: 34px; padding: 5px 10px; }
.pd-controls .note { color: var(--text-3); font-size: 12.5px; }
#plot { width: 100%; min-height: 760px; margin-top: 10px; }

/* ---- help prose ---- */
.prose { max-width: 920px; line-height: 1.7; }
.prose h1, .prose h2 { font-size: 24px; letter-spacing: -.01em; margin: 0 0 12px; }
.prose h2 ~ h2, .prose h3, .prose h4 { font-size: 17px; margin: 28px 0 8px; }
.prose p { margin: 0 0 12px; color: var(--text-2); text-wrap: pretty; }
.prose li { color: var(--text-2); margin: 4px 0; }
.prose code { background: var(--surface-2); padding: 2px 6px; border-radius: 5px; font-size: 13px; }
.prose pre { background: var(--surface-2); padding: 14px; border-radius: var(--radius-sm); overflow: auto; font-size: 13px; }
.prose img { max-width: 100%; height: auto; border-radius: var(--radius-sm); }
.prose table { border-collapse: collapse; width: 100%; font-size: 14px; }
.prose td, .prose th { border: 1px solid var(--border); padding: 8px 10px; text-align: left; }
.prose > div { margin: 0 !important; width: auto !important; max-width: none !important; padding: 0 !important; }

/* ---- footer ---- */
.foot { padding: 28px 20px 48px; color: var(--text-3); font-size: 13px; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.foot p { margin: 0; }
.foot-links { display: flex; gap: 16px; }
.foot a { color: var(--text-2); }

@media (max-width: 640px) {
  .grid { grid-template-columns: 1fr; }
  .card { padding: 20px; }
  .hero { padding: 28px 0 18px; }
  .hero img { height: 88px; }
  .nav a { padding: 7px 8px; }
  .job-head { flex-direction: column; }
}

/* input hints and the live length readout */
.hint code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.hint strong { color: var(--text-2); }
.hint.warn, .meta.warn { color: var(--warn); }
.meta { font-size: 12.5px; color: var(--text-3); font-variant-numeric: tabular-nums; margin-left: auto; }

/* ---- interactive result viewers ---- */
.interactive { margin-top: 18px; }
.viewbar { display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: flex-end; padding: 12px 14px; background: var(--surface-2); border-radius: var(--radius-sm); margin-bottom: 10px; }
.viewbar .btn { margin-left: auto; }
.viewbar-item { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.viewbar-item .control { min-height: 36px; padding: 6px 30px 6px 10px; font-size: 13.5px; max-width: 420px; }
.viewbar-label { font-size: 11.5px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { font: inherit; font-size: 13px; font-weight: 500; padding: 5px 11px; border: 0; border-radius: 6px; background: transparent; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.seg button[aria-selected="true"] { background: var(--accent); color: #fff; }
.seg button:hover:not([aria-selected="true"]) { background: var(--surface-2); color: var(--text); }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 500; cursor: pointer; padding-bottom: 8px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.plot-tall { width: 100%; min-height: 520px; }
.plot-row { display: grid; grid-template-columns: minmax(0, 3fr) minmax(260px, 1fr); gap: 12px; align-items: start; }
.plot-square { width: 100%; min-height: 520px; }
@media (max-width: 860px) { .plot-row { grid-template-columns: 1fr; } }
