:root {
  --bg: #070b14;
  --bg-elev: #0d1526;
  --bg-panel: rgba(15, 23, 42, 0.84);
  --bg-input: #0a1020;
  --border: rgba(148, 163, 184, 0.16);
  --border-bright: rgba(56, 189, 248, 0.42);
  --text: #e2e8f0;
  --muted: #94a3b8;
  --dim: #64748b;

  --cyan: #38bdf8;
  --emerald: #34d399;
  --teal: #2dd4bf;
  --amber: #f59e0b;
  --crimson: #f43f5e;
  --violet: #a78bfa;
  --red: #ef4444;

  --mono: "JetBrains Mono", "Cascadia Code", "Fira Code", Consolas, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  min-height: 100vh;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(circle at 15% 12%, rgba(56, 189, 248, 0.11), transparent 36%),
    radial-gradient(circle at 86% 18%, rgba(52, 211, 153, 0.09), transparent 38%),
    linear-gradient(rgba(148, 163, 184, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.04) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 34px 34px, 34px 34px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1.75rem;
  background: rgba(7, 11, 20, 0.86);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.16), rgba(52, 211, 153, 0.12));
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.brand h1 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.version-pill {
  font-size: 0.7rem;
  font-family: var(--mono);
  padding: 0.14rem 0.45rem;
  border-radius: 999px;
  color: var(--cyan);
  background: rgba(56, 189, 248, 0.13);
  border: 1px solid rgba(56, 189, 248, 0.32);
}

.subtitle {
  margin: 0.1rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  color: var(--muted);
  padding: 0.36rem 0.75rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 10px var(--emerald);
}

.status-pill.busy .status-dot {
  background: var(--amber);
  box-shadow: 0 0 10px var(--amber);
}

.lang-switch {
  display: inline-flex;
  padding: 3px;
  border-radius: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
}

.lang-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.76rem;
  font-weight: 600;
  padding: 0.32rem 0.65rem;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.16s ease;
}

.lang-btn.active {
  background: rgba(56, 189, 248, 0.2);
  color: var(--cyan);
}

.container {
  position: relative;
  z-index: 1;
  max-width: 1420px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  box-shadow: 0 14px 36px rgba(2, 6, 23, 0.45);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.95rem;
  flex-wrap: wrap;
}

.card-header.compact {
  margin-bottom: 0.75rem;
}

.card h2 {
  margin: 0;
  font-size: 1.03rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.card-desc {
  margin: 0.2rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  gap: 0.85rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.77rem;
  color: var(--muted);
}

.field input[type="number"],
.field select,
.seq-input,
.ph-field input {
  width: 100%;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 0.5rem 0.68rem;
  font-family: var(--mono);
  font-size: 0.84rem;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.field input:focus,
.field select:focus,
.seq-input:focus,
.ph-field input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.14);
}

.range-wrap {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 0.38rem 0.65rem;
}

.range-wrap input[type="range"] {
  flex: 1;
  accent-color: var(--cyan);
}

.range-wrap output {
  font-family: var(--mono);
  color: var(--cyan);
  font-weight: 600;
  min-width: 2ch;
  text-align: right;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border-radius: 10px;
  padding: 0.56rem 1.05rem;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.12s ease, background 0.16s ease, border-color 0.16s ease;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, #0284c7, #0d9488);
  color: #f8fafc;
  box-shadow: 0 6px 20px rgba(2, 132, 199, 0.35);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #0ea5e9, #14b8a6);
}

.btn-secondary {
  background: rgba(56, 189, 248, 0.14);
  color: var(--cyan);
  border-color: rgba(56, 189, 248, 0.34);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(56, 189, 248, 0.24);
}

.btn-ghost {
  background: rgba(148, 163, 184, 0.08);
  color: var(--text);
  border-color: var(--border);
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(148, 163, 184, 0.16);
}

.lab-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.12fr);
  gap: 1.15rem;
}

.viz-card {
  display: flex;
  flex-direction: column;
}

.badge-stack {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.badge {
  font-family: var(--mono);
  font-size: 0.74rem;
  font-weight: 600;
  padding: 0.22rem 0.58rem;
  border-radius: 999px;
  border: 1px solid transparent;
}

.badge-cyan {
  background: rgba(56, 189, 248, 0.15);
  color: var(--cyan);
  border-color: rgba(56, 189, 248, 0.35);
}

.badge-red {
  background: rgba(239, 68, 68, 0.16);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.35);
}

.badge-emerald {
  background: rgba(52, 211, 153, 0.15);
  color: var(--emerald);
  border-color: rgba(52, 211, 153, 0.35);
}

.badge-slate {
  background: rgba(148, 163, 184, 0.12);
  color: var(--muted);
  border-color: var(--border);
}

.canvas-stage {
  position: relative;
  background: radial-gradient(circle at 50% 48%, rgba(15, 29, 58, 0.75), rgba(7, 11, 20, 0.94));
  border: 1px solid rgba(148, 163, 184, 0.13);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-height: 410px;
}

.canvas-stage canvas {
  width: 100%;
  height: auto;
  max-height: 440px;
  display: block;
}

.pareto-stage canvas {
  cursor: crosshair;
}

.tooltip {
  position: absolute;
  pointer-events: none;
  z-index: 10;
  background: rgba(7, 11, 20, 0.95);
  border: 1px solid var(--border-bright);
  border-radius: 10px;
  padding: 0.55rem 0.72rem;
  font-size: 0.74rem;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.55);
  min-width: 190px;
}

.tooltip.hidden {
  display: none;
}

.tooltip .tt-title {
  font-weight: 700;
  color: var(--cyan);
  margin-bottom: 0.2rem;
}

.tooltip .tt-seq {
  font-family: var(--mono);
  color: var(--text);
  font-size: 0.72rem;
  word-break: break-all;
  margin-bottom: 0.3rem;
}

.tooltip .tt-row {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  color: var(--muted);
}

.tooltip .tt-row strong {
  color: var(--text);
  font-family: var(--mono);
}

.legend-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1.05rem;
  margin-top: 0.75rem;
  font-size: 0.74rem;
  color: var(--muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.dot-cationic { background: var(--cyan); }
.dot-hydrophobic { background: var(--amber); }
.dot-polar { background: var(--teal); }
.dot-anionic { background: var(--crimson); }
.dot-moment { background: var(--red); border-radius: 2px; width: 14px; height: 4px; }
.dot-pareto { background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
.dot-benchmark { background: var(--violet); transform: rotate(45deg); border-radius: 2px; }
.dot-selected { background: transparent; border: 2px solid #ffffff; }

.playback-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.2rem;
  flex-wrap: wrap;
  padding: 0.9rem 1.25rem;
}

.playback-left {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex: 1 1 420px;
}

.scrubber-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.scrubber-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--muted);
}

.scrubber-labels strong {
  font-family: var(--mono);
  color: var(--emerald);
}

.scrubber-wrap input[type="range"] {
  width: 100%;
  accent-color: var(--emerald);
}

.playback-stats {
  display: flex;
  align-items: center;
  gap: 1.05rem;
  flex-wrap: wrap;
}

.mini-stat {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 82px;
}

.mini-stat span {
  font-size: 0.7rem;
  color: var(--muted);
}

.mini-stat strong {
  font-family: var(--mono);
  font-size: 0.92rem;
  color: var(--text);
}

#sparklineCanvas {
  border-radius: 8px;
  background: rgba(7, 11, 20, 0.7);
  border: 1px solid var(--border);
}

.inspector-form {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
  align-items: stretch;
  margin-bottom: 0.75rem;
}

.seq-input {
  flex: 1 1 320px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  font-weight: 600;
}

.ph-field {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 0 0.65rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.ph-field input {
  width: 66px;
  border: none;
  padding: 0.48rem 0.2rem;
  background: transparent;
}

.ph-field input:focus {
  box-shadow: none;
}

.export-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.error-banner {
  background: rgba(244, 63, 94, 0.14);
  border: 1px solid rgba(244, 63, 94, 0.4);
  color: #fecdd3;
  padding: 0.55rem 0.85rem;
  border-radius: 9px;
  font-size: 0.82rem;
  margin-bottom: 0.75rem;
}

.error-banner.hidden, .hidden {
  display: none;
}

.benchmark-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 1rem;
}

.chip {
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.85);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.3rem 0.72rem;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip:hover {
  border-color: var(--cyan);
  color: var(--text);
}

.chip.active {
  background: rgba(167, 139, 250, 0.18);
  border-color: var(--violet);
  color: #ede9fe;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.kpi {
  background: rgba(7, 11, 20, 0.68);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 0.75rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.kpi-label {
  font-size: 0.72rem;
  color: var(--muted);
}

.kpi-val {
  font-family: var(--mono);
  font-size: 1.22rem;
  letter-spacing: -0.02em;
}

.kpi-sub {
  font-family: var(--mono);
  font-size: 0.71rem;
  color: var(--dim);
}

.kpi-bar {
  width: 100%;
  height: 5px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.14);
  overflow: hidden;
  margin-top: 0.15rem;
}

.kpi-bar i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  transition: width 0.28s ease;
}

.kpi-potency .kpi-val { color: var(--emerald); }
.kpi-potency .kpi-bar i { background: linear-gradient(90deg, #0ea5e9, #34d399); }

.kpi-hemolysis .kpi-val { color: var(--amber); }
.kpi-hemolysis .kpi-bar i { background: linear-gradient(90deg, #f59e0b, #f43f5e); }

.kpi-stability .kpi-val { color: var(--cyan); }
.kpi-stability .kpi-bar i { background: linear-gradient(90deg, #38bdf8, #818cf8); }

.kpi-ti .kpi-val { color: #f8fafc; }

.ribbon-section {
  background: rgba(7, 11, 20, 0.62);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 0.8rem 0.9rem;
}

.ribbon-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.65rem;
}

.cleavage-summary {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--text);
}

.sequence-ribbon {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.32rem 0.22rem;
}

.res-tile {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  width: 30px;
  padding: 0.24rem 0;
  border-radius: 7px;
  font-family: var(--mono);
  border: 1px solid transparent;
}

.res-tile strong {
  font-size: 0.84rem;
  line-height: 1.1;
}

.res-tile span {
  font-size: 0.6rem;
  opacity: 0.78;
}

.res-cationic { background: rgba(56, 189, 248, 0.18); color: #7dd3fc; border-color: rgba(56, 189, 248, 0.35); }
.res-hydrophobic { background: rgba(245, 158, 11, 0.18); color: #fcd34d; border-color: rgba(245, 158, 11, 0.35); }
.res-polar { background: rgba(45, 212, 191, 0.16); color: #5eead4; border-color: rgba(45, 212, 191, 0.35); }
.res-anionic { background: rgba(244, 63, 94, 0.18); color: #fda4af; border-color: rgba(244, 63, 94, 0.38); }

.cut-marker {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 700;
  padding: 0.14rem 0.22rem;
  border-radius: 5px;
  line-height: 1.05;
}

.cut-trypsin {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.18);
  border: 1px dashed rgba(239, 68, 68, 0.55);
}

.cut-chymo {
  color: #fdba74;
  background: rgba(249, 115, 22, 0.18);
  border: 1px dashed rgba(249, 115, 22, 0.55);
}

.peptide-note {
  margin: 0.75rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  border-left: 3px solid var(--violet);
  padding-left: 0.75rem;
}

.tab-group {
  display: inline-flex;
  gap: 0.3rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  padding: 3px;
  border-radius: 10px;
}

.tab-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.77rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: 7px;
  cursor: pointer;
}

.tab-btn.active {
  background: rgba(56, 189, 248, 0.18);
  color: var(--cyan);
}

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.81rem;
}

.data-table th {
  text-align: left;
  padding: 0.6rem 0.7rem;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 0.58rem 0.7rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.08);
  font-family: var(--mono);
  white-space: nowrap;
}

.data-table tbody tr {
  cursor: pointer;
  transition: background 0.14s ease;
}

.data-table tbody tr:hover {
  background: rgba(56, 189, 248, 0.08);
}

.data-table tbody tr.selected-row {
  background: rgba(56, 189, 248, 0.16);
}

.name-cell {
  font-family: var(--sans) !important;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.tag-pill {
  font-family: var(--mono);
  font-size: 0.65rem;
  padding: 0.1rem 0.38rem;
  border-radius: 5px;
}

.tag-evolved {
  background: rgba(56, 189, 248, 0.16);
  color: var(--cyan);
}

.tag-bench {
  background: rgba(167, 139, 250, 0.18);
  color: #ddd6fe;
}

.seq-cell {
  letter-spacing: 0.06em;
  color: #cbd5e1;
}

.score-good { color: var(--emerald); font-weight: 600; }
.score-mid { color: var(--amber); font-weight: 600; }
.score-bad { color: var(--crimson); font-weight: 600; }

.footer {
  position: relative;
  z-index: 1;
  max-width: 1420px;
  margin: 0 auto;
  padding: 0.9rem 1.5rem 1.8rem;
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
  font-size: 0.76rem;
  color: var(--dim);
  border-top: 1px solid var(--border);
}

@media (max-width: 980px) {
  .lab-grid {
    grid-template-columns: 1fr;
  }
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
}
