.virtual-keyboard {
  flex-shrink: 0;
  background: var(--bg-secondary);
  backdrop-filter: blur(var(--blur-amount));
  -webkit-backdrop-filter: blur(var(--blur-amount));
  border-top: 1px solid var(--border-color);
  padding: 8px 8px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}

.key-row {
  display: flex;
  gap: 5px;
  margin-bottom: 5px;
  align-items: center;
}

.key-row:last-child {
  margin-bottom: 0;
}

/* ── Physical key style ──────────────────────────── */
.key {
  flex: 0 0 auto;
  min-width: 40px;
  height: 36px;
  border: 1px solid var(--key-border);
  border-bottom: 2px solid var(--key-depth);
  border-radius: var(--radius-xs);
  background: var(--key-bg);
  background-image: linear-gradient(180deg, var(--key-bg-highlight) 0%, transparent 60%);
  color: var(--text-primary);
  font-size: 0.77rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 7px;
  -webkit-user-select: none;
  user-select: none;
  transition: background var(--transition-fast), transform var(--transition-fast), border-color var(--transition-fast);
}

.key:active {
  background: var(--key-active-bg);
  background-image: none;
  border-bottom-width: 1px;
  transform: translateY(1px);
}

.key.modifier {
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.key.modifier.active {
  background: var(--accent);
  background-image: var(--accent-gradient);
  color: #fff;
  border-color: transparent;
  border-bottom-color: var(--accent-dim);
  box-shadow: 0 0 14px var(--accent-glow);
}

.key.modifier.locked {
  background: var(--accent);
  background-image: var(--accent-gradient);
  color: #fff;
  border-color: transparent;
  border-bottom-color: var(--accent-dim);
  box-shadow: 0 0 0 2px var(--accent-hover), 0 0 20px var(--accent-glow);
}

.key.shortcut {
  font-family: 'SF Mono', 'JetBrains Mono', 'Menlo', monospace;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-secondary);
  min-width: 36px;
}

.key-spacer {
  flex: 1;
}

/* ── Input row — pill style ──────────────────────── */
.input-row {
  gap: 6px;
}

.text-input {
  flex: 1;
  height: 38px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.9rem;
  padding: 0 16px;
  outline: none;
  font-family: 'SF Mono', 'JetBrains Mono', 'Menlo', monospace;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.text-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.text-input::placeholder {
  color: var(--text-dimmed);
}

.send-key {
  width: 38px;
  height: 38px;
  min-width: unset;
  padding: 0;
  flex-shrink: 0;
  border-radius: var(--radius-pill);
  background: var(--accent);
  background-image: var(--accent-gradient);
  color: #fff;
  border: none;
  border-bottom: none;
  font-size: 1.05rem;
  font-weight: 700;
  box-shadow: 0 2px 10px var(--accent-glow);
}

.send-key:active {
  background-image: none;
  background: var(--accent-dim);
  transform: scale(0.92);
  box-shadow: none;
}

/* ── Landscape ───────────────────────────────────── */
@media (max-height: 500px) {
  .key {
    height: 30px;
    min-width: 34px;
    font-size: 0.68rem;
  }
  .text-input, .send-key {
    height: 30px;
  }
  .virtual-keyboard {
    padding: 4px;
  }
  .key-row {
    margin-bottom: 3px;
  }
}

/* ── Desktop ─────────────────────────────────────── */
@media (min-width: 1024px) {
  .virtual-keyboard {
    padding: 10px 20px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }

  .key {
    min-width: 46px;
    height: 34px;
  }

  .key:hover {
    background-image: none;
    background: var(--key-active-bg);
    border-color: var(--accent);
  }

  .text-input {
    max-width: 640px;
  }

  .send-key:hover {
    filter: brightness(1.12);
    box-shadow: 0 4px 16px var(--accent-glow);
  }
}

.key-row.shortcut-keys {
  overflow-x: auto;
  flex-wrap: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.key-row.shortcut-keys::-webkit-scrollbar { display: none; }
.key-row.shortcut-keys .key.shortcut { min-width: 32px; padding: 0 5px; }

.keyboard-toggle {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; height: 28px;
  background: var(--bg-secondary); border: none;
  border-top: 1px solid var(--border-color);
  color: var(--text-dimmed); font-size: 0.72rem;
  cursor: pointer; flex-shrink: 0;
}
.keyboard-toggle:hover { color: var(--text-secondary); background: var(--bg-tertiary); }
.virtual-keyboard.collapsed .key-row:not(.input-row) { display: none; }
