/* Learning surfaces: stable state, readable code, and a real question hierarchy. */
::selection {
  background: #aaa5ff55;
  color: var(--ink);
}
* {
  scrollbar-color: var(--line) transparent;
  scrollbar-width: thin;
}
input,
textarea {
  caret-color: var(--accent);
}
button svg {
  display: block;
  flex-shrink: 0;
}
h1,
h2 {
  letter-spacing: -0.035em;
}
.study {
  grid-template-columns: 292px minmax(0, 1fr);
  max-width: 1600px;
}
.sidebar {
  padding: 0;
  border-right: 1px solid var(--line);
  background: var(--bg);
  position: relative;
}
.sidebar-inner {
  position: sticky;
  top: 86px;
  height: calc(100dvh - 86px);
  max-height: none;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 22px 12px 12px;
}
.sidebar-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px 16px;
  gap: 10px;
}
.sidebar-heading a {
  padding: 0;
  border: 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}
.sidebar-heading button {
  display: none;
}
.sidebar-search {
  display: block;
  margin: 0 8px 15px;
}
.sidebar-search input {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 11px;
  color: var(--ink);
  font-size: 12px;
}
.sidebar-scroll {
  overflow: auto;
  flex: 1;
  min-height: 0;
  overscroll-behavior: contain;
  padding-right: 4px;
  position: relative;
}
.sidebar-topic {
  margin-bottom: 3px;
}
.sidebar-topic > summary {
  list-style: none;
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 11px 8px;
  cursor: pointer;
  font-size: 12px;
  color: var(--ink);
  line-height: 1.4;
  border-radius: 6px;
}
.sidebar-topic > summary:hover {
  background: var(--panel);
}
.sidebar-topic > summary::-webkit-details-marker {
  display: none;
}
.sidebar-topic > summary > span:nth-child(2) {
  flex: 1;
}
.sidebar-topic-number {
  color: var(--muted);
  font: 10px var(--mono);
}
.sidebar-topic summary > small {
  font: 9px var(--mono);
  color: var(--muted);
}
.sidebar-topic summary svg {
  width: 12px;
  height: 12px;
  color: var(--muted);
  transition: transform 0.15s;
}
.sidebar-topic[open] summary svg {
  transform: rotate(90deg);
}
.sidebar-questions {
  margin: 0 4px 12px 17px;
  padding-left: 8px;
  border-left: 1px solid var(--line);
}
.sidebar a.sidebar-question,
.sidebar a.topic-overview {
  font-size: 11px;
  border: 0;
  line-height: 1.5;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 5px;
  min-width: 0;
  color: var(--muted);
}
.sidebar a.topic-overview {
  color: var(--accent);
  padding-left: 9px;
  font-size: 10px;
}
.sidebar a.sidebar-question > span {
  font: inherit;
  color: inherit;
  white-space: normal;
}
.sidebar-question i {
  width: 5px;
  height: 5px;
  border: 1px solid var(--muted);
  border-radius: 50%;
  flex-shrink: 0;
}
.sidebar-question i.understood {
  background: var(--green);
  border-color: var(--green);
}
.sidebar a.active {
  background: var(--panel2);
  color: var(--ink);
}
.sidebar a.active > span {
  color: var(--ink);
}
.sidebar a.sidebar-question:hover {
  background: var(--panel);
  color: var(--ink);
}
.sidebar a.sidebar-all {
  font-size: 11px;
  border: 0;
  border-top: 1px solid var(--line);
  margin-top: 12px;
  padding: 15px 12px 5px;
  color: var(--ink);
  display: flex;
  justify-content: space-between;
}
.sidebar-no-results {
  font-size: 12px;
  color: var(--muted);
  padding: 10px;
}
.sidebar-backdrop,
.curriculum-mobile-bar {
  display: none;
}
.lesson {
  padding: 36px min(4vw, 58px) 70px;
  max-width: 1200px;
  width: 100%;
}
.lesson > p,
.lesson > ol {
  max-width: 75ch;
}
.lesson h1 {
  font-size: clamp(37px, 3.5vw, 56px);
  line-height: 1.13;
  overflow-wrap: break-word;
}
.lesson li {
  margin-bottom: 10px;
  line-height: 1.8;
}
.lesson-jumps {
  display: flex;
  gap: 4px;
  margin: 26px 0 0;
  border-bottom: 1px solid var(--line);
}
.lesson-jumps button {
  border: 0;
  border-radius: 0;
  padding: 10px 18px;
  color: var(--muted);
  font-size: 12px;
}
.lesson-jumps button:hover {
  background: var(--panel);
  color: var(--accent);
}
#question-animation,
#question-code,
#question-notes {
  scroll-margin-top: 110px;
}
.lesson-jumps + h2 {
  margin-top: 28px;
}
.problem-player {
  margin: 24px 0 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--panel);
  outline-offset: 4px;
  contain: layout style;
}
.player-heading {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: center;
}
.player-heading > div {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.player-heading b {
  font-size: 13px;
  line-height: 1.4;
}
.player-dot {
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  flex-shrink: 0;
}
.player-badge {
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
}
.trace-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 210px;
  min-height: 320px;
}
.trace-stage {
  padding: 24px 22px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 20px;
}
.trace-inspector {
  border-left: 1px solid var(--line);
  padding: 24px 18px;
  background: var(--bg);
  min-width: 0;
}
.inspector-label {
  font-size: 10px;
  color: var(--accent);
}
.trace-inspector h3 {
  font-size: 14px !important;
  line-height: 1.5;
  margin: 10px 0;
}
.trace-inspector .trace-message {
  font-size: 12px;
  line-height: 1.8;
  margin-bottom: 16px;
  overflow-wrap: anywhere;
  color: var(--muted);
}
.trace-vars {
  margin: 0;
}
.trace-vars > div {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
  padding: 9px 0;
  gap: 3px;
}
.trace-vars dt {
  color: var(--muted);
  font: 10px var(--mono);
  overflow-wrap: anywhere;
}
.trace-vars dd {
  margin: 0;
  font: 12px/1.7 var(--mono);
  color: var(--ink);
  overflow-wrap: anywhere;
  max-height: 90px;
  overflow: auto;
}
.trace-panels {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.trace-panel {
  min-width: 0;
}
.trace-panel-label {
  font: 11px var(--mono);
  color: var(--muted);
  margin-bottom: 12px;
  overflow-wrap: anywhere;
}
.trace-array {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: end;
  min-height: 75px;
}
.trace-cell {
  width: 42px;
  min-width: 32px;
  flex-shrink: 0;
  text-align: center;
  position: relative;
  padding-top: 20px;
  line-height: 1;
  z-index: 1;
}
.cell-pointer {
  font: 8px/1.1 var(--mono);
  color: var(--accent);
  position: absolute;
  bottom: 61px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
}
.trace-cell b {
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 41px;
  padding: 5px 3px;
  font: 12px/1.3 var(--mono);
  color: var(--ink);
  background: var(--bg);
  overflow-wrap: anywhere;
  transition:
    background 0.22s,
    border-color 0.22s,
    color 0.22s;
  max-height: 80px;
  overflow: hidden;
}
.trace-cell small {
  display: block;
  font: 9px/1.3 var(--mono);
  color: var(--muted);
  margin-top: 7px;
}
.trace-cell.is-active b {
  background: #aaa5ff26;
  border-color: var(--accent);
  color: var(--accent);
}
.trace-cell.is-done b {
  background: #92d5af16;
  border-color: #92d5af77;
  color: var(--green);
}
.trace-cell.is-active.is-done b {
  border-color: var(--accent);
  color: var(--accent);
}
.trace-empty {
  font: 12px/1.8 var(--mono);
  color: var(--muted);
}
.trace-result {
  border-top: 1px solid var(--line);
  padding-top: 18px;
  display: flex;
  gap: 12px;
  flex-direction: column;
}
.trace-result[hidden] {
  display: none;
}
.trace-result > span {
  font: 10px var(--mono);
  color: var(--green);
}
.trace-result strong {
  font: 15px/1.7 var(--mono);
  color: var(--green);
  overflow-wrap: anywhere;
  max-height: 220px;
  overflow: auto;
}
.trace-matrix-scroll {
  overflow: auto;
  max-width: 100%;
  padding: 3px 0;
}
.trace-matrix {
  border-collapse: separate;
  border-spacing: 4px;
  font: 12px var(--mono);
  table-layout: fixed;
}
.trace-matrix td {
  background: var(--bg);
  border: 1px solid var(--line);
  text-align: center;
  padding: 9px 8px;
  min-width: 37px;
  border-radius: 4px;
  color: var(--ink);
  transition: background 0.2s;
}
.trace-matrix .is-active {
  background: #aaa5ff26;
  border-color: var(--accent);
  color: var(--accent);
}
.trace-matrix .is-done {
  background: #92d5af16;
  border-color: #92d5af77;
  color: var(--green);
}
.cell-updated {
  animation: cell-change 0.6s ease-out;
}
@keyframes cell-change {
  from {
    box-shadow: inset 0 0 0 2px var(--accent);
  }
  to {
    box-shadow: inset 0 0 0 0 transparent;
  }
}
.trace-graph svg {
  display: block;
  width: 100%;
  height: auto;
  min-height: 150px;
  overflow: visible;
}
.trace-node circle {
  fill: var(--panel2);
  stroke: var(--muted);
  stroke-width: 1.5;
  transition:
    fill 0.2s,
    stroke 0.2s;
}
.trace-node text {
  fill: var(--ink);
  font: 12px var(--mono);
}
.trace-node.active circle {
  fill: #aaa5ff33;
  stroke: var(--accent);
  stroke-width: 2;
}
.trace-node.active text {
  fill: var(--accent);
}
.trace-node.done circle {
  stroke: var(--green);
  fill: #92d5af22;
}
.trace-node.muted {
  opacity: 0.35;
}
.edge-label {
  font: 11px var(--mono);
  fill: var(--ink);
  paint-order: stroke;
  stroke: var(--panel);
  stroke-width: 5px;
}
.trace-controls {
  display: flex;
  gap: 13px;
  padding: 15px 20px;
  align-items: center;
  border-top: 1px solid var(--line);
  background: var(--panel2);
}
.transport {
  display: flex;
  gap: 5px;
  align-items: center;
}
.transport button {
  border: 1px solid var(--line);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 7px;
  width: 34px;
  height: 34px;
  border-radius: 6px;
}
.transport .play {
  width: 84px;
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
  gap: 6px;
  font-size: 11px;
}
.transport .play svg {
  width: 14px;
  height: 14px;
}
.trace-controls input[type="range"] {
  min-width: 40px;
  width: 100%;
  flex: 1;
  accent-color: var(--accent);
  cursor: pointer;
}
.trace-counter {
  font: 10px var(--mono);
  color: var(--muted);
  white-space: nowrap;
  min-width: 48px;
  text-align: center;
}
.trace-controls select {
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 5px;
  font-size: 11px;
}
.trace-legend {
  display: flex;
  gap: 16px;
  padding: 12px 20px;
  align-items: center;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
}
.trace-legend span {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 9px;
  color: var(--muted);
}
.trace-legend i {
  width: 7px;
  height: 7px;
  background: var(--line);
  border-radius: 2px;
}
.trace-legend .active-key {
  background: var(--accent);
}
.trace-legend .done-key {
  background: var(--green);
}
.trace-legend small {
  margin-left: auto;
  font-size: 9px;
}
.trace-inputs {
  border-top: 1px solid var(--line);
}
.trace-inputs summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  font-size: 11px;
  cursor: pointer;
  list-style: none;
}
.trace-inputs summary span {
  font: 9px var(--mono);
  color: var(--muted);
}
.trace-inputs > p,
.trace-inputs > div {
  margin: 0 20px 14px;
  font-size: 11px;
  color: var(--muted);
}
.trace-inputs textarea {
  display: block;
  margin: 0 20px 14px;
  width: calc(100% - 40px);
  min-height: 150px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
  padding: 12px;
  font: 12px/1.7 var(--mono);
  resize: vertical;
  tab-size: 2;
}
.trace-inputs > div {
  display: flex;
  gap: 8px;
}
.trace-inputs button {
  font-size: 11px;
  padding: 7px 12px;
}
.trace-inputs .apply-input {
  border-color: var(--accent);
  color: var(--accent);
}
.trace-inputs .trace-error {
  color: var(--red);
}
.trace-error:empty {
  display: none;
}
.codebox {
  border-radius: 10px;
  background: var(--panel);
  margin: 24px 0;
}
.codebar {
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  flex-wrap: wrap;
}
.code-tools {
  display: flex;
  gap: 4px;
}
.code-tools button {
  padding: 5px 9px;
  font-size: 11px;
  border: 1px solid transparent;
}
.code-tools button[aria-pressed="true"] {
  background: var(--panel2);
  color: var(--accent);
}
.language-tabs button {
  padding: 6px 12px;
  border-radius: 5px;
}
.code-filebar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 20px;
  background: var(--bg);
  font: 11px var(--mono);
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.code-filebar small {
  font: 10px var(--mono);
}
.code-scroll {
  display: flex;
  overflow: auto;
  max-height: 650px;
  line-height: 1.85;
  background: var(--bg);
  tab-size: 4;
  scrollbar-gutter: stable;
}
.code-gutter {
  display: flex;
  flex-direction: column;
  align-items: end;
  flex-shrink: 0;
  min-width: 52px;
  padding: 20px 12px 20px 16px;
  border-right: 1px solid var(--line);
  font: 12px/1.85 var(--mono);
  color: var(--muted);
  user-select: none;
}
.code-gutter span {
  display: block;
}
.code-scroll pre {
  padding: 20px;
  max-height: none;
  overflow: visible;
  flex: 1;
  font: 12px/1.85 var(--mono);
  color: var(--ink);
  min-width: max-content;
  white-space: pre;
  tab-size: 4;
}
.code-scroll code {
  font: inherit;
  color: inherit;
  white-space: inherit;
}
.code-environment {
  font-size: 10px;
  color: var(--muted);
  padding: 11px 20px;
  border-top: 1px solid var(--line);
}
.wrap-code .code-scroll pre {
  min-width: 0;
  width: 100%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.wrap-code .code-gutter {
  display: none;
}
.hljs-comment,
.hljs-quote {
  color: #91a299;
  font-style: italic;
}
.hljs-keyword,
.hljs-selector-tag,
.hljs-literal {
  color: var(--accent);
}
.hljs-string,
.hljs-regexp,
.hljs-addition {
  color: var(--green);
}
.hljs-number,
.hljs-symbol,
.hljs-bullet {
  color: #e4bd7a;
}
.hljs-title,
.hljs-function .hljs-title {
  color: #9fcbeb;
}
.hljs-type,
.hljs-built_in,
.hljs-class .hljs-title {
  color: #e8d6a4;
}
.hljs-meta {
  color: var(--muted);
}
.hljs-params,
.hljs-variable,
.hljs-property {
  color: var(--ink);
}
body.light .hljs-title {
  color: #21638c;
}
body.light .hljs-number {
  color: #946114;
}
body.light .hljs-comment {
  color: #5b7163;
}
body.light .hljs-type,
body.light .hljs-built_in {
  color: #906b2c;
}
@media (min-width: 1600px) {
  .trace-layout {
    grid-template-columns: minmax(0, 1fr) 240px;
  }
  .trace-cell {
    width: 46px;
  }
  .trace-cell b {
    font-size: 13px;
  }
}
@media (max-width: 1150px) {
  .study {
    grid-template-columns: 250px minmax(0, 1fr);
  }
  .lesson {
    padding-left: 26px;
    padding-right: 26px;
  }
  .trace-layout {
    display: block;
  }
  .trace-inspector {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 18px 20px;
  }
  .trace-inspector .trace-message {
    margin-bottom: 12px;
  }
  .trace-vars {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 22px;
  }
  .trace-vars > div {
    border: 0;
    padding: 0;
    min-width: 55px;
    max-width: 200px;
  }
  .trace-stage {
    min-height: 240px;
  }
  .trace-controls {
    gap: 8px;
    padding: 12px;
  }
  .trace-legend {
    padding: 12px;
    gap: 12px;
  }
  .trace-legend small {
    display: none;
  }
}
@media (max-width: 800px) {
  .study {
    display: block;
  }
  .curriculum-mobile-bar {
    position: sticky;
    top: 70px;
    z-index: 9;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--line);
    background: var(--bg);
    padding: 10px 5vw;
    gap: 15px;
  }
  .curriculum-mobile-bar button {
    display: flex;
    gap: 8px;
    align-items: center;
    border: 0;
    padding: 3px 0;
    font-size: 12px;
    white-space: nowrap;
  }
  .curriculum-mobile-bar > span {
    font-size: 10px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .sidebar {
    display: none;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(330px, 87vw);
    z-index: 40;
    border-right: 1px solid var(--line);
    padding: 0;
    background: var(--bg);
  }
  .sidebar.drawer-open {
    display: block;
  }
  .sidebar-inner {
    display: flex;
    top: 0;
    position: static;
    height: 100dvh;
    padding: 20px 12px 12px;
    max-height: none;
  }
  .sidebar-heading button {
    display: block;
    border: 0;
    padding: 3px;
  }
  .sidebar-backdrop:not([hidden]) {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 39;
    background: #0009;
    border: 0;
    border-radius: 0;
  }
  .curriculum-is-open {
    overflow: hidden;
  }
  .sidebar a {
    min-width: 0;
  }
  .sidebar-questions a {
    display: flex;
  }
  .sidebar a.sidebar-question,
  .sidebar a.topic-overview {
    font-size: 12px;
  }
  .sidebar-topic > summary {
    padding: 13px 8px;
    font-size: 13px;
  }
  .sidebar-scroll {
    padding-bottom: 15px;
  }
  .lesson {
    padding: 28px 5vw 50px;
  }
  .lesson h1 {
    font-size: 40px;
    line-height: 1.14;
  }
  .lesson h2 {
    font-size: 28px;
  }
  .player-heading {
    padding: 14px;
  }
  .player-badge {
    display: none;
  }
  .trace-stage {
    padding: 20px 14px;
  }
  .trace-cell {
    width: 39px;
  }
  .trace-cell b {
    font-size: 12px;
  }
  .trace-array {
    gap: 5px;
  }
  .trace-graph svg {
    min-height: 180px;
  }
  .trace-graph {
    overflow-x: auto;
  }
  .trace-graph svg {
    min-width: 350px;
  }
  .code-scroll pre {
    padding: 16px 12px;
    font-size: 12px;
  }
  .code-gutter {
    padding: 16px 9px;
    font-size: 12px;
    min-width: 38px;
  }
  .codebar {
    padding: 9px 8px;
  }
  .language-tabs {
    gap: 2px;
  }
  .language-tabs button {
    padding: 6px 8px;
    font-size: 11px;
  }
  .code-tools button {
    font-size: 10px;
    padding: 5px 7px;
  }
  .code-environment {
    padding: 12px;
    font-size: 10px;
  }
  .trace-controls {
    flex-wrap: wrap;
    gap: 10px;
  }
  .trace-controls input[type="range"] {
    order: 3;
    flex-basis: 100%;
    margin: 4px 0;
  }
  .trace-controls select {
    margin-left: auto;
  }
  .trace-counter {
    margin-left: auto;
  }
  .trace-inspector {
    padding: 16px;
  }
  .trace-inputs textarea {
    min-height: 170px;
  }
  .lesson-jumps button {
    padding: 10px 13px;
  }
  #question-animation,
  #question-code,
  #question-notes {
    scroll-margin-top: 135px;
  }
}
@media (min-width: 701px) and (max-width: 800px) {
  .curriculum-mobile-bar {
    top: 86px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .trace-node {
    transition: none !important;
  }
  .cell-updated {
    animation: none;
  }
  .trace-cell b {
    transition:
      background 0.1s,
      color 0.1s;
  }
  .sidebar-topic summary svg {
    transition: none;
  }
}
[hidden] {
  display: none !important;
}

.elevation-svg {
  display: block;
  width: 100%;
  height: auto;
  min-height: 150px;
}
.elevation-ground {
  fill: var(--green);
  opacity: 0.85;
}
.elevation-water {
  fill: #8caaff;
  opacity: 0.7;
}
.elevation-value {
  fill: var(--ink);
  font: 12px var(--mono);
}
.elevation-index {
  fill: var(--muted);
  font: 10px var(--mono);
}

.is-compact.problem-player {
  border: 0;
  border-radius: 0;
  margin: 0;
  background: transparent;
}
.is-compact .player-heading,
.is-compact .trace-inspector,
.is-compact .trace-legend,
.is-compact .trace-inputs,
.is-compact .trace-result {
  display: none;
}
.is-compact .trace-layout {
  display: block;
  min-height: 290px;
}
.is-compact .trace-stage {
  min-height: 290px;
  padding: 15px 25px;
  justify-content: center;
}
.is-compact .trace-panel {
  display: none;
}
.is-compact .trace-panel.hero-visible {
  display: block;
}
.is-compact .trace-panel-label {
  display: none;
}
.is-compact .trace-controls {
  background: transparent;
  padding: 12px 18px;
}
.is-compact .trace-controls input[type="range"] {
  display: none;
}
.is-compact .trace-controls select {
  margin-left: auto;
}
.is-compact .trace-array {
  justify-content: center;
}
.is-compact .trace-graph svg {
  min-height: 230px;
}
.is-compact .elevation-svg {
  min-height: 235px;
}
.hero-model .model-description {
  min-height: 110px;
}
.trace-cell b {
  font-variant-numeric: tabular-nums;
}

.trace-graph svg {
  min-width: 0;
}
.sidebar a.sidebar-question {
  font-size: 12px;
}
.code-scroll pre,
.code-gutter {
  font-size: 13px;
  line-height: 1.85;
}
.trace-inspector .trace-message {
  font-size: 13px;
}
.trace-panel-label {
  font-size: 12px;
}
.trace-cell b {
  font-size: 13px;
}
.cell-pointer {
  font-size: 9px;
}
.trace-node text {
  font-size: 13px;
}
@media (max-width: 800px) {
  .code-scroll pre,
  .code-gutter {
    font-size: 12px;
  }
  .trace-inspector .trace-message {
    font-size: 12px;
  }
}

.problem-player:not(.is-compact){display:flex;flex-direction:column}.problem-player:not(.is-compact)>.player-heading{order:0}.problem-player:not(.is-compact)>.trace-controls{order:1;border-top:0;border-bottom:1px solid var(--line)}.problem-player:not(.is-compact)>.trace-layout{order:2}.problem-player:not(.is-compact)>.trace-legend{order:3}.problem-player:not(.is-compact)>.trace-inputs{order:4}

/* Multi-Approach Navigation, Pros & Cons, and Solution Architecture */
.approaches-section {
  margin: 32px 0 24px;
}
.approaches-header {
  margin-bottom: 16px;
}
.approaches-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.approaches-title-group h2 {
  margin: 0;
  font-size: clamp(22px, 2.5vw, 28px);
}
.approaches-badge {
  font-size: 11px;
  font-family: var(--mono);
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--panel2);
  border: 1px solid var(--line);
  color: var(--muted);
  letter-spacing: 0.02em;
}
.approaches-intro {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.approach-tabs {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin: 18px 0 16px;
  scrollbar-width: thin;
}
.approach-tab {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
  user-select: none;
}
.approach-tab:hover {
  background: var(--panel2);
  border-color: var(--accent);
}
.approach-tab.active {
  background: var(--panel2);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.approach-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.approach-tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 4px;
}
.approach-tag.brute {
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
}
.approach-tag.better {
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.35);
}
.approach-tag.optimal {
  color: var(--green);
  background: rgba(146, 213, 175, 0.12);
  border: 1px solid rgba(146, 213, 175, 0.35);
}
.approach-tab-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.approach-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 24px;
  margin-bottom: 24px;
}
.approach-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}
.approach-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.approach-type-pill {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 9px;
  border-radius: 5px;
}
.approach-type-pill.brute {
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.4);
}
.approach-type-pill.better {
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.4);
}
.approach-type-pill.optimal {
  color: var(--green);
  background: rgba(146, 213, 175, 0.14);
  border: 1px solid rgba(146, 213, 175, 0.4);
}
.approach-headline {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
}

.complexities-pill-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.complexity-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  color: var(--ink);
}
.complexity-badge .badge-label {
  color: var(--muted);
  font-size: 11px;
}
.complexity-badge b {
  font-family: var(--mono);
  color: var(--accent);
  font-size: 12px;
}

.approach-section-block {
  margin-bottom: 22px;
}
.approach-section-block h4.subhead {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 8px;
}
.approach-idea-text {
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink);
  margin: 0;
  max-width: 80ch;
}
.approach-step-list {
  padding-left: 22px;
  margin: 0;
  line-height: 1.7;
  color: var(--ink);
  font-size: 14px;
}
.approach-step-list li {
  margin-bottom: 7px;
}

.pros-cons-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 24px;
}
@media (max-width: 720px) {
  .pros-cons-grid {
    grid-template-columns: 1fr;
  }
}
.pro-con-box {
  border-radius: 8px;
  padding: 16px 18px;
}
.pros-box {
  background: rgba(146, 213, 175, 0.06);
  border: 1px solid rgba(146, 213, 175, 0.22);
}
.cons-box {
  background: rgba(233, 147, 147, 0.06);
  border: 1px solid rgba(233, 147, 147, 0.22);
}
.pro-con-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
}
.pros-box .pro-con-head {
  color: var(--green);
}
.cons-box .pro-con-head {
  color: var(--red);
}
.pro-con-icon {
  font-size: 14px;
  line-height: 1;
}
.pro-con-box ul {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink);
}
.pro-con-box li {
  margin-bottom: 5px;
}

.code-approach-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 11px 16px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 20px 0 12px;
  font-size: 13px;
}
.code-approach-banner .banner-label {
  color: var(--muted);
  font-size: 12px;
}
.code-approach-banner b {
  color: var(--ink);
}
.code-approach-quick-nav {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}
.code-quick-tab {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s ease;
}
.code-quick-tab:hover {
  color: var(--ink);
  border-color: var(--accent);
}
.code-quick-tab.active {
  background: var(--accent);
  color: #0c1210;
  border-color: var(--accent);
  font-weight: 700;
}

/* Approach slider + accordion + enriched animation */
.approach-sliderwrap{display:flex;align-items:stretch;gap:8px;margin:14px 0 10px}
.slider-btn{flex:0 0 auto;width:36px;border:1px solid var(--line);background:var(--panel);border-radius:8px;font-size:22px;line-height:1;color:var(--ink);cursor:pointer}
.slider-btn:hover{border-color:var(--accent);color:var(--accent)}
.approach-slider{display:flex;gap:14px;overflow-x:auto;scroll-snap-type:x mandatory;padding:4px 2px 10px;flex:1;scrollbar-width:thin}
.approach-slide{scroll-snap-align:center;flex:0 0 min(92%,720px);background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:20px;opacity:.72;transition:opacity .18s,border-color .18s,box-shadow .18s}
.approach-slide.is-active{opacity:1;border-color:var(--accent);box-shadow:0 0 0 1px var(--accent)}
.slider-dots{display:flex;gap:8px;flex-wrap:wrap;margin:8px 0 16px}
.slider-dot{border:1px solid transparent;background:transparent;padding:4px 6px;border-radius:999px;cursor:pointer}
.slider-dot.active{border-color:var(--accent);background:var(--panel2)}
.approach-accordion{margin-top:14px;border-top:1px solid var(--line)}
.approach-accordion .acc{border-bottom:1px solid var(--line)}
.approach-accordion .acc>summary{padding:12px 4px;font-size:13px;font-weight:700;cursor:pointer;list-style:none;display:flex;justify-content:space-between;align-items:center;gap:10px}
.approach-accordion .acc>summary::-webkit-details-marker{display:none}
.approach-accordion .acc>summary::after{content:"▾";color:var(--muted)}
.approach-accordion .acc[open]>summary::after{content:"▴"}
.acc-count{font:10px var(--mono);color:var(--muted);border:1px solid var(--line);padding:2px 8px;border-radius:999px}
.acc-note{font-size:13px;line-height:1.65;color:var(--ink);margin:10px 0 4px}
.slide-watch{margin-top:14px;width:100%;padding:10px 12px;border-radius:8px;border:1px solid var(--accent);background:var(--panel2);color:var(--accent);font-weight:700;cursor:pointer;font-size:13px}
.slide-watch:hover{background:var(--accent);color:#0c1210}
.anim-approach-banner{display:flex;flex-wrap:wrap;gap:10px;align-items:center;border:1px solid var(--line);background:var(--panel2);border-radius:8px;padding:10px 14px;margin:12px 0 4px;font-size:13px}
.anim-approach-banner span{color:var(--muted);font-size:12px}
.anim-complexity{margin-left:auto;font-family:var(--mono);font-size:12px;color:var(--accent)}
.player-approach{font:10px var(--mono);padding:3px 8px;border-radius:999px;border:1px solid var(--line);color:var(--muted)}
.player-approach[data-type="brute"]{color:#f59e0b;border-color:rgba(245,158,11,.5)}
.player-approach[data-type="better"]{color:#38bdf8;border-color:rgba(56,189,248,.5)}
.player-approach[data-type="optimal"]{color:var(--green);border-color:rgba(146,213,175,.5)}
.trace-deepdive{margin:6px 0 14px;border:1px solid var(--line);border-radius:8px;background:var(--panel2);padding:10px 12px;display:grid;gap:8px}
.trace-deepdive[hidden]{display:none}
.deep-row{display:grid;grid-template-columns:64px 1fr;gap:10px;align-items:start}
.deep-row>span{font:10px var(--mono);text-transform:uppercase;letter-spacing:.05em;color:var(--accent)}
.deep-row p{margin:0;font-size:12px;line-height:1.6;color:var(--ink)}
@media(max-width:800px){
  .approach-slide{flex-basis:92%;padding:16px}
  .slider-btn{display:none}
  .deep-row{grid-template-columns:1fr;gap:2px}
}
@media(prefers-reduced-motion:reduce){.approach-slide{transition:none}}



/* Approach selection is an accordion; each summary selects its own trace. */
.approach-options { display: grid; gap: 12px; }
.approach-option { min-width: 0; width: 100%; border: 1px solid var(--border, #ddd); border-radius: 12px; overflow: hidden; }
.approach-option-summary { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 16px; cursor: pointer; list-style: none; }
.approach-option-summary::-webkit-details-marker { display: none; }
.approach-option-summary::after { content: '+'; margin-left: auto; font-size: 1.4rem; }
.approach-option[open] > .approach-option-summary::after { content: '−'; }
.approach-option-cost { font-size: .85rem; opacity: .75; }
.approach-option-body { padding: 0 16px 18px; }
.trace-coach { border: 1px solid #ad739a; border-radius: 10px; padding: 14px; margin-bottom: 14px; background: rgba(190, 90, 150, .08); overflow-wrap: anywhere; }
.coach-step { display: block; font-size: .7rem; font-weight: 700; letter-spacing: .08em; opacity: .75; }
.coach-title { display: block; margin-top: 4px; }
.coach-message { margin: 6px 0; line-height: 1.5; }
.coach-flow { font-size: .85rem; font-weight: 600; }
@media (max-width: 600px) { .approach-option-summary strong { flex: 1 1 65%; } .approach-option-cost { flex-basis: 100%; } }
/* The approach list is a vertical accordion, never a horizontal carousel. */
.approach-options { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin: 14px 0 18px; }
.approach-option.approach-slide { display: block; flex: initial; width: 100%; max-width: none; scroll-snap-align: none; padding: 0; opacity: 1; }
.approach-option.approach-slide.is-active { border-color: var(--accent); }
.approach-option-summary { min-height: 58px; }
.approach-option-summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }
.approach-option[open] > .approach-option-summary { border-bottom: 1px solid var(--line); }
.approach-option-body { min-width: 0; }
.approach-select-label { display:block; font-size:.82rem; font-weight:700; margin:12px 0 6px; }
.approach-select { display:block; width:100%; min-height:48px; padding:10px 42px 10px 14px; border:1px solid var(--line); border-radius:10px; color:var(--text); background:var(--panel); font:inherit; cursor:pointer; }
.approach-select:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
/* Refined single approach selector and selected detail card. */
.approach-select {
  width: 100%; min-height: 46px; margin: 4px 0 16px; padding: 10px 42px 10px 14px;
  color: var(--ink); background-color: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; box-shadow: none; font: 13px var(--sans); appearance: auto;
}
.approach-select:hover { border-color: #526456; }
.approach-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-color: var(--accent); }
.approach-option.approach-slide {
  display: block; width: 100%; max-width: 900px; margin: 0 auto 22px; padding: 22px;
  flex: initial; scroll-snap-align: none; opacity: 1; color: var(--ink);
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0,0,0,.12); transition: none;
}
.approach-option.approach-slide.is-active { border-color: var(--line); box-shadow: 0 8px 28px rgba(0,0,0,.12); }
.approach-option .approach-detail-header { gap: 12px; padding-bottom: 14px; margin-bottom: 16px; }
.approach-option .approach-idea-text { max-width: 76ch; line-height: 1.75; }
.approach-option .approach-accordion { margin-top: 20px; border-top: 1px solid var(--line); }
.approach-option .approach-accordion .acc { border-bottom: 1px solid var(--line); }
.approach-option .approach-accordion .acc > summary { padding: 14px 2px; }
.approach-option .approach-step-list { padding: 4px 0 8px 24px; }
.approach-option .approach-step-list li { padding: 2px 0; }
.approach-option .insight { border: 0; border-left: 3px solid var(--accent); border-radius: 0 8px 8px 0; margin: 12px 0 4px; overflow-wrap: anywhere; }
.approach-option .slide-watch { border-color: var(--line); }
@media (max-width: 640px) {
  .approach-option.approach-slide { padding: 16px; margin-bottom: 16px; }
  .approach-option .approach-detail-header { align-items: flex-start; }
  .approach-option .complexities-pill-group { width: 100%; }
}
