/* ===== Basis: Desktop/Allgemein ===== */
.vk {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 12px;
  z-index: 9999;
  background: rgba(255,255,255,0.98);
  backdrop-filter: blur(6px);
  border: 1px solid #ddd;
  border-radius: 12px;
  padding: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  max-width: min(90em, 96vw);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.vk.is-hidden { display: none; }

.vk-header { display:flex; justify-content: space-between; align-items:center; padding: 6px 8px 0; }
.vk-title { font-size: 12px; color:#666; }
.vk-close { border:none; background:transparent; cursor:pointer; font-size:18px; padding:6px 8px; border-radius:8px; }

.vk-row { display: flex; gap: 6px; margin: 6px 4px; justify-content: center; }
.vk-key {
  min-width: 36px;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 10px;
  text-align: center;
  cursor: pointer;
  line-height: 1.15;
  font-size: 16px;
  background: #f8f8f8;
  -webkit-tap-highlight-color: transparent;
}
.vk-key:active { background: #eee; }
.vk-key[data-wide="1"] { min-width: 105px; }
.vk-key[data-xwide="1"] { min-width: 120px; }

/* verhindert Ghost-Clicks & 300ms-Delay auf Touch */
.vk-key, .vk-close { touch-action: manipulation; }

/* ===== Mobile/Tablet: allgemeine Touch-Geräte ===== */
@media (pointer: coarse), (hover: none) {
  .vk {
    /* Safe-Area unten (iOS) + mehr Platz am Rand */
    left: 0; right: 0; transform: none;
    margin: 0 auto;
    bottom: calc(8px + env(safe-area-inset-bottom));
    max-width: 100vw;
    padding: 10px;
    border-radius: 14px;
    /* bei sehr kleinen Höhen Scroll erlauben */
    max-height: min(44vh, 420px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .vk-header { padding: 4px 6px 2px; }
  .vk-title { font-size: 13px; }
  .vk-row   { gap: 8px; margin: 8px 6px; }

  .vk-key {
    /* dynamische Größe mit Clamp (skaliert zwischen 18–22px) */
    font-size: clamp(18px, 2.4vw, 22px);
    min-width: clamp(44px, 7.5vw, 64px);
    padding: 14px 16px;
    border-radius: 12px;
  }

  .vk-key[data-wide="1"]  { min-width: clamp(110px, 28vw, 180px); }
  .vk-key[data-xwide="1"] { min-width: clamp(140px, 36vw, 220px); }
  .vk-close { font-size: 22px; padding: 8px 10px; }
}

/* ===== Hochformat (Portrait) – mehr Höhe, größere Tasten ===== */
@media (pointer: coarse) and (orientation: portrait) {
  .vk {
    max-height: min(50vh, 520px);
  }
  .vk-key {
    font-size: clamp(20px, 2.8vw, 24px);
    min-width: clamp(48px, 8.5vw, 70px);
    padding: 16px 18px;
  }
  .vk-key[data-wide="1"]  { min-width: clamp(120px, 34vw, 200px); }
  .vk-key[data-xwide="1"] { min-width: clamp(160px, 44vw, 260px); }
}

/* ===== Querformat (Landscape) – kompakter, damit nichts überläuft ===== */
@media (pointer: coarse) and (orientation: landscape) {
  .vk {
    bottom: calc(6px + env(safe-area-inset-bottom));
    max-height: min(42vh, 380px);
  }
  .vk-row   { gap: 6px; margin: 6px 4px; }
  .vk-key {
    font-size: clamp(18px, 2.0vw, 20px);
    min-width: clamp(40px, 6.2vw, 58px);
    padding: 12px 14px;
  }
  .vk-key[data-wide="1"]  { min-width: clamp(96px, 24vw, 160px); }
  .vk-key[data-xwide="1"] { min-width: clamp(120px, 32vw, 220px); }
}

/* ===== Sehr kleine Geräte (? 360px Breite) – Notfallmodus ===== */
@media (max-width: 360px) {
  .vk { padding: 8px; }
  .vk-row { gap: 5px; margin: 5px 3px; }
  .vk-key {
    font-size: 18px;
    min-width: 40px;
    padding: 12px 12px;
  }
  .vk-key[data-wide="1"]  { min-width: 96px; }
  .vk-key[data-xwide="1"] { min-width: 120px; }
}
