:root {
  --paper: #efe4cd;
  --wash: #fcf4df;
  --ink: #483d32;
  --label: #685743;
  --surface: #fff9e9;
  --edge: #c9b492;
  --primary: #855430;
}
.scene {
  background: #a5764d url(./bench.webp) center/cover;
  display: grid;
  place-items: center;
}
.dig-tray {
  aspect-ratio: 1;
  height: 91%;
  position: relative;
  z-index: 1;
  overflow: hidden;
  border: 8px solid #70523a;
  border-radius: 19px;
  background: #654936;
  box-shadow:
    0 0 0 3px #cfaa74,
    0 7px 14px #4125158a;
}
.dig-tray img,
.dig-tray canvas {
  position: absolute;
  width: 100%;
  height: 100%;
  inset: 0;
}
.dig-tray canvas {
  touch-action: none;
  cursor: crosshair;
}
.dig-tray img {
  object-fit: cover;
}
.brush {
  display: none;
  position: absolute;
  z-index: 1;
  width: 8%;
  height: 28%;
  transform: translateY(-100%) rotate(36deg);
  transform-origin: 0 100%;
  border-radius: 12px 12px 4px 4px;
  background: linear-gradient(
    to bottom,
    #a87951 0 59%,
    #d3ac72 61% 65%,
    #b6bbad 67% 75%,
    #e0c286 77% 100%
  );
  box-shadow: 2px 3px 4px #44351f66;
  pointer-events: none;
}
.brushing .brush {
  display: block;
}
.fine .brush {
  width: 4.5%;
}
.found canvas {
  pointer-events: none;
}
.field-card {
  max-height: 94%;
  overflow-y: auto;
  overscroll-behavior: contain;
  position: absolute;
  z-index: 2;
  bottom: 3%;
  left: 3%;
  right: 3%;
  border: 1px solid #a18b68;
  background: #fff8e8;
  color: #493a2e;
  border-radius: 14px;
  padding: 12px 16px;
  box-shadow: 0 4px 16px #33261e66;
}
.field-card h3 {
  margin: 0;
  font-size: 19px;
}
.field-card p {
  margin: 4px 0 7px;
  font-size: 14px;
}
.field-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.field-actions button {
  min-height: 43px;
  padding: 5px 9px;
  border: 1px solid #cab797;
  border-radius: 9px;
  background: #f0e5cd;
  font-weight: 700;
}
.field-actions button img {
  width: 32px;
  height: 32px;
  vertical-align: middle;
  border-radius: 4px;
  margin-right: 5px;
}
.field-actions button.dismiss {
  background: #fff9ec;
}
@media (max-width: 600px) {
  .dig-tray {
    height: auto;
    width: 91%;
    border-width: 5px;
  }
  .field-card {
    padding: 8px 10px;
    bottom: 2%;
  }
  .field-card h3 {
    font-size: 16px;
  }
  .field-card p {
    font-size: 13px;
  }
  .field-actions button {
    font-size: 13px;
  }
}
.repair {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(82px, 25%);
  grid-template-rows: minmax(0, 1fr) auto;
  align-items: center;
  justify-items: center;
  gap: 8px;
  padding: 3% 5%;
  background: #e6d6b7 url(./bench.webp) center/cover;
}
.repair[hidden] {
  display: none;
}
.mount {
  position: relative;
  aspect-ratio: 1;
  height: 100%;
  max-width: 100%;
  grid-row: 1/3;
  display: grid;
  grid-template: repeat(2, 1fr) / repeat(2, 1fr);
  gap: 2px;
  padding: 5px;
  border-radius: 8px;
  background: #c7b797;
  box-shadow:
    0 2px 0 3px #7d6047,
    0 7px 10px #59422b55;
  overflow: hidden;
}
.socket,
.fragment,
.ghost {
  background-image: var(--rock);
  background-size: 200% 200%;
  border: 0;
  padding: 0;
}
.socket {
  filter: grayscale(0.8);
  opacity: 0.39;
}
.socket[aria-pressed="true"] {
  filter: none;
  opacity: 0.85;
  outline: 4px dashed #fff0a2;
  outline-offset: -5px;
  box-shadow: inset 0 0 0 7px #80602f;
}
.socket.fitted {
  opacity: 1;
  filter: none;
}
.rack {
  width: 100%;
  max-height: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  align-content: center;
}
.fragment {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 4px;
  border: 1px solid #f6dfb5;
  box-shadow: 1px 3px 0 #76563d;
  touch-action: none;
}
.fragment[aria-pressed="true"] {
  outline: 3px solid #ffe58e;
  outline-offset: 2px;
}
.ghost {
  position: fixed;
  z-index: 10;
  pointer-events: none;
  transform: translate(-50%, -50%) rotate(-4deg);
  width: 82px;
  height: 82px;
}
.mend-actions button {
  padding: 7px 12px;
  min-height: 44px;
  border: 1px solid #9f8563;
  border-radius: 10px;
  background: #fff7de;
  font-weight: 800;
}
@media (max-width: 600px) {
  .repair {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) 15% auto;
    gap: 4px;
    padding: 3%;
  }
  .mount {
    grid-row: 1;
  }
  .rack {
    grid-template-columns: repeat(4, 1fr);
    width: 68%;
    max-width: 270px;
    height: 100%;
    align-items: center;
  }
  .fragment {
    width: auto;
    height: 100%;
    min-height: 0;
    max-width: 100%;
  }
  .mend-actions button {
    min-height: 34px;
    padding: 4px 10px;
  }
}
.dig-tray.unbrushed .brush {
  display: block;
  animation: brush-cue 2.2s ease-in-out 3;
}
@keyframes brush-cue {
  0%,
  70%,
  100% {
    transform: translate(-4%, -100%) rotate(32deg);
  }
  38% {
    transform: translate(66%, -85%) rotate(46deg);
  }
}
.controls .wide-tool::before,
.controls .fine-tool::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 23px;
  margin: 0 9px -5px 2px;
  transform: rotate(23deg);
  border-radius: 40% 40% 2px 2px;
  background: linear-gradient(
    to bottom,
    #906844 0 42%,
    #acae97 42% 58%,
    #b7864e 58% 70%,
    #d5aa6d 70%
  );
  box-shadow: inset -1px 0 0 #826748;
}
.controls .fine-tool::before {
  width: 5px;
  border-radius: 50% 50% 35% 35%;
}

.detail-finds {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.detail-finds i {
  position: absolute;
  width: 12%;
  aspect-ratio: 1;
  border: 2px solid #ffe0a0;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow:
    0 0 0 1px #69462599,
    inset 0 0 8px #ffe0a04d;
}
.dig-tray:not(.fine) .detail-finds,
.dig-tray.found .detail-finds {
  display: none;
}

.repair.exhibiting {
  grid-template-columns: 1fr;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 8px;
}
.repair :is(.rack, .mount, .museum-plate)[hidden] {
  display: none;
}
.museum-plate {
  height: 100%;
  width: 100%;
  min-height: 0;
  margin: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  justify-items: center;
  gap: 6px;
}
.museum-plate img {
  height: 100%;
  max-width: 100%;
  object-fit: contain;
  aspect-ratio: 1;
  border: 4px solid #805a3b;
  border-radius: 6px;
  box-shadow: 1px 4px 6px #41281377;
}
.museum-plate figcaption {
  color: #473521;
  background: #fff0ca;
  padding: 3px 15px;
  border-radius: 3px;
  font:
    600 clamp(14px, 2vw, 19px) Georgia,
    serif;
}
.museum-plate figcaption {
  text-align: center;
}
.museum-plate figcaption small {
  display: block;
  font:
    500 12px/1.25 system-ui,
    sans-serif;
}
.repair.exhibiting .mend-actions button {
  min-height: 44px;
}

.field-actions button.compared {
  opacity: 0.62;
  border-style: dashed;
  background: #e2d8c1;
}
.field-actions button.compared img {
  filter: grayscale(0.85);
}

.mend-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
}
.fragment {
  transform: rotate(var(--turn, 0deg));
}
.fragment.ghost {
  transform: translate(-50%, -50%) rotate(var(--turn, 0deg));
}
.mend-actions button[hidden] {
  display: none;
}

.comparison-loupe {
  position: absolute;
  width: 28%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border: 4px solid #e6bd61;
  border-radius: 50%;
  box-shadow:
    0 0 0 2px #68462d,
    1px 4px 5px #452e2366,
    inset 0 0 5px #39271d;
  background-repeat: no-repeat;
  pointer-events: none;
}
.comparison-loupe[hidden] {
  display: none;
}
.comparison-loupe::after {
  content: "";
  position: absolute;
  width: 17%;
  height: 44%;
  left: 83%;
  top: 82%;
  border-radius: 2px 2px 6px 6px;
  transform: rotate(-36deg);
  transform-origin: top center;
  background: linear-gradient(90deg, #725438, #b98b4c 45%, #715035);
}

.notebook-details {
  display: block;
  color: #7f612a;
  letter-spacing: 2px;
  font-size: 13px;
}
@media (max-width: 600px) {
  .scene:has(.repair.exhibiting:not([hidden])) {
    aspect-ratio: 0.88;
  }
  .repair.exhibiting .mend-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(75px, 1fr));
    gap: 5px;
  }
  .repair.exhibiting .mend-actions button {
    padding: 5px;
    font-size: 13px;
    line-height: 1.15;
  }
}

.field-labels {
  position: absolute;
  z-index: 1;
  inset: auto 2% 3% auto;
  display: grid;
  gap: 5px;
}
.field-labels[hidden] {
  display: none;
}
.field-labels button {
  width: clamp(57px, 8vw, 75px);
  aspect-ratio: 1.15;
  min-height: 44px;
  padding: 3px;
  border: 2px solid #99704a;
  border-radius: 6px;
  background: #fff0c9;
  box-shadow: 0 2px 3px #3b291d77;
}
.field-labels img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 2px;
}
@media (max-width: 600px) {
  .field-labels {
    inset: auto 1% 1% auto;
    display: flex;
  }
}
