x-otp-input {
  align-items: center;
  gap: var(--space-3);
  vertical-align: top;
  font-family: var(--default-font-family);
  color: var(--neutral-12);
  --otp-cell-height: var(--space-6);
  --otp-cell-radius: var(--radius-2);
  --otp-cell-font: var(--font-size-3);
  --otp-border-width: 1px;
  --otp-border-color: var(--neutral-a7);
  --otp-focus-color: var(--focus-8);
  --otp-surface: var(--color-surface);
  display: inline-flex;
  position: relative;
}

x-otp-input:where([data-size="1"]) {
  --otp-cell-height: var(--space-5);
  --otp-cell-radius: var(--radius-2);
  --otp-cell-font: var(--font-size-2);
  gap: var(--space-2);
}

x-otp-input:where([data-size="3"]) {
  --otp-cell-height: var(--space-7);
  --otp-cell-radius: var(--radius-3);
  --otp-cell-font: var(--font-size-4);
}

x-otp-group {
  isolation: isolate;
  align-items: stretch;
  display: inline-flex;
}

x-otp-slot {
  z-index: 0;
  box-sizing: border-box;
  height: var(--otp-cell-height);
  min-width: calc(var(--otp-cell-height) * .9);
  padding-inline: calc(var(--otp-cell-height) * .28);
  font-size: var(--otp-cell-font);
  font-weight: var(--font-weight-medium);
  font-variant-numeric: tabular-nums;
  -webkit-user-select: none;
  user-select: none;
  background-color: var(--otp-surface);
  border: var(--otp-border-width) solid var(--otp-border-color);
  border-radius: var(--otp-cell-radius);
  justify-content: center;
  align-items: center;
  line-height: 1;
  display: inline-flex;
  position: relative;
}

x-otp-group > x-otp-slot:not(:last-child) {
  border-start-end-radius: 0;
  border-end-end-radius: 0;
}

x-otp-group > x-otp-slot:not(:first-child) {
  border-inline-start-width: 0;
  border-start-start-radius: 0;
  border-end-start-radius: 0;
}

x-otp-slot:where([data-active]) {
  z-index: 1;
  box-shadow: 0 0 0 2px var(--otp-focus-color);
  border-width: 0;
}

x-otp-slot:where([data-selected]) {
  z-index: 1;
  background-color: var(--accent-a4);
}

x-otp-slot:where([data-disabled]) {
  color: var(--neutral-a8);
  background-color: var(--neutral-a2);
  border-color: var(--neutral-a6);
}

x-otp-slot:where([data-caret]):after {
  content: "";
  background-color: var(--neutral-12);
  width: 1px;
  height: 1.1em;
  animation: 1s step-start infinite x-otp-caret-blink;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

@keyframes x-otp-caret-blink {
  0%, 49% {
    opacity: 1;
  }

  50%, 100% {
    opacity: 0;
  }
}

x-otp-separator {
  color: var(--neutral-a8);
  justify-content: center;
  align-items: center;
  display: inline-flex;
}

x-otp-separator:where(:empty):before {
  content: "";
  width: var(--space-3);
  border-radius: var(--radius-thumb);
  background-color: currentColor;
  height: 2px;
}

x-otp-input:where([data-variant="soft"]) {
  --otp-border-width: 0px;
  --otp-focus-color: var(--accent-8);
}

x-otp-input:where([data-variant="soft"]) x-otp-slot {
  background-color: var(--accent-a3);
  color: var(--accent-12);
}

@media (prefers-reduced-motion: reduce) {
  x-otp-slot:where([data-caret]):after {
    animation: none;
  }
}

@media (forced-colors: active) {
  x-otp-slot {
    border-color: buttontext;
  }

  x-otp-slot:where([data-active]) {
    outline-offset: -2px;
    outline: 2px solid highlight;
  }

  x-otp-slot:where([data-selected]) {
    color: highlighttext;
    background-color: highlight;
  }

  x-otp-slot:where([data-caret]):after {
    background-color: canvastext;
  }
}
