/* Project keyboard — self-contained, no external assets. */
#project-keyboard {
  width: 100%;
  max-width: 500px;
  margin-inline: auto;
  isolation: isolate;
}

.pk-stage {
  --pk-turn-x: 0deg;
  --pk-turn-y: 0deg;
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  padding: 35px 20px 45px;
  box-sizing: border-box;
  perspective: 1400px;
  -webkit-tap-highlight-color: transparent;
}

.pk-stage::before {
  content: "";
  position: absolute;
  inset: 25% 0 3%;
  z-index: -1;
  background: radial-gradient(ellipse at center, rgba(130, 238, 210, .085), transparent 66%);
  filter: blur(15px);
  pointer-events: none;
}

.pk-shell {
  position: relative;
  width: 100%;
  box-sizing: border-box;
  padding: 17px 18px 25px;
  border: 1px solid #4b4f4e;
  border-radius: 23px;
  background: linear-gradient(145deg, #353a39 0%, #242827 44%, #1d2120 100%);
  box-shadow: 0 2px 0 #616663 inset, 0 -1px 0 #0a0d0c inset,
    0 4px 0 #171b19, 0 8px 0 #161a18, 0 12px 0 #151917,
    0 16px 0 #111513, 7px 31px 24px rgba(0, 0, 0, .45),
    22px 53px 46px rgba(0, 0, 0, .25);
  transform: rotateX(calc(38deg + var(--pk-turn-x))) rotateY(var(--pk-turn-y)) rotateZ(-15deg);
  transform-style: preserve-3d;
  transition: transform .2s ease-out;
}

.pk-shell::before,
.pk-shell::after {
  content: "";
  position: absolute;
  width: 4px;
  height: 4px;
  bottom: 9px;
  border-radius: 50%;
  background: #151917;
  box-shadow: 0 1px 0 #515651;
}
.pk-shell::before { left: 12px; }
.pk-shell::after { right: 12px; }

.pk-board-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 2px 17px;
  color: #a1aaa4;
  font: 500 8px/1.1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .17em;
}
.pk-board-status { display: flex; align-items: center; gap: 6px; }
.pk-board-status i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #82eed2;
  box-shadow: 0 0 7px rgba(130, 238, 210, .4);
}

.pk-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px 12px;
  transform-style: preserve-3d;
}

.pk-key {
  --pk-cap: #363c39;
  --pk-edge: #1e2521;
  --pk-ink: #d5dcd5;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  aspect-ratio: 1 / 1.02;
  min-width: 0;
  padding: 14px 4px 10px;
  border: 1px solid rgba(255, 255, 255, .09);
  border-top-color: rgba(255, 255, 255, .16);
  border-radius: 12px;
  background: linear-gradient(150deg, rgba(255, 255, 255, .04), rgba(0, 0, 0, .06)), var(--pk-cap);
  color: var(--pk-ink);
  font: inherit;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  transform: translateZ(12px);
  box-shadow: 0 1px 1px rgba(255, 255, 255, .035) inset,
    0 -2px 2px rgba(0, 0, 0, .16) inset,
    0 2px 0 var(--pk-edge), 0 5px 0 var(--pk-edge), 0 8px 0 var(--pk-edge),
    0 9px 0 rgba(0, 0, 0, .8), 0 13px 7px rgba(0, 0, 0, .42);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease, filter .2s ease;
}

.pk-key[data-id="agentcrop"] {
  --pk-cap: #e5e6d9;
  --pk-edge: #a9afa0;
  --pk-ink: #262e29;
  border-color: #f1f1e7;
}
.pk-key[data-id="dna"] {
  --pk-cap: #7cb9a5;
  --pk-edge: #43745f;
  --pk-ink: #152f24;
}
.pk-key[data-id="zhixing"] {
  --pk-cap: #9ec9ba;
  --pk-edge: #618d7c;
  --pk-ink: #223b30;
}
.pk-key[data-id="archive"] { --pk-ink: #97b7a7; }

.pk-key-number {
  position: absolute;
  top: 8px;
  left: 9px;
  opacity: .55;
  font: 500 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.pk-key-icon { width: 29px; height: 29px; display: block; opacity: .94; }
.pk-key-icon svg { display: block; width: 100%; height: 100%; overflow: visible; }
.pk-key-name {
  max-width: 100%;
  white-space: nowrap;
  font-size: clamp(8px, 1.1vw, 11px);
  line-height: 1.1;
  font-weight: 600;
  letter-spacing: -.035em;
}

.pk-key:focus-visible {
  outline: 2px solid #b9ffe8;
  outline-offset: 5px;
  z-index: 2;
}
.pk-key:active,
.pk-key.is-pressed {
  transform: translateZ(5px) translateY(5px);
  box-shadow: 0 1px 1px rgba(255, 255, 255, .04) inset,
    0 -2px 2px rgba(0, 0, 0, .1) inset,
    0 2px 0 var(--pk-edge), 0 3px 0 rgba(0, 0, 0, .75),
    0 5px 3px rgba(0, 0, 0, .4);
  transition-duration: .08s;
}

.pk-board-footer {
  position: absolute;
  left: 50%;
  bottom: 7px;
  transform: translateX(-50%);
  color: #8b948d;
  font: 500 6px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .25em;
  white-space: nowrap;
}
.pk-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (hover: hover) and (pointer: fine) {
  .pk-key:hover:not(:active):not(.is-pressed) {
    transform: translateZ(22px) translateY(-3px);
    filter: brightness(1.12);
    border-color: rgba(170, 236, 208, .48);
    box-shadow: 0 1px 1px rgba(255, 255, 255, .08) inset,
      0 -2px 2px rgba(0, 0, 0, .1) inset,
      0 3px 0 var(--pk-edge), 0 6px 0 var(--pk-edge), 0 9px 0 var(--pk-edge),
      0 11px 0 rgba(0, 0, 0, .6), 0 17px 11px rgba(0, 0, 0, .4);
  }
}

@media (max-width: 640px) {
  .pk-stage { padding: 45px 37px 52px; }
  .pk-shell { padding: 12px 12px 21px; border-radius: 17px; }
  .pk-board-header { font-size: 6px; margin-bottom: 12px; letter-spacing: .12em; }
  .pk-grid { gap: 11px 8px; }
  .pk-key { border-radius: 9px; gap: 5px; padding: 13px 2px 8px; }
  .pk-key-number { top: 6px; left: 6px; font-size: 7px; }
  .pk-key-icon { width: 24px; height: 24px; }
  .pk-key-name { font-size: clamp(7px, 2.05vw, 10px); }
  .pk-board-footer { font-size: 5px; letter-spacing: .2em; }
}

@media (max-width: 390px) {
  .pk-stage { padding-inline: 27px; }
  .pk-shell { padding-inline: 10px; }
  .pk-grid { column-gap: 7px; }
  .pk-key-icon { width: 21px; height: 21px; }
}

@media (prefers-reduced-motion: reduce) {
  .pk-shell { transform: rotateX(32deg) rotateZ(-12deg); transition: none; }
  .pk-key { transition: none; }
}
