:root {
  --bg: #f6f1e8;
  --panel: rgba(255, 252, 246, 0.9);
  --ink: #1d2433;
  --muted: #606879;
  --accent: #da6d48;
  --accent-strong: #b85431;
  --max-fill: #cbe4f6;
  --min-fill: #ffa2a7;
  --leaf-fill: #c6a7e6;
  --visited: #708b51;
  --pruned: #867c89;
  --shadow: 0 22px 60px rgba(44, 34, 22, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Noto Sans SC", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(218, 109, 72, 0.16), transparent 24%),
    radial-gradient(circle at bottom right, rgba(125, 174, 212, 0.18), transparent 30%),
    linear-gradient(180deg, #fffdf9 0%, var(--bg) 100%);
}

button,
input {
  font: inherit;
}

code {
  padding: 0 0.28em;
  border-radius: 0.45em;
  background: rgba(29, 36, 51, 0.08);
}

.page-shell {
  max-width: 1460px;
  margin: 0 auto;
  padding: 28px 20px 36px;
}

.hero,
.panel {
  background: var(--panel);
  border: 1px solid rgba(34, 42, 57, 0.08);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.hero {
  display: grid;
  grid-template-columns: 1.35fr 0.95fr;
  gap: 18px;
  padding: 20px;
  margin-bottom: 20px;
}

.hero-copy {
  padding: 10px 10px 10px 8px;
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-strong);
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: "Space Grotesk", "Noto Sans SC", sans-serif;
}

h1 {
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 1.03;
  max-width: 11ch;
}

.hero-text,
.panel-heading p,
#step-description,
.log-item p {
  color: var(--muted);
}

.hero-text {
  margin: 16px 0 0;
  max-width: 60ch;
  line-height: 1.75;
}

.hero-card {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  align-content: center;
}

.metric,
.mini-card,
.log-item,
.explanation-panel {
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(34, 42, 57, 0.08);
  border-radius: 22px;
}

.metric {
  padding: 16px;
}

.metric span,
.mini-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric strong,
.mini-card strong {
  display: block;
  margin-top: 8px;
}

.metric strong {
  font-size: clamp(1.2rem, 2vw, 2rem);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) 420px;
  gap: 20px;
}

.side-column {
  display: grid;
  gap: 20px;
  align-content: start;
}

.panel {
  padding: 22px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 14px;
  margin-bottom: 18px;
}

.panel-heading p {
  margin: 6px 0 0;
  font-size: 14px;
}

.legend,
.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  display: inline-block;
}

.dot.current {
  background: var(--accent);
}

.dot.visited {
  background: var(--visited);
}

.dot.pruned {
  background: var(--pruned);
}

button {
  border: 0;
  border-radius: 999px;
  padding: 12px 16px;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease, opacity 160ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  box-shadow: 0 10px 24px rgba(184, 84, 49, 0.24);
}

.secondary-btn {
  background: linear-gradient(135deg, #6691b1, #446c89);
  color: #fff;
}

.ghost-btn {
  background: rgba(255, 255, 255, 0.84);
  color: var(--ink);
  border: 1px solid rgba(34, 42, 57, 0.1);
}

.control-group {
  margin-top: 18px;
}

.slider-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.mini-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 18px;
}

.mini-card {
  padding: 14px 16px;
}

.mini-card strong {
  font-size: 24px;
}

.tree-stage {
  overflow: auto;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(248, 242, 232, 0.92)),
    linear-gradient(90deg, rgba(218, 109, 72, 0.08), rgba(101, 144, 176, 0.06));
}

.tree-canvas {
  position: relative;
  width: 1000px;
  height: 740px;
  margin: 0 auto;
}

.tree-svg,
.tree-overlay {
  position: absolute;
  inset: 0;
  width: 1000px;
  height: 740px;
}

.tree-edge {
  stroke: rgba(20, 29, 42, 0.72);
  stroke-width: 4;
}

.tree-edge.visited {
  stroke: rgba(112, 139, 81, 0.84);
}

.tree-edge.active {
  stroke: rgba(218, 109, 72, 0.96);
}

.tree-edge.pruned {
  stroke: rgba(134, 124, 137, 0.82);
  stroke-dasharray: 12 10;
}

.edge-label {
  fill: #171b24;
  font-size: 24px;
  font-family: "Space Grotesk", "Noto Sans SC", sans-serif;
  font-weight: 700;
  text-anchor: middle;
}

.prune-cross {
  stroke: #cb3227;
  stroke-width: 6;
  stroke-linecap: round;
}

.tree-node {
  position: absolute;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  text-align: center;
  transition: transform 180ms ease, filter 180ms ease, opacity 180ms ease;
}

.tree-node.current {
  transform: translate(-50%, -50%) scale(1.05);
  filter: drop-shadow(0 0 18px rgba(218, 109, 72, 0.28));
}

.tree-node.visited {
  filter: drop-shadow(0 6px 14px rgba(112, 139, 81, 0.18));
}

.tree-node.pruned {
  opacity: 0.66;
}

.triangle-up,
.triangle-down {
  width: 128px;
  height: 112px;
  padding-bottom: 10px;
}

.triangle-up::before,
.triangle-down::before {
  content: "";
  position: absolute;
  inset: 0;
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
  border: 3px solid rgba(20, 29, 41, 0.66);
}

.triangle-up::before {
  background: var(--max-fill);
}

.triangle-down::before {
  background: var(--min-fill);
  transform: rotate(180deg);
}

.square {
  width: 92px;
  height: 74px;
  border: 3px solid rgba(20, 29, 41, 0.52);
  border-radius: 6px;
  background: var(--leaf-fill);
}

.node-role,
.node-bounds,
.node-name,
.node-value {
  position: relative;
  z-index: 1;
}

.node-role {
  margin-top: 10px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.node-value {
  font-size: 26px;
  font-weight: 700;
  font-family: "Space Grotesk", sans-serif;
}

.node-bounds {
  font-size: 13px;
  color: rgba(29, 36, 51, 0.78);
}

.node-name {
  margin-top: 4px;
  font-size: 18px;
  text-transform: lowercase;
  color: rgba(29, 36, 51, 0.84);
}

.node-cross {
  position: absolute;
  top: -18px;
  right: -10px;
  z-index: 2;
  font-size: 54px;
  line-height: 1;
  color: #cb3227;
  font-weight: 700;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(101, 144, 176, 0.12);
  color: #446c89;
  font-size: 12px;
}

.explanation-panel h3 {
  margin-top: 14px;
  margin-bottom: 10px;
  font-size: 28px;
}

#step-description {
  margin: 0;
  line-height: 1.75;
}

.log-list {
  display: grid;
  gap: 10px;
  max-height: 380px;
  overflow: auto;
}

.log-item {
  padding: 14px 16px;
}

.log-item.active {
  border-color: rgba(218, 109, 72, 0.38);
  background: rgba(218, 109, 72, 0.08);
}

.log-item strong {
  color: var(--accent-strong);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.log-item h4 {
  margin: 6px 0;
  font-size: 18px;
}

.log-item p {
  margin: 0;
  line-height: 1.6;
}

@media (max-width: 1200px) {
  .layout,
  .hero {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .page-shell {
    padding-inline: 14px;
  }

  .hero-card {
    grid-template-columns: 1fr;
  }

  .tree-canvas,
  .tree-svg,
  .tree-overlay {
    width: 1000px;
    height: 740px;
  }
}
