:root {
  color-scheme: light;
  --surface-0: #f6f5f1;
  --surface-1: #ffffff;
  --surface-2: #efeee9;
  --border: #dcdad2;
  --hairline: #e1e0d9;
  --text-primary: #1b1b19;
  --text-secondary: #55544e;
  --text-muted: #7c7b73;
  --accent: #2a78d6;
  --edge: #9a9890;
  --edge-hi: #1b1b19;
  --compound: #f1f0eb;
  --compound-border: #c9c7bd;

  --mod-phospho: #2a78d6;
  --mod-acetyl: #eb6834;
  --mod-methyl: #1baf7a;
  --mod-dehydrated: #eda100;
  --mod-gg: #e87ba4;
  --mod-carboxy: #008300;
  --mod-deamidated: #6250d6;
  --mod-hne: #e34948;
  --mod-other: #8a8985;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-0: #121211;
    --surface-1: #1a1a19;
    --surface-2: #242422;
    --border: #34342f;
    --hairline: #2c2c2a;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #94938a;
    --accent: #3987e5;
    --edge: #6d6c66;
    --edge-hi: #f0efec;
    --compound: #222220;
    --compound-border: #44443f;

    --mod-phospho: #3987e5;
    --mod-acetyl: #d95926;
    --mod-methyl: #199e70;
    --mod-dehydrated: #c98500;
    --mod-gg: #d55181;
    --mod-carboxy: #0ca30c;
    --mod-deamidated: #9085e9;
    --mod-hne: #e66767;
    --mod-other: #8a8985;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-0: #121211;
  --surface-1: #1a1a19;
  --surface-2: #242422;
  --border: #34342f;
  --hairline: #2c2c2a;
  --text-primary: #f0efec;
  --text-secondary: #c3c2b7;
  --text-muted: #94938a;
  --accent: #3987e5;
  --edge: #6d6c66;
  --edge-hi: #f0efec;
  --compound: #222220;
  --compound-border: #44443f;

  --mod-phospho: #3987e5;
  --mod-acetyl: #d95926;
  --mod-methyl: #199e70;
  --mod-dehydrated: #c98500;
  --mod-gg: #d55181;
  --mod-carboxy: #0ca30c;
  --mod-deamidated: #9085e9;
  --mod-hne: #e66767;
  --mod-other: #8a8985;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--surface-0);
  color: var(--text-primary);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 10px 16px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 18px; text-decoration: none; color: var(--text-primary); white-space: nowrap; }
.brand span { font-weight: 400; font-size: 13px; color: var(--text-secondary); margin-left: 6px; }
.search { position: relative; flex: 1; max-width: 640px; }
.search input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-0);
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
#suggest {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px);
  margin: 0; padding: 4px; list-style: none;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgb(0 0 0 / .12);
  max-height: 60vh; overflow-y: auto;
}
#suggest li { display: flex; gap: 10px; align-items: baseline; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
#suggest li[aria-selected="true"], #suggest li:hover { background: var(--surface-2); }
#suggest .kind { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); width: 76px; flex: none; }
#suggest .sub { color: var(--text-secondary); font-size: 12px; margin-left: auto; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 50%; }

.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 340px;
}
.panel { background: var(--surface-1); overflow-y: auto; padding: 12px 16px; }
.controls { border-right: 1px solid var(--border); }
.details { border-left: 1px solid var(--border); }
.panel h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin: 14px 0 6px; }
.panel section:first-child h2 { margin-top: 2px; }
.slider-row { display: flex; align-items: center; gap: 8px; }
.slider-row input { flex: 1; accent-color: var(--accent); }
.slider-row output { font-variant-numeric: tabular-nums; width: 3em; text-align: right; }
.check { display: flex; gap: 8px; align-items: center; margin: 4px 0; cursor: pointer; }
.check input { accent-color: var(--accent); }
.field { display: flex; justify-content: space-between; align-items: center; margin: 6px 0; }
.field select { padding: 2px 4px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-0); }
.hint { font-size: 12px; color: var(--text-muted); margin: 4px 0; }
.meta { font-size: 12px; color: var(--text-muted); border-top: 1px solid var(--hairline); margin-top: 16px; padding-top: 8px; }

.legend { list-style: none; margin: 0; padding: 0; }
.legend li { display: flex; align-items: center; gap: 8px; padding: 3px 4px; border-radius: 6px; cursor: pointer; user-select: none; }
.legend li:hover { background: var(--surface-2); }
.legend li.off { opacity: .4; }
.legend .swatch { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.legend .count { margin-left: auto; color: var(--text-muted); font-variant-numeric: tabular-nums; font-size: 12px; }

.stage { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.viewbar {
  display: flex; align-items: center; gap: 12px; padding: 8px 12px;
  border-bottom: 1px solid var(--border); background: var(--surface-1);
}
.view-title { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.view-title small { font-weight: 400; color: var(--text-secondary); margin-left: 8px; }
.viewbar-actions { display: flex; gap: 6px; }
.viewbar button, .details button {
  border: 1px solid var(--border); background: var(--surface-0); border-radius: 6px; padding: 3px 10px; cursor: pointer;
}
.viewbar button:hover, .details button:hover { background: var(--surface-2); }
.track { background: var(--surface-1); border-bottom: 1px solid var(--border); padding: 4px 12px 0; }
.track svg { display: block; width: 100%; }
.track text { fill: var(--text-secondary); font-size: 11px; }
.track .axis { stroke: var(--text-muted); }
.track .lolli { cursor: pointer; }
.track .lolli line { stroke: var(--text-muted); stroke-width: 1; }
.track .lolli circle { stroke: var(--surface-1); stroke-width: 2; }
.track .lolli.dim { opacity: .3; }
.track .lolli.hi circle { stroke: var(--edge-hi); }
.notice { background: var(--surface-2); color: var(--text-secondary); font-size: 12px; padding: 6px 12px; border-bottom: 1px solid var(--border); }
.cy { flex: 1; min-height: 0; background: var(--surface-0); }
.welcome {
  position: absolute; inset: 41px 0 0 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 24px; pointer-events: none;
}
.welcome h1 { font-size: 22px; margin: 0 0 8px; }
.welcome p { max-width: 460px; color: var(--text-secondary); margin: 0 0 16px; }
.examples { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; pointer-events: auto; }
.examples button { border: 1px solid var(--border); background: var(--surface-1); border-radius: 999px; padding: 5px 14px; cursor: pointer; }
.examples button:hover { border-color: var(--accent); }
.tooltip {
  position: absolute; z-index: 30; pointer-events: none; max-width: 300px;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px;
  box-shadow: 0 6px 18px rgb(0 0 0 / .15); font-size: 12px;
}
.tooltip b { font-size: 13px; }
.tooltip .muted { color: var(--text-muted); }

.details h3 { margin: 2px 0 2px; font-size: 18px; }
.details .subtitle { color: var(--text-secondary); margin: 0 0 10px; }
.details dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0 0 12px; }
.details dt { color: var(--text-muted); }
.details dd { margin: 0; font-variant-numeric: tabular-nums; }
.details h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin: 16px 0 6px; }
.details table { width: 100%; border-collapse: collapse; font-size: 12px; }
.details th { text-align: left; color: var(--text-muted); font-weight: 500; border-bottom: 1px solid var(--hairline); padding: 4px 4px; position: sticky; top: -12px; background: var(--surface-1); }
.details td { padding: 3px 4px; border-bottom: 1px solid var(--hairline); font-variant-numeric: tabular-nums; }
.details td.num, .details th.num { text-align: right; }
.details tr.link { cursor: pointer; }
.details tr.link:hover td { background: var(--surface-2); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }
.chip { display: inline-block; padding: 0 6px; border-radius: 4px; background: var(--surface-2); font-size: 11px; color: var(--text-secondary); }
.empty { color: var(--text-muted); }

@media (max-width: 1100px) {
  .layout { grid-template-columns: 220px minmax(0, 1fr); }
  .details { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--border); max-height: 40vh; }
}
@media (max-width: 720px) {
  .topbar { flex-direction: column; align-items: stretch; gap: 8px; }
  .brand span { display: none; }
  .layout { display: flex; flex-direction: column; overflow-y: auto; }
  .controls { border-right: 0; border-bottom: 1px solid var(--border); }
  .stage { height: 70vh; flex: none; }
  .details { max-height: none; }
  .viewbar { flex-wrap: wrap; }
}

[hidden] { display: none !important; }
