:root {
  --bg: #f6f2e8;
  --panel: rgba(255, 251, 245, 0.94);
  --panel-border: #d6c7af;
  --shadow: 0 18px 42px rgba(54, 39, 18, 0.12);
  --text: #23180c;
  --muted: #6d5841;
  --accent: #0f766e;
  --accent-soft: rgba(15, 118, 110, 0.12);
  --young: #f59e0b;
  --survivor: #10b981;
  --old: #2563eb;
  --pool: #c026d3;
  --danger: #dc2626;
  --line: #7c5f3b;
  --mono: "IBM Plex Mono", monospace;
  --sans: "Space Grotesk", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 199, 39, 0.22), transparent 34%),
    radial-gradient(circle at bottom right, rgba(15, 118, 110, 0.18), transparent 28%),
    linear-gradient(180deg, #fdf9f2 0%, #f6f2e8 100%);
}

button,
input,
textarea,
select {
  font: inherit;
}

.app-shell {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: var(--accent);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.8rem, 3vw, 2.7rem);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  max-width: 640px;
}

button {
  border: 1px solid #1d4f4b;
  background: #154744;
  color: #fffaf3;
  border-radius: 999px;
  padding: 10px 16px;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, opacity 180ms ease;
  box-shadow: 0 10px 24px rgba(21, 71, 68, 0.2);
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(21, 71, 68, 0.28);
}

button:disabled {
  opacity: 0.45;
  cursor: wait;
}

button.secondary {
  background: #fff8ef;
  color: #143533;
  border-color: #d0b48d;
  box-shadow: none;
}

#pause-button,
#next-step-button,
#resume-button {
  min-width: 112px;
}

.workspace {
  position: relative;
  display: grid;
  grid-template-columns: minmax(720px, 1fr) minmax(260px, 300px) 320px;
  gap: 18px;
  min-height: 760px;
}

.workspace.dual-thread-layout {
  grid-template-columns: minmax(720px, 1fr) minmax(260px, 300px) minmax(260px, 300px) 320px;
}

.stack-panel[data-thread-panel="T2"] {
  display: none;
}

.workspace.dual-thread-layout .stack-panel[data-thread-panel="T2"] {
  display: flex;
}

.thread-stacks-wrap {
  display: contents;
}

.reference-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

.panel {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 26px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.telemetry-panel {
  margin-top: 18px;
}

.telemetry-shell {
  padding: 18px 20px 20px;
}

.telemetry-chart-wrap {
  border-radius: 24px;
  overflow: hidden;
  background:
    radial-gradient(circle at top left, rgba(34, 211, 238, 0.08), transparent 28%),
    linear-gradient(180deg, #08111f 0%, #0e1827 100%);
  border: 1px solid rgba(84, 124, 173, 0.3);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.memory-chart {
  display: block;
  width: 100%;
  height: 240px;
}

.memory-legend {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.memory-card {
  border-radius: 18px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(84, 124, 173, 0.16);
}

.memory-card-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.memory-card-value {
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 700;
}

.memory-swatch {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  flex: 0 0 auto;
}

.chart-grid-line {
  stroke: rgba(150, 178, 214, 0.12);
  stroke-width: 1;
}

.chart-axis-line {
  stroke: rgba(150, 178, 214, 0.2);
  stroke-width: 1.2;
}

.chart-label {
  fill: rgba(219, 232, 248, 0.72);
  font-size: 11px;
  font-family: var(--mono);
}

.chart-area-heap {
  fill: rgba(14, 165, 233, 0.18);
}

.chart-line-heap {
  fill: none;
  stroke: #38bdf8;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-line-old {
  fill: none;
  stroke: #f59e0b;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-line-stack {
  fill: none;
  stroke: #22c55e;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 7 6;
}

.chart-dot {
  stroke: #08111f;
  stroke-width: 2;
}

.panel-heading {
  padding: 20px 22px 14px;
  border-bottom: 1px solid rgba(214, 199, 175, 0.65);
}

.panel-heading p {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.45;
}

.stack-root {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-end;
  gap: 14px;
  padding: 18px;
  min-height: 140px;
  max-height: 360px;
  overflow: auto;
  scrollbar-width: thin;
}

.stack-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.stack-panel.is-thread-highlight {
  box-shadow:
    0 0 0 2px rgba(15, 118, 110, 0.35),
    var(--shadow);
}

.local-cache {
  margin: 0 18px 18px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(124, 95, 59, 0.18);
  background: rgba(255, 255, 255, 0.72);
  font-family: var(--mono);
  font-size: 0.82rem;
}

.local-cache-title {
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 8px;
}

.local-cache-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.local-cache-key {
  color: var(--muted);
}

.local-cache-val {
  font-weight: 700;
  color: var(--accent);
}

.visibility-banner {
  grid-column: 1 / -1;
  margin: 0 18px 12px;
  padding: 12px 16px;
  border-radius: 16px;
  background: rgba(15, 118, 110, 0.14);
  border: 1px solid rgba(15, 118, 110, 0.28);
  color: var(--text);
  font-weight: 600;
  font-size: 0.92rem;
}

.stack-frame {
  position: relative;
  border: 1px solid #cdb28a;
  border-radius: 18px;
  background: linear-gradient(180deg, #fffaf0 0%, #f5e7cf 100%);
  padding: 14px;
  transition: box-shadow 220ms ease, border-color 220ms ease, transform 220ms ease;
  cursor: pointer;
}

.stack-frame:hover,
.stack-frame.is-selected {
  border-color: var(--accent);
  box-shadow: 0 14px 28px rgba(15, 118, 110, 0.16);
  transform: translateY(-1px);
}

.stack-frame h3 {
  font-size: 1rem;
}

.frame-badge {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(35, 24, 12, 0.08);
  font-size: 0.75rem;
  font-family: var(--mono);
}

.locals-list {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.local-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid rgba(124, 95, 59, 0.12);
}

.local-name {
  font-family: var(--mono);
}

.local-target {
  font-size: 0.84rem;
  color: var(--muted);
  font-family: var(--mono);
}

.heap-panel {
  padding-bottom: 14px;
}

.education-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  padding: 18px 18px 0;
}

.education-card {
  min-width: 0;
  border: 1px solid #d9c8af;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.82) 0%, rgba(244, 235, 221, 0.92) 100%);
  padding: 14px 16px;
}

.education-card h3 {
  margin-bottom: 10px;
  font-size: 0.95rem;
}

.execution-steps-card {
  border-color: rgba(15, 118, 110, 0.24);
  background:
    linear-gradient(180deg, rgba(240, 255, 252, 0.95) 0%, rgba(225, 245, 239, 0.92) 100%);
}

.execution-steps-subtitle {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.86rem;
}

#code-panel {
  max-height: 164px;
  overflow: auto;
  border-radius: 16px;
  background: rgba(35, 24, 12, 0.94);
  color: #fdf8ef;
  padding: 10px 0;
  font-family: var(--mono);
  scrollbar-width: thin;
}

.code-line {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 12px;
  align-items: center;
  padding: 8px 14px;
  transition: background-color 220ms ease, color 220ms ease;
}

.code-line-number {
  color: rgba(253, 248, 239, 0.56);
  text-align: right;
  user-select: none;
}

.code-line-text {
  white-space: pre;
}

.code-line.active-line {
  background: rgba(15, 118, 110, 0.38);
}

.code-line.active-line .code-line-number,
.code-line.active-line .code-line-text {
  color: #ffffff;
}

.code-volatile-keyword {
  color: #fbbf24;
  font-weight: 700;
}

#step-description,
#side-step-description {
  min-height: 164px;
  max-height: 280px;
  border-radius: 16px;
  background: rgba(15, 118, 110, 0.14);
  border: 1px solid rgba(15, 118, 110, 0.28);
  padding: 10px;
  color: #153a36;
}

.execution-steps-scroll {
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}

.execution-steps-feed {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 6px;
}

.execution-step-entry {
  position: relative;
  margin: 0;
  padding: 11px 12px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 253, 0.55);
  border: 1px solid rgba(15, 118, 110, 0.12);
  font-weight: 500;
  line-height: 1.62;
  color: #28423e;
  transition:
    opacity 260ms ease,
    border-color 260ms ease,
    box-shadow 260ms ease;
}

.execution-step-marker {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.execution-step-body {
  margin: 0;
  font-weight: 600;
}

.execution-step-entry:not(.is-current) {
  opacity: 0.78;
}

.execution-step-entry-placeholder {
  background: transparent;
  border-style: dashed;
  border-color: rgba(15, 118, 110, 0.22);
  color: var(--muted);
  font-weight: 500;
}

.execution-step-entry.is-current {
  opacity: 1;
  border-color: rgba(15, 118, 110, 0.45);
  background: rgba(255, 255, 253, 0.82);
  box-shadow: inset 5px 0 0 rgba(15, 118, 110, 0.85);
}

.side-execution-steps {
  max-height: 240px;
  min-height: 120px;
}

.heap-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.9fr);
  gap: 16px;
  padding: 18px;
  min-height: 620px;
  align-items: stretch;
}

.heap-column {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 16px;
  min-height: 620px;
}

.old-column {
  grid-template-rows: 1.2fr 0.8fr;
}

.survivor-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: stretch;
}

.heap-section {
  display: flex;
  flex-direction: column;
  border: 1px solid #d9c8af;
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82) 0%, rgba(244, 235, 221, 0.92) 100%);
  min-height: 180px;
  transition: border-color 220ms ease, box-shadow 220ms ease;
  cursor: pointer;
}

[data-section="eden"] {
  min-height: 430px;
}

[data-section="s0"],
[data-section="s1"] {
  min-height: 180px;
}

[data-section="old"] {
  min-height: 360px;
}

[data-section="stringPool"] {
  min-height: 244px;
}

.heap-section:hover,
.heap-section.is-selected {
  border-color: var(--accent);
  box-shadow: 0 14px 28px rgba(15, 118, 110, 0.13);
}

.section-title {
  padding: 14px 16px 10px;
  font-size: 0.95rem;
  font-weight: 700;
}

.object-zone {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 12px;
  padding: 0 16px 16px;
  min-height: 120px;
}

.old-gen .object-zone,
.string-pool .object-zone {
  align-content: flex-start;
}

.heap-object {
  position: relative;
  width: 98px;
  min-height: 58px;
  border-radius: 4px;
  padding: 10px 10px 8px;
  color: #fffaf2;
  border: 2px solid #000000;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.16) 0%, rgba(255, 255, 255, 0) 28%),
    linear-gradient(180deg, #5f90f3 0%, #3d73da 26%, #2d60c4 100%);
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, 0.28),
    inset -8px -8px 12px rgba(18, 42, 98, 0.24),
    0 10px 18px rgba(11, 22, 54, 0.16);
  transform-origin: center;
  transition:
    transform 400ms ease,
    opacity 400ms ease,
    border-color 220ms ease,
    border-style 220ms ease,
    box-shadow 220ms ease,
    outline-color 220ms ease;
  cursor: pointer;
}

.heap-object::before {
  content: "";
  position: absolute;
  top: 5px;
  left: 6px;
  width: 38%;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0));
  pointer-events: none;
}

.heap-object::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  width: 34%;
  height: 34%;
  background: linear-gradient(135deg, rgba(15, 33, 81, 0) 0%, rgba(15, 33, 81, 0.3) 100%);
  clip-path: polygon(100% 0, 0 100%, 100% 100%);
  pointer-events: none;
}

.heap-object.is-selected {
  outline: 3px solid rgba(15, 118, 110, 0.35);
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.2),
    inset -8px -10px 14px rgba(9, 20, 58, 0.36),
    0 14px 30px rgba(15, 118, 110, 0.2);
}

.heap-object.is-orphan {
  border-style: dotted;
}

.heap-object.mark-reachable {
  box-shadow:
    0 0 0 3px rgba(34, 197, 94, 0.28),
    inset 2px 2px 0 rgba(255, 255, 255, 0.2),
    inset -8px -10px 14px rgba(9, 20, 58, 0.36),
    0 16px 34px rgba(34, 197, 94, 0.28);
}

.heap-object.mark-unreachable {
  box-shadow:
    0 0 0 3px rgba(220, 38, 38, 0.3),
    inset 2px 2px 0 rgba(255, 255, 255, 0.2),
    inset -8px -10px 14px rgba(9, 20, 58, 0.36),
    0 16px 34px rgba(220, 38, 38, 0.26);
}

.heap-object.enter-start {
  opacity: 0;
  transform: scale(0.62);
}

.heap-object.enter-active {
  opacity: 1;
  transform: scale(1);
}

.heap-object.delete-active {
  opacity: 0;
  transform: translateY(-10px) scale(0.6);
}

.object-label {
  position: relative;
  z-index: 1;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.1;
  font-family: var(--mono);
  word-break: break-word;
}

.side-panel {
  padding-bottom: 16px;
}

.side-section {
  padding: 18px 22px 0;
}

.side-section h3 {
  margin-bottom: 10px;
  font-size: 1rem;
}

.side-section p,
.selection-content p,
.selection-content li {
  color: var(--muted);
  line-height: 1.55;
}

.selection-content ul {
  margin: 0;
  padding-left: 18px;
}

.selection-card {
  border-radius: 18px;
  border: 1px solid rgba(15, 118, 110, 0.18);
  background: var(--accent-soft);
  padding: 14px;
}

.selection-card dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 12px;
}

.selection-card dt {
  font-weight: 700;
}

.selection-card dd {
  margin: 0;
  font-family: var(--mono);
  word-break: break-word;
}

.reference-line {
  fill: none;
  stroke: var(--line);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  transition: opacity 240ms ease;
}

.reference-line.is-visible {
  opacity: 1;
}

.reference-arrow {
  fill: var(--line);
}

@media (max-width: 1280px) {
  .workspace {
    grid-template-columns: minmax(620px, 1fr) minmax(240px, 280px) minmax(260px, 300px);
  }

  .workspace.dual-thread-layout {
    grid-template-columns: minmax(620px, 1fr) minmax(240px, 280px) minmax(240px, 280px) minmax(260px, 300px);
  }

  .education-strip {
    grid-template-columns: 1fr;
  }

  .heap-layout {
    grid-template-columns: 1fr;
  }

  .old-column {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: none;
  }

  .memory-legend {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1040px) {
  .toolbar {
    flex-direction: column;
  }

  .controls {
    justify-content: flex-start;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .reference-layer {
    display: none;
  }

  .stack-root {
    min-height: auto;
  }

  .memory-legend {
    grid-template-columns: 1fr;
  }
}
