:root {
  --bg: #0f172a;
  --panel: #111827;
  --border: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #22c55e;
  --warn: #f59e0b;
  --focus: #38bdf8;
  --touch: #a78bfa;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

h1,
h2 {
  margin: 0 0 0.5rem;
}

.layout {
  display: grid;
  gap: 1rem;
  padding: 1rem;
  grid-template-columns: 320px minmax(0, 1fr) 320px;
}

.controls,
.viz,
.log {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
}

.control-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

input,
select,
button {
  background: #1f2937;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
}

button:hover,
button:focus-visible {
  border-color: var(--focus);
  outline: none;
}

#heap-svg {
  width: 100%;
  height: 640px;
  border: 1px dashed var(--border);
  border-radius: 6px;
  background: #0b1120;
}

.node circle {
  fill: #1e293b;
  stroke: #64748b;
  stroke-width: 2;
}

.node.min circle {
  stroke: var(--accent);
  stroke-width: 3;
}

.node.marked circle {
  stroke: var(--warn);
}

.node.touched circle {
  stroke: var(--touch);
}

.node text {
  font-size: 12px;
  text-anchor: middle;
  fill: var(--text);
  pointer-events: none;
}

.edge {
  fill: none;
  stroke: #475569;
  stroke-width: 2;
}

#operation-log {
  margin: 0;
  padding-left: 1.25rem;
  max-height: 640px;
  overflow: auto;
}

#operation-log li {
  margin-bottom: 0.3rem;
  color: var(--muted);
}

#status {
  min-height: 1.3rem;
  color: var(--focus);
}

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