body.page-bst .eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.86rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.bst-rule {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  max-width: 760px;
  margin: 20px auto;
}

.bst-rule > span {
  display: flex;
  min-height: 78px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  text-align: center;
}

.bst-rule > span:first-child {
  border-color: color-mix(in srgb, #7560ad 42%, var(--line));
  background: color-mix(in srgb, #7560ad 7%, var(--panel));
}

.bst-rule > span:last-child {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
  background: color-mix(in srgb, var(--accent) 7%, var(--panel));
}

.bst-rule .bst-rule__root {
  width: 82px;
  height: 82px;
  min-height: 82px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: var(--accent-soft);
}

.bst-rule__root strong {
  font-size: 1.35rem;
}

.bst-rule small {
  color: var(--muted);
}

.bst-visualizer {
  overflow: hidden;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.bst-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 22px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.bst-value-control label,
.bst-presets > span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.bst-value-control {
  display: grid;
  grid-template-columns: 105px 1fr;
  gap: 6px;
}

.bst-value-control label {
  grid-column: 1 / -1;
}

.bst-value-control input {
  width: 105px;
  min-height: 41px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-variant-numeric: tabular-nums;
}

.bst-operation-buttons,
.bst-presets,
.bst-rotation-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.bst-visualizer button {
  min-height: 39px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-alt);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 650;
}

.bst-visualizer button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.bst-visualizer button:focus-visible,
.bst-visualizer input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.bst-visualizer button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.bst-selection-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-alt);
}

.bst-selection-bar p {
  display: flex;
  min-width: 150px;
  flex-direction: column;
  margin: 0 auto 0 0;
  line-height: 1.2;
}

.bst-selection-bar p span {
  color: var(--muted);
  font-size: 0.74rem;
}

.bst-selection-bar p strong {
  color: var(--accent);
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}

.bst-rotation-buttons button {
  border-color: color-mix(in srgb, var(--accent) 32%, var(--line));
  background: var(--accent-soft);
}

.bst-canvas-scroll {
  overflow: auto;
  height: 490px;
  background-color: var(--panel-alt);
  background-image: radial-gradient(circle, color-mix(in srgb, var(--line) 70%, transparent) 1px, transparent 1px);
  background-size: 18px 18px;
}

.bst-canvas-scroll svg {
  display: block;
  margin: 0 auto;
}

.bst-edge {
  stroke: color-mix(in srgb, var(--muted) 70%, var(--line));
  stroke-width: 2;
}

.bst-node {
  cursor: pointer;
  outline: none;
}

.bst-node circle {
  fill: var(--panel);
  stroke: var(--line);
  stroke-width: 2;
  transition: fill 140ms ease, stroke 140ms ease, stroke-width 140ms ease;
}

.bst-node text {
  fill: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px;
  font-weight: 700;
  pointer-events: none;
}

.bst-node:hover circle,
.bst-node:focus-visible circle {
  stroke: var(--accent);
  stroke-width: 3;
}

.bst-node.is-path circle {
  fill: color-mix(in srgb, #dba13f 28%, var(--panel));
  stroke: color-mix(in srgb, #bd7712 65%, var(--line));
}

.bst-node.is-changed circle {
  fill: color-mix(in srgb, #2c8a55 30%, var(--panel));
  stroke: color-mix(in srgb, #2c8a55 65%, var(--line));
}

.bst-node.is-selected circle {
  fill: var(--accent-soft);
  stroke: var(--accent);
  stroke-width: 4;
}

.bst-node.is-selected.is-changed circle {
  fill: color-mix(in srgb, #2c8a55 30%, var(--accent-soft));
}

.bst-empty-label {
  fill: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px;
}

.bst-status {
  display: flex;
  min-height: 70px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 13px 18px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.bst-status p {
  margin: 0;
  font-weight: 650;
}

.bst-status span {
  flex: 0 0 auto;
  color: color-mix(in srgb, #247848 85%, var(--text));
  font-size: 0.8rem;
  font-weight: 700;
}

:root[data-theme="dark"] .bst-status span {
  color: #91d3aa;
}

.bst-status span.is-invalid {
  color: #a63832;
}

.bst-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 0;
  border-bottom: 1px solid var(--line);
}

.bst-metrics div {
  padding: 9px 12px;
  border-right: 1px solid var(--line);
  text-align: center;
}

.bst-metrics div:last-child {
  border-right: 0;
}

.bst-metrics dt {
  color: var(--muted);
  font-size: 0.73rem;
}

.bst-metrics dd {
  margin: 1px 0 0;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.bst-traversals {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
}

.bst-traversals p {
  min-width: 0;
  margin: 0;
  padding: 10px 13px;
  background: var(--panel);
}

.bst-traversals strong {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
}

.bst-traversals span {
  display: block;
  overflow-x: auto;
  padding-bottom: 2px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.77rem;
  white-space: nowrap;
}

.bst-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 13px;
  padding: 9px 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.75rem;
}

.bst-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.bst-swatch {
  width: 13px;
  height: 13px;
  border: 2px solid var(--line);
  border-radius: 50%;
}

.bst-swatch--selected { border-color: var(--accent); background: var(--accent-soft); }
.bst-swatch--path { border-color: #bd7712; background: color-mix(in srgb, #dba13f 28%, var(--panel)); }
.bst-swatch--changed { border-color: #2c8a55; background: color-mix(in srgb, #2c8a55 30%, var(--panel)); }

.operation-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.operation-grid article {
  position: relative;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.operation-grid article > span {
  display: inline-flex;
  width: 23px;
  height: 23px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
}

.operation-grid h4 {
  margin: 10px 0 7px;
}

.operation-grid p {
  margin: 0;
  color: var(--muted);
}

.rotation-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-top: 18px;
}

.rotation-grid article {
  padding: 17px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.rotation-grid h4 {
  margin: 0 0 10px;
}

.rotation-grid p {
  margin: 10px 0 0;
  color: var(--muted);
}

.rotation-diagram {
  overflow-x: auto;
  padding: 14px;
  border-radius: 7px;
  background: var(--code);
}

.rotation-diagram pre {
  width: max-content;
  margin: 0 auto;
  color: var(--text);
  font: 0.94rem/1.35 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.bst-complexity-table {
  min-width: 700px !important;
}

.shape-comparison {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-top: 14px;
}

.shape-comparison article {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.shape-comparison h4,
.shape-comparison p {
  margin: 0;
}

.shape-comparison strong {
  display: block;
  margin: 4px 0;
  color: var(--accent);
}

.shape-comparison p {
  color: var(--muted);
}

@media (max-width: 820px) {
  .bst-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .bst-selection-bar {
    flex-wrap: wrap;
  }

  .bst-selection-bar p {
    width: 100%;
  }

  .bst-canvas-scroll {
    height: 420px;
  }

  .bst-traversals,
  .operation-grid {
    grid-template-columns: 1fr;
  }

  .rotation-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .bst-rule {
    grid-template-columns: 1fr;
  }

  .bst-rule .bst-rule__root {
    grid-row: 1;
    justify-self: center;
  }

  .bst-toolbar,
  .bst-selection-bar,
  .bst-status {
    padding-right: 12px;
    padding-left: 12px;
  }

  .bst-value-control {
    grid-template-columns: 1fr;
  }

  .bst-value-control input,
  .bst-value-control label {
    grid-column: 1;
    width: 100%;
  }

  .bst-operation-buttons button,
  .bst-presets button,
  .bst-rotation-buttons button {
    flex: 1;
  }

  .bst-canvas-scroll {
    height: 360px;
  }

  .bst-status {
    min-height: 95px;
    flex-direction: column;
    gap: 5px;
  }

  .bst-metrics {
    grid-template-columns: repeat(2, 1fr);
  }

  .bst-metrics div:nth-child(2) {
    border-right: 0;
  }

  .bst-metrics div:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

  .shape-comparison {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bst-node circle {
    transition: none;
  }
}

@media print {
  .bst-toolbar,
  .bst-selection-bar {
    display: none;
  }

  .bst-canvas-scroll {
    height: 380px;
  }
}
