.tk-edit {
  align-items: center;
}
.tk-edit label {
  display: inline-flex;
  gap: 0.4rem;
  align-items: center;
}
.tk-edit select {
  min-height: 2rem;
  padding: 0 0.3rem;
}
.tk-edit input[type="color"] {
  width: 2.5rem;
  height: 2rem;
  padding: 2px;
  cursor: pointer;
}

.tk-graph {
  position: relative;
}
.tk-edges {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}
.tk-edges path {
  fill: none;
  stroke: var(--muted);
  stroke-width: 1;
  opacity: 0.55;
}
.tk-edges path.tk-hot {
  stroke: var(--redline);
  stroke-width: 1.5;
  opacity: 1;
  stroke-dasharray: 5 4;
  animation: tk-flow 0.6s linear infinite;
}
@keyframes tk-flow {
  to {
    stroke-dashoffset: -18;
  }
}

.tk-tier-label {
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-size: 0.85em;
}
.tk-tier {
  position: relative;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(138px, 1fr));
  gap: 0.4rem;
  margin-bottom: 2.1rem;
}
.tk-tier:last-child {
  margin-bottom: 0;
}
.tk-node {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  gap: 0 0.4rem;
  align-items: center;
  padding: 0.3rem 0.45rem;
  border: 1px solid var(--rule);
  background: var(--bg);
  transition: opacity 200ms ease-out, border-color 200ms ease-out;
}
.tk-node i {
  grid-row: span 2;
  width: 12px;
  height: 26px;
  border-radius: 2px;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--fg) 18%, transparent);
}
.tk-node .tk-name {
  overflow: hidden;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82em;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.tk-node small {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.78em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.tk-node.tk-unused > * {
  opacity: 0.4;
}
.tk-node.tk-flash {
  border-color: var(--redline);
}

.tk-preview {
  display: grid;
  margin-top: 1rem;
  padding: 1rem;
  background: color-mix(in srgb, var(--fg) 4%, transparent);
}
.tk-card {
  display: grid;
  gap: 0.2rem;
  justify-self: center;
  width: min(100%, 240px);
  padding: 0.9rem;
  border-radius: calc(var(--tk-radius, 8px) + 4px);
  background: var(--tk-card-bg);
  color: var(--tk-card-text);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--tk-card-text) 12%, transparent), 0 6px 20px -12px rgba(0, 0, 0, 0.35);
  transition: background-color 250ms ease-out, color 250ms ease-out;
}
.tk-card strong {
  font-weight: 500;
}
.tk-card span {
  opacity: 0.65;
}
.tk-card button {
  justify-self: start;
  margin-top: 0.6rem;
  padding: 0.35rem 0.8rem;
  border: 0;
  border-radius: var(--tk-radius, 8px);
  background: var(--tk-btn-bg);
  color: var(--tk-btn-text);
  font: inherit;
  cursor: default;
  transition: background-color 250ms ease-out, color 250ms ease-out;
}

.tk-range {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  margin-bottom: 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
}
.tk-range input {
  flex: 1;
  min-width: 0;
  max-width: 220px;
}
.tk-range output {
  min-width: 3ch;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.tk-code {
  max-height: 320px;
  margin: 0;
  overflow: auto;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--rule);
  font-size: 0.82em;
  line-height: 1.55;
}
.tk-code code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre;
}

@media (prefers-reduced-motion: reduce) {
  .tk-edges path.tk-hot {
    animation: none;
    stroke-dasharray: none;
  }
  .tk-card,
  .tk-card button,
  .tk-node {
    transition: none;
  }
}
