:root {
  color-scheme: light;
  font-family:
    system-ui,
    -apple-system,
    sans-serif;
  color: #19324e;
  background: #f3f6fa;
  font-size: 16px;
  line-height: 1.65;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
main {
  max-width: 1000px;
  margin: auto;
  padding: 20px 28px 48px;
}
a {
  color: #285690;
  text-underline-offset: 4px;
}
.return-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
  font-size: 14px;
  margin-bottom: 30px;
}
.return-nav a {
  padding: 6px 0;
}
header {
  margin-bottom: 24px;
}
.eyebrow {
  font-size: 12px;
  letter-spacing: 0.14em;
  color: #507198;
  font-weight: 700;
}
h1 {
  font-size: clamp(23px, 4vw, 34px);
  line-height: 1.4;
  margin: 10px 0;
}
header > p:last-child {
  color: #52657a;
  margin: 0;
  word-break: keep-all;
}
h2 {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 8px;
}
#settings {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
}
#settings label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
}
select,
button {
  font: inherit;
  background: white;
  color: inherit;
  border: 1px solid #b7c7d9;
  border-radius: 8px;
  padding: 8px 12px;
  min-height: 42px;
}
select {
  min-width: 175px;
}
button {
  cursor: pointer;
  font-size: 14px;
}
button:hover:enabled {
  background: #e3ecf9;
}
button:disabled {
  opacity: 0.45;
  cursor: default;
}
:focus-visible {
  outline: 3px solid #b76610;
  outline-offset: 3px;
}
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
}
.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.timeline {
  flex: 1;
  min-width: 180px;
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 13px;
}
.timeline span {
  white-space: nowrap;
}
.timeline input {
  min-width: 0;
  flex: 1;
  accent-color: #285690;
  min-height: 32px;
}
.explanation {
  background: #e2ecfb;
  border-left: 4px solid #3c6cab;
  padding: 14px 18px;
  border-radius: 0 10px 10px 0;
  margin-bottom: 20px;
}
.explanation p {
  margin: 0;
  min-height: 3.3em;
}
#visual {
  padding: 24px;
  border-radius: 14px;
  background: white;
  border: 1px solid #d9e2ec;
}
.array-row + .array-row {
  margin-top: 22px;
}
.cells {
  display: grid;
  grid-template-columns: repeat(var(--columns), minmax(0, 1fr));
  gap: 7px;
}
.cell {
  background: #edf2f8;
  border: 2px solid transparent;
  border-radius: 8px;
  text-align: center;
  padding: 7px 2px;
}
.cell small {
  display: block;
  color: #63758a;
  font-size: 12px;
}
.cell strong {
  font-size: 21px;
  font-variant-numeric: tabular-nums;
}
.cell.active {
  border-color: #246450;
  background: #d9f0e4;
}
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-top: 24px;
}
.metrics > div {
  padding: 10px 12px;
  background: #f2f5f9;
  border-radius: 8px;
}
.metrics span {
  font-size: 12px;
  color: #617084;
  display: block;
}
.metrics strong {
  display: block;
  font-size: 19px;
  margin-top: 4px;
  word-break: keep-all;
}
.jobs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.jobs > div {
  border: 1px solid #cddaea;
  border-radius: 10px;
  padding: 12px;
}
.jobs strong {
  display: block;
  font-size: 21px;
  color: #285690;
}
.jobs span {
  font-size: 13px;
  color: #52657a;
}
.table-wrap {
  overflow-x: auto;
  margin-top: 24px;
}
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 14px;
}
caption {
  text-align: left;
  font-size: 13px;
  padding-bottom: 10px;
  color: #52657a;
}
th,
td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid #dde5ef;
  font-variant-numeric: tabular-nums;
}
thead {
  background: #edf3fb;
}
.dropped {
  color: #69778a;
  background: #f5f6f8;
}
.dropped th {
  text-decoration: line-through;
}
.empty {
  font-size: 14px;
  color: #52657a;
  margin: 20px 0 0;
}
.boards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
}
.board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
}
.tile {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 650;
  border-radius: 7px;
  border: 2px solid transparent;
}
.tile-empty {
  background: #eff3f8;
  color: #728298;
}
.tile-A {
  background: #dbe7fb;
  color: #2456a1;
}
.tile-B {
  background: #f9e4c1;
  color: #875006;
}
.tile-C {
  background: #d6eee1;
  color: #25634d;
}
.tile.trial {
  border-color: #bd6b28;
}
.scope {
  font-size: 13px;
  color: #647386;
  margin: 20px 0 0;
}
@media (max-width: 600px) {
  main {
    padding: 16px 16px 32px;
  }
  .return-nav {
    margin-bottom: 22px;
  }
  #visual {
    padding: 16px;
  }
  .cells {
    gap: 4px;
  }
  .cell strong {
    font-size: 19px;
  }
  .boards {
    grid-template-columns: 1fr;
    gap: 22px;
  }
  .board {
    max-width: 320px;
  }
  .jobs > div {
    padding: 8px;
  }
  .jobs span {
    font-size: 12px;
  }
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .metrics strong {
    font-size: 17px;
  }
  .buttons {
    gap: 5px;
  }
  button {
    padding: 8px 10px;
  }
  th,
  td {
    padding: 8px 5px;
    font-size: 13px;
  }
  .explanation {
    padding: 12px 14px;
  }
  .timeline {
    flex-basis: 100%;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto;
  }
}
.heap-tree {
  display: block;
  width: 100%;
  margin: 18px 0;
  max-height: 300px;
  overflow: visible;
}
.heap-tree path {
  stroke: #9cb1ca;
  stroke-width: 2;
  fill: none;
}
.heap-tree circle {
  fill: #e2ecfc;
  stroke: #87a4cb;
  stroke-width: 2;
}
.heap-tree circle.focus {
  fill: #d7f0e2;
  stroke: #33795b;
}
.heap-tree text {
  font: 600 25px system-ui;
  fill: #213953;
}
.heap-tree text.node-index {
  font-size: 18px;
  font-weight: 400;
  fill: #56708e;
}
.heap-empty {
  text-align: center;
  padding: 38px;
  background: #f1f5fa;
  border-radius: 12px;
  margin: 20px 0;
  color: #61748e;
}
.fenwick-map {
  margin-top: 24px;
}
.range-row {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr) 42px;
  gap: 8px;
  align-items: center;
  padding: 6px 4px;
  border: 2px solid transparent;
  border-radius: 8px;
}
.range-row.focused {
  border-color: #33795b;
  background: #f0f8f3;
}
.range-row.visited {
  background: #edf6f0;
}
.range-row.visited .covered {
  background: #cde9d8;
  color: #225c42;
}
.range-row > span {
  font-size: 12px;
}
.range-row b {
  display: block;
  font-size: 17px;
}
.range-row > small {
  font-size: 12px;
  text-align: right;
}
.range-cells {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 3px;
}
.range-cells span {
  background: #f1f4f8;
  border-radius: 3px;
  text-align: center;
  font-size: 12px;
  padding: 5px 0;
  color: #65758a;
}
.range-cells .covered {
  background: #dae8fa;
  color: #284a78;
}
.range-cells .updated {
  box-shadow: inset 0 0 0 2px #b3701a;
}
@media (max-width: 600px) {
  .range-row {
    grid-template-columns: 54px minmax(0, 1fr) 36px;
    gap: 4px;
    padding: 5px 2px;
  }
  .range-cells {
    gap: 2px;
  }
  .range-cells span {
    font-size: 11px;
  }
  .range-row > span {
    font-size: 11px;
  }
  .range-row b {
    font-size: 15px;
  }
  .range-row > small {
    font-size: 11px;
  }
  body[data-demo='fenwick'] .cell strong,
  body[data-demo='compression'] .cell strong {
    font-size: 17px;
  }
}
