.boundary-lens {
  width: 100%;
  min-width: 0;
  color: var(--ink);
}

.boundary-lens .lens-plate {
  position: relative;
  margin: 0;
}

.boundary-lens .lens-plate:focus-visible {
  outline: 3px solid #877035;
  outline-offset: 4px;
}

.boundary-lens .lens-plate > img,
.boundary-lens .lens-surface > img {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
}

.boundary-lens .lens-surface {
  position: relative;
  overflow: hidden;
  background: var(--deep);
  cursor: zoom-in;
  user-select: none;
  -webkit-user-select: none;
}

.boundary-lens[data-lens-active] .lens-surface {
  cursor: crosshair;
  touch-action: none;
}

.boundary-lens .magnifier {
  position: absolute;
  width: clamp(108px, 14vw, 192px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  overflow: hidden;
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
}

.boundary-lens[data-lens-active] .magnifier.is-ready {
  opacity: 1;
  box-shadow: 0 3px 18px #07140e88;
}

.boundary-lens .magnifier img {
  position: absolute;
  max-width: none;
  left: 50%;
  top: 50%;
}

.boundary-lens .magnifier::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 2px solid var(--accent);
  box-shadow: inset 0 0 0 1px #16271ecc;
}

.boundary-lens:not([data-lens-ready]) :is(.lens-choices, [data-lens-toggle], .magnifier) {
  display: none;
}

.boundary-lens .lens-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px 14px;
  padding: 8px 12px;
  background: var(--deep);
  color: var(--paper);
}

.boundary-lens .lens-toolbar > span {
  flex: 1 1 130px;
  color: #d9dfd0;
  font-size: .77rem;
  line-height: 1.35;
}

.boundary-lens [data-lens-toggle] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 44px;
  padding: 7px 13px;
  border: 1px solid #b1b59e;
  color: var(--paper);
  font-size: .84rem;
}

.boundary-lens [data-lens-toggle]::before {
  content: "";
  width: 13px;
  height: 13px;
  border: 1px solid currentColor;
  border-radius: 50%;
  background:
    linear-gradient(currentColor, currentColor) center / 6px 1px no-repeat,
    linear-gradient(currentColor, currentColor) center / 1px 6px no-repeat;
}

.boundary-lens [data-lens-toggle][aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--deep);
}

.boundary-lens [data-lens-toggle][aria-pressed="true"]::before {
  background: linear-gradient(currentColor, currentColor) center / 6px 1px no-repeat;
}

.boundary-lens .lens-choices {
  display: flex;
  flex-wrap: wrap;
  border-block-end: 1px solid var(--line);
}

.boundary-lens .lens-choices button {
  position: relative;
  min-height: 44px;
  padding: 10px clamp(7px, 1.25vw, 20px);
  font-size: .82rem;
  color: var(--muted);
}

.boundary-lens .lens-choices button::after {
  content: "";
  position: absolute;
  inset: auto 6px 0;
  height: 2px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left center;
}

.boundary-lens .lens-choices button[aria-pressed="true"] {
  font-weight: 650;
  color: var(--ink);
}

.boundary-lens .lens-choices button[aria-pressed="true"]::after,
.boundary-lens .lens-choices button:focus-visible::after {
  transform: scaleX(1);
}

.boundary-lens button:focus-visible {
  z-index: 1;
  outline: 2px solid currentColor;
  outline-offset: -4px;
}

.boundary-lens figcaption {
  text-wrap: pretty;
  line-height: 1.45;
}

@media (hover: hover) {
  .boundary-lens .lens-choices button:hover::after {
    transform: scaleX(1);
  }
  .boundary-lens [data-lens-toggle]:hover {
    border-color: var(--accent);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .boundary-lens .magnifier {
    transition: opacity 140ms ease;
  }
  .boundary-lens .lens-choices button::after {
    transition: transform 240ms var(--ease);
  }
  .boundary-lens [data-lens-toggle] {
    transition: color 180ms, background-color 180ms, border-color 180ms;
  }
}
