.farm-trace {
  --trace-pencil: #385449;
  --trace-demo: #628472;
  width: min(480px, calc(100% - 28px));
  max-width: none;
  max-height: calc(100% - 28px);
  margin: auto;
  padding: clamp(18px, 4vw, 28px);
  box-sizing: border-box;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--rule, #d9dfd7);
  border-radius: 18px;
  background: var(--paper, #f9f8f4);
  color: var(--ink, #232b25);
  box-shadow: 0 22px 65px rgb(26 42 32 / 17%);
  font-family: inherit;
}

.farm-trace::backdrop {
  background: rgb(27 40 32 / 45%);
}

.farm-trace__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.farm-trace__header h2 {
  margin: 0;
  font-family: inherit;
  font-size: clamp(1.25rem, 4.2vw, 1.7rem);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.035em;
}

.farm-trace__header p,
.farm-trace__status {
  margin: 5px 0 0;
  color: var(--muted, #58635b);
  font-size: 0.93rem;
  line-height: 1.35;
}

.farm-trace__sheet {
  position: relative;
  width: min(100%, 306px, 55dvh);
  aspect-ratio: 144 / 136;
  margin: 19px auto;
  overflow: hidden;
  border: 1px solid var(--rule, #d9dfd7);
  border-radius: 9px;
  background: #fefefe;
}

.farm-trace__sheet img,
.farm-trace__sheet svg,
.farm-trace__sheet canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.farm-trace__sheet img,
.farm-trace__sheet svg {
  pointer-events: none;
  user-select: none;
}

.farm-trace__sheet canvas {
  cursor: crosshair;
  touch-action: none;
}

.farm-trace__guide {
  visibility: hidden;
}

.farm-trace__guide.is-visible {
  visibility: visible;
}

.farm-trace__guide path {
  fill: none;
  stroke: var(--trace-demo);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

.farm-trace__guide.is-visible path {
  animation: farm-trace-guide 980ms cubic-bezier(0.38, 0.1, 0.34, 1) forwards;
}

@keyframes farm-trace-guide {
  to { stroke-dashoffset: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .farm-trace__guide.is-visible path {
    animation: none;
    stroke-dashoffset: 0;
  }
}

.farm-trace__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.farm-trace button {
  min-height: 44px;
  padding: 7px 13px;
  border: 1px solid var(--rule, #d9dfd7);
  border-radius: 100px;
  background: transparent;
  color: var(--ink, #232b25);
  font: inherit;
  font-size: 0.88rem;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.farm-trace .farm-trace__show {
  background: #e5ede6;
  background: color-mix(in srgb, var(--sage, #668370) 18%, var(--paper, #f9f8f4));
}

.farm-trace button:hover {
  background: color-mix(in srgb, var(--sage, #668370) 14%, var(--paper, #f9f8f4));
}

.farm-trace button:focus-visible {
  outline: 2px solid var(--trace-pencil);
  outline-offset: 3px;
}

.farm-trace__status {
  min-height: 2.7em;
  margin-top: 9px;
}
