/* ==========================================================================
   metapredict.net
   A deliberately plain stylesheet: one accent, one font stack, generous
   whitespace, and colour reserved for the data rather than the chrome.
   ========================================================================== */

/* A single light palette. The page is white and the data keeps its own
   colours (disorder/pLDDT traces, chemistry-coloured residues); the brand
   teal and its pale-yellow counterpart carry the chrome -- top bar, card
   headers, primary actions. */
:root {
  --brand: #094354;
  --brand-text: #ffffb2;
  --brand-text-dim: rgba(255, 255, 178, 0.72);
  --brand-line: rgba(255, 255, 178, 0.38);

  --bg: #ffffff;
  --panel: #ffffff;
  --panel-alt: #f7f7f6;
  --text: #17181a;
  --muted: #6b7280;
  --faint: #9ca3af;
  --border: #e6e6e3;
  --border-strong: #d2d2ce;
  --accent: var(--brand);
  --accent-text: var(--brand-text);
  --link: #0b6a85;
  --disorder: #dc2626;
  --disorder-fill: rgba(220, 38, 38, 0.13);
  --plddt: #2563eb;
  --select: rgba(9, 67, 84, 0.12);
  --select-edge: #094354;
  --select-wash: #fde3e3;
  --warn-bg: #fff8e6;
  --warn-border: #f0d68a;
  --warn-text: #7a5c00;
  --err-bg: #fdf0ef;
  --err-border: #f0bdb8;
  --err-text: #9b2c22;
  --shadow: 0 1px 2px rgba(16, 18, 20, 0.03);
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; line-height: 1.3; }
h2 { font-size: 1.05rem; }
h3 { font-size: 0.95rem; }

p { margin: 0 0 0.85em; }
p:last-child { margin-bottom: 0; }

code, .mono { font-family: var(--mono); }

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */

.shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px 96px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--brand);
  color: var(--brand-text);
}

.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-weight: 650;
  font-size: 1.02rem;
  letter-spacing: -0.02em;
  color: var(--brand-text);
}
.brand:hover { text-decoration: none; }

.pill {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--brand-line);
  color: var(--brand-text-dim);
  white-space: nowrap;
}

/* Simple / Full switch, sitting next to the wordmark. The active tab inverts
   the brand pair so it reads clearly against the teal bar. */
.viewtabs {
  display: inline-flex;
  border: 1px solid var(--brand-line);
  border-radius: 7px;
  overflow: hidden;
  font-size: 0.8rem;
}
.viewtabs a {
  padding: 4px 12px;
  color: var(--brand-text-dim);
  border-right: 1px solid var(--brand-line);
  line-height: 1.5;
}
.viewtabs a:last-child { border-right: none; }
.viewtabs a:hover {
  color: var(--brand-text);
  text-decoration: none;
  background: rgba(255, 255, 178, 0.12);
}
.viewtabs a.on {
  background: var(--brand-text);
  color: var(--brand);
  font-weight: 600;
}
.viewtabs a.on:hover { background: var(--brand-text); color: var(--brand); }

.topnav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 18px;
  font-size: 0.86rem;
}
.topnav a { color: var(--brand-text-dim); }
.topnav a:hover { color: var(--brand-text); text-decoration: none; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  padding: 0;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }

.hero {
  padding: 44px 0 26px;
  max-width: 660px;
}
.hero h1 {
  font-size: 1.9rem;
  letter-spacing: -0.03em;
  margin-bottom: 10px;
}
.hero p { color: var(--muted); font-size: 1rem; }

/* --------------------------------------------------------------------------
   Cards & panels
   -------------------------------------------------------------------------- */

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card + .card { margin-top: 20px; }

.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.card-head h2 { flex: 0 0 auto; }
.card-head .spacer { flex: 1 1 auto; }
.card-body { padding: 18px; }

.sub { color: var(--muted); font-size: 0.85rem; }

/* --------------------------------------------------------------------------
   Form controls
   -------------------------------------------------------------------------- */

textarea#sequence {
  width: 100%;
  min-height: 150px;
  resize: vertical;
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.65;
  letter-spacing: 0.04em;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  outline: none;
}
textarea#sequence:focus { border-color: var(--accent); }
textarea#sequence::placeholder { color: var(--faint); letter-spacing: normal; font-family: inherit; }

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
  margin-top: 14px;
}

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

select, input[type="number"], input[type="text"] {
  appearance: none;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  padding: 7px 11px;
  height: 36px;
  outline: none;
}
select {
  padding-right: 30px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}
select:focus, input:focus { border-color: var(--accent); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 550;
  height: 36px;
  padding: 0 18px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease, opacity 0.12s ease;
}
.btn:hover:not(:disabled) { background: var(--panel-alt); border-color: var(--border-strong); }
.btn:disabled { opacity: 0.45; cursor: default; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
.btn-primary:hover:not(:disabled) { opacity: 0.86; background: var(--accent); }

.btn-sm { height: 28px; padding: 0 11px; font-size: 0.79rem; border-radius: 6px; }

.linkish {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 0.85rem;
  color: var(--link);
  cursor: pointer;
}
.linkish:hover { text-decoration: underline; }

.fetch-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
}
.fetch-row > label { color: var(--muted); }
.fetch-row input {
  height: 30px;
  width: 190px;
  font-size: 0.84rem;
  border-radius: 6px;
}
.fetch-row .divider {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 5px;
}
.fetch-row .linkish { margin-right: 4px; }

/* advanced settings disclosure */
details.advanced { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 14px; }
details.advanced > summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--muted);
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
details.advanced > summary::-webkit-details-marker { display: none; }
details.advanced > summary::before {
  content: "▸";
  font-size: 0.7rem;
  transition: transform 0.15s ease;
}
details.advanced[open] > summary::before { transform: rotate(90deg); }
.advanced-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.advanced-grid .field > label { text-transform: none; letter-spacing: 0; font-size: 0.78rem; }
.advanced-grid input { width: 100%; }

/* --------------------------------------------------------------------------
   Messages
   -------------------------------------------------------------------------- */

.notice {
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.86rem;
  margin-top: 14px;
  border: 1px solid;
}
.notice.warn { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn-text); }
.notice.err { background: var(--err-bg); border-color: var(--err-border); color: var(--err-text); }
.notice ul { margin: 4px 0 0; padding-left: 18px; }

/* --------------------------------------------------------------------------
   Plot
   -------------------------------------------------------------------------- */

#plot-wrap { position: relative; padding: 8px 4px 4px; }

#plot {
  display: block;
  width: 100%;
  height: 380px;
  cursor: crosshair;
  touch-action: none;
}

.plot-hint {
  font-size: 0.8rem;
  color: var(--faint);
  padding: 0 14px 12px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

#tooltip {
  position: absolute;
  pointer-events: none;
  z-index: 20;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  padding: 7px 10px;
  font-size: 0.79rem;
  line-height: 1.5;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.08s ease;
}
#tooltip.on { opacity: 1; }
#tooltip .tt-res { font-family: var(--mono); font-weight: 600; }
#tooltip .swatch {
  display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
}
.toolbar .spacer { flex: 1 1 auto; }

.toggle-group { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 7px; overflow: hidden; }
.toggle-group button {
  font: inherit;
  font-size: 0.79rem;
  height: 28px;
  padding: 0 11px;
  border: none;
  border-right: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
}
.toggle-group button:last-child { border-right: none; }
.toggle-group button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }

/* --------------------------------------------------------------------------
   Selection panel
   -------------------------------------------------------------------------- */

.selection-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.selection-range {
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 600;
}
.selection-range .len { color: var(--muted); font-weight: 400; }

/* Region properties are collapsed by default -- most of the time people want
   the sequence, not the polymer statistics. */
#regionProps { margin-top: 12px; }
#regionProps > summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--muted);
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
#regionProps > summary::-webkit-details-marker { display: none; }
#regionProps > summary::before {
  content: "▸";
  font-size: 0.7rem;
  transition: transform 0.15s ease;
}
#regionProps[open] > summary::before { transform: rotate(90deg); }
#regionProps > summary:hover { color: var(--text); }
#regionProps[aria-disabled="true"] > summary { opacity: 0.45; cursor: default; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-top: 12px;
}
.stat {
  background: var(--panel);
  padding: 9px 12px;
}
/* No text-transform here: uppercasing would turn κ and ν into Κ and Ν. */
.stat .k {
  font-size: 0.72rem;
  letter-spacing: 0.01em;
  color: var(--muted);
  line-height: 1.35;
}
.stat .v { font-family: var(--mono); font-size: 0.95rem; font-variant-numeric: tabular-nums; }
.stat .v.pending { color: var(--faint); }

/* Long selections get a scroll box rather than pushing the page around.
   Text here is natively selectable so it can be copied with the keyboard. */
#selSequence {
  min-height: 54px;
  max-height: 148px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--panel-alt);
  user-select: text;
  -webkit-user-select: text;
  cursor: text;
}
#selSequence.is-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  color: var(--faint);
  font-size: 0.9rem;
  white-space: normal;
  text-align: center;
  cursor: default;
}

.empty-state {
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 26px 18px;
}

/* --------------------------------------------------------------------------
   Sequence viewer
   -------------------------------------------------------------------------- */

.seqview {
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.85;
  white-space: pre;
  overflow-x: auto;
  padding: 4px 2px 8px;
  cursor: text;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y;
}
.seq-line { display: block; }
.seq-num {
  color: var(--faint);
  user-select: none;
  font-variant-numeric: tabular-nums;
}
.seqview .aa { border-radius: 2px; }

/* Selected residues keep whatever colour they already had -- chemistry,
   disorder gradient or the folded grey -- and are picked out by a light red
   wash behind them rather than by being repainted. */
.seqview .aa.sel {
  background: var(--select-wash);
  box-shadow: 0 -1px 0 var(--select-wash), 0 1px 0 var(--select-wash);
}
.seqview .aa.idr { text-decoration: underline; text-decoration-color: var(--disorder); text-underline-offset: 3px; }

/* Residues inside a predicted folded domain are pushed into the background so
   the disordered regions read first. */
.seqview .aa.folded { color: #c2c4c7 !important; }

.legend-row .key-idr {
  text-decoration: underline;
  text-decoration-color: var(--disorder);
  text-underline-offset: 3px;
}
.legend-row .key-folded { color: #c2c4c7; font-family: var(--mono); }

.legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 0.78rem;
  color: var(--muted);
  padding-top: 10px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}
.legend-row span b { font-weight: 600; }

.table-wrap { overflow-x: auto; }

/* --------------------------------------------------------------------------
   IDR blocks — every disordered region shown in full, coloured by chemistry
   -------------------------------------------------------------------------- */

.idr-block { border-top: 1px solid var(--border); padding: 14px 0; }
.idr-block:first-child { border-top: none; padding-top: 4px; }
.idr-block:last-child { padding-bottom: 2px; }

.idr-block-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.idr-block-head .name { font-weight: 600; font-size: 0.92rem; }
.idr-block-head .meta {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.idr-block-head .spacer { flex: 1 1 auto; }

.idr-seq {
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.85;
  white-space: pre;
  overflow-x: auto;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-alt);
  user-select: text;
  -webkit-user-select: text;
  cursor: text;
}
.idr-seq .seq-num { color: var(--faint); user-select: none; font-variant-numeric: tabular-nums; }

.idr-block.active .idr-seq { border-color: var(--border-strong); }

/* --------------------------------------------------------------------------
   Info sections
   -------------------------------------------------------------------------- */

.info { margin-top: 44px; }
.info h2 {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 14px;
}
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}
.info-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  font-size: 0.88rem;
}
.info-card h3 { margin-bottom: 8px; }
.info-card p, .info-card li { color: var(--muted); }
.info-card ul { margin: 0; padding-left: 18px; }
.info-card li { margin-bottom: 5px; }

.cite { font-size: 0.86rem; color: var(--muted); margin-bottom: 18px; }
.cite:last-child { margin-bottom: 0; }
.cite .title { color: var(--text); font-weight: 600; font-style: italic; display: block; }

details.changelog { font-size: 0.87rem; }
details.changelog summary { cursor: pointer; color: var(--muted); }
details.changelog h4 { margin: 16px 0 4px; font-size: 0.85rem; }
details.changelog ul { margin: 0; padding-left: 18px; color: var(--muted); }

footer {
  margin-top: 48px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 0.83rem;
  color: var(--faint);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
}

/* --------------------------------------------------------------------------
   Toast
   -------------------------------------------------------------------------- */

#toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 14px);
  background: var(--accent);
  color: var(--accent-text);
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 500;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 100;
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* --------------------------------------------------------------------------
   Busy state
   -------------------------------------------------------------------------- */

.spinner {
  width: 13px;
  height: 13px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: none;
}
.is-busy .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

[hidden] { display: none !important; }

@media (max-width: 700px) {
  .hero { padding-top: 30px; }
  .hero h1 { font-size: 1.55rem; }
  .topnav a.hide-sm { display: none; }
  .controls { gap: 10px; }
  .field { flex: 1 1 140px; }
  #plot { height: 300px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
