:root {
  --bg: #fbfaf7;
  --ink: #17171a;
  --soft: rgba(23, 23, 26, 0.58);
  --line: rgba(23, 23, 26, 0.14);
  --accent: #1f9d6b;
  --hot: #d8402f;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Mona Sans Variable", "Mona Sans", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.stage {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  padding: 10px 14px;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; outline: none; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
ul { list-style: none; }
.live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.qp { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); width: min(332px, 100%); }
.qp__sql { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 11px; line-height: 16px; color: var(--soft); padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.qp__sql b { font-weight: 600; color: var(--ink); }
.qp__clip { display: block; height: 16px; line-height: 16px; overflow: hidden; white-space: nowrap; }
.qp__clip span { display: block; overflow: hidden; text-overflow: ellipsis; }

.qp__top { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; padding: 14px 0 12px; }
.qp__label { font-size: 12px; line-height: 16px; font-weight: 640; color: var(--soft); padding-bottom: 5px; }
.qp__total { display: flex; align-items: baseline; gap: 5px; height: 44px; white-space: nowrap; }
.qp__total b { display: block; font-size: 46px; line-height: 44px; font-weight: 660; font-stretch: 86%; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; color: var(--hot); transition: color 0.5s ease; }
.qp__total i { font-style: normal; font-size: 15px; font-weight: 690; color: var(--soft); }
.qp.is-fast .qp__total b { color: var(--accent); }

/* the tree: each step a row pushed in by its depth, with the elbow that ties it to the step above */
/* the tree keeps the height of its three steps, so the switch never moves under the finger when a step folds */
.qp__tree { display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; height: 150px; }
.qp__node { position: relative; height: 50px; overflow: hidden; outline: none; }
.qp__in { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 10px; align-content: start; height: 50px; padding-top: 4px; }
.qp__node[data-node="sort"] .qp__in { margin-left: 22px; }
.qp__node[data-node="scan"] .qp__in { margin-left: 44px; }
.qp__elbow { position: absolute; left: -18px; top: -6px; width: 14px; height: 24px; fill: none; stroke: rgba(23, 23, 26, 0.3); stroke-width: 1.500; stroke-linecap: round; overflow: visible; }
.qp__elbow path { stroke-dasharray: 1; stroke-dashoffset: 0; }
.qp__name { font-size: 14px; line-height: 16px; font-weight: 720; letter-spacing: -0.005em; white-space: nowrap; min-width: 0; }
.qp__ms { font-size: 12.500px; line-height: 16px; font-weight: 680; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ink); transition: color 0.3s ease; }
.qp__rows { grid-column: 1 / -1; font-size: 11.500px; line-height: 16px; font-weight: 580; color: var(--soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.qp__bar { grid-column: 1 / -1; position: relative; height: 4px; margin-top: 4px; border-radius: 2px; background: rgba(23, 23, 26, 0.08); overflow: hidden; }
.qp__bar i { position: absolute; inset: 0; border-radius: 2px; background: rgba(23, 23, 26, 0.5); transform-origin: 0 50%; transition: background-color 0.4s ease; }
.qp__node.is-hot .qp__bar i { background: var(--hot); }
.qp__node.is-hot .qp__ms { color: var(--hot); }
.qp.is-fast .qp__node[data-node="scan"] .qp__bar i { background: var(--accent); }
.qp.is-fast .qp__node[data-node="scan"] .qp__ms { color: var(--accent); }
.qp__node .qp__name, .qp__node .qp__rows { transition: opacity 0.25s ease; }
.qp.is-peek .qp__node:not(.is-peek) .qp__name, .qp.is-peek .qp__node:not(.is-peek) .qp__rows, .qp.is-peek .qp__node:not(.is-peek) .qp__ms { opacity: 0.4; }
.qp__node:focus-visible .qp__name { text-decoration: underline; text-underline-offset: 3px; }

.qp__switch { display: flex; align-items: center; gap: 10px; height: 44px; margin-top: 8px; padding: 0 2px; border-top: 1px solid var(--line); text-align: left; }
.qp__track { position: relative; flex: none; width: 38px; height: 22px; border-radius: 11px; background: rgba(23, 23, 26, 0.16); transition: background-color 0.3s ease; }
.qp__track i { position: absolute; left: 2px; top: 2px; width: 18px; height: 18px; border-radius: 50%; background: #ffffff; box-shadow: 0 1px 3px rgba(23, 23, 26, 0.3); }
.qp.is-fast .qp__track { background: var(--accent); }
.qp__what { font-size: 13px; font-weight: 680; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.qp__what code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 11.500px; font-weight: 500; color: var(--soft); }
.qp__switch:focus-visible .qp__track { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--ink); }
.qp__hint { font-size: 12px; font-weight: 620; color: var(--soft); padding: 0 2px; }

.ghost { position: absolute; left: 0; top: 0; width: 24px; height: 24px; margin: -3px 0 0 -5px; transform-origin: 20% 15%; pointer-events: none; opacity: 0; fill: #17171a; stroke: #ffffff; stroke-width: 1.300; stroke-linejoin: round; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3)); z-index: 6; }

@media (max-width: 350px) { .qp__sql { font-size: 10px; } .qp__total b { font-size: 40px; } .qp__node[data-node="sort"] .qp__in { margin-left: 20px; } .qp__node[data-node="scan"] .qp__in { margin-left: 40px; } .qp__what code { font-size: 10.500px; } }
@media (max-height: 400px) { .qp__top { padding: 9px 0 8px; } .qp__sql { padding-bottom: 8px; } .qp__switch { margin-top: 4px; } }
@media (prefers-reduced-motion: reduce) { .qp__total b, .qp__ms, .qp__bar i, .qp__track, .qp__node .qp__name, .qp__node .qp__rows { transition: none; } }
