# Safe keypad dialog

> A brushed metal panel with keys that sink, indicator lights and a shake when the code is wrong.

- Category: [Overlays](https://library.aimran.es/components/overlays)
- Built with: HTML + CSS
- Live editor: https://library.aimran.es/blocks/uv-ov-safe-keypad
- Library: AIMRAN Library (https://library.aimran.es), free, no sign-up, by Aimran Oukham

## Where to use it

PIN dialogs tend to be four empty boxes, and this one feels like the safe in a hotel room. Brushed steel with rivets, round metal keys that sink when pressed, amber dots in a recessed display and a status light that goes red or green. A wrong code shakes the panel and resets it. It works for parental locks, vaults, escape room games and app passcodes.

The main color is the success light and the second one the metal tint. Change the code in the script, and type it with the number keys or Backspace as well as with taps, since the panel listens to the keyboard while it is open.

## Code

### HTML

```html
<div class="uvq13-sf"><div class="pg" aria-hidden="true"><i class="h"></i><i></i><i></i><i></i><i></i><i class="s"></i></div><button type="button" class="fire" aria-haspopup="dialog">Open the safe</button><div class="scr"></div><div class="dl" role="dialog" aria-modal="true" aria-labelledby="uvq13-sf-t"><div class="tp"><p id="uvq13-sf-t">Enter the code</p><i class="led" aria-hidden="true"></i></div><div class="dp" aria-hidden="true"><i></i><i></i><i></i><i></i></div><p class="st" aria-live="assertive"><span class="e">Wrong code</span><span class="or">Unlocked</span></p><div class="kp"><button type="button" data-k="1">1</button><button type="button" data-k="2">2</button><button type="button" data-k="3">3</button><button type="button" data-k="4">4</button><button type="button" data-k="5">5</button><button type="button" data-k="6">6</button><button type="button" data-k="7">7</button><button type="button" data-k="8">8</button><button type="button" data-k="9">9</button><button type="button" data-k="del" aria-label="Clear"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 5.5h10.5A1.5 1.5 0 0 1 21 7v10a1.5 1.5 0 0 1-1.5 1.5H9L3 12zM12 9.5l5 5M17 9.5l-5 5"/></svg></button><button type="button" data-k="0">0</button><button type="button" data-k="x" aria-label="Close"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M7 7l10 10M17 7L7 17"/></svg></button></div><p class="hn">Hint: the middle column</p></div></div>
```

### CSS

```css
.uvq13-sf {
  --c1: #22c55e;
  --c2: #b6b0a8;
  --s: 16px;
  /* tamaño */
  --k: 1;
  /* velocidad */
  --fg: #1d1d1f;
  /* texto */
  --bg: #f5f5f7;
  /* fondo */
}

.uvq13-sf {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  position: relative;
  width: 22em;
  height: 21em;
  border-radius: 1.2em;
  overflow: hidden;
  background: color-mix(in srgb,var(--fg) 3%,var(--bg));
  box-shadow: 0 0 0 1px color-mix(in srgb,var(--fg) 9%,transparent);
}

.uvq13-sf .pg {
  position: absolute;
  inset: 0;
  padding: 1.2em;
  display: grid;
  align-content: start;
  gap: .55em;
}

.uvq13-sf .pg i {
  height: .6em;
  border-radius: 1em;
  background: color-mix(in srgb,var(--fg) 6%,transparent);
}

.uvq13-sf .pg .h {
  width: 45%;
  height: 1em;
  margin-bottom: .4em;
  background: color-mix(in srgb,var(--fg) 12%,transparent);
}

.uvq13-sf .pg .s {
  width: 60%;
}

.uvq13-sf .scr {
  position: absolute;
  inset: 0;
  z-index: 4;
  background: rgba(10,12,20,.38);
  opacity: 0;
  pointer-events: none;
  transition: opacity calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq13-sf.open .scr {
  opacity: 1;
  pointer-events: auto;
}

.uvq13-sf .fire {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: absolute;
  right: 1em;
  top: 1em;
  z-index: 1;
  padding: .55em .95em;
  border-radius: 2em;
  font-size: .78em;
  font-weight: 650;
  color: var(--bg);
  background: var(--fg);
  transition: transform calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq13-sf .fire:active {
  transform: scale(.96);
}

.uvq13-sf button:focus-visible,.uvq13-sf a:focus-visible,.uvq13-sf input:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

.uvq13-sf .dl {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 5;
  box-sizing: border-box;
  transform: translate(-50%,-46%) scale(.95);
  opacity: 0;
  pointer-events: none;
  transition: transform calc(0.35s / var(--k)) cubic-bezier(.22,1,.36,1),opacity calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq13-sf.open .dl {
  transform: translate(-50%,-50%);
  opacity: 1;
  pointer-events: auto;
}

.uvq13-sf .dl {
  width: 13em;
  padding: 1em;
  border-radius: 1em;
  color: #1c1917;
  background: radial-gradient(circle at .6em .6em,#57534e .14em,#e7e5e4 .17em,transparent .26em),radial-gradient(circle at calc(100% - .6em) .6em,#57534e .14em,#e7e5e4 .17em,transparent .26em),radial-gradient(circle at .6em calc(100% - .6em),#57534e .14em,#e7e5e4 .17em,transparent .26em),radial-gradient(circle at calc(100% - .6em) calc(100% - .6em),#57534e .14em,#e7e5e4 .17em,transparent .26em),repeating-linear-gradient(90deg,rgba(255,255,255,.08) 0 1px,rgba(0,0,0,.04) 1px 2px,transparent 2px 4px),linear-gradient(155deg,color-mix(in srgb,var(--c2) 50%,#fff),var(--c2) 45%,color-mix(in srgb,var(--c2) 70%,#000));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.6),inset 0 -2px 0 rgba(0,0,0,.2),0 1.4em 2.4em -1em rgba(0,0,0,.6);
}

.uvq13-sf .dl.bad {
  animation: uvq13-sf-s calc(0.45s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq13-sf .tp {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 .2em .6em;
}

.uvq13-sf .tp p {
  margin: 0;
  font-size: .68em;
  font-weight: 800;
  letter-spacing: .09em;
  text-transform: uppercase;
  text-shadow: 0 1px 0 rgba(255,255,255,.5);
}

.uvq13-sf .led {
  width: .6em;
  height: .6em;
  border-radius: 50%;
  background: #7f1d1d;
  box-shadow: inset 0 0 .12em #000,0 1px 0 rgba(255,255,255,.5);
}

.uvq13-sf .bad .led {
  background: #ef4444;
  box-shadow: 0 0 .6em #ef4444;
}

.uvq13-sf .ok .led {
  background: var(--c1);
  box-shadow: 0 0 .6em var(--c1);
}

.uvq13-sf .dp {
  display: flex;
  justify-content: center;
  gap: .8em;
  padding: .75em;
  border-radius: .5em;
  background: #0f1110;
  box-shadow: inset 0 .15em .35em #000,0 1px 0 rgba(255,255,255,.55);
}

.uvq13-sf .dp i {
  width: .7em;
  height: .7em;
  border-radius: 50%;
  background: #262a27;
  transition: background .12s,box-shadow .12s;
}

.uvq13-sf .dp i.on {
  background: #fbbf24;
  box-shadow: 0 0 .5em #fbbf24;
}

.uvq13-sf .bad .dp i {
  background: #ef4444;
  box-shadow: 0 0 .5em #ef4444;
}

.uvq13-sf .ok .dp i {
  background: var(--c1);
  box-shadow: 0 0 .5em var(--c1);
}

.uvq13-sf .st {
  height: 1.3em;
  margin: .35em 0 .5em;
  text-align: center;
  font-size: .66em;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.uvq13-sf .st span {
  display: none;
}

.uvq13-sf .bad .st .e {
  display: inline;
  color: #b91c1c;
}

.uvq13-sf .ok .st .o {
  display: inline;
  color: #15803d;
}

.uvq13-sf .kp {
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: .55em .4em;
  justify-items: center;
}

.uvq13-sf .kp button {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: grid;
  place-items: center;
  width: 2.6em;
  height: 2.6em;
  border-radius: 50%;
  font: 800 1em/1 ui-monospace,"SF Mono",Menlo,Consolas,monospace;
  color: #292524;
  background: radial-gradient(circle at 35% 28%,rgba(255,255,255,.95),transparent 48%),linear-gradient(160deg,#f5f5f4,#a8a29e);
  box-shadow: inset 0 -.15em .2em rgba(0,0,0,.25),0 .2em 0 #57534e,0 .3em .5em rgba(0,0,0,.35);
  text-shadow: 0 1px 0 rgba(255,255,255,.8);
  transition: transform .06s cubic-bezier(.25,.1,.25,1),box-shadow .06s cubic-bezier(.25,.1,.25,1);
}

.uvq13-sf .kp button:active,.uvq13-sf .kp button.dn {
  transform: translateY(.17em);
  box-shadow: inset 0 -.05em .1em rgba(0,0,0,.25),0 .03em 0 #57534e,0 .1em .2em rgba(0,0,0,.35);
}

.uvq13-sf .kp svg {
  width: 1.1em;
  height: 1.1em;
}

.uvq13-sf .kp button:focus-visible {
  outline: 2px solid #1c1917;
  outline-offset: 2px;
}

.uvq13-sf .hn {
  width: max-content;
  margin: .9em auto 0;
  padding: .25em .6em;
  font: italic 600 .64em/1.3 Georgia,serif;
  color: #78350f;
  background: #fde68a;
  box-shadow: 0 .1em .2em rgba(0,0,0,.2);
  transform: rotate(-2deg);
}

@keyframes uvq13-sf-s {
  0%,100% {
    transform: translate(-50%,-50%);
  }
  20%,60% {
    transform: translate(calc(-50% - .35em),-50%);
  }
  40%,80% {
    transform: translate(calc(-50% + .35em),-50%);
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq13-sf,.uvq13-sf *,.uvq13-sf *::before,.uvq13-sf *::after {
    animation-duration: .01ms!important;
    animation-iteration-count: 1!important;
    transition-duration: .01ms!important;
  }
}
```

### JavaScript

```js
document.querySelectorAll(".uvq13-sf").forEach(el => {
  const fire=el.querySelector(".fire"),scr=el.querySelector(".scr"),pnl=el.querySelector(".dl");let tms=[];const later=(f,ms)=>tms.push(setTimeout(f,ms));
const foc=(t,ms)=>later(()=>{const n=typeof t==="string"?el.querySelector(t):t;n&&n.focus({preventScroll:true})},ms||0);
const isOpen=()=>el.classList.contains("open");
const open=u=>{if(isOpen())return;el.classList.add("open");pnl.inert=false;fire&&fire.setAttribute("aria-expanded","true");reset();u&&foc('.kp button',320)};
const close=()=>{if(!isOpen())return;el.classList.remove("open");pnl.inert=true;fire&&fire.setAttribute("aria-expanded","false");;fire&&fire.focus({preventScroll:true})};
fire&&fire.addEventListener("click",()=>isOpen()?close():open(true));scr&&scr.addEventListener("click",()=>close());
el.addEventListener("keydown",e=>{if(!isOpen())return;if(e.key==="Escape"){e.preventDefault();e.stopPropagation();close()}else if(e.key==="Tab"){const f=[...pnl.querySelectorAll('button:not([disabled]),input:not([disabled]),textarea,a[href],[tabindex="0"]')].filter(x=>x.getClientRects().length);if(!f.length){e.preventDefault();return}const a=f[0],z=f[f.length-1],ac=document.activeElement;if(e.shiftKey&&(ac===a||!pnl.contains(ac))){e.preventDefault();z.focus()}else if(!e.shiftKey&&(ac===z||!pnl.contains(ac))){e.preventDefault();a.focus()}}});
pnl.inert=true;later(()=>open(false),500);const dl=el.querySelector(".dl"),ds=[...el.querySelectorAll(".dp i")],kb=[...el.querySelectorAll(".kp button")];let code="",busy=false;const OK="2580";
const paint=()=>ds.forEach((d,i)=>d.classList.toggle("on",i<code.length));
const reset=()=>{code="";busy=false;dl.classList.remove("bad","ok");paint()};
const press=k=>{if(busy)return;if(k==="x"){close();return}if(k==="del"){code=code.slice(0,-1);paint();return}if(code.length>=4)return;code+=k;paint();if(code.length===4){busy=true;if(code===OK){dl.classList.add("ok");later(close,1300)}else{dl.classList.add("bad");later(reset,900)}}};
kb.forEach(b=>b.addEventListener("click",()=>press(b.dataset.k)));
el.addEventListener("keydown",e=>{if(!isOpen())return;const k=/^[0-9]$/.test(e.key)?e.key:e.key==="Backspace"?"del":null;if(!k)return;e.preventDefault();press(k);const b=kb.find(x=>x.dataset.k===k);if(b){b.classList.add("dn");later(()=>b.classList.remove("dn"),110)}});return()=>tms.forEach(clearTimeout)
});
```

### React

```tsx
// @ts-nocheck: setup() es JavaScript del DOM sin tipos, el mismo de la pestaña JS.
import { useEffect, useRef, type CSSProperties } from "react";

const css = `
.uvq13-sf {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  position: relative;
  width: 22em;
  height: 21em;
  border-radius: 1.2em;
  overflow: hidden;
  background: color-mix(in srgb,var(--fg) 3%,var(--bg));
  box-shadow: 0 0 0 1px color-mix(in srgb,var(--fg) 9%,transparent);
}

.uvq13-sf .pg {
  position: absolute;
  inset: 0;
  padding: 1.2em;
  display: grid;
  align-content: start;
  gap: .55em;
}

.uvq13-sf .pg i {
  height: .6em;
  border-radius: 1em;
  background: color-mix(in srgb,var(--fg) 6%,transparent);
}

.uvq13-sf .pg .h {
  width: 45%;
  height: 1em;
  margin-bottom: .4em;
  background: color-mix(in srgb,var(--fg) 12%,transparent);
}

.uvq13-sf .pg .s {
  width: 60%;
}

.uvq13-sf .scr {
  position: absolute;
  inset: 0;
  z-index: 4;
  background: rgba(10,12,20,.38);
  opacity: 0;
  pointer-events: none;
  transition: opacity calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq13-sf.open .scr {
  opacity: 1;
  pointer-events: auto;
}

.uvq13-sf .fire {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: absolute;
  right: 1em;
  top: 1em;
  z-index: 1;
  padding: .55em .95em;
  border-radius: 2em;
  font-size: .78em;
  font-weight: 650;
  color: var(--bg);
  background: var(--fg);
  transition: transform calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq13-sf .fire:active {
  transform: scale(.96);
}

.uvq13-sf button:focus-visible,.uvq13-sf a:focus-visible,.uvq13-sf input:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

.uvq13-sf .dl {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 5;
  box-sizing: border-box;
  transform: translate(-50%,-46%) scale(.95);
  opacity: 0;
  pointer-events: none;
  transition: transform calc(0.35s / var(--k)) cubic-bezier(.22,1,.36,1),opacity calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq13-sf.open .dl {
  transform: translate(-50%,-50%);
  opacity: 1;
  pointer-events: auto;
}

.uvq13-sf .dl {
  width: 13em;
  padding: 1em;
  border-radius: 1em;
  color: #1c1917;
  background: radial-gradient(circle at .6em .6em,#57534e .14em,#e7e5e4 .17em,transparent .26em),radial-gradient(circle at calc(100% - .6em) .6em,#57534e .14em,#e7e5e4 .17em,transparent .26em),radial-gradient(circle at .6em calc(100% - .6em),#57534e .14em,#e7e5e4 .17em,transparent .26em),radial-gradient(circle at calc(100% - .6em) calc(100% - .6em),#57534e .14em,#e7e5e4 .17em,transparent .26em),repeating-linear-gradient(90deg,rgba(255,255,255,.08) 0 1px,rgba(0,0,0,.04) 1px 2px,transparent 2px 4px),linear-gradient(155deg,color-mix(in srgb,var(--c2) 50%,#fff),var(--c2) 45%,color-mix(in srgb,var(--c2) 70%,#000));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.6),inset 0 -2px 0 rgba(0,0,0,.2),0 1.4em 2.4em -1em rgba(0,0,0,.6);
}

.uvq13-sf .dl.bad {
  animation: uvq13-sf-s calc(0.45s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq13-sf .tp {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 .2em .6em;
}

.uvq13-sf .tp p {
  margin: 0;
  font-size: .68em;
  font-weight: 800;
  letter-spacing: .09em;
  text-transform: uppercase;
  text-shadow: 0 1px 0 rgba(255,255,255,.5);
}

.uvq13-sf .led {
  width: .6em;
  height: .6em;
  border-radius: 50%;
  background: #7f1d1d;
  box-shadow: inset 0 0 .12em #000,0 1px 0 rgba(255,255,255,.5);
}

.uvq13-sf .bad .led {
  background: #ef4444;
  box-shadow: 0 0 .6em #ef4444;
}

.uvq13-sf .ok .led {
  background: var(--c1);
  box-shadow: 0 0 .6em var(--c1);
}

.uvq13-sf .dp {
  display: flex;
  justify-content: center;
  gap: .8em;
  padding: .75em;
  border-radius: .5em;
  background: #0f1110;
  box-shadow: inset 0 .15em .35em #000,0 1px 0 rgba(255,255,255,.55);
}

.uvq13-sf .dp i {
  width: .7em;
  height: .7em;
  border-radius: 50%;
  background: #262a27;
  transition: background .12s,box-shadow .12s;
}

.uvq13-sf .dp i.on {
  background: #fbbf24;
  box-shadow: 0 0 .5em #fbbf24;
}

.uvq13-sf .bad .dp i {
  background: #ef4444;
  box-shadow: 0 0 .5em #ef4444;
}

.uvq13-sf .ok .dp i {
  background: var(--c1);
  box-shadow: 0 0 .5em var(--c1);
}

.uvq13-sf .st {
  height: 1.3em;
  margin: .35em 0 .5em;
  text-align: center;
  font-size: .66em;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.uvq13-sf .st span {
  display: none;
}

.uvq13-sf .bad .st .e {
  display: inline;
  color: #b91c1c;
}

.uvq13-sf .ok .st .o {
  display: inline;
  color: #15803d;
}

.uvq13-sf .kp {
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: .55em .4em;
  justify-items: center;
}

.uvq13-sf .kp button {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: grid;
  place-items: center;
  width: 2.6em;
  height: 2.6em;
  border-radius: 50%;
  font: 800 1em/1 ui-monospace,"SF Mono",Menlo,Consolas,monospace;
  color: #292524;
  background: radial-gradient(circle at 35% 28%,rgba(255,255,255,.95),transparent 48%),linear-gradient(160deg,#f5f5f4,#a8a29e);
  box-shadow: inset 0 -.15em .2em rgba(0,0,0,.25),0 .2em 0 #57534e,0 .3em .5em rgba(0,0,0,.35);
  text-shadow: 0 1px 0 rgba(255,255,255,.8);
  transition: transform .06s cubic-bezier(.25,.1,.25,1),box-shadow .06s cubic-bezier(.25,.1,.25,1);
}

.uvq13-sf .kp button:active,.uvq13-sf .kp button.dn {
  transform: translateY(.17em);
  box-shadow: inset 0 -.05em .1em rgba(0,0,0,.25),0 .03em 0 #57534e,0 .1em .2em rgba(0,0,0,.35);
}

.uvq13-sf .kp svg {
  width: 1.1em;
  height: 1.1em;
}

.uvq13-sf .kp button:focus-visible {
  outline: 2px solid #1c1917;
  outline-offset: 2px;
}

.uvq13-sf .hn {
  width: max-content;
  margin: .9em auto 0;
  padding: .25em .6em;
  font: italic 600 .64em/1.3 Georgia,serif;
  color: #78350f;
  background: #fde68a;
  box-shadow: 0 .1em .2em rgba(0,0,0,.2);
  transform: rotate(-2deg);
}

@keyframes uvq13-sf-s {
  0%,100% {
    transform: translate(-50%,-50%);
  }
  20%,60% {
    transform: translate(calc(-50% - .35em),-50%);
  }
  40%,80% {
    transform: translate(calc(-50% + .35em),-50%);
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq13-sf,.uvq13-sf *,.uvq13-sf *::before,.uvq13-sf *::after {
    animation-duration: .01ms!important;
    animation-iteration-count: 1!important;
    transition-duration: .01ms!important;
  }
}
`;

// Interacción en JavaScript del DOM: la misma que en la pestaña JS.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function setup(el: any) {
  const fire=el.querySelector(".fire"),scr=el.querySelector(".scr"),pnl=el.querySelector(".dl");let tms=[];const later=(f,ms)=>tms.push(setTimeout(f,ms));
const foc=(t,ms)=>later(()=>{const n=typeof t==="string"?el.querySelector(t):t;n&&n.focus({preventScroll:true})},ms||0);
const isOpen=()=>el.classList.contains("open");
const open=u=>{if(isOpen())return;el.classList.add("open");pnl.inert=false;fire&&fire.setAttribute("aria-expanded","true");reset();u&&foc('.kp button',320)};
const close=()=>{if(!isOpen())return;el.classList.remove("open");pnl.inert=true;fire&&fire.setAttribute("aria-expanded","false");;fire&&fire.focus({preventScroll:true})};
fire&&fire.addEventListener("click",()=>isOpen()?close():open(true));scr&&scr.addEventListener("click",()=>close());
el.addEventListener("keydown",e=>{if(!isOpen())return;if(e.key==="Escape"){e.preventDefault();e.stopPropagation();close()}else if(e.key==="Tab"){const f=[...pnl.querySelectorAll('button:not([disabled]),input:not([disabled]),textarea,a[href],[tabindex="0"]')].filter(x=>x.getClientRects().length);if(!f.length){e.preventDefault();return}const a=f[0],z=f[f.length-1],ac=document.activeElement;if(e.shiftKey&&(ac===a||!pnl.contains(ac))){e.preventDefault();z.focus()}else if(!e.shiftKey&&(ac===z||!pnl.contains(ac))){e.preventDefault();a.focus()}}});
pnl.inert=true;later(()=>open(false),500);const dl=el.querySelector(".dl"),ds=[...el.querySelectorAll(".dp i")],kb=[...el.querySelectorAll(".kp button")];let code="",busy=false;const OK="2580";
const paint=()=>ds.forEach((d,i)=>d.classList.toggle("on",i<code.length));
const reset=()=>{code="";busy=false;dl.classList.remove("bad","ok");paint()};
const press=k=>{if(busy)return;if(k==="x"){close();return}if(k==="del"){code=code.slice(0,-1);paint();return}if(code.length>=4)return;code+=k;paint();if(code.length===4){busy=true;if(code===OK){dl.classList.add("ok");later(close,1300)}else{dl.classList.add("bad");later(reset,900)}}};
kb.forEach(b=>b.addEventListener("click",()=>press(b.dataset.k)));
el.addEventListener("keydown",e=>{if(!isOpen())return;const k=/^[0-9]$/.test(e.key)?e.key:e.key==="Backspace"?"del":null;if(!k)return;e.preventDefault();press(k);const b=kb.find(x=>x.dataset.k===k);if(b){b.classList.add("dn");later(()=>b.classList.remove("dn"),110)}});return()=>tms.forEach(clearTimeout)
}

export default function OvSafeKeypad() {
  const ref = useRef<HTMLDivElement>(null);

  useEffect(() => {
    const el = ref.current?.firstElementChild;
    return el ? setup(el) : undefined;
  }, []);

  return (
    <>
      <style>{css}</style>
      <div
        ref={ref} style={{
          "--c1": "#22c55e",
          "--c2": "#b6b0a8",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq13-sf"><div className="pg" aria-hidden="true"><i className="h"></i><i></i><i></i><i></i><i></i><i className="s"></i></div><button type="button" className="fire" aria-haspopup="dialog">Open the safe</button><div className="scr"></div><div className="dl" role="dialog" aria-modal="true" aria-labelledby="uvq13-sf-t"><div className="tp"><p id="uvq13-sf-t">Enter the code</p><i className="led" aria-hidden="true"></i></div><div className="dp" aria-hidden="true"><i></i><i></i><i></i><i></i></div><p className="st" aria-live="assertive"><span className="e">Wrong code</span><span className="or">Unlocked</span></p><div className="kp"><button type="button" data-k="1">1</button><button type="button" data-k="2">2</button><button type="button" data-k="3">3</button><button type="button" data-k="4">4</button><button type="button" data-k="5">5</button><button type="button" data-k="6">6</button><button type="button" data-k="7">7</button><button type="button" data-k="8">8</button><button type="button" data-k="9">9</button><button type="button" data-k="del" aria-label="Clear"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M9 5.5h10.5A1.5 1.5 0 0 1 21 7v10a1.5 1.5 0 0 1-1.5 1.5H9L3 12zM12 9.5l5 5M17 9.5l-5 5" /></svg></button><button type="button" data-k="0">0</button><button type="button" data-k="x" aria-label="Close"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M7 7l10 10M17 7L7 17" /></svg></button></div><p className="hn">Hint: the middle column</p></div></div>
      </div>
    </>
  );
}
```

## Prompt for AI assistants

Paste this into ChatGPT, Claude, Cursor, v0 or Lovable to adapt the block to your stack (Tailwind, Vue, Svelte…):

````text
I want to add the “Safe keypad dialog” block (Overlays) from AIMRAN Library to my project.

## What it is
A brushed metal panel with keys that sink, indicator lights and a shake when the code is wrong.

## Chosen settings
- Main color: #22c55e
- Secondary color: #b6b0a8
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)
- Text: "Introduce el código"

## What I need
1. Add it to my project with the same look and animation as the reference code: same sizes, colours, radii, shadows, timings and easing.
2. It is built with plain HTML and CSS (the reference wraps it in a React component with its CSS). If my project uses something else (Vue, Svelte, Astro, plain HTML…), translate it without losing any behaviour. If I use Tailwind, turn the styles into classes; if not, keep the CSS in its own file.
3. Expose the settings above as props (or CSS variables) with those values as defaults.
4. Make it work well on phones: nothing that depends only on hover, touch targets of at least 44 px and no overflow on 320 px screens.
5. Make it look right in light and dark mode.
6. Keep it accessible: semantic HTML, roles and aria-* where needed, visible focus and keyboard support.
7. Respect prefers-reduced-motion: with reduced motion, no big animations but the same end result.

## Reference code
```tsx
// @ts-nocheck: setup() es JavaScript del DOM sin tipos, el mismo de la pestaña JS.
import { useEffect, useRef, type CSSProperties } from "react";

const css = `
.uvq13-sf {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  position: relative;
  width: 22em;
  height: 21em;
  border-radius: 1.2em;
  overflow: hidden;
  background: color-mix(in srgb,var(--fg) 3%,var(--bg));
  box-shadow: 0 0 0 1px color-mix(in srgb,var(--fg) 9%,transparent);
}

.uvq13-sf .pg {
  position: absolute;
  inset: 0;
  padding: 1.2em;
  display: grid;
  align-content: start;
  gap: .55em;
}

.uvq13-sf .pg i {
  height: .6em;
  border-radius: 1em;
  background: color-mix(in srgb,var(--fg) 6%,transparent);
}

.uvq13-sf .pg .h {
  width: 45%;
  height: 1em;
  margin-bottom: .4em;
  background: color-mix(in srgb,var(--fg) 12%,transparent);
}

.uvq13-sf .pg .s {
  width: 60%;
}

.uvq13-sf .scr {
  position: absolute;
  inset: 0;
  z-index: 4;
  background: rgba(10,12,20,.38);
  opacity: 0;
  pointer-events: none;
  transition: opacity calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq13-sf.open .scr {
  opacity: 1;
  pointer-events: auto;
}

.uvq13-sf .fire {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: absolute;
  right: 1em;
  top: 1em;
  z-index: 1;
  padding: .55em .95em;
  border-radius: 2em;
  font-size: .78em;
  font-weight: 650;
  color: var(--bg);
  background: var(--fg);
  transition: transform calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq13-sf .fire:active {
  transform: scale(.96);
}

.uvq13-sf button:focus-visible,.uvq13-sf a:focus-visible,.uvq13-sf input:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

.uvq13-sf .dl {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 5;
  box-sizing: border-box;
  transform: translate(-50%,-46%) scale(.95);
  opacity: 0;
  pointer-events: none;
  transition: transform calc(0.35s / var(--k)) cubic-bezier(.22,1,.36,1),opacity calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq13-sf.open .dl {
  transform: translate(-50%,-50%);
  opacity: 1;
  pointer-events: auto;
}

.uvq13-sf .dl {
  width: 13em;
  padding: 1em;
  border-radius: 1em;
  color: #1c1917;
  background: radial-gradient(circle at .6em .6em,#57534e .14em,#e7e5e4 .17em,transparent .26em),radial-gradient(circle at calc(100% - .6em) .6em,#57534e .14em,#e7e5e4 .17em,transparent .26em),radial-gradient(circle at .6em calc(100% - .6em),#57534e .14em,#e7e5e4 .17em,transparent .26em),radial-gradient(circle at calc(100% - .6em) calc(100% - .6em),#57534e .14em,#e7e5e4 .17em,transparent .26em),repeating-linear-gradient(90deg,rgba(255,255,255,.08) 0 1px,rgba(0,0,0,.04) 1px 2px,transparent 2px 4px),linear-gradient(155deg,color-mix(in srgb,var(--c2) 50%,#fff),var(--c2) 45%,color-mix(in srgb,var(--c2) 70%,#000));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.6),inset 0 -2px 0 rgba(0,0,0,.2),0 1.4em 2.4em -1em rgba(0,0,0,.6);
}

.uvq13-sf .dl.bad {
  animation: uvq13-sf-s calc(0.45s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq13-sf .tp {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 .2em .6em;
}

.uvq13-sf .tp p {
  margin: 0;
  font-size: .68em;
  font-weight: 800;
  letter-spacing: .09em;
  text-transform: uppercase;
  text-shadow: 0 1px 0 rgba(255,255,255,.5);
}

.uvq13-sf .led {
  width: .6em;
  height: .6em;
  border-radius: 50%;
  background: #7f1d1d;
  box-shadow: inset 0 0 .12em #000,0 1px 0 rgba(255,255,255,.5);
}

.uvq13-sf .bad .led {
  background: #ef4444;
  box-shadow: 0 0 .6em #ef4444;
}

.uvq13-sf .ok .led {
  background: var(--c1);
  box-shadow: 0 0 .6em var(--c1);
}

.uvq13-sf .dp {
  display: flex;
  justify-content: center;
  gap: .8em;
  padding: .75em;
  border-radius: .5em;
  background: #0f1110;
  box-shadow: inset 0 .15em .35em #000,0 1px 0 rgba(255,255,255,.55);
}

.uvq13-sf .dp i {
  width: .7em;
  height: .7em;
  border-radius: 50%;
  background: #262a27;
  transition: background .12s,box-shadow .12s;
}

.uvq13-sf .dp i.on {
  background: #fbbf24;
  box-shadow: 0 0 .5em #fbbf24;
}

.uvq13-sf .bad .dp i {
  background: #ef4444;
  box-shadow: 0 0 .5em #ef4444;
}

.uvq13-sf .ok .dp i {
  background: var(--c1);
  box-shadow: 0 0 .5em var(--c1);
}

.uvq13-sf .st {
  height: 1.3em;
  margin: .35em 0 .5em;
  text-align: center;
  font-size: .66em;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.uvq13-sf .st span {
  display: none;
}

.uvq13-sf .bad .st .e {
  display: inline;
  color: #b91c1c;
}

.uvq13-sf .ok .st .o {
  display: inline;
  color: #15803d;
}

.uvq13-sf .kp {
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: .55em .4em;
  justify-items: center;
}

.uvq13-sf .kp button {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: grid;
  place-items: center;
  width: 2.6em;
  height: 2.6em;
  border-radius: 50%;
  font: 800 1em/1 ui-monospace,"SF Mono",Menlo,Consolas,monospace;
  color: #292524;
  background: radial-gradient(circle at 35% 28%,rgba(255,255,255,.95),transparent 48%),linear-gradient(160deg,#f5f5f4,#a8a29e);
  box-shadow: inset 0 -.15em .2em rgba(0,0,0,.25),0 .2em 0 #57534e,0 .3em .5em rgba(0,0,0,.35);
  text-shadow: 0 1px 0 rgba(255,255,255,.8);
  transition: transform .06s cubic-bezier(.25,.1,.25,1),box-shadow .06s cubic-bezier(.25,.1,.25,1);
}

.uvq13-sf .kp button:active,.uvq13-sf .kp button.dn {
  transform: translateY(.17em);
  box-shadow: inset 0 -.05em .1em rgba(0,0,0,.25),0 .03em 0 #57534e,0 .1em .2em rgba(0,0,0,.35);
}

.uvq13-sf .kp svg {
  width: 1.1em;
  height: 1.1em;
}

.uvq13-sf .kp button:focus-visible {
  outline: 2px solid #1c1917;
  outline-offset: 2px;
}

.uvq13-sf .hn {
  width: max-content;
  margin: .9em auto 0;
  padding: .25em .6em;
  font: italic 600 .64em/1.3 Georgia,serif;
  color: #78350f;
  background: #fde68a;
  box-shadow: 0 .1em .2em rgba(0,0,0,.2);
  transform: rotate(-2deg);
}

@keyframes uvq13-sf-s {
  0%,100% {
    transform: translate(-50%,-50%);
  }
  20%,60% {
    transform: translate(calc(-50% - .35em),-50%);
  }
  40%,80% {
    transform: translate(calc(-50% + .35em),-50%);
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq13-sf,.uvq13-sf *,.uvq13-sf *::before,.uvq13-sf *::after {
    animation-duration: .01ms!important;
    animation-iteration-count: 1!important;
    transition-duration: .01ms!important;
  }
}
`;

// Interacción en JavaScript del DOM: la misma que en la pestaña JS.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function setup(el: any) {
  const fire=el.querySelector(".fire"),scr=el.querySelector(".scr"),pnl=el.querySelector(".dl");let tms=[];const later=(f,ms)=>tms.push(setTimeout(f,ms));
const foc=(t,ms)=>later(()=>{const n=typeof t==="string"?el.querySelector(t):t;n&&n.focus({preventScroll:true})},ms||0);
const isOpen=()=>el.classList.contains("open");
const open=u=>{if(isOpen())return;el.classList.add("open");pnl.inert=false;fire&&fire.setAttribute("aria-expanded","true");reset();u&&foc('.kp button',320)};
const close=()=>{if(!isOpen())return;el.classList.remove("open");pnl.inert=true;fire&&fire.setAttribute("aria-expanded","false");;fire&&fire.focus({preventScroll:true})};
fire&&fire.addEventListener("click",()=>isOpen()?close():open(true));scr&&scr.addEventListener("click",()=>close());
el.addEventListener("keydown",e=>{if(!isOpen())return;if(e.key==="Escape"){e.preventDefault();e.stopPropagation();close()}else if(e.key==="Tab"){const f=[...pnl.querySelectorAll('button:not([disabled]),input:not([disabled]),textarea,a[href],[tabindex="0"]')].filter(x=>x.getClientRects().length);if(!f.length){e.preventDefault();return}const a=f[0],z=f[f.length-1],ac=document.activeElement;if(e.shiftKey&&(ac===a||!pnl.contains(ac))){e.preventDefault();z.focus()}else if(!e.shiftKey&&(ac===z||!pnl.contains(ac))){e.preventDefault();a.focus()}}});
pnl.inert=true;later(()=>open(false),500);const dl=el.querySelector(".dl"),ds=[...el.querySelectorAll(".dp i")],kb=[...el.querySelectorAll(".kp button")];let code="",busy=false;const OK="2580";
const paint=()=>ds.forEach((d,i)=>d.classList.toggle("on",i<code.length));
const reset=()=>{code="";busy=false;dl.classList.remove("bad","ok");paint()};
const press=k=>{if(busy)return;if(k==="x"){close();return}if(k==="del"){code=code.slice(0,-1);paint();return}if(code.length>=4)return;code+=k;paint();if(code.length===4){busy=true;if(code===OK){dl.classList.add("ok");later(close,1300)}else{dl.classList.add("bad");later(reset,900)}}};
kb.forEach(b=>b.addEventListener("click",()=>press(b.dataset.k)));
el.addEventListener("keydown",e=>{if(!isOpen())return;const k=/^[0-9]$/.test(e.key)?e.key:e.key==="Backspace"?"del":null;if(!k)return;e.preventDefault();press(k);const b=kb.find(x=>x.dataset.k===k);if(b){b.classList.add("dn");later(()=>b.classList.remove("dn"),110)}});return()=>tms.forEach(clearTimeout)
}

export default function OvSafeKeypad() {
  const ref = useRef<HTMLDivElement>(null);

  useEffect(() => {
    const el = ref.current?.firstElementChild;
    return el ? setup(el) : undefined;
  }, []);

  return (
    <>
      <style>{css}</style>
      <div
        ref={ref} style={{
          "--c1": "#22c55e",
          "--c2": "#b6b0a8",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq13-sf"><div className="pg" aria-hidden="true"><i className="h"></i><i></i><i></i><i></i><i></i><i className="s"></i></div><button type="button" className="fire" aria-haspopup="dialog">Open the safe</button><div className="scr"></div><div className="dl" role="dialog" aria-modal="true" aria-labelledby="uvq13-sf-t"><div className="tp"><p id="uvq13-sf-t">Enter the code</p><i className="led" aria-hidden="true"></i></div><div className="dp" aria-hidden="true"><i></i><i></i><i></i><i></i></div><p className="st" aria-live="assertive"><span className="e">Wrong code</span><span className="or">Unlocked</span></p><div className="kp"><button type="button" data-k="1">1</button><button type="button" data-k="2">2</button><button type="button" data-k="3">3</button><button type="button" data-k="4">4</button><button type="button" data-k="5">5</button><button type="button" data-k="6">6</button><button type="button" data-k="7">7</button><button type="button" data-k="8">8</button><button type="button" data-k="9">9</button><button type="button" data-k="del" aria-label="Clear"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M9 5.5h10.5A1.5 1.5 0 0 1 21 7v10a1.5 1.5 0 0 1-1.5 1.5H9L3 12zM12 9.5l5 5M17 9.5l-5 5" /></svg></button><button type="button" data-k="0">0</button><button type="button" data-k="x" aria-label="Close"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M7 7l10 10M17 7L7 17" /></svg></button></div><p className="hn">Hint: the middle column</p></div></div>
      </div>
    </>
  );
}
```

Give me the complete final code, ready to paste, and tell me in one line where to put it in my project.
````
