.dt-card {
  --dt-surface: #ffffff;
  --dt-soft: #f4f7f5;
  --dt-ink: #243029;
  --dt-muted: #617068;
  --dt-line: #cdd8d1;
  --dt-a: #2f9e44;
  --dt-a-soft: #dff3e4;
  --dt-b: #d97706;
  --dt-b-soft: #fbe8cc;
  --dt-accent: #59636d;
  box-sizing: border-box;
  width: 100%;
  padding: 1rem;
  color: var(--dt-ink);
  background: var(--dt-surface);
  border: 1px solid var(--dt-line);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(31, 48, 39, 0.08);
}

[theme="dark"] .dt-card {
  --dt-surface: #202523;
  --dt-soft: #29302c;
  --dt-ink: #edf3ef;
  --dt-muted: #aab8b0;
  --dt-line: #3d4942;
  --dt-a: #69db7c;
  --dt-a-soft: #1f4930;
  --dt-b: #ffa94d;
  --dt-b-soft: #50381d;
  --dt-accent: #d6dde0;
  box-shadow: none;
}

.dt-card * {
  box-sizing: border-box;
}

.dt-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

.dt-head h3 {
  margin: 0.1rem 0 0;
  color: var(--dt-ink);
  font-size: 1.05rem;
  line-height: 1.35;
}

.dt-eyebrow {
  margin: 0;
  color: var(--dt-muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.11em;
}

.dt-button {
  flex: 0 0 auto;
  padding: 0.55rem 0.8rem;
  color: #fff;
  background: #2b8a3e;
  border: 0;
  border-radius: 8px;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.dt-button:hover {
  background: #237234;
}

.dt-button:focus-visible,
.dt-card input:focus-visible,
.dt-tree-details summary:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--dt-a) 45%, transparent);
  outline-offset: 2px;
}

.dt-control {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.8rem;
  color: var(--dt-ink);
  font-size: 0.78rem;
  font-weight: 650;
}

.dt-control span {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.dt-control output {
  color: var(--dt-a);
  font-variant-numeric: tabular-nums;
}

.dt-control input {
  width: 100%;
  accent-color: var(--dt-a);
}

.dt-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

.dt-metrics div {
  min-width: 0;
  padding: 0.55rem 0.65rem;
  background: var(--dt-soft);
  border-radius: 8px;
}

.dt-metrics span,
.dt-metrics strong {
  display: block;
}

.dt-metrics span {
  margin-bottom: 0.2rem;
  color: var(--dt-muted);
  font-size: 0.66rem;
}

.dt-metrics strong {
  overflow: hidden;
  color: var(--dt-ink);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dt-canvas-wrap {
  overflow: hidden;
  background: var(--dt-soft);
  border: 1px solid var(--dt-line);
  border-radius: 10px;
}

.dt-card canvas {
  display: block;
  width: 100%;
  touch-action: manipulation;
}

#dt-split-canvas {
  aspect-ratio: 16 / 7;
}

#dt-grow-canvas {
  aspect-ratio: 4 / 3;
}

.dt-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  margin-top: 0.6rem;
  color: var(--dt-muted);
  font-size: 0.72rem;
}

.dt-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
}

.dt-legend i {
  width: 0.72rem;
  height: 0.72rem;
  border-radius: 50%;
}

.dt-legend .class-a {
  background: var(--dt-a);
}

.dt-legend .class-b {
  background: var(--dt-b);
}

.dt-legend .split,
.dt-legend .boundary {
  width: 1rem;
  height: 0;
  border-radius: 0;
  border-top: 2px solid var(--dt-accent);
}

.dt-hint,
.dt-caption {
  margin: 0.8rem 0 0;
  color: var(--dt-muted);
  font-size: 0.78rem;
  line-height: 1.5;
  text-align: center;
}

.dt-tree-details {
  margin-top: 0.65rem;
  color: var(--dt-muted);
  font-size: 0.75rem;
}

.dt-tree-details summary {
  width: max-content;
  cursor: pointer;
  font-weight: 700;
}

.dt-tree-details pre {
  max-height: 17rem;
  margin: 0.55rem 0 0;
  padding: 0.75rem;
  overflow: auto;
  color: var(--dt-ink);
  background: var(--dt-soft);
  border-radius: 8px;
  font-size: 0.7rem;
  line-height: 1.55;
  white-space: pre;
}

@media (max-width: 640px) {
  .dt-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .dt-metrics {
    grid-template-columns: 1fr;
  }

  .dt-card {
    padding: 0.75rem;
  }

  #dt-split-canvas {
    aspect-ratio: 4 / 3;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dt-card * {
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
  }
}
