:root {
  --totem-keyboard-accent: #007483;
  --totem-keyboard-accent-dark: #005d69;
  --totem-keyboard-green: #8fb51d;
  --totem-keyboard-surface: #eef4f5;
  --totem-keyboard-key: #ffffff;
  /* La botonera equivale a unos 23 cm en el tótem. 14.5dvh desplaza el
     teclado aproximadamente 10 cm hacia abajo en esa misma pantalla. */
  --totem-keyboard-lower-offset: 14.5dvh;
  --totem-keyboard-bottom: max(0px, calc(var(--totem-dock-height, 33.333dvh) - var(--totem-keyboard-lower-offset)));
}

.totem-keyboard {
  position: fixed;
  right: 0;
  /* Superpone el teclado sobre la parte alta de la botonera, dejando visible
     su franja inferior y acercando las teclas unos 10 cm al usuario. */
  bottom: var(--totem-keyboard-bottom);
  left: 0;
  z-index: 2147483647;
  display: none;
  padding: 10px 14px max(12px, env(safe-area-inset-bottom));
  border-top: 3px solid var(--totem-keyboard-accent);
  background: rgba(238, 244, 245, 0.99);
  box-shadow: 0 -12px 34px rgba(7, 27, 31, 0.24);
  font-family: Montserrat, Arial, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  max-height: calc(100dvh - var(--totem-keyboard-bottom) - 12px);
  overflow-y: auto;
}

.totem-keyboard--parent-document {
  bottom: 0;
  max-height: calc(100dvh - 12px);
}

.totem-keyboard.is-open {
  display: block;
}

.totem-keyboard__header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  max-width: 1180px;
  margin: 0 auto 9px;
}

.totem-keyboard__context {
  min-width: 0;
}

.totem-keyboard__eyebrow {
  display: block;
  color: var(--totem-keyboard-accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.totem-keyboard__target {
  display: block;
  overflow: hidden;
  color: #17282c;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.totem-keyboard__tabs {
  display: flex;
  gap: 6px;
}

.totem-keyboard__tab,
.totem-keyboard__close {
  min-height: 44px;
  border: 2px solid #b8cbce;
  border-radius: 10px;
  background: #fff;
  color: #28484e;
  cursor: pointer;
  font: 900 14px/1 Montserrat, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.totem-keyboard__tab {
  min-width: 82px;
  padding: 0 14px;
}

.totem-keyboard__tab.is-active {
  border-color: var(--totem-keyboard-accent);
  background: var(--totem-keyboard-accent);
  color: #fff;
}

.totem-keyboard__close {
  min-width: 48px;
  padding: 0 14px;
  font-size: 24px;
}

.totem-keyboard__keys {
  display: flex;
  flex-direction: column;
  gap: 7px;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
}

.totem-keyboard__row {
  display: flex;
  justify-content: center;
  gap: 7px;
}

.totem-keyboard__key {
  flex: 1 1 0;
  min-width: 0;
  min-height: 55px;
  padding: 6px 8px;
  border: 1px solid #cad8da;
  border-radius: 9px;
  background: var(--totem-keyboard-key);
  box-shadow: 0 2px 0 rgba(7, 27, 31, 0.13);
  color: #102d33;
  cursor: pointer;
  font: 900 clamp(17px, 2vw, 25px)/1 Montserrat, Arial, sans-serif;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.totem-keyboard__key:active {
  transform: translateY(2px);
  box-shadow: none;
}

.totem-keyboard__key--letter {
  border-color: #82bec7;
  background: #ffffff;
  color: #123b43;
}

.totem-keyboard__key--number {
  border-color: #68aeba;
  background: #dceff3;
  color: #075d6b;
}

.totem-keyboard__key--symbol {
  border-color: #ddb45f;
  background: #fff1cf;
  color: #6b4700;
}

.totem-keyboard__key--utility {
  flex-grow: 1.35;
  background: #dbe7e9;
  color: #21454c;
  font-size: clamp(13px, 1.4vw, 18px);
}

.totem-keyboard__key--space {
  flex-grow: 5;
}

.totem-keyboard__key--done {
  flex-grow: 1.55;
  border-color: var(--totem-keyboard-green);
  background: var(--totem-keyboard-green);
  color: #fff;
}

.totem-keyboard__key--shortcut {
  flex-grow: 1.35;
  background: #dff1f3;
  color: var(--totem-keyboard-accent-dark);
  font-size: clamp(13px, 1.35vw, 17px);
}

.totem-keyboard__key--provider {
  min-height: 46px;
  border-color: #8db5d5;
  background: #e8f2fb;
  color: #174f7d;
  font-size: clamp(12px, 1.25vw, 16px);
}

.totem-keyboard__key--provider::before {
  content: "Sugerencia";
  display: block;
  margin-bottom: 3px;
  color: #55758f;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.totem-keyboard__key[data-key-action="caps"].is-active {
  border-color: var(--totem-keyboard-accent);
  background: var(--totem-keyboard-accent);
  color: #fff;
}

@media (max-width: 760px) {
  .totem-keyboard {
    padding-right: 7px;
    padding-left: 7px;
  }

  .totem-keyboard__header {
    grid-template-columns: 1fr auto;
    gap: 7px;
  }

  .totem-keyboard__context {
    grid-column: 1 / -1;
  }

  .totem-keyboard__tabs {
    overflow-x: auto;
  }

  .totem-keyboard__tab {
    min-width: 70px;
    padding: 0 9px;
  }

  .totem-keyboard__row {
    gap: 4px;
  }

  .totem-keyboard__key {
    min-height: 48px;
    padding: 5px 3px;
    border-radius: 7px;
    font-size: clamp(14px, 4vw, 20px);
  }
}
